Large average
89% Success9422 Attempts10 Points2s Time Limit256MB Memory1024 KB Max Code

The average is defined as the sum of all the numbers divided (integer division) by the total numbers that are included to determine the average. Therefore, your task is to determine the average of all naturals number from \(L\) to \(R\) both inclusive.

For example, all the natural numbers from \(L = 3\) to \(R = 8\) are \([3, 4, 5, 6, 7, 8]\), then the average is \((3 + 4 + 5 + 6 + 7 + 8) / 6 = 33 / 6 = 5\).

Input format

  • First line: \(t\) denoting the number of test cases
  • Next \(t\) lines: Two space-separated integers \(L\) and \(R\) as described in the problem statement

Output format

Print \(t\) lines containing a single integer that denotes the required answer.

Constraints

\(1 \leq t \leq 10^5\)

\(0 \leq L \leq R \leq 10^{18}\)

Examples
Input
3
3 8
0 10
1234 5678
Output
5
5
3456
Explanation

Refer the example provided in the problem.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...
Results