What is wrong with my code?

please help
it passed only one test case
and gave either wa or run error for others
what is wrong with this code? it is giving correct output for test case given in example