#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int main()
{
    long long int test;
    cin >> test;
    while(test--)
    {
        long long int x, y;
        cin >> x >> y;
        long long int res = 0;
        long long int i = 2;
        while((min(x, (i-1)*(y+1)) - (i*i - 1)) >= 0)
        {
            //cout << " : " << i << " : " << (min(x, (i-1)*(y+1)) - (i*i - 1)) / (i-1) + 1<< endl;
            res += (min(x, (i-1)*(y+1)) - (i*i - 1)) / (i-1) +1;
            i++;
        }
        cout << res << endl;
    }
    return 0;
}