What's wrong with this code...some testcases are not passing

@Narasimha,
https://ide.codingblocks.com/s/230906 corrected code.
Use long instead of int.