#include <bits/stdc++.h>
 
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION cout << fixed << setprecision(20);
 
using namespace std;

void solve() {
    ll x, y;
    cin >> x >> y;

    ll ans = 0, b;
    for (b = 1; b <= y; b++) {
        ll lamda = x / (b + 1);
        if (lamda < b) {
            break;
        } else {
            ans += b - 1;
        }
    }

    while (b <= y) {
        // brute force value of lamda
        ll lamda = x / (b + 1);
        if (!lamda) break;
        
        ll bb = x / lamda;
        while ((bb + 1) * lamda > x) {
            bb--;
        }

        if (bb < b) break;

        bb = min(bb, y);
        ans += max(0LL, (bb - b + 1) * lamda);
        b = bb + 1;
    }

    cout << ans << "\n";
}

int main() {
    FASTIO;
    PRECISION; 

    int t = 1;
    cin >> t;

    for (int i = 1; i <= t; i++) {
        solve();
    }
}