BSTOPS | Runtime Error (SIGSEGV)

My answer runs fine on my computer, but when I submit it gives “RUNTIME ERROR (SIGSEGV)”. Please tell whats wrong with my code.

Link to the problem: https://www.codechef.com/problems/BSTOPS

Link to my solution: https://www.codechef.com/viewsolution/32138639