#include <bits/stdc++.h>
using namespace std;
int main(){
	long long t;cin>>t;
	while(t--){
		long long l,r;cin>>l>>r;
		if(l*2ll>r)cout<<0<<endl;
		else{
			long long d=r-l;
			long long f=d-l+1;
			long long g=f*(f+1);
			long long h=g/2;
			cout<<h<<endl;
		}
	}
}
#include <bits/stdc++.h>

using namespace std ;

#define i64 int64_t // typecast using i64(x)
#define int int64_t 
#define ld long double
#define f(i,a,b) for(int i = int(a); i < int(b); ++i)
#define endl '\n'

#define PQ priority_queue
#define LB lower_bound  
#define UB upper_bound
#define fr first
#define sc second

#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define sz(x) ((int)(x).size())
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))

//#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) {
  cout<<a; 
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cout<<"{";
  __p(a.first);
  cout<<",";
  __p(a.second);
  cout<<"}\n"; 
}
template<typename T>
void __p(std::vector<T> a) {
  cout<<"{";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cout<<",}\n"[it+1==a.end()]; 
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout<<name<<" : ";
  __p(arg1);
  cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cout.write(names,comma-names)<<" : ";
  __p(arg1);
  cout<<" | ";
  __f(comma+1,args...);
}
//#endif

void setIO(string s = "") {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  cin.exceptions(cin.failbit); 
  if(sz(s)){
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
  }
}
void solve(){
  int L, R ; cin >> L >> R ;
  int temp = max(int(0),R - 2*L + 1) ;
  cout << temp*(temp+1)/2 << endl ;
}
signed main(){
  setIO() ;
  int T ; cin >> T ;
  f(_,0,T){
    solve() ;
  }
}