Help for lunchtime div2 problem 2?

its giving wrong on answer 2 and same logic in cpp of my friend is accepted??? Solution: 49344701 | CodeChef