#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--){
        long long int x,y,ans=0;
        cin>>x>>y;
        for(long long int k=1;k*k<x;k++){
            ans+=max(min(y,x/k-1)-k,0LL);
            //cout<<k<<" "<<max(min(y,x/k-1)-k,0LL)<<endl;
        }
        cout<<ans<<endl;
        }

}
