Chef has two integers X and Y. Chef wants to perform some operations to make X and Y equal. In one operation, Chef can either:
set X := X + 1
or set Y := Y + 2 

Find the minimum number of operations required to make X and Y equal.

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

- The first line contains a single integer T — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two space separated integers X and Y.

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

For each test case, print the minimum number of operations required to make X and Y equal.

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

$1 ≤ T ≤ 10^{4}$
$1 ≤ X, Y ≤ 10^{9}$

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

----- Sample Output 1 ------ 
1
0
2
3
5

----- explanation 1 ------ 
Let $(x, y)$ denote the values of $X$ and $Y$ respectively.

Test case $1$: Only one operation is required: $(3, 4) \xrightarrow{X := X + 1}{} (4, 4)$

Test case $2$: No operations are required since $X$ and $Y$ are already equal.

Test case $3$: Two operations are required: $(7, 3) \xrightarrow{Y := Y + 2}{} (7, 5) \xrightarrow{Y := Y + 2}{} (7, 7)$

Test case $4$: Three operations are required. One such sequence of operations is: $(5, 2) \xrightarrow{Y := Y + 2}{} (5, 4) \xrightarrow{X := X + 1}{} (6, 4) \xrightarrow{Y := Y + 2}{} (6, 6)$

Difficulty: EASY
Tags: Mathematics

Starter code:

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


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


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


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


t = int(input())
global z
z = True

def di(a, b):
	if (a - b) % 2 == 0:
		return int((a - b) / 2)
	else:
		return int((a - b) / 2) + 2

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


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


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


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


import math
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if x == y:
		print('0')
	elif x < y:
		print(y - x)
	elif (x - y) % 2 == 0:
		print((x - y) // 2)
	else:
		print(math.ceil((x - y) / 2 + 1))


T = int(input())
for _ in range(T):
	(X, Y) = map(int, input().split())
	if X <= Y:
		diff = Y - X
		print(diff)
	elif X > Y:
		diff = X - Y
		while True:
			if diff % 2 == 0:
				print(diff // 2)
				break
			elif diff % 2 != 0:
				count = 0
				X += 1
				count += 1
				diff = X - Y
				count += diff // 2
				print(count)
				break


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	if a < b:
		c = b - a
		print(c)
	elif a > b:
		c = a - b
		if c % 2 == 0:
			print(c // 2)
		elif c % 2 != 0:
			d = (c - 1) // 2 + 2
			print(d)
	else:
		print('0')


def code():
	cases = int(input())
	for _ in range(cases):
		(x, y) = map(int, input().split(' '))
		if x < y:
			print(y - x)
		elif (x - y) % 2 == 0:
			print((x - y) // 2)
		else:
			print((x - y) // 2 + 2)
code()


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if x == y:
		print('0')
	elif y > x:
		print(y - x)
	else:
		dif = x - y
		if dif % 2 == 0:
			print(dif // 2)
		else:
			print(dif // 2 + 2)


T = int(input())
for i in range(T):
	(X, Y) = map(int, input().split())
	if X < Y:
		print(Y - X)
	elif (X - Y) % 2 == 0:
		print((X - Y) // 2)
	else:
		print((X - Y) // 2 + 2)


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


import math as m
for i in range(int(input())):
	(x, y) = map(int, input().split())
	a = 0
	b = 0
	if x <= y:
		a = y - x
		print(a)
	elif x > y:
		b = m.ceil((x - y) / 2) * 2
		if x < y + b:
			a = y + b - x
			print(a + b // 2)
		else:
			print(b // 2)


for tc in range(int(input())):
	(x, y) = map(int, input().split())
	count = 0
	if x <= y:
		print(y - x)
	elif (x - y) % 2 == 0:
		print((x - y) // 2)
	else:
		print((x - y) // 2 + 2)


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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		s = b - a
		print(s)
	elif a == b:
		print(0)
	else:
		l = a - b
		x = l // 2
		v = l % 2
		if v == 0:
			print(x)
		else:
			print(x + 2)


try:
	t = int(input())
	for r in range(t):
		(x, y) = map(int, input().split())
		if x <= y:
			print(abs(x - y))
		elif (x - y) % 2 == 0:
			print((x - y) // 2)
		else:
			print((x - y + 1) // 2 + 1)
except:
	pass


a = int(input())
for _ in range(a):
	(m, n) = map(int, input().split())
	i = 0
	if m > n:
		if m % 2 != 0 and n % 2 != 0:
			z = (m - n) // 2
			print(z)
		elif m % 2 == 0 and n % 2 == 0:
			z = (m - n) // 2
			print(z)
		else:
			m = m + 1
			z = (m - n) // 2
			print(z + 1)
	elif n > m:
		print(n - m)
	else:
		print(0)


import math
for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x > y:
		print(math.ceil((x - y) / 2) + (x - y) % 2)
	else:
		print(y - x)


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	s = x - y
	if x < y:
		print(y - x)
	elif x == y:
		print(s)
	elif x > y and s % 2 == 0:
		print(s // 2)
	else:
		print(s // 2 + 2)