#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#define boost() cin.tie(0); cin.sync_with_stdio(0);
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define uset unordered_set
#define umap unordered_map
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a));
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
ll T;
int main() {
    scanf("%lld", &T);
    for (ll t = 0; t < T; ++t) {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        ll ans = 0;
        for (ll c = 1; c * c <= x; ++c) {
            ans += max(0LL, min(y, x / c - 1) - c);
        }
        printf("%lld\n", ans);
    }
}
