Need Help in GIFTSRC

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

It is passing the sample test case but upon submitting it, I get WA. Can anyone tell me whats wrong with the code.

You don’t need to print the input string. Just comment it out or remove it and it will work.

I think I had added that just to check if the input string is read correctly and then forgot to remove it. Sorry for that.