i need help with my Code

Hi everyone
I DON’T understand why i get a Runtime Error(NZEC) but when i compile it with Cmd then its true
here is my Code:
https://www.codechef.com/viewsolution/21714070

Runtime errors won’t necessarily happen on every data set. So it’s not unusual that, say, accessing outside the bounds of an array will only happen with some input possibilities.

In this case I think you need to start by re-reading the question, however. In particular noting “infinite chess board”.

thank you for your Answer
but i still dont unterstand what i should exactly do