#include <iostream>


using namespace std;

template<typename T>
inline T read() {
    T s = 0, f = 1; char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) {s = (s << 3) + (s << 1) + ch - 48; ch = getchar();}
    return s * f;
}
#define gl() read<ll>()
#define gn() read<int>()

#define ll long long
#define INF 0x3f3f3f3f

bool debug;

#define DEBUG if (debug)

int main() {
    int T = gn();
    while (T--) {
        ll x = gl(), y = gl();
        ll ans = 0;
//         for (ll b = 2; b <= y; b++) {
//             if (x >= (b + 1) * (b - 1)) {
//                 ans += b - 1;
//             }
//             else {
//                 ans += x / (b + 1);
//                 cout << b << ": ";
//                 cout << x / (b + 1) << '\n';
//             }
//         }
//        return 0;

        if (y == 1) {
            cout << "0\n";
            continue;
        }
        ll l = 2, r = y + 1, mid = (l + r) >> 1;
        while (l + 1 < r) {

            if (x >= (mid + 1) * (mid - 1))
                l = mid;
            else r = mid;
            mid = (l + r) >> 1;
        }
        if (x < 3) l = 1;

        ans = l * (l - 1) / 2;


        for (l = l + 1, r; l <= y; l = r + 1) {
            if (x / (l + 1) == 0) break;
            r = x / (x / (l + 1)) - 1;

            r = min(r, y);
//            cout << l << " " << r << " " << x / (l + 1) << '\n';
            // do something with [l, r]...
            ans += x / (l + 1) * (r - l + 1);
        }

        cout << ans << '\n';
    }
}