#include <bits/stdc++.h>

using namespace std;
#define sz(a) int(a.size())
#define ll  long long int
#define mod (long long)(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define F first
#define S second

ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2)%mod;
    res=((res)*(res)) %mod;
    if(p%2)
        res=(res*n)%mod ;
    return res ;
}

// freopen ("myfile.txt","w",stdout);


int main()
{
    ENGZ;
    int t;
    cin>>t ;
    while(t--)
    {
        ll n , m , ans = 0 ,a = 1;
        cin>>n >>m ;
        while(a*(a+1)<n && a<m)
        {
            ans+=min(m,n/a-1)-a;
            a++ ;
        }
        cout<<ans <<endl ;
    }

    return 0;
}
