A competitive eater, Alice is scheduling some practices for an eating contest on a magical calendar. The calendar is unusual because a week contains not necessarily $7$ days!

In detail, she can choose any integer $k$ which satisfies $1 \leq k \leq r$, and set $k$ days as the number of days in a week.

Alice is going to paint some $n$ consecutive days on this calendar. On this calendar, dates are written from the left cell to the right cell in a week. If a date reaches the last day of a week, the next day's cell is the leftmost cell in the next (under) row.

She wants to make all of the painted cells to be connected by side. It means, that for any two painted cells there should exist at least one sequence of painted cells, started in one of these cells, and ended in another, such that any two consecutive cells in this sequence are connected by side.

Alice is considering the shape of the painted cells. Two shapes are the same if there exists a way to make them exactly overlapped using only parallel moves, parallel to the calendar's sides.

For example, in the picture, a week has $4$ days and Alice paints $5$ consecutive days. [1] and [2] are different shapes, but [1] and [3] are equal shapes. [Image] 

Alice wants to know how many possible shapes exists if she set how many days a week has and choose consecutive $n$ days and paints them in calendar started in one of the days of the week. As was said before, she considers only shapes, there all cells are connected by side.


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases. Next $t$ lines contain descriptions of test cases.

For each test case, the only line contains two integers $n$, $r$ ($1 \le n \le 10^9, 1 \le r \le 10^9$).


-----Output-----

For each test case, print a single integer  — the answer to the problem.

Please note, that the answer for some test cases won't fit into $32$-bit integer type, so you should use at least $64$-bit integer type in your programming language.


-----Example-----
Input
5
3 4
3 2
3 1
13 7
1010000 9999999

Output
4
3
1
28
510049495001



-----Note-----

In the first test case, Alice can set $1,2,3$ or $4$ days as the number of days in a week.

There are $6$ possible paintings shown in the picture, but there are only $4$ different shapes. So, the answer is $4$. Notice that the last example in the picture is an invalid painting because all cells are not connected by sides. [Image] 

In the last test case, be careful with the overflow issue, described in the output format.

Difficulty: EASY

