There are N children and Chef wants to give them 1 candy each. Chef already has X candies with him. To buy the rest, he visits a candy shop. In the shop, packets containing exactly 4 candies are available.

Determine the minimum number of candy packets Chef must buy so that he is able to give 1 candy to each of the N children.

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

- The first line of input will contain a single integer T, denoting the number of test cases.
- The first and only line of each test case contains two integers N and X — the number of children and the number of candies Chef already has.

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

For each test case, output the minimum number of candy packets Chef must buy so that he is able to give 1 candy to each of the N children.

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

$1 ≤ T ≤ 1000$
$1 ≤ N, X ≤ 100$

----- Sample Input 1 ------ 
4
20 12
10 100
10 9
20 9

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

----- explanation 1 ------ 
Test Case $1$: Chef must buy $2$ more packets after which he will have $20$ candies which will be enough to distribute $1$ candy to each of the $20$ children.

Test Case $2$: Chef does not need to buy more packets since he already has $100$ candies which are enough to distribute $1$ candy to each of the $10$ children.

Test Case $3$: Chef must buy $1$ more packet after which he will have $13$ candies which will be enough to distribute $1$ candy to each of the $10$ children.

Test Case $4$: Chef must buy $3$ more packets after which he will have $21$ candies which will be enough to distribute $1$ candy to each of the $20$ children.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
import math
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	if x <= y:
		print('0')
	else:
		k = x - y
		print(math.ceil(k / 4))


import math
t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	if n <= x:
		print(0)
	else:
		print(math.ceil((n - x) / 4))


