It’s not my code, so I won’t post it here, but it uses BufferedReader. To read a line with 1 integer it does:
int x = Integer.parseInt(reader.readLine());
To read a line with 2 integers it does:
StringTokenizer st = new StringTokenizer(reader.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken());
After that it does some simple O(n log n) computations and prints the answer. But it keeps getting TLE. Is this problem not solvable in Java? Is there a faster input method that needs to be usued?