import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); PrintWriter pw = new PrintWriter(System.out); for (int z = 0; z < t; z++) { String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); if (m <= n) { pw.println(m / 2); } else { long x = m / 2; long y = m - n; long ans1 = x - y; long ans2 = (3 + y + 1) * (y - 1) / 2; pw.println(ans1 + ans2); } } pw.flush(); br.close(); } }