https://www.codechef.com/viewsolution/30954985
Can someone have a look at my code and see why it is giving RE.