#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define mx LLONG_MAX
#define mn LLONG_MIN
#define pii pair<int,int>
#define vi vector<int>
#define vll vector< long long >
#define pb push_back
#define pop pop_back
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define f(i,a,n) for( i = a ; i < n ; i++)
using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin); 
        freopen ("output.txt","w",stdout);
    #endif
    fastIO;
    int TESTS = 1; 
    cin>>TESTS;
    while(TESTS--)
    {
        ll i,x,y,ans = 0; cin>>x>>y;
        ll q = sqrt(x); if(q*q < x) q++;
        q = min(q,y);
        for(i = 1 ; i<q ; i++)
            ans+=max(0*1ll , min(y , x/i - 1) - i);
        cout<<ans<<endl;
    } 
}