T=int(input()) for _ in range(T): a,b=map(int,input().split()) m=min(a,b//2) if a>=b: print(m*(m+1)//2) else: print((m+1)*m//2-3)