#include<bits/stdc++.h>
#define For(i, l, r) for(int i = l; i <= r; i++)
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
template <typename T>
T read(){
	T x=0,f=1;
	char ch;
	while(ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return f*x;
}

int main()
{
	int T;
	cin >> T;
	while(T--){
		int x ,y, i;
		cin >> x >> y;
		ll ans = 0;
		for(i = 1; i <= y; i++){
			if (i * i - 1 > x){
				for(int j = 1; j <= i - 2; j++){
					int ub = min(y, x / j - 1);
					int db = x / (j + 1) - 1;
					//if (x % (j + 1) == 0) db--; 
					db = max(i - 1, db);
					if (ub <= db) continue;
					ans += (ll) j * (ub - db);
				}
				break;
			}
			ans += i - 1;
		} 
		
		cout << ans << endl;
	}
	return 0;
}

