#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
using namespace std;
int t;
int l,r;
int main(){
	scanf("%d",&t);
	while(t--){
		scanf("%d %d",&l,&r);
		int ed=r-l;
		ll ans=0;
		if(ed>=l) ans+=(ll)(r-l*2+2)*(r-l*2+1)/2;
		else ans=0;
		printf("%lld\n",ans);
	}
	return 0;
}

//i:r-l-i+1
//3,

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i,j,n) for(long long i = j ; i < n ; ++i)
#define ones(x) __builtin_popcount(x)
#define endl '\n'
 
using namespace std;
//using namespace __gnu_pbds;
typedef long long  ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef deque<int> di;
typedef deque<long long> dll;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long>> vpll;
/*typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
const ll N = 5e5 + 100;
const ll M = 1e5 + 100;
const ll inf = 1e9;

void solve(){
	ll l,r; cin >> l >> r;
	if(r < 2*l){
		cout << 0 << endl;
		return;
	}
	ll x = r -(2*l-1);
	cout << (x*(x+1))/2 << endl;
}
 
int main(){
	fastio;
	int t; cin >> t;
	while(t--) solve();
	
	return 0;
}