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. CodeChef: Practical coding for everyone
I have applied every solution i can think of.
Problem Link - BSTOPS Problem - CodeChef
Please help me.