#C3151. Reverse Integer

    ID: 46547 Type: Default 1000ms 256MiB

Reverse Integer

Reverse Integer

Given a signed 32-bit integer \(x\), your task is to reverse its digits. If the reversed integer overflows the range \([-2^{31}, 2^{31}-1]\), you must output \(0\). The solution must read input from stdin and write the output to stdout.

For example, if the input is 123, the output should be 321. If the input is -123, the output should be -321. If reversing the integer causes overflow, output 0.

inputFormat

The input is provided on a single line containing one integer, \(x\), which may be positive, negative, or zero.

outputFormat

Output a single integer: the reversed form of \(x\) if it is within the signed 32-bit integer range, otherwise output 0.

## sample
123
321

</p>