BSTOPS giving runtime error even when working properly in custom input mode

I tested my code in my own computer and also tested it in the codechef compiler using my own test cases. Both worked well and give proper output, however it doesn’t work when I run it without giving custom input and submit it. Please help. @anukul
Link to my code: https://www.codechef.com/viewsolution/25046075