Fast A+B
Time limit1sMemory limit512 MB
Read T pairs of integers from fast input and print each sum on its own line.
- Level
Easy1 of 10
- Topics
- Implementation, Math, Array
- Solved
- No attempts yet
Problem
Before you work through loop problems in bulk, check how your program reads input and writes output. A slow method can time out once there are many lines to read or print.
In C++, if you use cin and cout, apply both cin.tie(NULL) and sync_with_stdio(false), and print the newline character \n instead of endl. Once you do that, stop mixing in the C style calls scanf, printf, puts, getchar, and putchar.
In Java, you can use BufferedReader and BufferedWriter instead of Scanner and System.out.println. Call BufferedWriter.flush once at the very end.
In Python, you can use sys.stdin.readline instead of input. It keeps the newline at the end of the line, so add .rstrip() when you store the string.
The input stream and the output stream are separate, so you do not have to read every test case before printing anything. Reading one case and printing its answer right away is fine.
Each test case gives two integers and . Print for every test case.
Input
The first line contains the number of test cases . is at most . Each of the next lines contains two integers and , with and .
Output
For each test case, print on its own line, in the order the cases are given.