Lumpy is a bus driver. Today, the conductor is absent so Lumpy has to do the conductor's job as well. There are N creatures in the bus. Sometimes the creatures don't carry change and can't pay the exact amount of the fare. Each creature in the bus today has paid an amount
greater than his/her fare. You are given information about the extra amount paid by each creature, by an array A of size N, where Ai denotes the extra amount paid by the i-th creature, in rupees.
After the end of the trip, Lumpy noticed that he had P one rupee coins and Q two rupee coins. He wants to pay back the creatures using this money. Being a kind hearted moose, Lumpy wants to pay back as many creatures as he can. Note that Lumpy will 
not pay back the i-th creature if he can't pay the exact amount that the i-th creature requires with the coins that he possesses. 
Lumpy is busy driving the bus and doesn't want to calculate the maximum number of creatures he can satisfy - He will surely cause an accident if he tries to do so. Can you help him out with this task? 

-----Input-----
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- For each test case, first line consists of three space separated integers N, P and Q.
- Second line consists of N space separated integers A containing N space integers, where i-th integer denotes Ai.

-----Output-----
- For each test case, output a single line containing an integer corresponding to maximum number of creatures that Lumpy can pay back.

-----Constraints-----
- 1 ≤ T ≤ 106
- 1 ≤ N ≤ 105
- 1 ≤ Ai ≤ 109
- 0 ≤ P, Q ≤ 1014
- Sum of N over all the cases does not exceed 106

-----Subtasks-----
- Subtask #1 (15 points): P = 0
- Subtask #2 (15 points): Q = 0
- Subtask #3 (70 points): Original constraints

-----Example-----
Input:3
3 3 0
1 2 2
3 2 1
1 2 1
4 5 4
2 3 4 5

Output:2
3
3

-----Explanation-----
Example 1. Lumpy has just 3 one rupee coins. 

He can pay creatures numbered {1, 2} or creatures numbered {1, 3} with these coins. Thus, answer is 2. 
Example 2. Lumpy has 2 one rupee coins and 1 two rupee coin. 

In the optimal solution, Lumpy can give the two rupee coin to creature 2 and the one rupee coins to creatures 1 and 3. Thus, answer is 3.

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Sorting


Solutions:
import math
a = int(input())
for i in range(a):
	aa = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	bb.sort()
	num1 = aa[1]
	num2 = aa[2]
	count = 0
	for i in range(aa[0]):
		kk = bb[i]
		cc = int(bb[i] / 2)
		if cc <= num2:
			kk -= cc * 2
			if num1 >= kk:
				count += 1
				num1 -= kk
				num2 -= cc
		else:
			kk -= num2 * 2
			num2 = 0
			if num1 >= kk:
				count += 1
				num1 -= kk
	print(count)


t = int(input())
for _ in range(t):
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	for i in a:
		if i % 2 == 0:
			if q >= i // 2:
				count += 1
				q -= i // 2
			elif p >= i - q - q:
				count += 1
				p -= i - q - q
				q = 0
			else:
				break
		elif q >= i // 2 and p > 0:
			count += 1
			p -= 1
			q -= i // 2
		elif p >= i - q - q:
			count += 1
			p -= i - q - q
			q = 0
		else:
			break
	print(count)


