Equal Beauty Problem

https://www.codechef.com/viewsolution/53006020
Here is my submitted code for the EqBeauty problem… Please have a look.
Please explain in which particular case my code won’t work… I have tried multiple times… it seems totally fine to me.