#include <bits/stdc++.h>

using namespace std;

/**************************************************************/
#define int          long long
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define err(x)       cerr << #x << " is : " << x << endl

/***************************************************************/

//bhenchod math me maza aa gya
//!!!!!!!
int32_t main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--)
    {
        int x , y;
        cin >> x >> y;

        int maxB = 5e4, ans = 0 , start = -1;
        for(int i = 2 ; i <= min(y , maxB) ; i++)
        {
            if(((i * i) - 1) <= x)
                ans += (i - 1);
            else
            {
                start = i;
                break;
            }
        }

        if(start == -1)
        {
            cout << ans << '\n';
            continue;
        }
        int value = x / (start + 1);
        while(value >= 1 && start <= y)
        {
            //how many will give this value
            int lastN = min((x / value) - 1 , y);
            ans += ((lastN - start + 1) * value);
            start = lastN + 1;
            value = x / (start + 1);
        }

        cout << ans << '\n';
    }
    return 0;
}
