Runtime error generally occurs when you are trying to access an invalid memory location. Generally in C++, you should always take some extra size of arrays so that such issues don’t arise.
If we change line 9 of your code from int chess[8][8]; to int chess[10][10];, your code starts giving Wrong Answer. Thus the runtime error is resolved, but there is still an error in your logic somewhere.
To debug that, here is the test case on which your code is failing after the above change.