#include <bits/stdc++.h>
//#include <iostream>
//#include <vector>
//#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll M = 998244353;

ll sum(ll mn, ll mx) {
	return (mx - mn + 1)*(mn + mx) / 2;
}

int main() {
	int t, l, r;
	cin >> t;
	rep(i, t) {
		cin >> l >> r;
		int mx;
		mx = r - l - l + 1;
		mx = max(mx, 0);

		cout << sum(1, mx) << endl;
	}
}
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t; cin>> t;
    for (int i=0; i<t; i++) {
        long long l, r;
        cin>> l >> r;
        if (r >= 2*l) {
            cout << (r + 2 - 2 * l) * (r + 1 - 2 * l) / 2 << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    return 0;
}