Problem7242--CodeChef MANYSUMS - Distinct Pair Sums

7242: CodeChef MANYSUMS - Distinct Pair Sums

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

You are given a range of integers $\{L, L+1, \ldots, R\}$. An integer X is said to be reachable if it can be represented as a sum of two not necessarily distinct integers in this range. 
Find the number of distinct reachable integers.

Input

The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains two space-separated integers L and R.

Output

For each test case, print a single line containing one integer — the number of reachable integers.

Constraints

$1≤T≤10^5$
$1 \leq L \leq R \leq 10^6$

Sample 1 Input

2
2 2
2 3

Sample 1 Output

1
3
Example case 1: The only reachable integer is 2 + 2 = 4.
Example case 2: 4, 5 and 6 are reachable, since 2+2=4, 2+3=5 and 3+3=6.

HINT

题目来源:CodeChef MANYSUMS

Source/Category