This problem is from recent Round #672 (Div. 2). I did a stupid miscalculation (-_-). One of the dimension-size of the array was supposed to be around 3200 but I assigned the size 160. But funny thing is it still got accepted (offline solve btw).
Later I understood the mistake and submitted the code again which I think is correct. 2nd Submission link
Now, why 1st solution is accepted? Is this something which can be exploited again? Or am I just lucky as there's also another dimension after it which might've persisted the result without conflicting.