Chef has started working at the candy store. The store has 100 chocolates in total.

Chef’s daily goal is to sell X chocolates. For each chocolate sold, he will get 1 rupee. 
However, if Chef exceeds his daily goal, he gets 2 rupees per chocolate for each extra chocolate.

If Chef sells Y chocolates in a day, find the total amount he made.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two space-separated integers X and Y — the daily goal of Chef, and the number of chocolates he actually sells.

------ Output Format ------ 

For each test case, output on a new line the total amount Chef made in a day.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ X, Y ≤ 10$

----- Sample Input 1 ------ 
4
3 1
5 5
4 7
2 3

----- Sample Output 1 ------ 
1
5
10
4

----- explanation 1 ------ 
Test case $1$: Chef's daily goal was $3$. Since he sold only $1$ chocolate, he'll get only $1$ rupee.

Test case $2$: Chef's daily goal was $5$. Since he sold $5$ chocolates, he'll get $5$ rupees.

Test case $3$: Chef's daily goal was $4$. Since he sold $7$ chocolate, he'll get $4$ rupees for the $4$ chocolates as his daily goal and $2$ rupees per chocolate for the extra $3$ chocolates. The total amount he gets is $4+3\cdot 2 = 10$.

Test case $4$: Chef's daily goal was $2$. Since he sold $3$ chocolate, he'll get $2$ rupees for the $2$ chocolates as his daily goal and $2$ rupees per chocolate for the extra $1$ chocolate. The total amount he gets is $2+1\cdot 2 = 4$.

Source: codechef | Difficulty: EASY
Tags: Mathematics


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


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split(' '))
	if X >= Y:
		print(Y)
	else:
		print(X + (Y - X) * 2)


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


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


test_cases = int(input())
for i in range(test_cases):
	chocolates = list(map(int, input().split()))
	if chocolates[0] >= chocolates[-1]:
		print(chocolates[-1])
	else:
		total = chocolates[-1] - chocolates[0]
		print(total * 2 + chocolates[0])


for m in range(int(input())):
	(x, y) = map(int, input().split())
	if x >= y:
		print(y)
	else:
		print(x + (y - x) * 2)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if x == y:
		print(x)
	elif x < y:
		print(x * 1 + (y - x) * 2)
	elif x > y:
		print(y)


t = int(input())
for i in range(t):
	integer = input().split()
	x = int(integer[0])
	y = int(integer[1])
	if y >= x:
		amount = x * 1 + (y - x) * 2
		print(amount)
	elif y < x:
		print(y)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x >= y:
		print(y)
	else:
		p = abs(x - y)
		print(x + p * 2)


t = int(input())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	extra = y - x
	if x >= y:
		print(y)
	elif x < y:
		print(x + extra * 2)


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	if a < b:
		print(a + (b - a) * 2)
	else:
		print(b)
	t -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	total = 0
	if y <= x:
		total = y
	if y > x:
		total = y + (y - x)
	print(total)


T = int(input())
for i in range(T):
	(x, y) = input().split()
	A = int(x)
	B = int(y)
	if A >= B:
		print(B)
	elif A < B:
		print(A + (B - A) * 2)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	c = b - a
	if a <= b:
		print(a + c * 2)
	elif a == b:
		print(a)
	else:
		print(min(a, b))


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


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


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


n = int(input())
for I in range(n):
	c = 0
	(a, b) = map(int, input().split())
	if a >= b:
		print(b)
	else:
		while b > a:
			b -= 1
			c += 2
		print(a + c)


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


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


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


n = int(input())
for i in range(n):
	(x, y) = list(map(int, input().split()))
	if x >= y:
		print(y)
	else:
		s = y - x
		sum = x + s * 2
		print(sum)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x >= y:
		print(y)
	elif y > x:
		a = x + (y - x) * 2
		print(a)


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


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


t = int(input())
for i in range(t):
	(X, Y) = map(int, input().split())
	if X >= Y:
		print(Y)
	if X < Y:
		print((Y - X) * 2 + X)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	print(x + (y - x) * 2 if y > x else y)
	t -= 1


a = int(input())
for i in range(0, a):
	(x, y) = map(int, input().split())
	if x >= y:
		print(y)
	else:
		print(x + 2 * (y - x))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	z = y - x
	if y <= x:
		print(y)
	if y > x:
		print(y + z)


t = int(input())
for h in range(t):
	(x, y) = map(int, input().split())
	a = x - y
	if x < y:
		print((y - x) * 2 + x)
	else:
		print(y)


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


def candy(x, y):
	if x >= y:
		return y
	else:
		a = 2 * (y - x)
		return a + x
t = int(input())
for i in range(0, t):
	(x, y) = map(int, input().split())
	print(candy(x, y))


for t in range(int(input())):
	(s, k) = map(int, input().split())
	if s >= k:
		print(k)
	else:
		print(s + (k - s) * 2)


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


for i in range(int(input())):
	x = list(map(int, input().split()))
	if x[0] >= x[1]:
		print(x[1])
	else:
		d = abs(x[0] - x[1])
		res1 = x[0] + d * 2
		print(res1)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().strip().split())
	if y <= x:
		print(y)
	else:
		a = y - x
		print(x + a * 2)


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