
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <deque>
#include <iomanip>
#define ll long long
#define ld long double

using namespace std;

void solve() {
    ll L, R;
    cin >> L >> R;
    ll left = R - L;
    if (left < L) {
        cout << "0\n";
        return;
    }
    ll c = R - L - L + 1;
    ll ans = (c + 1) * c / 2;
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin >> t;
    for (int ij = 0; ij < t; ++ij) {
        solve();
    }
}
//*/
/*
Description
@authors Magneto
@date    2021-02-13 17:36:16
@version 
*/
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long
#define l long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define pf pop.front()
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " = " << x << endl;
#define lcm(a,b) a*b/__gcd(a,b)
//__builtin_popcount = int
//__builtin_popcountl = long int
//__builtin_popcountll = long long

using namespace std;


void solve()
{
int a,b;
cin>>a>>b;

int left = a + a;
int right = b;
if(left > right){
cout<<0<<endl;
return;
}

ll n = right - left + 1; 

ll ans = n*(n+1)/2;
cout<<ans<<endl;
}


int32_t main()
{
FAST
l T=1;
cin>>T;
while(T--)
{
solve();
}
}








