#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void solve()
{
    ll x,y; cin >> x >> y;
    ll ans=0;
    for (ll i=1; i*i<x; i++){
        ans+=max(0LL,min(y,x/i-1)-i);
    }
    cout << ans << '\n';
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t; cin >> t;
    while (t--) solve();
}
