/// You just can't beat the person who never gives up
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;

const int N = 2e5+5 ;

/// a%b * (b+1) / b = a%b
int t ,a ,b ;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&a,&b);
        int st = 1 ,en = b ;
        while(st<en){
            int mid = (st+en+1)/2 ;
            if(a/(mid+1)>=mid-1) st = mid ;
            else en = mid-1 ;
        }
        long long ans = 1ll*st*(st-1)/2 ;
        int i = st+1 ;
        while(i<=b){
            st = i ,en = b ;
            int cur = a/(i+1) ;
            while(st<en){
                int mid = (st+en+1)/2 ;
                if(a/(mid+1)==cur) st = mid ;
                else en = mid-1 ;
            }
            ans += 1ll*cur*(st-i+1) ;
            i = st+1 ;
        }
        printf("%lld\n",ans);
    }
    return 0;
}
