for _ in range(int(input())):
    s = [int(a) for a in input().split()]
    n = s[0]
    n1 = s[1]
    n0 = n-n1
    f=0
    if(n0==n1):
       f = (n**2) /2
    if(n0>n1):
       f = 2*n0*n1
    if(n0<n1):
       f = (n**2 + n1-n0)/2
    
    print(f)
       