#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define ld  long double
 
const int INF = 1e9 + 7;

void solve(){
	ll L , R; cin >> L >> R;
	ll ans = 0;
	if(R < 2 * L) cout << 0 << endl;
	else{
		ll numAs = R - 2 * L + 1;
		ll ans = numAs * (R + 2 * L) / 2;
		ans -= (2 * L * numAs);
		ans += numAs;
		cout << ans << endl;
	}
}
 
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    int tt = 1;
    cin >> tt;
    for(int tc = 1; tc <= tt; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
}
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
int main (){
    LL T, l, r;
    cin >> T;
    while (T--){
        scanf("%lld%lld", &l, &r);
        LL m = r - 2 * l + 1;
        if (m <= 0){
            printf("0\n");
        }
        else{
            printf("%lld\n", (m + 1) * m / 2);
        }
    }
    return 0;
}
//n: n - 2l + 1 (2l ~ r)
// m = r - 2l + 1