for i in range(int(input())):
	(n, x) = map(int, input().split())
	if n > x and n - x > 4 and ((n - x) % 4 != 0):
		print((n - x) // 4 + 1)
	elif n > x and n - x <= 4:
		print(1)
	elif n > x and n - x > 4 and ((n - x) % 4 == 0):
		print(int((n - x) / 4))
	elif n <= x:
		print(0)


for i in range(int(input())):
	(children, candy) = map(int, input().split(' '))
	remaining = children - candy
	if remaining > 0:
		if remaining % 4 == 0:
			print(remaining // 4)
		else:
			print(remaining // 4 + 1)
	else:
		print(0)


x = int(input())
for i in range(x):
	(a, b) = map(int, input().split())
	if a > b:
		z = a - b
		w = z // 4
		if z % 4 < 4 and z % 4 > 0:
			w = w + 1
		print(w)
	else:
		print('0')


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


from math import ceil
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if a < b:
		print('0')
	else:
		left = a - b
		ans = ceil(left / 4)
		print(ans)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	print(0 if n <= x else (n - x) // 4 if (n - x) % 4 == 0 else (n - x) // 4 + 1)
	t -= 1


for i in range(int(input())):
	(N, X) = map(int, input().split())
	candyToBuy = N - X if N - X > 0 else 0
	noOfPacket = int(candyToBuy / 4) if candyToBuy % 4 == 0 else int(candyToBuy / 4) + 1
	print(noOfPacket)


T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	A = N - X
	B = A / 4
	if A > 0:
		if A % 4 == 0:
			print(int(B))
		else:
			print(int(B + 1))
	else:
		print(0)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x > y:
		if (x - y) % 4 == 0:
			print((x - y) // 4)
		else:
			print((x - y) // 4 + 1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	if n <= x:
		print('0')
	elif n > x:
		c = n - x
		f = c // 4
		g = c % 4
		if g == 0:
			print(f)
		else:
			print(f + 1)


import math
for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	c = 4
	d = a - b
	if a < b:
		print(0)
	else:
		print(math.ceil(d / 4))


import math
t = int(input())
for tc in range(t):
	(n, x) = map(int, input().split())
	y = n - x
	if n < x:
		print(0)
	else:
		print(math.ceil(y / 4))


import math
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	val = n - x
	if val < 0:
		print('0')
	else:
		ans = math.ceil(val / 4)
		print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	if x >= n:
		print(0)
	else:
		a = n - x
		if a % 4 == 0:
			print(int(a / 4))
		else:
			print(int(a / 4) + 1)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	while b < a:
		b += 4
		c += 1
	print(c)


import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x < y:
		print('0')
	else:
		s = x - y
		print(math.ceil(s / 4))


import math
t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	candiesRequired = n - x if x <= n else 0
	print(math.ceil(candiesRequired / 4) if candiesRequired != 0 else 0)
	t -= 1


T = int(input())
for i in range(0, T):
	(n, x) = map(int, input().split())
	if x - n >= 0:
		print(0)
	else:
		temp = n - x
		if (n - x) % 4 == 0:
			print((n - x) // 4)
		else:
			print((n - x) // 4 + 1)


import math
T = int(input())
for i in range(T):
	(N, X) = map(int, input().split())
	if N > X:
		R = (N - X) / 4
		print(math.ceil(R))
	else:
		print(0)


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if n > x:
		diff = n - x
		if diff % 4 == 0:
			print(diff // 4)
		else:
			print(diff // 4 + 1)
	else:
		print(0)


import math
t = int(input())
for i in range(t):
	(N, X) = list(map(int, input().split()))
	a = N - X
	b = a / 4
	c = math.ceil(b)
	if N <= X:
		print(0)
	else:
		print(c)


for i in range(int(input())):
	x = [int(x) for x in input().split()]
	if x[1] < x[0]:
		a = x[0] - x[1]
		if a % 4 != 0:
			print(a // 4 + 1)
		else:
			print(a // 4)
	else:
		print(0)


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	if n > x:
		if (n - x) % 4 == 0:
			print((n - x) // 4)
		else:
			print((n - x) // 4 + 1)
	else:
		print(0)


n = int(input(''))
for i in range(n):
	(N, X) = map(int, input('').split())
	if N > X:
		if (N - X) % 4 == 0:
			print((N - X) // 4)
		else:
			print((N - X) // 4 + 1)
	else:
		print(0)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	if n < x:
		print('0')
		continue
	n = n - x
	if n % 4 == 0:
		print(n // 4)
	else:
		print(n // 4 + 1)


import math
t = int(input())
while t > 0:
	t -= 1
	(x, y) = map(int, input().split())
	c = x - y
	if c < 0:
		print('0')
	else:
		print(math.ceil(c / 4))


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


import math
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	z = x - y
	if y > x:
		print('0')
	else:
		print(math.ceil(z / 4))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	if x >= n:
		print(0)
	else:
		c = 0
		rem = n - x
		while rem > 0:
			rem -= 4
			c += 1
		print(c)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x < y:
		print(0)
	else:
		temp = x - y
		d = temp / 4
		s = temp % 4
		if s == 0:
			print(int(d))
		else:
			print(int(d + 1))


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


t = lambda x, y: 0 if x < y else (x - y) // 4 + int((x - y) % 4 != 0)
for _ in [(I := input)] * int(I()):
	(x, y) = map(int, I().split())
	print(t(x, y))


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


t = int(input())
for i in range(t):
	(c1, c2) = map(int, input().split(' '))
	r = c1 - c2
	if r > 0:
		if r % 4 == 0:
			print(r // 4)
		else:
			print(r // 4 + 1)
	else:
		print(0)


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


t = int(input())
import math
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	if x >= n:
		print(0)
	else:
		need = n - x
		print(math.ceil(need / 4))


n = int(input())
for _ in range(n):
	(N, X) = list(map(int, input().split()))
	if N - X < 0:
		print(0)
	elif (N - X) % 4 == 0:
		print((N - X) // 4)
	else:
		print((N - X) // 4 + 1)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	need = n - x
	if n < x:
		print('0')
	elif need % 4 == 0:
		print(int(need / 4))
	else:
		print(int(need / 4) + 1)


i = 0
t = int(input())
while i < t:
	(n, x) = map(int, input().split())
	if n > x:
		s = n - x
		a = s / 4
		if s % 4 == 0:
			print(int(a))
		else:
			print(s // 4 + 1)
	else:
		print(0)
	i += 1


for i in range(int(input())):
	(n, x) = map(int, input().split())
	rest = n - x
	rem = rest % 4
	if n > x:
		if rem == 0:
			print(rest // 4)
		else:
			print(rest // 4 + 1)
	else:
		print(0)