#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 1000043
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
#define pll pair<ll,ll>

using namespace std;
void solve(){
    ll x,y;
    cin >> x >> y;
    ll ans = 0;
	for(ll i = 1; i*i < x; i++)ans+=max(min(y,x/i-1)-i,0LL);
    cout << ans << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    test{
        solve();
    }
}

