Problem: AtCoder ABC 237 A — Not Overflow [English] · 한국어 · 日本語
The input value can be much larger than a 32-bit signed integer, so read it as a long. A signed 32-bit integer ranges from Integer.MIN_VALUE (-2^31) through Integer.MAX_VALUE (2^31 - 1), inclusive. Compare the long value against both endpoints; print Yes exactly when it lies within that range, and No otherwise. Using inclusive comparisons correctly accepts both boundary values and rejects values just below or above them.
Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
long value = Long.parseLong(input.readLine().trim());
System.out.println(Integer.MIN_VALUE <= value && value <= Integer.MAX_VALUE ? "Yes" : "No");
}
}