#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vct vector
#define vi vct<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
///............x...........///
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)), (X).end())
#define ft cout << "for test" << endl;
#define read(v, a, n) for (int i = a; i < n; i++)cin >> v[i];
#define print(v) for (auto it : v){cout << it << ' ';cout << endl;}
#define PI acos(-1.0)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test, cs = 1;cin >> test;while (test--)
#define casep cout << "Case " << cs++ << ":"<<endl;
///................function.....................///
#define D(a) (double)(a)
#define sqr(a) (a * a)
#define siz(s) (int)(s.size())
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define Min(a) *min_element(all(a))
#define Max(a) *max_element(all(a))
#define mod 1000000007
///.........Graph.........///
int X[] = {1, -1, 0, 0};
int Y[] = {0, 0, 1, -1};
///........constant........///
const int N = 2e5 + 5;
ll ok(ll mid, ll x){
    if(mid*(mid-1)+mid-1<=x){
        ///cout<<mid<<" "<<mid*(mid-1)+mid-1<<endl;
        return 1;
    }
    return 0;
}
int main()
{
    FIO;
    t_c{
        ll x,y;
        cin>>x>>y;
        ll hi=y,lo=2;
        if(x<=lo){
            cout<<0<<endl;
            continue;
        }
        ll ans=0;
        while (lo<=hi)
        {
            ll mid = (hi+lo)/2;
            if(ok(mid,x)){
                lo=mid+1;
                ans=mid;
            }
            else hi=mid-1;
        }
        ll result=0;
        if(ans==0){
            for(ll i=max(y,2ll); i<=min(y,x-1); i++){
                ll tmp = x/(i+1);
                result += tmp;
            }
        }
        else{
            result = (ans*(ans-1))/2ll;
            y = min(y,x-1);
            ans++;
            while(ans<=y){
                hi = y,lo=ans;
                ll now = x/(ans+1),nxt;
                while (lo<=hi)
                {
                    ll mid = (lo+hi)/2;
                    ll mm = x/(mid+1);
                    if(mm==now){
                        nxt = mid;
                        lo = mid+1;
                    }
                    else hi=mid-1;
                }
                result += now*(nxt-ans+1);
                ans=nxt+1;
            }
        }
        cout<<result<<endl;
        
    }
}