Why test cases failing? || Given example case passed

Checked the code for the given example in the question. Working fine.
Why the test cases failing?
Help me detect the mistake I am making.

Changed int to Long. 1 case passed. Still 1 case failing.

take input like String x = sc.next();