for _ in range(int(input())):
	(n, p, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	for i in range(n):
		x = min(q, l[i] // 2)
		l[i] -= x * 2
		if l[i] <= p:
			p -= l[i]
			q -= x
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, p, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(l)
	c = 0
	for i in range(len(l)):
		a = int(l[i] / 2)
		b = int(l[i] % 2)
		if a <= q and b <= p:
			p = p - b
			q = q - a
			c = c + 1
		elif a > q:
			a = a - q
			q = 0
			if a * 2 + b <= p:
				p = p - (2 * a + b)
				c = c + 1
			else:
				break
	print(c)


for t in range(int(input())):
	temp = list(map(int, input().split()))
	n = temp[0]
	p = temp[1]
	q = temp[2]
	amount = p + 2 * q
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	for i in range(n):
		if amount <= 0 or amount < a[i]:
			break
		two = a[i] // 2
		one = a[i] % 2
		rev = 0
		if q >= two:
			q -= two
			rev = two
			amount -= 2 * two
			a[i] -= 2 * two
		else:
			amount -= 2 * q
			rev = q
			a[i] -= 2 * q
			q = 0
		if a[i] != 0 and p == 0:
			q += rev
			amount += 2 * rev
			continue
		else:
			p -= a[i]
			amount -= a[i]
			ans += 1
	print(ans)


for t in range(int(input())):
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	for i in range(n):
		if a[i] >= 2:
			two = a[i] // 2
			one = a[i] - two * 2
			if two > q:
				two = q
				q = 0
				one = a[i] - two * 2
			else:
				q -= two
			if one <= p:
				p -= one
				count += 1
			else:
				q += two
		elif p > 0:
			p -= 1
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(n, p, q) = list(map(int, input().split(' ')))
	l = list(map(int, input().split(' ')))
	l.sort()
	s = sum(l)
	a = p + 2 * q
	b = 0
	for i in l:
		if p == 0:
			if i % 2 == 0 and a >= i:
				a = a - i
				b = b + 1
		elif q == 0:
			if a >= i:
				a = a - i
				b = b + 1
		elif i % 2 == 0 and a >= i:
			a = a - i
			b = b + 1
		elif i % 2 != 0 and p != 0 and (a >= i):
			a = a - i
			b = b + 1
			p = p - 1
	print(b)


for _ in range(int(input())):
	(n, p, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	for i in range(n):
		x = l[i] // 2
		if q > 0:
			if q >= x and q > 0:
				q -= x
				l[i] -= x * 2
			else:
				l[i] -= q * 2
				q = 0
				x = 0
		p -= l[i]
		if p < 0 and q <= 0:
			break
		ans += 1
	print(ans)


from sys import stdin, stdout
import math
from collections import Counter
import functools
import time
import bisect

def tr():
	return range(int(line()))

def sm():
	return map(int, line().split())

def ln():
	return list(sm())

def nl():
	return int(line())

def ssm():
	return map(str, line().split())

def line():
	return stdin.readline().rstrip()

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

def o(x):
	if type(x) != type(''):
		x = str(x)
	stdout.write(x + '\n')

def osp(x):
	if type(x) != type(''):
		x = str(x)
	stdout.write(x + ' ')

def ol(x):
	stdout.write(' '.join(map(str, x)))

def wline():
	return stdin.read().split()

def main():
	for _ in tr():
		(n, p, q) = sm()
		a = ln()
		count = 0
		a.sort()
		for i in a:
			if p + 2 * q < i:
				break
			temp = min(q, i // 2)
			if p >= i - 2 * temp:
				count += 1
				q -= temp
				p -= i - 2 * temp
		print(count)
main()


t = int(input())
for i in range(t):
	(n, p, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	for i in arr:
		res = i // 2
		if q >= res:
			if not i & 1:
				ans += 1
				q -= res
			elif p >= i - 2 * res:
				q -= res
				p -= i - 2 * res
				ans += 1
		elif p >= i - 2 * q:
			ans += 1
			p -= i - 2 * q
			q = 0
	print(ans)


t = int(input())
for _ in range(t):
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	a.sort()
	for z in a:
		if p + 2 * q < z:
			break
		else:
			k = z // 2
			if z & 1:
				rem = 1
			else:
				rem = 0
			if rem > p:
				continue
			p -= rem
			q -= k
			ans += 1
	print(ans)


from heapq import heapify, heappop
for i in range(int(input())):
	(n, p, q) = map(int, input().split())
	heap = list(map(int, input().split()))
	heapify(heap)
	ans = 0
	while heap:
		temp = heappop(heap)
		if temp // 2 <= q:
			qLoss = temp // 2
			temp = temp & 1
		else:
			temp -= 2 * q
			qLoss = q
		if temp <= p:
			pLoss = temp
			temp = 0
		else:
			temp -= p
			pLoss = p
		if temp > 0:
			continue
		ans += 1
		p -= pLoss
		q -= qLoss
	print(ans)


t = int(input())
while t:
	(n, p, q) = map(int, input().split(' '))
	ls = [int(i) for i in input().split(' ')]
	ls.sort()
	count = 0
	for i in range(n):
		if ls[i] % 2:
			if q < ls[i] // 2:
				if p + 2 * q >= ls[i]:
					p -= ls[i] - 2 * q
					q = 0
					count += 1
			elif p == 0:
				continue
			else:
				p -= 1
				q -= ls[i] // 2
				count += 1
		elif q < ls[i] // 2:
			if p + 2 * q >= ls[i]:
				p -= ls[i] - 2 * q
				q = 0
				count += 1
		else:
			q -= ls[i] // 2
			count += 1
	print(count)
	t -= 1


for _ in range(int(input())):
	(n, p, q) = list(map(int, input().split()))
	l = sorted(map(int, input().split()))
	ans = 0
	if q == 0:
		ans = 0
		for amount in l:
			if amount <= p:
				p -= amount
				ans += 1
			if p == 0:
				break
		print(ans)
	elif p == 0:
		ans = 0
		for amount in l:
			if amount % 2 == 0:
				k = amount // 2
				if k <= q:
					q -= k
					ans += 1
			if q == 0:
				break
		print(ans)
	else:
		ans = 0
		for amount in l:
			k = amount // 2
			if k <= q:
				amount -= k * 2
				q -= k
			else:
				amount -= q * 2
				q -= q
			if amount <= p:
				p -= amount
				amount -= amount
			else:
				amount -= p
				p -= p
			if amount == 0:
				ans += 1
			if p == 0 and q == 0:
				break
		print(ans)


for _ in range(int(input())):
	(n, one, two) = map(int, input().split())
	l = [int(i) for i in input().split()]
	l.sort()
	cnt = 0
	i = 0
	j = 0
	odd = [i for i in l if i & 1]
	even = [i for i in l if i & 1 == 0]
	n = len(even)
	m = len(odd)
	while i < n and j < m:
		if even[i] < odd[j]:
			curr = even[i]
			if two * 2 >= curr:
				cnt += 1
				two -= curr // 2
			else:
				rem = curr - two * 2
				if one >= rem:
					two = 0
					cnt += 1
					one -= rem
				else:
					pass
			i += 1
		else:
			curr = odd[j]
			j += 1
			if one == 0:
				continue
			one -= 1
			curr -= 1
			if two * 2 >= curr:
				cnt += 1
				two -= curr // 2
			else:
				rem = curr - two * 2
				if one >= rem:
					two = 0
					one -= rem
					cnt += 1
				else:
					pass
	while i < n:
		curr = even[i]
		if two * 2 >= curr:
			cnt += 1
			two -= curr // 2
		else:
			rem = curr - two * 2
			if one >= rem:
				two = 0
				one -= rem
				cnt += 1
			else:
				pass
		i += 1
	while j < m:
		curr = odd[j]
		j += 1
		if one == 0:
			continue
		one -= 1
		curr -= 1
		if two * 2 >= curr:
			cnt += 1
			two -= curr // 2
		else:
			rem = curr - two * 2
			if one >= rem:
				two = 0
				one -= rem
				cnt += 1
			else:
				pass
	print(cnt)


t = int(input())
while t > 0:
	(n, p, q) = input().split(' ')
	n = int(n)
	p = int(p)
	q = int(q)
	l = list(map(int, input().split(' ')))
	if q == 0:
		s = 0
		count = 0
		l.sort()
		for i in l:
			s = s + i
			if s > p:
				break
			else:
				count = count + 1
		print(count)
	elif p == 0:
		l1 = list(filter(lambda x: x % 2 == 0, l))
		s = 0
		count = 0
		l1.sort()
		for i in l1:
			s = s + i
			if s > 2 * q:
				break
			else:
				count = count + 1
		print(count)
	else:
		count = 0
		s = 0
		sum = p + 2 * q
		l1 = list(filter(lambda x: x % 2, l))
		l2 = list(filter(lambda x: x % 2 == 0, l))
		l1.sort()
		l2.sort()
		if len(l1) <= len(l2):
			x = len(l1)
		else:
			x = len(l2)
		i = 0
		j = 0
		lst = []
		while i + j < len(l1) + len(l2) - 1:
			if i == len(l1):
				lst.append(l2[j])
				j = j + 1
			if j == len(l2):
				lst.append(l1[i])
				i = i + 1
			if l1[i] < l2[j]:
				if p > 0:
					lst.append(l1[i])
					p = p - 1
					i = i + 1
				else:
					i = i + 1
			else:
				lst.append(l2[j])
				j = j + 1
		for i in lst:
			s = s + i
			if s > sum:
				break
			else:
				count = count + 1
		print(count)
	t = t - 1


from sys import stdin, stdout
import math
import time
import bisect

def solve():
	(n, p, q) = map(int, stdin.readline().rstrip().split())
	a = list(map(int, stdin.readline().rstrip().split()))
	count = 0
	a.sort()
	for i in a:
		if p + 2 * q < i:
			break
		if q < i // 2:
			temp = q
		else:
			temp = i // 2
		if p >= i - 2 * temp:
			count += 1
			q -= temp
			p -= i - 2 * temp
	print(count)
for _ in range(int(stdin.readline().rstrip())):
	solve()


for i in range(int(input())):
	inp = list(map(int, input().split()))
	n = inp[0]
	p = inp[1]
	q = inp[2]
	a = []
	a = list(map(int, input().split()))
	count = 0
	tm = 2 * q + p
	a.sort()
	for k in a:
		r = k // 2
		if r > q:
			r = q
		if k - r * 2 <= p:
			count += 1
			q -= r
			p -= k - r * 2
		else:
			pass
	print(count)


z = int(input())
for _ in range(z):
	(n, o, t) = map(int, input().split())
	l = [int(x) for x in input().split()]
	l.sort()
	i = 0
	t *= 2
	while i < n:
		temp = l[i] if l[i] % 2 == 0 else l[i] - 1
		if t >= temp and o > 0:
			if l[i] % 2:
				o -= 1
			t -= temp
			l[i] = 0
		elif o == 0:
			if l[i] % 2 == 0:
				if t >= l[i]:
					t -= l[i]
					l[i] = 0
				else:
					break
		else:
			l[i] -= t
			t = 0
			break
		i += 1
	l.sort()
	i = 0
	while i < n:
		if l[i] <= o:
			o -= l[i]
		else:
			break
		i += 1
	print(i)


t = int(input())
for i in range(t):
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	for j in a:
		if j // 2 <= q and j % 2 <= p:
			q -= j // 2
			p -= j % 2
			c += 1
		elif j // 2 > q and p >= j - 2 * q:
			p -= j - 2 * q
			q = 0
			c += 1
	print(c)


for _ in range(int(input())):
	(n, p, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	k = 0
	for i in l:
		if 2 * q + p < i:
			break
		else:
			r2 = i // 2
			if i % 2 == 0:
				r1 = 0
			else:
				r1 = 1
			if r1 > p:
				continue
			q -= r2
			p -= r1
			k += 1
	print(k)


try:
	for _ in range(int(input())):
		(n, p, q) = list(map(int, input().split()))
		l = list(map(int, input().split()))
		l.sort()
		for i in range(n):
			if l[i] % 2 == 0:
				a = l[i] // 2
				q = q - a
				if q >= 0:
					l[i] = l[i] - 2 * a
				else:
					break
		i = 0
		while p >= 0 and i < n:
			p = p - l[i]
			if p >= 0:
				l[i] = 0
			i += 1
		print(l.count(0))
except:
	pass


t = int(input())
while t > 0:
	(n, p, q) = input().split(' ')
	n = int(n)
	p = int(p)
	q = int(q)
	l = list(map(int, input().split(' ')))
	if q == 0:
		s = 0
		count = 0
		l.sort()
		for i in l:
			s = s + i
			if s > p:
				break
			else:
				count = count + 1
		print(count)
	elif p == 0:
		l1 = list(filter(lambda x: x % 2 == 0, l))
		s = 0
		count = 0
		l1.sort()
		for i in l1:
			s = s + i
			if s > 2 * q:
				break
			else:
				count = count + 1
		print(count)
	t = t - 1


t = int(input())
while t > 0:
	t -= 1
	(n, p, q) = map(int, input().strip().split())
	li = list(map(int, input().strip().split()))
	li.sort()
	i = 0
	amt = 2 * q + p
	count = 0
	while i < n and amt >= li[i]:
		j = min(q, li[i] // 2)
		k = min(p, li[i] - j * 2)
		x = k + j * 2
		if x == li[i]:
			q -= j
			p -= k
			count += 1
		amt = 2 * q + p
		i += 1
	print(count)


t = int(input())
while t:
	d = input().split()
	(n, p, q) = (int(d[0]), int(d[1]), int(d[2]))
	l = list(map(int, input().split()))
	r = 0
	l.sort()
	for j in range(len(l)):
		if l[j] % 2 != 0:
			if p <= 0:
				continue
			else:
				l[j] -= 1
				p -= 1
		if q >= l[j] / 2:
			q -= l[j] / 2
			r += 1
		elif q * 2 + p >= l[j]:
			p -= l[j] - q * 2
			q = 0
			r += 1
	print(r)
	t = t - 1


t = int(input())
for i in range(t):
	(n, p, q) = map(int, input().split())
	array = list(map(int, input().split()))
	array.sort()
	count = 0
	for k in array:
		if k // 2 <= q and k % 2 <= p:
			q -= k // 2
			p -= k % 2
			count += 1
		elif k // 2 > q and p >= k - 2 * q:
			p -= k - 2 * q
			q = 0
			count += 1
	print(count)


for _ in range(int(input())):
	(n, p, q) = map(int, input().split())
	a = sorted(map(int, input().split()))
	ans = 0
	for i in range(n):
		if a[i] // 2 <= q:
			if a[i] % 2 <= p:
				p -= a[i] % 2
				q -= a[i] // 2
				ans += 1
		elif p >= a[i] - 2 * q:
			p -= a[i] - 2 * q
			q = 0
			ans += 1
	print(ans)


for i in range(int(input())):
	(n, p, q) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	count = 0
	for i in sorted(a):
		no_2 = i // 2
		q1 = q
		if no_2 <= q:
			q1 -= no_2
		else:
			q1 = 0
			no_2 = q
		if p >= i - 2 * no_2:
			p -= i - 2 * no_2
			q = q1
			count += 1
	print(count)


for _ in range(int(input())):
	(N, P, Q) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	A.sort()
	z = 0
	for i in A:
		x = min(Q, i // 2)
		y = min(P, i - 2 * x)
		if y + 2 * x >= i:
			P -= y
			Q -= x
			z += 1
	print(z)


from sys import stdin, stdout
input = stdin.readline
t = int(input().strip())
for _ in range(t):
	(n, p, q) = list(map(int, input().strip().split()))
	arr = list(map(int, input().strip().split()))
	arr.sort()
	count = 0
	prev = q
	for num in arr:
		t1 = num // 2
		prev = q
		if t1 >= q:
			t2 = num - 2 * q
			q = 0
		else:
			q -= t1
			t2 = num % 2
		if p >= t2:
			p -= t2
		else:
			q = prev
			continue
		count += 1
	print(count)


for tcase in range(int(input())):
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	while i < n and q > 0 and (p > 0):
		d = min(q, a[i] // 2)
		a[i] -= 2 * d
		q -= d
		if a[i] == 1:
			a[i] = 0
			p -= 1
		i += 1
	i0 = max(i - 1, 0)
	i = i0
	while i < n and q > 0:
		if a[i] % 2 == 0:
			d = min(q, a[i] // 2)
			a[i] -= 2 * d
			q -= d
		i += 1
	i = i0
	while i < n and q > 0:
		if a[i] % 2 == 1:
			d = min(q, a[i] // 2)
			a[i] -= 2 * d
			q -= d
		i += 1
	a.sort()
	i = i0
	while i < n and p > 0:
		d = min(p, a[i])
		a[i] -= d
		p -= d
		i += 1
	i = i0
	while i < n and a[i] == 0:
		i += 1
	print(i)


t = int(input())
for i in range(t):
	(n, p, q) = input().split()
	(n, p, q) = (int(n), int(p), int(q))
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	for j in range(len(l)):
		if l[j] % 2 != 0:
			if p <= 0:
				continue
			else:
				l[j] -= 1
				p -= 1
		if q >= l[j] // 2:
			q -= l[j] // 2
			c += 1
		elif q * 2 + p >= l[j]:
			p -= l[j] - q * 2
			q = 0
			c += 1
		else:
			break
	print(c)


t = int(input())
while t > 0:
	(n, p, q) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	tot = 2 * q + p
	i = 0
	ans = 0
	for i in range(len(a)):
		if p == 0:
			if a[i] % 2 == 0 and a[i] <= tot:
				ans += 1
				tot = tot - a[i]
		elif a[i] <= tot and p != 0:
			ans += 1
			tot = tot - a[i]
			if a[i] % 2 == 1:
				p = p - 1
	print(ans)
	t -= 1


for j in range(int(input())):
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	for i in a:
		if p == 0 and q == 0:
			break
		elif i % 2 == 0:
			if q >= i // 2:
				count += 1
				q -= i // 2
			elif p >= i - q - q:
				count += 1
				p -= i - q - q
				q = 0
			else:
				continue
		elif q >= i // 2:
			if p > 0:
				count += 1
				p -= 1
				q -= i // 2
			else:
				continue
		elif p >= max(i - q - q, -1):
			count += 1
			p -= i - q - q
			q = 0
		else:
			continue
	print(count)


T = int(input())
for _ in range(T):
	(n, p, q) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	count = 0
	arr.sort()
	for i in arr:
		t = i
		u = min(q, t // 2)
		t -= 2 * u
		if p >= t:
			count += 1
			q -= u
			p -= i - 2 * u
	print(count)


t = int(input())
for i in range(t):
	(n, p, q) = map(int, input().split())
	lis = list(map(int, input().split()))
	lis.sort()
	ct = 0
	for temp in lis:
		if q == 0:
			if p >= temp:
				ct += 1
				p -= temp
			else:
				break
		elif p == 0:
			if temp % 2 == 0:
				m1 = temp // 2
				if q >= m1:
					q -= m1
					ct += 1
				else:
					break
		else:
			x = temp // 2
			if q <= x:
				temp = temp - 2 * q
				q = 0
				if p >= temp:
					ct += 1
					p -= temp
				else:
					break
			else:
				q = q - x
				if temp % 2 == 0:
					ct += 1
				elif p > 0:
					p -= 1
					ct += 1
				else:
					break
		if p == 0 and q == 0:
			break
	print(ct)


try:
	for _ in range(int(input())):
		(n, p, q) = map(int, input().split())
		a = list(map(int, input().split()))
		a.sort()
		b = 0
		for i in a:
			if i // 2 <= q and i % 2 <= p:
				q -= i // 2
				p -= i % 2
				b += 1
			elif i // 2 > q and i - 2 * q <= p:
				p -= i - 2 * q
				q = 0
				b += 1
		print(b)
except:
	pass


T = int(input())
for i in range(T):
	m = input().split(' ')
	N = int(m[0])
	P = int(m[1])
	Q = int(m[2])
	a = input().split(' ')
	l = []
	for i in range(N):
		l.append(int(a[i]))
	l.sort()
	count = 0
	for i in range(len(l)):
		c = int(l[i] / 2)
		d = int(l[i] % 2)
		if d <= P and c <= Q:
			P = P - d
			Q = Q - c
			count = count + 1
		elif c > Q:
			c = c - Q
			Q = 0
			if c * 2 + d <= P:
				P = P - (c * 2 + d)
				count = count + 1
			else:
				break
	print(count)


t = int(input())
while t > 0:
	ans = 0
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	for i in a:
		if p + 2 * q < i:
			break
		k = i // 2
		if i & 1:
			rem = 1
		else:
			rem = 0
		if rem > p:
			continue
		p -= rem
		q -= k
		ans += 1
	print(ans)
	t -= 1


for _ in range(int(input())):
	(n, p, q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	for i in a:
		if i == 0:
			c += 1
			continue
		if i % 2 == 1 and p == 0:
			continue
		if p + q * 2 < i:
			break
		if i % 2 == 1:
			if p > 0 and q >= i // 2:
				p -= 1
				q -= i // 2
				c += 1
			elif p > 0:
				x = i - 2 * q
				q = 0
				p -= x
				c += 1
		if i % 2 == 0:
			if q >= i // 2:
				q -= i // 2
				c += 1
			elif p > 0:
				x = i - 2 * q
				q = 0
				p -= x
				c += 1
	print(c)


def test(p, q, fares):
	fares.sort()
	counter = 0
	for f in fares:
		if f - p - 2 * q > 0:
			break
		elif f % 2 == 1 and p == 0:
			continue
		else:
			copy = f
			if copy % 2 == 1:
				p -= 1
				copy -= 1
			nb2 = min(copy / 2, q)
			copy -= 2 * nb2
			q -= nb2
			nb1 = min(copy, p)
			copy -= nb1
			p -= nb1
			counter += 1
	return counter

def main():
	nb_tests = int(input())
	for ti in range(nb_tests):
		(n, p, q) = [int(x) for x in input().split()]
		fares = [int(x) for x in input().split()]
		counter = test(p, q, fares)
		print(counter)
main()


def curr_m(P, Q):
	return P + Q * 2
for _ in range(int(input())):
	(N, P, Q) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	for i in range(N):
		(p, q, r) = (P, Q, a[i])
		if curr_m(P, Q) >= a[i]:
			if a[i] % 2 == 0:
				req_2 = int(r / 2)
				r -= min(q, req_2) * 2
				q -= min(q, req_2)
				if r != 0:
					req_1 = r
					r -= min(p, req_1)
					p -= min(p, req_1)
				if r == 0:
					count += 1
					(P, Q) = (p, q)
			else:
				req_2 = int(r / 2)
				r -= min(q, req_2) * 2
				q -= min(q, req_2)
				req_1 = r
				r -= min(p, req_1)
				p -= min(p, req_1)
				if r == 0:
					count += 1
					(P, Q) = (p, q)
	print(count)


for i in range(int(input())):
	(n, o, t) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort()
	ans = 0
	for i in a:
		two_coin = 0
		one_coin = 0
		if 2 * t + o < i:
			break
		if i // 2 > 0:
			two_coin = i // 2
		if two_coin > t:
			two_coin = t
		one_coin = i - 2 * two_coin
		if one_coin > o:
			continue
		t = t - two_coin
		o = o - one_coin
		ans += 1
	print(ans)


def main():
	T = int(input())
	for t in range(T):
		(N, ones, twos) = map(int, input().split(' '))
		debts = sorted(map(int, input().split(' ')))
		satisfied = 0
		for debt in debts:
			req_twos = min(debt // 2, twos)
			debt -= 2 * req_twos
			req_ones = min(debt, ones)
			debt -= req_ones
			if debt:
				continue
			satisfied += 1
			ones -= req_ones
			twos -= req_twos
			if not ones and (not twos):
				break
		print(satisfied)
main()


for _ in range(int(input())):
	(n, p, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ite = 0
	tot = 0
	while ite < n:
		if arr[ite] > p + 2 * q:
			break
		if p == 0:
			if arr[ite] & 1:
				ite += 1
			else:
				q -= arr[ite] // 2
				tot += 1
				ite += 1
		elif q == 0:
			p -= arr[ite]
			tot += 1
			ite += 1
		else:
			(two, one) = divmod(arr[ite], 2)
			if arr[ite] & 1:
				if two <= q:
					q -= arr[ite] // 2
					p -= 1
					tot += 1
					ite += 1
				else:
					rem = 2 * (two - q)
					q = 0
					p -= rem
					p -= 1
					tot += 1
					ite += 1
			elif two <= q:
				q -= arr[ite] // 2
				tot += 1
				ite += 1
			else:
				rem = 2 * (two - q)
				q = 0
				p -= rem
				tot += 1
				ite += 1
	print(tot)


t = int(input())
for i in range(t):
	(n, p, q) = map(int, input().split())
	a = sorted(map(int, input().split()))
	count = 0
	for j in a:
		if j <= p + 2 * q:
			if j % 2 == 0:
				count += 1
				q -= j // 2
			elif j % 2 == 1:
				if p == 0:
					pass
				else:
					count += 1
					p -= 1
					q -= (j - 1) // 2
	print(count)


for _ in range(int(input())):
	(n, p, q) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	i = ans = 0
	while i < n and (p > 0 or q > 0):
		twoavail = min(arr[i] // 2, q)
		arr[i] -= 2 * twoavail
		q -= twoavail
		oneavail = min(arr[i], p)
		arr[i] -= oneavail
		p -= oneavail
		if arr[i] == 0:
			ans += 1
		else:
			q += twoavail
			p += oneavail
		i += 1
	print(ans)


for _ in range(int(input())):
	(n, p, q) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))
	res = 0
	if p == 0:
		for i in a:
			if i % 2 == 0 and q - i // 2 >= 0:
				res += 1
				q -= i // 2
	elif q == 0:
		for i in a:
			if p - i >= 0:
				res += 1
				p -= i
	else:
		for i in a:
			if q >= i // 2 and p >= i % 2:
				q -= i // 2
				p -= i % 2
				res += 1
			elif q < i // 2 and p >= i - 2 * q:
				p -= i - 2 * q
				q = 0
				res += 1
	print(res)


from collections import Counter
T = int(input())
for i in range(T):
	(n, p, q) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a = sorted(a)
	count = 0
	j = 0
	while p > 0 and q > 0 and (j < n):
		if a[j] % 2 == 0:
			if q * 2 >= a[j]:
				q -= a[j] / 2
				count += 1
			else:
				a[j] -= 2 * q
				q = 0
				if p >= a[j]:
					p -= a[j]
					count += 1
		elif 2 * q + p >= a[j]:
			n_even_to_throw = min(q, (a[j] - 1) / 2)
			q -= n_even_to_throw
			p -= a[j] - n_even_to_throw * 2
			count += 1
		else:
			(p, q) = (0, 0)
		j += 1
	if q == 0 and p > 0:
		while p > 0 and j < n:
			if p >= a[j]:
				p -= a[j]
				count += 1
			else:
				p = 0
			j += 1
	if q > 0 and p == 0:
		while q > 0 and j < n:
			if a[j] % 2 == 0:
				if 2 * q >= a[j]:
					q -= a[j] / 2
					count += 1
				else:
					q = 0
			j += 1
	print(count)


T = int(input())
for _t in range(T):
	(N, P, Q) = map(int, input().strip().split())
	A = list(map(int, input().strip().split()))
	A.sort()
	a = P + (Q << 1)
	i = 0
	ans = 0
	while a > 0 and i < N:
		j = A[i]
		t = min(Q, j >> 1)
		o = min(P, j - (t << 1))
		x = o + (t << 1)
		if x == j and x <= a:
			ans += 1
			a -= x
			P -= o
			Q -= t
		i += 1
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, p, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	for i in range(n):
		x = arr[i] // 2
		q_given = min(q, x)
		p_given = min(p, arr[i] - q_given * 2)
		if p_given + q_given * 2 == arr[i]:
			ans += 1
			p -= p_given
			q -= q_given
		if p == 0 and q == 0:
			break
	print(ans)


def check(arr, tar, p, q):
	count = 0
	for y in arr:
		if y == 1:
			if p - 1 >= 0:
				p -= 1
				count += 1
			elif q >= 1:
				pass
			else:
				break
		elif y % 2 == 0:
			if q - y // 2 >= 0:
				q -= y // 2
				count += 1
			elif p - (y - 2 * q) >= 0:
				p -= y - 2 * q
				q = 0
				count += 1
			else:
				break
		elif q - y // 2 >= 0:
			if p - 1 >= 0:
				p -= 1
				q -= y // 2
				count += 1
			elif p == 0 and q > 0:
				pass
			else:
				break
		elif p - (y - 2 * q) >= 0:
			p -= y - 2 * q
			q = 0
			count += 1
		elif p == 0 and q > 0:
			pass
		else:
			break
	if count >= tar:
		return True
	return False

def ans(arr, n, p, q):
	arr.sort()
	start = 0
	end = n
	current = 0
	while start <= end:
		mid = (start + end) // 2
		if check(arr, mid, p, q) is True:
			current = mid
			start = mid + 1
		else:
			end = mid - 1
	return current
test_cases = int(input())
while test_cases != 0:
	d = list(map(int, input().split()))
	d2 = list(map(int, input().split()))
	print(ans(d2, d[0], d[1], d[2]))
	test_cases -= 1


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

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

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

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

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

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

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = inp()
for i in range(t):
	(n, p, q) = mp()
	l = li()
	l.sort()
	c = 0
	for i in range(n):
		if l[i] % 2 == 0:
			if q * 2 >= l[i]:
				c += 1
				q -= l[i] // 2
			else:
				l[i] -= q * 2
				r = q
				q = 0
				if l[i] <= p:
					p -= l[i]
					c += 1
				else:
					q = r
		elif l[i] - 1 <= q * 2 and p > 0:
			p -= 1
			q -= (l[i] - 1) // 2
			c += 1
		elif l[i] - 1 > q * 2:
			l[i] -= q * 2
			r = q
			q = 0
			if l[i] <= p:
				p -= l[i]
				c += 1
			else:
				q = r
	print(c)


t = int(input())
while t > 0:
	(n, p, q) = input().split(' ')
	n = int(n)
	p = int(p)
	q = int(q)
	l = list(map(int, input().split(' ')))
	if q == 0:
		s = 0
		count = 0
		l.sort()
		for i in l:
			s = s + i
			if s > p:
				break
			else:
				count = count + 1
		print(count)
	t = t - 1


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, r1, r2) = map(int, stdin.readline().split())
	a = sorted(map(int, stdin.readline().split()))
	ans = 0
	for c in a:
		if (r2 << 1) + r1 < c:
			break
		if r1 == 0:
			if ~c & 1:
				r2 -= c >> 1
				ans += 1
			continue
		if r2 > 0:
			r2 -= (t := min(r2, c >> 1))
			r1 += t << 1
		r1 -= c
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, p, q) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	for i in l:
		if p + 2 * q < i:
			break
		cost = min(q, i // 2)
		if p >= i - 2 * cost:
			c += 1
			q -= cost
			p -= i - 2 * cost
	print(c)