//HYBRYDO RAAAAAAAAAAA
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(nullptr)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pii pair<int, int>
#define ss second
#define ff first
using namespace std;
typedef long long ll;
typedef long double Double;
const int INF=1e9+9;
const int N=3e7+1;
const int MOD=3e7;

void solve(){
  int x, y; cin>>x>>y;
  ll ans=0;
  for(int i=1; (i*i<x && i<y); ++i){
    int num=x/i;
    num=min(num, y+1);
    if(num<i+2) continue;
    ans+=(num-i-1);
  }
  cout<<ans<<endl;
}
int main(){
    FAST_IO;
    int t; cin>>t;    
    while(t--) solve();
    return 0;
}