Failing for hidden test cases

My code is working for given test cases but failing for hidden test cases.

Can someone pls help me

https://www.codechef.com/problems/CAKEDOOM

https://www.codechef.com/viewsolution/25018179