#include "bits/stdc++.h"
 using namespace std;
 
typedef long long ll;
 
 
void solve() {
 
    int _; cin >> _;
    while(_--) {
        ll a, b; cin >> a >> b;
        ll ans = 0;
        ll t = sqrt(a + 1);
        if(t > b) {
            t = b;
            ans += t * (t - 1) / 2;
        }
        else {
            ans += t * (t - 1) / 2;
            for (ll l = t + 1, r; l <= min(a, b); l = r + 1) {
                if (a / (l + 1) == 0) break;
                else r = min(b, min(a, a / (a / (l + 1)) - 1));
                ans += (r - l + 1) * (a / (l + 1));
            }
        }
        cout << ans << endl;
    }
}
 
signed main() {
    solve();
}
