Chef is multi-talented. He has developed a cure for coronavirus called COVAC-19. Now that everyone in the world is infected, it is time to distribute it throughout the world efficiently to wipe out coronavirus from the Earth. Chef just cooks the cure, you are his distribution manager.
In the world, there are $N$ countries (numbered $1$ through $N$) with populations $a_1, a_2, \ldots, a_N$. Each cure can be used to cure one infected person once. Due to lockdown rules, you may only deliver cures to one country per day, but you may choose that country arbitrarily and independently on each day. Days are numbered by positive integers. On day $1$, Chef has $x$ cures ready. On each subsequent day, Chef can supply twice the number of cures that were delivered (i.e. people that were cured) on the previous day. Chef cannot supply leftovers from the previous or any earlier day, as the cures expire in a day. The number of cures delivered to some country on some day cannot exceed the number of infected people it currently has, either.
However, coronavirus is not giving up so easily. It can infect a cured person that comes in contact with an infected person again ― formally, it means that the number of infected people in a country doubles at the end of each day, i.e. after the cures for this day are used (obviously up to the population of that country).
Find the minimum number of days needed to make the world corona-free.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains two space-separated integers $N$ and $x$.
- The second line contains $N$ space-separated integers $a_1, a_2, \ldots, a_N$.

-----Output-----
For each test case, print a single line containing one integer ― the minimum number of days.

-----Constraints-----
- $1 \le T \le 10^3$
- $1 \le N \le 10^5$
- $1 \le a_i \le 10^9$ for each valid $i$
- $1 \le x \le 10^9$
- the sum of $N$ over all test cases does not exceed $10^6$

-----Subtasks-----
Subtask #1 (20 points): $a_1 = a_2 = \ldots = a_N$
Subtask #2 (80 points): original constraints

-----Example Input-----
3
5 5
1 2 3 4 5
5 1
40 30 20 10 50
3 10
20 1 110

-----Example Output-----
5
9
6

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
import math
for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	l.sort()
	flag = 0
	d = 0
	for j in range(n):
		if l[j] > x:
			for k in range(j, n):
				if x < l[k]:
					d += math.ceil(math.log(l[k] / x) / math.log(2)) + 1
				else:
					d += 1
				x = l[k] * 2
				flag = 1
			break
	if flag == 1:
		print(j + d)
	else:
		print(n)


test = int(input())
for _ in range(test):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	days = 0
	for i in range(n):
		if arr[i] > x:
			while x < arr[i]:
				x = x * 2
				days = days + 1
			days = days + 1
			x = 2 * arr[i]
		else:
			days = days + 1
			x = max(x, 2 * arr[i])
	print(days)


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	for i in range(n):
		if a[i] <= k:
			c += 1
			k = max(k, 2 * a[i])
		else:
			while k < a[i]:
				k = 2 * k
				c += 1
			c += 1
			k = 2 * a[i]
	print(c)


from sys import stdin, stdout
import math
from itertools import permutations, combinations, permutations
from collections import defaultdict
from collections import Counter
from bisect import bisect_left
import sys
from queue import PriorityQueue
import operator as op
from functools import reduce
mod = 1000000007

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

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

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, list(range(n, n - r, -1)), 1)
	denom = reduce(op.mul, list(range(1, r + 1)), 1)
	return numer // denom

def myCode():
	(n, x) = In()
	lst = L()
	count = 0
	lst.sort()
	for i in lst:
		if x >= i:
			count += 1
			x = max(x, 2 * i)
		else:
			while x < i:
				count += 1
				x = 2 * x
			count += 1
			x = 2 * i
	print(count)

def main():
	for t in range(I()):
		myCode()

def __starting_point():
	main()
__starting_point()


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	m = max(a)
	if k >= m:
		print(n)
		continue
	else:
		c = 0
		while k < m:
			f = 0
			for i in range(n):
				if a[i] <= k and a[i] > k // 2:
					f = 1
					k = 2 * a[i]
					a[i] = 0
					break
			if f == 0:
				k = k * 2
			c += 1
		for i in range(n):
			if a[i] != 0:
				c += 1
		print(c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	count = 0
	while i < n:
		if l[i] <= x:
			count += 1
			x = max(l[i] * 2, x)
			i += 1
		elif l[i] > x:
			count += 1
			x = x * 2
	print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	days = 0
	while i < n and 2 * l[i] <= x:
		i += 1
		days += 1
	while i < n:
		days += 1
		if l[i] > x and 2 * (l[i] - x) >= l[i]:
			x = 2 * x
			continue
		if l[i] <= x:
			x = l[i]
			i += 1
		x = 2 * x
	print(days)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	for i in range(n):
		if a[i] >= x / 2:
			break
	count = i
	while 1:
		if a[i] <= x:
			count += 1
			x = max(x, 2 * a[i])
		else:
			while a[i] > x:
				x = 2 * x
				count += 1
			x = 2 * a[i]
			count += 1
		i += 1
		if i == n:
			break
	print(count)


t = int(input())

def solvethequetion(l, n, x):
	(p, ct) = (0, 0)
	for i in range(0, n):
		if l[i] * 2 >= x:
			p = i
			break
	for i in range(p, n):
		if l[i] <= x:
			x = l[i] * 2
			ct += 1
		elif x < l[i]:
			while x < l[i]:
				x *= 2
				ct += 1
			x = l[i] * 2
			ct += 1
	print(ct + p)
while t != 0:
	t -= 1
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	l.sort()
	solvethequetion(l, n, x)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	my_max = arr[-1]
	if x >= my_max:
		print(len(arr))
	else:
		count = 0
		while x < my_max:
			for i in arr:
				if 2 * i > x and x >= i:
					arr.remove(i)
					break
			x *= 2
			count += 1
		print(count + len(arr))


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	l.sort()
	days = 0
	for target in l:
		while x < target:
			x <<= 1
			days += 1
		x = max(x, target << 1)
		days += 1
	print(days)


for i in range(int(input())):
	k = list(map(int, input().split()))
	n = k[0]
	x = k[1]
	l = list(map(int, input().split()))
	l.sort()
	i = 0
	v = 0
	c = 0
	t = 0
	for i in l:
		if x >= i:
			v = v + 1
			x = x * 2
		while x <= i:
			z = i - x
			c = c + 1
			x = x * 2
			if z * 2 <= i:
				i = z
				t = 1
			else:
				i = i
	print(c + v + t)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	cnt = list(map(int, input().split()))
	cnt.sort()
	day = 0
	j = 0
	while j < n:
		day += 1
		if cnt[j] - x <= 0:
			x = max(x, 2 * cnt[j])
			j += 1
		else:
			x = 2 * x
	print(day)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	days = 0
	i = 0
	while i < n:
		if a[i] <= m:
			m = max(2 * a[i], m)
			days += 1
			i += 1
		else:
			m *= 2
			days += 1
	print(days)