I am getting 0 in some test cases I dont know why pls help

Please Correct My code

https://codeforces.com/contest/1443/problem/B

Its a very easy problem but stuck with some error test cases not passing and my logic is correct

you can take help from this code

Reference Code