#include <bits/stdc++.h>
 
using namespace std;
 
#define ar array
#define pii pair<int, int>
#define vi vector<int>
#define sz(s) (int) s.size()
#define all(s) s.begin(), s.end()
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b) - 1; i >= (a); i--)
 
typedef long long ll;
typedef unsigned long long ull;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

void solve() {
    int x, y;
    cin >> x >> y;
    ll ans = 0;
    for (int i = 1; i * i < x; i++) {
        ans += max(min(y, x / i - 1) - i, 0);
    }
    cout << ans << '\n';
}
 
int main(int argc, char** argv) {
    ios::sync_with_stdio(false); 
    cin.tie(nullptr); cout.tie(nullptr);
 
    int t; cin >> t;
    while (t--) solve();
 
    return 0;
}