#include <bits/stdc++.h>
using namespace std;


using ll = long long;


int main(){
    ll t;cin >> t;
    while(t--){
        ll L, R;cin >> L >> R;
        if(2 * L > R){
            cout<<0<<endl;
        }else{
            cout<<(R - 2 * L + 2) * ((R - 2 * L) + 1) / 2<<endl;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	int n; cin >> n;
	vector<P> v(n);
	rep(i, n)
		cin >> v[i].first >> v[i].second;
	int ans = 0;
	for(int i = 0 ; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			double x, y;
			x = v[i].first - v[j].first;
			y = v[i].second - v[j].second;
			if ((y / x) >= -1 && (y / x) <= 1)
				ans++;
		}
	}
	cout << ans << endl;
	return (0);
}