#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

ll power(ll a ,ll b){
  if(b == 0)return 1;
  ll res = power(a,b/2);
  res = res*res;
  if(b&1)res = res*a;
  return res;
}
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0); 
  
    ll t;
    cin >> t;
   
    while(t--){
      ll x,y;
      cin >> x >> y;
      ll res = 0;
      ll p = sqrt(x);
      for(int i = 1;i <= p;i++){
          res += max(0ll,min(y,x/i-1)-i);
      }
      cout << res << endl;

}



  return 0;
}