SOLVE
LATER
iMagine yourself as a loyal fan of one popular company that creates all kind of gadgets. After all of these years "that company" has created n different mobile phones, enumerated from 1 to n and powering devices, enumerated the same way. Due to the production policy, phones can be charged only by devices with phone's version not exceeding charger's version. Moreover, phone's and device's total version has to be equal or less than k. For example, if phone's version is a and charger's is b, then the phone can be charged if \(a \le b\) and \(a + b \le k\).
You are so loyal, you have already bought every device — all n phones and n chargers! Moreover, you are fond of tea and taking photos with your cool mug, but with your effort phone discharges in a couple of hours, and you have to take a phone and a charger with you to the tea-shop and, of course, a pair of different ones.
Your task is to find the number of days, you can visit the tea-shop with a different pair of phone and a charger, which you haven't brought before, so that you can charge the phone, according to the rules mentioned above.
Input format
The first line of input contains one integer t — number of test cases.
For each case, single line contains two integers n and k — number of mobile phones and versions' maximum sum, respectively.
Constraints
\(1 \le t \le 10000\)
\( 1 \le n, k \le 2 \cdot 10^9 \)
Output format
For each case, output on a separate line a single integer — number of different pairs of a phone and a charger, satisfying the rules described in the statement.
Let the first number in a pair be phone's version and second — charger's.
Then, for the first test case, there are four days, you can go to the tea-shop with a different pair of phone and a charger, which you haven't brought before, so that you can charge the phone, according to the rules mentioned in the statement:
Next, for the second test case, versions' maximum sum is 1, therefore no pair of a charger and a phone exists.
Finally, for the third test case, there are two days: