    import java.util.*;
import java.io.*;
public class Test
{
    
    public static void main(String[] args) throws Exception {   
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(in.readLine());
        while(t-- > 0){
            String s[] = in.readLine().split(" ");
            long n = Long.parseLong(s[0]);
            long m = Long.parseLong(s[1]);
            long total = (n*(n+1))/2;
            long dif = n-m;
            long ans = total-dif;
            if(dif <= m){
                System.out.println(ans);
                continue;
            }
            if(m!=0)
                ans++;
            

            
            long rem = n-m-1;
            ans-= (rem*(rem+1))/2;
            System.out.println(ans);

        }
        
    } 
}
