Wrong answer in few test cases

Why is it showing wrong answer in few test cases?

Link to the code: https://ide.codingblocks.com/s/245320

tally with this code