#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
	int T;
	scanf("%d", &T);
	while (T--) {
		ll n, m, ans = 0;
		scanf("%lld%lld", &n, &m);
		for (ll k = 1; k <= n / k; k++) {
			ans += max(0ll, min(n / k - 1, m) - k);
		}
		printf("%lld\n", ans);
	}
	return 0;
}
/*
1
50 3
*/