What is wrong with my approach it is failing all test cases(question included)

image

use long long int on line 28 & 29
rest code is correct