Unusual Runtime error in May Cook Off Problem

Hi all, I participated in May Cook-Off Div3, And while submitting a solution for this (Problem Name: Last Problem), I’m getting an unusual runtime error. I have set the matrice limits as per the constraints and my code doesn’t seem to go out of bounds.

Here is my code: Code.
If anyone could find the bug, it would be of great help.

The problem works well on my local machine and it doesn’t crash.