#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define fs first
#define sc second

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int x, y;
int SOLVE() {
    scanf("%d%d", &x, &y);
    // x가 무한대라면 
    // special은 [0,1,2,3,4,5,6...] 으로 증가
    // (y - 1)*y /2가 답
    // A: [3], [4, 8], [5, 10, 15], [6, 12, 18, 24], `[7, 14, 21, 28, 35] [8, ...]
    // B:  2    3       4            5                 6                 
    // x는 [1, (y + 1) * (y - 1)]의 범위까지 

    // 1 <= kb + k == k(b + 1) == a <= x
    // k + 1 <= b <= x/k - 1
    const int root = sqrt(x);
    ll ans = 0;
    for (int i = 1; i <= root; i++) {
        // 
        if (i + 1 > min(y, x / i - 1)) break;
        ans += min(y, x / i - 1) - i;
    }
    printf("%lld\n", ans);
    return 0;
}

int main() {
    int t = 1;
    scanf("%d", &t);
    while (t--) {
        SOLVE();
    }
    return 0;
}