Need Help! My my code successfully works with many testcases that i can think of.There is no problem with run & compile panel of codechef but when i am submitting my code it says WA. The Question Code is BSTOPS

I am posting my solution link. https://www.codechef.com/viewsolution/37184379
I have applied every solution i can think of.
Problem Link - https://www.codechef.com/problems/BSTOPS
Please help me.