#include<bits/stdc++.h>
#define ll         long long int
#define ff         first
#define ss         second
#define pb         push_back
#define srt(v)     sort(v.begin(),v.end())
#define rsrt(v)    sort(v.rbegin(),v.rend())
#define mkp(a,b)   make_pair(a,b)
#define scf2(a,b)  scanf("%lld%lld",&a,&b)
#define scf(a)     scanf("%lld",&a)
#define pf(a)      printf("%lld\n",a)
#define maxn       100005
#define MOD        100000000
using namespace std;



int main()
{

    ll tc;
    scf(tc);

    while(tc--)
    {
        ll a , b , ans = 0;
        scf2(a , b);

        if(a<=b)b = a-1;

        for(ll i=1;i<b;i++)
        {
            ll kop = b - i , joss = a/i;

            joss-=(i+1);

            ll mn = min(kop , joss);

            if(mn>0)ans+=mn;
            else break;
        }

        pf(ans);
    }


}
