Simple input failing test cases 1 to 3

Hi,
I spent a lot of time analyzing and coding this simple input problem and most of my test cases seem to pass.But the test cases defined in coding block is failing.

Can someone please help what is wrong with my below code :

Submission #3635285

please help me.

Thanks,
Pradeep

Please save your code on cb.lk/ide and send the link.