#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,x,n) for(int i = x;i <= n;++i)	


int main() 
{
	int T;scanf("%d",&T);
	while(T--)
	{
		ll x,y;scanf("%lld%lld",&x,&y);
		ll res = 0;
		for(ll k = 1;k <= x / k;++k)	res += max(0ll,min(x / k - 1,y) - k);
		printf("%lld\n",res);
	}
	return 0;
}