#include <bits/stdc++.h>
using namespace std;
#define ll  long long
const int maxn=2e5+30;
int n;
pair<int,int> a[maxn];
bool canwin(int x,ll po)
{
  
	for(int i=0;i<n;i++)
	{
		if((po>=a[i].first)and(i!=x))
		{
			po=po+a[i].first;
		}
		if((po<a[i].first)and(i!=x))
		{
			return false;
		}
	}
	return true;
}
int main()
{
	#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
    #endif
    std::ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
    	ll x,y;
    	cin>>x>>y;
    	ll res=0;
    	
    	for(ll b=1;b<=min((ll)sqrt(x),y);b++)
    	{
    		res+=min(b*b,x)/(b+1);
		}
			ll res1=0;
    	
    	for(ll b=1;b<=sqrt(x);b++)
    	{
    		res1+=max((ll)0,min((ll)y,(ll)x/b-(ll)1)-b);
		}
		cout<<res1<<endl;
    }
}