https://www.codechef.com/viewsolution/33596543
can anyone find any error? any test case it is not working?