#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t;
    cin >> t;
    while (t--) {
        ll x, y;
        cin >> x >> y;
        if (x <= 2 || y <= 1) {
            cout << 0 << '\n';
            continue;
        }

        ll l = 2;
        ll r = y;
        while (l <= r) {
            ll mid = (l + r) / 2;
            if (x / (mid + (ll)1) >= mid - 1) {
                l = mid + 1;
            } else
                r = mid - 1;
        }

        // 최대로 다 가질 수 있는 b값
        ll ans = r * (r - (ll)1) / (ll)2;
        ll now = r + (ll)1;

        while (now <= y) {
            l = now;
            r = y;
            ll cnt = x / (now + (ll)1);
            if (cnt == 0) break;
            while (l <= r) {
                ll mid = (l + r) / 2;
                if (x / (mid + (ll)1) != cnt) {
                    r = mid - 1;
                } else
                    l = mid + 1;
            }

            ans += cnt * (ll)(r - now + 1);
            now = r + 1;
        }
        cout << ans << '\n';
    }
}
