Why the code 1 is working fine while the code 2 below it is not working fine?

Why the code 1 is working fine while the code 2 below it is not working fine?



Problem: -
http://codeforces.com/problemset/problem/263/A

hello @cbcao263
I think both the code should work.

btw answer will always be absolute value of ( coordinate of 1 - coordinate of center).

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.