#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,n) repi(i,0,n)
#define repi(i,a,n) for(ll i=a;i<(ll)n;++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
void YN(bool a) { cout << (a ? "Yes" : "No") << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
void show(){ cout << endl; }
template <class Head, class... Tail>
void show(Head&& head, Tail&&... tail){ cout << head << " "; show(std::forward<Tail>(tail)...); }
template<class T> inline void showall(T& a) { for(auto v:a) cout<<v<<" "; cout<<endl; }

void solve()
{
  ll t;
  cin >> t;
  rep(ti, t)
  {
    ll l, r;
    cin >> l >> r;

    ll ans = 0;
    if (r < l * 2) ans = 0;
    else if (r == l * 2) ans = 1;
    else {
      r -= (l - 1) * 2 + 1;
      ans = (r) * (r + 1) / 2;
    }
    show(ans);
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}
#include<bits/stdc++.h>
using namespace std;
int t;
long long ans;
long long l,r;
int main()
{
	cin>>t;
	for(int o=1;o<=t;o++)
	{
		cin>>l>>r;
		if(r<2*l)
		{
			printf("0\n");
			continue;
		}
		ans=(r-l+1ll)*(r-2ll*l+1ll);
		ans-=r*(r-2ll*l+1ll)/2ll;
		cout<<ans<<endl;
	}
	return 0;
}