
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
vector<ll> solve(ll t, vector<ll> l, vector<ll> r) {
    vector<ll> res(t);

    for(ll i = 0ll; i < t; i++) {
        ll count = max(r[i] - 2ll * l[i] + 1ll, 0ll);
        res[i] = count * (count + 1ll) / 2ll;
    }
    return res;
}
int main()
{
	std::ios::sync_with_stdio(false);
	ll t;
    cin >> t;
    vector<ll> l(t), r(t);
    for(int i = 0; i < t; i++) {
        cin >> l[i] >> r[i];
    }
    vector<ll> res =  solve(t, l, r);
    for(ll i=0ll;i<t; i++) {
        cout << res[i] << endl;
    }
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std ;

void solve()
{
      ll l , r ; cin>>l>>r ;
      if(r-l*2>=0){
         cout<< (r-2*l+1) * (r-2*l+2) / 2 <<endl;
      }else {
         cout<< 0 <<endl;
      }
}





signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t ;
    cin>>t ;
    while(t--){
        solve() ;
    }
    return 0 ;
}

