Wrong answer in marbles

Can anyone point out what went wrong in this ? Here is my solution https://www.codechef.com/viewsolution/15437851

Mate

You should add details to your question, like what’s your approach…

You expect everyone to go through your code to find a bug for you…

I don’t code in C language, but i still wanna help, so

Please explain your code…