I have been trying to do UVA "Ahoy, Pirates!" but it seems there is an error somewhere. I have downloaded code that gives AC to test against my solution on test cases generated by a program I wrote and compared the outputs with WinMerge, only to see that they are identical.
One curious thing I noted was that changing M from 101 to 301 in the code converts the Wrong Answer into a Runtime Error, which baffles me. Would you please help me in finding the error in my code, or is there an error somewhere else?
Edit: Ran it through the test cases generated by my generator using VS 2012 compilation with array bounds checking, not a single error reported.