#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int t;
    cin>>t;
    while(t--){
        ll x,y;
        cin>>x>>y;
        ll ans=0;
        for(ll i=2;true;i++){
            ll s=i*i-1;
            ll e=(y+1)*(i-1);
            //cout<<s<<' '<<e<<endl;
            if(x<s)break;
            if(e<s)break;
            if(x>=e){
                ans+=y-i+1;
                continue;
            }
            ll v=x-s;
            ll add=v/(i-1);
            ans+=add+1;
            //cout<<ans<<endl;
        }
        cout<<ans<<endl;
    }
    return 0;
}