Solutions:
for i in range(int(input())):
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	s = 0
	if n > r:
		if r % 2 == 0:
			s = s + (r + 1) * (r // 2)
		else:
			s = s + (r // 2 + 1) + (r + 1) * (r // 2)
	else:
		a = n - 1
		if a % 2 == 0:
			s = 1 + (a + 1) * (a // 2)
		else:
			s = 1 + (a // 2 + 1) + (a + 1) * (a // 2)
	print(s)


from math import ceil
t1 = int(input())
for i in range(t1):
	(n, r) = map(int, input().split())
	x = min(r, n)
	ans = 0
	if n == x:
		ans = x * (x - 1) // 2
		ans += 1
	else:
		ans = x * (x + 1) // 2
	print(ans)


for i in range(int(input())):
	(n, r) = map(int, input().split())
	if n <= r:
		n -= 1
		x = n * (n + 1)
		x //= 2
		x += 1
		print(x)
		continue
	if n > r:
		x = r * (r + 1)
		x = x // 2
		print(x)
		continue


def sol(read):
	(a, b) = read
	n = min(a - 1, b)
	s = (1 + n) * n // 2
	print(int(s) + (b >= a))
for i in range(int(input())):
	read = list(map(int, input().split()))
	sol(read)


from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
	t = I()
	for _ in range(t):
		(n, r) = LI()
		if r < n:
			print(r * (r + 1) >> 1)
		else:
			ans = n * (n - 1) >> 1
			ans += 1
			print(ans)
	return
solve()


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	r = min(r, n)
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((r - 1) * r // 2 + 1)


import sys
input = sys.stdin.readline

def sum_up_to_n(n):
	return n * (n + 1) // 2

def main():
	t = int(input())
	for _ in range(t):
		(N, R) = [int(x) for x in input().split()]
		if N <= R:
			x = sum_up_to_n(min(N - 1, R))
			print(x + 1)
		else:
			x = sum_up_to_n(min(N - 1, R))
			print(x)
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	if n <= m:
		print(n * (n - 1) // 2 + 1)
	else:
		print(m * (m + 1) // 2)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	cnt = 0
	if n < r + 1:
		r = n - 1
		cnt += 1
	cnt += r * (r + 1) // 2
	print(cnt)


t = int(input())
i = 0
while i < t:
	(n, r) = [int(n) for n in input().split()]
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)
	i += 1


case = int(input())
for _ in range(case):
	(n, r) = map(int, input().split())
	ans = 0
	if r >= n:
		r = n - 1
		ans += 1
	ans += (r + 1) * r // 2
	print(ans)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	(n, r) = mi()
	if n <= r:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


def solve(n, r):
	if n > r:
		return r * (r + 1) // 2
	return n * (n - 1) // 2 + 1
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	print(solve(n, r))


t = int(input())
for x in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		f = b * (b + 1)
		f = f // 2
	else:
		d = a - 1
		f = d * (d + 1)
		f = f // 2
		f += 1
	print(f)


def main():
	t = Iint()
	for _ in range(t):
		(n, r) = Imap()
		if n <= r:
			n -= 1
			a = n * (n + 1) // 2 + 1
		elif n > r:
			a = r * (r + 1) // 2
		print(a)
FIO = 1

def I():
	return input()

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
en = enumerate
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import sys
	import os
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


def solve(r, k):
	limit = min(r - 1, k)
	ans = (1 + limit) * limit // 2
	if r <= k:
		ans += 1
	return ans
n = int(input())
for _ in range(n):
	(r, k) = map(int, input().split())
	print(solve(r, k))


t = int(input())
while t > 0:
	(n, r) = map(int, input().split())
	s = 1
	if n > r:
		print(r * (r + 1) // 2)
	else:
		val = n * (n + 1) // 2 - n + 1
		print(val)
	t = t - 1


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, r) = list(map(int, input().split()))
		if n > r:
			yield ((r + 1) * r // 2)
		else:
			yield (n * (n - 1) // 2 + 1)
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	string1 = input()
	string = string1.split()
	n = int(string[0])
	r = int(string[1])
	if n > r:
		print(r * (r + 1) // 2)
	if r >= n:
		print(n * (n - 1) // 2 + 1)


t = int(input())
while t > 0:
	(n, r) = map(int, input().split())
	ans = 0
	if r >= n:
		ans += 1
	k = min(n - 1, r)
	ans += k * (k + 1) // 2
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	(n, r) = (l[0], l[1])
	if n > r:
		print(r * (r + 1) // 2)
	else:
		p = (n - 1) * n // 2
		print(p + 1)


for _ in range(int(input())):
	(N, R) = list(map(int, input().split()))
	if N > R:
		print(R * (R + 1) // 2)
	else:
		t = N * (N - 1) // 2
		print(t + 1)


for _ in range(int(input())):
	(day, week) = map(int, input().split())
	n = min(day - 1, week)
	print(n * (n + 1) // 2 + int(day <= week))


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(n, r) = map(int, input().split())
	z = 0
	ans = 0
	if n <= r:
		z = n - 1
		ans += 1
	else:
		z = r
	ans += z * (z + 1) // 2
	print(ans)


import math
from collections import deque
from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	res = 0
	res += (1 + min(n, r + 1) - 1) * (min(n, r + 1) - 1) // 2
	if n <= r:
		res += 1
	print(res)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	x = min(r, n - 1)
	ans = x * (x + 1) // 2
	if r >= n:
		ans += 1
	print(ans)


import math
t = int(input())
for tc in range(t):
	line = input().split()
	(n, r) = (int(line[0]), int(line[1]))
	if r == 1:
		print('1')
		continue
	r += 1
	if r > n:
		sum_ = n * (n - 1) // 2 + 1
	elif n >= r:
		sum_ = math.ceil(r * (r - 1) // 2)
	print(sum_)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	(a, b) = f()
	n = min(a, b)
	if a <= b:
		l = n * (n - 1) // 2
		print(l + 1)
	else:
		l = n * (n + 1) // 2
		print(l)


from math import ceil

def main():
	t = int(input())
	for i in range(t):
		(n, r) = map(int, input().split())
		if r >= n:
			print(1 + (n - 1) * n // 2)
		else:
			print(r * (r + 1) // 2)
main()


t = int(input())
while t:
	t -= 1
	(n, r) = map(int, input().split())
	if n <= r:
		print(1 + n * (n - 1) // 2)
	else:
		print(r * (r + 1) // 2)


from sys import *
input = stdin.readline
from typing import Counter

def solve(n, r):
	if n > r:
		return r * (r + 1) // 2
	elif n <= r:
		x = n - 1
		return x * (x + 1) // 2 + 1
t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	print(solve(n, r))


def solve():
	(n, r) = map(int, input().split())
	if n <= r:
		ans = (n - 1) * n // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)
t = int(input())
while t > 0:
	t -= 1
	solve()


t = int(input())
for i in range(t):
	(n, r) = list(map(int, input().split()))
	if n > r:
		ans = r * (r + 1) // 2
	else:
		s = n - 1
		ans = s * (s + 1) // 2 + 1
	print(ans)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	c = 0
	if n > r:
		c = r * (r + 1) // 2
	else:
		c = n * (n - 1) // 2 + 1
	print(c)


def main():
	for _ in range(int(input())):
		(n, x) = list(map(int, input().split()))
		if n > x:
			print(x * (x + 1) >> 1)
		else:
			print((n * (n - 1) >> 1) + 1)
main()


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	if n > r:
		ans = r * (r + 1) // 2
		print(ans)
	else:
		ans = n * (n - 1) // 2
		print(ans + 1)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from math import sqrt, floor, factorial, gcd, log
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def solve():
	for _ in range(int(input())):
		(n, r) = read()
		if r >= n:
			m = n - 1
			print(m * (m + 1) // 2 + 1)
		else:
			print(r * (r + 1) // 2)
solve()


t = int(input())
for i in range(t):
	arr = list(map(int, input().strip().split(' ')))
	n = arr[0]
	r = arr[1]
	d = min(n, r)
	if d == n:
		s = d * (d - 1) // 2
	else:
		s = d * (d + 1) // 2
	if r >= n:
		print(1 + s)
	else:
		print(s)


n = int(input())
for _ in range(n):
	(m, n) = map(int, input().split())
	if m > n:
		temp = int(n * (n + 1) // 2)
		print(temp)
	else:
		temp2 = int(m * (m + 1) // 2 - (m - 1))
		print(temp2)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	ans = 0
	if n <= r:
		if n == 1:
			print(1)
		else:
			print(n * (n - 1) // 2 + 1)
	elif r == 1:
		print(1)
	else:
		temp = r * (r + 1) // 2
		print(temp)


for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	print((k >= n) + min(n * (n - 1), k * (k + 1)) // 2)


import math

def isPrimes2(n):
	if n > 1:
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		for x in range(3, int(math.sqrt(n) + 1), 2):
			if n % x == 0:
				return False
		return True
	return False

def main():
	t = int(input())
	for i in range(t):
		(n, m) = map(int, input().split())
		if n > m:
			print((1 + m) * m // 2)
		elif m == n:
			print((1 + m - 1) * (m - 1) // 2 + 1)
		else:
			print((1 + n - 1) * (n - 1) // 2 + 1)
main()


import sys
import random
from fractions import Fraction
from math import *

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def linput():
	return list(input())

def rinput():
	return list(map(int, tinput()))

def fiinput():
	return list(map(float, tinput()))

def rlinput():
	return list(map(int, input().split()))

def trinput():
	return tuple(rinput())

def srlinput():
	return sorted(list(map(int, input().split())))

def NOYES(fl):
	if fl:
		print('NO')
	else:
		print('YES')

def YESNO(fl):
	if fl:
		print('YES')
	else:
		print('NO')

def main():
	(n, r) = rinput()
	print((r >= n) + min(n * (n - 1), r * (r + 1)) // 2)
for i in range(iinput()):
	main()


import sys
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	if r >= n:
		print((n - 1) * n // 2 + 1)
	else:
		print(r * (r + 1) // 2)


s = []
for iiii in range(int(input())):
	(n, r) = map(int, input().split())
	if r >= n:
		s.append(n * (n - 1) // 2 + 1)
	else:
		s.append(r * (r + 1) // 2)
for i in s:
	print(i)


t = int(input())
for case in range(t):
	(n, r) = map(int, input().split())
	count = 0
	if n <= r:
		count += (1 + (n - 1)) * (n - 1) // 2
		count += 1
	else:
		count = (1 + r) * r // 2
	print(count)


for test in range(int(input())):
	(n, r) = map(int, input().split())
	if r >= n:
		ans = 1
		r = n - 1
	else:
		ans = 0
	if r % 2 == 0:
		ans += r // 2
	ans += (r + 1) // 2 * r
	print(ans)


import os
import sys, math
from io import BytesIO, IOBase

def main():
	t = int(input())
	for case in range(t):
		(n, r) = list(map(int, input().split()))
		if n > r:
			print(r * (r + 1) // 2)
		elif n == r:
			print(1 + r * (r - 1) // 2)
		else:
			print(1 + n * (n - 1) // 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def calculateDistinctShapes(n, r):
	if n == 1:
		return 1
	if r >= n:
		count = n * (n - 1) // 2 + 1
	else:
		count = r * (r + 1) // 2
	return count
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	print(calculateDistinctShapes(n, r))


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	res = 0
	if r >= n:
		r = n - 1
		res += 1
	res += (2 + (r - 1)) * r // 2
	print(res)


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7
T = int(stdin.readline())
for _ in range(T):
	(n, r) = list(map(int, stdin.readline().split()))
	N = min(n - 1, r)
	ans = N * (N + 1) // 2
	ans += 1 if r >= n else 0
	print(ans)


import math
from itertools import permutations

def allPermutations(str):
	permList = permutations(str)
	for perm in list(permList):
		print(''.join(perm))
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	if n <= m:
		print(n * (n - 1) // 2 + 1)
	else:
		print(m * (m + 1) // 2)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n > k:
		ans = k * (k + 1) // 2
		print(ans)
	elif n == k:
		print(k * (k - 1) // 2 + 1)
	else:
		x = k - n - 1
		y = k - n
		ans = n * (n - 1) // 2 + 1
		print(ans)


def func(n, r):
	if r >= n:
		r = n - 1
		res = r * (r + 1) // 2
		res += 1
		print(res)
		return
	else:
		res = r * (r + 1) // 2
		print(res)
		return
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	func(n, r)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if b < a:
		print((b ** 2 + b) // 2)
	else:
		print((a ** 2 - a + 2) // 2)


cases = int(input())
for t in range(cases):
	(n, r) = list(map(int, input().split()))
	if n > r:
		v = r * (r + 1) // 2
	else:
		v = n * (n - 1) // 2 + 1
	print(v)


t = int(input())
while t > 0:
	t -= 1
	(n, r) = map(int, input().split())
	if r < n:
		k = r * (r + 1) // 2
		print(int(k))
	else:
		z = n * (n + 1) // 2 + (1 - n)
		print(int(z))


test = int(input())
for t in range(test):
	(n, r) = map(int, input().split())
	if n <= r:
		count = (n - 1) * n // 2 + 1
	else:
		count = r * (r + 1) // 2
	print(count)


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	r = int(l[1])
	z = 0
	if r < n:
		print(r * (r + 1) // 2)
	else:
		z += n * (n - 1) // 2
		z += 1
		print(z)


t = int(input())
while t:
	nr = input().split()
	n = int(nr[0])
	r = int(nr[1])
	if n > r:
		print(r * (r + 1) // 2)
	else:
		n -= 1
		print(n * (n + 1) // 2 + 1)
	t -= 1


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


l = lambda : map(int, input().split())
for i in range(int(input())):
	(n, k) = l()
	s = 0
	if n > k:
		s = k * (k + 1) // 2
	else:
		s = n * (n - 1) // 2
		s += 1
	print(s)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	qu = 0
	if n <= 1:
		print(1)
		continue
	if n <= r:
		qu = 1
		r = n - 1
	print(qu + (1 + r) * r // 2)


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


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		(n, r) = ain()
		x = min(n, r)
		if x == n:
			print(x * (x + 1) // 2 - x + 1)
		else:
			print(x * (x + 1) // 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import ceil
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	ans = 0
	if n <= 1:
		ans = 1
	elif r >= n:
		ans = n * (n - 1) // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


t = int(input())
for _ in range(t):
	(n, r) = [int(i) for i in input().split()]
	count = 0
	if r >= n:
		r = n - 1
		count += 1
	count += (2 + (r - 1)) * r // 2
	print(count)


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	for test in range(tests):
		[n, r] = inlt()
		if n > r:
			val = r * (r + 1) // 2
			print(int(val))
		else:
			val1 = n * (n - 1) // 2
			val1 = val1 + 1
			print(int(val1))
main()


q = int(input())
for _ in range(q):
	(n, r) = map(int, input().split())
	max_k = min(n - 1, r)
	wyn = max_k * (max_k + 1) // 2
	if r >= n:
		wyn += 1
	print(wyn)


import math
from collections import deque
import sys
sys.setrecursionlimit(10 ** 4)

def Divisors(n):
	l = []
	i = 2
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(n)
	return l

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	result.append(n)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < abs(max_ending_here):
			max_so_far = max_ending_here
	return max_so_far

def longestsubarray(arr, n, k):
	current_count = 0
	max_count = 0
	for i in range(0, n, 1):
		if arr[i] % k != 0:
			current_count += 1
		else:
			current_count = 0
		max_count = max(current_count, max_count)
	return max_count

def main():
	(n, k) = list(map(int, input().split()))
	if n > k:
		print(k * (k + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)
t = int(input())
for i in range(0, t):
	main()


for i in range(int(input())):
	(n, r) = map(int, input().strip().split())
	k = min(n - 1, r)
	c = k * (k + 1) // 2 + (n <= r)
	print(c)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if n <= r:
		value = (n - 1) * n // 2 + 1
		print(value)
		continue
	if n > r:
		value = r * (r + 1) // 2
		print(value)


t = int(input())
for _ in range(t):
	(n, r) = [int(i) for i in input().split()]
	k = 1
	shapes = 0
	if n > r:
		shapes = (r + 1) * r // 2
	else:
		shapes = n * (n - 1) // 2
		shapes += 1
	print(shapes)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k * (k + 1) // 2)
	else:
		x = n - 1
		ans = x * (x + 1) // 2
		print(ans + 1)


for _ in range(int(input())):
	ans = 0
	(k, r) = map(int, input().split())
	m = min(k - 1, r)
	ans = m * (m + 1) // 2 + (m == k - 1 and k - 1 != r)
	print(ans)


def calendar(n, r):
	sum = 0
	if n > r:
		sum = r * (r + 1) // 2
	else:
		sum = n * (n - 1) // 2 + 1
	return sum
i = int(input())
for j in range(i):
	n_r = [int(ele) for ele in input().split()]
	n = n_r[0]
	r = n_r[1]
	print(calendar(n, r))


import os
import sys
from io import BytesIO, IOBase

def solution(n, r):
	if r == 1:
		write(1)
		return
	if n > r:
		write(r * (r + 1) // 2)
	else:
		k = n - 1
		res = k * (k + 1) // 2 + 1
		write(res)

def main():
	for _ in range(r_int()):
		(n, r) = r_array()
		solution(n, r)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for (N, R) in Query:
	a = min(R, N - 1)
	ans = a * (a + 1) // 2
	if R >= N:
		ans += 1
	print(ans)


def B(n, r):
	if n > r:
		return r * (r + 1) // 2
	else:
		x = n - 1
		return x * (x + 1) // 2 + 1
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	print(B(n, r))


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if n <= r:
		x = n * (n - 1) // 2 + 1
		print(x)
	else:
		y = r * (r + 1) // 2
		print(y)


for t in range(int(input())):
	(n, r) = [int(x) for x in input().split()]
	if n <= r:
		print((n * n - n) // 2 + 1)
	else:
		print((r * r + r) // 2)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	m = min(n, m)
	ans = 0
	if n == m:
		ans = ans + 1
		m = m - 1
	ans = ans + m * (m + 1) // 2
	print(ans)


t = int(input())
for _ in range(t):
	(n, r) = [int(x) for x in input().split()]
	if n <= r:
		c = 1
		k = n - 1
	else:
		c = 0
		k = r
	c += k * (k + 1) // 2
	print(c)


for _ in range(int(input())):
	(n, r) = list(map(int, input().split()))
	ans = 0
	if r == 1 and n == 1:
		ans = 1
	elif r < n:
		ans = r * (r + 1) // 2
	elif r >= n:
		ans = (n - 1) * n // 2 + 1
	print(ans)


for i in range(0, int(input())):
	(m, n) = map(int, input().split())
	if n >= m:
		m -= 1
		print(m * (m + 1) // 2 + 1)
	else:
		print(n * (n + 1) // 2)


def main():
	t = int(input())
	for _ in range(t):
		(n, r) = map(int, input().split())
		if r >= n:
			print((n - 1) * n // 2 + 1)
		else:
			print((r + 1) * r // 2)
main()


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, r) = map(int, input().split())
	ans = 0
	if n > r:
		ans = r * (r + 1) // 2
	elif n == r:
		ans = r * (r - 1) // 2 + 1
	else:
		ans = n * (n - 1) // 2 + 1
	print(ans)


import sys
input = sys.stdin.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	for _ in range(int(input())):
		(n, r) = map(int, input().split())
		if n > r:
			print(r * (r + 1) // 2)
		else:
			print(n * (n - 1) // 2 + 1)
prog()


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r < n:
		answer = 0
	else:
		answer = 1
	x = min(n - 1, r)
	answer += x * (x + 1) // 2
	print(answer)


t = int(input())
for _ in range(t):
	(n, r) = list(map(int, input().split()))
	if r < n:
		ct = (1 + r) * r // 2
	else:
		ct = n * (n - 1) // 2 + 1
	print(ct)


t = int(input())
while t:
	t -= 1
	(n, r) = map(int, input().split())
	soln = lambda x: x * (x + 1)
	if n > r:
		print(soln(r) >> 1)
	else:
		n -= 1
		print((soln(n) >> 1) + 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k >= n:
		print(n * (n - 1) // 2 + 1)
	else:
		print(k * (k + 1) // 2)


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def inn():
	return int(input())
mo = 1000000007
t = inn()
st = 'abcdefghijklmnopqrstuvwxyz'
while t:
	t -= 1
	(n, r) = value()
	if n > r:
		res = r * (r + 1) // 2
		print(res)
	else:
		res = n * (n - 1) // 2 + 1
		print(res)


for i in range(int(input())):
	(n, r) = (int(i) for i in input().split())
	a = min(n - 1, r)
	if n - 1 < r:
		ans = 1
	else:
		ans = 0
	print(a * (a + 1) // 2 + ans)


for s in [*open(0)][1:]:
	(n, r) = map(int, s.split())
	print((n * n - n + 2, r * r + r)[n > r] // 2)


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	d = 0
	if n <= r:
		d += 1
		r = n - 1
	d += r * (r + 1) // 2
	stdout.write(str(d) + '\n')


import sys

def f(n):
	return n * (n + 1) // 2
input = sys.stdin.readline
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r == 1:
		print(1)
		continue
	if r < n:
		print(f(r))
	else:
		ans = f(n - 1)
		ans += 1
		print(ans)


ans = ''
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r >= n:
		x = (n - 1) * n // 2 + 1
	else:
		x = r * (r + 1) // 2
	ans += str(x) + '\n'
print(ans)


import math
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	else:
		n1 = n - 1
		s = n1 * (n1 + 1) // 2 + 1
		print(s)


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	if n > r:
		k = r * (r + 1)
		print(k // 2)
	else:
		k = n * (n - 1)
		k1 = k // 2
		print(k1 + 1)


t = int(input())
for case in range(t):
	(n, r) = list(map(int, input().split(' ')))
	if r >= n:
		print((n - 1) * n // 2 + 1)
	else:
		print(r * (r + 1) // 2)


for i in range(int(input())):
	(n, r) = map(int, input().split())
	t = min(n - 1, r)
	count = t * (t + 1) // 2
	if n <= r:
		count += 1
	print(count)


import sys
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
t = int(input())
for test in range(t):
	(n, k) = get_ints()
	ans = 0
	if n <= k:
		ans = n * (n - 1) // 2
		ans += 1
	else:
		ans += k * (k + 1) // 2
	print(ans)


import sys

def Nsum(n):
	return n * (n + 1) // 2
input = sys.stdin.readline
print = sys.stdout.write
t = int(input())
while t:
	t = t - 1
	(n, r) = list(map(int, input().split()))
	if r < n:
		print(str(Nsum(r)) + '\n')
	else:
		{print(str(Nsum(n - 1) + 1) + '\n')}


t = int(input())
for r in range(t):
	K = list(map(int, input().split()))
	(n, r) = (K[0], K[1])
	ans = 0
	if n <= r:
		ans = ans + 1
		w = n
	else:
		w = r + 1
	w = w - 1
	ans = ans + w * (w + 1) // 2
	print(ans)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def main():
	try:
		(n, k) = In()
		if n < k:
			temp = n * (n - 1) // 2
			print(temp + 1)
		elif n == k:
			temp = n * (n - 1) // 2
			print(temp + 1)
		else:
			temp = k * (k + 1) // 2
			print(temp)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


try:
	k = int(input())
	for i in range(k):
		lis = list(map(int, input().split()))
		if lis[1] >= lis[0]:
			sm = (lis[0] - 1) * lis[0]
			sm = sm // 2
			sm += 1
		else:
			sm = lis[1] * (1 + lis[1])
			sm = sm // 2
		print(sm)
except Exception:
	pass


t = int(input())
for z in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		print((1 + b) * b // 2)
	else:
		k = a * (a - 1) // 2
		print(k + 1)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in range(base ** n):
		s = [tb // base ** bt % base for bt in range(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()

class Tree:

	def __init__(self, inp_size=None, ls=None, init=True, index=1):
		self.LCA_init_stat = False
		self.ETtable = []
		if init:
			if ls == None:
				self.stdin(inp_size, index=index)
			else:
				self.node_size = len(ls) + 1
				(self.edges, _) = GI(self.node_size, self.node_size - 1, ls, index=index)
		return

	def stdin(self, inp_size=None, index=1):
		if inp_size == None:
			self.node_size = int(input())
		else:
			self.node_size = inp_size
		(self.edges, _) = GI(self.node_size, self.node_size - 1, index=index)
		return

	def listin(self, ls, index=0):
		self.node_size = len(ls) + 1
		(self.edges, _) = GI(self.node_size, self.node_size - 1, ls, index=index)
		return

	def dfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.node_size
		v[x] = root_v
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def bfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.node_size
		v[x] = root_v
		while q:
			c = q.popleft()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def parent(self, x):
		return self.dfs(0, func=lambda pr, prv, nx, dist: pr, root_v=-1)

	def topological_sort(self, x):
		tps = []
		q = deque([x])
		v = [None] * self.node_size
		v[x] = 0
		while q:
			c = q.popleft()
			tps.append(c)
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = 0
		return tps

	def EulerTour(self, x):
		q = deque()
		q.append(x)
		self.depth = [None] * self.node_size
		self.depth[x] = 0
		self.ETtable = []
		self.ETdepth = []
		self.ETin = [-1] * self.node_size
		self.ETout = [-1] * self.node_size
		cnt = 0
		while q:
			c = q.pop()
			if c < 0:
				ce = ~c
			else:
				ce = c
				for (nb, d) in self.edges[ce]:
					if self.depth[nb] == None:
						q.append(~ce)
						q.append(nb)
						self.depth[nb] = self.depth[ce] + 1
			self.ETtable.append(ce)
			self.ETdepth.append(self.depth[ce])
			if self.ETin[ce] == -1:
				self.ETin[ce] = cnt
			else:
				self.ETout[ce] = cnt
			cnt += 1
		return

	def doubling_LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.depth = [None] * self.node_size
			self.depth = self.bfs(0, func=lambda pr, prv, nxt, dist: prv + 1)
			self.par = self.bfs(0, func=lambda pr, prv, nxt, dist: pr)
			self.db = [self.par]
			for i in range(self.node_size.bit_length()):
				self.db += [[self.db[-1][self.db[-1][i]] for i in range(self.node_size)]]
			self.LCA_init_stat = True
		dx = self.depth[x]
		dy = self.depth[y]
		if dx > dy:
			(dx, dy) = (dy, dx)
		c = self.node_size.bit_length()
		while c > 0:
			if dx + c <= dy:
				x = self.db[c][x]
				dx += 1 << c
			c >>= 1
		if x == y:
			return x
		c = self.node_size.bit_length()
		while c > 0:
			if self.db[c][x] != self.db[c][y]:
				x = self.db[c][x]
				y = self.db[c][y]
			c >>= 1
		return self.par[x]

	def LCA_init(self, root):
		self.EulerTour(root)
		self.st = SparseTable(self.ETdepth, init_func=min, init_idl=inf)
		self.LCA_init_stat = True
		return

	def LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.LCA_init(root)
		(xin, xout) = (self.ETin[x], self.ETout[x])
		(yin, yout) = (self.ETin[y], self.ETout[y])
		a = min(xin, yin)
		b = max(xout, yout, xin, yin)
		id_of_min_dep_in_et = self.st.query_id(a, b + 1)
		return self.ETtable[id_of_min_dep_in_et]

	def __str__(self):
		return str(self.edges)

	def show(self):
		if all([all([d == 1 for (nd, d) in e]) for e in self.edges]):
			print([[nd for (nd, d) in e] for e in self.edges])
		else:
			print(self)

	def dfs2(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.node_size
		v[x] = root_v
		dfs_tr = [x]
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
					dfs_tr += (nb,)
		return (v, dfs_tr)

class SparseTable:

	def __init__(self, ls, init_func=min, init_idl=float('inf')):
		self.func = init_func
		self.idl = init_idl
		self.size = len(ls)
		self.N0 = self.size.bit_length()
		self.table = [ls[:]]
		self.index = [list(range(self.size))]
		self.lg = [0] * (self.size + 1)
		for i in range(2, self.size + 1):
			self.lg[i] = self.lg[i >> 1] + 1
		for i in range(self.N0):
			tmp = [self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) for j in range(self.size)]
			tmp_id = [self.index[i][j] if self.table[i][j] == self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) else self.index[i][min(j + (1 << i), self.size - 1)] for j in range(self.size)]
			self.table += [tmp]
			self.index += [tmp_id]

	def query(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		return self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))])

	def query_id(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		(a, b) = (self.index[N][l], self.index[N][max(0, r - (1 << N))])
		if self.table[0][a] == self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))]):
			b = a
		return b

	def right_bound(self, pos, x):
		k = (self.size - pos).bit_length()
		for j in range(k)[::-1]:
			nx = pos + (1 << j)
			if nx < n and self.query(pos, nx + 1) <= x:
				pos += 1 << j
		return pos

	def left_bound(self, pos, x):
		k = pos.bit_length()
		for j in range(k)[::-1]:
			nx = pos - (1 << j)
			if 0 <= nx and self.query(nx, pos + 1) <= x:
				pos -= 1 << j
		return pos

	def __str__(self):
		return str(self.table[0])

	def print(self):
		for i in self.table:
			print(*i)
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	ans = 0
	(n, r) = LI()
	mx = min(n - 1, r)
	ans = mx * (mx + 1) // 2
	if r >= n:
		ans += 1
	print(ans)


T = int(input())
for _ in range(T):
	(N, R) = [int(x) for x in input().split(' ')]
	Q = min(R, N - 1)
	ans = Q * (Q + 1) // 2 + (1 if R >= N else 0)
	print(ans)


from math import *
t = int(input())
for _ in range(t):
	(nc, n) = map(int, input().split())
	if nc > n:
		print(n * (n + 1) // 2)
	else:
		n = nc - 1
		print(n * (n + 1) // 2 + 1)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	result = 0
	if n <= r:
		mini = n - 1
		result += 1
	else:
		mini = r
	if mini % 2 == 1:
		result += mini * (mini // 2 + 1)
	else:
		mini += 1
		result += mini * (mini // 2 + 1)
		result -= mini
	print(result)


import sys
import math
import heapq
from collections import defaultdict, deque
input = sys.stdin.readline

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	(n, r) = rm()
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)


import sys
import heapq

def main():
	t = int(input())
	for _ in range(t):
		(n, r) = map(int, sys.stdin.readline().split())
		val = min(n, r)
		ans = val * (val - 1) // 2
		if r >= n:
			print(ans + 1)
		else:
			print(ans + r)
	return
main()


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def printp(p):
	for i in p:
		print(i)
MOD = 10 ** 9 + 7
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, r) = list(map(int, stdin.readline().split()))
	if r >= n:
		ans = n * (n - 1) // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


for _ in range(int(input())):
	(n, r) = [int(__) for __ in input().split()]
	if n <= r:
		print((n - 1) * n // 2 + 1)
	else:
		print(r * (r + 1) // 2)


import sys
input = sys.stdin.readline
tc = int(input())
for _ in range(tc):
	(n, r) = map(int, input().split())
	if n > r:
		if r % 2 == 0:
			print((r + 1) * r // 2)
		else:
			tmp = r
			r -= 1
			print((r + 1) * (r // 2) + tmp)
	elif n % 2 == 0:
		print((n + 1) * n // 2 - n + 1)
	else:
		tmp = n
		n -= 1
		print((n + 1) * (n // 2) + 1)


t = int(input())
for z in range(t):
	(n, r) = map(int, input().split(' '))
	if r == 1:
		print(1)
	elif n > r:
		ans = r * (r + 1) // 2
		print(ans)
	else:
		ans = n * (n - 1) // 2 + 1
		print(ans)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	add = int(x <= y)
	x = min(x - 1, y)
	print(x * (x + 1) // 2 + add)


def sumz(a):
	return a * (a + 1) // 2
for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1 or k == 1:
		print(1)
	elif n > k:
		sumi = sumz(k)
		print(sumi)
	else:
		sumi = min(sumz(k), sumz(n)) - n + 1
		print(sumi)


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def solve():
	(n, r) = num_input()
	x = min(n, r) - 1
	ans = x * (x + 1) // 2
	if n > r:
		ans += r
	else:
		ans += 1
	print(ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for case in range(t):
		(n, r) = map(int, stdin.readline().split())
		x = min(r, n)
		if r < n:
			ans = x * (x + 1) // 2
		else:
			x -= 1
			ans = x * (x + 1) // 2 + 1
		stdout.write(str(ans) + '\n')
	return
main()


q = int(input())
for qq in range(q):
	s = input().split()
	n = int(s[0])
	r = int(s[1])
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


def sofs(x):
	return x * (x + 1) // 2
for t in range(int(input())):
	(n, r) = map(int, input().split())
	if n == 1 or r == 1:
		print(1)
	elif r >= n:
		print(sofs(n - 1) + 1)
	else:
		print(sofs(r))


for i in ' ' * int(input()):
	(n, r) = map(int, input().split())
	mn = min(n, r)
	print((mn - 1) * mn // 2 + 1 if n <= r else mn * (mn + 1) // 2)


from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	if m < n:
		print(m * (m + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if n <= r:
		wn = n - 1
		wynik = wn * (wn + 1) // 2 + 1
	else:
		wn = r
		wynik = wn * (wn + 1) // 2
	print(wynik)


t = int(input())
l = []
for i in range(t):
	(n, r) = map(int, input().split())
	ans = 0
	if n > r:
		l.append(r * (r + 1) // 2)
	else:
		x = n - 1
		ans = x * (x + 1) // 2
		ans = ans + 1
		l.append(ans)
for each in l:
	print(int(each))


import math
t = int(input())
for _ in range(t):
	(n, r) = [int(x) for x in input().strip().split(' ')]
	if r >= n:
		print(int(n * (n - 1) // 2) + 1)
	else:
		print(int(r * (r + 1) // 2))


from sys import stdin, stdout
import bisect

def st():
	return list(stdin.readline())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	(n, r) = mp()
	if n > r:
		x = r * (r + 1) // 2
	else:
		x = n * (n - 1) // 2 + 1
	pr(x)
for _ in range(inp()):
	solve()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print(1 + n * (n - 1) // 2)


import math
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	p = min(n, r)
	if r < n:
		ans = p * (p + 1)
		ans = ans // 2
		print(ans)
	else:
		p = p - 1
		ans = p * (p + 1)
		ans = ans // 2
		print(ans + 1)


q = int(input())
for _ in range(q):
	(n, r) = map(int, input().split())
	if n > r:
		sum = r * (r + 1) // 2
	else:
		sum = n * (n - 1) // 2 + 1
	print(sum)


def testcase():
	import sys
	input = sys.stdin.readline
	(n, r) = [int(x) for x in input().strip().split()]
	ans = min(n - 1, r) * (1 + min(n - 1, r)) // 2 + (r >= n)
	print(ans)

def main():
	import sys
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		testcase()
main()


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	w = min(n, r)
	if r >= n:
		print((w - 1) * w // 2 + 1)
	else:
		print((w + 1) * w // 2)


import math

def main_function():
	tests = range(int(input()))
	answer = []
	for test in tests:
		(n, r) = [int(i) for i in input().split(' ')]
		if n <= r:
			result = (n - 1) * n // 2 + 1
		elif n > r:
			result = (r + 1) * r // 2
		answer.append(result)
	for ans in answer:
		print(ans)
main_function()


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r >= n:
		n -= 1
		print(n * (n + 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r >= n:
		ans = 1 + (n - 1) * n // 2
		print(ans)
	else:
		ans = r * (r + 1) // 2
		print(ans)


t = int(input())
for T in range(t):
	(n, r) = [int(x) for x in input().split()]
	val = min(n - 1, r)
	val = val * (val + 1) // 2
	if n <= r:
		val += 1
	print(val)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(n, r) = rinput()
	if n > r:
		s = r * (r + 1) // 2
		print(s)
	elif n == r:
		s = r * (r + 1) // 2
		print(s - n + 1)
	else:
		m = n - 1
		s = m * (m + 1) // 2
		print(s + 1)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	v = 0
	if x <= y:
		v += 1
	x = min(x - 1, y)
	v += (x + 1) * x // 2
	print(v)


for _ in range(int(input())):
	(n, r) = list(map(int, input().split()))
	if r == 1:
		print(1)
	else:
		if r >= n:
			count = n * (n + 1) // 2 - n + 1
		if r < n:
			count = r * (r + 1) // 2
		print(count)


for __ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	num = min(a - 1, b)
	ans = num * (num + 1) // 2
	if a - 1 < b:
		ans += 1
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, r) = input().split()
	n = int(n)
	r = int(r)
	count = 0
	if r >= n:
		count += 1
		r = n - 1
	count += r * (r + 1) // 2
	print(count)


t = int(input())
for test in range(t):
	l = list(map(int, input().split()))
	(n, r) = (l[0], l[1])
	shapes = 0
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(1 + n * (n - 1) // 2)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r == 1:
		print(1)
		continue
	mn = min(n, r)
	v = mn * (mn + 1) // 2 - mn + 1
	if mn == r and n != r:
		v += r - 1
	print(v)


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
testCases = int(input())
answers = []
for _ in range(testCases):
	(n, r) = input_split()
	if n > r:
		ans = r * (r + 1) // 2
	else:
		ans = n * (n - 1) // 2 + 1
	answers.append(ans)
print(*answers, sep='\n')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	(n, r) = Ri()
	ans = 0
	if r < n:
		print(r * (r + 1) // 2)
	elif n < r:
		n -= 1
		print(n * (n + 1) // 2 + 1)
	else:
		n -= 1
		print(n * (n + 1) // 2 + 1)


t = int(input(''))
while t > 0:
	(n, a) = map(int, input().split())
	if n > a:
		ans = a * (a + 1) // 2
	else:
		ans = n * (n - 1) // 2 + 1
	print(ans)
	t -= 1


def main():
	(n, r) = map(int, input().split())
	mn = min(r, n)
	sm = mn * (mn + 1) // 2
	if n <= r:
		sm -= n - 1
	print(sm)
t = int(input())
for i in range(t):
	main()


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	(n, r) = mInt()
	if r >= n:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


tk = int(input())
for i in range(tk):
	(a, b) = map(int, input().split())
	if b > a:
		b = a
	if a > b:
		print(b * (b + 1) // 2)
	else:
		print(b * (b - 1) // 2 + 1)


import math
import os
import random
import re
import sys
from collections import OrderedDict

def solve():
	for _ in range(int(input())):
		(n, r) = map(int, input().strip().split())
		c = 0
		x = min(n, r)
		if n <= r:
			print(x * (x - 1) // 2 + 1)
		else:
			print(x * (x + 1) // 2)
solve()


from math import *
t = int(input())
while t:
	t = t - 1
	(n, r) = map(int, input().split())
	out = 0
	if r < n:
		out += r * (r + 1) // 2
	else:
		n = n - 1
		out += n * (n + 1) // 2
		out += 1
	print(out)


import time, math, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x))

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 9 + 7

def solve():
	(n, r) = IP()
	if n > r:
		print(r * (r + 1) // 2)
	else:
		x = n - 1
		y = x * (x + 1) // 2
		print(y + 1)
t = II()
for i in range(t):
	solve()


import math
import sys
import itertools
import random

def lcm(x, y):
	return x * y // math.gcd(x, y)

def hcf(x, y):
	return math.gcd(x, y)

def primes(n):
	prime = [True for _ in range(0, n + 1)]
	res = []
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[p] = False
		p += 1
	for i in range(0, n + 1):
		if prime[i] == True:
			res.append(i)
	return res

def primeFactors(n):
	res = []
	while n % 2 == 0:
		res.append(2)
		n //= 2
	for i in range(3, math.sqrt(n) + 1, 2):
		while n % i == 0:
			res.append(i)
			n //= i
	if n > 2:
		res.append(n)
	return res
for _ in range(0, int(input())):
	(n, r) = map(int, input().strip().split())
	res = 0
	if r == n:
		res = res + n * (n - 1) // 2 + 1
	elif r > n:
		ex = r - n
		res = res + n * (n - 1) // 2 + 1
	else:
		res = res + r * (r + 1) // 2
	print(res)


import math

def shrey():
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)
T = input()
T = int(T)
for q in range(1, T + 1):
	shrey()


from sys import stdin, stdout

def gets(r, n):
	if r < n:
		return 0
	else:
		t1 = r - n + 1
		return t1 * (t1 + 1) // 2

def gets2(x):
	return x * (x + 1) // 2
t = int(stdin.readline().strip())
for _ in range(t):
	(n, r) = stdin.readline().strip().split(' ')
	(n, r) = (int(n), int(r))
	ans = 0
	if n <= r:
		ans += gets2(n - 1) + 1
	else:
		ans += gets2(r)
	stdout.write(str(ans) + '\n')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n <= m:
		print(n * (n - 1) // 2 + 1)
	else:
		print(m * (m + 1) // 2)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, r) = list(map(int, stdin.readline().split()))
	res = 0
	if r >= n:
		res += 1
	t = min(r, n - 1)
	res += t * (t + 1) // 2
	print(res)


for _t in range(int(input())):
	(n, r) = list(map(int, input().split()))
	if n > r:
		v = r * (r + 1)
		v = v // 2
		print(v)
	else:
		v = n * (n + 1) // 2
		print(v - n + 1)


t = int(input())
while t > 0:
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	else:
		x = n - 1
		summ = 0
		summ += x * n // 2
		summ += 1
		print(summ)
	t = t - 1


t = int(input())

def f(x):
	return x * (x + 1) // 2
for i in range(t):
	(n, r) = [int(x) for x in input().split()]
	ans = f(min(n - 1, r)) + (r >= n)
	print(ans)


n = int(input(''))
matrix = []
for i in range(n):
	matrix.append(list(map(int, input().split())))
for i in range(n):
	x = matrix[i][0]
	r = matrix[i][1]
	sol = min(x - 1, r)
	sol = sol * (sol + 1)
	sol = sol // 2
	if r >= x:
		sol = sol + 1
	print(sol)


import math
import collections
t = int(input())
import math
for i in range(t):
	(n, r) = map(int, input().split())
	flag = False
	if r >= n:
		flag = True
		r = n - 1
	s = 0
	s = r * (r + 1) // 2
	if flag:
		s += 1
	print(s)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	sumi = 0
	if x > y:
		sumi = y * (y + 1) // 2
	else:
		x = x - 1
		sumi = sumi = x * (x + 1) // 2
		sumi = sumi + 1
	print(sumi)


from math import *

def r1(t):
	return t(input())

def r2(t):
	return [t(i) for i in input().split()]
for _ in range(r1(int)):
	(n, r) = r2(int)
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k * (k + 1) // 2)
	elif n == k:
		print((k - 1) * k // 2 + 1)
	else:
		print((n - 1) * n // 2 + 1)


from sys import stdin
from math import ceil
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, r) = [int(x) for x in inp().split()]
	if r >= n:
		n -= 1
		ans = n * (n + 1) // 2
		ans += 1
		print(ans)
	else:
		ans = r * (r + 1) // 2
		print(ans)


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')
from collections import deque as que
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
Testcase = inin()
for _ in range(Testcase):
	(n, k) = inar()
	if n > k:
		ans = k * (k + 1) // 2
	else:
		ans = n * (n - 1) // 2 + 1
	print(ans)


import sys
import heapq
import random
import collections
import bisect

def solve(n, r):
	if r >= n:
		return n * (n - 1) // 2 + 1
	else:
		return r * (r + 1) // 2

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	(n, r) = list(map(int, input().split()))
	res = solve(n, r)
	print(res)


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def sum(n):
	return n * (n + 1) // 2

def ans(n, r):
	if r < n:
		return sum(r)
	return sum(n - 1) + 1
T = int(input())
for _ in range(T):
	(n, r) = input().split(' ')
	n = int(n)
	r = int(r)
	print(ans(n, r))


ll = lambda : list(map(int, input().split()))
st = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
from collections import *
from math import *
for _ in range(ii()):
	(n, r) = v()
	if n <= r:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


list_ans = []
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r < n:
		list_ans.append((1 + r) * r // 2)
	else:
		list_ans.append((n - 1) * n // 2 + 1)
for item in list_ans:
	print(item)


def sumn(v):
	return v * (v + 1) // 2

def solve():
	(n, r) = [int(v) for v in input().split()]
	if r < n:
		ans = sumn(r)
	else:
		ans = sumn(n - 1) + 1
	print(ans)
t = int(input())
for _ in range(t):
	solve()


def solve():
	(n, r) = list(map(int, input().split()))
	k = min(r, n - 1)
	print(k * (k + 1) // 2 + (r >= n))
for i in range(int(input())):
	solve()


from sys import stdin

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, r) = [int(x) for x in inp().split()]
	if r >= n:
		k = n - 1
		ans = k * (k + 1) // 2 + 1
		print(ans)
	else:
		k = r
		ans = k * (k + 1) // 2
		print(ans)


tt = int(input())
for loop in range(tt):
	(n, r) = map(int, input().split())
	if r >= n:
		print(1 + n * (n - 1) // 2)
	else:
		print(r * (r + 1) // 2)


T = int(input())
for t in range(T):
	(n, r) = (int(i) for i in input().split())
	if n > r:
		print((1 + r) * r // 2)
	else:
		print(n * (n - 1) // 2 + 1)


from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for _ in range(test):
		(n, r) = [int(i) for i in input().split(' ')]
		if n == 1 or r == 1:
			print(1)
		else:
			c = 0
			if r < n:
				c = r * (r + 1) // 2
			else:
				c = n * (n - 1) // 2 + 1
			print(c)
main()


import sys
input = sys.stdin.buffer.readline
a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	if b > c:
		print(c * (c + 1) // 2)
	else:
		print(b * (b - 1) // 2 + 1)


nb_cases = int(input())
for case in range(nb_cases):
	(n, r) = [int(x) for x in input().split()]
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	sum = 0
	if r < n:
		sum = r * (r + 1) // 2
		print(sum)
	else:
		sum = n * (n - 1) // 2
		print(sum + 1)


import sys
readline = lambda : sys.stdin.readline().strip('\n')
readlist = lambda : list(map(int, readline().split()))
for i in range(int(input())):
	(n, r) = readlist()
	s = 0
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)
quit()
for i in range(int(input())):
	n = int(input())
	print(n // 2 + n % 2)
	a = 1


import math

def check(t, h, c, n):
	return abs(t - (n * (h + c) - c) / (2 * n - 1))
li = []

def fact(n):
	sumy = n
	a = 1
	b = n
	for i in range(1, int(n ** (1 / 2)) + 1):
		if n % i == 0 and sumy > i + n / i:
			a = i
			b = n // i
			sumy = a + b
	if b == n:
		li.append(b)
		return
	fact(a)
	fact(b)

def solution():
	(n, k) = map(int, input().split())
	m = min(n, k) - 1
	ans = m * (m + 1) // 2
	if min(n, k) != n:
		ans += k
	else:
		ans += 1
	print(ans)
for _ in range(int(input())):
	solution()


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	print([1 + n * (n - 1) // 2, r * (r + 1) // 2][n > r])


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, sqrt, trunc, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, r) = sp()
	n -= 1
	answer = (0, 1)[r > n]
	n = min(n, r)
	out(answer + n * (n + 1) // 2)


import sys
import math
from math import *
from collections import defaultdict
import os
import sys
from io import BytesIO, IOBase
from collections import deque

def main():
	res = 0
	(a, b) = list(map(int, input().split()))
	if a <= 1:
		print(1)
		return
	if a <= b:
		b = a - 1
		res = 1
	print(res + (1 + b) * b // 2)
for i in range(int(input())):
	main()


def i():
	return int(input())

def I():
	return map(int, input().split())
t = i()
for i in range(t):
	(n, r) = I()
	ans = (1 + min(n - 1, r)) * min(n - 1, r) // 2 + 1
	if n > r:
		ans -= 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	total = 0
	if n > k:
		print(k * (k + 1) // 2)
	elif n <= k:
		print((n - 1) * n // 2 + 1)
	else:
		pass


t = input()
t = int(t)
while t > 0:
	t -= 1
	(n, r) = input().split()
	n = int(n)
	r = int(r)
	l = min(r, n - 1)
	ans = (1 + l) * l // 2
	if r >= n:
		ans += 1
	print(ans)


def main2():
	t = int(input())
	for i in range(t):
		(n, r) = list(map(int, input().split()))
		total = 0
		for k in range(1, r + 1):
			if k >= n:
				if k > n:
					break
				total += 1
			else:
				total += k
		print(total)

def main():
	t = int(input())
	for i in range(t):
		(n, r) = list(map(int, input().split()))
		total = 0
		if n > r:
			total = r * (r + 1) // 2
		if n <= r:
			total = n * (n - 1) // 2 + 1
		print(str(total))
main()


n1 = int(input())
for i in range(n1):
	array = list(map(int, input().rstrip().split()))
	n = array[0]
	r = array[1]
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


for i in range(int(input())):
	(a, b) = [int(num) for num in input().split()]
	if a > b:
		c = b * (b + 1) // 2
		print(c)
	else:
		c = (a - 1) * (a - 2) // 2 + a
		print(c)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if n > r:
		print((r + 1) * r // 2)
	else:
		k = n * (n - 1) // 2
		print(k + 1)


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	k = min(n - 1, r)
	ans = k * (k + 1) // 2
	if r > n - 1:
		ans += 1
	print(ans)


from math import *
from collections import *
from bisect import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		re = n * (n - 1)
		re = re // 2
		print(re + 1)


from sys import *
t = int(stdin.readline())
while t > 0:
	(n, r) = map(int, stdin.readline().split())
	if n > r:
		print((1 + r) * r // 2)
	elif n <= r:
		a = n - 1
		print((a + 1) * a // 2 + 1)
	t -= 1


import sys
input = sys.stdin.readline
for f in range(int(input())):
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		sol = (n - 1) * n // 2
		sol += 1
		print(sol)


t = int(input())
while t > 0:
	(n, r) = map(int, input().split(' '))
	if n > r:
		print(r * (r + 1) // 2)
	elif n == r:
		print(r * (r - 1) // 2 + 1)
	else:
		d = min(n - 1, r - 1)
		print(d * (d + 1) // 2 + 1)
	t -= 1


import sys
t = int(input())
for i in range(t):
	(n, r) = list(map(int, sys.stdin.readline().strip().split()))
	if n <= r:
		x = (n - 1) * (1 + n - 1) // 2 + 1
		print(x)
	else:
		n = r
		x = n * (n + 1) // 2
		print(x)


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	work = min(n, r)
	if work == 1:
		print(1)
		continue
	rs = 0
	if r >= n:
		rs += 1
	if r < n:
		work += 1
	work -= 1
	rs += work * (work + 1) // 2
	print(rs)


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(10000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, r) = int_array()
	if r < n:
		ans = r * (r + 1) // 2
		print(ans)
	else:
		x = n - 1
		ans = x * (x + 1) // 2
		print(ans + 1)


y = int(input())
ans = []
for i in range(y):
	al = input().split()
	m = list(map(int, al))
	n = m[0]
	r = m[1]
	if n > r:
		z = r * (r + 1) // 2
	else:
		z = n * (n - 1) // 2 + 1
	ans.append(z)
for i in ans:
	print(i)


import math
n = int(input())
for w in range(n):
	(a, b) = map(int, input().split())
	x = min(a, b)
	s = x * (x + 1) // 2
	if b >= a:
		s = s - x + 1
	print(s)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	temp = min(n - 1, r)
	ans = temp * (temp + 1) // 2
	temp = max(0, r - n + 1)
	if temp != 0:
		ans += 1
	print(ans)


def solve():
	(n, k) = map(int, input().split())
	p = min(n, k)
	delt = 0
	if p == n:
		p -= 1
		delt = 1
	print(delt + (p * (p + 1) >> 1))
for _ in range(int(input())):
	solve()


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	(n, r) = map(int, input().split())
	if n <= r:
		m = n - 1
		ans = m * (m + 1) // 2
		ans += 1
	else:
		ans = r * (r + 1) // 2
	print(ans)
	t -= 1


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10, 6)))
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
t = 1
t = int(input())
for _ in range(t):
	(n, r) = L()
	if n > r:
		ans = (r + 1) * r // 2
	else:
		ans = (n - 1) * n // 2
		ans += 1
	print(ans)


t = int(input())
while t > 0:
	(n, r) = list(map(int, input().split()))
	x = min(n - 1, r)
	ans = x * (x + 1) // 2
	if r >= n:
		ans = ans + 1
	print(ans)
	t = t - 1


import sys
from decimal import *

def swap(x, y, a):
	temp = a[x]
	a[x] = a[y]
	a[y] = temp
	return a

def solve():
	return None

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(line)
	for i in range(len(q)):
		q[i] = q[i].rstrip().split(' ')
		q[i] = [int(x) for x in q[i]]
	for i in range(1, len(q)):
		n = q[i][0]
		r = q[i][1]
		temp = min(n, r)
		t = temp * (temp + 1) // 2
		if n <= r:
			t = t - n + 1
		print(t)
main()


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	m = min(n - 1, r)
	print(m * (m + 1) // 2 + (r >= n))


R = lambda : map(int, input().split())
(m,) = R()
for i in range(m):
	(n, r) = R()
	if r < n:
		print((1 + r) * r // 2)
	else:
		print(n * (n - 1) // 2 + 1)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, k) = li()
	s = k * (k + 1) // 2
	if k < n:
		print(s)
	else:
		s = n * (n + 1) // 2
		print(s - n + 1)
for _ in range(I()):
	solve()


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve():
	tt = I()
	for ii in range(tt):
		(n, k) = IL()
		m = min(n - 1, k)
		ans = m * (m + 1) // 2
		if m < k:
			ans += 1
		print(ans)
solve()


from math import ceil
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if b >= a:
		b = a
		print((b - 1) * b // 2 + 1)
	else:
		print(b * (b + 1) // 2)


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for i in range(n):
	l = inlt()
	n = l[0]
	r = l[1]
	res = 0
	x = min(n, r + 1)
	res = x * (x - 1) // 2
	if n <= r:
		res += 1
	print(res)


def solve(n, k):
	if k < n:
		return k * (k + 1) // 2
	else:
		return n * (n + 1) // 2 + k - n - (k - 1)
for i in range(int(input())):
	(n, k) = map(int, input().split())
	print(solve(n, k))


a = int(input())
for i in range(a):
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		m = r - n + 1
		x = n - 1
		print(x * (x + 1) // 2 + 1)


import sys
f_in = sys.stdin
f_out = sys.stdout
i = int(f_in.readline())
for j in range(i):
	a = f_in.readline().split(' ')
	n = int(a[0])
	r = int(a[1])
	if r >= n:
		answer = str(int(n * (n - 1) // 2 + 1))
		f_out.write(answer + '\n')
	else:
		answer = str(int(r * (r + 1) // 2))
		f_out.write(answer + '\n')


def solve():
	(n, r) = list(map(int, input().split()))
	last_full_k = min(r, n - 1)
	full_k_count = last_full_k * (last_full_k + 1) // 2
	if r >= n:
		full_k_count += 1
	return full_k_count

def main():
	t = int(input())
	for i in range(t):
		print(solve())
main()


t = int(input())
for cs in range(t):
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)


n = eval(input())
inputs = []
for i in range(n):
	tem = input()
	tem = tem.split()
	inputs.append([int(tem[0]), int(tem[1])])
result = [0 for i in range(n)]
for j in range(n):
	nums = inputs[j]
	(n1, n2) = (nums[0], nums[1])
	tem = min(n1, n2)
	if n1 > n2:
		result[j] += tem * (tem + 1) // 2
	else:
		result[j] += (tem - 1) * tem // 2 + 1
for num in result:
	print(num)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def printMaxPatterns():
	(n, r) = invr()
	if r < n:
		ans = r * (r + 1) // 2
	else:
		ans = n * (n - 1) // 2 + 1
	print(math.floor(ans))
test = inp()
while test > 0:
	printMaxPatterns()
	test -= 1


calendars = eval(input())
for _ in range(calendars):
	(consec, days) = map(int, input().split(' '))
	shapes = 0
	if consec <= days:
		shapes = consec * (consec - 1) // 2 + 1
	else:
		shapes = days * (days + 1) // 2
	print(shapes)


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	ceil = min(n, r)
	tillsum = ceil - 1
	s1 = tillsum * (tillsum + 1) // 2
	if n <= r:
		s1 += 1
	else:
		s1 += ceil
	print(s1)


test_cases = int(input())
while test_cases > 0:
	ans = 0
	(n, r) = map(int, input().split())
	if r >= n:
		ans -= min(n, r)
		toFind = min(n, r)
		ans += (toFind + 1) * toFind // 2 + 1
	else:
		ans += r * (r + 1) // 2
	print(ans)
	test_cases -= 1


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	count = 0
	count_2 = 0
	count_3 = 0
	nn = min(n - 1, r)
	last = nn * (nn + 1) // 2
	count = (1 if n <= r + 0 else 0) + last
	print(count)


def series(first, diff, n):
	last = first + diff * (n - 1)
	return (first + last) * n // 2
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	s = series(1, 1, min(n - 1, r))
	if n <= r:
		s += 1
	print(s)


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import random
import re
import heapq

def sumOfAP(a, d, n):
	sum = n / 2 * (2 + n - 1)
	return sum
t = int(input())
while t:
	t -= 1
	(n, r) = map(int, input().split())
	ans = 0
	nn = min(n, r)
	if n <= r:
		nn -= 1
		ans += 1
	ans += nn * (nn + 1) // 2
	print(int(ans))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	n = min(a - 1, b)
	ans = n * (n + 1) // 2
	if a <= b:
		ans += 1
	print(ans)


t = int(input())
ans = []
for i in range(t):
	(n, r) = input().split()
	n = int(n)
	r = int(r)
	l = 0
	if n > r:
		l = r * (r + 1) // 2
	if n <= r:
		l = n * (n - 1) // 2
		l += 1
	ans.append(l)
for an in ans:
	print(an)


try:
	for _ in range(int(input())):
		(n, r) = map(int, input().split())
		if n <= r:
			ans = n * (n - 1) // 2 + 1
			print(ans)
		else:
			print(r * (r + 1) // 2)
except:
	pass


import math
t = int(input())
for w in range(t):
	(n, r) = (int(i) for i in input().split())
	k = min(n - 1, r)
	s = k * (k + 1) // 2
	if n <= r:
		print(s + 1)
	else:
		print(s)


for i in range(int(input())):
	(n, r) = [int(i) for i in input().split()]
	if n > r:
		sum = (1 + r) * r // 2
	elif n < r:
		el = n - 1
		sum = (1 + el) * el // 2 + 1
	else:
		el = r - 1
		sum = (1 + el) * el // 2 + 1
	print(sum)


def main():
	(n, r) = map(int, input().split())
	if r >= n:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime
from collections import deque
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(int(input())):
		(n, r) = ria()
		if r >= n:
			k = (n - 1) * n // 2
			k += 1
			print(k)
		if r < n:
			k = (r + 1) * r // 2
			print(k)

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k = min(n, k)
	s = k * (k + 1) // 2
	if k == n:
		s -= n - 1
	print(s)


for tc in range(int(input())):
	(n, r) = input().split(' ')
	(n, r) = (int(n), int(r))
	if n <= r:
		print((n - 1) * n // 2 + 1)
	elif n > r:
		print((r + 1) * r // 2)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	res = 0
	res += r * (r + 1) // 2
	if r > n:
		d = r - n
		d += 1
		c = d * (n + r) // 2
		res -= c
		res += 1
	if r == n:
		res -= n - 1
	print(res)


for I in range(int(input())):
	(n, k) = map(int, input().split())
	if n <= k:
		res = n * (n - 1) // 2
		res += 1
	else:
		res = k * (k + 1) // 2
	print(res)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def solve(n, r):
	if r <= n - 1:
		return r * (r + 1) // 2
	return n * (n - 1) // 2 + 1

def main():
	mod = 1000000007
	inv = lambda x: pow(x, mod - 2, mod)
	t = int(input())
	for _ in range(t):
		(n, r) = map(int, input().split())
		ans = solve(n, r)
		sys.stdout.write(str(ans) + '\n')
main()


for _ in range(int(input())):
	(n, r) = [int(x) for x in input().split()]
	if r < n:
		print(r * (r + 1) // 2)
	elif r == n:
		r -= 1
		print(r * (r + 1) // 2 + 1)
	else:
		k = n - 1
		print(k * (k + 1) // 2 + 1)


import math
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	A = min(n, r)
	Sum = A * (A + 1) // 2
	if n <= r:
		print(Sum - n + 1)
	else:
		print(Sum)


t = int(input())
for i in range(t):
	(n, r) = list(map(int, input().split()))
	res = 0
	if n <= r:
		res += n * (n - 1) // 2
		res += 1
	else:
		res += r * (r + 1) // 2
	print(res)


t = int(input())
for test in range(t):
	(n, r) = [int(i) for i in input().split()]
	maxi = min(n - 1, r)
	ans = maxi * (maxi + 1) // 2
	if maxi < r:
		ans += 1
	print(ans)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = inp()
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(n, r) = invr()
	if n < r:
		print(n * (n - 1) // 2 + 1)
	elif n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (r - 1) // 2 + 1)


import math
import bisect
import sys
from collections import OrderedDict
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
T = inp()
for t in range(T):
	(n, r) = invr()
	k = min(n - 1, r)
	out = k * (k + 1) // 2
	if r <= n - 1:
		print(out)
	else:
		print(out + 1)


import math

def read():
	return int(input())

def reads():
	return map(int, input().split())

def f(n):
	return (n + 1) * n // 2

def solve():
	(n, r) = reads()
	print(int(f(min(n - 1, r)) + (r >= n)))
test_num = int(input())
while test_num:
	solve()
	test_num -= 1


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	elif n == r:
		print((r - 1) * r // 2 + 1)
	else:
		s = n * (n - 1) // 2
		print(s + 1)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n, r) = I()
	k = r
	r = min(n, r)
	an = r * (r + 1) // 2
	print(an - n + 1 if n <= k else an)


import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

def count_ans(n, r):
	if n > r:
		return r * (r + 1) // 2
	else:
		ans = n * (n - 1) // 2 + 1
		return ans

def main():
	t = int(input())
	ns = [list(map(int, input().split(' '))) for _ in range(t)]
	for i in range(t):
		print(count_ans(*ns[i]))
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, r) = LI()
		if r < n:
			rr.append(r * (r + 1) // 2)
			continue
		t = n * (n - 1) // 2 + 1
		rr.append(t)
	return JA(rr, '\n')
print(main())


t = int(input())
for _ in range(t):
	(n, r) = list(map(int, input().split()))
	N = min(r, n - 1)
	c = N * (N + 1) // 2
	if r >= n:
		c += 1
	print(c)


testcases = int(input())
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	first = int(temparr[0])
	second = int(temparr[1])
	mins = min(first, second)
	if mins == 1:
		print(1)
		continue
	if first <= second:
		mins -= 1
		formula = mins * (mins + 1) // 2 + 1
		print(formula)
	else:
		formula = mins * (mins + 1) // 2
		print(formula)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far
from math import *
for _ in range(int(input())):
	modulo = 10000007
	(n, r) = map(int, input().split())
	if r >= n:
		ans = (n - 1) * n // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


T = int(input())
for t in range(T):
	(n, r) = map(int, input().split())
	count = 0
	num1 = min(n, r)
	if num1 == n:
		num1 = num1 - 1
		count = 1
	count = count + num1 * (num1 + 1) // 2
	print(count)


from collections import Counter, defaultdict, deque
import sys
input = sys.stdin.readline

def solve():
	(n, r) = [int(x) for x in input().split()]
	if r >= n:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)
tt = int(input())
for test in range(tt):
	solve()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		(n, r) = RL()
		mi = min(n, r)
		res = (mi + 1) * mi // 2
		if r >= n:
			res -= n - 1
		print(res)
main()


def calender(n, r):
	if n > r:
		ans = r * (r + 1) // 2
	elif n == r:
		r -= 1
		ans = r * (r + 1) // 2 + 1
	else:
		r = n - 1
		ans = r * (r + 1) // 2 + 1
	return ans
t = int(input())
for i in range(t):
	(n, r) = [int(j) for j in input().split()]
	print(calender(n, r))


import decimal
D = decimal.Decimal
n = int(input())
while n:
	l1 = [int(x) for x in input().split()]
	m = l1[0]
	r = l1[1]
	sumo = 0
	while r >= m:
		sumo += 1
		r = m - 1
	sumo += r * D((r + 1) / 2)
	print(int(sumo))
	n -= 1


t = int(input())
for i in range(t):
	cnt = 0
	(n, k) = map(int, input().split())
	if k >= n:
		cnt += 1
		k = n - 1
	cnt += k * (k + 1) // 2
	print(cnt)


t = int(input(''))
cases = []

def solve(n, r):
	sum = 0
	max_k = min(n, r)
	total_permutations = max_k * (max_k + 1) // 2
	if r >= n:
		total_permutations = total_permutations - max_k + 1
	return total_permutations
for i in range(t):
	line = input('').split(' ')
	n = int(line[0])
	r = int(line[1])
	print(solve(n, r))


for t in range(int(input())):
	(n, r) = [int(k) for k in input().split()]
	ans = 0
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


import math
from collections import Counter, deque
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()
mod = 10 ** 9 + 7

def s(a):
	print(' '.join(list(map(str, a))))

def solve():
	(n, r) = M()
	if n == 1:
		print(1)
		return
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)
for i in range(I()):
	solve()


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
k = inp()
for i in range(k):
	duo = inlt()
	duo1 = duo[0]
	duo2 = duo[1]
	if duo2 >= duo1:
		denom = (duo1 - 1) * duo1 // 2 + 1
	else:
		denom = duo2 * (duo2 + 1) // 2
	print(denom)


def any(x):
	if x % 2 == 0:
		return (x + 1) * (x // 2)
	else:
		return (x + 1) * (x // 2) + (x + 1) // 2
for t in range(int(input())):
	(n, r) = map(int, input().split())
	if r < n:
		g = any(r)
	else:
		g = any(n - 1) + 1
	print(g)


def solve(n, k):
	ans = 0
	if k >= n:
		ans = n * (n - 1) // 2 + 1
	else:
		ans = k * (k + 1) // 2
	print(ans)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	solve(n, k)


import sys
for _ in range(int(sys.stdin.readline().rstrip())):
	(n, r) = list(map(int, sys.stdin.readline().rstrip().split()))
	j = min(n, r)
	if n <= r:
		j -= 1
	re = (j + 1) * int(j / 2)
	if j % 2 == 1:
		re += int((j + 1) / 2)
	if n <= r:
		re += 1
	print(re)


for z in range(int(input())):
	(n, r) = list(map(int, input().split()))
	if n > r:
		ans = r * (r + 1) // 2
		print(ans)
	else:
		ans = (n - 1) * n // 2
		ans += 1
		print(ans)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def calculate_sum(a, N):
	m = N / a
	sum = m * (m + 1) / 2
	ans = a * sum
	return ans

def series(N):
	return N * (N + 1) // 2
for _ in range(inin()):
	(n, r) = spin()
	if n > r:
		print(int(series(r)))
	else:
		print(int(series(n - 1) + 1))


T = int(input())
for i in range(T):
	(N, R) = map(int, input().split())
	sm = R * (R + 1) // 2
	if R < N:
		ans = sm
	elif R > N:
		ans = N * (N - 1) // 2 + 1
	else:
		ans = (R - 1) * R // 2 + 1
	print(ans)


t = int(input())
for t in range(t):
	x = 0
	(n, r) = map(int, input().split())
	if n <= r:
		r = n - 1
		x = 1
	print(x + (1 + r) * r // 2)


import sys
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

def solve():
	(n, r) = I()
	if n <= r:
		ok = min(n, r)
		print(ok * (ok - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)
(t,) = I()
while t:
	t -= 1
	solve()


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n > x:
		print(x * (x + 1) // 2)
	else:
		n1 = n
		p = n * (n + 1) // 2
		print(p + 1 - n)


import sys
input = iter(sys.stdin.read().splitlines()).__next__
sys.setrecursionlimit(10000)

def sum1toN(N):
	return N * (N + 1) // 2

def solve(N, R):
	res = sum1toN(min(R, N - 1))
	if R >= N:
		res += 1
	return res
TC = int(input())
for tc in range(TC):
	(N, R) = map(int, input().split())
	res = solve(N, R)
	print(res)


input_length = int(input())
while input_length != 0:
	num_string = str(input())
	(n, r) = tuple(num_string.split())
	(n, r) = (int(n), int(r))
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)
	input_length -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m >= n:
		sum = n * (n - 1) // 2
		sum += 1
		print(sum)
		continue
	else:
		sum = m * (m + 1) // 2
		print(sum)
		continue


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, r) = mints()
	r = min(r, n)
	all = r * (r + 1) // 2
	if r == n:
		all -= r - 1
	print(all)
for i in range(mint()):
	solve()


import math
from sys import stdin
from collections import Counter, defaultdict, deque
input = stdin.readline
mod = pow(10, 9) + 7

def solve():
	(n, k) = map(int, input().split())
	if n > k:
		x = k * (k + 1) // 2
		print(x)
	else:
		x = n * (n + 1) // 2
		x = x - (n - 1)
		print(x)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	val = str(input())
	arr = val.split(' ')
	n = int(arr[0])
	r = int(arr[1])
	if r < n:
		a = r * (r + 1) // 2
		print(a)
	else:
		a = (n - 1) * n // 2
		print(a + 1)


t = int(input())
for i in range(t):
	(b, c) = map(int, input().split())
	d = 0
	if b > c:
		d += c * (c + 1) // 2
	else:
		d += 1
		d += (b - 1) * b // 2
	print(d)


import sys
import math
import collections
import heapq

def set_debug(debug_mode=False):
	if debug_mode:
		fin = open('input.txt', 'r')
		sys.stdin = fin

def int_input():
	return list(map(int, input().split()))
t = int(input())
for ti in range(1, t + 1):
	(n, r) = int_input()
	res = 0
	l = 1
	if n <= l:
		print(1)
		continue
	if n <= r:
		r = n - 1
		res = 1
	print(res + (l + r) * (r - l + 1) // 2)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	count = 0
	if r >= n:
		bool = True
	else:
		bool = False
	if bool:
		count += 1
	if bool:
		r = n - 1
		count += r * (r + 1) // 2
	else:
		count += r * (r + 1) // 2
	print(count)


import sys
input = sys.stdin.readline
from math import ceil
for i in range(int(input())):
	(n, r) = map(int, input().split())
	m = min(n, r)
	res = m * (m + 1) // 2
	if r >= n:
		res -= n - 1
	print(res)


def solve():
	(n, r) = list(map(int, input().split()))
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)
t = int(input())
for test in range(t):
	solve()


t = int(input())
for _ in range(t):
	nr = list(map(int, input().rstrip().split()))
	n = nr[0]
	r = nr[1]
	i = 0
	count = 0
	x = 0
	if n > r:
		x = r
		count += x * (x + 1) // 2
		print(count)
		continue
	else:
		x = n
		count += x * (x - 1) // 2
		count += 1
		print(count)


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	for _ in range(int(input())):
		(n, r) = li()
		if n > r:
			print(r * (r + 1) // 2)
		else:
			ans = n * (n - 1) // 2 + 1
			print(ans)
solve()


t = int(input())

def rec(mn, ind, l, b, dp):
	if ind == 0:
		return 0
	else:
		if dp[ind - 1] == 0:
			if mn[ind - 1][0] < l and mn[ind - 1][1] < b:
				dp[ind - 1] = max(rec(mn, ind - 1, l, b, dp), mn[ind - 1][2] + rec(mn, ind - 1, mn[ind - 1][0], mn[ind - 1][1], dp))
			else:
				dp[ind - 1] = rec(mn, ind - 1, l, b, dp)
		return dp[ind - 1]
for _ in range(t):
	(n, k) = map(int, input().split())
	if k >= n:
		print(1 + n * (n - 1) // 2)
	else:
		print(k * (k + 1) // 2)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	(n, r) = vars()
	if n > r:
		ans = (r + 1) * r // 2
	else:
		ans = (n - 1) * n // 2
		ans += 1
	print(ans)
t = int(input())
for _ in range(t):
	main()


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
while t > 0:
	t -= 1
	(n, r) = listIn()
	if n <= r:
		ans = n * (n - 1) // 2 + 1
		print(ans)
	else:
		ans = r * (r + 1) // 2
		print(ans)


def readn():
	return int(input())

def readlist():
	return list(map(int, input().split()))

def readnos():
	return map(int, input().split())
for _ in range(int(input())):
	(n, r) = readnos()
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, r) = list(map(int, input().split()))
	if r >= n:
		print((n - 1) * n // 2 + 1)
	else:
		print(r * (r + 1) // 2)


t = int(input())

def primes(n):
	count = 0
	rl = 0
	while n % 2 == 0:
		n = n // 2
		count += 1
	while n % 3 == 0:
		n = n // 3
		rl += 1
	if n != 1 or count > rl:
		return -1
	else:
		return [rl, count]
from math import *
for xy in range(t):
	(n, r) = [int(x) for x in input().split()]
	if n > r:
		print(r * (r + 1) // 2)
	elif n <= r:
		print(n * (n - 1) // 2 + 1)


import sys
from sys import stdin
input = sys.stdin.readline

def cei(x, y):
	if int(x / y) == x / y:
		return x // y
	else:
		return x // y + 1
for _ in range(int(input())):
	(n, r) = (int(x) for x in input().split())
	if n <= r:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


for tests in range(int(input())):
	(n, r) = map(int, input().split())
	if n <= r:
		ans = n * (n - 1) // 2
		ans += 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


for _ in range(int(input())):
	(n, r) = [int(x) for x in input().split()]
	N = min(n - 1, r)
	answer = N * (N + 1) // 2
	answer += r - n + 1 > 0
	print(answer)


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT

def main():
	for _ in range(int(input())):
		(n, r) = map(int, input().split())
		if r >= n:
			print((n - 1) * n // 2 + 1)
		else:
			print(r * (r + 1) // 2)
main()


import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(N, R) = [int(_) for _ in input().split()]
	up_to = min(R, N) - 1
	answer = up_to * (up_to + 1) // 2
	if R >= N:
		answer += 1
	else:
		answer += R
	print(answer)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(n, r) = getVars()
	m = min(n - 1, r)
	res = m * (m + 1) // 2
	if r >= n:
		res += 1
	print(res)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b < a:
		print(b * (b + 1) // 2)
	else:
		print(a * (a - 1) // 2 + 1)


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
tests = lambda : range(1, int_in() + 1)
case_out = lambda i, o: out('Case #{}: {}'.format(i, o))

def solve(n, r):
	if r >= n:
		return n * (n - 1) // 2 + 1
	return r * (r + 1) // 2
for _ in tests():
	(n, r) = arr_in()
	out(solve(n, r))


t = int(input())
for j in range(t):
	(n, r) = map(int, input().split())
	ans = 0
	i = 1
	if r < n:
		ans = r * (r + 1) // 2
		print(ans)
	elif r == n:
		ans = r * (r - 1) // 2
		ans += 1
		print(ans)
	elif r > n:
		ans = n * (n - 1) // 2
		ans += 1
		print(ans)


def main():
	t = int(input())
	for _ in range(t):
		(n, r) = map(int, input().split())
		i = 0
		b = []
		if r >= n:
			ans = 1
			r = n - 1
		else:
			ans = 0
		print(r * (r + 1) // 2 + ans)
main()


def f(n):
	return n * (n + 1) // 2
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	s = f(min(r, n - 1))
	s += 1 * (r > min(r, n - 1))
	print(s)


t = int(input())
for _ in range(t):
	(n, r) = [int(i) for i in input().split()]
	if n > r:
		print(int(r * (r + 1) >> 1))
	else:
		print(int((n - 1) * (n - 1 + 1) >> 1) + 1)


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	ans1 = 0
	ans2 = 0
	if r < n:
		ans1 = ans1 + r * (r + 1) // 2
	if r >= n:
		ans1 = ans1 + n * (n - 1) // 2
		ans2 = ans2 + 1
	print(ans1 + ans2)


import os, io
from sys import stdout
import collections
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter
from decimal import Decimal

def primes(n):
	sieve = [True] * n
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [i for i in range(3, n, 2) if sieve[i]]

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def powerOfK(k, max):
	if k == 1:
		return [1]
	if k == -1:
		return [-1, 1]
	result = []
	n = 1
	while n <= max:
		result.append(n)
		n *= k
	return result

def prefixSum(arr):
	for i in range(1, len(arr)):
		arr[i] = arr[i] + arr[i - 1]
	return arr

def divisors(n):
	i = 1
	result = []
	while i * i <= n:
		if n % i == 0:
			if n / i == i:
				result.append(i)
			else:
				result.append(i)
				result.append(n / i)
		i += 1
	return result

def kadane(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def digitsSum(n):
	if n == 0:
		return 0
	r = 0
	while n > 0:
		r += n % 10
		n //= 10
	return r
t = int(input())
for _ in range(t):
	(n, r) = list(map(int, input().split()))
	if r >= n:
		result = 1 + Decimal(n - 1) * Decimal(n) / Decimal(2)
		print(int(result))
	elif r < n:
		result = Decimal(r) * Decimal(r + 1) / Decimal(2)
		print(int(result))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def solve(t):
	(n, r) = t
	smaller = min(n, r)
	total = smaller * (smaller - 1) // 2
	if n <= r:
		total += 1
	else:
		total += r
	print(total)
T = inp()
tests = []
for _ in range(T):
	tests.append(inlt())
for t in tests:
	solve(t)


t = int(input())
for g in range(t):
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
		continue
	ans = 1
	a = n - 1
	ans += a * (a + 1) // 2
	print(ans)


for xyz in range(0, int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k * (k + 1) // 2)
	else:
		print(1 + n * (n - 1) // 2)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if n > r:
		val = r * (r + 1) // 2
		print(val)
	else:
		val = (n - 1) * n // 2
		print(val + 1)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(n, r) = map(int, sys.stdin.readline().split())
	k = min(n, r)
	result = k * (k - 1) // 2
	if n > r:
		result += r
	else:
		result += 1
	print(result)


for x in [*open(0)][1:]:
	(n, r) = map(int, x.split())
	mn = min(n, r)
	print((mn - 1) * mn // 2 + 1 if n <= r else mn * (mn + 1) // 2)


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	p = min(a - 1, b)
	print(p * (p + 1) // 2 + (a <= b))


T = int(input())
while T > 0:
	(n, r) = map(int, input().split())
	if r < n:
		res = (1 + r) * r // 2
	else:
		res = n * (n - 1) // 2 + 1
	print(res)
	T -= 1


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for t in range(int(input())):
	(n, r) = map(int, input().split())
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


import math
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	if l > r:
		print(r * (r + 1) // 2)
	else:
		print(l * (l - 1) // 2 + 1)


def getShape(n, c, k):
	r = 0
	shape = []
	cshape = 0
	for _ in range(n):
		shape.append((r, c))
		if c + 1 < k:
			c += 1
		else:
			r += 1
			c = 0
	cmin = float('inf')
	for (r, c) in shape:
		cmin = min(cmin, c)
	result = [(r, c - cmin) for (r, c) in shape]
	if len(result) == 1:
		return 1
	for (r, c) in result:
		found = False
		for (rn, cn) in [(r - 1, c), (r + 1, c), (r, c - 1), (r, c + 1)]:
			if (rn, cn) in result:
				found = True
		if not found:
			return None
	return result

def brute(n, r):
	result = 0
	seenShapes = set([])
	for k in range(1, r + 1):
		for c in range(k):
			shape = getShape(n, c, k)
			if shape is None:
				continue
			hashVal = str(shape)
			if hashVal not in seenShapes:
				result += 1
				seenShapes.add(hashVal)
	return result
import operator as op
from functools import reduce

def fast(n, r):
	if n == 1:
		return 1
	if n == 2:
		if r == 1:
			return 1
		else:
			return 2
	if r < n:
		return r * (r + 1) // 2
	return fast(n, n - 1) + 1

def test():
	n = 3
	r = 4
	b = brute(n, r)
	print(b)
import random

def findPattern():
	t = 100
	for n in range(1, 1000):
		for r in range(1, 1000):
			b = brute(n, r)
			f = fast(n, r)

def randomTest():
	t = 100
	for _ in range(t):
		n = random.randint(1, 100)
		r = random.randint(1, 100)
		print(n, r)
		b = brute(n, r)
		f = fast(n, r)
		if b != f:
			print('Broken')
			print(b, f)
			return

def main():
	t = int(input())
	for _ in range(t):
		(n, r) = [int(x) for x in input().split()]
		result = fast(n, r)
		print(result)
main()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	cnt = 0
	if x <= y:
		print(x * (x - 1) // 2 + 1)
	else:
		print(y * (y + 1) // 2)


import math
from decimal import *
getcontext().prec = 30
t = int(input())
while t:
	t -= 1
	(n, r) = map(int, input().split())
	if r >= n:
		ans = n * (n - 1) // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


from sys import stdin, stdout
from sys import maxsize

def solve():
	pass
test = 1
test = int(input())
for t in range(0, test):
	(n, r) = list(map(int, input().split()))
	if n <= r:
		print(n * (n - 1) // 2 + 1)
	if r < n:
		print(r * (r + 1) // 2)
	ans = solve()


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(n, r) = map(int, stdin.readline().split())
	if n > r:
		print(r * (r + 1) // 2)
		continue
	ans = n * (n - 1) // 2 + 1
	print(ans)


def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split(' ')))
t = read_int()
for case_num in range(t):
	(n, r) = read_ints()
	r = min(r, n)
	l = min(r, n - 1)
	ans = l * (l + 1) // 2
	if r == n:
		ans += 1
	print(ans)


t = int(input())

def countAns(n, r):
	x = min(n - 1, r)
	return (x + 1) * x // 2 + int(n <= r)
for _ in range(t):
	(n, r) = list(map(int, input().split()))
	print(countAns(n, r))


t = eval(input(''))
for i in range(t):
	(a, b) = map(int, input('').split())
	if a > b:
		print(b * (b + 1) // 2)
	else:
		print(a * (a - 1) // 2 + 1)


import math
import sys
import collections
import bisect
from collections import defaultdict
from sys import stdin, stdout
MOD = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 7)

def take_root(num):
	return math.ceil(math.sqrt(num))

def sieve():
	limit = 86028121
	isprime = [1] * 86028122
	isprime[0] = 0
	isprime[1] = 0
	for i in range(2, take_root(limit + 1)):
		if isprime[i] == 1:
			for j in range(i * i, limit + 1, i):
				isprime[j] = 0
	primes = []
	for i in range(limit + 1):
		if isprime[i] == True:
			primes.append(i)
	return primes

def minput():
	return map(int, input().split())

def iinput():
	return int(input())

def strinput():
	return input()

def linput():
	return list(map(int, input().split()))
for _ in range(iinput()):
	(n, r) = minput()
	x = min(n, r)
	x -= 1
	temp = x * (x + 1) // 2
	if n > r:
		temp = temp + r
	else:
		temp += 1
	print(temp)


t = int(input())
while t > 0:
	t -= 1
	(n, r) = map(int, input().strip().split(' '))
	ans = 1 if r >= n else r
	n = min(n, r)
	ans += n * (n - 1) // 2
	print(ans)


for p in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = min(n, k)
	if n > k:
		print(a * (a + 1) // 2)
	else:
		print(a * (a - 1) // 2 + 1)


import collections as cc
import math as mt
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, k) = I()
	d = 0
	if k >= n:
		d = abs(n - k)
		n -= 1
		print(n * (n + 1) // 2 + 1)
	else:
		print(k * (k + 1) // 2)


from math import ceil, log, floor, sqrt
import math

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_k(x, y, n):
	return (n - y) // x * x + y

def count_sticks(n):
	if n % 2 == 0:
		return n // 2
	return n // 2 + 1

def get_types(n, r):
	if r < n:
		return r * (r + 1) // 2
	r = n - 1
	return r * (r + 1) // 2 + 1
t = 1
t = int(input())
while t:
	t = t - 1
	(n, r) = map(int, input().split())
	print(get_types(n, r))


from sys import stdin
input = stdin.readline
import bisect
import math
for xoxo in range(1):

	def s(x):
		return (x + 1) * x // 2
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		x = min(n, k)
		if k >= n:
			xx = s(n - 1)
			print(xx + 1)
		else:
			print(s(k))


import sys
readline = sys.stdin.readline
t = int(readline())
for _ in range(t):
	(n, r) = map(int, readline().split())
	x = min(n, r)
	if n <= r:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


production = True
import sys, math, collections

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()[:-1]
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = list(next_line)
		elif input_format == 4:
			formatted_input = list(map(int, list(next_line)))
		elif input_format == 5:
			formatted_input = next_line.split()
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 2:
		formatted_output = '\n'.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c

def mapl(iterable, format=0):
	if format == 0:
		return list(map(int, iterable))
	elif format == 1:
		return list(map(str, iterable))
	elif format == 2:
		return list(map(list, iterable))

def solve():
	(n, r) = input(1)
	k = min(r, n - 1)
	f = k * (k + 1) // 2
	if n <= r:
		f += 1
	out(f)
	return
for i in range(input(11)):
	solve()


import math
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a <= b:
		sumi = (a - 1) * a // 2
		print(sumi + 1)
	else:
		sumi = b * (b + 1) // 2
		print(sumi)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
for _ in range(II()):
	(n, r) = MI()
	mx = min(n - 1, r)
	ans = mx * (mx + 1) // 2 + (r >= n) * 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def sm(a, b):
	return b * (b + 1) // 2 - (a - 1) * a // 2
for _ in range(int(input()) if True else 1):
	(n, k) = map(int, input().split())
	ans = min(n - 1, k) * (min(n - 1, k) + 1) // 2
	if n <= k:
		ans += 1
	print(ans)


import sys

def read_num_list():
	return [int(i) for i in sys.stdin.readline().split()]

def solve(_turn):
	(n, r) = read_num_list()
	a = min(n - 1, r)
	res = a * (a + 1) // 2
	if r >= n:
		res += 1
	print(res)

def main():
	T = read_num_list()[0]
	for i in range(T):
		solve(i + 1)
main()


for pratyush in range(int(input())):
	(n, r) = map(int, input().split())
	a = min(r, n - 1)
	ans = int(a * (a + 1) // 2)
	if a != r:
		ans += 1
	print(ans)


import sys, math, os
from io import BytesIO, IOBase
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = 10 ** 9
mod = 998244353
for t in range(int(data())):
	(n, r) = mdata()
	k = min(n, r)
	k = k * (k + 1) // 2
	if n <= r:
		k -= min(n, r) - 1
	out(k)


def mi():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return input().split()
t = ii()
for _ in range(t):
	(n, r) = mi()
	if n > r:
		print(r * (r + 1) // 2)
		continue
	if n == r:
		r -= 1
		ans = r * (r + 1) // 2
		print(ans + 1)
	else:
		n -= 1
		ans = n * (n + 1) // 2
		print(ans + 1)


def read_int():
	return int(input().strip())

def read_ints():
	return list(map(int, input().strip().split(' ')))

def solve():
	(n, r) = read_ints()
	if r < n:
		return r * (r + 1) // 2
	return 1 + n * (n - 1) // 2
T = read_int()
for _ in range(T):
	print(solve())


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, R):
	brute = 0
	M = min(R + 1, N)
	brute += M * (M - 1) // 2
	if N <= R:
		brute += 1
	return brute
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, R) = [int(x) for x in input().split()]
	ans = solve(N, R)
	print(ans)


for q in [*open(0)][1:]:
	(a, p) = map(int, q.split())
	print((a * a - a + 2, p * p + p)[a > p] // 2)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	ans = 0
	mx = min(n, r + 1)
	print(mx * (mx - 1) // 2 + int(n <= r))


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, r) = map(int, input().split())
	x = r * (r + 1) >> 1
	if n > r:
		print(x)
	else:
		y = n * (n - 1) >> 1
		print(y + 1)


def shape(n, r):
	if r < n:
		return r * (r + 1) // 2
	return shape(n, n - 1) + 1
test = int(input())
matrix = []
for _ in range(test):
	lst = list(map(lambda elem: int(elem), input().split(' ')))
	matrix.append(lst)
for [n, r] in matrix:
	print(shape(n, r))


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, k) = R()
	print(sm(min(n - 1, k)) + min(1, max(k - n + 1, 0)))


T = int(input())
while T > 0:
	raw = input().split()
	(n, r) = (int(raw[0]), int(raw[1]))
	ans = int(0)
	if n <= r:
		ans = (n - 1) * n // 2 + 1
	else:
		ans = (r + 1) * r // 2
	print(ans)
	T = T - 1


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	x = min(n - 1, r)
	ans = x * (x + 1) >> 1
	if n <= r:
		ans += 1
	print(ans)


from sys import stdin, stdout
from bisect import bisect, bisect_left, bisect_right

def gt():
	return map(int, stdin.readline().split())

def gi():
	return int(stdin.readline())

def gl():
	return list(map(int, stdin.readline().split()))

def gs():
	return stdin.readline()
t = gi()
for _ in range(t):
	(n, r) = gt()
	if n > r:
		n = min(n, r)
		print(n * (n + 1) // 2)
	else:
		n = min(n, r)
		print(n * (n - 1) // 2 + 1)


from sys import stdin, stdout
q = int(input())
for i in range(q):
	(n, r) = list(map(int, stdin.readline().split()))
	if n > r:
		d = r * (r + 1) // 2
		print(d)
	elif n == r:
		d = (r - 1) * r // 2
		print(d + 1)
	else:
		d = (n - 1) * n // 2
		print(d + 1)


for _ in range(int(input())):
	(n, r) = list(map(int, input().split()))
	x = min(n - 1, r)
	p = 0
	if r >= n:
		p = 1
	print(x * (x + 1) // 2 + p)


from collections import deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_left as bl
from math import log2, ceil
from itertools import permutations

def main():
	for t in range(int(input())):
		(n, r) = [int(j) for j in input().split()]
		if r < n:
			print(r * (r + 1) // 2)
		else:
			print(n * (n - 1) // 2 + 1)
main()


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		(N, r) = map(int, input().split())
		if r >= N:
			print(N * (N - 1) // 2 + 1)
		else:
			print(r * (r + 1) // 2)
main()


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	q = min(n - 1, r)
	ans = q * (q + 1) // 2
	print(ans + (r >= n))


rr = lambda : input().strip()
rrm = lambda : map(int, rr().split())

def solve():
	(n, r) = rrm()
	ans = 0
	if n > r:
		ans = r * (r + 1) // 2
	else:
		ans = n * (n - 1) // 2
		ans += 1
	return ans
T = int(rr())
for _ in range(T):
	ans = solve()
	print(ans)


def readintlst():
	return list(map(int, input().split(' ')))

def readn():
	return int(input())
import math
for _ in range(readn()):
	(n, r) = readintlst()
	ans = 0
	mm = min(n - 1, r)
	ans = (1 + mm) * mm // 2
	if r >= n:
		ans += 1
	print(ans)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from copy import copy
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, r) = map(int, input().split())
		d = min(n - 1, r)
		ans = d * (d + 1) // 2
		if r >= n:
			ans += 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	(day, week) = map(int, input().split())
	m = min(day - 1, week)
	ans = (m + 1) * m // 2 + int(day <= week)
	print(ans)


t = int(input())
for i in range(t):
	l = [int(i) for i in input().split()]
	n = l[0]
	r = l[1]
	if r == 1 or n == 1:
		print(1)
	elif n <= r:
		print((n - 1) * n // 2 + 1)
	else:
		print(r * (r + 1) // 2)


def func(n, r):
	if n > r:
		print((r + 1) * r // 2)
	else:
		print((n - 1) * n // 2 + 1)
cases = int(input())
for i in range(cases):
	(n, r) = map(int, input().split())
	func(n, r)


from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
	(n, r) = list(map(int, stdin.readline().split()))
	cnt = 0
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


try:
	t = int(input())
	while t:
		(n, r) = [int(x) for x in input().split()]
		if n > r:
			h = r * (r + 1)
			print(h // 2)
		else:
			j = n * (n + 1)
			j = j // 2
			s = j - (n - 1)
			print(s)
		t -= 1
except:
	pass


def f():
	(n, r0) = [int(s) for s in input().split()]
	r = min(n - 1, r0)
	ans = r * (r + 1) // 2
	if r0 >= n:
		ans += 1
	print(ans)
for t in range(int(input())):
	f()


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	m = 0
	if n <= r:
		m += n * (n - 1) // 2 + 1
	if n > r:
		m += r * (r + 1) // 2
	print(m)


for _ in range(int(input())):
	(n, r) = (int(i) for i in input().split())
	print(min(r + 1, n) * min(r, n - 1) // 2 + int(r >= n))


for i in range(int(input())):
	(n, r) = map(int, input().split())
	if n > r:
		a = r * (r + 1)
		print(a // 2)
	else:
		b = n - 1
		a = b * (b + 1)
		c = a // 2
		print(c + 1)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
test = inp()
for i in range(0, test):
	nk = inlt()
	n = nk[0]
	k = nk[1]
	if n > k:
		answer = k * (k + 1) // 2
	else:
		answer = n * (n - 1) // 2 + 1
	print(answer)


from math import *
t = int(input())
while t > 0:
	(n, r) = [int(x) for x in input().split()]
	r = min(n, r)
	if r == n:
		ans = 1
		r -= 1
	else:
		ans = 0
	ans = ans + r * (r + 1) // 2
	print(ans)
	t -= 1


import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	T = int(input())
	for _ in range(T):
		(N, R) = getlist()
		if N > R:
			ans = int(R * (R + 1) // 2)
			print(ans)
		else:
			ans = int(N * (N - 1) // 2)
			ans += 1
			print(ans)
main()


from decimal import Decimal as D
cases = int(input())
for i in range(cases):
	l1 = input().split(' ')
	n = D(l1[0])
	r = D(l1[1])
	if n == r:
		shape = (r - D(1)) * r / D(2) + D(1)
		print(int(shape))
	elif n < r:
		shape = n * (n - D(1)) / D(2) + D(1)
		print(int(shape))
	elif n > r:
		shape = r * (r + D(1)) / D(2)
		print(int(shape))


import sys
INF = 10 ** 18
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()
YesNo = lambda b: bool([print('Yes')] if b else print('No'))
YESNO = lambda b: bool([print('YES')] if b else print('NO'))
int1 = lambda x: int(x) - 1
T = int(input())
for _ in range(T):
	(N, R) = map(int, input().split())
	ans = 0
	if N >= R + 1:
		ans += (1 + R) * R // 2
	else:
		ans += (1 + (N - 1)) * (N - 1) // 2
		ans += 1
	print(ans)


a = input()
for x in range(int(a)):
	b = input().split(' ')
	c = int(b[1])
	b = int(b[0])
	ans = 0
	if b > c:
		print((1 + c) * c // 2)
	else:
		print(b * (b - 1) // 2 + 1)


try:
	tc = int(input())
except:
	exit()
for _ in range(tc):
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	v = min(r, n - 1)
	s = v * (v + 1) // 2
	if r >= n:
		s += 1
	print(s)


import math
t = int(input())
for _ in range(t):
	(n, r) = [int(i) for i in input().split()]
	if r >= n:
		n1 = n * (n - 1) // 2
		print(n1 + 1)
	else:
		n1 = r * (r + 1) // 2
		print(n1)


import sys
input = sys.stdin.readline
f = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, r) = f()
	if r < n:
		ans = r * (r + 1) // 2
	else:
		ans = (n - 1) * n // 2 + 1
	print(ans)


def solve():
	(n, r) = map(int, input().split())
	lim = min(n, r + 1)
	count = lim * (lim - 1) // 2
	if r >= n:
		count += 1
	print(count)
t = int(input())
for _ in range(t):
	solve()


T = int(input())

def solve(n, r):
	if n <= r:
		if (n - 1) % 2 == 0:
			a = int(n - 1) // 2
			ret = int(a * n) + 1
		else:
			a = int(n // 2)
			ret = int(a * (n - 1)) + 1
	elif n > r:
		if (r + 1) % 2 == 0:
			a = int((r + 1) / 2)
			ret = int(a * r)
		else:
			a = int(r // 2)
			ret = int(a * (r + 1))
	return ret

def solve2(n, r):
	ret = 1
	for k in range(2, r + 1):
		if n > k:
			ret += k
		else:
			ret += 1
			break
	return ret
while T > 0:
	(n, r) = [int(el) for el in input().split(' ')]
	print(solve(n, r))
	T -= 1


def magic(n, r):
	if r < n:
		return r * (r + 1) // 2
	else:
		return n * (n - 1) // 2 + 1
t = int(input())
array = []
for i in range(t):
	array.append(list(map(int, input().split(' '))))
for x in array:
	print(magic(*x))


t = int(input())
for k in range(t):
	(n, k) = map(int, input().split())
	if n - 1 < k:
		s = n - 1
		res = s * (s + 1) // 2 + 1
	else:
		s = k
		res = s * (s + 1) // 2
	print(res)


def main(n, r):
	if n > r:
		re = (1 + r) * r // 2
	else:
		re = (1 + n - 1) * (n - 1) // 2
		re += 1
	if n == 1:
		re = 1
	return re
t = int(input())
for i in range(t):
	(n, r) = list(map(int, input().split()))
	re = main(n, r)
	print(re)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	(n, r) = ip()
	ans = 0
	if n > r:
		ans = r * (r + 1) // 2
	else:
		ans = n * (n - 1) // 2 + 1
	print(ans)


import sys, math, cmath, time
start_time = time.time()

def solve():
	(n, r) = invr()
	if n > r:
		q = r * (r + 1) // 2
	else:
		q = n * (n - 1) // 2
		q = q + 1
	print(q)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = (q[ord(a[i]) - 97], 1)
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


for i in range(int(input())):
	(n, r) = map(int, input().split())
	ct = 0
	if r >= n:
		ct = (n - 1) * n // 2 + 1
		print(int(ct))
	elif r < n:
		ct = r * (r + 1) // 2
		print(int(ct))


import math
t = int(input())
for i in range(0, t):
	(n, r) = map(int, input().split())
	if n > r:
		r = r * (r + 1)
		print(r // 2)
	else:
		n = n * (n - 1)
		print(n // 2 + 1)


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, r) = [int(x) for x in input().split()]
		ans = 0
		if n > r:
			ans += r * (r + 1) // 2
		elif n == r:
			ans += r * (r - 1) // 2
			ans += 1
		else:
			ans += n * (n - 1) // 2
			ans += 1
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def solve(n, r):
	k = min(r, n - 1)
	res = k * (k + 1) // 2
	if n <= r:
		res += 1
	return res
t = int(input())
for i_t in range(t):
	current_str = input().split(' ')
	n = int(current_str[0])
	r = int(current_str[1])
	print(solve(n, r))


import sys
lines = sys.stdin.readlines()
T = int(lines[0].strip())
for t in range(T):
	(n, r) = map(int, lines[t + 1].strip().split(' '))
	mini = min(n - 1, r)
	res = mini * (mini + 1) // 2
	if n - 1 < r:
		res += 1
	print(res)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def solve(n, r):
	m = min(n - 1, r)
	return m * (m + 1) // 2 + (1 if r >= n else 0)

def main():
	for _ in range(ri()):
		(n, r) = ria()
		wi(solve(n, r))
main()


import sys

def sum1toN(n):
	if n % 2 == 0:
		return (n + 1) * (n // 2)
	else:
		return n // 2 * (n + 1) + (n // 2 + 1)

def answer(n, r):
	if n == 1:
		return 1
	if r == 1:
		return 1
	if r <= n - 1:
		return sum1toN(r)
	else:
		return sum1toN(n - 1) + 1
	return

def main():
	t = int(input())
	while t:
		(n, r) = [int(i) for i in sys.stdin.readline().split()]
		print(answer(n, r))
		t -= 1
	return
main()


def f(n, r):
	if r >= n:
		return n * (n - 1) // 2 + 1
	else:
		return r * (r + 1) // 2
for tc in range(int(input())):
	al = list(map(int, input().split()))
	print(f(al[0], al[1]))


for _ in range(int(input())):
	(n, k) = [int(c) for c in input().split()]
	if k >= n:
		i = n - 1
		ans = i * (i + 1) // 2
		ans += 1
	else:
		i = k
		ans = i * (i + 1) // 2
	print(ans)


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	nk = stdin.readline().split()
	n = int(nk[0])
	r = int(nk[1])
	r = min(n, r)
	if r <= n - 1:
		stdout.write(str((r + 1) * r // 2) + '\n')
	else:
		stdout.write(str(n * (n - 1) // 2 + r - n + 1) + '\n')


from fractions import Fraction
cases = int(input())
for _ in range(cases):
	[n, r] = input().split()
	n = int(n)
	r = int(r)
	n = Fraction(n)
	n1 = Fraction(n - 1)
	r = Fraction(r)
	r1 = Fraction(r + 1)
	h = Fraction(0.5)
	if r >= n:
		an = int(n * n1)
		ans = int(Fraction(an) * h) + 1
	else:
		an = int(r * r1)
		ans = int(Fraction(an) * h)
	print(ans)


for i in range(int(input())):
	(n, r) = map(int, input().split())
	ans = 0
	if r >= n:
		ans = 1
	r = min(n - 1, r)
	print(r * (r + 1) // 2 + ans)


ans = []
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r >= n:
		ansi = n * (n - 1) // 2 + 1
	else:
		ansi = r * (r + 1) // 2
	ans.append(ansi)
print('\n'.join(map(str, ans)))


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	(n, k) = list(map(int, input().split()))
	if n > k:
		x = k
		ans = x * (x + 1) // 2
	else:
		x = n - 1
		ans = x * (x + 1) // 2
		ans += 1
	print(ans)


import sys

def Nsum(n):
	return n * (n + 1) // 2
t = int(input())
while t:
	t = t - 1
	(n, r) = list(map(int, input().split()))
	if r < n:
		print(str(Nsum(r)))
	else:
		{print(str(Nsum(n - 1) + 1))}


import sys
n = int(sys.stdin.readline())
for i in range(n):
	(n, r) = [int(i) for i in sys.stdin.readline().split()]
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


t = int(input())
for _ in range(t):
	(n, r) = [int(i) for i in input().split()]
	res = 0
	r = min(r, n)
	if n == r:
		print((1 + n - 1) * (n - 1) // 2 + 1)
	else:
		print((1 + r) * r // 2)


t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	ans = 0
	a1 = min(b, a)
	if a1 == a:
		a1 -= 1
	ans += (a1 + 1) * a1 // 2
	if b >= a:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, r) = [int(x) for x in input().split()]
	i = min(r, n - 1)
	count = i * (i + 1) // 2
	if r >= n:
		count += 1
	print(count)


import functools
import heapq as hp
import collections
import bisect
import math

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
	return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def main():
	for _ in range_n():
		(n, r) = unpack()
		if n > r:
			ans = r * (r + 1) // 2
		else:
			ans = n * (n - 1) // 2 + 1
		print(ans)
main()


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	if n - 1 < k:
		print((n - 1) * n // 2 + 1)
	else:
		print(k * (k + 1) // 2)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	count = 0
	if r < n:
		k = r * (r + 1) // 2
	else:
		k = n * (n - 1) // 2 + 1
	print(k)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, r) = li()
	print(n * (n - 1) // 2 + 1 if n <= r else r * (r + 1) // 2)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		l = 1
		res = 0
		(n, r) = map(int, input().split())
		if n <= l:
			print(1)
			continue
		if n <= r:
			r = n - 1
			res = 1
		print(res + (r - l + 1) * (r + l) // 2)
main()


import sys
input = sys.stdin.buffer.readline

def solution():
	for _ in range(int(input())):
		(n, r) = map(int, input().split())
		if n > r:
			print(r * (r + 1) // 2)
		else:
			x = n - 1
			ans = x * (x + 1) // 2
			print(ans + 1)
solution()


import sys
input = sys.stdin.readline
ans = []
for i in range(int(input())):
	anwser = 0
	(n, r) = map(int, input().split())
	if n > r:
		ans.append(r * (r + 1) // 2)
	else:
		ans.append(n * (n - 1) // 2 + 1)
print(*ans, sep='\n')


for qq in range(int(input())):
	(n, r) = map(int, input().split())
	x = min(n - 1, r)
	print(x * (x + 1) // 2 + (n <= r))


from sys import stdin, stdout
import math
input = stdin.readline

def print(x='', y='', end='\n'):
	if y == '':
		stdout.write(str(x) + end)
	else:
		stdout.write(str(x) + ' ' + str(y) + end)

def solve():
	(n, r) = map(int, input().split())
	ans = r * (r + 1) // 2
	if r < n:
		print(ans)
		return
	ans = n * (n + 1) // 2
	ans -= n
	ans += 1
	print(ans)
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


from collections import defaultdict

def is_pw(x):
	d = 1
	while d < x:
		d *= 3
	return d == x
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


from math import gcd
import sys
t = int(input())

def inp():
	return sys.stdin.readline().strip()
for _ in range(t):
	(n, r) = map(int, inp().split())
	ans = 0
	if n > r:
		ans = r * (r + 1) // 2
	else:
		ans = 1 + n * (n - 1) // 2
	print(ans)


t = int(input())
while t > 0:
	t = t - 1
	(n, m) = input().split()
	a = int(n)
	b = int(m)
	if a > b:
		ans = (b + 1) * b // 2
		print(int(ans))
	else:
		a = a - 1
		ans = (a + 1) * a // 2
		print(int(ans + 1))


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	(n, r) = map(int, inputi().split())
	if r < n:
		res = r * (r + 1) // 2
	else:
		res = n * (n - 1) // 2 + 1
	print(res)

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


for tt in range(int(input())):
	(n, r) = map(int, input().split())
	ans = r * (r + 1) // 2
	if n <= r:
		r = n - 1
		ans = r * (r + 1) // 2
		ans += 1
	print(ans)


PUTIN_HELP_ME = not None
NAVALNY_HELP_ME = not None
DURKA_HELP_ME = not None
import sys, os, re
from math import *
from random import *

class Answer(BaseException):

	def __init__(self, txt):
		self.__text = txt

	def what(self):
		return self.__text

def answer(arg):
	raise Answer

def lcm(a, b: int):
	return a * b // gcd(a, b)

def readArr(modifier=int):
	return list(map(modifier, input().split()))

def rA(m=int):
	return readArr(m)

def chomp(s: str):
	return s[:-1] if s[-1] == '\n' else s

def readFile(name: str):
	f = open(name, 'r')
	r = f.readlines()
	f.close()
	return r

def init_all():
	sys.setrecursionlimit(max(sys.getrecursionlimit(), 500000))

def lower_bound(a, k):
	(l, r) = (0, len(a) - 1)
	while l != r:
		mid = (l + r) // 2
		if a[mid] < k:
			l = mid + 1
		else:
			r = mid
	return l

def upper_bound(a, k):
	(l, r) = (0, len(a) - 1)
	while l + 1 < r:
		mid = (l + r) // 2
		if a[mid] <= k:
			l = mid
		else:
			r = mid - 1
	if a[r] == k:
		return r
	else:
		return l

class poly_hash:

	def __init__(self, s):
		self.seed = 228
		self.M = 1000000007
		self.n = len(s)
		self.pows = [1]
		self.hsh = [0 for _ in range(self.n + 1)]
		for _ in range(self.n):
			self.pows.append(self.pows[-1] * self.seed % self.M)
		for i in range(self.n):
			self.hsh[i + 1] = (self.hsh[i] * self.seed + s[i]) % self.M

	def sub_hash(self, l, r):
		return (self.hsh[r] - self.hsh[l] * self.pows[r - l]) % self.M

def pre_func(s):
	p = [0]
	a = 0
	for i in range(1, len(s)):
		while a > 0 and s[i] != s[a]:
			a = p[a - 1]
		if s[i] == s[a]:
			a += 1
		p.append(a)
	return p

def solve():
	(n, r) = readArr()
	s = lambda x: x * (x + 1) // 2
	print(1 + s(n - 1) if r >= n else s(r))

def main(argv: list):
	init_all()
	t = 1
	t = int(input())
	for _ in range(t):
		try:
			solve()
		except Answer as a:
			print(a.what())
	return 0
exit(main(sys.argv))


from fractions import Fraction
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
krish = 1000
res = krish - 900
t = int(input())
for _ in range(t):
	(n, r) = [int(x) for x in input().split()]
	if n <= r:
		c = 1
		k = n - 1
	else:
		c = 0
		k = r
	c += k * (k + 1) // 2
	print(c)
	res += 1


def sum(x):
	ans = x * (x + 1) // 2
	return ans
for ii in range(int(input())):
	(n, k) = map(int, input().split())
	co = 0
	if n <= k:
		print(sum(n - 1) + 1)
	else:
		print(sum(k))


import math
import sys
imput = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k * (k + 1) // 2)
	else:
		n -= 1
		print(n * (n + 1) // 2 + 1)


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	if n > m:
		k = m * (m + 1) // 2
	else:
		k = n * (n - 1) // 2 + 1
	print(k)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
start_time = time.time()

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 998244353

def solve():
	(N, R) = getInts()
	if R >= N:
		return N * (N - 1) // 2 + 1
	return R * (R + 1) // 2
for _ in range(getInt()):
	print(solve())


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, r) = map(int, sys.stdin.readline().split())
	if n > r:
		sum = r * (r + 1) // 2
	else:
		sum = (n - 1) * n // 2
		sum += 1
	sys.stdout.write(str(sum) + '\n')


T = int(input())
for _ in range(T):
	(n, r) = map(int, input().split())
	r = min(n, r)
	ans = r * (r + 1) >> 1
	if r == n:
		ans -= r - 1
	print(ans)


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
for _ in range(int(input())):
	(n, r) = arrIN()
	if n == 1:
		print(1)
	elif n == 2:
		if r >= 2:
			print(2)
		else:
			print(1)
	else:
		mn = min(n, r)
		if n <= mn:
			mn -= 1
			print(mn * (mn + 1) // 2 + 1)
		else:
			print(mn * (mn + 1) // 2)


def main(n, r):
	sum0 = (n - 1) * n // 2
	if r >= n:
		return sum0 + 1
	else:
		return (r + 1) * r // 2
for _ in range(int(input())):
	(n, r) = [int(x) for x in input().split()]
	print(main(n, r))


import sys
from sys import stdin
from collections import deque, Counter
from math import factorial
from itertools import groupby

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, r) = neo()
	t = min(n, r)
	if n > r:
		print(t * (t + 1) // 2)
	else:
		print(1 + t * (t - 1) // 2)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque, defaultdict
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000000 + 7
mod2 = 998244353
for _ in range(I()):
	(n, r) = M()
	if r < n:
		s = r * (r + 1) // 2
	elif r == n:
		s = n * (n - 1) // 2 + 1
	else:
		s = n * (n - 1) // 2 + 1
	print(s)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
from bisect import bisect, bisect_right, bisect_left

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	(n, r) = get_tuple()
	if n > r:
		return r * (r + 1) // 2
	else:
		ans = n * (n + 1) // 2
		return ans - (n - 1)

def main():
	print(solve())
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


import sys
t = int(sys.stdin.readline())
while t:
	(n, r) = map(int, sys.stdin.readline().strip().split())
	if n > r:
		count = r * (r + 1) // 2
	else:
		count = (n - 1) * n // 2 + 1
	print(count)
	t -= 1


import math
t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	count = 0
	if k < n:
		j = k
	else:
		j = n - 1
		count += 1
	count += j * (j + 1) // 2
	print(count)


t = int(input())
while t > 0:
	t -= 1
	(n, r) = map(int, input().split())
	if n > r:
		if r % 2 == 1:
			print(r * ((r + 1) // 2))
		elif r % 2 == 0:
			print((r + 1) * (r // 2))
	elif n <= r:
		n -= 1
		if n % 2 == 1:
			print(n * ((n + 1) // 2) + 1)
		elif n % 2 == 0:
			print((n + 1) * (n // 2) + 1)


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	m = min(n, r)
	m1 = m * (m + 1) // 2
	if r >= n:
		m1 = m1 - n + 1
	print(m1)


q = int(input())
for blah in range(q):
	(n, r) = map(int, input().split(' '))
	ans = 0
	if n > r:
		print(r * (r + 1) // 2)
	else:
		ans = n * (n - 1) // 2
		ans += 1
		print(ans)


for x in range(int(input())):
	(n, r) = list(map(int, input().split()))
	if n > r:
		print(r * (r + 1) // 2)
	else:
		k = n * (n - 1) // 2
		k += 1
		print(k)


import math
import datetime
import collections
import statistics
import itertools

def is_prime(num):
	for i in range(2, int(math.sqrt(num)) + 1):
		if num % i == 0:
			return False
	return True

def input_list():
	ll = list(map(int, input().split(' ')))
	return ll
tc = int(input())
for _ in range(tc):
	(n, r) = map(int, input().split())
	if r >= n:
		ans = n * (n - 1) // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	(n, r) = MI()
	if r < n:
		s = r * (r + 1) // 2
	else:
		s = (n - 1) * n // 2 + 1
	print(s)


for i in range(int(input())):
	(n, r) = list(map(int, input().split()))
	if r == 1:
		print(1)
	else:
		g = min(r, n - 1)
		ans = g * (g + 1) // 2
		if r >= n:
			ans += 1
		print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, r) = value()
	if n > r:
		ans = r * (r + 1) // 2
	else:
		n -= 1
		ans = n * (n + 1) // 2 + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, r) = [int(x) for x in input().split()]
	p = min(n - 1, r)
	ans = (p * p + p) // 2
	if r >= n:
		ans += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = min(n - 1, k)
	c = 0
	if d < k:
		c = 1
	print(d * (d + 1) // 2 + c)


for u in range(int(input())):
	(n, m) = map(int, input().split())
	if n > m:
		print(m * (m + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


from bisect import insort_right, insort_left, bisect_left, bisect_right
from heapq import heapify, heappop, heappush
t = int(input())
while t:
	t -= 1
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


for iota in range(int(input())):
	nr = input().split()
	n = int(nr[0])
	r = int(nr[1])
	if r >= n:
		print((n * (n - 1) >> 1) + 1)
	else:
		print(r * (r + 1) >> 1)


import sys
import math
input = sys.stdin.readline
from collections import deque
from queue import LifoQueue
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	ans = 0
	if n <= r:
		print((n - 1) * n // 2 + 1)
	else:
		print((r + 1) * r // 2)


def solution(n, k):
	if k < n:
		return k * (k + 1) // 2
	ans = n * (n - 1) // 2
	return ans + 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(solution(n, k))


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	(n, r) = rl()
	tot = 0
	m = min(n - 1, r)
	tot = m * (m + 1) // 2
	if n <= r:
		tot += 1
	print(tot)
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


def read_line(type_=int):
	return list(map(type_, input().split()))
t = int(input())
for _ in range(t):
	(n, r_) = read_line()
	r = min(r_, n - 1)
	ans = r * (r + 1) // 2
	if n <= r_:
		ans += 1
	print(ans)


import os
from sys import stdin, stdout

def solve(tc):
	(n, r) = map(int, stdin.readline().split())
	cnt = 0
	if n <= r:
		cnt += n * (n - 1) // 2
		cnt += 1
	else:
		cnt = (r + 1) * r // 2
	print(cnt)
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


def shapes(n, r):
	ans = (1 + min(n - 1, r)) * min(n - 1, r) // 2
	if r >= n:
		ans += 1
	return ans
t = int(input())
for i in range(t):
	s = input()
	(n, r) = (int(s.split()[0]), int(s.split()[1]))
	print(shapes(n, r))


T = int(input())
for _ in range(T):
	(n, r) = map(int, input().split())
	if r >= n:
		mini = min(n, r)
		ans = 0
		ans = mini * (mini - 1)
		ans //= 2
		print(ans + 1)
	else:
		mini = min(n, r)
		ans = mini * (mini + 1)
		ans //= 2
		print(ans)


N = int(input())
i = 0
while i < N:
	l = list(map(int, input().split()))
	(n, r) = (l[0], l[1])
	mi = min(n, r)
	if r >= n:
		print((mi - 1) * mi // 2 + 1)
	else:
		print((mi + 1) * mi // 2)
	i += 1


import sys
from math import ceil
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r == 1:
		print(1)
		continue
	if n > r:
		ans = r * (r + 1) // 2
		print(ans)
	else:
		ans = n * (n - 1) // 2
		ans += 1
		print(ans)


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def gi():
	return [x for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')
t = fi()
while t > 0:
	t -= 1
	(n, r) = mi()
	c = min(n, r)
	print(c * (c + 1) // 2 - (0 if n > c else n - 1))


T = int(input())
for _ in range(T):
	(n, r) = list(map(int, input().split()))
	if n <= r:
		m = n - 1
		ans = m * (m + 1) // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


TC = int(input())
for tc in range(TC):
	(N, R) = map(int, input().split())
	mr = 0
	if N - 1 >= R:
		mr = R
		result = 0
	else:
		mr = N - 1
		result = 1
	print((1 + mr) * mr // 2 + result)


import sys
import math
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for t in range(int(input())):
	(n, r) = intInp()
	x = min(n, r)
	total = (x - 1) * x // 2
	if r >= n:
		total += 1
	else:
		total += x
	print(int(total))


def paint(n, r):
	m = min(n - 1, r)
	return m * (m + 1) // 2 + (r >= n)
t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	print(paint(n, r))


def func(n, k):
	res = 0
	if n <= k:
		res = (n - 1) * n // 2 + 1
	else:
		res = (k + 1) * k // 2
	return res
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	print(func(n, k))


from sys import stdin
input = lambda : stdin.readline().strip()
char = [chr(i) for i in range(97, 123)]
CHAR = [chr(i) for i in range(65, 91)]
mp = lambda : list(map(int, input().split()))
INT = lambda : int(input())
rn = lambda : range(INT())
from math import ceil, sqrt, factorial, gcd
for _ in rn():
	(n, r) = mp()
	if n <= r:
		ans = 1 + n * (n - 1) // 2
	else:
		ans = r * (r + 1) // 2
	print(ans)


t = int(input())
for i in range(t):
	(n, w) = map(int, input().split())
	if n <= w:
		a = (n - 1) * n // 2
		print(a + 1)
	else:
		a = w * (w + 1) // 2
		print(a)


def solve(n, r, ans):
	x = min(r, n - 1)
	total = x * (x + 1) // 2
	r -= x
	total += min(r, 1)
	ans.append(total)

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(n, r) = map(int, input().split())
		solve(n, r, ans)
	for i in ans:
		print(i)
main()


import sys
input = sys.stdin.readline
inputr = lambda : sys.stdin.readline().rstrip('\n')
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	if r == 1:
		print(1)
		continue
	if n > r:
		ans2 = r * (r + 1) // 2
	else:
		ans2 = n * (n - 1) // 2
		ans2 += 1
	print(ans2)


from math import ceil
t = int(input())
for _ in range(t):
	(n, r) = list(map(int, input().split()))
	if n <= r:
		ans = n * (n - 1) // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7

def get_sum(a, d, n):
	return (2 * a + (n - 1) * d) * n // 2
for _ in range(INT()):
	(N, r) = MAP()
	r = min(N, r)
	ans = 0
	if N == r:
		ans += 1
		r -= 1
	ans += get_sum(1, 1, r)
	print(ans)


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
import io, os
input = sys.stdin.readline
from bisect import *
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().strip().split()))
rls = lambda : list(map(str, input().split()))
t = int(input())
d = defaultdict(lambda : 0)
for _ in range(0, t):
	(n, r) = rl()
	if n <= r:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
num = int(z())
for _ in range(num):
	(n, r) = map(int, z().split())
	if n <= r:
		print(n * (n - 1) // 2 + 1)
	else:
		print(r * (r + 1) // 2)


t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	ct = 0
	if r >= n:
		ct = 1
	r1 = min(n, r)
	if r1 == n:
		r1 -= 1
	x = r1 * (r1 + 1) // 2
	print(ct + x)


t = int(input())
for i in range(t):
	nr = list(map(int, input().split()))
	n = nr[0]
	r = nr[1]
	counter = 0
	if n <= r:
		if (n - 1) % 2:
			counter = (n + 1) * (n // 2) - n + 1
		else:
			counter = n * ((n - 1) // 2) + 1
	elif r % 2:
		counter = (r + 2) * ((r + 1) // 2) - (r + 1)
	else:
		counter = (r + 1) * (r // 2)
	print(int(counter))


def help():
	(n, m) = map(int, input().split(' '))
	tt = min(n, m)
	ans = tt * (tt + 1) // 2
	if n <= m:
		ans -= n - 1
	print(ans)
for _ in range(int(input())):
	help()


I = lambda : list(map(int, input().split(' ')))
for _ in range(int(input())):
	(n, r) = I()
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(1 + n * (n - 1) // 2)


for _ in range(int(input())):
	(n, r) = map(int, input().split())
	tot = 0
	if r >= n:
		tot += 1
	m = min(r, n - 1)
	print(m * (m + 1) // 2 + tot)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n >= k:
		if n == k:
			ans = n * (n - 1) // 2 + 1
		else:
			ans = k * (k + 1) // 2
	else:
		ans = n * (n - 1) // 2 + 1
	print(ans)


test = int(input())
temp = test
my_list = []

def print_func():
	for n in my_list:
		print(n)

def append_func(number):
	string = number
	my_list.append(string)
while test != 0:
	(n, r) = [int(x) for x in input().split()]
	k = 0
	l = 1
	if n <= l:
		k = 1
		append_func(k)
		test -= 1
		continue
	if n <= r:
		r = n - 1
		k = 1
	k = int(k + (l + r) * (r - l + 1) // 2)
	append_func(k)
	test -= 1
print_func()


for T in range(int(input())):
	(n, k) = map(int, input().split())
	if n <= k:
		ans = n * (n - 1) // 2 + 1
	else:
		ans = k * (k + 1) // 2
	print(ans)


import sys
input = sys.stdin.readline
T = int(input())
for testcase in range(T):
	(n, r) = map(int, input().split())
	if r <= n - 1:
		res = (1 + r) * r // 2
	else:
		res = (n - 1) * n // 2
		res += 1
	print(res)


t = int(input())
while t:
	line = input().split()
	(n, r) = (int(line[0]), int(line[1]))
	ans = r >= n
	r = min(r, n - 1)
	ans += r * (r + 1) // 2
	print(ans)
	t -= 1


import sys
import math
from math import factorial, inf, gcd, sqrt
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
from bisect import *
import random
sys.setrecursionlimit(10 ** 5)

def rarray():
	return [int(i) for i in input().split()]
t = 1
t = int(input())
for ii in range(t):
	(n, r) = rarray()
	if r <= n - 1:
		print((1 + r) * r // 2)
	else:
		print(n * (n - 1) // 2 + 1)


def ans(n, k):
	if n > k:
		return k * (k + 1) // 2
	if n <= k:
		return (n - 1) * n // 2 + 1
m = int(input())
for i in range(m):
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	print(ans(n, k))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	if a > b:
		if b % 2 == 0:
			c = b * (b // 2) + b // 2
		else:
			c = b * (b // 2 + 1)
		print(int(c))
	else:
		if (a - 1) % 2 == 0:
			c = (a - 1) * (a - 1) // 2 + (a - 1) // 2
		else:
			c = (a - 1) * ((a - 1) // 2 + 1)
		print(int(c + 1))


def algo(n, r):
	if r < n:
		return (1 + r) * r // 2
	elif r == n:
		return (1 + r - 1) * (r - 1) // 2 + 1
	else:
		return (1 + n - 1) * (n - 1) // 2 + 1
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	result = algo(n, r)
	print(result)


import sys
import heapq

class IoTool:
	DEBUG = 0

	def _reader_dbg():
		with open('./input.txt', 'r') as f:
			lines = f.readlines()
		return iter(lines)
	reader = _reader_dbg() if DEBUG else iter(sys.stdin.read().split('\n'))
input = lambda : next(IoTool.reader)

def main():
	t = int(input())
	for _ in range(t):
		(n, r) = map(int, input().split())
		tr = min(n - 1, r)
		ans = (tr + 1) * tr // 2
		if r >= n:
			ans += 1
		print(ans)
main()


t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	elif r >= n:
		print(n * (n - 1) // 2 + 1)


t = int(input())
for hatt in range(t):
	lis = input().split()
	(n, r) = (int(lis[0]), int(lis[1]))
	lam = min(n - 1, r)
	ans = lam * (lam + 1) // 2
	if n <= r:
		ans += 1
	print(ans)


import math

def S(n, r):
	s = 0
	if r >= n:
		s = 1 + n * (n - 1) // 2
	else:
		s = r * (r + 1) // 2
	return s
t = int(input())
for i in range(0, t):
	nr = input().split()
	n = int(nr[0])
	r = int(nr[1])
	print(S(n, r))


le = 1
for _ in range(int(input())):
	res = 0
	(n, r) = map(int, input().split())
	if n <= le:
		print(1)
	else:
		if n <= r:
			r = n - 1
			res = 1
		print(res + (r + le) * (r - le + 1) // 2)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, r) = iia()
	if n <= r:
		n -= 1
		ans = n * (n + 1) // 2
		ans += 1
		print(ans)
	else:
		ans = r * (r + 1) // 2
		print(ans)


inp = lambda : int(input())
inpm = lambda : map(int, input().split())
inpl = lambda : list(inpm())
l2mn = lambda _n, _m: [[0 for __ in range(_m)] for _ in range(_n)]
l2n = lambda _n: l2mn(_n, _n)
INF = int(1e+18)
MOD = int(1000000000.0) + 7
N = 2000009

def solve():
	(n, r) = inpm()
	if n > r:
		print((1 + r) * r // 2)
	else:
		print(n * (n - 1) // 2 + 1)

def main():
	t = inp()
	for i in range(t):
		solve()
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ref = min(a - 1, b)
	ans = ref * (ref + 1) // 2
	print(ans + (a <= b))


def f(n, r):
	x = 0
	if r < n:
		x += (r ** 2 + r) // 2
	else:
		n -= 1
		x += (n ** 2 + n) // 2 + 1
	return x
t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	print(f(n, r))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	k = 0
	if a <= b:
		print(1 + (a - 1) * a // 2)
	else:
		print(b * (b + 1) // 2)


def read_list():
	return list(map(int, input().strip().split(' ')))

def print_list(l):
	print(' '.join(map(str, l)))
N = int(input())
for _ in range(N):
	(n, r) = read_list()
	t = min(n - 1, r)
	res = (t + 1) * t >> 1
	if n <= r:
		res += 1
	print(res)


t = int(input())
for _ in range(t):
	l = input().split()
	(n, r) = (int(l[0]), int(l[1]))
	ans = 0
	if r >= n:
		ans += (n - 1) * n // 2
		ans += 1
	else:
		ans = 0
		ans += r * (r + 1) // 2
	print(ans)


import sys
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	ty = min(n, r)
	ans = ty * (ty + 1) // 2
	if n <= ty:
		ans -= n - 1
	print(ans)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
from math import *
for ii in range(int(input())):
	(n, r) = map(int, input().split())
	ans = 0
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		(n, r) = mi()
		if n <= r:
			print(n * (n - 1) // 2 + 1)
		else:
			print(r * (r + 1) // 2)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output1.txt', 'w')
else:
	input = sys.stdin.readline
solve()


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, r) = map(int, input().split())
	ans = 0
	if r >= n:
		ans = 1
		r = n - 1
	ans += r * (r + 1) // 2
	print(ans)


times = int(input())
while times:
	(n, r) = map(int, input().split())
	result = 0
	if r >= n:
		result += 1
		result += n * (n - 1) // 2
	else:
		result += (r + 1) * r // 2
	print(result)
	times -= 1


for _ in range(int(input())):
	liStr = input().split()
	n = int(liStr[0])
	r = int(liStr[1])
	if r < n:
		print(r * (r + 1) // 2)
		continue
	s = n * (n - 1) // 2
	print(s + 1)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = 0
	if a > b:
		ans = b * (b + 1) // 2
	else:
		ans = a * (a - 1) // 2 + 1
	print(ans)


def sa(num):
	return num * (num // 2 - (1 - num % 2)) + num + num // 2 * (1 - num % 2)
t = int(input())
for ex in range(t):
	(n, r) = [int(i) for i in input().split()]
	ans = sa(min(n, r) - 1)
	if r >= n:
		ans = sa(min(n, r) - 1) + 1
	else:
		ans = sa(min(n, r))
	print(ans)


import sys
from os import path
if path.exists('C:/Users/prana/Desktop/sublime/input.txt'):
	sys.stdin = open('C:/Users/prana/Desktop/sublime/input.txt', 'r')
	sys.stdout = open('C:/Users/prana/Desktop/sublime/output.txt', 'w')

def solve():
	(n, r) = input().split()
	n = int(n)
	r = int(r)
	ans = 0
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)
T = 1
T = int(input())
for _ in range(1, T + 1):
	print('Case #', _, file=sys.stderr)
	solve()


T = int(input())
for i in range(T):
	(a, b) = map(int, input().split())
	if b < a:
		ans = b * (b + 1) // 2
	else:
		b = a - 1
		ans1 = b * (b + 1) // 2
		ans = ans1 + 1
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, r) = map(int, input().split())
	u = min(n - 1, r)
	ans = u * (u + 1) // 2
	if r >= n:
		ans += 1
	print(ans)


for w in range(int(input())):
	(n, r) = map(int, input().strip().split())
	p = min(n - 1, r)
	c = p * (p + 1) // 2 + (n <= r)
	print(c)


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(fastinput())
while t:
	t -= 1
	(n, k) = map(int, fastinput().split())
	if n > k:
		print((k + 1) * k // 2)
	else:
		print(n * (n - 1) // 2 + 1)


from sys import stdin, stdout
INF = 100000000000.0

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()
from collections import defaultdict
for _ in range(int(stdin.readline())):
	(n, r) = get_ints()
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)


for t in range(int(input())):
	(n, r) = list(map(int, input().split()))
	if r == 1 or n == 1:
		print(1)
	else:
		c = 1
		if n <= r:
			c += n * (n - 1) // 2
			print(c)
		else:
			c = 0
			c += r * (r + 1) // 2
			print(c)


import sys

def rl():
	return sys.stdin.readline().strip()
T = int(rl())
for test in range(T):
	(n, r) = map(int, rl().split())
	tot = 0
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print((n - 1) * n // 2 + 1)


from collections import defaultdict as dd
from collections import Counter
from math import log, ceil

def sum(n):
	return n * (n + 1) // 2

def form(n, r):
	return r + (-n * r + sum(r))
	return n - r + 1

def solve():
	(n, r) = list(map(int, input().split()))
	if r < n:
		print(sum(r))
		return
	print(sum(n - 1) + 1)
t = 1
t = int(input())
for _ in range(t):
	solve()


import math
t = int(input())
for _ in range(t):
	line = input().strip().split(' ')
	(n, r) = (int(line[0]), int(line[1]))
	if n <= r:
		ways = n * (n - 1) // 2 + 1
	else:
		ways = (1 + r) * r // 2
	print(ways)


t = int(input())

def combinations(n, r):
	if n > r:
		return r * (r + 1) // 2
	else:
		return (n - 1) * n // 2 + 1
for i in range(t):
	(n, r) = input().split()
	n = int(n)
	r = int(r)
	print(combinations(n, r))


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for i in range(INT()):
	(n, r) = MAP()
	ans = 0
	if n == 1 or r == 1:
		ans = 1
	elif r >= n:
		ans += n * (n - 1) // 2 + 1
	else:
		ans = r * (r + 1) // 2
	print(ans)


import sys
input = sys.stdin.buffer.readline
import os
from math import *
t = int(input())
while t:
	t -= 1
	(n, r) = map(int, input().split())
	if r < n:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


for test in range(0, int(input())):
	(n, r) = [int(x) for x in input().split()]
	if n > r:
		print(r * (r + 1) // 2)
	else:
		print(n * (n - 1) // 2 + 1)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, r) = map(int, input().split())
	t = min(r, n - 1)
	print((t * (t + 1) >> 1) + (1 if r >= n else 0))


def task_B():
	t = int(input())
	for _ in range(t):
		(n, r) = map(int, input().split())
		min_n_r = min(n, r) - 1
		add = 1 if r >= n else r
		print((1 + min_n_r) * min_n_r // 2 + add)

def main():
	task_B()
main()


T = int(input())
for _ in range(T):
	(N, R) = map(int, input().split())
	if R > N:
		R = N
	ans = (R + 1) * R // 2
	if R == N:
		ans -= R - 1
	print(ans)