Chef has N friends. Chef promised that he would gift a pair of shoes (consisting of one left shoe and one right shoe) to each of his N friends. Chef was about to go to the marketplace to buy shoes, but he suddenly remembers that he already had M left shoes.

What is the minimum number of extra shoes that Chef will have to buy to ensure that he is able to gift a pair of shoes to each of his N friends?

For example, if N = 2, M = 4, then Chef already has 4 left shoes, so he must buy 2 extra right shoes to form 2 pairs of shoes.

Therefore Chef must buy at least 2 extra shoes to ensure that he is able to get N = 2 pairs of shoes.

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

- The first line contains a single integer T - the number of test cases. Then the test cases follow.
- The first line of each test case contains two integers N and M - the number of Chef's friends and the number of left shoes Chef has.

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

For each test case, output the minimum number of extra shoes that Chef will have to buy to ensure that he is able to get N pairs of shoes.

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

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$0 ≤ M ≤ 100$

----- Sample Input 1 ------ 
3
2 4
6 0
4 3

----- Sample Output 1 ------ 
2
12
5

----- explanation 1 ------ 
Test Case 1: Discussed in the problem statement

Test Case 2: Chef initially has no left shoes. He must buy $6$ more left shoes and $6$ more right shoes to form $6$ pairs of shoes.

Test Case 3: Chef initially has $3$ left shoes. He must buy $1$ more left shoe and $4$ more right shoes to form $4$ pairs of shoes.

Difficulty: EASY
Tags: Mathematics

Starter code:

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


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


t = int(input())
for u in range(t):
	(N, M) = list(map(int, input().split()))
	if M >= N:
		print(N)
	elif N > M:
		print(M + (N - M) * 2)


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


while True:
	try:
		for _ in range(int(input())):
			(a, b) = map(int, input().split())
			left = a
			right = a
			if b >= left:
				print(left)
			else:
				print(right + (left - b))
	except:
		break


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


t = int(input())
for i in range(t):
	(N, M) = map(int, input().split())
	if N <= M:
		print(N)
	else:
		print(2 * N - M)


T = int(input())
for i in range(T):
	(N, M) = map(int, input().split())
	if N > M:
		print(N * 2 - M)
	elif N <= M:
		print(N)


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


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


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


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


t = int(input())
while t > 0:
	[n, m] = map(int, input().split())
	if n <= m:
		print(n)
	else:
		print(m + 2 * (n - m))
	t -= 1


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


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


T = int(input())
for i in range(T):
	(N, M) = map(int, input().split())
	if N <= M:
		print(N)
	else:
		C = N - M
		print(C + N)


T = int(input())
for i in range(0, T):
	(n, m) = map(int, input().split())
	if n - m <= 0:
		print(n)
	else:
		print(n - m + n)


def shoes(x, y):
	if x <= y:
		return x
	elif x > y:
		c = x - y
		return c + x
t = int(input())
for i in range(0, t):
	(x, y) = map(int, input().split())
	print(shoes(x, y))


t = int(input())
for i in range(t):
	(N, M) = map(int, input().split())
	sum = 0
	if N <= M:
		print(N)
	elif N > M:
		print(2 * (N - M) + M)
	else:
		pass


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


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	if n > m:
		print(n + n - m)
	elif n < m:
		print(n)
	elif n == m:
		print(n)


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	a = n - m
	print(abs(a + max(n, m)))
	t -= 1


t = int(input())
for i in range(t):
	count = 0
	(n, m) = map(int, input().split())
	if m > n:
		print(n)
	else:
		while m != n:
			count += 1
			m += 1
		print(count + n)


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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a - b <= 0:
		print(a)
	else:
		print(a - b + a)