Chef and Chain

whats wrong with my code…as they are giving the write output to the given input but the codechef compiler says its wrong answer…

actually There are a lot of test cases in the codechef, so it is possible that your program may give an incorrect answer for some testcases or it may be due to your data type