#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI = acos(-1);

int main() {
    #ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #else
    fastIO;
    #define endl '\n'
    #endif
    int t;
    cin >> t;
    while(t--) {
        int x, y, h, aux; 
        ll ans = 0;
        cin >> x >> y;
        h = sqrt(x+1) - 1;
        h = min(h, y - 1);
        for(int i = h; i > 0; i--) {
            ans += min(x/i - 1, y) - i;
        } 
        cout << ans << endl;
    }
}