K-reverse probelm

this code doesnt run on hacker blocks ques(it just shows running but doesnt complete it ever) https://hack.codingblocks.com/contests/c/916/1287 and when i submit it gives wrong answer