#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define mod 1000000007
 
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int t;cin >> t;
	while(t--){
		ll l,r,count;
		cin >> l >> r;
		if(r/2<l)count =0;
		else count = r-l-l+1;
		cout << count*(count+1)/2 << '\n';
		}
}

#include "bits/stdc++.h"
using namespace std;
using LLI = long long;
#define INF 999999999
#define MOD 1000000007
#define FOR(i, s, e) for(LLI i = s, i##_lim = (e); i < i##_lim; i++)
#define FORR(i, s, e) for(LLI i = s-1, i##_lim = (e); i##_lim<=i; i--)
#define REP(i, n) FOR(i,0,n)
#define REPR(i, n) FORR(i,n,0)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define Mat2(type,name,h,w,def) vector<vector<type>> name(h,vector<type>(w, def))
#define Mat3(type,name,h,w,d,def) vector<vector<vector<type>>> name(h,vector<vector<type>>(w, vector<int>(d,def)))
// int 2.14E±9    LLIi 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	int t;
	cin >> t;
	REP(i, t)
	{
		LLI l, r;
		cin >> l >> r;
		if (r < l * 2)
		{
			cout << 0 << endl;
		}
		else
		{

			cout << (r - l * 2 + 1) * (r - l * 2 + 2) / 2 << endl;
		}
	}

	return 0;
}