//BISMILLAHIR RAHMANIR RAHIM
//RABBI ZIDNI ILMA
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define ff first
#define ss second
#define inf (1LL<<61)
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define all(x) x.begin(), x.end()
#define intPow(n, p) (ll)(pow(n, p) + 0.5)
#define fastio ios_base::sync_with_stdio(0); cin.tie(NULL);
#define debug(x) cout<<"["<<#x<<": "<<x<<"]\n"
#define debug2(x, y) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]\n"
#define debug3(x, y, z) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]\n"
#define debug4(x, y, z, k) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]"<<"  ["<<#k<<": "<<k<<"]\n"

const ll N = 1e5 + 9;

int main()
{
    fastio
    ll tt;
    cin>> tt;
    while(tt--){
        ll x, y;
        cin>> x>> y;
        ll ans = 0;
        for(ll i=1; i*i<x && y>i; i++){
            ll ub = max((x-i)/i - i, 0LL);
            ans += min(ub, y-i);
            //debug4(i, ub, y-i+1);
        }
        cout<< ans << endl;
    }
}
