#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define REPA(i,j) for(int i=1;i<=j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
const int INF=1<<30;
inline void read(int &x){
//	short neg=1;
	x=0;
	char c=getchar();
	/*while(c<'0'||c>'9'){
		if(c=='-')neg=-1;
		c=getchar();
	}*/
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+(c^48),c=getchar();
	}
//	x*=neg;
}
int t;
int main(void){
	cin>>t;
	REP(ii,t){
		ll L,R;
		cin>>L>>R;
		ll ans;
		if(R-L<L)ans=0;
		else ans=(R-L+1)*(R-2*L+1)-R*(R-2*L+1)/2;
		cout<<ans<<endl;
	}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>

using namespace std;
int t,l,r;
long long c,ans;
int main()
{
	int i,j;
	scanf("%d",&t);
	for (i=1;i<=t;i++)
	{
		scanf("%d%d",&l,&r);
		if (l+l>r) {printf("0\n"); continue;}
		c=r-l-l;
		ans=(c+1+1)*(c+1)/2;
		printf("%lld\n",ans);
	}
	return 0;
}