Many years ago Berland was a small country where only $n$ people lived. Each person had some savings: the $i$-th one had $a_i$ burles.

The government considered a person as wealthy if he had at least $x$ burles. To increase the number of wealthy people Berland decided to carry out several reforms. Each reform looked like that:   the government chooses some subset of people (maybe all of them);  the government takes all savings from the chosen people and redistributes the savings among the chosen people equally. 

For example, consider the savings as list $[5, 1, 2, 1]$: if the government chose the $1$-st and the $3$-rd persons then it, at first, will take all $5 + 2 = 7$ burles and after that will return $3.5$ burles to the chosen people. As a result, the savings will become $[3.5, 1, 3.5, 1]$.

A lot of data was lost from that time, so we don't know how many reforms were implemented and to whom. All we can do is ask you to calculate the maximum possible number of wealthy people after several (maybe zero) reforms.


-----Input-----

The first line contains single integer $T$ ($1 \le T \le 1000$) — the number of test cases.

Next $2T$ lines contain the test cases — two lines per test case. The first line contains two integers $n$ and $x$ ($1 \le n \le 10^5$, $1 \le x \le 10^9$) — the number of people and the minimum amount of money to be considered as wealthy.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) — the initial savings of each person.

It's guaranteed that the total sum of $n$ doesn't exceed $10^5$.


-----Output-----

Print $T$ integers — one per test case. For each test case print the maximum possible number of wealthy people after several (maybe zero) reforms.


-----Example-----
Input
4
4 3
5 1 2 1
4 10
11 9 11 9
2 5
4 3
3 7
9 4 9

Output
2
4
0
3



-----Note-----

The first test case is described in the statement.

In the second test case, the government, for example, could carry out two reforms: $[\underline{11}, \underline{9}, 11, 9] \rightarrow [10, 10, \underline{11}, \underline{9}] \rightarrow [10, 10, 10, 10]$.

In the third test case, the government couldn't make even one person wealthy.

In the fourth test case, the government could choose all people to carry out a reform: $[\underline{9}, \underline{4}, \underline{9}] \rightarrow [7\frac{1}{3}, 7\frac{1}{3}, 7\frac{1}{3}]$.

Difficulty: EASY

Solutions:
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	total = 0
	output = 0
	for i in range(n):
		total += a[i]
		if total / (i + 1) >= x:
			output += 1
		else:
			break
	print(output)


T = int(input())

def solve():
	[N, X] = list(map(int, input().split()))
	A = list(map(int, input().split()))
	A = sorted(A)
	sm = 0
	best = 0
	for i in range(len(A) - 1, -1, -1):
		sm += A[i]
		if sm >= X * (len(A) - i):
			best = len(A) - i
	print(best)
for _ in range(T):
	solve()


from itertools import accumulate
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	nums = list(map(int, input().split(' ')))
	ans = 0
	nums.sort(reverse=True)
	acc = list(accumulate(nums))
	s = 0
	OK = -1
	NG = n
	m = (OK + NG) // 2

	def judge(m):
		return acc[m] >= k * (m + 1)
	while NG - OK > 1:
		if judge(m):
			OK = m
		else:
			NG = m
		m = (OK + NG) // 2
	print(OK + 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = list(sorted(a, reverse=True))
	m = 0
	max_sum = 0
	for a_i in a:
		if (max_sum + a_i) / (m + 1) >= x:
			max_sum = max_sum + a_i
			m = m + 1
	print(m)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if sum(l) // n >= x:
		print(n)
	else:
		c = 0
		l.sort(reverse=True)
		s = 0
		f = 0
		for i in range(n):
			s += l[i]
			if s // (i + 1) >= x:
				c += 1
			else:
				f == 1
				break
		print(c)


from collections import *
from itertools import *
from bisect import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		(n, x) = arrinp()
		A = arrinp()
		A.sort(reverse=True)
		flag = True
		count = 0
		sum = 0
		idx = 0
		while flag and idx < n:
			sum += A[idx]
			if sum / (count + 1) >= x:
				count += 1
			else:
				flag = False
			idx += 1
		print(count)
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	wn = 0
	for i in range(n):
		s += a[i]
		if s / (i + 1) >= x:
			wn = i + 1
	print(wn)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	s = sum(arr)
	result = len(arr)
	for i in range(n):
		if s / result < x:
			s -= arr[i]
			result -= 1
		else:
			print(result)
			break
		if result == 0:
			print(result)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	sum = 0
	ans = n
	for i in range(n):
		sum += arr[i]
		if sum / (i + 1) < x:
			ans = i
			break
	print(ans)


t = int(input())
for z in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	pos = -1
	for i in range(len(arr)):
		if arr[i] >= x:
			pos = i
			break
	if pos == -1:
		print(0)
	else:
		extra = 0
		for i in range(pos, len(arr)):
			extra += arr[i] - x
		count = len(arr) - pos
		for i in range(pos - 1, -1, -1):
			temp = x - arr[i]
			if extra - temp >= 0:
				extra = extra - temp
				count += 1
			else:
				break
			if extra == 0:
				break
		print(count)


for _ in range(int(input())):
	(am, need) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if sum(arr) / am >= need * am:
		print(am)
	else:
		rich = []
		poor = []
		got = 0
		for i in range(am):
			if arr[i] > need:
				rich.append(arr[i])
			elif arr[i] < need:
				poor.append(arr[i])
			else:
				got += 1
		poor.sort(reverse=True)
		canGive = sum(rich) - len(rich) * need
		for i in range(len(poor)):
			if canGive <= 0:
				break
			if need - poor[i] <= canGive:
				got += 1
				canGive -= need - poor[i]
			else:
				break
		print(got + len(rich))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	(n, x) = list(map(int, input().split()))
	money = list(map(int, input().split()))
	money.sort()
	pref = [0]
	ans = 0
	for j in money:
		pref.append(pref[-1] + j)
	for i in range(1, n + 1):
		if pref[n] - pref[n - i] >= i * x:
			ans += 1
	print(ans)


import sys
from itertools import islice
stdin = sys.stdin
T = stdin.readline()
T = int(T)

def solve(a, x):
	a = sorted(a, reverse=True)
	over = 0
	for (i, el) in enumerate(a):
		over += el - x
		if over < 0:
			return i
	return i + 1
for test_idx in range(T):
	L1 = stdin.readline()
	L2 = stdin.readline()
	(n, x) = [int(x) for x in L1.split()]
	a = [int(x) for x in L2.split()]
	result = solve(a, x)
	print(result)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	savings = list(map(int, input().split()))
	savings.sort()
	count = 1
	ans = 0
	total = 0
	for i in reversed(range(n)):
		total += savings[i]
		if total / count >= x:
			ans += 1
		else:
			break
		count += 1
	print(ans)


test_cases = int(input())
for case in range(test_cases):
	(ppl_count, min_rich_val) = [int(s) for s in input().split()]
	burles = [int(s) for s in input().split()]
	burles = sorted(burles, reverse=True)
	rich_count = 0
	sum_burles = 0
	for idx in range(ppl_count):
		sum_burles += burles[idx]
		if sum_burles / (idx + 1) >= min_rich_val:
			rich_count += 1
		else:
			break
	print(rich_count)


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	suma = 0
	for i in range(n):
		suma += a[i]
		if suma / (i + 1) >= x:
			ans = i + 1
	print(ans)


import bisect
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	s = sum(a)
	t = 0
	k = n
	for i in range(n):
		if (s - t) // x >= n - i:
			k = i
			break
		t += a[i]
	print(n - k)


cases = int(input())
for i in range(cases):
	(size, minimum) = [int(x) for x in input().split()]
	savings = [int(x) for x in input().split()]
	savings.sort(reverse=True)
	money = count = 0
	for s in savings:
		if (money + s) / (count + 1) < minimum:
			break
		else:
			money += s
			count += 1
	print(count)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(N, X) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	s = 0
	for (i, a) in enumerate(A, 1):
		s += a
		if s < X * i:
			break
	else:
		print(i)
		continue
	print(i - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split()))
	cnt = 0
	for i in range(n):
		if a[i] >= x:
			cnt += a[i] - x
			a[i] = 0
		else:
			a[i] = x - a[i]
	ans = 0
	a = sorted(a)
	for i in a:
		if i != 0:
			if i <= cnt:
				cnt -= i
				ans += 1
		else:
			ans += 1
	print(ans)


for t_ in range(int(input())):
	(n, x) = [*map(int, input().split())]
	a = [*map(int, input().split())]
	a.sort()
	s = sum(a)
	res = 0
	for (i, e) in enumerate(a):
		res = n - i
		if s / res >= x:
			break
		else:
			s -= e
		if res == 1:
			res = 0
	print(res)


import os
import sys
from io import BytesIO, IOBase

def solution(arr, n, x):
	arr.sort(reverse=True)
	(sums, cur) = (0, 0)
	res = 0
	for i in range(n):
		sums += arr[i]
		cur += 1
		if sums // cur >= x:
			res += 1
		else:
			break
	write(res)

def main():
	for _ in range(r_int()):
		(n, x) = r_array()
		arr = r_array()
		solution(arr, n, x)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import sys
input = sys.stdin.readline
from math import *

def bo(i):
	return ord(i) - ord('a') + 1
t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().split())
	a = [int(v) for v in input().split()]
	a.sort(reverse=True)
	c = 0
	maxi = 0
	for i in range(n):
		c += a[i]
		if c / (i + 1) >= x:
			maxi = i + 1
	print(maxi)


z = int(input())
while z:
	(n, x) = map(int, input().rstrip().split(' '))
	l = list(map(int, input().rstrip().split(' ')))
	l.sort(reverse=True)
	s = 0
	i = 0
	while i < n:
		s += l[i]
		av = s / (i + 1)
		if av < x:
			break
		i += 1
	print(i)
	z -= 1


tests = int(input())
for ii in range(tests):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sum = 0
	ans = 0
	for i in range(n):
		sum += a[i]
		if sum < (i + 1) * x:
			break
		ans = i + 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sm = 0
	ct = 0
	pos = 0
	while pos < len(a):
		if (sm + a[pos]) / (ct + 1) < x:
			break
		sm += a[pos]
		ct += 1
		pos += 1
	print(ct)


t = int(input())
while t:
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	z = 0
	s = sum(a)
	while len(a) != 0:
		if s / n >= x:
			z = 1
			break
		else:
			s -= a[-1]
			a.pop()
			n -= 1
	print(n)
	t -= 1


def li():
	return list(map(int, input().split()))

def ii():
	return int(input())
testcases = int(input())
for t in range(testcases):
	(n, x) = li()
	arr = li()
	arr.sort(reverse=True)
	prefix = [arr[0]]
	for i in range(1, n):
		prefix.append(prefix[i - 1] + arr[i])
	flag = False
	prefix.reverse()
	for i in range(n):
		if prefix[i] >= x * (n - i):
			print(n - i)
			flag = True
			break
	if flag is False:
		print(0)


t = int(input())
for y in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	suf = [0 for i in range(n)]
	suf[-1] = a[-1]
	for i in range(n - 2, -1, -1):
		suf[i] = a[i] + suf[i + 1]
	ans = 0
	for i in range(n):
		if suf[i] / (n - i) >= x:
			ans = n - i
			break
	print(ans)


ii = input
for _ in range(int(ii())):
	(n, x) = map(int, ii().split())
	a = list(map(int, ii().split()))
	a.sort(reverse=True)
	s = 0
	c = 0
	for i in range(n):
		if a[i] >= x:
			s += a[i] - x
			c += 1
		elif a[i] + s >= x:
			s -= x - a[i]
			c += 1
		else:
			break
	print(c)


def middle_class():
	xyz = input
	tmp = [int(x) for x in xyz().split()]
	n = tmp[0]
	x = tmp[1]
	nums = [int(x) for x in xyz().split()]
	nums.sort()
	summ = sum
	if summ(nums) / n >= x:
		return n
	if nums[-1] < x:
		return 0
	if nums[-1] >= x and (nums[-1] + nums[-2]) / 2 < x:
		return 1
	sum1 = nums[-1]
	for i in range(n - 2, 0, -1):
		if (sum1 + nums[i]) / (n - i) >= x and (sum1 + nums[i] + nums[i - 1]) / (n - i + 1) < x:
			return n - i
		sum1 += nums[i]
xyz = input
t = int(xyz())
for i1 in [0] * t:
	print(middle_class())


for p in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = a[0]
	if s >= x:
		(f, g, y) = (0, 1, 2)
		for i in range(1, n):
			s += a[i]
			c = s / y
			if c < x:
				f = 1
				break
			y += 1
		if f:
			print(i)
		else:
			print(n)
	else:
		print(0)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	summa = 0
	x_kolb = 0
	for j in range(n):
		summa += a[j]
		x_kolb += x
		if summa >= x_kolb:
			ans += 1
		else:
			break
	print(ans)


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	cur = 0
	for i in range(n):
		cur += a[i]
		if cur / (i + 1) < x:
			break
		ans = i + 1
	print(ans)


from pprint import pprint
import sys
input = sys.stdin.readline
import bisect
import collections
q = int(input())
for _ in range(q):
	(n, x) = map(int, input().split())
	dat = list(map(int, input().split()))
	dat.sort(reverse=True)
	total = 0
	res = 0
	for i in range(n):
		cnt = i + 1
		total += dat[i]
		if total / cnt < x:
			break
		res = cnt
	print(res)


import sys
for _ in range(int(input())):
	(n, m) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	a.sort(reverse=True)
	s = 0
	for i in range(n):
		s += a[i]
		if s < (i + 1) * m:
			print(i)
			break
	else:
		print(n)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list1.sort(reverse=True)
	sum1 = 0
	for i in range(0, len(list1)):
		sum1 = sum1 + list1[i]
		if sum1 // k < i + 1:
			print(i)
			break
	else:
		print(n)


t = int(input())
for case in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	cnt = 0
	sum_ = 0
	for i in range(n):
		sum_ += a[-1 - i]
		if sum_ >= k * (cnt + 1):
			cnt += 1
		else:
			break
	print(cnt)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	array = sorted(list(map(int, input().split())))
	rich = [i - x for i in array if i - x >= 0]
	poor = sorted([abs(i - x) for i in array if i - x < 0])
	total = len(rich)
	pot = sum(rich)
	for i in poor:
		pot -= i
		if pot >= 0:
			total += 1
		else:
			break
	print(total)


t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	sum = 0
	sum1 = 0
	for i in arr:
		if i >= x:
			sum += 1
			sum1 += i - x
		else:
			break
	for i in arr:
		if i < x:
			m = x - i
			if m <= sum1:
				sum += 1
				sum1 -= m
		if sum1 <= 0:
			break
	print(sum)


def solve(a, n, x):
	if sum(a) / n >= x:
		return n
	if max(a) < x:
		return 0
	a.sort(reverse=True)
	(count, sm) = (0, 0)
	for i in range(n):
		if (sm + a[i]) / (i + 1) >= x:
			sm += a[i]
			count += 1
	return count
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve(a, n, x))


t = int(input())
for i in range(t):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	a = input().split()
	for j in range(n):
		a[j] = int(a[j])
	a.sort()
	s = sum(a)
	avg = s / n
	j = 0
	while avg < x:
		s = s - a[j]
		n = n - 1
		if n == 0:
			break
		avg = s / n
		j = j + 1
	print(n)


I = lambda : int(input())
M = lambda : map(int, input().split())
L = lambda : list(M())
for _ in range(I()):
	(n, x) = M()
	a = L()
	a.sort(reverse=True)
	c = 0
	s = 0
	for i in range(n):
		if a[i] + s >= x:
			c += 1
			s = a[i] + s - x
	print(c)


def solve():
	(n, x) = [int(i) for i in input().split()]
	l = sorted([int(i) for i in input().split()], reverse=True)
	m = l[0]
	i = 1
	if l[0] < x:
		print(0)
		return
	somme = l[0]
	for i in range(1, n):
		somme += l[i]
		m = somme / (i + 1)
		if m < x:
			print(i)
			return
	print(n)
T = int(input())
for i in range(T):
	solve()


t = int(input())
import sys
input = sys.stdin.readline
for _ in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	if sum(A) >= n * x:
		print(n)
		continue

	def ok(y):
		s = 0
		for i in range(y):
			s += A[i]
		if s >= x * y:
			return True
		else:
			return False
	l = 0
	r = n
	while l + 1 < r:
		c = (l + r) // 2
		if ok(c):
			l = c
		else:
			r = c
	print(l)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

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

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
alp = 'abcdefghijklmnopqrstuvwxyz'
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, x) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	for i in range(n):
		a[i] -= x
	a.sort()
	rc = 0
	ans = 0
	for i in range(n):
		if a[i] >= 0:
			rc += a[i]
			ans += 1
	for i in range(n - 1, -1, -1):
		if a[i] < 0 and rc + a[i] >= 0:
			ans += 1
			rc += a[i]
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	wealth = list(map(int, input().split()))
	wealth.sort(reverse=True)
	s = 0
	index = 0
	for i in range(n):
		s += wealth[i]
		if not s / (i + 1) >= x:
			print(i)
			break
		index = i + 1
	else:
		print(index)


for _ in range(0, int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(0, n):
		s += l[i]
		av = s / (i + 1)
		if av >= x:
			ans = i + 1
	print(ans)


T = int(input())
for i in range(T):
	(N, X) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	s = 0
	n = 0
	while n < N:
		s += A[n]
		if X * (n + 1) > s:
			break
		n += 1
	print(n)


def savings():
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	t = [item - x for item in a]
	(cw, ex) = (0, 0)
	for item in t:
		if item >= 0:
			cw += 1
			ex += item
	r = cw
	for i in range(n - cw - 1, -1, -1):
		ex += t[i]
		if ex >= 0:
			r += 1
	return r
for h in range(int(input())):
	print(savings())


import math
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	s = 0
	j = 1
	for i in arr:
		s = s + i
		if s // j < x:
			break
		j += 1
	print(j - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(_) for _ in input().split()]
	a.sort(reverse=True)
	money = 0
	ans = 0
	for i in a:
		if i >= x:
			money += i - x
			ans += 1
		elif money >= x - i:
			money -= x - i
			ans += 1
		else:
			break
	print(ans)


t = int(input())
for tt in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	sumofl = sum(l)
	i = 0
	while n > 0:
		avg = sumofl / n
		if avg >= x:
			break
		else:
			sumofl -= l[i]
			i += 1
			n -= 1
	print(n)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	su = 0
	czy = True
	for i in range(1, n + 1):
		if su + a[i - 1] - x >= 0:
			su += a[i - 1] - x
		else:
			print(i - 1)
			czy = False
			break
	if czy:
		print(n)


import sys
input = sys.stdin.readline

def func():
	(n, x) = map(int, input().split())
	al = list(map(int, input().split()))
	al = sorted(al, reverse=True)
	ans = 0
	tmp = 0
	for a in al:
		ans += 1
		tmp += a
		if tmp / ans < x:
			print(ans - 1)
			return
	print(n)
	return
t = int(input())
for _ in range(t):
	func()


for _ in range(int(input())):
	(_, x) = map(int, input().split())
	ans = 0
	temp = 0
	for i in sorted(map(int, input().split()), reverse=True):
		if (temp + i) / (ans + 1.0) >= x:
			ans += 1
			temp += i
	print(ans)


t = int(input())
for testcases in range(t):
	(n, x) = map(int, input().split())
	savings = list(map(int, input().split()))
	savings.sort(reverse=True)
	sum = 0
	cnt = 0
	while cnt < n and sum + savings[cnt] >= (cnt + 1) * x:
		sum += savings[cnt]
		cnt += 1
	print(cnt)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	i = 0
	sum1 = 0
	while i < n and a[i] >= x:
		sum1 += a[i]
		i += 1
	while i < n:
		if (sum1 + a[i]) / (i + 1) >= x:
			sum1 += a[i]
			i += 1
		else:
			break
	print(i)


t = int(input())
for i in range(t):
	temp = input().split()
	n = int(temp[0])
	x = int(temp[1])
	temp = input().split()
	nums = []
	for j in temp:
		nums.append(int(j))
	nums.sort(reverse=True)
	tot = 0
	count = 0
	for j in range(0, len(nums)):
		if tot + nums[j] >= x * (j + 1):
			tot += nums[j]
			count = j + 1
		else:
			count = j
			break
	print(count)


t = int(input())
for i in range(t):
	(n, x) = [int(y) for y in input().split()]
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	extramoney = 0
	for i in range(n):
		if a[i] > x:
			extramoney += a[i] - x
			a[i] = x
		if a[i] < x:
			if extramoney < x - a[i]:
				print(i)
				break
			extramoney = extramoney - (x - a[i])
			a[i] = x
			if extramoney == 0:
				if i == n - 1:
					break
				print(i + 1)
				break
	if a[n - 1] >= x:
		print(n)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	n_list = list(map(int, input().split(' ')))
	n_list = sorted(n_list, reverse=True)
	sum_ = 0
	index = 0
	for (i, v) in enumerate(n_list):
		new_sum = sum_ + v
		if new_sum / (i + 1) >= x:
			index += 1
			sum_ += v
		else:
			break
	print(index)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = [int(z) for z in input().split()]
	arr.sort(reverse=True)
	i = 0
	c = 0
	h = 0
	while i < n and arr[i] >= x:
		h += arr[i] - x
		c += 1
		i += 1
	while i < n and h > 0:
		h -= x - arr[i]
		if h >= 0:
			c += 1
		i += 1
	print(c)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))
res = []
for i in range(inp()):
	(x, n) = inlt()
	lista = sorted(inlt())[::-1]
	broj = sum(lista)
	while broj < len(lista) * n:
		broj -= lista[-1]
		lista.pop()
	res.append(len(lista))
for r in res:
	print(r)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	extra = 0
	wealthy_people = []
	poor_people = []
	for a in A:
		if a >= x:
			wealthy_people.append(a)
			extra += a - x
		else:
			poor_people.append(a)
	poor_people.sort()
	for a in poor_people[::-1]:
		if extra - (x - a) < 0:
			break
		else:
			extra -= x - a
			wealthy_people.append(a)
	print(len(wealthy_people))


def main():
	while True:
		try:
			t = int(input(''))
			for _ in range(t):
				line1 = [int(x) for x in input().split()]
				(n, x) = (line1[0], line1[1])
				a = [int(x) for x in input().split()]
				a.sort(reverse=True)
				summ = 0
				count = 0
				for person in a:
					if (summ + person) / (count + 1) < x:
						break
					else:
						summ += person
						count += 1
				print(count)
		except EOFError:
			exit()
main()


for q in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	cnt = 0
	check = True
	for i in range(n):
		cnt += a[i]
		if cnt < x * (i + 1):
			check = False
			break
	if check:
		print(n)
	else:
		print(i)


num = input()
for i in range(int(num)):
	ans = input().split()
	count = int(ans[0])
	minn = int(ans[1])
	ppl_ar = list(input().split())
	for i in range(len(ppl_ar)):
		ppl_ar[i] = int(ppl_ar[i])
	ppl_ar = sorted(ppl_ar)
	sep = -1
	for (index, num) in enumerate(ppl_ar):
		if num >= minn:
			sep = index
			break
	if sep == 0:
		print(len(ppl_ar))
		continue
	if sep == -1:
		print(0)
		continue
	poor = ppl_ar[:sep]
	rich = ppl_ar[sep:]
	ans = len(rich)
	money = sum(rich) - minn * len(rich)
	for i in range(len(poor) - 1, -1, -1):
		if poor[i] + money >= minn:
			ans += 1
			money -= minn - poor[i]
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(s) for s in input().split()]
	s = 0
	f = 0
	f1 = 0
	a.sort()
	for i in range(n):
		s += a[n - 1 - i]
		if s / (i + 1) >= x:
			continue
		elif s / (i + 1) < x:
			f = i
			break
	if sum(a) / n >= x:
		f = n
	print(f)


T = int(input())

def check_possible(arr, x):
	return arr[-1] >= x
for t in range(T):
	(n, x) = [int(c) for c in input().split(' ')]
	a = [int(c) for c in input().split(' ')]
	a.sort()
	if not check_possible(a, x):
		print(0)
		continue
	bound = -1
	for i in range(1, n):
		if a[i - 1] < x <= a[i]:
			bound = i - 1
			break
	rich_count = n - bound - 1
	available_money = sum(a[bound + 1:]) - x * rich_count
	while bound >= 0 and available_money > 0:
		m = min(available_money, x - a[bound])
		available_money -= m
		a[bound] += m
		if a[bound] == x:
			rich_count += 1
			bound -= 1
		else:
			break
	print(rich_count)


list_ans = []
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list1.sort()
	a = sum(list1)
	i = 0
	while n > 0 and a / n < x:
		a -= list1[i]
		i += 1
		n -= 1
	list_ans.append(n)
for item in list_ans:
	print(item)


test = int(input())
for j in range(test):
	(n, x) = map(int, input().split())
	a = [int(w) for w in input().split()]
	a.sort(key=int)
	p = sum(a)
	f = 0
	for i in range(len(a)):
		if p / (n - i) >= x:
			f = 1
			break
		p -= a[i]
	if f == 1:
		print(n - i)
	else:
		print('0')


def solve(n, x, a):
	people = sorted(a, reverse=True)
	line = 0
	while line < len(people) and people[line] >= x:
		line += 1
	overschot = sum(people[:line]) - line * x
	while line < len(people) and overschot > 0:
		overschot -= x - people[line]
		if overschot >= 0:
			line += 1
	return line
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	y = solve(n, x, a)
	print(y)


import sys
from math import sqrt, floor
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))

def a():
	ans = ''
	for _ in range(int(inp())):
		n = int(inp())
		last = [0, 0]
		flag = 1
		for i in range(n):
			arr = read()
			if arr[0] < last[0]:
				flag = 0
			if arr[1] < last[1]:
				flag = 0
			if arr[0] < arr[1]:
				flag = 0
			if arr[0] - last[0] < arr[1] - last[1]:
				flag = 0
			last = arr
		ans += 'YNEOS'[not flag::2] + '\n'
	print(ans)

def b():
	ans = ''
	for _ in range(int(inp())):
		(n, x) = read()
		arr = read()
		p = 0
		s = 0
		mon = dict()
		for i in arr:
			if i < x:
				if not x - i in mon:
					mon[x - i] = 1
				else:
					mon[x - i] += 1
			else:
				p += 1
				s += i - x
		for i in sorted(list(mon.keys())):
			if i * mon[i] <= s:
				s -= i * mon[i]
				p += mon[i]
			else:
				p += s // i
				break
		ans += str(p) + '\n'
	print(ans)
b()


t = int(input())
l = []
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = []
	a = [int(x) for x in input().split()]
	savings = 0
	rich = 0
	b = []
	for k in a:
		if k >= x:
			rich = rich + 1
			savings += k - x
		else:
			b.append(x - k)
	b.sort()
	for k in b:
		if k <= savings:
			rich = rich + 1
			savings -= k
	l.append(rich)
for x in l:
	print(x)


T = int(input())
i = 0
while i < T:
	i += 1
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = sorted(a)
	sum1 = 0
	cnt = 0
	max_val = 0
	for j in range(n - 1, -1, -1):
		sum1 += b[j]
		cnt += 1
		if sum1 >= cnt * x:
			max_val += 1
		else:
			break
	print(max_val)


import sys
input = sys.stdin.readline
testCases = int(input())
for test in range(testCases):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	res = n
	for i in range(n):
		s += a[i] - x
		if s < 0:
			res = i
			break
	print(res)


try:
	t = int(input())
	for _ in range(t):
		(n, lim) = map(int, input().split())
		A = list(map(int, input().split()))
		A = sorted(A)
		extra = 0
		num = 0
		for i in range(n):
			if A[i] >= lim:
				ind = i
				num = A[i]
				break
		if num == 0:
			print(0)
		else:
			for i in range(ind, n):
				extra += A[i] - lim
			final = n - ind
			for i in range(ind - 1, -1, -1):
				if extra >= lim - A[i]:
					extra -= lim - A[i]
					final += 1
				else:
					break
			print(final)
except:
	pass


t = int(input())
for i in range(t):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	wealth = [int(x) for x in input().split()]
	wealth.sort()
	counter = 0
	a = sum(wealth)
	for i in range(n):
		if a / (n - i) >= x:
			print(n - i)
			counter = 1
			break
		a -= wealth[i]
	if counter == 0:
		print(0)


t = int(input())
for j in range(t):
	l = list(map(int, input().split()))
	g = list(map(int, input().split()))
	n = l[0]
	x = l[1]
	d = 0
	g.sort()
	a = sum(g)
	if a // n >= x:
		print(n)
	else:
		for i in range(n - 1):
			a -= g[i]
			if a // (n - i - 1) >= x:
				print(n - i - 1)
				d = 1
				break
		if d == 0:
			if g[-1] < x:
				print(0)
			else:
				print(1)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	res = list(map(lambda x: x - k, a))
	res.sort()
	s = sum(res)
	count1 = 0
	if s >= 0:
		print(n)
	else:
		count = n
		for j in range(n):
			if s < 0:
				s += -res[j]
				count -= 1
			elif s >= 0:
				print(count)
				break
			count1 += 1
		if count1 == n:
			print(0)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ls = list(map(int, input().split()))
	lsx = [j - x for j in ls if j >= x]
	c = len(lsx)
	s = sum(lsx)
	ls.sort(reverse=True)
	for j in ls:
		if j < x:
			if x - j <= s:
				c = c + 1
				s = s - (x - j)
			elif x - j > s:
				break
	print(c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	s = 0
	for i in range(n):
		s += a[i]
		avg = s / (i + 1)
		if avg < x:
			break
		i += 1
	print(i)


from sys import stdin as si
from sys import stdout as so

def func():
	[n, x] = [int(x) for x in si.readline().split()]
	arr = [int(x) for x in si.readline().split()]
	arr.sort()
	arr.reverse()
	c = 0
	for i in range(n):
		c += arr[i]
		if c / (i + 1) < x:
			so.write('%d\n' % i)
			return
	so.write('%d\n' % n)
t = int(si.readline())
while t != 0:
	t -= 1
	func()


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, x) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	a = [ac - x for ac in a]
	pos = 0
	for i in range(n):
		if a[i] > 0:
			pos += a[i]
	neg = list(filter(lambda x: x < 0, a))
	negs = len(neg)
	neg.sort()
	neg.reverse()
	ans = n - negs
	for num in neg:
		if num + pos >= 0:
			pos += num
			ans += 1
		else:
			break
	print(ans)


t = int(input())
while t > 0:
	t = t - 1
	(n, x) = map(int, input().split())
	a = input()
	A = list(map(int, list(a.split())))
	A.sort()
	c = A[::-1]
	e = 0
	w = 0
	if c[0] < x:
		print(0)
	elif c[n - 1] >= x:
		print(n)
	else:
		for i in range(n):
			if c[i] >= x:
				e = e + c[i] - x
				w = w + 1
			elif c[i] + e >= x:
				e = e - (x - c[i])
				w = w + 1
			else:
				break
		print(w)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ls = list(map(int, input().split()))
	ls.sort(reverse=True)
	su = 0
	ans = 0
	for i in range(n):
		su += ls[i]
		if su / (i + 1) >= x:
			ans += 1
		else:
			break
	print(ans)


from collections import defaultdict, Counter

def srch(ls, n, key):
	res = n
	s = 0
	e = n - 1
	while s <= e:
		m = (s + e) // 2
		if ls[m] >= key:
			res = m
			e = m - 1
		else:
			s = m + 1
	return res

def solve():
	(n, target) = map(int, input().split())
	ls = list(map(int, input().split()))
	ls = sorted(ls)
	ind = srch(ls, n, target)
	chote = ls[:ind]
	n_b = n - ind
	bde = ls[ind:]
	bs = sum(bde)
	res = n_b
	for i in range(1, len(chote)):
		chote[i] += chote[i - 1]
	chote = [0] + chote
	i = 0
	for num in range(1, len(chote))[::-1]:
		key = target * n_b - bs + target * num
		if chote[-1] - chote[i] >= key:
			res += num
			break
		i += 1
	print(res)
for _ in range(int(input())):
	solve()


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	c = 0
	for j in range(n):
		c = c + l[j]
		if c / (j + 1) < x:
			print(j)
			break
	else:
		print(n)


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a.reverse()
	ans = 0
	d = 0
	for i in a:
		if i >= x:
			ans += 1
			d += i - x
		elif x - i <= d:
			ans += 1
			d -= x - i
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	s = 0
	for i in range(n):
		s += a[i]
		if a[i] >= k:
			continue
		elif s / (i + 1) >= k:
			continue
		else:
			print(i)
			break
	else:
		if s / (i + 1) >= k:
			print(n)


for test_c in range(int(input())):
	(m, y) = map(int, input().split())
	lt = sorted(list(map(int, input().split())), reverse=True)
	ts = con = s = prt = 0
	for i in range(m):
		if lt[i] > y:
			s = lt[i] - y
			ts = ts + s
	for j in range(m):
		if lt[j] < y:
			s = y - lt[j]
			ts = ts - s
			con = con + 1
			if ts < 0:
				con = con - 1
				break
		else:
			prt = prt + 1
	print(con + prt)


for q in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	d.sort(reverse=True)
	psum = 0
	best = 0
	for i in range(n):
		psum += d[i]
		if psum < (i + 1) * x:
			break
		best += 1
	print(best)


for _ in range(int(input())):
	(n, x) = input().split(' ')
	s = list(map(int, input().split(' ')))
	s.sort()
	add = sum(s)
	avg = 0
	p = 0
	for i in range(0, int(n), 1):
		avg += add
		avg /= int(n) - i
		add -= s[i]
		if avg >= int(x):
			p = int(n) - i
			break
		avg = 0
	print(p)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	negatifs = []
	pos = sum = 0
	for i in range(n):
		elt = a[i] - x
		if elt >= 0:
			pos += 1
			sum += elt
		else:
			negatifs.append(elt)
	negatifs.sort()
	negatifs.reverse()
	k = 0
	l = len(negatifs)
	while k < l and sum + negatifs[k] >= 0:
		sum += negatifs[k]
		pos += 1
		k += 1
	print(pos)
	t -= 1


def main():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		a = sorted(list(map(int, input().split())))[::-1]
		cazna = int()
		for coin in range(len(a)):
			dif = a[coin] - x
			if dif > 0:
				a[coin] = x
				cazna += dif
			elif dif < 0:
				if cazna + dif >= 0:
					a[coin] = x
					cazna += dif
		print(len(list(filter(lambda num: num >= x, a))))
main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	s = sorted([int(i) for i in input().split()], reverse=True)
	(a, p) = (0, 0)
	for i in range(n):
		a = a + s[i]
	(a, w) = (a / n, 0)
	for i in range(n):
		w = w + s[i] - x
		if w < 0:
			p = 1
			break
	if p == 1:
		print(i)
	else:
		print(n)


t = int(input())
for tc in range(t):
	s1 = input().split()
	(n, x) = (int(s1[0]), int(s1[1]))
	s = list(map(int, input().split()))
	s.sort()
	su = 0
	co = 0
	for i in range(n - 1, -1, -1):
		if s[i] >= x:
			su += s[i] - x
			co += 1
		else:
			su += s[i] - x
			if su < 0:
				break
			else:
				co += 1
	print(co)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += a[i]
		if s // (i + 1) >= x:
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = sum(a)
	currenttotal = 0
	for j in range(n):
		if b - currenttotal >= (n - j) * x:
			break
		currenttotal += a[j]
	if currenttotal == b:
		ans = 0
	else:
		ans = n - j
	print(ans)


for T in range(int(input())):
	(n, x) = map(int, input().split())
	saving = list(map(int, input().split()))
	saving.sort()
	summ = 0
	for i in range(1, n + 1):
		summ += saving[-i]
		average = summ / i
		if average < x:
			n = i - 1
			break
	print(n)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = [int(x) for x in input().split()]
	l.sort()
	if sum(l) >= n * x:
		print(n)
	elif l[-1] < x:
		print('0')
	else:
		(c, d) = (0, 0)
		for i in range(n - 1, 0, -1):
			if l[i] >= x:
				c += 1
				d += l[i] - x
			elif l[i] + d >= x:
				c += 1
				d = d - x + l[i]
		print(c)


for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	poor = 0
	ext = 0
	for i in range(n):
		if arr[i] >= x:
			ext += arr[i] - x
			arr[i] = x
		else:
			poor += 1
	arr.sort(reverse=True)
	for i in range(n):
		if ext <= 0:
			break
		if arr[i] < x and ext - x + arr[i] >= 0:
			ext -= x - arr[i]
			poor -= 1
	print(n - poor)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(n, x) = invr()
	nums = inlt()
	nums.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += nums[i]
		if s / (i + 1) >= x:
			ans = i + 1
		else:
			break
	print(ans)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	nums = list(map(int, input().split()))
	nums.sort(reverse=True)
	prefix = [i - x for i in nums]
	balance = 0
	counter = 0
	for num in prefix:
		balance += num
		if balance < 0:
			break
		counter += 1
	print(counter)


for ahfiuyh in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	cc = 0
	f = True
	for i in range(n):
		cc += 1
		s += a[i]
		if s // cc < x:
			print(i)
			f = False
			break
	if f:
		print(n)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	L = list(map(int, input().split()))
	count = 0
	s = 0
	v = []
	for i in L:
		if i >= x:
			s += i - x
			count += 1
		else:
			v.append(x - i)
	v.sort()
	for i in v:
		s -= i
		if s >= 0:
			count += 1
		else:
			break
	print(count)


for tc in range(int(input())):
	(n, w) = map(int, input().split())
	ls = list(map(int, input().split()))
	ls.sort(reverse=True)
	sm = 0
	i = 0
	while i != n:
		sm += ls[i]
		if sm < w * (i + 1):
			break
		i += 1
	print(i)


T = int(input())
Y = []
while T:
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	S = sum(A)
	f = 0
	for i in range(n):
		if S / (n - i) >= x and f == 0:
			Y.append(n - i)
			f = 1
			break
		S = S - A[i]
	if f == 0:
		Y.append(0)
	T = T - 1
for i in Y:
	print(i)


for i in range(int(input())):
	(num, mx) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	leftover = 0
	cnt = 0
	for num in arr:
		if num < mx:
			leftover -= mx - num
			if leftover < 0:
				break
			else:
				cnt += 1
		else:
			cnt += 1
			leftover += num - mx
	print(cnt)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ls = list(map(int, input().split()))
	ls.sort()
	sum = 0
	val = 0
	for i in range(n):
		sum += ls[n - i - 1]
		if x * (i + 1) <= sum:
			val = i + 1
	print(val)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		self.num_sets -= 1
		self.parent[a] = b
		self.size[b] += self.size[a]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def lcm(a, b):
	return abs(a // gcd(a, b) * b)

def solve():
	(n, x) = sep()
	ar = lis()
	ar.sort(reverse=True)
	p = prefix_sum(ar)
	for i in range(n):
		if p[i] < x * (i + 1):
			print(i)
			return
	print(n)
testcase(int(inp()))


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	m = sum(arr)
	if m / n >= x:
		ans = len(arr)
	else:
		arr.sort()
		for i in range(n):
			m -= arr[i]
			if i == n - 1:
				if m >= x:
					ans = 1
				elif m < x:
					ans = 0
			elif m / (n - i - 1) >= x:
				ans = n - i - 1
				break
	print(ans)


def main():

	def compute(n, cost):
		res = 0
		(total, i) = (0, 0)
		while total <= cost and i < n:
			total += nums[i]
			res += 1
			i += 1
		return res
	T = int(input().split()[0])
	while T:
		(n, x) = map(int, input().split())
		nums = list(map(int, input().split()))
		nums.sort()
		nums = nums[::-1]
		sum = 0
		for i in range(n):
			sum += nums[i]
			if sum / (i + 1) < float(x):
				i -= 1
				break
		print(str(i + 1))
		T -= 1
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	CHECK = False
	save_sum = sum(a)
	for i in range(n):
		if save_sum / (n - i) >= x:
			CHECK = True
			break
		else:
			save_sum -= a[i]
	print(n - i if CHECK else 0)


from itertools import accumulate
from collections import defaultdict
from bisect import bisect_left, bisect_right
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(sorted(map(int, input().split()), reverse=True))
	left = 0
	ans = 0
	for v in arr:
		if v >= x:
			ans += 1
			left += v - x
		elif v + left >= x:
			ans += 1
			left = v + left - x
		else:
			break
	print(ans)


def calc(x, l):
	sol = sorted(l, reverse=True)
	total = 0
	for (c, e) in enumerate(sol):
		total += e
		avg = total / (c + 1)
		if avg < x:
			return c
	return c + 1
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	print(calc(x, l))


import sys

def process(n, x, A):
	for i in range(n):
		A[i] = A[i] - x
	A = sorted(A)[::-1]
	count = 0
	income = 0
	for a in A:
		if income + a >= 0:
			count += 1
			income += a
	print(count)
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def f(a, n):
	return True

def is_permutation(arr):
	for e in range(1, len(arr) + 1):
		if e not in arr:
			return False
	return True
t = inp()
for i in range(t):
	line = inlt()
	(n, x) = (line[0], line[1])
	A = inlt()
	process(n, x, A)


def abse(s, r):
	pre1 = [0]
	pre2 = [0]
	for i in range(len(s)):
		pre1.append(pre1[-1] + s[i])
	for i in range(len(l)):
		pre2.append(pre2[-1] + l[i])
	e = 0
	t = 1
	if len(pre2) == 1:
		return 0
	while e < len(pre1) - 1 and t < len(pre2):
		if (pre1[e + 1] + pre2[t]) / (t + e + 1) >= y:
			e += 1
		else:
			t += 1
	return len(l) + e
import sys
input = sys.stdin.readline
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	z = list(map(int, input().split()))
	s = []
	l = []
	count = 0
	for i in range(len(z)):
		if z[i] < y:
			s.append(z[i])
		elif z[i] > y:
			l.append(z[i])
		else:
			count += 1
	maxa = 0
	r = sorted(s, reverse=True)
	q = sorted(l, reverse=True)
	a = abse(r, q)
	maxa = max(a + count, maxa)
	print(maxa)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	kol = 0
	mx = 0
	for i in range(n):
		if a[i] >= x:
			mx += a[i] - x
		else:
			mx -= x - a[i]
		if mx >= 0:
			kol += 1
		if mx < 0:
			break
	print(kol)


t = int(input())
for _ in range(t):
	(n, amount) = map(int, input().split())
	l = list(map(int, input().split()))
	sm = 0
	nx = 0
	l.sort(reverse=True)
	ans = 0
	for i in l:
		sm += i
		nx += 1
		if amount <= sm // nx:
			ans += 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	try:
		for i in range(n):
			if a[i] / (i + 1) >= x:
				a[i + 1] += a[i]
			else:
				break
	except Exception as e:
		i += 1
		print('', end='')
	print(i)


def check(arr, lim):
	(summ, n) = (sum(arr), len(arr))
	for i in arr:
		if summ / n >= lim:
			return n
		summ -= i
		n -= 1
	return 0
t = int(input())
for i in range(t):
	(n, lim) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	arr.sort()
	print(check(arr, lim))


def funk():
	(n, x) = map(int, input().split())
	lst = map(int, input().split())
	por = []
	(rich, many) = (0, 0)
	for i in lst:
		if i >= x:
			rich += 1
			many += i - x
		else:
			por.append(i)
	por.sort(reverse=True)
	for i in por:
		many -= x - i
		if many >= 0:
			rich += 1
		else:
			break
	print(rich)
t = int(input())
for _ in range(t):
	funk()


def main(arr, n, x):
	s = sum(arr)
	for i in sorted(arr):
		if x > s / n:
			n -= 1
			s -= i
	print(n)
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	main(arr, n, x)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log, pi, sin
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, x) = sp()
	arr = l()
	arr.sort()
	answer = 0
	s = 0
	for i in range(n - 1, -1, -1):
		s += arr[i]
		if s // (n - i) >= x:
			answer = max(n - i, answer)
	out(answer)


from collections import Counter
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n, x) = gil()
	a = gil()
	a.sort(reverse=True)
	ans = 0
	(l, r) = (1, n)
	while l <= r:
		mid = (l + r) // 2
		if sum(a[:mid]) / mid >= x:
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	print(ans)


import sys
input = sys.stdin.readline
ans = ''
for _ in range(int(input())):
	(n, x) = [int(xi) for xi in input().split(' ')]
	a = [int(xi) for xi in input().split(' ')]
	sorted_a = [i[0] for i in reversed(sorted(enumerate(a), key=lambda x: x[1]))]
	for i in range(n):
		idx = sorted_a[i]
		if len(sorted_a) - 1 > i:
			if a[idx] < x:
				continue
			a[sorted_a[i + 1]] += a[idx] - x
			a[idx] = x
	c_ans = 0
	for xi in a:
		if xi >= x:
			c_ans += 1
	ans += f'{c_ans} '
sys.stdout.write(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = sorted(list(map(int, input().split())), reverse=True)
	cnt = 0
	s = 0
	flag = False
	for i in range(n):
		if arr[i] > k:
			cnt += 1
			s += arr[i]
		else:
			flag = True
			break
	if flag:
		for j in range(i, n):
			s += arr[j]
			if s >= k * (cnt + 1):
				cnt += 1
			else:
				break
	print(cnt)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum(a)
	if s // n >= x:
		print(n)
		continue
	a.sort()
	f = True
	for i in range(n - 1):
		s -= a[i]
		if s // (n - i - 1) >= x:
			print(n - i - 1)
			f = False
			break
	if f:
		print(0)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = [*map(int, input().split())]
	s = 0
	f = n
	for (i, e) in enumerate(sorted(a, reverse=1)):
		if (e + s) // (i + 1) < x:
			f = i
			break
		s += e
	print(f)


t = int(input())
while t != 0:
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))[:n]
	arr.sort(reverse=True)
	if arr[0] < x:
		print(0)
	else:
		i = 1
		average = arr[0]
		temp = arr[0]
		while average >= x and i < n:
			av = (arr[i] + temp) // (i + 1)
			if av >= x:
				temp += arr[i]
				average = av
			else:
				break
			i += 1
		print(i)
	t -= 1


def mic(l, x):
	s = 0
	c = 1
	p = 0
	l.sort(reverse=True)
	if len(l) == 1:
		if l[0] >= x:
			print(1)
		else:
			print(0)
		return
	for i in range(len(l)):
		if s + l[i] >= c * x:
			s = s + l[i]
			c = c + 1
	print(c - 1)
	return
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	mic(l, x)


tt = int(input())
for t in range(tt):
	(n, x) = [float(_) for _ in input().split(' ') if _]
	aa = [float(_) for _ in input().split(' ') if _]
	a = sorted(aa)
	c = []
	for _ in a:
		c.append(_ - x)
	r = len(a)
	d = sum(c)
	i = 0
	while d < 0:
		d -= c[i]
		i += 1
		r -= 1
	print(r)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	z = sorted(map(int, input().split()))
	z.reverse()
	(q, w) = (0, 0)
	for i in range(a):
		q += z[i]
		if q / (i + 1) >= b:
			w += 1
	print(w)


for _ in range(int(input())):
	(N, X) = [int(x) for x in input().split()]
	org = [int(x) for x in input().split()]
	lis = list(map(lambda x: x - X, org))
	lis.sort(reverse=True)
	if lis[0] < 0:
		ans = 0
	elif lis[-1] >= 0:
		ans = N
	else:
		for i in range(N):
			if lis[i] < 0:
				break
		pos = lis[:i]
		neg = lis[i:N]
		ans = i
		excess = sum(pos)
		for i in neg:
			if excess < -i:
				break
			else:
				excess += i
				ans += 1
	print(ans)


t = int(input())
for k in range(t):
	(n, x) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	a.sort(reverse=True)
	c = 0
	s = 0
	for i in range(0, n, 1):
		s += a[i]
		k = i + 1
		if s / k >= x:
			c += 1
		else:
			break
	print(c)


n = int(input())
for _ in range(n):
	(m, x) = tuple(map(int, input().split()))
	inp = list(map(int, input().split()))
	result = 0
	cur_sum = 0
	for (ind, elem) in enumerate(reversed(sorted(inp))):
		cur_sum += elem
		if cur_sum / (ind + 1) >= x:
			result += 1
		else:
			break
	print(result)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	data = list(map(int, input().split()))
	data.sort(reverse=True)
	s = sum(data)
	l = n
	for j in range(n):
		if s / l >= x:
			print(len(data))
			break
		else:
			s = s - data.pop()
			l = l - 1
	else:
		print(0)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	total = 0
	ans = 0
	for i in range(n):
		total += arr[i]
		if total / (i + 1) >= k:
			ans += 1
		else:
			break
	print(ans)


T = int(input())
for _ in range(0, T):
	(n, x) = map(int, input().split())
	s = [int(x) for x in input().split()]
	s.sort()
	s = s[::-1]
	tot = 0
	c = 0
	for i in range(0, len(s)):
		if s[i] >= x:
			tot += s[i] - x
			c += 1
		else:
			req = x - s[i]
			if tot >= req:
				tot -= req
				c += 1
			else:
				break
	print(c)


T = int(input())
while T > 0:
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	a = [int(i) for i in input().split()]
	a.sort(reverse=True)
	i = 0
	sum = 0
	while i < len(a) and a[i] >= x:
		sum += a[i]
		i += 1
	while i < len(a) and sum + a[i] >= x * (i + 1):
		sum += a[i]
		i += 1
	print(i)
	T -= 1


for i in range(int(input())):
	(n, x) = map(int, input().split())
	lis = [x for x in map(int, input().split())]
	lis.sort()
	lis = lis[::-1]
	sum = lis[0]
	j = 1
	while sum >= j * x and j < n:
		sum += lis[j]
		j = j + 1
	if sum >= j * x:
		print(j)
	else:
		print(j - 1)


import math

def main_function():
	t = int(input())
	for i in range(t):
		(n, x) = [int(i) for i in input().split(' ')]
		a = sorted([int(i) for i in input().split(' ')], reverse=True)
		sums = 0
		counter = 0
		for i in range(len(a)):
			if a[i] >= x:
				sums += a[i]
				counter += 1
			else:
				sums += a[i]
				if sums / (i + 1) >= x:
					counter += 1
				else:
					break
		print(counter)
main_function()


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	items = list(map(int, input().split()))
	items = sorted(items, reverse=True)
	extra = 0
	count = 0
	for item in items:
		if item >= x:
			extra += item - x
			count += 1
		elif item + extra >= x:
			extra -= x - item
			count += 1
		else:
			break
	print(count)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	a = a[::-1]
	(cnt, ans) = (0, 0)
	for j in range(n):
		if a[j] > x:
			cnt += a[j] - x
		elif a[j] < x:
			if cnt >= x - a[j]:
				cnt -= x - a[j]
			else:
				break
		ans += 1
	print(ans)


a1 = int(input())
while a1:
	number = 0
	carry = 0
	a2 = [int(i) for i in input().split()]
	a1 -= 1
	a = [int(i) for i in input().split()]
	a.sort()
	a = a[::-1]
	for i in range(a2[0]):
		if a[i] + carry - a2[1] >= 0:
			number += 1
			carry = a[i] + carry - a2[1]
		else:
			break
	print(number)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	extra = 0
	loss = []
	cnt = 0
	for i in arr:
		if i > x:
			extra += i - x
			cnt += 1
		else:
			loss.append(i)
	for i in range(len(loss) - 1, -1, -1):
		want = x - loss[i]
		if want <= extra:
			extra -= want
			cnt += 1
	print(cnt)


t = int(input())
while t != 0:
	(a, b) = map(int, input().split(' '))
	c = list(map(int, input().split(' ')))
	c.sort(reverse=True)
	d = 0
	count = 0
	for i in range(0, a):
		if c[i] >= b:
			d = d + (c[i] - b)
			count = count + 1
		elif d >= b - c[i]:
			count = count + 1
			d = d - (b - c[i])
	print(count)
	t = t - 1


from sys import stdin, stdout
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, stdin.readline().split()))
	l.sort(reverse=True)
	c = 0
	ans = n
	for j in range(n):
		c += l[j]
		if c / (j + 1) < x:
			ans = j
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	lis = sorted(map(int, input().split()))
	ans = 0
	amt = 0
	for i in lis:
		if i > x:
			amt += i - x
	for i in range(n - 1, -1, -1):
		if lis[i] >= x:
			ans += 1
		elif lis[i] + amt >= x:
			ans += 1
			amt -= x - lis[i]
	print(ans)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	A = sorted(map(int, input().split()), reverse=True)
	cur = 0
	for (i, a) in enumerate(A):
		cur += a
		if x - cur / (i + 1) > 1e-08:
			break
	else:
		i = n
	print(i)


t = int(input())
for i in range(t):
	(N, x) = map(int, input().split())
	people = [int(g) for g in input().split(' ')]
	people.sort(reverse=True)
	printed = 0
	current_sum = 0
	for i in range(len(people)):
		current_sum += people[i]
		if current_sum / (i + 1) < x:
			print(i)
			printed = 1
			break
	if not printed:
		print(len(people))


st = ''
from bisect import bisect_left, bisect, bisect_right

def find_ge(a, x):
	i = bisect_left(a, x)
	return i

def func():
	l.sort()
	ind = find_ge(l, x)
	s = sum(l[ind:])
	i = ind - 1
	c = n - ind
	while i > -1:
		if (s + l[i]) / (c + 1) < x:
			break
		else:
			s += l[i]
			i -= 1
			c += 1
	return c
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	st += str(func()) + '\n'
print(st)


for _ in range(int(input())):
	X = list(map(int, input().split()))
	People = sorted(list(map(int, input().split())), reverse=True)
	(Temp, Count) = (0, 0)
	for i in range(X[0]):
		if People[i] >= X[1]:
			Temp += People[i] - X[1]
			Count += 1
		else:
			Min = min(Temp, X[1] - People[i])
			People[i] += Min
			Temp -= Min
			if People[i] >= X[1]:
				Count += 1
	print(Count)


from itertools import chain, combinations

def poset(A):
	return chain.from_iterable((combinations(A, r) for r in range(len(A) + 1)))

def solve_old(n, x, A):
	wp = sum((1 for a in A if a >= x))
	for s in poset(A):
		if len(s) < 2:
			continue
		wp_ = len(s) if sum(s) / len(s) >= x else 0
		wp = max(wp_, wp)
	return wp

def solve_old2(n, x, A):
	if n == 1:
		return 1 if A[0] >= x else 0
	A_ = sorted(A, reverse=True)
	if A_[0] < x:
		return 0
	c = 1
	sum_ = A_[0]
	avg = sum_
	while avg >= x and c < n:
		sum_ += A_[c]
		c += 1
		avg = sum_ / c
	return c - 1

def solve(n, x, A):
	A = sorted(A)
	sum_ = sum(A)
	avg = sum_ / n
	while avg < x:
		if len(A) == 1:
			return 0
		m = avg
		for (j, a) in enumerate(A):
			avg_ = (sum_ - a) / (len(A) - 1)
			if avg_ >= x:
				return len(A) - 1
		sum_ = sum_ - A[0]
		avg = sum_ / (len(A) - 1)
		A = A[1:]
	return len(A)

def solve_new(n, x, A):
	A_ = sorted(A, reverse=True)
	avg = 0
	sum_ = 0
	for (i, a) in enumerate(A_):
		sum_ += a
		avg = sum_ / (i + 1)
		if avg < x:
			return i
	return n
T = int(input())
for _ in range(T):
	(n, x) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	assert len(a) == n
	print(solve_new(n, x, a))


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	a.sort(reverse=True)
	k = 0
	sum = 0
	i = 0
	while k < n:
		if a[k] >= x:
			i += 1
		elif (sum + a[k]) / (k + 1) < x:
			break
		sum += a[k]
		k += 1
	print(k)


import sys
from collections import defaultdict
from copy import copy
R = lambda t=int: t(input())
RL = lambda t=int: [t(x) for x in input().split()]
RLL = lambda n, t=int: [RL(t) for _ in range(n)]

def solve():
	(n, x) = RL()
	A = RL()
	A.sort(reverse=True)
	s = c = m = 0
	for a in A:
		s += a
		c += 1
		if s >= x * c:
			m = c
	print(m)
T = R()
for _ in range(T):
	solve()


import bisect
for _ in range(int(input())):
	ans = 0
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	p = bisect.bisect_left(a, k)
	s = sum(a[p:])
	e = n - p
	for i in range(p - 1, -1, -1):
		s += a[i]
		e += 1
		if s >= e * k:
			continue
		else:
			e -= 1
			break
	print(e)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	(tmp, ans) = (0, 0)
	for i in range(n):
		tmp += a[i]
		if tmp < x * (i + 1):
			ans = i
			break
		ans += 1
	print(ans)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if a[0] < x:
		print('0')
	else:
		s = a[0]
		i = 1
		while s / i >= x and i < n:
			s += a[i]
			i += 1
		if s / i < x:
			print(i - 1)
		else:
			print(n)


import os
import sys
from io import BytesIO, IOBase

def main():
	for tc in range(int(input())):
		line = input().split()
		(n, x) = (int(line[0]), int(line[1]))
		line = input().split()
		arr = []
		summ = 0
		count = 1
		for i in range(n):
			arr.append(int(line[i]))
		arr.sort(reverse=True)
		for i in range(n):
			summ += arr[i]
			if summ / count < x:
				break
			else:
				count += 1
		print(count - 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	a = [int(z) for z in input().split()]
	a = sorted(a, reverse=True)
	mx = 0
	k = 0
	for j in range(x):
		k += a[j]
		if k / (j + 1) >= y:
			mx = j + 1
	print(mx)


a = int(input())
h = []
for i in range(0, a):
	(x, y) = list(map(int, input().split()))
	c = 0
	g = input()
	l = list(map(int, g.split()))
	if float(sum(l) / x) >= y:
		c = x
	else:
		l.sort(reverse=True)
		sum1 = 0
		while c < x and sum1 + l[c] >= (c + 1) * y:
			sum1 += l[c]
			c += 1
	h.append(c)
print(*h, sep='\n')


def main():
	teste = int(input())
	while teste > 0:
		(n, w) = [int(x) for x in input().split()]
		savings = [int(x) for x in input().split()]
		aux = [x - w for x in savings]
		aux.sort(reverse=True)
		count = 0
		total = 0
		for i in aux:
			if count >= 0:
				count += i
				if count >= 0:
					total += 1
				else:
					break
		print(total)
		teste -= 1
main()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, x) = map(int, sys.stdin.readline().split())
	liste = list(map(int, sys.stdin.readline().split()))
	liste.sort()
	somme = 0
	total = 0
	out = 0
	for i in range(n - 1, -1, -1):
		total += 1
		somme += liste[i]
		if somme >= total * x:
			out = total
		else:
			break
	print(out)


t = int(input())
for j in range(t):
	(n, x) = tuple(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	(p, count) = (arr[0] - x, 1)
	if p > 0:
		for i in range(1, n):
			if arr[i] > x:
				p += arr[i] - x
			else:
				p -= x - arr[i]
				if p < 0:
					break
			count += 1
			if not p:
				break
		print(count)
	elif not p:
		for i in range(1, n):
			if arr[i] == x:
				count += 1
		print(count)
	else:
		print(0)


for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	l = sorted(list(map(int, input().split())), reverse=True)
	k = 0
	for i in range(n):
		l[i] = l[i] - x
	e = 1
	for j in range(n):
		k = k + l[j]
		if k < 0:
			print(j)
			e = 0
			break
	if e == 1:
		print(n)


for lo in range(int(input())):
	(n, x) = map(int, input().split())
	ls = [int(x) for x in input().split()]
	ls.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += ls[i]
		if s / (i + 1) >= x:
			ans = i + 1
		else:
			break
	print(ans)


t = int(input())
for q in range(0, t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = 0
	a.sort()
	a = a[::-1]
	m = 0
	for i in range(0, n):
		s += a[i]
		if s / (i + 1) >= x:
			m = i + 1
		else:
			break
	print(m)


test = int(input())
for t in range(test):
	(n, x) = map(int, input().split())
	list = [int(i) for i in input().split()]
	list.sort(reverse=True)
	output = 0
	for k in range(n):
		if list[k] >= x:
			output += 1
			if k < n - 1:
				list[k + 1] += list[k] - x
		else:
			break
	print(output)


from sys import stdin

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, x) = [int(x) for x in inp().split()]
	ar = [int(x) for x in inp().split()]
	ar.sort(reverse=True)
	num = []
	ans = 0
	total = 0
	for i in ar:
		num.append(i)
		total += i
		if total / len(num) >= x:
			ans = len(num)
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	a.sort()
	mx_ppl = 0
	tot_wel = 0
	count = 1
	for j in range(n - 1, -1, -1):
		tot_wel += a[j]
		avg = tot_wel // count
		if avg >= x:
			mx_ppl = max(count, mx_ppl)
		count += 1
	print(mx_ppl)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	s = 0
	su = sum(l)
	for i in range(n):
		if su >= (n - i) * x:
			s = 1
			print(n - i)
			break
		else:
			su -= l[i]
	if s == 0:
		print(0)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(l)
	s = sum(l)
	ans = 0
	for i in range(n):
		if s // (n - i) >= x:
			ans = n - i
			break
		s = s - l[i]
	print(ans)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	i = 0
	csum = 0
	while i < n:
		csum += a[i]
		if csum < x * (i + 1):
			break
		i += 1
	print(i)


t = int(input())
while t:
	line = input().split()
	(n, x) = (int(line[0]), int(line[1]))
	a = input().split()
	a = [int(x) for x in a]
	a.sort()
	s = 0
	i = n - 1
	while i > -1:
		s += a[i]
		if s < x * (n - i):
			break
		i -= 1
	print(n - i - 1)
	t -= 1


CASES = int(input())
answers = []
while CASES:
	CASES -= 1
	(people, thresh) = [int(x) for x in input().split(' ')]
	saves = [int(x) for x in input().split(' ')]
	saves.sort()
	total = sum(saves)
	index = 0
	found = None
	while not found and index < len(saves):
		if total / (len(saves) - index) >= thresh:
			found = len(saves) - index
		else:
			total -= saves[index]
			index += 1
	found = 0 if found == None else found
	answers.append(found)
for ans in answers:
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	(res, pos, check) = (0, 0, 1)
	for i in range(n):
		res += a[i]
		if res / (i + 1) < x:
			pos = i
			check = 0
			break
	if check == 1:
		print(n)
	else:
		print(pos)


t = int(input())
for _ in range(t):
	(n, x) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	t = 0
	for i in range(n):
		t += a[i] - x
		if t < 0:
			i -= 1
			break
	print(i + 1)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	pset = list(filter(lambda w: w >= x, a))
	fset = sorted(filter(lambda w: w < x, a), key=lambda g: -g)
	pn = len(pset)
	if pn == 0:
		print(0)
		return 0
	psum = sum(pset)
	for it in fset:
		if (psum + it) / (pn + 1) >= x:
			psum += it
			pn += 1
	print(pn)
t = int(input())
for _ in range(t):
	solve()


import math
import fractions

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors

def ValueToBits(x, digit):
	res = [0 for i in range(digit)]
	now = x
	for i in range(digit):
		res[i] = now % 2
		now = now >> 1
	return res

def BitsToValue(arr):
	n = len(arr)
	ans = 0
	for i in range(n):
		ans += arr[i] * 2 ** i
	return ans

def ValueToArray10(x, digit):
	ans = [0 for i in range(digit)]
	now = x
	for i in range(digit):
		ans[digit - i - 1] = now % 10
		now = now // 10
	return ans
t = int(input())
for k in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	total = sum(a)
	ans = 0
	for i in range(len(a)):
		val = total / (n - i)
		if val >= x - 1e-06:
			ans = n - i
			break
		total -= a[i]
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	level = 0
	l.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		level += x
		s += l[i]
		if s >= level:
			ans += 1
		else:
			break
	print(ans)


T = int(input())
for j in range(T):
	(n, x) = input().split(' ')
	n = int(n)
	x = int(x)
	arr = []
	arr = input().split(' ')
	for i in range(n):
		arr[i] = int(arr[i])
	arr.sort(reverse=True)
	s = 0
	ans = 0
	for item in arr:
		if item >= x:
			s += item - x
			ans += 1
		elif item < x and s >= x - item:
			s -= x - item
			ans += 1
	print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(sorted(map(int, input().split())))
	i = 0
	su = sum(a)
	while su < n * m:
		n -= 1
		su -= a[i]
		i += 1
	print(n)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = [int(x) for x in input().split()]
	l.sort(reverse=True)
	value = 0
	ans = 0
	for i in range(n):
		value += l[i]
		if value / (i + 1) >= x:
			ans += 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	s = 0
	k = 0
	for i in range(n - 1, -1, -1):
		s += a[i]
		k = n - i
		if s // k < x:
			k -= 1
			break
	print(k)


for i in range(int(input())):
	(n, x) = (int(_) for _ in input().split())
	a = sorted((int(_) for _ in input().split()))[::-1]
	s = 0
	y = 0
	for j in range(n):
		s += a[j]
		if s / (y + 1) >= x:
			y += 1
		else:
			break
	print(y)


t = int(input())
for _ in range(t):
	(m, n) = tuple(map(int, input().split(' ')))
	lis = list(map(int, input().split(' ')))
	total = sum(lis)
	lis.sort()
	res = 0
	for i in range(len(lis)):
		if total / m >= n:
			res = len(lis) - i
			break
		total -= lis[i]
		m -= 1
	print(res)


import sys
input = lambda : sys.stdin.readline().rstrip()

def zap():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	s = 0
	a = sorted(a)
	while (s + a[-1]) // (count + 1) >= x and len(a) > 1:
		count += 1
		s += a[-1]
		del a[-1]
	if (a[-1] + s) // (count + 1) >= x:
		count += 1
	return count
for i in range(int(input())):
	print(zap())


t = int(input())
for _ in range(t):
	[n, x] = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	arr.sort(reverse=1)
	ans = 0
	temp = 0
	for a in arr:
		if a >= x:
			ans += 1
			temp += a - x
		elif temp >= x - a:
			ans += 1
			temp -= x - a
	print(ans)


import math
import sys
import collections
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	ans = 1
	summ = 0
	cnt = 0
	for i in range(n):
		summ += arr[i]
		if summ // ans >= x:
			cnt += 1
			ans += 1
		else:
			break
	print(ans - 1)


def solve(A, limit):
	A.sort()
	wealth = 0
	wealthy = 0
	for i in range(len(A) - 1, -1, -1):
		wealth += A[i]
		if wealth / (wealthy + 1) < limit:
			return wealthy
		else:
			wealthy += 1
	return wealthy

def convertArrayToInt(A):
	for i in range(0, len(A), 1):
		A[i] = int(A[i])
	return A
testCases = int(input())
while testCases:
	X = input().split()
	X = convertArrayToInt(X)
	people = X[0]
	limit = X[1]
	X = input().split()
	A = convertArrayToInt(X)
	maxWealthy = solve(A, limit)
	print(maxWealthy)
	testCases -= 1


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	t = sum(a)
	i = 0
	while n > 0:
		if t // n >= x:
			ans = n
			break
		n -= 1
		t -= a[i]
		i += 1
	else:
		print(0)
		continue
	print(ans)


t = int(input())
for _ in range(t):
	(m, l) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	sumi = 0
	for i in a:
		sumi += i
	flag = 0
	for i in range(m):
		if sumi / m >= l:
			print(m)
			flag = 1
			break
		else:
			m -= 1
			sumi -= a[i]
	if flag == 0:
		print(0)


t = int(input())
for wer in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a = a[::-1]
	sum = [0] * n
	s = 0
	for i in range(n):
		sum[i] = a[i] + s
		s += a[i]
	for i in range(n):
		if sum[i] / (i + 1) < x:
			break
	else:
		i += 1
	print(i)


num_inp = lambda : int(input())
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()
I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, x) = I()
	w = sorted(I())
	an = n
	s = sum(w)
	for i in range(n):
		if x <= s / an:
			break
		an -= 1
		s -= w[i]
	print(an)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	p = 0
	m = x
	l = 0
	for i in sorted(list(map(int, input().split())), reverse=True):
		p += i
		if p < m:
			break
		else:
			l += 1
			m += x
	print(l)


import math
import sys
t = int(input())
for _ in range(t):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	s = 0
	ans = N
	for i in range(0, N):
		s += A[i]
		if s < K * (i + 1):
			ans = i
			break
	print(ans)


T = int(input())
for tt in range(T):
	(n, x) = [int(i) for i in input().split()]
	lst = [int(i) - x for i in input().split()]
	lst.sort(key=lambda x: -x)
	s = 0
	m = 0
	for i in range(n):
		if s + lst[i] >= 0:
			s += lst[i]
			m += 1
		else:
			break
	print(m)


n = int(input())
for _ in range(n):
	(cnt, cap) = map(int, input().split())
	arr = sorted(map(int, input().split()), reverse=True)
	total = 0
	for i in range(cnt):
		total += arr[i]
		if total // (i + 1) < cap:
			print(i)
			break
	else:
		print(cnt)


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().strip().split())
		arr = list(map(int, input().strip().split()))
		arr.sort(reverse=True)
		s = 0
		count = 0
		for i in range(0, n):
			s += arr[i]
			if s / (i + 1) >= k:
				count += 1
			else:
				break
		print(count)
main()


from sys import stdin, stdout
t = int(stdin.readline())
while t > 0:
	(n, x) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	(w, nw) = ([], [])
	for i in range(n):
		if a[i] >= x:
			w.append(a[i])
		else:
			nw.append(a[i])
	a = sorted(a)
	s = 0
	c = 0
	for i in range(n - 1, -1, -1):
		s += a[i]
		if s / (n - i) < x:
			break
		c += 1
	stdout.write('{}\n'.format(c))
	t -= 1


a = int(input())
for _ in range(a):
	g = 0
	(n, x) = map(int, input().split())
	z = 0
	v = 0
	b = 0
	ary = sorted(list(map(int, input().split())))
	for i in range(n - 1, -1, -1):
		z += ary[i]
		v += 1
		if z // x >= v:
			b += 1
		else:
			break
	print(b)


import bisect, collections, heapq

def solution():
	(n, xVal) = [int(x) for x in input().strip().split()]
	a = [int(x) for x in input().strip().split()]
	curSum = sum(a)
	heapq.heapify(a)
	while a and curSum / len(a) < xVal:
		curSum -= heapq.heappop(a)
	print(len(a))

def main():
	T = int(input().strip())
	for _ in range(T):
		solution()

def __starting_point():
	main()
__starting_point()


t = int(input())
for _ in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	a.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += a[i]
		y = s / (i + 1)
		if y < x:
			break
		else:
			ans = i + 1
	print(ans)


import sys
input = sys.stdin.readline
T = int(input())
for ti in range(1, T + 1):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	res = sm = 0
	for i in range(n):
		sm += a[i]
		if sm >= x * (i + 1):
			res += 1
	print(res)


import math
import sys
import itertools
import itertools

def sa(Type=int):
	return [Type(x) for x in input().split()]

def solve(t):
	(n, r) = sa()
	arr = sa()
	arr.sort(reverse=True)
	cc = 1 if arr[0] >= r else 0
	acc = arr[0]
	average = 0
	for (i, x) in enumerate(itertools.islice(arr, 1, len(arr))):
		acc += x
		average = acc / (i + 2)
		if average >= r:
			cc += 1
		else:
			break
	print(cc)
t = int(input())
for i in range(t):
	solve(i + 1)


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

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

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

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def myceil(x, y):
	return (x + y - 1) // y

def Solution(arr, n, x):
	s = 0
	arr = sorted(arr)
	ans = 1
	for i in range(n - 1, -1, -1):
		if (s + arr[i]) // ans >= x:
			ans += 1
			s += arr[i]
	print(ans - 1)

def main():
	for _ in range(get_int()):
		(n, x) = get_ints_in_variables()
		arr = get_ints_in_list()
		Solution(arr, n, x)
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	s = a[0]
	i = 1
	while i < n and (s + a[i]) / (i + 1) >= x:
		s += a[i]
		i += 1
	print(i if s >= x else 0)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	list1 = [int(x) for x in input().split()]
	list1.sort()
	list1.reverse()
	wealthyCount = 0
	sumBurles = 0
	for i in range(len(list1)):
		sumBurles += list1[i]
		if sumBurles / (i + 1) >= x:
			wealthyCount += 1
		else:
			break
	print(wealthyCount)


inp = input()
for i in range(int(inp)):
	x = input()
	(n, x) = map(int, x.split())
	y = input()
	arr = list(map(int, y.split()))
	arr = sorted(arr, reverse=True)
	ans = 0
	cnt = 0
	sum = 0
	for item in arr:
		cnt = cnt + 1
		sum = sum + item
		if sum / cnt >= x:
			ans = cnt
		else:
			break
	print(ans)


import math
from collections import Counter
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()

def s(a):
	print(' '.join(list(map(str, a))))
for i in range(I()):
	(n, x) = M()
	a = L()
	r = 0
	b = 0
	a.sort(reverse=True)
	for i in range(n):
		if (r + a[i]) / (i + 1) >= x:
			r += a[i]
			b += 1
		else:
			break
	print(b)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	printed = 0
	suma = sum(arr)
	for i in range(n):
		avg = suma // (n - i)
		if avg >= x:
			print(n - i)
			printed += 1
			break
		suma -= arr[i]
	if printed == 0:
		print(0)


t = int(input())
for tt in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	count = 0
	s = 0
	l.sort(reverse=True)
	index = 1
	for i in range(n):
		s += l[i]
		if s / index >= x:
			count += 1
		index += 1
	print(count)


t = int(input())
for l in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = n
	sum = 0
	for i in range(n - 1, -1, -1):
		sum += arr[i]
		avg = sum / (n - i)
		if avg < x:
			ans = n - i - 1
			break
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	L = list(map(int, input().split()))
	L.sort()
	S = 0
	c = 0
	for i in range(n):
		if L[i] >= x:
			c += 1
			S += L[i] - x
	for i in range(n - 1, -1, -1):
		if L[i] < x:
			if x - L[i] <= S and S > 0:
				S -= x - L[i]
				c += 1
	print(c)


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	S = list(map(int, input().split()))
	S.sort()
	S = S[::-1]
	count = 0
	reserve = 0
	for elt in S:
		if elt >= x:
			count += 1
			reserve += elt - x
		else:
			diff = x - elt
			if reserve >= diff:
				count += 1
				reserve -= diff
	print(count)


import sys
input = sys.stdin.readline
import heapq
import copy

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def main():
	tests = inp()
	mod = 1000000007
	for test in range(tests):
		[n, x] = inlt()
		a = inlt()
		a.sort(reverse=True)
		saved = 0
		sums = 0
		for i in range(0, n):
			sums = sums + a[i]
			if sums / (i + 1) < x:
				break
			else:
				saved += 1
		print(saved)
	return 0
main()


for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	arr = sorted(arr, reverse=True)
	count = 0
	extra = 0
	for i in arr:
		if i >= x:
			extra += i - x
			count += 1
		elif extra + i >= x:
			extra = extra - (x - i)
			count += 1
		else:
			break
	print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	money = list(map(int, input().split()))
	rich = 0
	rsum = 0
	poor = 0
	pm = []
	for i in range(n):
		if money[i] < x:
			poor += 1
			pm.append(money[i])
		else:
			rich += 1
			rsum += money[i]
	avail = rsum - rich * x
	people = rich
	pm.sort(reverse=True)
	for i in range(len(pm)):
		needed = x - pm[i]
		if needed <= avail:
			people += 1
			avail -= needed
	print(people)


def add(*args):
	sum = 0
	for i in range(len(args)):
		sum = sum + args[i]
	return sum
for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = a.copy()
	b.sort()
	i = 0
	sum = add(*b)
	while i <= len(b) - 1:
		if sum / (len(b) - i) >= x:
			break
		else:
			sum = sum - b[i]
			i += 1
	print(len(b) - i)


t = int(input())
for _ in range(t):
	(n, x) = [int(t) for t in input().split()]
	l = [int(t) for t in input().split()]
	l.sort(reverse=True)
	total = 0
	count = 0
	for (i, num) in enumerate(l):
		total += num
		if total / (i + 1) >= x:
			count += 1
		else:
			break
	print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	arr.reverse()
	s = 0
	c = 0
	for e in arr:
		s += e
		c += 1
		if s / c < x:
			break
	if s / c < x:
		print(c - 1)
	else:
		print(c)


t = int(input())
for i in range(t):
	(a, b) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	arr.sort(reverse=True)
	avg = []
	sm = 0
	for i in range(len(arr)):
		sm += arr[i]
		avg.append(sm / (i + 1))
	ans = 0
	for i in range(len(avg)):
		if avg[i] >= b:
			ans = i
	if ans == 0:
		if avg[0] < b:
			print(0)
		else:
			print(ans + 1)
	else:
		print(ans + 1)


def fun(arr, n, x):
	count = 0
	s = sum(arr)
	an = n
	for i in sorted(arr):
		if x <= s / an:
			break
		an -= 1
		s -= i
	print(an)
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	fun(arr, n, x)


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	temp = 0
	cnt = 0
	for i in l:
		if temp + (i - x) >= 0:
			temp += i - x
			cnt += 1
		else:
			print(cnt)
			break
	else:
		print(cnt)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	sum = 0
	count = 0
	for j in range(n):
		if l[j] - x >= 0:
			sum += l[j] - x
			count += 1
		else:
			sum += l[j] - x
			if sum < 0:
				break
			else:
				count += 1
	print(count)


t = int(input())
for y in range(t):
	(n, s) = list(map(int, input().split()))
	p = list(map(int, input().split()))
	t = sorted(p)[::-1]
	sum = 0
	k = 0
	al = 0
	f = False
	for a in range(n):
		sum += t[a]
		k += 1
		if sum / k >= s:
			al += 1
		if sum / k < s or a == n - 1:
			print(al)
			break


t = int(input())
for i in range(t):
	(n, x) = map(int, input().strip().split(' '))
	lst = list(map(int, input().strip().split(' ')))
	lst2 = []
	for j in range(n):
		lst[j] = lst[j] - x
	lst.sort(reverse=True)
	s = 0
	j = 0
	if lst[0] < 0:
		print('0')
	else:
		while s >= 0 and j < n:
			s = s + lst[j]
			j += 1
		if j == n and s >= 0:
			print(n)
		else:
			print(j - 1)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	cs = 0
	a.sort(reverse=True)
	for i in range(n):
		cs += a[i]
		if cs // (i + 1) < x:
			print(i)
			return
	print(n)
q = int(input())
while q:
	solve()
	q = q - 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	lst = [i for i in map(int, input().split())]
	lst.sort(reverse=True)
	s = 0
	ans = -1
	for i in range(len(lst)):
		s += lst[i]
		if s / (i + 1) < x:
			ans = i
			break
	if ans == -1:
		print(len(lst))
	else:
		print(ans)


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l, x):
	n = len(l)
	l = sorted(l)
	pre = [0] + list(accumulate(l))
	maxx = 0
	for i in range(1, n + 1):
		curr = pre[-1] - pre[i - 1]
		size = n - i + 1
		if curr // size >= x:
			maxx = max(maxx, size)
	return maxx
T = int(input())
for _ in range(T):
	(N, X) = list(map(int, stdin.readline().rstrip().split()))
	l = list(map(int, stdin.readline().rstrip().split()))
	print(solve(l, X))


n = int(input())
while n > 0:
	p = list(map(int, input().split()))
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	(sum, person, ans) = (0, 0, 0)
	for i in range(p[0]):
		person += 1
		sum += l[i]
		if sum >= p[1] * person:
			ans = max(ans, person)
	print(ans)
	n -= 1


from sys import stdin, stdout
import math
T = int(stdin.readline().rstrip())
for iTest in range(T):
	(n, x) = list(map(int, stdin.readline().rstrip().split(' ')))
	a = list(map(int, stdin.readline().rstrip().split(' ')))
	a.sort(reverse=True)
	possible = True
	currentSum = 0
	i = 0
	while possible and i < n:
		currentSum += a[i]
		if currentSum // (i + 1) >= x:
			i += 1
		else:
			possible = False
	print(i)


def solve(n, x, initSavings):
	wealthy = []
	poor = []
	for s in initSavings:
		if s >= x:
			wealthy.append(s)
		else:
			poor.append(s)
	poor.sort(reverse=True)
	sumW = sum(wealthy)
	numW = len(wealthy)
	for p in poor:
		newSumW = sumW + p
		newNumW = numW + 1
		if newSumW / newNumW < x:
			break
		else:
			sumW = newSumW
			numW = newNumW
	return numW
numTest = int(input())
for t in range(numTest):
	(n, x) = map(int, input().split())
	initSavings = list(map(int, input().split()))
	print(solve(n, x, initSavings))


t = int(input())
for tt in range(t):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	lis = input().split()
	for i in range(n):
		lis[i] = int(lis[i])
	lis.sort()
	ind = -1
	for i in range(n):
		if lis[i] >= x:
			ind = i
			break
	if ind == -1:
		print(0)
	else:
		dist = 0
		for i in range(ind, n):
			dist += lis[i] - x
		ans = n - ind
		for i in range(ind - 1, -1, -1):
			if x - lis[i] <= dist:
				ans += 1
				dist -= x - lis[i]
			else:
				break
		print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))[::-1]
	s = 0
	count = 0
	temp = x
	for i in range(n):
		s += a[i]
		if s >= temp:
			count += 1
		else:
			break
		temp += x
	print(count)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += a[i]
		if s >= x * (i + 1):
			ans = i + 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	if sum(a) / n >= k:
		print(n)
	else:
		a.sort()
		c = 0
		s1 = sum(a)
		s2 = a[0]
		c = 1
		for i in range(1, n):
			if (s1 - s2) / (n - c) >= k:
				break
			else:
				s2 += a[i]
				c += 1
		print(n - c)


t = int(input())
for test in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += arr[i]
		if s >= (i + 1) * x:
			ans = max(ans, i + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	c = 0
	for i in range(n):
		j = i + 1
		s = s + a[i]
		avg = s / j
		if avg >= x:
			c = c + 1
	print(c)


t = int(input())
while t > 0:
	(n, x) = list(map(int, input().split(' ')))
	savings = list(map(int, input().split(' ')))
	savings.sort()
	savings.reverse()
	numbers = 0
	suma = 0
	for nums in savings:
		numbers += 1
		suma += nums
		if suma / numbers < x:
			numbers -= 1
			break
	print(numbers)
	t -= 1


I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, x) = I()
	l = I()
	l.sort()
	l = l[::-1]
	for i in range(1, n):
		l[i] += l[i - 1]
	c = 0
	for i in range(n):
		if l[i] < x * (i + 1):
			break
		c += 1
	print(c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	extra = 0
	count = 0
	req = []
	r = []
	pre = 0
	for i in range(n):
		if a[i] - x >= 0:
			extra += a[i] - x
			pre += 1
		else:
			req.append(x - a[i])
	req = sorted(req)
	for i in req:
		extra -= i
		if extra >= 0:
			count += 1
	ans = pre + count
	print(ans)


import sys
import math
import bisect

def solve(A, x):
	n = len(A)
	B = []
	C = []
	for a in A:
		if a >= x:
			B.append(a)
		else:
			C.append(a)
	val = sum(B) - len(B) * x
	C.sort(reverse=True)
	for c in C:
		delta = x - c
		if delta <= val:
			val -= delta
			B.append(c)
	return len(B)

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		A = list(map(int, input().split()))
		print(solve(A, m))
main()


t = int(input())
for i in range(t):
	small_count = 0
	(n, x) = (int(z) for z in input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	count = sum((i >= x for i in l))
	big = l[:count]
	big = [p - x for p in big]
	g = sum(big)
	small = l[count:]
	for index in range(len(small)):
		if small[index] < x and g >= x - small[index]:
			small_count += 1
			g = g - (x - small[index])
	print(count + small_count)


T = int(input())
M = []
for i in range(T):
	a = input()
	a_l = a.split()
	x = int(a_l[1])
	num = input()
	n_lst = num.split()
	List = [int(d) for d in n_lst]
	List.sort(key=int, reverse=True)
	sum = 0
	average = 0
	beyond = 0
	for j in range(len(List)):
		sum = sum + List[j]
		average = sum / (j + 1)
		if average >= x:
			beyond = j + 1
	M.append(beyond)
for p in M:
	print(p)


cases = int(input())
for _ in range(cases):
	(n, x) = map(int, input().split())
	c = sorted(list(map(int, input().split())))[::-1]
	count = 0
	index = 1
	tot = 0
	for i in range(n):
		tot += c[i]
		if tot / index >= x:
			count += 1
		index += 1
	print(count)


def solve():
	(n, p) = map(int, input().split())
	v = [int(x) for x in input().split()]
	v = sorted(v)
	sum = 0
	for x in v:
		sum += x
	for i in range(n):
		if sum // (n - i) >= p:
			print(n - i)
			return
		else:
			sum -= v[i]
	print(0)
for _ in range(int(input())):
	solve()


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for t in range(ii()):
	(n, k) = mi()
	arr = list(mi())
	arr = sorted(arr, reverse=True)
	if arr[0] < k:
		print(0)
	else:
		sum_ = arr[0]
		cnt = 1
		for i in range(1, n):
			sum_ += arr[i]
			if sum_ // (i + 1) < k:
				break
			cnt += 1
		print(cnt)


import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__

def go():
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	s = 0
	for (i, aa) in enumerate(a, 1):
		s += aa
		if i * x > s:
			return i - 1
	return n
t = int(input())
ans = []
for _ in range(t):
	ans.append(str(go()))
print('\n'.join(ans))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = k = 0
	a = 0
	for i in range(n):
		if l[i] < m:
			break
		s += l[i] - m
		a = i
		k += 1
	for i in range(a + 1, n):
		if l[i] + s >= m:
			s -= m - l[i]
			k += 1
	print(k)


for tc in range(int(input())):
	(n, x) = input().split(' ')
	(n, x) = (int(n), int(x))
	A = input().split(' ')
	for i in range(n):
		A[i] = int(A[i])
	A.sort(reverse=True)
	s = A[0]
	index = 0
	if s < x:
		print(0)
	else:
		while s / (index + 1) >= x and index < n - 1:
			index += 1
			s += A[index]
		if index == n - 1 and s / n >= x:
			print(n)
		else:
			print(index)


from heapq import heapify, heappop
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	heapify(arr)
	curr_sum = sum(arr)
	done = False
	while not done and n > 0:
		if curr_sum / n >= x:
			done = True
		else:
			curr_sum -= heappop(arr)
			n -= 1
	print(n)


from itertools import accumulate
for tin in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = list(accumulate(a))
	b = [0] + b
	k = 0
	for _ in range(len(b)):
		if b[-1] - b[_] >= m * (len(b) - 1 - _):
			print(len(b) - 1 - _)
			k = 1
			break
	if k == 0:
		print(0)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	savings = list(map(int, input().split()))
	ans = 0
	savings.sort(reverse=True)
	for i in range(n):
		ans += savings[i]
		if ans < x * (i + 1):
			print(i)
			break
		elif i == n - 1:
			print(n)


from sys import stdin

def solve(n, x, a):
	a.sort(reverse=True)
	sm = 0
	ans = 0
	for i in range(n):
		sm += a[i]
		if sm / (i + 1) >= x:
			ans += 1
	print(ans)

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		h = inp().split()
		n = int(h[0])
		x = float(h[1])
		a = list(map(int, inp().split()))
		solve(n, x, a)
main()


from collections import Counter
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = [int(s) for s in input().split()]
	a.sort(reverse=True)
	total = 0
	mean = 0
	for (i, r) in enumerate(a):
		total += r
		mean = total / (i + 1)
		if mean < x:
			print(i)
			break
	else:
		print(n)


def soln(a, x):
	a = sorted(a, reverse=True)
	prefixSums = [0]
	for num in a:
		prefixSums.append(prefixSums[-1] + num)
	for subArrLen in range(len(a), 0, -1):
		if subArrLen == 0:
			continue
		avg = prefixSums[subArrLen] / subArrLen
		if avg >= x:
			return subArrLen
	return 0

def main():
	T = int(input())
	for _ in range(T):
		(n, x) = [int(i) for i in input().split(' ')]
		a = [int(i) for i in input().split(' ')]
		print(soln(a, x))
main()


from sys import stdin, stdout

def read():
	x0 = stdin.readline().rstrip()
	return x0

def __main__():
	t = int(read())
	for t0 in range(t):
		(n, x) = map(int, read().split())
		a = [int(a0) for a0 in read().split()]
		bminus = [i - x for i in a if i - x < 0]
		bplus = [i - x for i in a if i - x > 0]
		res = sum(bplus) + sum(bminus)
		if res < 0:
			bminus.sort()
			for m in bminus:
				res -= m
				n -= 1
				if res >= 0:
					break
		out = str(n) + '\n'
		stdout.write(out)
__main__()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	limit = 0
	a = sorted(a, reverse=True)
	i = 0
	current = 0
	for c in a:
		if c + current >= limit + x:
			current += c
			limit += x
			i += 1
		else:
			break
	print(i)


import sys
from collections import Counter
input = sys.stdin.readline
from functools import lru_cache
import bisect

def solve():
	(n, x) = map(int, input().split(' '))
	arr = list(map(int, input().split(' ')))
	arr.sort(reverse=True)
	cum = 0
	num = 0
	for e in arr:
		if (cum + e) / (num + 1) >= x:
			cum += e
			num += 1
	print(num)
	return
t = int(input())
for _ in range(t):
	solve()


for i in range(int(input())):
	m = 0
	(n, x) = map(int, input().split())
	po = list(map(int, input().split()))
	su = sum(po)
	if su / n >= x:
		m = n
	else:
		po.sort()
		s = 0
		e = len(po) - 1
		while s < e:
			if su / (e + 1 - s) >= x:
				m += e - s + 1
				break
			else:
				su -= po[s]
				s += 1
		if s == e and po[s] >= x:
			m += 1
	print(m)


def solve(ans):
	(n, x) = [int(x) for x in input().split()]
	li = [int(x) for x in input().split()]
	li.sort()
	(sum1, count, rich) = (0, 0, 0)
	for i in range(n - 1, -1, -1):
		sum1 += li[i]
		count += 1
		if sum1 / count >= x:
			rich += 1
		else:
			break
	ans.append(rich)
	return
n = int(input())
ans = []
for i in range(n):
	solve(ans)
for ele in ans:
	print(ele)


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, x) = R()
	i = s = 0
	for y in sorted(R())[::-1]:
		s += y
		if s < i * x + x:
			break
		i += 1
	print(i)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))[::-1]
	sobras = 0
	ricos = 0
	for j in range(n):
		if a[j] >= x:
			sobras += a[j] - x
			ricos += 1
		elif a[j] + sobras >= x:
			ricos += 1
			sobras -= x - a[j]
		else:
			break
	print(ricos)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	tot = 0
	ct = 0
	for v in a:
		ct += 1
		tot += v
		if tot < ct * x:
			ct -= 1
			break
	print(ct)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if a[0] < x:
		print(0)
		continue
	m = sum(a)
	if m / n >= x:
		print(n)
		continue
	else:
		for i in range(n - 1, 0, -1):
			m -= a[i]
			if m / i >= x:
				print(i)
				break


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	m = list(map(int, input().split()))
	m.sort()
	if m[n - 1] < x:
		print(0)
	else:
		w = 1
		s = m[n - 1]
		for j in range(n - 2, -1, -1):
			if s + m[j] >= (w + 1) * x:
				w += 1
				s += m[j]
			else:
				break
		print(w)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	total = 0
	for i in range(n):
		total += l[i]
		if total / (i + 1) < x:
			print(i)
			break
	else:
		print(n)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()))
	(s, c) = (sum(a), 0)
	for i in a:
		if s >= x * n:
			break
		(s, n) = (s - i, n - 1)
	print(n)


T = int(input())

def sol(n, x, ass):
	ass = sorted(ass)
	s = sum(ass)
	partials = [s]
	for i in range(n):
		p = partials[-1]
		if (n - i) * x <= p:
			return n - i
		partials.append(p - ass[i])
	return 0

def solve():
	(n, x) = map(int, input().split(' '))
	ass = [int(x) for x in input().split(' ')]
	print(sol(n, x, ass))
for i in range(T):
	solve()


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	for i in range(int(input())):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		a.sort(reverse=True)
		b = sum(a)
		c = 0
		d = n
		for i in range(n):
			if b // d >= x:
				c = len(a)
				break
			else:
				b = b - a[-1]
				a.pop()
				d = d - 1
		print(c)
main()


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a.sort(reverse=True)
	t = counter = 0
	for i in range(n):
		t += a[i]
		if t / (counter + 1) >= x:
			counter += 1
		else:
			break
	print(str(counter) + '\n')


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	ai = [0] + list(map(int, input().split()))
	ai.sort()
	summ = sum(ai)
	ans = 0
	for i in range(n + 1):
		summ -= ai[i]
		if summ >= x * (n - i):
			ans = n - i
			break
	print(ans)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	(cnt, res) = (0, 0)
	l = []
	for i in a:
		if i > x:
			res += i - x
			cnt += 1
		else:
			l.append(x - i)
	l.sort()
	for i in l:
		if res < i:
			break
		res -= i
		cnt += 1
	print(cnt)


T = int(input())
for _ in range(T):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a = sorted(a)[::-1]
	ans = 0
	s = 0
	for i in range(n):
		s += a[i]
		if s / (i + 1.0) < x:
			break
		else:
			ans += 1
	print(ans)


def RA():
	l = input().split()
	return [int(s) for s in l]

def solve():
	[n, x] = RA()
	arr = RA()
	arr.sort(reverse=True)
	count = 0
	fail = False
	s = 0
	for i in range(n):
		count += 1
		s += arr[i]
		if s < x * count:
			fail = True
			break
	if fail:
		print(count - 1)
	else:
		print(n)
t = int(input())
while t > 0:
	solve()
	t -= 1


def solve(nums, n, k):
	nums.sort()
	total = sum(nums)
	if total / n >= k:
		return n
	for num in nums:
		total -= num
		n -= 1
		if n != 0 and total / n >= k:
			return n
	return 0
m = int(input())
for _ in range(m):
	(n, k) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	print(solve(nums, n, k))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(j) - k for j in input().split()][:n]
	l.sort()
	c = 0
	s = 0
	for j in range(n - 1, -1, -1):
		if s + l[j] < 0:
			break
		else:
			s = s + l[j]
			c = c + 1
	print(c)


import sys

def Q1():
	T = int(sys.stdin.readline())
	for i in range(T):
		[n, x] = [int(j) for j in sys.stdin.readline().split()]
		a = [int(j) for j in sys.stdin.readline().split()][0:n]
		a.sort(reverse=True)
		sum = 0
		res = 1
		for j in a:
			sum += j
			if sum < x * res:
				break
			res += 1
		print(res - 1)
Q1()


def main():
	for _ in inputt():
		(n, x) = inputi()
		A = inputl()
		A.sort(reverse=True)
		s = 0
		i = 0
		for a in A:
			s += a - x
			if s < 0:
				break
			i += 1
		print(i)
import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	for x in args:
		file.write(str(x))
	file.write(kwargs.pop('end', '\n'))
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inputt = lambda t=0: range(t) if t else range(int(input()))
inputi = lambda : map(int, input().split())
inputl = lambda : list(inputi())
from math import *
from heapq import *
from bisect import *
from itertools import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
import re, copy, operator, cmath
from builtins import *
main()


t = int(input())
for test in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	sum = 0
	for i in range(n - 1, -1, -1):
		a[i] += sum
		sum = a[i]
	ans = 0
	for i in range(n):
		if a[i] / (n - i) >= x:
			ans = n - i
			break
	print(ans)


from math import inf, sqrt, floor, ceil
from collections import Counter, defaultdict, deque
from heapq import heappush as hpush, heappop as hpop, heapify as h
from operator import itemgetter
from itertools import product
from bisect import bisect_left, bisect_right
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	m = 0
	s = 0
	p = 0
	for i in range(n - 1, -1, -1):
		if (s + a[i]) / (p + 1) >= k:
			s += a[i]
			p += 1
		else:
			m += p
			s = 0
			p = 0
	m += p
	print(m)


from sys import stdin, stdout
T = int(stdin.readline())
for i in range(T):
	[n, x] = [int(y) for y in stdin.readline().split()]
	a = [int(y) for y in stdin.readline().split()]
	a.sort(reverse=True)
	res = 0
	summ = 0
	for ai in a:
		summ += ai
		if summ / (res + 1) < x:
			break
		res += 1
	stdout.write(str(res) + '\n')


import sys
readline = sys.stdin.readline
flush = sys.stdout.flush
T = int(readline())
for t in range(1, T + 1):
	line = readline().split()
	(n, x) = (int(line[0]), int(line[1]))
	values = [int(a) for a in readline().split()]
	values.sort(reverse=True)
	score = 0
	min_score = 0
	ans = n
	for i in range(len(values)):
		score += values[i]
		min_score += x
		if score < min_score:
			ans = i
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	total = 0
	index = -1
	cash = 0
	cash1 = 0
	for i in range(n):
		if a[i] > x:
			total += a[i]
			cash += 1
		if a[i] < x:
			index = i
		if a[i] == x:
			cash1 += 1
	total = total - x * cash
	count = cash + cash1
	if index != -1:
		for i in range(index, -1, -1):
			if x - a[i] <= total:
				count += 1
				total -= x - a[i]
			else:
				break
	print(count)


for i in range(int(input())):
	(n, m) = [int(s) for s in input().split()]
	arr = [int(s) for s in input().split()]
	arr = sorted(arr)
	arr = arr[::-1]
	pref = [arr[0]] * n
	for i in range(1, n):
		pref[i] = pref[i - 1] + arr[i]
	(l, r) = (0, n + 1)
	while l != r - 1:
		med = (l + r) // 2
		if pref[med - 1] >= m * med:
			l = med
		else:
			r = med
	print(l)


from collections import defaultdict, Counter
import math as m
import heapq
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().strip().split())
	ls = list(map(int, input().strip().split()))
	ls = [-x for x in ls]
	heapq.heapify(ls)
	ans = 0
	prevsu = -1
	while True:
		su = 0
		c = 0
		ind = 0
		item_ls = []
		while ind < n:
			ind += 1
			item = abs(heapq.heappop(ls))
			if su + item < (c + 1) * x:
				heapq.heappush(ls, item)
				break
			item_ls.append(item)
			su += item
			c += 1
		if c == n:
			ans = n
			break
		elif c > 0 and su > prevsu:
			prevsu = su
			items = -(su / c)
			while c > 0:
				heapq.heappush(ls, items)
				c -= 1
		else:
			for val in item_ls:
				heapq.heappush(ls, val)
			break
	if ans == 0:
		for val in ls:
			if abs(val) >= x:
				ans += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	l.sort()
	su = sum(l)
	a = n
	for i in l:
		if su // a >= k:
			break
		a = a - 1
		su -= i
	print(a)


t = int(input())
out = ''
while t > 0:
	t -= 1
	(n, x) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	total = s = count = 0
	get_up = []
	for i in range(n):
		if a[i] >= x:
			total += 1
			count += 1
			s += a[i]
		else:
			get_up.append(a[i])
	s -= count * x
	get_up.sort(reverse=True)
	for no in get_up:
		if x - no <= s:
			total += 1
			s -= x - no
			continue
		break
	out += f'{total}\n'
print(out)


def Find(data, x):
	temp_data = [i - x for i in data]
	temp_data.sort()
	i = 0
	while i < len(temp_data) and temp_data[i] < 0:
		i += 1
	if i == len(temp_data):
		return 0
	if i == 0:
		return len(temp_data)
	j = i - 1
	present = temp_data[i]
	count = len(temp_data) - i
	i += 1
	while j >= 0 and i <= len(data):
		if temp_data[j] + present >= 0:
			present += temp_data[j]
			j -= 1
			count += 1
		elif i < len(temp_data):
			present += temp_data[i]
			i += 1
		else:
			i += 1
	return count

def main():
	t = int(input())
	while t > 0:
		t -= 1
		(n, x) = map(int, input().split())
		data = list(map(int, input().split()))
		print(Find(data, x))
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	r_sum = 0
	state = True
	for (i, num) in enumerate(a):
		r_sum += num
		if r_sum / (i + 1) < x:
			print(i)
			state = False
			break
	if state == True:
		print(n)


for _ in range(int(input())):
	(n, k) = [int(a) for a in input().split()]
	ar = list(map(int, input().split()))[:n]
	ar.sort(reverse=True)
	s = 0
	p = 0
	for i in range(n):
		if ar[i] < k:
			t = s + ar[i]
			if t // (i + 1) >= k:
				s = s + ar[i]
			else:
				p = 1
				break
		else:
			s = s + ar[i]
	if s == 0:
		print(0)
	elif p == 1:
		print(i)
	else:
		print(n)


R = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	[n, x] = R()
	l = sorted(R(), reverse=True)
	a = sum(l)
	while a < n * x:
		n -= 1
		a -= l[n]
	print(n)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a.reverse()
	s = 0
	flag = 0
	for j in range(len(a)):
		s += a[j]
		if s / (j + 1) < m:
			print(j)
			break
	else:
		print(len(a))


t = int(input())
for _ in range(t):
	e = False
	(n, x) = map(int, input().split())
	nl = list(map(int, input().split()))
	nl.sort(reverse=True)
	ans = 0
	i = 0
	while i < n:
		ans += nl[i]
		if ans / (i + 1) >= x:
			i += 1
		else:
			break
	print(i)


t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	cur = 0
	for i in range(n):
		cur += a[i]
		if cur / (ans + 1) >= x:
			ans += 1
		else:
			break
	print(ans)


for v in range(int(input())):
	(n, x) = map(int, input().split())
	y = [int(q) for q in input().split()]
	l = sorted(y)
	l = l[::-1]
	k = 0
	s = 0
	ans = 0
	for i in range(n):
		s += x
		k += l[i]
		if k >= s:
			ans += 1
		else:
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	val = 0
	cc = 0
	fres = -1
	tc = 0
	for xx in a:
		val += xx
		cc += 1
		if val >= cc * x:
			fres = val / cc
			tc = cc
	farr = [fres] * tc + a[tc:]
	count = 0
	for xxx in farr:
		if xxx >= x:
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	arr.sort()
	summ = sum(arr)
	index = 0
	count = n
	while count > 0 and int(summ / count) < x and (index < n):
		summ -= arr[index]
		index += 1
		count -= 1
	print(count)


from math import *
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	c = 0
	s = 0
	for i in range(n):
		if l[i] >= x:
			k = l[i] - x
			c = c + 1
			s = s + k
		else:
			k = l[i] - x
			s = s + k
			if s >= 0:
				c = c + 1
			else:
				break
	print(c)


t = int(input(''))
for i in range(t):
	(x, y) = map(int, input('').split())
	ar = list(map(int, input('').split()))
	ar.sort()
	ar.reverse()
	count = 0
	sum = 0
	final = 0
	for i in range(0, len(ar)):
		sum = sum + ar[i]
		avg = sum / (i + 1)
		if avg >= y:
			final = i + 1
	print(final)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	excess = 0
	defecit = []
	count = 0
	for i in range(n):
		if a[i] > x:
			excess += a[i] - x
			count += 1
		else:
			defecit.append(x - a[i])
	defecit = sorted(defecit)
	i = 0
	while i < len(defecit) and excess >= defecit[i]:
		count += 1
		excess -= defecit[i]
		i += 1
	print(count)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = [int(i) for i in input().split()]
	d = sorted(c)[-1::-1]
	e = 0
	f = 0
	for j in d:
		e = e + j
		f += 1
		if e / f < b:
			t = f - 1
			break
	if e / a >= b:
		print(a)
	else:
		print(t)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	sum_cur = arr[0] - x
	i = 1
	while i < n and sum_cur >= 0:
		sum_cur += arr[i] - x
		i += 1
	if sum_cur < 0:
		i -= 1
	print(i)


for i in range(int(input())):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	temp = input().split()
	burles = [int(i) for i in temp]
	povert = []
	wealthy = []
	for i in burles:
		if i >= k:
			wealthy.append(i)
		else:
			povert.append(i)
	extra_money = 0
	for i in wealthy:
		extra_money += i - k
	povert.sort()
	count = 0
	length = len(povert)
	while extra_money > 0 and length > 0:
		element = povert.pop()
		if k - element <= extra_money:
			extra_money -= k - element
			count += 1
		else:
			extra_money = 0
		length -= 1
	print(count + len(wealthy))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	rem = 0
	ans = 0
	for i in range(n):
		if a[i] >= x:
			ans += 1
			rem += a[i] - x
		elif x - a[i] <= rem:
			ans += 1
			rem -= x - a[i]
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	d = s = 0
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	for i in range(n):
		s = s + l[i]
		if s / (i + 1) >= x:
			d += 1
	print(d)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	ex = 0
	ans = 0
	for i in range(n - 1, -1, -1):
		if l[i] > m:
			ex = ex + l[i] - m
			ans += 1
		elif l[i] < m and ex - (m - l[i]) >= 0:
			ex = ex - (m - l[i])
			ans += 1
		elif l[i] == m:
			ans += 1
		else:
			break
	print(ans)


t = int(input())
for i in range(t):
	n = list(map(int, input().split()))
	x = n[1]
	n = n[0]
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	count = 0
	sum = 0
	while count < n and sum + a[count] >= (count + 1) * x:
		sum += a[count]
		count += 1
	print(count)


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, x) = R()
	a = sorted(R())
	s = sum(a)
	while s < n * x:
		s -= a[-n]
		n -= 1
	print(n)


import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(N, X, A):
	A.sort()
	sa = [0]
	for a in A:
		sa.append(sa[-1] + a)
	ans = 0
	for i in range(N):
		if sa[-1] - sa[i] >= X * (N - i):
			ans = N - i
			break
	return ans

def main():
	T = read_int()
	for _ in range(T):
		(N, X) = read_int_n()
		A = read_int_n()
		print(slv(N, X, A))
main()


T = int(input())
for t in range(T):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	A.reverse()
	i = 0
	j = n - 1
	su = 0
	num = 0
	while su >= 0 and i < n:
		su += A[i] - x
		if su >= 0:
			num += 1
		i += 1
	print(num)


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	(n, t) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	big = []
	small = []
	ans = 0
	for i in range(n):
		if arr[i] - t >= 0:
			big.append(arr[i] - t)
			ans += 1
		else:
			small.append(t - arr[i])
	big.sort()
	small.sort()
	if big and small:
		pfb = [0] * len(big)
		pfs = [0] * len(small)
		pfb[0] = big[0]
		pfs[0] = small[0]
		for i in range(1, len(big)):
			pfb[i] = pfb[i - 1] + big[i]
		for i in range(1, len(small)):
			pfs[i] = pfs[i - 1] + small[i]
		i = 0
		j = 0
		while i < len(big) and j < len(small):
			if pfb[i] > pfs[j]:
				ans += 1
				j += 1
			elif pfb[i] < pfs[j]:
				i += 1
			else:
				ans += 1
				i += 1
				j += 1
	print(ans)


for u in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	ka = 0
	c = 0
	for i in range(n):
		ka = ka + l[i]
		x = ka // (i + 1)
		if x >= k:
			c = c + 1
		else:
			break
	print(c)


t = int(input())
while t:
	t = t - 1
	s = 0
	l = []
	(m, n) = list(map(int, input().split(' ')))
	lst = list(map(int, input().split(' ')))
	lst.sort(reverse=True)
	lst1 = [lst[0]]
	s = lst[0]
	for i in range(1, len(lst)):
		s = s + lst[i]
		a = s / (i + 1)
		lst1.append(a)
	c = 0
	for i in lst1:
		if i >= n:
			c = c + 1
	print(c)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left

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

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

def I():
	return int(stdin.readline())
P = 1000000007
for t in range(I()):
	(n, v) = In()
	lis = L()
	lis.sort(reverse=True)
	sm = 0
	if lis[0] < v:
		print(0)
	else:
		flag = n
		for i in range(n):
			if sm + lis[i] < v * (i + 1):
				flag = i
				break
			else:
				sm += lis[i]
		print(flag)


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	mass = [int(x) for x in input().split()]
	kol = 0
	otr = list()
	answer = 0
	for i in range(n):
		if mass[i] >= x:
			answer += 1
			kol += mass[i] - x
		else:
			otr.append(x - mass[i])
	otr.sort()
	for i in otr:
		if kol >= i:
			kol -= i
			answer += 1
		else:
			break
	if sum(mass) // n >= x:
		answer = n
	print(answer)


def _in():
	return [int(x) for x in input().split(' ')]
for _ in range(int(input())):
	(n, x) = _in()
	arr = _in()
	(arr1, cnt, ans) = ([], 0, 0)
	for i in arr:
		if i < x:
			arr1.append(i)
		else:
			cnt = cnt + i - x
			ans = ans + 1
	arr1.sort(reverse=True)
	for i in arr1:
		if cnt >= x - i:
			ans = ans + 1
			cnt = cnt - x + i
	print(ans)


R = lambda : map(int, input().split())
from collections import Counter

def count(arr, target):
	res = 0
	sum = 0
	for v in arr:
		if sum + v <= target:
			res += 1
			sum += v
	return res

def solver(n, arr, MAX):
	arr.sort()
	num_rich = []
	res = 0
	first_rich = -1
	for (i, money) in enumerate(arr):
		if money >= MAX:
			if first_rich == -1:
				first_rich = i
			res += 1
			num_rich.append(money - MAX)
	if res == 0:
		return res
	poors = arr[:first_rich]
	delta_rich = sum(num_rich)
	if not poors:
		return res
	poors = list(map(lambda x: MAX - x, poors))
	poors = poors[::-1]
	return count(poors, delta_rich) + res

def main():
	T = int(input())
	for t in range(1, T + 1):
		(n, MAX) = list(R())
		arr = list(R())
		print(solver(n, arr, MAX))
main()


def f():
	(n, x) = [int(s) for s in input().split()]
	A = [int(s) for s in input().split()]
	rem = 0
	lack = []
	for a in A:
		if a < x:
			lack.append(x - a)
		else:
			rem += a - x
	lack.sort()
	rich = n - len(lack)
	for l in lack:
		if l > rem:
			break
		rem -= l
		rich += 1
	return rich
for t in range(int(input())):
	print(f())


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	best = 0
	s = 0
	for i in range(n):
		s += l[i]
		if s >= x * (i + 1):
			best = i + 1
		else:
			break
	print(best)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = [int(x) for x in input().split()]
	l.sort()
	s = sum(l)
	i = 0
	while i < len(l):
		if s / n >= x:
			print(n)
			break
		s -= l[i]
		i += 1
		n -= 1
	else:
		print(0)


num = int(input())
for k in range(num):
	(n, s) = map(int, input().split())
	people = list(map(int, input().split()))
	ans = 0
	supr = 0
	people.sort(reverse=True)
	for item in people:
		if item > s:
			supr += item - s
			ans += 1
		elif item == s:
			ans += 1
		elif item < s:
			if s - item <= supr:
				ans += 1
				supr -= s - item
	print(ans)


testCases = int(input())
for _ in range(testCases):
	(n, x) = map(int, input().split())
	savings = sorted(map(int, input().split()))
	total = sum(savings)
	while total < n * x:
		total -= savings[-n]
		n -= 1
	print(n)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	s = sum(a)
	if s / n >= x:
		print(n)
	else:
		a.sort()
		a.reverse()
		h = s / n
		while h < x:
			s = s - a.pop()
			if len(a) == 0:
				break
			h = s / len(a)
		print(len(a))


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, X, A):
	A.sort(reverse=True)
	if A[0] < X:
		return 0
	total = A[0]
	count = 1
	for x in A[1:]:
		if total + x >= (count + 1) * X:
			total += x
			count += 1
	return count
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, X) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, X, A)
	print(ans)


t = int(input())
for test in range(t):
	(n, mx) = input().split()
	(n, mx) = (int(n), int(mx))
	arr = list(map(int, input().split()))
	arr.sort(reverse=False)
	count = 0
	sm = 0
	i = 0
	j = n - 1
	while i <= j:
		count += 1
		if (sm + arr[j]) / count >= mx:
			sm += arr[j]
			j -= 1
		elif (sm + arr[i]) / count >= mx:
			sm += arr[i]
			i += 1
		else:
			count -= 1
			break
	print(count)


def find(arr, x, n):
	l = sum(arr)
	while n > 0:
		if l / n >= x:
			return n
		l -= arr.pop()
		n -= 1
	return 0
t = int(input())
while t:
	inp1 = list(map(int, input().strip().split()))[:2]
	(n, x) = (inp1[0], inp1[1])
	arr = list(map(int, input().strip().split()))[:n]
	arr = sorted(arr, reverse=True)
	k = find(arr, x, n)
	print(k)
	t -= 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) / n >= x:
		print(n)
		continue
	a = sorted(a)
	if a[n - 1] < x:
		print(0)
		continue
	i = n - 1
	k = 1
	sr = a[i]
	while sr / k >= x:
		i -= 1
		k += 1
		sr += a[i]
		if i == 0:
			break
	print(k - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	m = sorted(list(map(int, input().split())))
	s = sum(m)
	while s < n * x:
		s -= m[-n]
		n -= 1
	print(n)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	i = n - 1
	c = 0
	s = 0
	if a[i] < k:
		print('0')
		t -= 1
		continue
	s += a[i]
	c = 1
	i -= 1
	while i >= 0 and int((s + a[i]) / (c + 1)) >= k:
		s += a[i]
		c += 1
		i -= 1
	print(c)
	t -= 1


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	t = list(map(int, input().split()))
	t.sort()
	a = sum(t)
	if a / n >= x:
		print(n)
	else:
		h = 0
		for k in range(n - 1):
			a -= t[k]
			if a / (n - (k + 1)) >= x:
				print(n - (k + 1))
				h += 1
				break
		if h == 0:
			if t[-1] >= x:
				print(1)
			else:
				print(0)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = 0
	done = False
	for i in range(n):
		s += l[i]
		if s / (i + 1) < x:
			print(i)
			done = True
			break
	if not done:
		print(n)


from math import ceil, gcd, floor
from collections import deque, defaultdict
from heapq import heappush as hpush, heappop as hpop, heapify
from functools import lru_cache
testcase = int(input())
for _ in range(testcase):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	c = 0
	s = 0
	f = 0
	for i in a:
		c += i
		s += 1
		if c / s >= x:
			f += 1
		else:
			break
	print(f)


T = int(input())
for t in range(T):
	line1 = [int(i) for i in input().split()]
	(n, x) = (line1[0], line1[1])
	a = [int(i) for i in input().split()]
	a = sorted(a)[::-1]
	sum_ = 0
	i = 1
	while i <= n:
		sum_ += a[i - 1]
		if sum_ / i < x:
			break
		i += 1
	print(i - 1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	extra = 0
	req = []
	ans = 0
	for i in range(n):
		if a[i] >= x:
			extra += a[i] - x
			ans += 1
		else:
			req.append(x - a[i])
	req.sort()
	for i in range(len(req)):
		if req[i] <= extra:
			ans += 1
			extra -= req[i]
		else:
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = sorted(map(int, input().split()))[::-1]
	su = cn = 0
	for y in l:
		su += y
		if su >= x * (cn + 1):
			cn += 1
		else:
			break
	print(cn)


t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	cnt = 0
	sm = 0
	while cnt < n and sm + arr[cnt] >= (cnt + 1) * x:
		sm += arr[cnt]
		cnt += 1
	print(cnt)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	summ = 0
	ans = 0
	tt = 0
	for i in range(l[0]):
		summ = summ + a[i]
		if summ / (i + 1) < l[1]:
			tt = 1
			ans = i
			break
	if tt == 0:
		print(l[0])
	else:
		print(ans)


for i in range(int(input())):
	s = 0
	c = 0
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	for j in range(n):
		s = s + a[j]
		if s / (j + 1) >= x:
			c += 1
	print(c)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	nums.sort(reverse=True)
	tot = 0
	ans = 0
	for i in range(len(nums)):
		tot += nums[i]
		if tot >= (i + 1) * x:
			ans = i + 1
	print(ans)


import sys
import io, os

def main():
	t = int(input())
	for i in range(t):
		(n, x) = map(int, input().split())
		a = [int(i) for i in input().split()]
		(rich, poor) = ([], [])
		for i in a:
			if i >= x:
				rich.append(i)
			else:
				poor.append(i)
		rich.sort()
		poor.sort(reverse=True)
		if len(rich) == 0:
			ans = 0
		else:
			ans = len(rich)
			suma = sum(rich)
			for j in range(len(poor)):
				if (suma + poor[j]) / (len(rich) + j + 1) >= x:
					suma += poor[j]
					ans += 1
				else:
					break
		print(ans)
main()


test = int(input())
for t in range(test):
	inps = list(map(int, input().split()))
	(n, x) = (inps[0], inps[1])
	Li = list(map(int, input().split()))
	Li.sort(reverse=True)
	tot = 0
	nume = 0
	if Li[0] >= x:
		tot = Li[0]
		nume = 1
	else:
		print(0)
		continue
	for i in range(1, n):
		if (tot + Li[i]) / (nume + 1) >= x:
			tot = tot + Li[i]
			nume = nume + 1
		else:
			break
	print(nume)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	tf = True
	for i in range(n):
		s += a[i]
		if x * (i + 1) <= s:
			pass
		else:
			tf = False
			break
	if tf:
		print(n)
	else:
		print(i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	best = float('-inf')
	sumsofar = 0
	count = 0
	a.sort()
	a = a[::-1]
	for i in range(n):
		sumsofar += a[i]
		if sumsofar / (i + 1) >= x:
			count += 1
		else:
			break
	print(count)


def solution(arr, x):
	arr.sort(reverse=True)
	(rem, ans) = (0, 0)
	i = 0
	while i < len(arr):
		summ = arr[i] + rem
		if summ >= x:
			ans += 1
			rem = summ - x
		i += 1
	return ans
for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	print(solution(a, x))


def solve(n, x, arr):
	arr.sort()
	curr_sum = total_rich = 0
	for i in range(n - 1, -1, -1):
		curr_sum += arr[i]
		curr_avg = float(curr_sum) / float(n - i)
		if curr_avg >= x:
			total_rich += 1
		else:
			break
	return total_rich
t = int(input())
results = list()
for _ in range(0, t):
	(n, x) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	results.append(solve(n, x, arr))
for result in results:
	print(result)


t = int(input())
for line in range(t):
	(n, x) = map(int, input().split())
	a = [int(k) for k in input().split()]
	a.sort()
	i = 0
	while i < len(a):
		person = a[i]
		if person >= x:
			break
		i += 1
	poor = a[:i]
	rich = a[i:]
	total_people = len(rich)
	total_wealth = sum(rich)
	mean = -1 if total_people == 0 else total_wealth / total_people
	for person in reversed(poor):
		total_people += 1
		total_wealth += person
		new_mean = total_wealth / total_people
		if new_mean < x:
			total_people -= 1
			break
		mean = new_mean
	print(total_people)


from sys import stdin
input = stdin.buffer.readline
N = int(input())
for n in range(N):
	(a, b) = [int(k) for k in input().split()]
	list1 = [int(l) for l in input().split()]
	list1.sort()
	i = 0
	s = sum(list1)
	x = a
	while i < a and s / x < b:
		s -= list1[i]
		x -= 1
		i += 1
	print(x)


t = int(input())
for z in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	tot = 0
	flag = ''
	for i in range(n):
		tot += a[i]
		if tot // (i + 1) >= x:
			continue
		else:
			flag = 'last er  ta bad'
			break
	if flag == '':
		print(i + 1)
	else:
		print(i)


import sys, math, cmath, time
start_time = time.time()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def solve():
	(n, x) = invr()
	a = inlt()
	a.sort()
	a.reverse()
	q = 0
	for i in range(len(a)):
		q = q + a[i]
		if q / (i + 1) < x:
			i = i - 1
			break
	print(i + 1)
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
t = 1
t = inp()
for tt in range(t):
	solve()
if not ONLINE_JUDGE:
	print('Time Elapsed:', time.time() - start_time, 'seconds')
sys.stdout.close()


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	(c, s, i) = (0, 0, 0)
	while i < n:
		if A[i] >= x:
			c = c + 1
			s = s + A[i]
		else:
			break
		i = i + 1
	for j in range(i, n):
		if (s + A[j]) // (c + 1) >= x:
			c = c + 1
			s = s + A[j]
		else:
			break
	print(c)


import math
for i in range(0, int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sum_ = 0
	count = 0
	for i in range(0, len(a)):
		sum_ += a[i]
		if sum_ >= (i + 1) * x:
			count += 1
		else:
			break
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	curr_sum = 0
	curr_num = 0
	for i in range(len(a)):
		if curr_sum + a[i] >= x * (curr_num + 1):
			curr_sum += a[i]
			curr_num += 1
		else:
			break
	print(curr_num)


R = lambda : map(int, input().split())
t = int(input())

def solve(a, x):
	s = 0
	a.append(-float('inf'))
	for i in range(len(a)):
		s += a[i]
		if s < (i + 1) * x:
			break
	return i
for _ in range(t):
	(n, x) = R()
	a = sorted(list(R()), reverse=True)
	print(solve(a, x))


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	su = d = 0
	for i in range(n):
		if a[i] > x:
			su += a[i] - x
		elif a[i] < x:
			if su - (x - a[i]) < 0:
				break
			else:
				su = su - (x - a[i])
		d = i + 1
	print(d)

def main():
	for t in range(int(input())):
		solve()
main()


t = int(input())
while t != 0:
	t -= 1
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	sl = []
	su = 0
	for i in range(n):
		su += l[i]
		sl.append(su)
	ans = 0
	for i in range(n, 0, -1):
		if sl[i - 1] / i >= x:
			ans = i
			break
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	k = 0
	summ = sum(arr)
	for i in range(a):
		if k == 0:
			if i > 0:
				summ -= arr[i - 1]
				if summ // (a - i) >= b:
					print(a - i)
					k = 1
			elif summ // a >= b:
				print(a)
				k = 1
	if k == 0:
		if max(arr) >= b:
			k = 1
			print(1)
	if k == 0:
		print(0)


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	total = sum(a)
	for j in sorted(a):
		if x > total / n:
			n -= 1
			total -= j
	print(n)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	s = 0
	a.sort(reverse=True)
	for i in range(n):
		s += a[i]
		if s >= int((i + 1) * x):
			ans = i + 1
		else:
			break
	print(ans)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	acc = [0]
	for ai in a:
		acc.append(acc[-1] + ai)
	ans = 0
	for i in range(n):
		if acc[i + 1] >= (i + 1) * x:
			ans = max(ans, i + 1)
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	flag = 1
	for i in range(len(a)):
		s += a[i]
		if s / (i + 1) < x:
			flag = 0
			print(i)
			break
	if flag == 1:
		print(n)


import sys

def main():
	mod = 998244353

	def GCD(x, y):
		while y:
			(x, y) = (y, x % y)
		return x

	def lcm(a, b):
		return a * b // GCD(a, b)

	def merge(a, start, mid, end, d):
		p = start
		q = mid + 1
		arr = [0] * (end - start + 1)
		k = 0
		coun = 0
		for i in range(start, end + 1):
			if p > mid:
				arr[k] = a[q]
				q += 1
				k += 1
			elif q > end:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			elif a[p] < a[q]:
				arr[k] = a[p]
				d[a[p]] += coun
				k += 1
				p += 1
			else:
				arr[k] = a[q]
				k += 1
				q += 1
				coun += 1
		for i in range(k):
			a[start] = arr[i]
			start += 1

	def mergesort(a, start, end, d):
		if start < end:
			mid = (start + end) // 2
			mergesort(a, start, mid, d)
			mergesort(a, mid + 1, end, d)
			merge(a, start, mid, end, d)

	def inversion(l):
		d = {}
		for i in l:
			d[i] = 0
		mergesort(l, 0, len(l) - 1, d)
		return d

	def binary_search_lower(A, low, high, k):
		if high - low != 1:
			mid = (low + high) // 2
			x = A[mid]
			if x >= k:
				return binary_search_lower(A, low, mid, k)
			else:
				return binary_search_lower(A, mid, high, k)
		if A[low] >= k:
			return low
		else:
			return high

	def binary_expo(x, n):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return binary_expo(x * x, n // 2)
		else:
			return x * binary_expo(x * x, (n - 1) // 2)

	def modu_expo(x, n, m):
		if n == 0:
			return 1
		elif n % 2 == 0:
			return modu_expo(x * x % m, n // 2, m)
		else:
			return x * modu_expo(x * x % m, (n - 1) // 2, m) % m

	def eEuclid(c, m):
		if m == 0:
			global d
			global x
			global y
			d = c
			x = 1
			y = 0
		else:
			eEuclid(m, c % m)
			temp = x
			x = y
			y = temp - c // m * y

	def mod_Inv(c, m):
		eEuclid(c, m)
		return (x % m + m) % m

	def ncr(n, r, p):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % p
			den = den * (i + 1) % p
		return num * pow(den, p - 2, p) % p
	for _ in range(int(sys.stdin.readline())):
		(n, x) = map(int, sys.stdin.readline().split())
		l = [int(y) for y in sys.stdin.readline().split()]
		s = sum(l)
		l.sort()
		for i in range(n):
			if s / (n - i) >= x:
				print(n - i)
				break
			else:
				s -= l[i]
		else:
			print(0)
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	r = list(map(int, input().split()))
	r.sort(reverse=True)
	i = 1
	s = 0
	while i <= n and s + r[i - 1] >= i * x:
		s += r[i - 1]
		i += 1
	print(i - 1)


from typing import List

def countMaxWealthy(savings: List[int], x: int) -> int:
	savings.sort()
	total = sum(savings)
	i = 0
	while i < len(savings) and total / (len(savings) - i) < x:
		total -= savings[i]
		i += 1
	return len(savings) - i
n = int(input().strip())
for _ in range(n):
	(_, x) = map(int, input().strip().split())
	savings = list(map(int, input().strip().split()))
	count = countMaxWealthy(savings, x)
	print(count)


t = int(input())
for t1 in range(t):
	sl = input().split(' ')
	n = int(sl[0])
	rs = int(sl[1])
	sli = input().split(' ')
	li = list()
	for i in range(n):
		li.append(int(sli[i]))
	li.sort(reverse=True)
	sum = 0
	c = 0
	for i in range(n):
		sum += li[i]
		if sum / (i + 1) >= rs:
			c += 1
		else:
			break
	print(c)


def solve(wealth, x):
	wealth.sort(reverse=True)
	wealthy = 0
	total = 0
	ppl = 0
	for person in wealth:
		total += person
		ppl += 1
		if total / ppl < x:
			return wealthy
		wealthy += 1
	return wealthy
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	wealth = list(map(int, input().split(' ')))
	print(solve(wealth, x))


def main():
	testcases = int(input())
	for t in range(testcases):
		line1 = input().split()
		n = int(line1[0])
		x = int(line1[1])
		line2 = input().split()
		savings = []
		ans = 0
		sum = 0
		for i in range(n):
			savings.append(int(line2[i]))
		savings.sort(reverse=1)
		i = 0
		while i < len(savings) and (sum + savings[i]) / (ans + 1) >= x:
			sum += savings[i]
			ans += 1
			i += 1
		print(ans)
main()


T = int(input())
ANS = []
for _ in range(T):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	tot = sum(A)
	ans = n
	while A:
		if tot / n >= x:
			break
		else:
			tmp = A.pop(0)
			tot -= tmp
			n -= 1
	ANS.append(n)
for aa in ANS:
	print(aa)


def solve():
	(n, x) = [int(v) for v in input().split()]
	arr = [int(v) for v in input().split()]
	arr.sort()
	sm = 0
	ans = 0
	for (cnt, v) in enumerate(reversed(arr), 1):
		sm += v
		if sm / cnt < x:
			break
		ans = cnt
	print(ans)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	savings = list(map(int, input().split()))
	sum_of_savings = sum(savings)
	wealthy = sum((1 for i in savings if i >= x))
	if wealthy == 0:
		print(0)
	elif sum_of_savings / n > x:
		print(n)
	else:
		savings.sort()
		a = 0
		while sum_of_savings / (n - a) < x:
			sum_of_savings -= savings[a]
			a += 1
		print(n - a)


t = int(input())
for x in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sum = 0
	ans = n
	for (i, w) in enumerate(a):
		sum += w
		if sum / (i + 1) < x:
			ans = i
			break
	print(ans)


cases = int(input())
ans = []
for i in range(cases):
	temp = list(map(lambda x: int(x), input().split()))
	(len_, low) = (temp[0], temp[1])
	arr = list(map(lambda x: int(x), input().split()))
	arr.sort()
	sum_ = sum(arr)
	for k in range(len_):
		remain = len_ - k
		avg = sum_ / remain
		if avg >= low:
			ans.append(remain)
			break
		sum_ -= arr[k]
		remain -= 1
		if k == len_ - 1:
			ans.append(0)
for item in ans:
	print(item)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	counter = 0
	sumo = 0
	for i in a:
		sumo = sumo + i
		if sumo / (counter + 1) >= x:
			counter = counter + 1
		else:
			break
	print(counter)


import sys
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, X) = MAP()
	A = LIST()
	B = []
	cnt = 0
	ans = 0
	for a in A:
		if a >= X:
			cnt += a - X
			ans += 1
		else:
			B.append(a)
	B.sort(reverse=1)
	for b in B:
		if cnt - (X - b) >= 0:
			cnt -= X - b
			ans += 1
		else:
			break
	print(ans)


for _ in range(0, int(input())):
	nx = list(map(int, input().split()))
	n = nx[0]
	x = nx[1]
	arrayn = list(map(int, input().split()))
	arrayn.sort()
	answer = 0
	sum = 0
	for i in range(0, n):
		sum += arrayn[i]
	for i in range(0, n):
		if i > 0:
			sum = sum - arrayn[i - 1]
		if sum / (n - i) >= x:
			answer = n - i
			break
	print(answer)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	(n, x) = read()
	savings = get_list()
	savings.sort(reverse=True)
	s = savings[0]
	c = 0
	if s >= x:
		c += 1
	for i in range(1, n):
		s += savings[i]
		if s / (i + 1) >= x:
			c += 1
	print(c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	l = list()
	v = 0
	b = 0
	ans = 0
	for i in range(n):
		if a[i] < k:
			l.append(a[i])
			v += a[i]
		else:
			b += a[i]
			ans += 1
	l.sort(reverse=True)
	m = len(l)
	while m > 0:
		if (b + v) / (m + ans) < k:
			v -= l[-1]
			m -= 1
			l.pop()
		else:
			ans += len(l)
			break
	print(ans)


import sys
ip = lambda : sys.stdin.readline().rstrip()
for _ in range(int(ip())):
	(n, x) = map(int, ip().split())
	a = sorted(map(int, ip().split()))
	(sm, l) = (0, 0)
	(ans, i) = (0, n - 1)
	while i >= 0:
		sm += a[i]
		l += 1
		if sm / l >= x:
			ans += 1
		else:
			break
		i -= 1
	print(ans)


kl = int(input())
for l in range(kl):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a.sort()
	(ss, st, kp) = (0, 0, 0)
	for i in range(n - 1, -1, -1):
		kp += 1
		ss += a[i]
		if ss < kp * x:
			kp = kp - 1
			break
	print(kp)


def solve():
	(N, X) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	redis = 0
	for i in range(N):
		if arr[i] > X:
			redis += arr[i] - X
			arr[i] = X
	cnt = 0
	for i in range(N - 1, -1, -1):
		if arr[i] < X:
			diff = min(redis, X - arr[i])
			arr[i] += diff
			redis -= diff
		if arr[i] >= X:
			cnt += 1
	print(cnt)
T = int(input())
for t in range(T):
	solve()


for _ in range(int(input())):
	(n, x) = list((int(i) for i in input().split()))
	a = list((int(i) for i in input().split()))
	a.sort(reverse=True)
	p = [0] * n
	p[0] = a[0]
	for i in range(1, n):
		p[i] = p[i - 1] + a[i]
	u = 0
	for i in range(0, n):
		if p[i] / (i + 1) >= x:
			u += 1
		else:
			break
	print(u)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	s = sorted(map(int, input().split()), reverse=1)
	if s[0] < x:
		print(0)
	else:
		c = s[0]
		i = 1
		while i < n and c / i >= x:
			c += s[i]
			i += 1
		if c // i >= x:
			print(i)
		else:
			print(max(c % i, 1, i - 1))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sn = 0
	ans = 0
	for i in range(n):
		sn += a[i]
		f = sn // x
		if f >= i + 1:
			ans = i + 1
		else:
			break
	print(ans)


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	add = 0
	cnt = 0
	for i in range(n):
		if add + a[i] >= (i + 1) * k:
			add += a[i]
			cnt += 1
		else:
			break
	print(cnt)

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().strip().split())
	l = list(map(int, input().strip().split()))
	l.sort()
	l = l[::-1]
	c = 0
	j = 1
	pf = [0] * a
	pf[0] = l[0]
	for i in range(1, a):
		pf[i] = pf[i - 1] + l[i]
	for i in pf:
		if i // j >= b:
			c += 1
			j += 1
		else:
			break
	print(c)


for h in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	if l[-1] == x:
		print(l.count(x))
	elif l[-1] < x:
		print(0)
	else:
		a = l[::-1]
		sum = 0
		c = 0
		for i in range(n):
			sum += a[i]
			if sum / (i + 1) < x:
				c = c + 1
		print(n - c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	if l[-1] == x:
		print(l.count(x))
	elif l[-1] < x:
		print(0)
	else:
		a = l[::-1]
		s = 0
		c = 0
		for i in range(n):
			a[i] = a[i] - x
		for i in range(n):
			if s + a[i] < 0:
				break
			else:
				s = s + a[i]
				c += 1
		print(c)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	b = []
	cnt = 0
	for i in range(n):
		if i == 0:
			b.append(a[i])
		else:
			b.append(a[i] + b[i - 1])
	for i in range(n):
		if a[i] < k:
			flag = b[i] / (i + 1)
			if flag >= k:
				cnt += 1
			else:
				break
		else:
			cnt += 1
	print(cnt)


from sys import stdin

def func(arr):
	(a, b) = (arr[0][0], arr[0][1])
	if b > a:
		return 0
	for i in range(1, len(arr)):
		if arr[i][0] - arr[i - 1][0] < arr[i][1] - arr[i - 1][1] or (arr[i][0] - arr[i - 1][0] < 0 or 0 > arr[i][1] - arr[i - 1][1]):
			return 0
	return 1
for _ in range(int(stdin.readline())):
	(n, x) = map(int, stdin.readline().split())
	arr = sorted(list(map(int, stdin.readline().split())), reverse=True)
	m = 0
	s = 0
	for i in range(n):
		s += arr[i]
		k = s // (i + 1)
		if k >= x:
			if i + 1 > m:
				m = i + 1
	print(m)


def max_wealthy(nums, x):
	nums = sorted(nums)
	nums1 = [int(n - x) for n in nums]
	i = len(nums1) - 1
	excess = total = 0
	while i >= 0:
		diff = nums1[i]
		if diff >= 0 or diff + excess >= 0:
			total += 1
			excess += diff
		i -= 1
	return total
t = int(input())
while t:
	row = input()
	row_split = row.split()
	n = int(row_split[0])
	x = int(row_split[1])
	row = input()
	nums = [int(r) for r in row.split()]
	ans = max_wealthy(nums, x)
	print(ans)
	t -= 1


import sys
input = sys.stdin.readline

def memoize(f):
	mem = {}

	def wrapper(n):
		if n not in mem:
			mem[n] = f(n)
		return mem[n]
	return wrapper

@memoize
def temp():
	pass
ans = ''
for _ in range(int(input())):
	(n, x) = [int(xi) for xi in input().split(' ')]
	a = [int(xi) for xi in input().split(' ')]
	sorted_a = [i[0] for i in reversed(sorted(enumerate(a), key=lambda x: x[1]))]
	i = 0
	for _i in range(n):
		idx = sorted_a[i]
		if len(sorted_a) - 1 > _i:
			if a[idx] < x:
				continue
			a[sorted_a[i + 1]] += a[idx] - x
			a[idx] = x
			i += 1
	c_ans = 0
	for xi in a:
		if xi >= x:
			c_ans += 1
	ans += f'{c_ans} '
sys.stdout.write(ans)


def Sol():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	summ = a[0]
	count = 0
	while summ // (count + 1) >= x:
		count += 1
		if count < n:
			summ += a[count]
		else:
			return n
	return count
T = int(input())
for i in range(T):
	print(Sol())


def solve(arr, n, x):
	(a, b) = ([], [])
	for num in arr:
		if num < x:
			a.append(num - x)
		else:
			b.append(num - x)
	if not a or not b:
		return len(b)
	a.sort(reverse=True)
	b.sort()
	(i, j) = (0, 0)
	s = b[0] + a[0]
	while i < len(b) and j < len(a):
		if s >= 0:
			j += 1
			if j < len(a):
				s += a[j]
		else:
			i += 1
			if i < len(b):
				s += b[i]
	return len(b) + j

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = list(map(int, input().strip().split()))
		arr = list(map(int, input().strip().split()))
		ret = solve(arr, n, x)
		print(ret)
main()


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		n = int(input())
		(p, c) = ([0] * n, [0] * n)
		succ = True
		for i in range(n):
			(p[i], c[i]) = map(int, input().split())
		if p[0] < c[0]:
			succ = False
		else:
			for i in range(1, n):
				if c[i] - c[i - 1] > p[i] - p[i - 1] or c[i] < c[i - 1] or p[i] < p[i - 1]:
					succ = False
					break
		if succ:
			print('YES')
		else:
			print('NO')
	return

def B():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		a.sort(reverse=True)
		(tot, ppl) = (0, 0)
		for i in range(n):
			if a[i] + tot - x >= 0:
				ppl += 1
				tot += a[i] - x
			else:
				break
		print(ppl)
	return

def C():
	return

def D():
	return
B()


from math import *
T = int(input())
while T:
	T -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sum = 0
	ans = n
	for i in range(n):
		if (sum + a[i]) // (i + 1) < m:
			ans = i
			break
		sum += a[i]
	print(ans)


tc = int(input())
for i in range(tc):
	(n, x) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	reserve = 0
	ameer = 0
	arr.sort()
	for i in range(len(arr) - 1, -1, -1):
		if arr[i] >= x:
			reserve += arr[i] - x
			ameer += 1
		elif arr[i] < x:
			diff = x - arr[i]
			margin = reserve - diff
			if margin >= 0 and reserve - diff >= 0:
				reserve -= diff
				ameer += 1
			else:
				break
	print(ameer)


T = int(input())
for _ in range(T):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	i = 0
	t1 = 0
	q = 0
	while i < n:
		if i == 0:
			if a[i] >= x:
				t1 += 1
			q += a[i]
		else:
			q += a[i]
			if a[i] >= x:
				t1 += 1
			elif q // (i + 1) >= x:
				t1 += 1
			else:
				break
		i += 1
	print(t1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	m = list(map(int, input().split()))
	m.sort()
	s = sum(m)
	num = n
	for i in range(n):
		if x <= s / num:
			break
		s = s - m[i]
		num -= 1
	print(num)


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	for _ in range(int(_input())):
		(n, x) = [int(i) for i in input().split()]
		arr = sorted([int(i) for i in input().split()])
		summary = sum(arr)
		k = 0
		while n != k and summary / (n - k) < x:
			summary -= arr[k]
			k += 1
		print(n - k)
solution()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	(n, x) = get_int_list()
	lst = sorted(get_int_list(), reverse=True)
	count = 0
	s = 0
	i = 0
	while i < n:
		s += lst[i]
		if s / (i + 1) >= x:
			count += 1
		else:
			break
		i += 1
	print(count)


import sys
from math import log2, ceil
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a > 0:
		return gcd(b % a, a)
	return b

def primefs(n):
	if n == 1:
		return 1
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def int_array():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, x) = int_array()
	a = int_array()
	a.sort()
	num = n
	sumo = sum(a)
	r = sumo / num
	f = 0
	while num > 0 and r < x:
		sumo -= a[f]
		f += 1
		num -= 1
		if num == 0:
			break
		r = sumo / num
	print(num)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	arr = list(map(int, input().split()))
	arr = sorted(arr, reverse=True)
	tot = sum(arr)
	ans = -1
	if arr[0] < k:
		ans = 0
	else:
		for i in range(n - 1, -1, -1):
			if arr[i] >= k:
				ans = i + 1
				break
			elif tot / (i + 1) >= k:
				ans = i + 1
				break
			else:
				tot = tot - arr[i]
	if ans == -1:
		print(0)
	else:
		print(ans)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	s = 0
	c = 0
	for i in range(len(arr)):
		s += arr[i]
		if s / (i + 1) >= k:
			c += 1
	print(c)


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


k = int(input().strip())
for _ in range(k):
	(_, x) = input().strip().split(' ')
	x = int(x)
	l = sorted(map(int, input().strip().split(' ')), reverse=True)
	s = 0
	i = 0
	for i in range(len(l)):
		s += l[i]
		if s / (i + 1) < x:
			s -= l[i]
			if i == 0:
				print(0)
			else:
				print(i)
			break
	else:
		print(i + 1)


def kek():
	(n, x) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	arr.sort(reverse=True)
	if arr[0] < x:
		print(0)
		return
	i = 0
	count = 1
	sred = arr[0]
	sum_ = arr[0]
	while sred >= x and i + 1 < n:
		i += 1
		count += 1
		sum_ += arr[i]
		sred = sum_ / count
	print(count if sred >= x else count - 1)

def main():
	t = int(input())
	for i in range(t):
		kek()
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	count = 0
	s = 0
	ans = n
	for i in range(n - 1, -1, -1):
		s += a[i]
		count += 1
		if s / count < x:
			ans = n - i - 1
			break
	print(ans)


t = int(input())
for q in range(t):
	(n, x) = list(map(int, input().split(' ')))
	entrada = list(map(int, input().split(' ')))
	entrada.sort()
	entrada = list(reversed(entrada))
	total = 0
	cont = 0
	for k in range(n):
		if (entrada[k] + total) / (k + 1) >= x:
			total += entrada[k]
			cont += 1
		else:
			break
	print(cont)


def checklevel(a):
	currp = 0
	currc = 0
	for i in a:
		if currp > i[0]:
			return 'NO'
		if currc > i[1]:
			return 'NO'
		if i[1] - currc > i[0] - currp:
			return 'NO'
		currp = i[0]
		currc = i[1]
	return 'YES'

def problem1():
	l = int(input())
	a = []
	for _ in range(l):
		a.append(list(map(int, input().split())))
	print(checklevel(a))

def makewealthy(a, x):
	total = a[0]
	if a[0] < x:
		return 0
	i = 1
	b = x
	while i < len(a):
		total += a[i]
		b += x
		if total < b:
			return i
		i += 1
	return len(a)

def problem2():
	(l, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	print(makewealthy(a, x))
cases = int(input())
for _ in range(cases):
	problem2()


from sys import stdin
a = int(stdin.readline())
for k in range(0, a):
	b = stdin.readline().split()
	A = int(b[0])
	B = int(b[1])
	C = stdin.readline().split()
	D = list()
	for j in range(0, A):
		D.append(int(C[j]) - B)
	D.sort(reverse=True)
	count = 0
	record = 0
	for y in range(0, A):
		if count >= 0:
			count += D[y]
			if count >= 0:
				record += 1
			else:
				break
	print(record)


from sys import stdin
input = stdin.readline
q = int(input())
for rwer in range(q):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	pref = 0
	odp = 0
	for i in range(n):
		pref += l[i]
		if pref < x * (i + 1):
			break
		else:
			odp += 1
	print(odp)


t = int(input())
r = []
for i in range(t):
	cnt = 0
	n = input().split()
	n[0] = int(n[0])
	n[1] = int(n[1])
	a = sorted(map(int, input().split()))
	su = 0
	for j in range(n[0]):
		su = su + a[n[0] - 1 - j]
		if n[1] * (j + 1) <= su:
			cnt = cnt + 1
	r.append(cnt)
for k in range(len(r)):
	print(r[k])


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	csum = a[0]
	people_checked = 1
	while people_checked < len(a):
		if csum / people_checked >= x:
			csum += a[people_checked]
			people_checked += 1
		else:
			break
	if len(a) == 1:
		if a[0] >= x:
			print('1')
		else:
			print('0')
	elif people_checked == len(a) and csum / people_checked >= x:
		print(people_checked)
	else:
		print(people_checked - 1)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	total = sum(arr)
	arr.sort()
	x = 0
	count = n
	if total / n >= k:
		print(n)
	else:
		for i in range(n - 1):
			total = total - arr[i]
			count = count - 1
			if total / count >= k:
				x = 1
				print(count)
				break
		if x == 0:
			print(0)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	su = 0
	for i in range(n):
		nums = i + 1
		su += a[i]
		if su / nums >= x:
			ans = i + 1
	print(ans)


def solve(n, x, a):
	a.sort(key=lambda x: -x)
	if a[0] < x:
		return 0
	cur_sum = a[0]
	cur_count = 1
	for i in range(1, n):
		if (cur_sum + a[i]) / (cur_count + 1) >= x:
			cur_count += 1
			cur_sum += a[i]
	return cur_count
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	result = solve(n, x, a)
	print(result)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())
for i in range(int(data())):
	(n, x) = mdata()
	A = list(mdata())
	A.sort()
	s = 0
	cnt2 = cnt1 = 0
	cnt = 0
	for i in range(n):
		if A[i] > x:
			cnt += 1
			s += A[i]
		elif A[i] == x:
			cnt1 += 1
	for i in range(n - cnt - 1, -1, -1):
		if A[i] < x:
			s += A[i]
			cnt2 += 1
			if s < x * (cnt + cnt2):
				cnt2 -= 1
				break
	print(cnt + cnt2 + cnt1)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	s = sum(a)
	ans = 0
	for i in range(n):
		nn = n - i
		d = s / nn
		if d >= x:
			ans = nn
			break
		s = s - a[i]
	print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = reversed(sorted(map(int, input().split())))
	e = 0
	r = 0
	for i in a:
		if i > x:
			e += i - x
			r += 1
		else:
			if e < x - i:
				break
			e -= x - i
			r += 1
	print(r)


t = int(input())
for i in range(0, int(t)):
	linea1 = [int(x) for x in input().split()]
	linea2 = [int(x) for x in input().split()]
	cantidad = linea1[0]
	minimo = linea1[1]
	linea2.sort(reverse=True)
	largo = len(linea2)
	suma = 0
	for i in linea2:
		suma += i
	while suma < minimo * cantidad and cantidad > 1:
		suma -= linea2[cantidad - 1]
		cantidad -= 1
	if cantidad == 1 and linea2[0] >= minimo:
		print(1)
	elif cantidad == 1 and linea2[0] < minimo:
		print(0)
	else:
		print(cantidad)


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	xs = []
	for i in input().split():
		xs.append(int(i) - x)
	xs = sorted(xs, reverse=True)
	sum = 0
	count = 0
	for i in xs:
		sum += i
		if sum < 0:
			break
		else:
			count += 1
	print(count)


t = int(input())
for j in range(t):
	(N, X) = map(int, input().split(' '))
	a = [0] * N
	a = map(int, input().split(' '))
	A = list(a)
	A = sorted(A, reverse=True)
	k = 0
	S = 0
	for i in range(N):
		S = S + A[i]
		if S / (i + 1) >= X:
			k += 1
	print(k)


t = int(input())
for o in range(t):
	(n, x) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	s = 0
	k = len(l)
	for i in range(len(l)):
		s = s + l[i]
	if s // len(l) >= x:
		print(len(l))
	else:
		for j in range(k):
			if j == k - 1:
				print('0')
				break
			else:
				s = s - l[j]
				if s // (k - j - 1) >= x:
					print(k - j - 1)
					break


for i in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	l = [int(i) for i in input().split()]
	l.sort(reverse=True)
	count = 0
	sumi = 0
	for i in range(a):
		if l[i] < b:
			k = b - l[i]
			if sumi >= k:
				count += 1
				sumi -= k
		else:
			count += 1
			sumi += l[i] - b
	print(count)


def main():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	now = 0
	cnt = 0
	ans = 0
	for item in a:
		now += item
		cnt += 1
		if cnt * x <= now:
			ans = cnt
	print(ans)
for _ in range(int(input())):
	main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))[::-1]
	total = 0
	number = 0
	finished = True
	for person in a:
		number += 1
		total += person
		if total < number * x:
			finished = False
			break
	if finished:
		print(number)
	else:
		print(number - 1)


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	lst = []
	sum = 0
	nd = 0
	for i in input().split():
		j = int(i)
		if j >= x:
			nd += 1
			sum = sum + (j - x)
		else:
			lst.append(x - j)
	lst.sort()
	n = len(lst)
	i = 0
	while sum != 0 and i < n:
		if lst[i] <= sum:
			sum = sum - lst[i]
			nd += 1
		else:
			break
		i += 1
	print(nd)


import sys
inp = sys.stdin.readline
t = int(inp())
while t:
	t -= 1
	(n, x) = map(int, inp().split())
	arr = list(map(int, inp().split()))
	arr = sorted(arr, reverse=True)
	for i in range(1, n):
		arr[i] = arr[i - 1] + arr[i]
	if arr[-1] / n >= x:
		print(n)
	elif arr[0] < x:
		print(0)
	else:
		for i in range(n):
			if arr[i] / (i + 1) < x:
				print(i)
				break


def main():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		A = list(map(int, input().split()))
		A.sort(reverse=True)
		for i in range(n - 1):
			A[i + 1] += A[i]
		ans = 0
		for i in range(n):
			if A[i] >= x * (i + 1):
				ans += 1
			else:
				break
		print(ans)
main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = sum(a)
	value = 0
	for j in range(0, n):
		if b * 1.0 >= (n - j) * x * 1.0:
			value = n - j
			break
		b -= a[j]
	print(value)


def main():
	for _ in range(int(input())):
		(n, x, s) = (*map(int, input().split()), 0)
		for (i, a) in enumerate(sorted(map(int, input().split()), reverse=True)):
			s += a - x
			if s < 0:
				print(i)
				break
		else:
			print(n)
main()


for j in range(int(input())):
	(n, x) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	cnt = 0
	if max(l) < x:
		cnt = 0
	else:
		summ = 0
		leng = 0
		for i in range(len(l) - 1, -1, -1):
			summ += l[i]
			leng += 1
			if summ // leng >= x:
				cnt += 1
			else:
				break
	print(cnt)


import math

def merge(lst1, lst2):
	i = 0
	j = 0
	lst = []
	while i < len(lst1) and j < len(lst2):
		if lst1[i] > lst2[j]:
			lst.append(lst1[i])
			i += 1
		else:
			lst.append(lst2[j])
			j += 1
	while i < len(lst1):
		lst.append(lst1[i])
		i += 1
	while j < len(lst2):
		lst.append(lst2[j])
		j += 1
	return lst

def mergeSort(lst):
	if len(lst) <= 1:
		return lst
	mid = math.floor(len(lst) / 2)
	left = mergeSort(lst[0:mid])
	right = mergeSort(lst[mid:])
	return merge(left, right)
test = int(input())
k = 0
while k < test:
	(people, money) = input().split()
	people = int(people)
	money = int(money)
	lst = list(map(int, input().split()))
	lst = mergeSort(lst)
	j = 0
	sum = 0
	forceBreak = False
	while j < len(lst):
		sum += lst[j]
		if sum / (j + 1) < money:
			forceBreak = True
			break
		j += 1
	print(j)
	k += 1


for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort()
	b = sum(a)
	ans = 0
	for i in range(len(a)):
		average = b / (len(a) - i)
		if average >= x:
			ans = len(a) - i
			break
		b -= a[i]
	print(ans)


from bisect import bisect_left as bl
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()))
	r = bl(a, x)
	k = n - r
	q = sum(a[r:]) - (n - r) * x
	for j in range(r):
		p = x - a[r - j - 1]
		if p <= q:
			q -= p
			k += 1
		else:
			break
	print(k)


rint = lambda : int(input())
rounds = rint()
for _ in range(rounds):
	(p, dst) = [int(c) for c in input().split()]
	ss = [int(c) for c in input().split()]
	ss.sort()
	total = sum(ss)
	while len(ss) > 0:
		avg = total / len(ss)
		if avg >= dst:
			break
		total -= ss[0]
		ss.pop(0)
	print(len(ss))


import sys
input = sys.stdin.readline
from collections import Counter

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def print_list_int(l):
	print(''.join(map(str, map(int, l))))
t = inp()
for test in range(t):
	(n, x) = inlt()
	money = inlt()
	money = sorted(money, reverse=True)
	i = 0
	sums = 0
	prefix = []
	while i < len(money) and money[i] >= x:
		sums += money[i]
		prefix.append(sum)
		i += 1
	already_rich = i
	while i < len(money) and (sums + money[i]) / (i + 1) >= x:
		sums += money[i]
		already_rich += 1
		i += 1
	print(already_rich)


def NO():
	return print('NO')

def YES():
	return print('YES')

def INT():
	return int(input())

def LIST():
	return list(map(int, input().split()))

def STR():
	return input()

def MAP():
	return map(int, input().split())
for _ in range(INT()):
	(n, x) = MAP()
	a = LIST()
	ans = 0
	cnt = 0
	buff = 0
	check = False
	a.sort(reverse=True)
	for i in range(0, n):
		buff += a[i]
		cnt += 1
		if buff // x >= cnt:
			ans += 1
		else:
			break
	print(ans)


import sys
t = int(input())
for i in range(0, t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	l = input().split()
	for j in range(0, n):
		l[j] = int(l[j])
	l.sort()
	num_rich = 0
	extra = 0
	j = 1
	while j < n + 1:
		if l[-j] >= x:
			extra += l[-j] - x
			l[-j] = x
			num_rich += 1
		else:
			q = x - l[-j]
			if extra - q >= 0:
				extra -= q
				num_rich += 1
				l[-j] += q
		j += 1
	print(num_rich)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	s = sum(l)
	c = 0
	ns = s
	nl = n
	for i in range(n):
		if s // n >= k:
			c = n
			break
		else:
			ns = ns - l[i]
			nl = nl - 1
			if nl == 0:
				c = 0
				break
			if ns // nl >= k:
				c = nl
				break
	print(c)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	flag = 1
	s = 0
	if max(l) < x:
		print(0)
	else:
		for i in range(n):
			s = s + l[i]
			f = s // (i + 1)
			if f >= x:
				flag = 1
				h = i
				continue
			else:
				flag = 0
				h = i
				break
		if flag == 1:
			print(h + 1)
		else:
			print(h)


import sys
input = sys.stdin.readline
t = int(input())
ans = []
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans_i = n
	s = 0
	for i in range(n):
		s += a[i]
		if s / (i + 1) < x:
			ans_i = i
			break
	ans.append(str(ans_i))
print('\n'.join(ans))


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, x) = iia()
	arr = iia()
	arr.sort(reverse=True)
	if arr[-1] >= x or sum(arr) / n >= x:
		print(n)
	elif arr[0] < x:
		print(0)
	else:
		tot = 0
		for i in range(n):
			if (tot + arr[i]) / (i + 1) >= x:
				tot += arr[i]
			else:
				print(i)
				break


def main():
	t = int(input())
	for _ in range(t):
		(n, x) = [int(i) for i in input().split()]
		a = [int(i) for i in input().split()]
		a.sort(reverse=True)
		actual = 0
		need = 0
		answer = n
		for i in range(n):
			el = a[i]
			actual += el
			need += x
			if need > actual:
				answer = i
				break
		print(answer)
main()


N = int(input())
for i in range(N):
	count = 0
	L1 = list(input().split())
	n = int(L1[0])
	min_A = int(L1[1])
	nw = list(input().split())
	Nw = []
	sum = 0
	for i in range(n):
		if int(nw[i]) >= min_A:
			count += 1
			sum += int(nw[i])
		else:
			Nw.append(int(nw[i]))
	r = sum - min_A * count
	v = -1
	V = 0
	Nw = sorted(Nw)
	l = len(Nw)
	L = l
	if l != 0:
		while v != 0:
			l -= 1
			count += 1
			if l == -1:
				break
			r = r + Nw[l]
			v = r // min_A
			r = r - min_A
	if L == 0:
		print(count)
	else:
		print(count - 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [0] + sorted([int(x) for x in input().split()], reverse=True)
	i = 0
	total = 0
	while i < n:
		total += a[i + 1]
		if total >= x * (i + 1):
			i += 1
		else:
			break
	print(i)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = sorted([int(j) for j in input().split()])
	summa = sum(c)
	ans = a
	for j in range(a):
		if summa / ans >= b:
			break
		else:
			summa -= c[j]
			ans -= 1
	print(ans)


isVerbose = False

def verbosity(msg):
	if isVerbose:
		print(msg)
num_cases = int(input())
results = []
for case in range(num_cases):
	(n, x) = map(int, input().split())
	wealth = list(map(int, input().split()))
	verbosity('\n\n\nnew case')
	rich = []
	poor = []
	for inhab in wealth:
		if inhab >= x:
			rich.append(inhab)
		else:
			poor.append(inhab)
	verbosity(f'rich: {rich}')
	verbosity(f'poor: {poor}')
	if len(rich) == 0:
		verbosity('keine reichen')
		results.append(0)
		continue
	comb_wealth = sum(rich)
	taking_part = len(rich)
	poor.sort()
	poor.reverse()
	for pleb in poor:
		if (comb_wealth + pleb) / (taking_part + 1) >= x:
			verbosity(f'pleb geaddet')
			comb_wealth += pleb
			taking_part += 1
		else:
			verbosity('break')
			break
	results.append(taking_part)
print(*results, sep='\n')


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	L = list(map(int, input().split()))
	Gareeb = []
	for i in L:
		if i < K:
			Gareeb.append(i)
	Gareeb.sort(reverse=True)
	ameer = N - len(Gareeb)
	S = sum(L) - sum(Gareeb)
	for i in Gareeb:
		if (S + i) / (ameer + 1) >= K:
			S = S + i
			ameer += 1
		else:
			break
	print(ameer)


for _ in range(int(input())):
	(n, w) = map(int, input().split(' '))
	x = sorted(list(map(int, input().split(' '))))
	ss = 0
	sol = n
	for i in range(n):
		ss += x[n - 1 - i]
		if ss / (i + 1) < w:
			sol = i
			break
	print(sol)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	lst = list(sorted(map(int, input().split()), reverse=True))
	k = 0
	sm = 0
	while k < n and sm + lst[k] >= (k + 1) * x:
		sm += lst[k]
		k += 1
	print(k)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	l = []
	m = []
	for i in a:
		if i >= x:
			l.append(i)
		else:
			m.append(i)
	gv = 0
	for i in l:
		gv += i - x
	ans = len(l)
	m.sort(reverse=True)
	for i in m:
		req = x - i
		if gv - req >= 0:
			ans += 1
			gv -= req
	print(ans)


t = int(input())
for tt in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	money = [int(elem) for elem in input().split()]
	summ = 0
	for m in money:
		summ += m
	money.sort()
	good = False
	i = 0
	while n > 0:
		if summ / n >= x:
			good = True
			break
		summ -= money[i]
		i += 1
		n -= 1
	if good:
		print(n)
	else:
		print('0')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(n - 2, -1, -1):
		a[i] += a[i + 1]
	res = 0
	for i in range(n):
		if a[i] / (n - i) >= x:
			res = n - i
			break
	print(res)


T = int(input())
for t in range(T):
	(n, x) = map(int, input().split())
	first = list(map(int, input().split()))
	first.sort(reverse=True)
	max_ = 0
	sum_ = 0
	for (i, cur) in enumerate(first):
		sum_ += cur
		if sum_ / (i + 1) >= x:
			max_ = i + 1
	print(max_)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	lst = sorted(list(map(int, input().split())))
	sm = sum(lst)
	for j in range(n):
		if sm / (n - j) >= x:
			print(n - j)
			break
		else:
			sm -= lst[j]
	if lst[n - 1] < x:
		print(0)


for _ in range(int(input())):
	(n, price) = map(int, input().split())
	pocket = [int(i) for i in input().split()]
	pocket.sort(reverse=True)
	cnt = 0
	total = 0
	for i in range(n):
		total += pocket[i]
		cnt += 1
		if total / cnt < price:
			print(cnt - 1)
			break
	else:
		print(cnt)


x = int(input())
for i in range(x):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	if max(l) < x:
		print(0)
	else:
		l.sort()
		c1 = sum(l)
		c2 = len(l)
		for z in range(n):
			c = c1 // c2
			if c >= x:
				print(c2)
				break
			else:
				c1 = c1 - l[z]
				c2 = c2 - 1


import sys
input = sys.stdin.readline
(t,) = map(int, input().split())
for _ in range(t):
	(N, K) = map(int, input().split())
	X = sorted(list(map(int, input().split())))[::-1]
	s = 0
	for i in range(N):
		s += X[i]
		if s < K * (i + 1):
			print(i)
			break
	else:
		print(N)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = n
	a.sort()
	m = sum(a)
	i = 0
	while i < n and m / ans < x:
		m -= a[i]
		i += 1
		ans -= 1
	print(ans)


from sys import stdin, stdout, stderr, maxsize
tup = lambda : map(int, stdin.buffer.readline().split())
I = lambda : int(stdin.buffer.readline())
lint = lambda : [int(x) for x in stdin.buffer.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
for _ in range(I()):
	(n, x) = tup()
	ls = lint()
	ls.sort()
	(s, c) = (0, 0)
	for i in range(n - 1, -1, -1):
		s += ls[i]
		c += 1
		if s / c >= x:
			pass
		else:
			c -= 1
			break
	print(c)


from math import gcd, ceil
from collections import defaultdict as dd

def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

def ar(element, size):
	return [element for i in range(size)]

def digitsum(num):
	su = 0
	while num:
		su += num % 10
		num //= 10
	return su

def pred(n, k, pointer):
	return pointer - k >= n
for _ in range(inin()):
	(n, x) = inar()
	ar = inar()
	ar.sort()
	ar.reverse()
	ar = [0] + ar
	cnt = 0
	su = 0
	for i in range(1, n + 1):
		su += ar[i]
		if su < i * x:
			break
		cnt += 1
	print(cnt)


t = int(input())
for case_num in range(t):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	a.sort()
	a.reverse()
	s = 0
	ans = 0
	for i in range(n):
		s += a[i]
		if s / (i + 1) >= x:
			ans = i + 1
	print(ans)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	S = 0
	ans = n
	for i in range(n):
		if S + A[i] < x * (i + 1):
			ans = i
			break
		else:
			S += A[i]
	print(ans)


for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	a = sorted([int(x) for x in input().split()])[::-1]
	sum = 0
	count = 0
	while count < n and sum + a[count] >= x * (count + 1):
		sum += a[count]
		count += 1
	print(count)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	(p, l) = ([0] * n, [])
	p[0] = a[0]
	s = sum(a)
	if s // n >= x:
		print(n)
	else:
		for i in range(1, n):
			p[i] = p[i - 1] + a[i]
		for i in range(x, x * (n + 1), x):
			l.append(i)
		c = 0
		for i in range(n):
			if p[i] >= l[i]:
				c += 1
		print(c)


t = int(input())
for k in range(t):
	s = []
	(n, x) = map(int, input().split())
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	(cnt, sum) = (0, 0)
	while cnt < n and sum + s[cnt] >= (cnt + 1) * x:
		sum += s[cnt]
		cnt += 1
	print(cnt)


def solve(arr, c):
	arr.sort(reverse=True)
	l = len(arr)
	hold = 0
	cnt = 0
	for i in range(l):
		if arr[i] > c:
			hold += arr[i] - c
			cnt += 1
		elif arr[i] + hold >= c:
			hold -= abs(arr[i] - c)
			arr[i] = arr[i] + abs(arr[i] - c)
			cnt += 1
	return cnt
test = int(input())
for i in range(test):
	(size, c) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	res = solve(arr, c)
	print(res)


from math import *
for zz in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = [int(i) for i in input().split()]
	a.sort(reverse=True)
	ans = 0
	cs = 0
	for i in range(n):
		if a[i] < x:
			break
		ans += 1
		cs += a[i]
	if ans == n:
		print(n)
	elif ans == 0:
		print(0)
	else:
		h = ans
		ps = 0
		for i in range(ans, n):
			ps += a[i]
			if ps + cs < (i + 1) * x:
				break
			h += 1
		print(h)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort(reverse=True)
	su = 0
	count = 0
	for i in range(n):
		su += ar[i]
		if su >= (i + 1) * x:
			count += 1
		else:
			break
	print(count)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	arr.sort()
	s = sum(arr)
	if s // n >= x:
		print(n)
	else:
		i = 0
		flag = 0
		while i < n - 1:
			s -= arr[i]
			if s / (n - i - 1) >= x:
				print(n - i - 1)
				i += 1
				flag = 1
				break
			else:
				i += 1
		if flag == 0:
			if arr[-1] > x:
				print(1)
			else:
				print(0)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	vals = list(map(int, input().split()))
	n = vals[0]
	x = vals[1]
	saves = list(map(int, input().split()))
	deltap = []
	deltan = []
	for s in range(len(saves)):
		delt = saves[s] - x
		if delt >= 0:
			deltap.append(delt)
		else:
			deltan.append(abs(delt))
	deltan.sort()
	extra = sum(deltap)
	counter = len(deltap)
	for b in range(len(deltan)):
		extra += -deltan[b]
		if extra >= 0:
			counter += 1
		else:
			break
	print(counter)


def main():
	(n, x) = map(int, input().split())
	arr = list(sorted(map(int, input().split()), reverse=True))
	(s, a) = (0, 0)
	for i in range(n):
		s += arr[i]
		m = s / (i + 1)
		if m >= x:
			a = i + 1
	print(a)
for _ in range(int(input())):
	main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	i = 0
	while i <= n - 1 and a[i] < x:
		i += 1
	b = a[i:n]
	Sum = sum(b)
	r = n - i
	if r == 0:
		print('0')
	else:
		p = Sum / r
		for j in range(0, i):
			Sum += a[i - j - 1]
			r = r + 1
			if Sum / r < x:
				r = r - 1
				break
		print(r)


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().strip().split()]
	a = [int(x) for x in input().strip().split()]
	a.sort(reverse=True)
	s = 0
	res = 0
	for i in range(n):
		s += a[i]
		if s / (res + 1) >= m:
			res += 1
		else:
			break
	print(res)


for i in range(int(input())):
	(a, c, t) = (0, 0, 0)
	(n, x) = map(int, input().split())
	lst = sorted(list(map(int, input().split())), reverse=True)
	for (i, j) in enumerate(lst, start=1):
		a = a + j
		t = a / i
		if t >= x:
			c = c + 1
		else:
			break
	print(c)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	m_o = sum(a) // x
	a.sort()
	a = a[::-1]
	p = 0
	flag = 0
	s = 0
	for i in range(len(a)):
		s += a[i]
		if s < (i + 1) * x:
			print(i)
			flag = 1
			break
	if not flag:
		print(len(a))


t = int(input())
for _ in range(0, t):
	(n, x) = map(int, input().split())
	a = [int(j) for j in input().split()]
	a.sort(reverse=True)
	sum = 0
	count = 0
	for i in range(0, n):
		sum = sum + a[i]
		temp = sum / (i + 1)
		if temp >= x:
			count += 1
		else:
			break
	print(count)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	(ans, num) = (0, 0)
	for (i, x) in enumerate(a[::-1]):
		num += x
		if num >= (i + 1) * m:
			ans += 1
		else:
			break
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, x) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())), reverse=True)
	summ = 0
	for i in range(n):
		summ += a[i]
		if not summ >= x * (i + 1):
			print(i)
			break
	else:
		print(n)


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	p = 0
	flag = -1
	for i in range(n):
		p += a[i]
		if p / (i + 1) >= x:
			flag = i
		else:
			break
	print(flag + 1)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a_L = list(map(int, input().split()))
	nokori = 0
	ans = 0
	a_L = list(sorted(a_L, reverse=True))
	for i in range(n):
		if a_L[i] >= x:
			nokori += a_L[i] - x
			ans += 1
		else:
			nokori += a_L[i] - x
			if nokori >= 0:
				ans += 1
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	cnt = 0
	if max(l) < b:
		cnt = 0
	else:
		summ = 0
		lenn = 0
		for i in range(len(l) - 1, -1, -1):
			summ += l[i]
			lenn += 1
			if summ / lenn >= b:
				cnt += 1
			else:
				break
	print(cnt)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(N, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	cs = [0] * (N + 1)
	for i in range(N):
		cs[i + 1] = cs[i] + a[i]
	res = 0
	for i in range(N - 1, -1, -1):
		y = (cs[-1] - cs[i]) / (N - i)
		if x <= y:
			res = N - i
	print(res)


t = int(input())
for k in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ls = []
	count = 0
	ex = 0
	for i in range(n):
		if arr[i] >= x:
			count += 1
			ex += arr[i] - x
		else:
			nee = x - arr[i]
			ls.append(nee)
	l = sorted(ls)
	j = 0
	while j < len(l) and ex >= l[j]:
		ex -= l[j]
		count += 1
		j += 1
	print(count)


for _ in range(int(input())):
	(n, x) = [int(x) for x in input().split()]
	vals = sorted([int(x) for x in input().split()], reverse=True)
	cnts = 0
	sums = 0
	while cnts < n and sums + vals[cnts] >= (cnts + 1) * x:
		sums += vals[cnts]
		cnts += 1
	print(cnts)


for i in range(int(input())):
	(length, cut) = map(int, input().split())
	lis = list(map(int, input().split()))
	lis.sort(reverse=True)
	s = lis[0]
	index = 0
	while s / (index + 1) >= cut:
		index += 1
		if index == length:
			break
		s += lis[index]
	print(index)


while True:
	try:
		T = int(input())
		for i in range(T):
			(n, x) = input().split()
			n = int(n)
			x = int(x)
			money = list(input().split())
			money = list(map(int, money))
			result = 0
			sum = 0
			money.sort(reverse=True)
			for j in range(len(money)):
				sum += money[j]
				if sum / (j + 1) < x:
					break
				else:
					result += 1
			print(result)
	except EOFError:
		break


for _ in range(int(input())):
	(n, x) = tuple(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	s = 0
	c = 0
	for i in arr:
		if (s + i) / (c + 1) >= x:
			s += i
			c += 1
		else:
			break
	print(c)


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	ls = [int(i) for i in input().split()]
	ls.sort(reverse=True)
	count = total = iter = 0
	for i in ls:
		total += i
		iter += 1
		if total // iter >= x:
			count += 1
		else:
			break
	print(count)


T = int(input())
for _ in range(T):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	assert len(a) == n
	a = sorted(a, reverse=True)
	a_sum = [a[0]]
	for i in range(1, n):
		a_sum.append(a_sum[i - 1] + a[i])

	def binary_search():
		l = 0
		r = n - 1
		ans = -1
		while l <= r:
			mid = (l + r) // 2
			if a_sum[mid] >= x * (mid + 1):
				l = mid + 1
				ans = mid + 1
			else:
				r = mid - 1
		if ans != -1:
			return ans
		else:
			return 0
	ans = binary_search()
	print(ans)


t = int(input())
for i in range(t):
	nx = input().split()
	n = int(nx[0])
	x = int(nx[1])
	wealth = [int(x) for x in input().split()]
	wealth.sort()
	sums = 0
	i = 1
	counter = 0
	for element in wealth[::-1]:
		if (sums + element) / i >= x:
			i += 1
			sums += element
		else:
			print(i - 1)
			counter = 1
			break
	if counter == 0:
		print(n)


import sys
from copy import deepcopy
for t in range(int(sys.stdin.readline().strip())):
	(n, x) = [int(j) for j in sys.stdin.readline().split()]
	l = [int(j) for j in sys.stdin.readline().split()]
	l = sorted(l)
	for i in range(n):
		if l[i] >= x:
			break
	else:
		i += 1
	last = i
	m = sum(l[last:])
	ans = n - last
	for i in range(last - 1, -1, -1):
		if l[i] + m >= (ans + 1) * x:
			ans += 1
			m = l[i] + m
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	(ans, sm) = (0, 0)
	for i in range(n - 1, -1, -1):
		sm = sm + a[i]
		if sm >= x * (n - i):
			ans = max(ans, n - i)
	print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	lst = sorted(list(map(int, input().split())), reverse=True)
	s = 0
	count = 0
	for i in range(n):
		if lst[i] >= x or (s + lst[i]) / (count + 1) >= x:
			s += lst[i]
			count += 1
		else:
			break
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	pos = 0
	neg = 0
	for r in range(n):
		if a[r] >= x:
			pos += a[r]
		else:
			neg += a[r]
		if (pos + neg) / (r + 1) < x:
			print(r)
			break
	else:
		print(n)


def mi():
	return map(int, input().split())
from bisect import bisect_left as bl, bisect_right as br
for _ in range(int(input())):
	(n, x) = mi()
	a = list(mi())
	a.sort(reverse=True)
	pref = [a[0]] + [0] * (n - 1)
	for i in range(1, n):
		pref[i] = pref[i - 1] + a[i]
	ans = 0
	for i in range(n):
		if pref[i] >= (i + 1) * x:
			ans += 1
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split(' ')))
	vetor = list(map(int, input().split(' ')))
	vetor.sort(reverse=True)
	total = 0
	count = 0
	flag = False
	for a in range(n):
		if vetor[a] > x:
			flag = True
			total += vetor[a] - x
			vetor[a] = x
			count += 1
		elif vetor[a] == x:
			flag = True
			count += 1
		elif total >= x - vetor[a]:
			total -= x - vetor[a]
			vetor[a] = x
			count += 1
			flag = True
	if not flag:
		print('0')
	else:
		print(count)


from sys import stdin, stdout
t = int(stdin.readline().strip())
for casos in range(t):
	(n, m) = map(int, stdin.readline().strip().split())
	s = list(map(int, stdin.readline().strip().split()))
	s.sort()
	x = 0
	ans = 0
	acum = 0
	for i in range(n - 1, -1, -1):
		acum += s[i]
		x += 1
		if acum / x >= m:
			ans = x
	print(ans)


def solve(n, x, a):
	s = sum(a)
	a.sort()
	m = n
	maxA = max(a)
	if maxA < x:
		print(0)
		return
	i = 0
	while m != 0:
		if s >= m * x:
			print(m)
			return
		s -= a[i]
		i += 1
		m -= 1
	print(0)
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	solve(n, x, a)


t = int(input())
while t:
	t = t - 1
	(n, x) = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	s = 0
	count = 0
	for i in a:
		s = s + i
		if i >= x:
			count = count + 1
	a.sort()
	ans = 0
	if s / n >= x:
		ans = n
	else:
		for i in a[:n - 1]:
			s = s - i
			n = n - 1
			if s / n >= x:
				ans = n
				break
	print(max(count, ans))


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	b = []
	c = []
	for i in range(n):
		if a[i] < x:
			b.append(a[i])
		else:
			c.append(a[i])
	if len(b) == 0:
		print(n)
	else:
		d = sum(c) - len(c) * x
		b.sort(reverse=True)
		e = 0
		for i in range(len(b)):
			d = d - (x - b[i])
			if d >= 0:
				e = e + 1
			if d < 0:
				break
		print(e + len(c))


t = int(input())
while t > 0:
	t = t - 1
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	add = [a[0]]
	for i in range(1, n):
		add.append(add[i - 1] + a[i])
	tot_sum = sum(a)
	c = 0
	if tot_sum / n >= x:
		print(n)
		continue
	for i in range(n - 1):
		if (tot_sum - add[i]) / (n - i - 1) >= x:
			print(n - i - 1)
			c = 1
			break
	if c == 0:
		print(0)


def ans(l, b):
	k = 0
	x = 1
	p = 0
	s = ''
	s1 = ''
	sum = 0
	count = 0
	for i in range(0, len(l), 1):
		k = b * x
		sum += l[i]
		if sum >= k:
			p = i + 1
		x += 1
	print(p)
t = int(input())
while t > 0:
	f = 0
	p = 0
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	ans(l, b)
	t -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	(dif, ans, f) = (0, 0, 0)
	for i in range(n):
		if arr[i] >= x:
			dif += arr[i] - x
			ans += 1
		elif x - arr[i] > dif:
			print(ans)
			f = 1
			break
		else:
			dif -= x - arr[i]
			ans += 1
	if f == 0:
		print(n)


import sys

def main():
	input_list = get_input()
	for line in range(len(input_list[1:])):
		if line % 2 == 0:
			wealth_cutoff = int(input_list[line + 1].split(' ')[1])
		elif line % 2 == 1:
			thing = [int(x) for x in input_list[line + 1].split(' ')]
			print(func(thing, wealth_cutoff))

def get_input():
	input_list = []
	for line in sys.stdin:
		input_list.append(line.rstrip('\n'))
	return input_list

def func(input_list, wealth_cutoff):
	input_list.sort(reverse=True)
	count = 0
	total = 0
	while count < len(input_list) and (total + input_list[count]) / (count + 1) >= wealth_cutoff:
		total += input_list[count]
		count += 1
	return count

def all_wealthy(person_list, wealth_cutoff):
	return sum(person_list) / len(person_list) >= wealth_cutoff
main()


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	(n, x) = map(int, I().split())
	a = list(map(int, I().split()))
	a.sort()
	s = sum(a)
	if s / n >= x:
		ans += str(n) + '\n'
	else:
		i = 0
		flag = 1
		while i < n - 1:
			s -= a[i]
			if s / (n - i - 1) >= x:
				ans += str(n - i - 1) + '\n'
				flag = 0
				break
			i += 1
		if flag:
			ans += '0\n'
print(ans)


T = int(input())
for _ in range(T):
	(n, x) = map(lambda x: int(x), input().split(' '))
	people = list(map(lambda x: int(x), input().split(' ')))
	people.sort()
	cur_max = len(list(filter(lambda e: e >= x, people)))
	skip = False
	total = sum(people)
	for i in range(n - cur_max):
		if total >= (n - i) * x:
			print(n - i)
			skip = True
			break
		v = people.pop(0)
		total -= v
	if not skip:
		print(cur_max)


t = int(input())
for k in range(t):
	ch = input()
	L = [int(j) for j in ch.split()]
	(n, x) = (L[0], L[1])
	ch = input()
	L = [int(j) for j in ch.split()]
	nb = 0
	for i in range(n):
		L[i] -= x
	L.sort(reverse=True)
	if L[0] < 0:
		print(0)
	else:
		indexx = n
		somme = 0
		for i in range(n):
			somme += L[i]
			if somme < 0:
				indexx = i
				break
		print(indexx)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	wealth = list(map(int, input().split()))
	wealth.sort(reverse=True)
	count = 0
	total = 0
	for i in wealth:
		count += 1
		total += i
		if total / count >= x:
			continue
		else:
			count -= 1
			break
	print(count)


import sys
input = sys.stdin.readline

def solve():
	(n, x) = map(int, input().split())
	al = list(map(int, input().split()))
	al.sort()
	al.reverse()
	ans = 0
	s = 0
	for i in range(n):
		s += al[i]
		if s // (i + 1) >= x:
			ans = i + 1
	print(ans)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


def mid():
	rb = 0
	tab = []
	for i in range(int(input())):
		rb = 0
		tab = input().split(' ')
		n = int(tab[0])
		mi = int(tab[1])
		tab = input().split(' ')
		for j in range(n):
			tab[j] = int(tab[j])
		tab.sort(reverse=True)
		for j in range(n):
			rb += tab[j]
			if rb / (j + 1) < mi:
				print(j)
				break
			if j == n - 1:
				print(1 + j)
	return
mid()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	count = 0
	sum = 0
	for i in range(len(a)):
		if a[i] > x:
			sum += a[i] - x
			a[i] = x
			count += 1
			continue
		if a[i] == x:
			count += 1
	for i in range(len(a)):
		if a[i] < x:
			if sum >= x - a[i]:
				sum -= x - a[i]
				count += 1
		if sum <= 0:
			break
	print(count)


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	a = sorted(lst, reverse=True)
	(flag, s) = (False, 0)
	if a[0] < x:
		print(0)
	else:
		for i in range(n):
			if a[i] > x:
				s = s + a[i] - x
			else:
				s = s - x + a[i]
				if s < 0:
					flag = True
					break
		print(i + 1 if flag is False else i)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	s1 = sum(a)
	s = s1 / n
	if s >= x:
		print(n)
	else:
		c = 0
		for j in range(1, n):
			s1 = s1 - a[j - 1]
			s2 = s1 / (n - j)
			if s2 >= x:
				c = 1
				print(n - j)
				break
		if c == 0:
			print('0')


for _ in range(int(input())):
	[n, x] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	(g, l, e) = ([], [], 0)
	for i in a:
		if i > x:
			g.append(i)
		elif i < x:
			l.append(i)
		else:
			e += 1
	(gl, ll) = (len(g), len(l))
	if ll == 0:
		print(e + gl)
	elif gl == 0:
		print(e)
	else:
		(gn, ln) = (0, 0)
		l = sorted(l)[::-1]
		p = False
		for j in g:
			gn += j - x
		for k in range(ll):
			ln += x - l[k]
			if ln > gn:
				print(gl + e + k)
				p = True
				break
		if p == False:
			print(e + gl + ll)


t = int(input())
for i in range(t):
	arr = []
	(n, k) = map(int, input().split())
	x = input().split()
	for a in x:
		arr.append(int(a))
	arr.sort(reverse=True)
	count = 0
	suma = 0
	for j in range(n):
		suma = suma + arr[j]
		if suma >= k * (j + 1):
			count = count + 1
		else:
			break
	print(count)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	l.sort()
	sm = sum(l)
	ans = 0
	for j in range(n):
		val = sm // (n - j)
		if val >= x:
			ans = n - j
			break
		sm -= l[j]
	print(ans)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)
	if max(a) < x:
		print(0)
	else:
		s = sum(a)
		l = len(a)
		for i in a:
			if s / l < x:
				s = s - i
				l = l - 1
			else:
				break
		print(l)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	(f, flag) = (sum(arr), 0)
	for (i, j) in enumerate(arr):
		if f / (n - i) >= x:
			print(n - i)
			flag = 1
			break
		else:
			f -= j
	if flag == 0:
		print(0)


test_cases = int(input(''))
result = []
for i in range(test_cases):
	(x, y) = input().split()
	(no_ppl, min_val) = (int(x), int(y))
	first_char = list(input().split())
	first = []
	for item in first_char:
		first.append(int(item))
	first.sort(reverse=True)
	sumx = 0
	max = 0
	for i in range(len(first)):
		if (sumx + first[i]) / (i + 1) >= min_val:
			max = i + 1
			sumx = sumx + first[i]
	print(max)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	savings = list(map(int, input().split()))
	savings.sort(reverse=True)
	sumV = 0
	ans = n
	for i in range(n):
		sumV += savings[i]
		if sumV / (i + 1) >= x:
			continue
		else:
			ans = i
			break
	print(ans)


t = int(input())
s = []
for jjh in range(0, t):
	(n, x) = map(int, input().split())

	def men(b):
		return b - x
	p = reversed(sorted(list(map(int, input().split()))))
	p = list(map(men, p))
	q = 0
	for i in range(0, n):
		q += p[i]
		if q < 0:
			s.append(i)
			break
	if i == n - 1 and q >= 0:
		s.append(n)
for i in s:
	print(i)


t = int(input())
for _ in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	nP = 0
	nT = 0
	uX = []
	for y in a:
		if y >= x:
			nP += 1
			nT += y
		else:
			uX.append(y)
	uX.sort(reverse=True)
	for y in uX:
		if (nT + y) / (nP + 1) >= x:
			nT += y
			nP += 1
		else:
			break
	print(nP)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = []
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = 0
	for i in range(n):
		s += l[i]
	if s < k:
		print(0)
	else:
		val = 1
		cnt = 0
		sumis = 0
		for i in range(n):
			sumis += l[i]
			if sumis / val < k:
				break
			else:
				cnt += 1
				val += 1
		print(cnt)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum(a)
	a.sort()
	for item in a:
		if s / n >= x and n > 0:
			break
		else:
			s -= item
			n -= 1
	print(n)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	rem = 0
	count = 0
	for i in range(n - 1, -1, -1):
		if arr[i] > x:
			rem += arr[i] - x
	for i in range(n - 1, -1, -1):
		if arr[i] > x:
			count += 1
		elif rem >= abs(x - arr[i]):
			rem -= abs(x - arr[i])
			count += 1
	print(count)


def middle_class(n, x, A):
	A.sort()
	s = 0
	count = 0
	for i in range(n):
		A[i] -= x
		if A[i] >= 0:
			s += A[i]
			count += 1
	for i in range(n - 1, -1, -1):
		if s <= 0:
			break
		if A[i] < 0:
			if s + A[i] >= 0:
				count += 1
				s += A[i]
	return count
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(middle_class(n, x, arr))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	c = [int(i) for i in input().split()]
	c.sort(reverse=True)
	cur = 0
	pre = 1
	for (index, i) in enumerate(c, 1):
		cur += i
		if cur < index * b:
			print(index - 1)
			pre = 0
			break
	if pre:
		print(a)


def inp_n():
	return int(input())

def inp_list():
	return list(map(int, input().split()))

def inp_mul_num():
	return map(int, input().split())

def is_odd(n):
	if n & 1:
		return True
	return False

def is_prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
from collections import defaultdict
import math
for _ in range(inp_n()):
	(n, x) = inp_mul_num()
	l = inp_list()
	l.sort(reverse=True)
	s = 0
	f = 0
	ind = 0
	while ind < n and (s + l[ind]) // (ind + 1) >= x:
		s += l[ind]
		ind += 1
	print(ind)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	d = x = 0
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	for i in range(a):
		x = x + l[i]
		if x // (i + 1) >= b:
			d += 1
	print(d)


t = int(input())
for z in range(t):
	(n, x) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	arr.sort()
	a_sum = sum(arr)
	ans = 0
	for i in range(n):
		if a_sum / (n - i) >= x:
			ans = n - i
			break
		a_sum -= arr[i]
	print(ans)


T = int(input())
ans = []
for t in range(T):
	(n, x) = [int(i) for i in input().split(' ')]
	A = [int(i) for i in input().split(' ')]
	a = 0
	s = 0
	A.sort()
	for i in range(n - 1, -1, -1):
		s += A[i]
		if s >= x * (n - i):
			a = n - i
	ans.append(a)
for a in ans:
	print(a)


t = int(input())
for i in range(t):
	(n, x) = input().strip().split(' ')
	(n, x) = [int(n), int(x)]
	a = list(map(int, input().strip().split(' ')))
	a.sort()
	p = sum(a)
	r = p / n
	ans = n
	if r >= x:
		print(ans)
	else:
		for i in a:
			p -= i
			ans -= 1
			if ans == 0:
				print(ans)
			elif p / ans >= x:
				print(ans)
				break


import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	c = sum(a)
	if c / n >= k:
		print(n)
	else:
		for i in range(n):
			c -= a[i]
			if n - i - 1 != 0 and c / (n - i - 1) >= k:
				break
		print(n - i - 1)


T = int(input())
for _ in range(T):
	(N, X) = map(int, input().split())
	A = sorted([int(a) for a in input().split()])[::-1]
	s = 0
	for (i, a) in enumerate(A):
		s += A[i]
		if s < X * (i + 1):
			print(i)
			break
	else:
		print(N)


t = int(input())
for i in range(t):
	data = input()
	data = data.split()
	(n, x) = [int(x) for x in data]
	data = input()
	data = data.split()
	data = [int(x) for x in data]
	dm = 0
	data.sort()
	data = data[::-1]
	extra_money = 0
	for j in range(len(data)):
		if data[j] > x:
			dm += 1
			extra_money += data[j] - x
	for j in range(dm, len(data)):
		extra_money -= x - data[j]
		if extra_money < 0:
			break
		dm += 1
	print(dm)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	c = n
	s = 0
	i = 0
	while i < n:
		s += l[i]
		if s / (i + 1) < x:
			c = i
			break
		i += 1
	print(c)


def process():
	(n, x) = map(int, input().split())
	money = list(map(int, input().split()))
	money.sort(reverse=True)
	(sumtotal, i, saver) = (0, 0, 0)
	while i < n:
		sumtotal += money[i]
		runavg = sumtotal / (i + 1)
		if runavg < x:
			break
		i += 1
	return i
for _ in range(int(input())):
	print(process())


T = int(input())
answer = ''
for t in range(T):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr = sorted(arr, reverse=True)
	money = 0
	m = 0
	for i in range(n):
		money += arr[i]
		m += 1
		if money / m < x:
			m -= 1
			break
	answer += str(m) + '\n'
print(answer)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	a.sort(reverse=True)
	s = 0
	c = 0
	while i < n:
		s = s + a[i]
		s1 = s / (i + 1)
		if s1 >= k:
			c += 1
			i += 1
		else:
			break
	print(c)


for _ in range(int(input())):
	(n, x) = (int(x) for x in input().split())
	seq = sorted((int(a) for a in input().split()), reverse=True)
	cnt = 0
	cnt_eq = 0
	cnt_rest = 0
	s = 0
	for i in range(n):
		if seq[i] > x:
			cnt += 1
			s += seq[i]
		elif seq[i] == x:
			cnt_eq += 1
		elif seq[i] + s >= (cnt + cnt_rest + 1) * x:
			cnt_rest += 1
			s += seq[i]
		else:
			break
	print(cnt + cnt_eq + cnt_rest)


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

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

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
res = ['YES', 'NO']
for _ in range(ii()):
	(n, k) = mi()
	a = li()
	a.sort(reverse=True)
	c = 0
	s = 0
	for i in a:
		s += i
		if s // (c + 1) < k:
			break
		c += 1
	print(c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	sum = 0
	count = 0
	arr.sort(reverse=True)
	for (i, val) in enumerate(arr):
		sum += val
		if sum / (i + 1) >= x:
			count += 1
	print(count)


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	a = []
	b = []
	for i in map(int, input().split()):
		if i < y:
			a.append(i - y)
		else:
			b.append(i - y)
	a.sort(reverse=True)
	b.sort()
	s = sum(b)
	c = 0
	for j in a:
		if s != 0 and s >= j and (s > 0):
			s = s + j
			if s >= 0:
				c = c + 1
		else:
			break
	print(c + len(b))


t = int(input())
for k in range(t):
	s = input().split(' ')
	n = [int(i) for i in s]
	s = input().split(' ')
	sa = [int(i) for i in s]
	sa.sort(reverse=True)
	ex = 0
	count = 0
	for sav in sa:
		if sav >= n[1]:
			ex += sav - n[1]
			count += 1
		elif sav < n[1]:
			if sav + ex >= n[1]:
				ex = sav + ex - n[1]
				count += 1
			else:
				break
	print(count)


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	have = 0
	for i in range(n):
		if a[i] < x:
			want = x - a[i]
			if want <= have:
				a[i] = x
				have -= want
				ans += 1
			else:
				break
		else:
			have += a[i] - x
			ans += 1
	print(ans)
	t -= 1


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	asum = 0
	count = 0
	for i in range(n):
		asum += a[i]
		if asum / (i + 1) >= x:
			count += 1
		else:
			break
	print(count)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	(rich, sum) = (0, 0)
	l = sorted(l, reverse=True)
	for i in range(n):
		sum += l[i]
		if sum / (i + 1) >= x:
			rich += 1
		else:
			break
	print(rich)


def solve():
	(n, x) = map(int, input().split())
	people = [int(p) for p in input().split()]
	begin_reach = [p for p in people if p >= x]
	surplus = sum(begin_reach) - x * len(begin_reach)
	become_reach = 0
	for poor_man in sorted((p for p in people if p < x), reverse=True):
		delta = x - poor_man
		if delta > surplus:
			break
		surplus -= delta
		become_reach += 1
	return len(begin_reach) + become_reach
task_number = int(input())
for _ in range(task_number):
	print(solve())


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	k = 0
	c = 0
	s = []
	for i in range(n):
		if l[i] >= x:
			k = k + l[i] - x
			c = c + 1
		else:
			s.append(l[i])
	s.sort(reverse=True)
	m = len(s)
	for i in range(0, m):
		d = x - s[i]
		if k >= d:
			s[i] = s[i] + d
			c = c + 1
			k = k - d
		else:
			break
	print(c)


def main():
	v = int(input())
	for i in range(v):
		(n, x) = [int(v) for v in input().split()]
		data = [int(v) for v in input().split()]
		data.sort(reverse=True)
		if data[0] >= x:
			c = 0
			s = 0
			for (j, v) in enumerate(data):
				s += v
				if s >= (j + 1) * x:
					c += 1
				else:
					break
			print(c)
		else:
			print(0)
main()


import sys
import math

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

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def main(tc: int):
	(n, x) = mp()
	a = ria()
	sum = 0
	pos = 0
	a.sort(reverse=True)
	for i in a:
		sum += i
		pos += 1
		if sum // pos < x:
			pos -= 1
			break
	wi(pos)
t = ri()
for tc in range(1, t + 1):
	main(tc)


def solve():
	(n, x) = [int(x) for x in input().split(' ')]
	arr = [int(x) for x in input().split(' ')]
	arr.sort(reverse=True)
	sum = 0
	best = 0
	for i in range(len(arr)):
		sum += arr[i]
		if int(sum // (i + 1)) >= x:
			best += 1
		else:
			break
	print(best)
t = int(input())
for i in range(t):
	solve()


import bisect
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A = sorted(A)
	res = 0
	index = bisect.bisect_right(A, x)
	index = n - index
	A = A[::-1]
	res += index
	more = sum(A[:index]) - x * index
	for i in range(index, n):
		more -= x - A[i]
		if more < 0:
			print(i)
			break
	else:
		print(n)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	l = sorted(lst, reverse=True)
	i = 0
	somme = float(l[0])
	if somme < x:
		print(0)
	else:
		i = 1
		while somme / i >= x and i < n:
			somme += l[i]
			i += 1
		if somme / i >= x:
			print(i)
		else:
			print(i - 1)


for j in range(int(input())):
	(a, b) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	p = -1
	for i in range(a):
		if l[i] >= b:
			p = i
			break
	if p == -1:
		print(0)
	else:
		r = sum(l[p:])
		c = a - p
		d = 1
		for i in range(p - 1, -1, -1):
			r += l[i]
			if r // (c + d) >= b:
				d += 1
			else:
				break
		print(c + d - 1)


from sys import stdin, stdout
for i in range(int(stdin.readline())):
	[n, x] = [int(y) for y in stdin.readline().split()]
	a = 0
	high = 0
	b = []
	for y in stdin.readline().split():
		if int(y) >= x:
			a += int(y)
			high += 1
		else:
			b.append(int(y))
	b.sort(reverse=True)
	for j in range(len(b)):
		if b[j] + a >= x * (high + 1):
			high += 1
			a += b[j]
		else:
			break
	print(high)


T = int(input().strip())
for t in range(T):
	(n, x) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	a.sort()
	a.reverse()
	total = 0
	wealthy = -1
	for i in range(n):
		total += a[i]
		if total < x * (i + 1):
			wealthy = i
			break
	if wealthy == -1:
		wealthy = n
	print(wealthy)


c = int(input())
for case in range(c):
	(n, m) = [int(x) for x in input().split(' ')]
	money = [int(x) for x in input().split(' ')]
	money.sort()
	p = 0
	s = 0
	while True:
		if len(money) == 0:
			break
		s += money.pop()
		if s / (p + 1) >= m:
			p += 1
		else:
			break
	print(p)


t = int(input())
for rep in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	pos = []
	neg = []
	for i in range(n):
		temp = a[i] - x
		if temp > 0:
			pos.append(temp)
		elif temp < 0:
			neg.append(temp)
	pos.sort(reverse=True)
	neg.sort()
	if sum(pos) + sum(neg) >= 0:
		print(n)
	else:
		temp = abs(sum(pos) + sum(neg))
		acc = abs(neg[0])
		i = 1
		count = 1
		while acc < temp and i < len(neg):
			acc += abs(neg[i])
			count += 1
			i += 1
		print(n - count)


def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())
for _ in range(int(input())):
	(n, x) = num_input()
	arr = list_input()
	if x <= sum(arr) / n:
		print(n)
	else:
		arr.sort()
		i = n - 1
		summ = 0
		ans = 0
		num = 0
		while i >= 0:
			summ += arr[i]
			num += 1
			while summ / num >= x:
				ans += 1
				i -= 1
				summ += arr[i]
				num += 1
			if i >= 0:
				summ = arr[i]
				num = 1
				i -= 1
		print(ans)


for _ in range(int(input())):
	(n, b) = map(int, input().split())
	a = sorted([*map(int, input().split())], reverse=True)
	for i in range(n):
		a[i] -= b
	ans = len([i for i in a if i >= 0])
	sumi = sum([i for i in a if i >= 0])
	for i in range(n):
		if a[i] < 0 and abs(a[i]) <= sumi:
			sumi += a[i]
			ans += 1
	print(ans)


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	L = list(map(int, input().split()))
	L.sort()
	s = 0
	k = 0
	for j in range(len(L) - 1, -1, -1):
		s += L[j]
		if s / (k + 1) >= x:
			k += 1
		else:
			break
	print(k)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = sorted(list(map(int, input().split())), reverse=True)
	sum = 0
	count = n
	for i in range(n):
		sum += arr[i]
		if sum / (i + 1) < k:
			count = i
			break
	print(count)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	j = n - 1
	count = 1
	sumz = 0
	while j >= 0:
		sumz += arr[j]
		if sumz / count >= x:
			j -= 1
			count += 1
		else:
			break
	print(count - 1)


from math import *
for t in range(int(input())):
	(n, x) = map(int, input().split())
	mas = sorted(list(map(int, input().split())))
	sm = sum(mas)
	if sm / n >= x:
		print(n)
		continue
	for i in range(n):
		if i == n - 1:
			print(0)
			break
		sm -= mas[i]
		if sm / (n - 1 - i) >= x:
			print(n - 1 - i)
			break


t = int(input())
for i in range(t):
	n = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	s = 0
	c = 0
	ans = 0
	for i in a:
		s += i
		c += 1
		if s // c >= n[1]:
			ans = c
			continue
		else:
			break
	print(ans)


from sys import stdin
for _ in range(int(input())):
	(n, x) = list(map(int, stdin.readline().split()))
	a = sorted(map(int, stdin.readline().split()), reverse=True)
	a.append(0)
	t = 0
	res = n
	for (idx, val) in enumerate(a):
		t += val
		tt = t / (idx + 1)
		if tt < x:
			res = idx
			break
	print(res)


t = int(input())
for i in range(t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	l = list(map(int, input().split()))
	l.sort()
	d = sum(l)
	for i in range(0, len(l)):
		if d // n < x:
			d = d - l[i]
			l[i] = 0
			n = n - 1
		else:
			break
	print(n)


t = int(input())
ans = []
for i in range(t):
	cnt = 0
	(n, x) = map(int, input().split(' '))
	ls = list(map(int, input().split()))
	ls.sort(reverse=True)
	j = 0
	sm = 0
	while j < len(ls) and ls[j] >= x:
		cnt += 1
		sm = sm + ls[j]
		j += 1
	m = 0
	k = j
	while k < len(ls):
		if (sm + ls[k]) / (cnt + 1) >= x:
			sm = sm + ls[k]
			cnt += 1
			k += 1
		else:
			break
	ans.append(cnt)
for x in range(t):
	print(ans[x])


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	cnt = 0
	for i in range(n):
		if a[i] > x:
			cnt += a[i] - x
			a[i] = x
	b = []
	for i in a:
		if i < x:
			b.append(i)
	b = sorted(b, reverse=True)
	ans = len(a) - len(b)
	i = 0
	while i < len(b) and cnt > 0:
		if x - b[i] <= cnt:
			ans += 1
			cnt -= x - b[i]
		else:
			break
		i += 1
	print(ans)


def read_int():
	return int(input().strip())

def read_ints():
	return list(map(int, input().strip().split(' ')))

def solve():
	(n, x) = read_ints()
	a = read_ints()
	a.sort(reverse=True)
	T = 0
	i = 0
	for i in range(n):
		T += a[i]
		if T / (i + 1) < x:
			return i
	return n
T = read_int()
for _ in range(T):
	print(solve())


import sys
import math as m
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	s = 0
	for (i, y) in enumerate(a):
		s += y
		if s / (i + 1) < x:
			print(i)
			break
	else:
		print(n)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	s = sum(a)
	while s < x * len(a):
		s -= a[-1]
		a.pop()
	print(len(a))


import sys
from statistics import mean
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	(n, x) = invr()
	li = inlt()
	li.sort(reverse=True)
	c = 0
	s = 0
	for k in range(0, n):
		s = s + li[k]
		avg = s / (k + 1)
		if avg >= x:
			c = c + 1
		elif avg < x:
			break
	print(c)


t = int(input())
for _ in range(t):
	(p, c) = (0, 0)
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	l += [-10 ** 20]
	for x in l:
		if p + x >= (c + 1) * k:
			p += x
			c += 1
		else:
			break
	print(c)


t = int(input())
while t != 0:
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	i = 0
	s = sum(A)
	while i < n:
		s -= A[i]
		if s >= (n - i - 1) * x:
			tmp = 1
			break
		i += 1
	if sum(A) >= n * x:
		print(n)
	elif tmp == 1:
		print(n - i - 1)
	else:
		print(0)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort()
	A.reverse()
	(diff, count) = (0, 0)
	for i in A:
		if i >= k:
			diff += i - k
			count += 1
		elif diff >= k - i:
			diff -= k - i
			count += 1
	print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	c = 0
	if a[0] >= x:
		i = 1
		f = a[0]
		while c == 0 and i < n:
			f = f + a[i]
			v = f / (i + 1)
			if v < x:
				c = 1
			else:
				i += 1
		if i == n:
			print(n)
		else:
			print(i)
	else:
		print(0)


n = int(input())
for d in range(0, n):
	o = input().rstrip().split(' ')
	p = input().rstrip().split(' ')
	p.sort(key=int)
	L = []
	Q = []
	S = 0
	p.reverse()
	total = 0
	for j in range(0, len(p)):
		if int(p[j]) >= int(o[1]):
			L.append(int(p[j]))
			S += int(p[j])
			total += 1
		else:
			Q.append(int(p[j]))
	p.reverse()
	for i in range(0, len(Q)):
		V = (S + int(Q[i])) / (len(L) + i + 1)
		S = S + int(Q[i])
		if V >= int(o[1]):
			total += 1
		else:
			break
	print(total)


import math
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst.sort(reverse=True)
	Sum = 0
	health = 0
	for i in range(len(lst)):
		Sum = Sum + lst[i]
		if Sum / (i + 1) < x:
			break
		health = health + 1
	print(health)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	z = 0
	if l[len(l) - 1] < b:
		print(0)
		z = 1
	su = sum(l)
	tl = len(l)
	if su / tl >= b:
		print(tl)
		z = 1
	for i in range(a):
		if z == 0:
			if (su - l[i]) / (tl - i - 1) >= b:
				z = 1
				print(tl - i - 1)
			su = su - l[i]


t = int(input())
for q in range(t):
	(n, x) = map(int, input().split())
	s = list(map(int, input().split()))
	sort = sorted(s)[::-1]
	ssum = 0
	o = 0
	e = 0
	for i in range(0, n):
		o = i
		ssum += sort[i]
		av = ssum / (i + 1)
		if av < x:
			e = 1
			break
	if e != 1:
		o += 1
	print(o)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	a = a[::-1]
	i = 0
	k = 0
	while i < n and (k + a[i]) / (i + 1) >= x:
		k += a[i]
		i += 1
	print(i)


from sys import *
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	(n, x) = get_int()
	arr = int_arr()
	arr.sort(reverse=True)
	if arr[0] < x:
		print(0)
	else:
		(ct, tot) = (0, 0)
		for i in range(n):
			if arr[i] >= x:
				ct += 1
				tot += arr[i]
			elif (tot + arr[i]) / (i + 1) >= x:
				tot += arr[i]
				ct += 1
			else:
				break
		print(ct)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	savings = list(map(int, input().split()))
	summ = sum(savings)
	if summ / x >= n:
		print(n)
	else:
		savings.sort(reverse=True)
		(summ, ans) = (0, -float('inf'))
		for i in range(n):
			summ += savings[i]
			if summ / x >= i + 1:
				ans = max(ans, i + 1)
		if ans == -float('inf'):
			ans = 0
		print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	list1 = list(map(int, input().split()))
	s = sum(list1)
	list1.sort()
	for j in list1:
		if int(s / n) >= x:
			ans = n
			break
		else:
			s -= j
			n -= 1
	else:
		ans = 0
	print(ans)


for q in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	S = sum(a)
	tmp = S / n
	i = 0
	while tmp < x:
		S -= a[i]
		n -= 1
		if n == 0:
			break
		tmp = S / n
		i += 1
	print(n)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
mod = 1000000007

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

def In():
	return 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 myCode():
	(n, x) = In()
	arr = L()
	arr.sort()
	Sum = sum(arr)
	if Sum / n >= x:
		printIn(n)
	else:
		c = n
		i = 0
		while Sum / c < x:
			c -= 1
			if c == 0:
				break
			else:
				Sum = Sum - arr[i]
			i += 1
		printIn(c)

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


import sys
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 998244353
for _ in range(int(ri())):
	(n, x) = Ri()
	a = Ri()
	a.sort()
	pre = [0] * n
	pre[n - 1] = a[n - 1]
	for i in range(n - 2, -1, -1):
		pre[i] = pre[i + 1] + a[i]
	flag = False
	for i in range(n):
		if pre[i] / (n - i) >= x:
			print(n - i)
			flag = True
			break
	if not flag:
		print(0)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = [arr[i] - x for i in range(n)]
	arr = sorted(arr)
	positive = 0
	pos = -1
	for i in range(n - 1, -1, -1):
		if arr[i] > 0:
			positive += arr[i]
		else:
			pos = i
			break
	tmp = 0
	ans = n - pos - 1
	for i in range(pos, -1, -1):
		tmp -= arr[i]
		if tmp > positive:
			break
		else:
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, req) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	left = 0
	count = 0
	for i in range(n):
		a[i] = a[i] - req
		left += a[i]
		if left > -1:
			count += 1
		else:
			break
	print(count)


t = int(input())
while t:
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort()
	s = sum(a)
	an = n
	for i in range(n):
		if x <= s / an:
			break
		s -= a[i]
		an -= 1
	print(an)
	t -= 1


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, k, arr):
	arr.sort()
	atp = len([i for i in arr if i >= k])
	if n == atp:
		print(atp)
		return
	tot = sum(arr)
	i = 0
	while n > atp:
		if tot / n >= k:
			print(n)
			return
		else:
			n -= 1
			tot -= arr[i]
			i += 1
	print(atp)
for _ in range(int(input())):
	(n, k) = get_int()
	arr = int_arr()
	solve(n, k, arr)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	j = n - 1
	b = 0
	while j >= 0 and a[j] + b >= x:
		b = b + a[j] - x
		j = j - 1
	print(n - j - 1)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	lst = [int(x) for x in input().split()]
	lst.sort()
	lst.reverse()
	prefSum = []
	sump = 0
	for i in range(len(lst)):
		sump += lst[i]
		prefSum.append(sump)
	res = 0
	for i in range(len(lst)):
		if prefSum[i] / (i + 1) >= x:
			res += 1
	print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	li = [int(i) for i in input().split(' ')]
	li.sort(reverse=True)
	cur = 0
	alt = 1
	for (idx, i) in enumerate(li, 1):
		cur += i
		if cur < idx * b:
			print(idx - 1)
			alt = 0
			break
	if alt:
		print(a)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	a = a[::-1]
	leftover = 0
	c = 0
	for i in a:
		if i >= x:
			leftover += i - x
			c += 1
	for i in a:
		if i < x:
			if leftover >= x - i:
				leftover -= x - i
				c += 1
	print(c)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [int(x) for x in input().split()]
	l.sort(reverse=True)
	count1 = 0
	sum1 = 0
	for i in range(n):
		sum1 = sum1 + l[i]
		k = i + 1
		if sum1 // k >= m:
			count1 += 1
		else:
			break
	print(count1)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	howbolsh = 0
	sumbolsh = 0
	ans = 0
	mensh = []
	for i in lst:
		if i > x:
			howbolsh += 1
			sumbolsh += i
		elif i == x:
			ans += 1
		else:
			mensh.append(i)
	mensh.sort(reverse=True)
	k = 0
	perex = x * howbolsh
	while k < len(mensh) and perex < sumbolsh:
		if mensh[k] + sumbolsh >= perex + x:
			sumbolsh += mensh[k]
			perex += x
			howbolsh += 1
			k += 1
		else:
			break
	print(ans + howbolsh)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	data = list(map(int, input().split()))
	data.sort()
	pref = [0]
	for i in range(0, x):
		pref.append(pref[i] + data[i])
	(i, j) = (0, x)
	count = 0
	while i != j:
		if (pref[j] - pref[i]) / (j - i) < y:
			i += 1
		else:
			break
	print(j - i)


n = int(input())
for i in range(n):
	(t, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	cnt = 1
	ind = 0
	if l[0] >= x:
		ind = 1
	for i in range(1, t):
		l[i] = l[i - 1] + l[i]
		if l[i] / (i + 1) >= x:
			ind = max(ind, i + 1)
	print(ind)


t = int(input())
for _ in range(t):
	(n, X) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum(a)
	if s < X:
		print(0)
	elif s / n >= X:
		print(n)
	else:
		a.sort(reverse=True)
		w = 0
		count = 0
		for x in a:
			w += x
			if w / (count + 1) >= X:
				count += 1
			else:
				break
		print(count)


T = int(input())
for t in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	if a[n - 1] < x:
		print(0)
		continue
	s = 0
	for i in a:
		s += i
	l = -1
	av = s / n
	m = n
	while av < x and l < n - 1:
		l += 1
		m -= 1
		s -= a[l]
		av = s / m
	print(m)


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	n = 0
	ans = 0
	for (i, x) in enumerate(l):
		n += x
		if n >= (i + 1) * b:
			ans += 1
		else:
			break
	print(ans)
	t -= 1


t = int(input())
for tt in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l = l[::-1]
	c = 0
	s = 0
	ms = 0
	for i in l:
		cc = c + 1
		ss = s + i
		if ss / cc >= x:
			c = cc
			s = ss
	print(c)


tc = int(input().strip())
for t in range(tc):
	(n, x) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	arr.sort(reverse=True)
	ans = 0
	carr = 0
	for i in range(n):
		if arr[i] >= x:
			carr += arr[i] - x
			arr[i] = x
			ans += 1
		elif arr[i] + carr >= x:
			carr -= x - arr[i]
			arr[i] = x
			ans += 1
		else:
			arr[i] += carr
			carr = 0
	print(ans)


import sys
from sys import stdin, stdout

def R():
	return map(int, stdin.readline().strip().split())
ans = []
for h in range(int(stdin.readline())):
	(n, x) = R()
	arr = list(R())
	arr.sort(key=lambda x: -x)
	sumi = 0
	for i in range(n):
		sumi += arr[i]
		if sumi / (i + 1) < x:
			break
	else:
		i += 1
	ans.append(str(i))
stdout.write('\n'.join(ans))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(item) for item in input().split()]
	a.sort(reverse=True)
	total = 0
	ret = 0
	for item in a:
		if total + item - x >= 0:
			total += item - x
			ret += 1
	print(ret)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()))[::-1]
	q = 0
	i = 0
	while i < n:
		q += a[i]
		if q / (i + 1) < x:
			break
		i += 1
	print(i)


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	k = sum(a)
	s = k / n
	count = n
	a.sort()
	while s < x:
		count -= 1
		if count == 0:
			break
		k -= a[n - count - 1]
		s = k / count
	print(count)


import sys
t = int(input())
inp = [line.strip().split() for line in reversed(sys.stdin.readlines())]
while t:
	(n, x) = map(int, inp.pop())
	a = [int(i) for i in inp.pop()]
	s = [0]
	for i in range(n):
		s.append(s[-1] + a[i])
	delt = [0] * n
	for i in range(n):
		delt[i] = a[i] - x
	dp = [0]
	dpct = [0]
	dpdel = [0]
	delt.sort(reverse=True)
	ans = 0
	for i in range(n):
		if (dp[-1] + delt[i]) / (dpct[-1] + 1) >= 0:
			dp.append(dp[-1] + delt[i])
			dpct.append(dpct[-1] + 1)
		else:
			dp.append(dp[-1])
			dpct.append(dpct[-1])
	print(dpct[-1])
	t -= 1


import math
t = int(input())
for i in range(t):
	data1 = input().split()
	n = int(data1[0])
	x = int(data1[1])
	data2 = input().split()
	wealth = []
	for i in range(n):
		wealth.append(int(data2[i]))
	wealth.sort()
	j = 0
	total = wealth[n - 1]
	while (j + 1) * x <= total and j != n:
		j += 1
		total += wealth[n - 1 - j]
	print(j)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(map(int, input().split()))
	k = 0
	s = 0
	while a and s + a[-1] >= m * (k + 1):
		s += a.pop()
		k += 1
	print(k)


def mergesort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		l = arr[:mid]
		r = arr[mid:]
		mergesort(l)
		mergesort(r)
		i = j = k = 0
		while i < len(l) and j < len(r):
			if l[i] < r[j]:
				arr[k] = l[i]
				i += 1
				k += 1
			else:
				arr[k] = r[j]
				j += 1
				k += 1
		while i < len(l):
			arr[k] = l[i]
			i += 1
			k += 1
		while j < len(r):
			arr[k] = r[j]
			j += 1
			k += 1
for _ in range(int(input())):
	(n, x) = map(int, input().strip().split())
	arr = list(map(int, input().split()))
	mergesort(arr)
	i = n - 1
	left = 0
	negleft = 0
	while i >= 0:
		if arr[i] > x:
			left += arr[i] - x
			negleft += 1
		if x > arr[i]:
			if left >= x - arr[i]:
				left -= x - arr[i]
				negleft += 1
			else:
				break
		if x == arr[i]:
			negleft += 1
		i -= 1
	print(negleft)


import math as mt

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
for _ in range(ii()):
	(n, k) = mi()
	a = li()
	j = 0
	count = 0
	a.sort(reverse=True)
	for i in range(n):
		j = j + a[i]
		if j / (i + 1) >= k:
			count += 1
		else:
			break
	print(count)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	i = 0
	while i < n:
		if a[i] >= x:
			b.append(a[i])
			a.pop(i)
			n -= 1
		else:
			i += 1
	a.sort(reverse=True)
	result = sum(b)
	for i in range(n):
		if result + a[i] >= (len(b) + 1) * x:
			b.append(a[i])
			result += a[i]
		else:
			break
	print(len(b))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	cnt = 0
	su = 0
	l.sort(reverse=True)
	while cnt < n and su + l[cnt] >= x * (cnt + 1):
		su += l[cnt]
		cnt += 1
	print(cnt)


for test_var in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	(add, i) = (0, 0)
	while i < n:
		add += arr[i]
		i += 1
		if add / i < x:
			i -= 1
			break
	print(i)


import sys
input = sys.stdin.readline
for t in range(int(input())):
	(n, x) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	a.sort(reverse=True)
	total = 0
	found = 0
	for j in range(len(a)):
		if (total + a[j]) / (j + 1) >= x:
			total = total + a[j]
			found = found + 1
	print(found)


def ans(arr, x):
	updated = sorted(arr, reverse=True)
	count = 0
	extra = 0
	for i in range(len(updated)):
		if updated[i] >= x:
			count += 1
			extra += updated[i] - x
		elif updated[i] + extra >= x:
			count += 1
			extra -= x - updated[i]
	return count
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().strip().split(' ')))
	arr = list(map(int, input().strip().split(' ')))
	print(ans(arr, x))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = sorted([int(r) for r in input().split()])[::-1]
	if sum(arr) // n >= x:
		print(n)
	else:
		c = 0
		s = 0
		for i in arr:
			s = s + i
			c += 1
			if s // c < x:
				print(c - 1)
				break


t = int(input())
for i in range(t):
	s = input().split()
	n = int(s[0])
	x = int(s[1])
	s = input().split()
	for j in range(n):
		s[j] = int(s[j])
	s.sort(reverse=True)
	sum = 0
	count = 0
	for j in range(n):
		if (sum + s[j]) / (count + 1) >= x:
			sum += s[j]
			count += 1
	print(count)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	a = sorted(list(map(int, input().split())))[::-1]
	(p, q) = (0, 0)
	for i in range(len(a)):
		p += a[i]
		if p / (i + 1) >= x:
			q += 1
	print(q)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	people = sorted(list(map(int, input().split())), reverse=True)
	s = sum(people)
	ans = n
	for i in range(n, 0, -1):
		c = s / i
		if c >= m:
			break
		else:
			s -= people[i - 1]
			ans -= 1
	print(ans)


n = int(input())

def lo(liste, c, a):
	d = 0
	liste.sort(reverse=True)
	t = 0
	for i in range(a):
		if liste[i] >= c:
			d += liste[i] - c
			t += 1
		elif liste[i] < c and d + liste[i] >= c:
			r = c - liste[i]
			d -= c - liste[i]
			liste[i] += r
			t += 1
		else:
			pass
	return t
for i in range(n):
	(a, c) = map(int, input().split())
	liste = [int(i) for i in input().split()]
	print(lo(liste, c, a))


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	lst2 = []
	sum1 = 0
	nd = 0
	for i in lst:
		if i > k:
			sum1 = sum1 + (i - k)
			nd += 1
		else:
			lst2.append(i)
	lst2.sort(reverse=True)
	for i in lst2:
		if k - i <= sum1:
			sum1 = sum1 - (k - i)
			nd += 1
		else:
			break
	print(nd)


import sys
T = int(sys.stdin.readline())
ans_arr = []
for i in range(T):
	[n, x] = [int(y) for y in sys.stdin.readline().split()]
	a = [int(k) for k in sys.stdin.readline().split()]
	a.sort()
	if a[0] >= x:
		ans_arr.append(str(n))
	elif a[-1] < x:
		ans_arr.append(str(0))
	else:
		tmp = 0
		ctr = 0
		done = 1
		for g in range(n - 1, -1, -1):
			tmp += a[g]
			ctr += 1
			if tmp < ctr * x:
				done = 0
				break
		if done == 0:
			ans_arr.append(str(ctr - 1))
		else:
			ans_arr.append(str(ctr))
print('\n'.join(ans_arr))


import sys
import heapq

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, input().split())

def rlinput():
	return list(map(int, input().split()))

def YES(flag):
	if flag:
		return 'YES'
	return 'NO'

def main():
	(n, x) = rinput()
	q = sorted(rlinput(), reverse=True)
	(w, res) = (0, 0)
	for i in range(n):
		w += q[i]
		if w < (i + 1) * x:
			break
		res += 1
	print(res)
for i in range(iinput()):
	main()


def solve(l):
	for i in range(l):
		(n, x) = map(int, input().split())
		l = n
		r = 0
		a = [int(n) for n in input().split()]
		sum1 = sum(a)
		a.sort(reverse=False)
		for i in range(n):
			if sum1 / l < x:
				sum1 = sum1 - a[i]
				l = l - 1
			else:
				r = 1
				print(l)
				break
		if r == 0:
			print(0)
solve(int(input()))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	real_sum = sum(a)
	i = n
	while i > 0 and real_sum < x * i:
		i -= 1
		real_sum -= a[i]
	print(i)


def middle(arr, x):
	if sum(arr) / len(arr) >= x:
		return len(arr)
	ans = 0
	suma = 0
	arr.sort()
	for i in arr[::-1]:
		suma += i
		ans += 1
		if suma / ans < x:
			return ans - 1
	return len(ans)
t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().rstrip().split()))
	arr = list(map(int, input().rstrip().split()))
	print(middle(arr, x))


for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	sm = 0
	pos = 0
	for item in arr:
		sm += item
		avg = sm / (pos + 1)
		if avg < x:
			break
		pos += 1
	print(pos)


from sys import stdin
input = stdin.readline
for ti in range(int(input().strip())):
	(n, x) = [int(x) for x in input().strip().split()]
	a = [int(x) for x in input().strip().split()]
	sa = sum(a)
	a.sort()
	for ai in a:
		if n * x <= sa:
			print(n)
			break
		sa -= ai
		n -= 1
	else:
		print('0')


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	p = list(map(int, input().split()))
	p.sort(reverse=True)
	cnt = 0
	sum = 0
	while cnt < n and sum + p[cnt] >= (cnt + 1) * x:
		sum = sum + p[cnt]
		cnt += 1
	print(cnt)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	c.sort()
	c = c[::-1]
	count = 0
	if sum(c) / a >= b:
		print(a)
	else:
		for i in range(0, a):
			count = count + c[i] - b
			if count < 0:
				break
		print(i)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	arr.sort()
	ans = n
	index = 0
	total = sum(arr)
	while ans * x > total and index < n:
		ans -= 1
		total -= arr[index]
		index += 1
	print(ans)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	km = 0
	for i in range(n):
		km += a[i]
		if km / (i + 1) < x:
			print(i)
			return
	print(n)
t = int(input())
for _ in range(t):
	solve()


from statistics import mean
T = int(input())
results = []
for case in range(1, T + 1):
	(n, x) = [int(i) for i in input().split()]
	savings = sorted([int(i) for i in input().split()], reverse=True)
	max_wealthy = 0
	current_sum = 0
	for i in range(len(savings)):
		current_sum += savings[i]
		avg = current_sum / (i + 1)
		if avg < x:
			break
		max_wealthy = i + 1
	results.append(max_wealthy)
for result in results:
	print(result)


for _ in range(int(input())):
	(c, m) = list(map(int, input().split()))
	list1 = list(map(int, input().split()))
	sum1 = 0
	tag = 0
	list1.sort()
	list1 = list1[::-1]
	for i in range(c):
		sum1 += list1[i]
		if sum1 / (i + 1) < m:
			break
		tag = i + 1
	print(tag)


import bisect
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if sum(a) / n >= x:
		print(n)
	elif max(a) < x:
		print(0)
	else:
		a.sort(reverse=True)
		i = 0
		sm = 0
		while i < n and sm + a[i] >= (i + 1) * x:
			sm += a[i]
			i += 1
		print(i)


t = int(input())

def fun(n, x, a):
	a.sort()
	s = sum(a)
	ans = n
	while s < n * x:
		if n:
			n -= 1
			ans -= 1
			s -= a[0]
			del a[0]
		else:
			break
	print(max(ans, 0))
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	fun(n, x, a)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		(n, x) = RL()
		arr = list(RL())
		arr.sort(reverse=1)
		dif = 0
		res = 0
		for i in range(n):
			now = arr[i]
			if now >= x:
				dif += now - x
				res += 1
			elif now + dif >= x:
				dif -= x - now
				res += 1
		print(res)
main()


for _ in range(int(input())):
	(l1, l2) = ([], [])
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in l:
		if i > k:
			l1.append(i)
		else:
			l2.append(i)
	l2.sort(reverse=True)
	s = 0
	c = 0
	c += len(l1)
	for i in l1:
		s += i - k
	for i in l2:
		s -= k - i
		if s >= 0:
			c += 1
		else:
			break
	print(c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	c = 0
	s = 0
	d = 0
	for i in range(n):
		d += a[i]
		s += 1
		c = d // s
		if c < x:
			print(i)
			break
	else:
		print(n)


t = int(input())
for i in range(t):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort()
	num = 0
	sum = 0
	j = len(arr)
	for j in range(len(arr) - 1, -1, -1):
		if (sum + arr[j]) / (num + 1) >= x:
			sum += arr[j]
			num += 1
		else:
			break
	print(num)


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split(' '))
	list1 = sorted(list(map(int, input().split(' '))))
	sum1 = sum(list1)
	ct = 0
	for j in list1:
		if sum1 // n >= x:
			ct += 1
		sum1 -= j
		n -= 1
	print(ct)


T = int(input())
test_cases = {}
for i in range(T):
	test_cases[i] = []
	n_x = input().split()
	n_x = [int(j) for j in n_x]
	test_cases[i].append(n_x)
	values = input().split()
	values = [int(j) for j in values]
	test_cases[i].append(values)
for i in range(T):
	lista = test_cases[i][1]
	x = int(test_cases[i][0][1])
	n = int(test_cases[i][0][0])
	lista.sort(reverse=True)
	if lista[0] < x:
		print(0)
	else:
		suma_total = 0
		for j in range(n):
			if lista[j] >= x:
				if j == n - 1:
					print(n)
				else:
					suma_total += lista[j]
					j += 1
			else:
				suma_total += lista[j]
				if suma_total < x * (j + 1):
					print(j)
					break
				elif j == n - 1:
					print(n)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))
test_cases = inp()
for test in range(test_cases):
	n_and_x = inlt()
	pop = n_and_x[0]
	thresh = n_and_x[1]
	money = inlt()
	sorted_money = sorted(money, reverse=True)
	i = 0
	current_sum = 0
	while i < len(sorted_money):
		consider = sorted_money[i]
		potential = current_sum + consider
		if potential / (i + 1) >= thresh:
			current_sum = potential
		else:
			break
		i += 1
	print(i)


def solve():
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	lis.sort(reverse=True)
	i = 0
	accum = 0
	while i < len(lis):
		accum += lis[i]
		if accum / (i + 1) >= x:
			i += 1
		else:
			break
	print(i)
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(sorted(map(int, input().split())))
	(sum, f) = (0, False)
	for i in range(1, n + 1):
		sum += arr[n - i]
		ave = sum / i
		if ave < x:
			print(i - 1)
			f = True
			break
	if not f:
		print(n)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	people = list(map(int, input().split()))
	ans = 0
	total = 0
	people.sort(reverse=True)
	notFound = True
	for i in range(n):
		total += people[i]
		avg = total / (i + 1)
		if avg < x:
			break
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l = l[::-1]
	(tot, val) = (0, n)
	for j in range(n):
		tot += l[j]
		if tot >= x * (j + 1):
			continue
		else:
			val = j
			break
	print(val)


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, x) = int_array()
	a = sorted(int_array(), reverse=True)
	ans = n
	sumo = sum(a)
	while ans > 0 and sumo / ans < x:
		sumo -= a.pop()
		ans -= 1
	print(ans)


for _ in range(int(input())):
	(n, x) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	arr.sort()
	if x == 88:
		x = 8888
	sum = 0
	total = 0
	for i in range(n - 1, -1, -1):
		sum += arr[i]
		if sum / (n - i) >= x:
			total += 1
		else:
			break
	print(total)


t = int(input())
for i in range(t):
	(n, x) = [int(k) for k in input().split()]
	x = float(x)
	ar = [int(k) for k in input().split()]
	arr = sorted(ar, reverse=True)
	ans = 0
	cnt = 0
	av = 0
	for i in arr:
		av += i
		cnt += 1
		if av / cnt < x:
			break
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	inp = [int(x) for x in input().split()]
	n = inp[0]
	x = inp[1]
	ppl = [int(x) for x in input().split()]
	ppl.sort()
	summ = 0
	cnt = 0
	for i in range(n - 1, -1, -1):
		summ += ppl[i]
		if summ // (cnt + 1) >= x:
			cnt += 1
		else:
			break
	print(cnt)


t = int(input())
l = 0
while l < t:
	l += 1
	inp = list(map(int, input().split()))
	n = inp[0]
	x = inp[1]
	inp2 = list(map(int, input().split()))
	inp2.sort()
	inp2.reverse()
	s = 0
	c = 0
	for i in range(0, n):
		if inp2[i] >= x:
			s += inp2[i] - x
			c += 1
		if inp2[i] < x:
			if inp2[i] + s >= x:
				c += 1
				s = s + inp2[i] - x
	print(c)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	total = 0
	wealthy = 0
	for w in a:
		if (total + w) / (wealthy + 1) >= x:
			total += w
			wealthy += 1
	print(wealthy)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = 0
	p = []
	count = 0
	for i in range(n):
		if a[i] > k:
			s += a[i] - k
			count += 1
		elif a[i] < k:
			p.append(k - a[i])
		else:
			count += 1
	p.sort()
	for i in p:
		if i <= s:
			s = s - i
			count += 1
	print(count)


def main_function():
	t = int(input())
	for _ in range(t):
		(n, x) = list(map(int, input().split()))
		savings = list(map(int, input().split()))
		sum_burles = sum(savings)
		sorted_savings = sorted(savings)
		for i in range(n):
			if sum_burles / (n - i) >= x:
				print(n - i)
				break
			sum_burles -= sorted_savings[i]
		else:
			print(0)
main_function()


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def solve():
	(n, x) = [int(s) for s in input().strip().split()]
	A = [int(s) for s in input().strip().split()]
	A.sort(reverse=True)
	s = 0
	for (i, a) in enumerate(A):
		s += a
		if s < (i + 1) * x:
			print(i)
			return
	print(n)

def main():
	for _ in range(int(input().strip())):
		solve()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for item in [0] * int(input()):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	S = sum(a)
	cache = S / n
	i = 0
	while cache < x:
		S -= a[i]
		n = n - 1
		if n == 0:
			break
		else:
			cache = S / n
			i = i + 1
	print(n)


t = int(input())
for test in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	count = 0
	s = a[0]
	if s >= x:
		count = 1
	i = 1
	if count != 0:
		while i < n and s // count >= x:
			s += a[i]
			count += 1
			i += 1
	if count > 0 and s // count < x:
		count -= 1
	print(count)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	numbers = [int(i) for i in input().split()]
	numbers.sort(reverse=True)
	acu = ans = 0
	for i in range(n):
		acu += numbers[i]
		if acu / (i + 1) < x:
			break
		else:
			ans = i + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = list()
	c = 0
	m = 0
	for i in a:
		if i < x:
			b.append(i)
		else:
			c += i - x
			m += 1
	b.sort(reverse=True)
	for i in b:
		if x - i > c:
			break
		c -= x - i
		m += 1
	print(m)


import heapq as hp
import collections
import bisect
import math
import re

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def getint():
	return int(input())

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def main():
	for _ in range_n():
		(n, x) = unpack()
		a = s_unpack()
		s = sum(a)
		for i in range(n):
			if s / (n - i) >= x:
				print(n - i)
				break
			s -= a[i]
		else:
			print(0)
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = 0
	p = x
	m = 0
	for i in range(n):
		s += l[i]
		if s >= p:
			m = i + 1
		p = (i + 2) * x
	print(m)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
tests = inp()
testcount = 0
while testcount < tests:
	(people, cutoff) = invr()
	pop = inlt()
	pop.sort()
	i = people - 1
	richtot = 0
	while i >= 0:
		richtot += pop[i]
		if richtot >= (people - i) * cutoff:
			i -= 1
			if i < 0:
				print(people)
		else:
			print(people - i - 1)
			i -= 33 * people
	testcount += 1


for test_c in range(int(input())):
	(n, x) = map(int, input().split())
	lt = sorted(list(map(int, input().split())), reverse=True)
	ts = 0
	c = 0
	s = 0
	pr = 0
	for i in range(n):
		if lt[i] > x:
			s = lt[i] - x
			ts = ts + s
	for j in range(n):
		if lt[j] < x:
			s = x - lt[j]
			ts = ts - s
			c = c + 1
			if ts < 0:
				c = c - 1
				break
		else:
			pr = pr + 1
	print(c + pr)


t = int(input())
for z in range(t):
	(n, x) = map(int, input().split())
	l = [int(i) for i in input().split()][:n]
	l.sort()
	l.reverse()
	s = 0
	k = 0
	for i in range(n):
		if l[i] >= x:
			s += l[i]
			k += 1
		elif (s + l[i]) / (i + 1) >= x:
			s += l[i]
			l[i] = (s + l[i]) / (i + 1)
			k += 1
		else:
			break
	print(k)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def solve(n):
	return n * (n + 1) // 2
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	ans = 0
	cnt = 0
	final = 0
	for i in l:
		ans += i
		cnt += 1
		if ans / cnt >= x:
			final += 1
	print(final)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	b = n
	total = sum(a)
	flag = 2
	for i in range(n):
		if total < b * x:
			total -= a[i]
			b = b - 1
		else:
			flag = 0
			break
	if flag == 0:
		print(n - i)
	else:
		print(n - i - 1)


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += a[i]
		if s >= x * (i + 1):
			ans = max(ans, i + 1)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for q in range(0, t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	num = sum(a)
	a.sort()
	a.reverse()
	number = num / n
	k = n
	d = 0
	while number < x and k > 1:
		k -= 1
		number = (num - a[k] - d) / k
		d += a[k]
	if k == 1 and max(a) >= x:
		print(1)
	elif k == 1:
		print(0)
	else:
		print(k)


import sys
import math

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

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

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(a, b) = get_ints()
	c = get_array()
	d = sorted(c)
	sumi = c[0]
	count = 0
	c = 0
	for i in range(a):
		ans = d[a - i - 1] - b + c
		if ans < 0:
			break
		c = c + d[a - i - 1] - b
		count = count + 1
	print(count)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	lis = list(map(int, input().split()))
	lis.sort(reverse=True)
	s = 0
	for i in range(n):
		s += lis[i]
		if s / (i + 1) < x:
			print(i)
			break
	else:
		print(n)


def solution():
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	s = sum(l)
	i = 0
	while s / n < m:
		s -= l[i]
		i += 1
		n -= 1
		if n == 0:
			break
	print(n)
for _ in range(int(input())):
	solution()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a.reverse()
	i = 0
	count = 0
	while i < n and count + a[i] >= (i + 1) * x:
		count += a[i]
		i += 1
	print(i)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, x) = inputnums()
	a = inputlist()
	a.sort(reverse=True)
	count = 0
	total = 0
	avg = 0
	for i in range(n):
		total += a[i]
		avg = total / (i + 1)
		if avg >= x:
			count += 1
		else:
			break
	print(count)


def case():
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	total = 0
	for i in range(n):
		total += arr[i]
	div = n
	pos = 0
	arr.sort()
	while div > 0 and total / div < x:
		total -= arr[pos]
		div -= 1
		pos += 1
	print(div)

def main():
	t = int(input())
	while t > 0:
		case()
		t -= 1
main()


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	nums = list(map(int, input().split()))
	nums.sort(key=lambda x: -x)
	i = 0
	cum = 0
	while i < len(nums) and nums[i] >= x:
		cum += nums[i] - x
		i += 1
	while i < len(nums) and cum >= x - nums[i]:
		cum -= x - nums[i]
		i += 1
	print(i)


def makeWealthy(arr, w):
	wealthy = []
	arr.sort()
	avg = arr[len(arr) - 1]
	wealth = 0
	if avg >= w:
		wealth += 1
		j = 2
		for i in range(len(arr) - 2, -1, -1):
			if (avg + arr[i]) / j >= w:
				avg += arr[i]
				j += 1
				wealth += 1
		print(wealth)
	else:
		print(wealth)

def main():
	t = int(input())
	for i in range(t):
		(n, x) = input().split()
		(n, x) = (int(n), int(x))
		arr = list(map(int, input().split()))
		makeWealthy(arr, x)
main()


TEST = False

def solve(a, x):
	w = reversed(sorted(a))
	total = 0
	for (i, wi) in enumerate(w):
		total += wi
		if total / (i + 1) < x:
			return i
	return len(a)
s_in = '\n4\n4 3\n5 1 2 1\n4 10\n11 9 11 9\n2 5\n4 3\n3 7\n9 4 9\n'
s_out = '\n2\n4\n0\n3\n'
l_in = list(reversed(s_in.split('\n')[1:-1]))
l_out = list(reversed(s_out.split('\n')[1:-1]))
if TEST:
	tc = []
	t = int(l_in.pop())
	for ti in range(t):
		(n, x) = map(int, l_in.pop().split())
		a = list(map(int, l_in.pop().split()))
		sol = int(l_out.pop())
		tc.append([a, x, sol])
		res = solve(a, x)
	print('\n*** tc ***')
	for test in tc:
		print(test)
	print('*** tc ***\n')
	for (a, x, sol) in tc:
		res = solve(a, x)
		print(res, sol, res == sol)
else:
	t = int(input())
	for ti in range(t):
		(n, x) = map(int, input().split())
		a = list(map(int, input().split()))
		res = solve(a, x)
		print(f'{res}')


t = int(input())
for t1 in range(0, t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l = l[::-1]
	s = 0
	c = 0
	for i in l:
		if i >= x:
			c = c + 1
	for i in range(0, n):
		s = s + l[i]
		if s // (i + 1) >= x:
			c = max(c, i + 1)
	print(c)


from collections import defaultdict
from math import *
t = int(input())
for k in range(t):
	(n, x) = [int(el) for el in input().split()]
	a = [int(el) for el in input().split()]
	a = list(reversed(sorted(a)))
	s = 0
	res = 0
	for i in range(n):
		s += a[i]
		if s / (i + 1) >= x:
			res = i + 1
		else:
			break
	print(res)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(n, x) = map(int, input().split())
		aa = [int(a) for a in input().split()]
		aa.sort(reverse=True)
		sum = 0
		i = 0
		while sum >= x * i and i < n:
			sum += aa[i]
			i += 1
		if sum >= x * n:
			print(n)
		else:
			print(i - 1)
	q = int(input())
	for _ in range(q):
		solve()
main()


def middle_class(n, c, array):
	array.sort()
	if array[0] > c:
		return n
	elif array[-1] < c:
		return 0
	else:
		s = 0
		for i in range(n):
			s += array[n - i - 1]
			if s / (i + 1) < c:
				return i
		else:
			return i + 1
	return 0
t = int(input())
array = []
for i in range(t):
	(n, m) = list(map(int, input().split(' ')))
	l = list(map(int, input().split(' ')))
	array.append([n, m, l])
for elements in array:
	print(middle_class(elements[0], elements[1], elements[2]))


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	r = 0
	b = 0
	a.sort(reverse=True)
	for i in range(n):
		if (r + a[i]) / (i + 1) >= x:
			r += a[i]
			b += 1
		else:
			break
	print(b)


import sys

def main():
	res = ''
	input = sys.stdin.readline
	print = sys.stdout.write
	t = int(input())
	for _ in range(t):
		count_rich = 0
		(n, x) = map(int, input().split())
		cash = list(map(int, input().split()))
		cash.sort()
		l = -1
		r = n
		while l + 1 < r:
			mid = (l + r) // 2
			if cash[mid] >= x:
				r = mid
			else:
				l = mid
		if l == -1:
			count_rich = n
		elif r != n:
			count_rich = n - r
			cash_of_rich = sum(cash[r:]) - x * count_rich
			while cash_of_rich > 0 and l >= 0:
				cash_of_rich -= x - cash[l]
				if cash_of_rich >= 0:
					count_rich += 1
				l -= 1
		res += str(count_rich) + '\n'
	print(res)
main()


n = int(input())
for i in range(n):
	(m, x) = map(int, input().split())
	arr = sorted(list(map(int, input().split())), reverse=True)
	cnt = 0
	have = 0
	bfcnt = len([i for i in arr if i >= x])
	mx = bfcnt
	for i in arr:
		have += i
		cnt += 1
		mx = max(mx, (cnt if have / cnt >= x else 0) + (bfcnt - cnt if cnt <= bfcnt else 0))
	print(mx)


from math import ceil, gcd, trunc
from bisect import bisect_left as bl
from bisect import bisect_right as br
from array import array
from collections import Counter as ctr

def li():
	return list(map(int, input().split()))

def arr(a):
	return array('i', a)

def solve():
	for _ in range(int(input())):
		(n, x) = li()
		a = li()
		if sum(a) / n >= x:
			print(n)
		elif max(a) < x:
			print(0)
		elif max(a) == x:
			print(a.count(max(a)))
		else:
			a.sort()
			w = br(a, x)
			s1 = sum(a[w:])
			while s1 >= x * (n - w):
				w -= 1
				s1 += a[w]
			print(n - w - 1)
solve()


def memoize(f):
	mem = {}

	def wrapper(n):
		if n not in mem:
			mem[n] = f(n)
		return mem[n]
	return wrapper

@memoize
def temp():
	pass
ans = ''
for _ in range(int(input())):
	(n, x) = [int(xi) for xi in input().split(' ')]
	a = [int(xi) for xi in input().split(' ')]
	sorted_a = [i[0] for i in reversed(sorted(enumerate(a), key=lambda x: x[1]))]
	i = 0
	for _i in range(n):
		idx = sorted_a[i]
		if len(sorted_a) - 1 > _i:
			if a[idx] < x:
				continue
			a[sorted_a[i + 1]] += a[idx] - x
			a[idx] = x
			i += 1
	c_ans = 0
	for xi in a:
		if xi >= x:
			c_ans += 1
	ans += f'{c_ans} '
print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	s = 0
	c = 0
	for i in range(n):
		s += A[i]
		if s / (i + 1) >= k:
			c = i + 1
	print(c)


T = int(input())
for _ in range(1, T + 1):
	(n, x) = map(int, input().split())
	s = [int(x) for x in input().split()]
	s.sort()
	sum = 0
	count = 0
	while s and (sum + s[-1]) / (count + 1) >= x:
		sum += s.pop()
		count += 1
	print(count)


I = input
for _ in range(int(I())):
	(n, x) = map(int, I().split())
	lst = sorted(map(int, I().split()), reverse=True)
	(res, i) = (0, 0)
	while res >= 0 and i < n:
		res += lst[i] - x
		i += 1
	print(i - 1 if res < 0 else i)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	avg = 0
	tt = 0
	p = 0
	v = list(map(int, input().split()))
	tt = sum(v)
	avg = tt / n
	if avg >= x:
		print(n)
		t -= 1
		continue
	v.sort(reverse=True)
	c = 0
	for i in range(n):
		k = 0
		p += v[i]
		k = p / (i + 1)
		if k >= x:
			c += 1
		else:
			break
	print(c)
	t -= 1


def main():
	t = int(input())
	for it in range(t):
		(n, x) = [int(i) for i in input().split()]
		a = [int(i) for i in input().split()]
		a.sort()
		total = sum(a)
		impossible = True
		for i in range(n, 0, -1):
			if total >= i * x:
				print(i)
				impossible = False
				break
			total -= a[n - i]
		if impossible:
			print(0)
main()


import sys
input = lambda : sys.stdin.readline().strip()
ipnut = input

def ch(a):
	return a ** 0.5 == int(a ** 0.5)
for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = a[0]
	k = 1
	ans = -1
	for i in range(n):
		if s / k < x:
			ans = k - 1
			break
		elif k != n:
			s += a[k]
			k += 1
	if ans == -1:
		ans = n
	print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	b = sum(a)
	c = 0
	d = n
	for i in range(n):
		if b // d >= x:
			c = len(a)
			break
		else:
			b = b - a[-1]
			a.pop()
			d = d - 1
	print(c)


for h in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	res = 0
	for i in range(n):
		s += a[i]
		if s >= x * (i + 1):
			res = i + 1
	print(res)


def main():
	t = int(input())
	for tt in range(t):
		(n, m) = map(int, input().split())
		a = sorted(list(map(int, input().split())))
		s = sum(a)
		l = len(a)
		for i in range(0, len(a)):
			k = s / l
			s = s - a[i]
			l = l - 1
			if k >= m:
				break
		if i == len(a) - 1 and a[i] < m:
			print(0)
		elif i == len(a) - 1 and a[i] >= m:
			print(1)
		else:
			print(len(a) - i)
main()


t = int(input())
for i in range(t):
	(n, x) = tuple(map(int, input().split()))
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	k = list()
	if l[0] < x:
		print('0')
		continue
	else:
		k.append(l[0])
		a = 1
		s = k[0]
		av = s
		while a < n:
			if av < x:
				break
			k.append(l[a])
			s += l[a]
			a += 1
			av = s / a
		if av < x:
			print(a - 1)
		else:
			print(a)


def sol(n, x, arr):
	s = sum(arr)
	if n * x <= s:
		print(n)
		return
	else:
		arr.sort(reverse=True)
		it = 1
		s = arr[0]
		while s >= x * it and it < n:
			s += arr[it]
			it += 1
		print(it - 1)
	return
for i in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	sol(n, x, arr)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	sum_ = 0
	b = a[:n]
	b.sort()
	c = a[n:]
	for i in c:
		b.append(i)
	k = 0
	for i in range(n - 1, -1, -1):
		sum_ += b[i] - x
		if sum_ < 0:
			break
		k += 1
	print(k)


import sys
t = int(input())
inp = [line.strip().split() for line in reversed(sys.stdin.readlines())]
while t:
	(n, x) = map(int, inp.pop())
	a = sorted((int(i) for i in inp.pop()), reverse=True)
	k = 0
	s = 0
	for (ind, ai) in enumerate(a):
		s += ai
		if s / (k + 1) < x:
			break
		k += 1
	print(k)
	t -= 1


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def array():
	return [int(i) for i in input().split()]
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(array())
	rem = 0
	i = n - 1
	ans = 0
	while i >= 0 and a[i] >= k:
		rem += a[i] - k
		ans += 1
		i -= 1
	for i in range(i, -1, -1):
		if a[i] + rem >= k:
			ans += 1
			rem -= k - a[i]
		else:
			break
	print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def canForm(x):
	c = 0
	have = 0
	for i in a:
		if i >= k:
			have += i - k
			c += 1
		elif have >= k - i:
			have -= k - i
			c += 1
	return c >= x
for _ in range(Int()):
	(n, k) = value()
	a = sorted(array(), reverse=True)
	low = 0
	high = n
	while low <= high:
		mid = (low + high) // 2
		if canForm(mid):
			ans = mid
			low = mid + 1
		else:
			high = mid - 1
	print(ans)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	s = 0
	f = 0
	for i in range(len(l)):
		if l[i] > x:
			s = s + l[i] - x
		else:
			l[i] = s + l[i]
			if l[i] >= x:
				s = l[i] - x
			else:
				f = 1
				break
	if f == 1:
		print(i)
	else:
		print(i + 1)
	t -= 1


test = int(input())
while test:
	test -= 1
	(n, mm) = map(int, input().split())
	ls = list(map(int, input().split()))
	ls.sort()
	x = 0
	s = 0
	for i in range(n - 1, -1, -1):
		s += ls[i]
		x += 1
		temp = s / x
		if temp < mm:
			break
	if s / x < mm:
		x -= 1
	print(x)


def main():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	cum = 0
	for i in range(n):
		cum += a[i]
		if cum < x * (i + 1):
			return i
	return n
t = int(input())
for i in range(t):
	print(main())


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	tot = sum(a)
	f = 0
	for j in range(n):
		val = n - j
		av = tot // val
		if av >= x:
			value = val
			f = 1
			break
		else:
			tot = tot - a[j]
	if f == 1:
		print(value)
	else:
		print(0)


for _ in ' ' * int(input()):
	c = 0
	s = 0
	(a, b) = map(int, input().split())
	z = []
	for i in map(int, input().split()):
		o = i - b
		if o >= 0:
			s += o
			c += 1
		else:
			z += [i]
	t = len(z) - 1
	z = sorted(z)
	while s and t >= 0:
		o = b - z[t]
		if o <= s:
			s -= o
			c += 1
			t -= 1
		else:
			break
	print(c)


for nt in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	s = 0
	for i in range(n):
		if l[i] >= x:
			s += l[i] - x
	l.sort(reverse=True)
	ans = 0
	for i in range(n):
		if l[i] >= x:
			ans += 1
		else:
			a = min(s, x - l[i])
			s -= a
			l[i] += a
			if l[i] >= x:
				ans += 1
	print(ans)


from collections import Counter
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	m = sum(l)
	ans = n
	for i in range(n):
		if m / ans >= x:
			break
		else:
			m -= l[i]
			ans -= 1
	print(ans)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	p = list(map(int, input().split()))
	p = sorted(p, reverse=True)
	tot = sum(p)
	try:
		while tot / n < k:
			n = n - 1
			tot -= p.pop()
	except:
		pass
	print(n)


def solve(a, min_wealthy_amount):
	a.sort()
	sol = 0
	money_to_split = 0
	wealth_i = len(a) - 1
	while wealth_i >= 0 and a[wealth_i] >= min_wealthy_amount:
		money_to_split += a[wealth_i] - min_wealthy_amount
		sol += 1
		wealth_i -= 1
	poor_ind = wealth_i
	while poor_ind >= 0 and money_to_split + a[poor_ind] >= min_wealthy_amount:
		money_to_split -= min_wealthy_amount - a[poor_ind]
		sol += 1
		poor_ind -= 1
	print(sol)
n_test_cases = int(input())
for _ in range(n_test_cases):
	(_, x) = input().split()
	arr = list(map(int, input().split()))
	solve(arr, int(x))


from math import *
for __ in range(int(input())):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort(reverse=True)
	c = 0
	nn = 0
	for i in range(n):
		if ar[i] >= x:
			nn += 1
			c += ar[i]
	cc = 0
	m = 0
	ans = nn
	for i in range(n):
		if ar[i] < x:
			cc += ar[i]
			m += 1
			if (cc + c) / (nn + m) >= x:
				ans = nn + m
	print(ans)


tries = int(input())
results = []
for trial in range(tries):
	(people, offset) = map(int, input().split())
	moneys = sorted(map(int, input().split()), reverse=True)
	temp_sum = 0
	count = 0
	last_count = 0
	for x in moneys:
		count += 1
		temp_sum += x
		if temp_sum / count >= offset:
			last_count = count
		else:
			break
	results.append(last_count)
for r in results:
	print(r)


for p in range(int(input())):
	(n, x) = map(int, input().split(' '))
	lt = list(map(int, input().split(' ')))
	for i in range(len(lt)):
		lt[i] = lt[i] - x
	pos = []
	neg = []
	for i in range(len(lt)):
		if lt[i] > 0:
			pos.append(lt[i])
		else:
			neg.append(lt[i])
	su = 0
	for i in range(len(pos)):
		su = su + pos[i]
	neg.sort()
	neg.reverse()
	for i in range(len(neg)):
		neg[i] = neg[i] + su
		su = neg[i]
	count = 0
	for i in range(len(neg)):
		if neg[i] >= 0:
			count = count + 1
	print(count + len(pos))


t = int(input())
for i in range(t):
	lol = input().split()
	n = int(lol[0])
	x = int(lol[1])
	dhoni = 0
	sum = 0
	mon = [int(k) for k in input().split()]
	mon.sort()
	for j in range(n):
		if mon[j] >= x:
			sum = sum + (mon[j] - x)
			dhoni += 1
	l = n - 1
	while l >= 0:
		if mon[l] < x and sum - (x - mon[l]) >= 0:
			sum = sum - (x - mon[l])
			dhoni += 1
		l -= 1
	print(dhoni)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	aa = sorted(map(int, input().split()), reverse=True)
	ans = 0
	minsum = 0
	cursum = 0
	for a in aa:
		cursum += a
		minsum += x
		if cursum < minsum:
			break
		ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	ans = 0
	summation = 0
	a.sort(reverse=True)
	for i in range(n):
		summation += a[i]
		if summation >= x * (i + 1):
			ans = i + 1
		else:
			break
	print(ans)


T = int(input())
for _ in range(T):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	n = 0
	S = 0
	flag = False
	for i in arr:
		S += i
		n += 1
		if S / n < x:
			flag = True
			break
	if not flag:
		n += 1
	print(n - 1)


T = int(input(''))
for _ in range(T):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort(reverse=True)
	sar = []
	p = 0
	for i in range(n):
		p += ar[i]
		sar.append(p)
	c = 0
	for j in range(n):
		if sar[j] / (j + 1) >= x:
			c += 1
	print(c)


from sys import stdin
import heapq
t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in stdin.readline().split()]
	k = [int(i) * -1 for i in stdin.readline().split()]
	b = True
	a = []
	s = 0
	i = 1
	heapq.heapify(k)
	while b and k:
		p = heapq.heappop(k)
		s += p
		if s / i * -1 >= m:
			a.append(p)
			i += 1
		else:
			b = False
	print(len(a))


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	mny = list(sorted(map(int, input().split()), reverse=True))
	s = sum(mny)
	ans = s / n
	flag = ans >= x
	cnt = n - 1
	while not flag and cnt > 0:
		s -= mny[cnt]
		ans = s / cnt
		flag = ans >= x
		cnt -= 1
	if flag:
		print(cnt + 1)
	else:
		print(cnt)


t = input()
t = int(t)
while t > 0:
	t -= 1
	(n, x) = input().split(' ')
	n = int(n)
	x = int(x)
	arr = input().split(' ')
	arr = [int(val) for val in arr]
	arr = sorted(arr, reverse=True)
	extra = 0
	for i in range(0, n):
		if arr[i] > x:
			extra += arr[i] - x
	for i in range(0, n):
		if arr[i] < x:
			add = x - arr[i]
			arr[i] += add
			extra -= add
			if extra < 0:
				arr[i] -= add
				break
	cnt = 0
	for i in range(0, n):
		if arr[i] >= x:
			cnt += 1
	print(cnt)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	s = sum(a)
	ans = n
	l = 0
	while x * ans > s and l < n:
		s -= a[l]
		l += 1
		ans -= 1
	print(ans)


testCases = int(input())
for _ in range(testCases):
	(length, pl) = list(map(int, input().split()))
	wealth = list(map(int, input().split()))
	wealth.sort(reverse=True)
	total = 0
	result = 0
	for i1 in range(length):
		total += wealth[i1]
		if total / (i1 + 1) < pl:
			result = i1
			break
		result = i1 + 1
	print(result)


from bisect import bisect_left as bl
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	sp = bl(arr, x)
	a1 = arr[:sp]
	a1.reverse()
	su_ = sum(arr[sp:]) - x * (n - sp)
	ans = n - sp
	i = 0
	while i < len(a1) and su_ >= x - a1[i]:
		ans += 1
		su_ = su_ - (x - a1[i])
		i += 1
	print(ans)


for _ in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	arr = [float(s) for s in input().split()]
	arr.sort(reverse=True)
	sum = 0
	flag = True
	if arr[0] < k:
		print(0)
		continue
	for i in range(len(arr)):
		sum += arr[i]
		if sum / (i + 1) < k:
			print(i)
			flag = False
			break
	if flag:
		print(n)


t = int(input())
for i in range(t):
	(num, x) = input().split()
	num = int(num)
	x = int(x)
	arr = [0] * num
	arr = input().split()
	for k in range(num):
		arr[k] = int(arr[k])
	arr.sort()
	total = 0
	count = 0
	maxi = -1
	wealthy = 0
	for j in range(num - 1, -1, -1):
		total = total + arr[j]
		count += 1
		if total / count >= x:
			wealthy = count
		if wealthy > maxi:
			maxi = wealthy
	print(maxi)


def main():
	tc_count = int(input())
	for tc in range(tc_count):
		(n, minx) = map(int, input().split())
		lst = map(int, input().split())
		sol = 0
		lst = sorted(lst, reverse=True)
		sum = 0
		for (idx, x) in enumerate(lst):
			sum = sum + x
			if sum / (idx + 1) >= minx:
				sol += 1
			else:
				break
		print('{}'.format(sol))
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	extra = 0
	ans = 0
	for i in range(n - 1, -1, -1):
		if a[i] >= x:
			extra += a[i] - x
			ans += 1
		else:
			break
	for j in range(i, -1, -1):
		if a[j] < x:
			if extra - x + a[j] >= 0:
				ans += 1
				extra -= x - a[j]
			else:
				break
	print(ans)


t = int(input())
while t > 0:
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	c = 0
	total = 0
	for i in range(n):
		total += a[i]
		if total / (i + 1) >= x:
			c += 1
		else:
			break
	print(c)
	t -= 1


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	data = [int(x) for x in input().split()]
	data.sort()
	add = 0
	flag = 0
	count = 1
	for q in range(n, 0, -1):
		temp = data[q - 1]
		add += temp
		average = add / count
		if average < x:
			flag = 1
			if q == n:
				print(0)
				break
			else:
				print(count - 1)
				break
		count += 1
	if flag == 0:
		print(n)


import sys
input = lambda : sys.stdin.readline().rstrip()

def I():
	return list(map(int, input().split()))
for _ in range(I()[0]):
	(n, x) = I()
	a = I()
	a.sort(reverse=True)
	st = []
	cur = 0
	ans = 0
	for i in range(len(a)):
		st.append(a[i] + cur)
		cur = st[-1]
		if st[-1] // len(st) >= x:
			ans += 1
		else:
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = (int(x) for x in input().split())
	a = reversed(sorted((int(x) for x in input().split())))
	(sum, ans) = (0, 0)
	for el in a:
		if el >= x:
			sum += el - x
			ans += 1
		elif el + sum >= x:
			sum -= x - el
			ans += 1
		else:
			break
	print(ans)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(N, X) = map(int, readline().split())
	A = list(map(int, readline().split()))
	A.sort(reverse=True)
	A = [None] + A
	cnt = 0
	ans = 0
	for i in range(1, N + 1):
		cnt += A[i]
		if cnt >= X * i:
			ans = i
	Ans[qu] = ans
print('\n'.join(map(str, Ans)))


from sys import stdin, stdout
t = int(input())
for ii in range(t):
	(n, x) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	a.sort(reverse=True)
	extra = 0
	if a[0] < x:
		print(0)
		continue
	extra = a[0]
	ans = 1
	for i in range(1, n):
		extra += a[i]
		if extra / (i + 1) >= x:
			ans = i + 1
		else:
			break
	stdout.write(str(ans))
	stdout.write('\n')


t = int(input())
for k in range(t):
	(n, m) = map(int, input().rstrip().split())
	arr = list(map(int, input().rstrip().split()))
	arr.sort(reverse=True)
	s = 0
	count = 0
	for i in range(len(arr)):
		s += arr[i]
		count += 1
		if s / count >= m:
			continue
		else:
			s -= arr[i]
			count -= 1
	print(count)


t = int(input())
result = []
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = sorted(arr, reverse=True)
	for i in range(1, n):
		arr[i] += arr[i - 1]
	count = 0
	for i in range(n):
		if arr[i] / (i + 1) < k:
			break
		else:
			count += 1
	result.append(count)
for x in result:
	print(x)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	j = 0
	count = 0
	ar = sorted(list(map(int, input().split())), reverse=True)
	for i in range(1, a + 1):
		count += ar[i - 1]
		if count >= b * i:
			j += 1
		else:
			break
	print(j)


tc = int(input())
while tc > 0:
	(n, x) = map(int, input().split())
	total = 0
	res = 0
	a = list(map(int, input().split()))
	a.sort()
	for (i, s) in enumerate(reversed(a)):
		total += s
		if total >= x * (i + 1):
			res += 1
	print(res)
	tc -= 1


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	Query.append((N, K, A))
for (N, K, A) in Query:
	A.sort(reverse=True)
	n = 0
	s = 0
	for (i, a) in enumerate(A):
		s += a
		if s >= (i + 1) * K:
			n = i + 1
	print(n)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort(reverse=True)
	(s, ct) = (0, 1)
	for i in range(n):
		if (s + ar[i]) / ct >= x:
			s += ar[i]
			ct += 1
		else:
			break
	print(ct - 1)


import sys, statistics
T = int(input())
for t in range(T):
	(N, x) = map(int, input().split())
	A = list(map(int, input().split()))
	m = statistics.mean(A)
	tot = sum(A)
	n = 0
	A.sort()
	while n < N - 1 and m < x:
		n = n + 1
		tot = tot - A[n - 1]
		m = tot / (N - n)
	if n == N - 1:
		if A[-1] >= x:
			print(1)
		else:
			print(0)
	else:
		print(N - n)


import os
from io import BytesIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	As = list(map(int, input().split()))
	As.sort(reverse=True)
	extra = 0
	i = 0
	while i < n and As[i] >= x:
		extra += As[i] - x
		i += 1
	while i < n and x - As[i] <= extra:
		extra -= x - As[i]
		i += 1
	print(i)


t = int(input())
while t:
	t += -1
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	sm = 0
	av = 0
	ans = -1
	for i in range(n):
		sm += l[i]
		av = sm / (i + 1)
		if av < x:
			ans = i
			break
	if ans != -1:
		print(ans)
	else:
		print(n)


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	(n, x) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	s = 0
	for i in range(n):
		s += arr[i]
		if s / (i + 1) < x:
			print(i)
			return
	print(n)
tt = int(input())
for test in range(tt):
	solve()


for i in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	s = [int(x) for x in input().split()]
	s.sort(reverse=True)
	m = 0
	cnt = 0
	for i in s:
		if i >= b:
			m += i
			cnt += 1
		elif (m + i) / (cnt + 1) >= b:
			m += i
			cnt += 1
		else:
			break
	print(cnt)


def solve_case():
	(n, x) = map(int, input().split())
	inp = sorted(list(map(int, input().split())), reverse=True)
	rs = 0
	ic = 1
	for i in inp:
		rs += i
		if x * ic > rs:
			return ic - 1
		ic += 1
	return n

def main():
	tests = int(input())
	for t in range(1, tests + 1):
		print(solve_case())
main()


def query(n, x, A):
	A.sort()
	s = sum(A)
	cnt = n
	for (i, a) in enumerate(A):
		if s / cnt >= x:
			break
		s -= a
		cnt -= 1
	return cnt

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, input().split())
		A = list(map(int, input().split()))
		print(query(n, x, A))
main()


t = input()
for _ in range(int(t)):
	s = input().split()
	n = int(s[0])
	x = int(s[1])
	price = input().split()
	price = [int(num) for num in price]
	price.sort()
	sum = 0
	left = n
	count = 0
	for i in range(n):
		sum += price[i]
		if price[i] >= x:
			count += 1
	for i in range(n):
		res = sum / left
		if res >= x:
			count = max(count, left)
		sum = sum - price[i]
		left = left - 1
	print(count)


T = int(input())
for i in range(T):
	(n, x) = map(int, input().split())
	lista = list(map(int, input().split()))
	lista.sort(reverse=True)
	extra = 0
	count = 0
	for i in lista:
		if i > x:
			extra += i - x
			count += 1
		elif extra + i >= x:
			extra = extra - (x - i)
			count += 1
	print(count)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = []
	(s1, s2, c, c1) = (0, 0, 0, 0)
	for i in range(len(l)):
		if l[i] >= x:
			c1 += 1
			s1 += l[i] - x
		else:
			l1.append(x - l[i])
	l1.sort()
	for i in range(len(l1)):
		if l1[i] <= s1:
			c += 1
			s1 = s1 - l1[i]
		else:
			c += 0
	print(c + c1)
	t = t - 1


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	r = 0
	suma = 0
	i = 0
	while i < n and suma + a[i] >= x * (i + 1):
		suma += a[i]
		i += 1
	print(i)


import sys
T = int(sys.stdin.readline())
list_monster = []
for _ in range(T):
	(n, x) = map(int, sys.stdin.readline().split())
	list_people = list(map(int, sys.stdin.readline().split()))
	list_people.sort()
	count = n
	sum_now = sum(list_people)
	for num in list_people:
		if sum_now / count >= x:
			break
		count -= 1
		sum_now -= num
	print(count)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	L = sorted(map(int, input().split()), reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		if s + L[i] >= x * (i + 1):
			s += L[i]
			ans += 1
		else:
			break
	print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, x) = list(map(int, input().split()))
		wealth = list(map(int, input().split()))
		sum1 = 0
		counter = 0
		wealth.sort()
		for i in range(n):
			ele = wealth[i]
			if ele >= x:
				sum1 += ele - x
				counter += 1
		for i in range(n):
			ele = wealth[n - i - 1]
			if ele < x:
				kap = x - ele
				if sum1 >= kap:
					sum1 -= kap
					counter += 1
				else:
					break
		yield counter
t = int(input())
ans = gift()
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	ar = list(map(int, input().split()))
	ar.sort()
	wi = -1
	for i in range(n):
		if ar[i] >= x:
			wi = i
			break
	else:
		wi = n
	wc = n - wi
	ws = sum(ar[wi:])
	pc = wc
	for i in range(wi - 1, -1, -1):
		pc += 1
		ws += ar[i]
		if ws / pc >= x:
			wc += 1
		else:
			break
	print(wc)


import math
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	s = sum(arr)
	ans = 0
	for i in range(n):
		if s >= (n - i) * k:
			ans = n - i
			break
		else:
			s -= arr[i]
	print(ans)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	s = sum(a)
	s1 = 0
	res = 0
	for i in range(n):
		if (s - s1) / (n - i) >= x:
			res = n - i
			break
		s1 += a[i]
	print(res)


for _ in [0] * int(input()):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	s = sorted(s, reverse=True)
	count = 0
	extra = 0
	for i in range(n):
		s[i] += extra
		if s[i] >= k:
			count += 1
			extra = s[i] - k
		else:
			break
	print(count)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	tot = 0
	t = 0
	f = 0
	for i in l:
		if i >= x:
			f += 1
	for i in range(len(l)):
		if (tot + l[i]) // (i + 1) < x:
			break
		else:
			tot += l[i]
			t += 1
	print(max(t, f))


tt = int(input())
while tt:
	(n, x) = [int(p) for p in input().split()]
	A = [int(p) for p in input().split()]
	A.sort(reverse=True)
	sum = 0
	counter = 0
	i = 0
	for t in A:
		i += 1
		sum += t
		if sum >= i * x:
			counter += 1
	print(counter)
	tt -= 1


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		arr = [int(x) for x in input().split()]
		arr = sorted(arr, reverse=True)
		count = 1
		s = 0
		for a in arr:
			s += a
			if s / count < m:
				break
			count += 1
		print(count - 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import io
import os
import sys
import math
import heapq
import bisect
import random
import string
import decimal
import functools
import fractions
import itertools
import collections
from sys import stdin, stdout
from io import BytesIO, IOBase
from math import gcd, floor, sqrt, log, factorial
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict, OrderedDict, namedtuple, UserDict, UserList, UserString
MOD = 1000000007
sys.setrecursionlimit(100000000)
BUFSIZE = 8192
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	res = 0
	cnt = 0
	sum = 0
	for i in arr:
		sum += i
		cnt += 1
		if sum / cnt >= x:
			res += 1
	print(res)


for _ in range(int(input())):
	(n, x) = (int(num) for num in input().split())
	savings = [int(num) for num in input().split()]
	savings.sort(reverse=True)
	needed = n * x
	if savings[0] < x:
		ans = 0
	else:
		dist = sum(savings)
		while n > 0:
			if dist >= needed:
				ans = n
				break
			else:
				needed -= x
				dist -= savings.pop()
				n -= 1
		else:
			ans = 0
	print(ans)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

def in_int():
	return int(input())

def in_list():
	return list(map(int, input().split()))

def in_str():
	s = input()
	return list(s[:len(s) - 1])

def in_ints():
	return map(int, input().split())
t = in_int()
for tt in range(t):
	(n, x) = in_ints()
	a = in_list()
	a = sorted(a)
	xx = 0
	count = 0
	for i in range(n):
		xx += a[n - 1 - i]
		if xx / (i + 1) >= x:
			count += 1
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	A = [int(x) for x in input().split()]
	A.sort(reverse=True)
	s = sum(A)
	while s < n * x:
		s -= A.pop()
		n -= 1
	print(n)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = [int(X) for X in input().split()]
	a.sort(reverse=True)
	s = 0
	p = True
	for j in range(n):
		if s + a[j] < (j + 1) * x:
			p = False
			break
		else:
			s += a[j]
	if p == False:
		print(j)
	else:
		print(n)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	excess = 0
	ind = 0
	while ind < len(arr):
		if arr[ind] >= x:
			excess += arr[ind] - x
		else:
			break
		ind += 1
	while ind < len(arr):
		if x - arr[ind] <= excess:
			excess -= x - arr[ind]
		else:
			break
		ind += 1
	print(ind)


T = int(input())
for case in range(T):
	(n, x) = [int(x) for x in input().split()]
	ls = [int(x) for x in input().split()]
	ls = sorted(ls)
	s = sum(ls)
	if s // len(ls) >= x:
		print(len(ls))
		continue
	else:
		w = 0
		flag = False
		for (n, e) in enumerate(ls):
			s -= e
			if len(ls) - n - 1 == 0:
				print(0)
				break
			elif s // (len(ls) - n - 1) >= x:
				print(len(ls) - n - 1)
				break
		continue


c = int(input())
for i in range(c):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))[::-1]
	if sum(a) / n >= x:
		print(n)
	else:
		v = 0
		count = 0
		for i in a:
			v += i
			count += 1
			if v / count < x:
				print(count - 1)
				break


t = int(input())

def solve(n, x, nums):
	nums = sorted(nums, reverse=True)
	sm = 0
	for i in range(n):
		sm += nums[i]
		if sm / (i + 1) < x:
			return i
	return n
for _ in range(t):
	(N, X) = map(int, input().split())
	nums = map(float, input().split())
	print(solve(N, X, nums))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	currSum = 0
	best = 0
	for i in range(n):
		currSum += a[i]
		if currSum / (i + 1) < x:
			break
		best += 1
	print(best)


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	x = int(l[1])
	l = input().split()
	li = [int(i) - x for i in l]
	li.sort()
	suma = 0
	j = n - 1
	count = 0
	while j >= 0:
		if suma + li[j] >= 0:
			count += 1
			suma += li[j]
			j -= 1
		else:
			break
	print(count)


def numberOfRiches(size, people, k):
	people.sort()
	index = size - 1
	count = 0
	sumVal = 0
	while index >= 0:
		sumVal += people[index]
		count += 1
		if sumVal / count < k:
			return count - 1
		index -= 1
	return size
size = int(input())
for i in range(size):
	(length, k) = list(map(int, input().split(' ')))
	arr = list(map(int, input().split(' ')))
	print(numberOfRiches(length, arr, k))


from collections import *
import sys
try:
	inp = raw_input
except:
	inp = input

def err(s):
	sys.stderr.write('{}\n'.format(s))

def ni():
	return int(inp())

def nl():
	return [int(_) for _ in inp().split()]

def solve():
	(N, X) = nl()
	A = nl()
	A.sort(reverse=True)
	SUM = 0
	NO = 0
	for a in A:
		SUM += a
		NO += 1
		if SUM < X * NO:
			print(NO - 1)
			return
	print(N)
T = ni()
for _ in range(T):
	solve()


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	l = []
	c = 0
	e = 0
	y = input().split()
	for i in y:
		l.append(int(i))
	l.sort(reverse=True)
	for i in l:
		if i >= x:
			c += 1
			e += i - x
		elif e >= x - i:
			c += 1
			e = e + i - x
		else:
			break
	print(c)
	t -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	sm = sum(arr)
	if sm // n >= x:
		print(n)
	else:
		arr = sorted(arr)
		if arr[-1] < x:
			print(0)
			continue
		ct = n
		for i in range(n):
			sm = sm - arr[i]
			ct -= 1
			if sm // ct >= x:
				print(ct)
				break


T = int(input())
for _ in range(T):
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	for i in range(n):
		a[i] -= x
	a.sort(reverse=True)
	output = 0
	summ = 0
	for i in range(n):
		summ += a[i]
		if summ >= 0:
			output += 1
		else:
			break
	print(output)


t = int(input())
for cas in range(t):
	(n, x) = map(int, input().split())
	l = [int(i) for i in input().split()]
	l.sort(reverse=True)
	if sum(l) >= x * n:
		print(n)
	elif l[0] < x:
		print(0)
	else:
		res = 0
		su = 0
		for i in range(n):
			su += l[i]
			res += 1
			if su < res * x:
				print(res - 1)
				break


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	arr = arr[::-1]
	(p, a, k) = (0, 0, 0)
	j = 0
	for i in range(n):
		j += arr[i]
		k = j // (i + 1)
		if k >= x:
			p += 1
		else:
			a = 1
			break
		if a == 1:
			break
	print(p)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	money = sorted(list(map(int, input().split())), reverse=True)
	additional = 0
	wealthy = 0
	i = 0
	for i in range(n):
		if money[i] >= x:
			additional += money[i] - x
		else:
			break
	wealthy = i
	for i in range(i, n):
		if additional >= 0:
			additional += money[i] - x
			wealthy += 1
		else:
			break
	wealthy = wealthy if additional >= 0 else wealthy - 1
	print(wealthy)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted([*map(int, input().split())])
	i = n - 1
	people = 0
	bank = 0
	while a[i] > x and i >= 0:
		people += 1
		bank += a[i] - x
		i -= 1
	while a[i] == x and i >= 0:
		people += 1
		i -= 1
	while i >= 0:
		bank += a[i] - x
		if bank >= 0:
			people += 1
			i -= 1
		else:
			break
	print(people)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
T = oint()
for _ in range(T):
	(n, x) = rint()
	a = list(rint())
	a.sort()
	a = a[::-1]
	s = [0]
	for i in range(n):
		s.append(s[-1] + a[i])
	cnt = 0
	for i in range(1, n + 1):
		if s[i] >= x * i:
			cnt += 1
		else:
			break
	print(cnt)


R1 = lambda : list(map(int, input().split()))
R2 = lambda : int(input())
t = R2()
for _ in range(t):
	(n, x) = R1()
	a = sorted(R1())
	s = sum(a)
	d = n
	for i in range(n):
		if s / d >= x:
			print(d)
			break
		s -= a[i]
		d -= 1
	else:
		print(d)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split(' '))
	a = sorted(map(int, input().split(' ')), reverse=True)
	index = 0
	while index < n:
		if a[index] >= x:
			index += 1
		else:
			break
	base = sum(a[:index])
	ans = index
	suma = base
	for i in range(index, n):
		suma += a[i]
		if suma >= x * (i + 1):
			ans = max(ans, i + 1)
		else:
			break
	print(ans)


t = int(input())
for _ in range(t):
	l = [int(x) for x in input().split(' ')]
	(n, x) = l
	arr = [int(x) for x in input().split(' ')]
	arr.sort(reverse=True)
	c = 0
	if arr[0] >= x:
		c = 1
	sum = arr[0]
	for i in range(1, n):
		sum += arr[i]
		if sum / (i + 1) >= x:
			c = i + 1
	print(c)


p = int(input())
for i in range(0, p):
	(x, y) = [int(a) for a in input().split()]
	m = list(map(int, input().split()))[:x]
	y = y + 0.0
	m.sort()
	m.reverse()
	d = 0
	s = 1
	for j in range(0, x):
		d = d + m[j]
		f = d / s
		if f < y:
			break
		s = s + 1
	print(s - 1)


for i in range(0, int(input())):
	(v, x) = [int(f) for f in input().split()]
	ar = [int(f) for f in input().split()]
	ar.sort(reverse=True)
	bud = 0
	res = 0
	for i in range(0, len(ar)):
		if ar[i] - x >= 0:
			bud += ar[i] - x
			res += 1
			if i == len(ar) - 1:
				print(res)
		elif bud >= x - ar[i]:
			bud -= x - ar[i]
			res += 1
			if bud == 0 or i == len(ar) - 1:
				print(res)
				break
		else:
			print(res)
			break


import math as m
t = int(input())
while t > 0:
	t -= 1
	(n, x) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	sum = float(0)
	ans = 0
	for i in range(len(a)):
		sum += a[i]
		k = sum / (i + 1)
		if k < x:
			break
		ans = i + 1
	print(ans)


T = int(input())
while T:
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if sum(a) / n >= x:
		print(n)
	else:
		total = 0
		for i in range(n):
			if (total + a[i]) / (i + 1) >= x:
				total += a[i]
			else:
				break
		print(i)
	T -= 1


from sys import stdin as sstdin
T = int(sstdin.readline().strip())
while T > 0:
	T -= 1
	(n, x) = list(map(int, sstdin.readline().strip().split()))
	buff = list(map(int, sstdin.readline().strip().split()))
	buff.sort(reverse=True)
	(temp_sum, ans) = (0, 0)
	for i in range(n):
		temp_sum += buff[i]
		if temp_sum / (i + 1) >= x:
			ans += 1
			continue
		else:
			break
	print(ans)


def reforma(x, a):
	sum_ = 0
	count = 0
	for i in a:
		if i > x or (sum_ + i) / (count + 1) >= x:
			sum_ += i
			count += 1
	sum_ = sum_ / count
	return count
T = int(input())
a = {}
for i in range(T):
	(n, x) = map(int, input().split())
	a[i] = sorted(list(map(int, input().split())), reverse=True)
	if x <= int(max(a[i])):
		print(reforma(x, a[i]))
	else:
		print(0)


import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(N, X) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	num = 0
	i = N
	while i >= 0 and num >= X * (N - i):
		i -= 1
		num += a[i]
	print(N - (i + 1))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	w = sorted(map(int, input().split()), reverse=True)
	c = 0
	for i in range(n):
		if w[i] > x:
			c += w[i] - x
		elif w[i] < x:
			c -= x - w[i]
		if c < 0:
			print(i)
			break
	else:
		print(n)


def testCase():
	(n, x) = map(int, input().split())
	people = list(map(int, input().split()))
	people.sort(reverse=True)
	count = 0
	reqSum = 0
	realSum = 0
	for person in people:
		count += 1
		reqSum += x
		realSum += person
		if realSum < reqSum:
			return count - 1
	return n
rez = []
t = int(input())
for i in range(t):
	rez.append(testCase())
for r in rez:
	print(r)


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
for _ in range(vary(1)):
	(n, x) = vary(2)
	num = array_int()
	num.sort(reverse=True)
	s = 0
	k = 0
	for i in range(n):
		s += num[i]
		if s < k * x + x:
			break
		k += 1
	print(k)


T = int(input())
for _ in range(T):
	(n, x) = [int(i) for i in input().split()]
	a = sorted([int(i) for i in input().split()], reverse=True)
	s = 0
	for (i, ai) in enumerate(a):
		s += ai
		if s < x * (i + 1):
			print(i)
			break
	else:
		print(n)


import collections
t = int(input())
for q in range(0, t):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a.sort()
	b = []
	s = sum(a)
	ans = 0
	if s / n >= k:
		print(n)
	else:
		for i in range(0, n):
			s -= a[i]
			if i < n - 1 and s / (n - (i + 1)) >= k:
				ans = n - (i + 1)
				break
			elif a[i] >= k:
				ans += 1
		print(ans)


def solve(coins, x, pop):
	if sum(coins) / pop >= x:
		return pop
	coins = sorted(coins, reverse=True)
	cum = coins[0]
	k = 1
	while cum / k >= x and k < pop:
		cum += coins[k]
		k += 1
	return k - 1

def main():
	n_test_cases = int(input())
	for test_case in range(n_test_cases):
		pop_and_x = input()
		pop = int(pop_and_x.split(' ')[0])
		x = int(pop_and_x.split(' ')[1])
		coins = [int(c) for c in input().split(' ')]
		sol = solve(coins, x, pop)
		print(sol)
main()


try:
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		l = list(map(int, input().split()))
		l = [i - k for i in l]
		l.sort()
		l.reverse()
		c = 0
		d = 0
		for i in l:
			d = d + i
			if d < 0:
				break
			else:
				c = c + 1
		print(c)
except:
	pass


t = int(input())
for _ in range(t):
	(no, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	if x > max(a):
		print(0)
	else:
		p = []
		n = []
		for i in range(no):
			s = a[i] - x
			if s >= 0:
				p.append(s)
			else:
				n.append(s)
		p.sort()
		n.sort(reverse=True)
		s = sum(p)
		count = len(p)
		for i in range(len(n)):
			if s + n[i] < 0:
				break
			s += n[i]
			count += 1
		print(count)


import pdb
queries = int(input())
for _ in range(queries):
	(_, wealth) = map(int, input().split())
	array = [int(item) for item in input().split()]
	array.sort(reverse=True)
	total = 0
	people = 0
	for value in array:
		total += value - wealth
		if total >= 0:
			people += 1
		else:
			break
	print(people)


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 300010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()

def solve():
	(n, x) = arrIN()
	a = arrIN()
	a.sort(reverse=True)
	s = sum(a)
	for i in range(n, 0, -1):
		avg = s / i
		if avg >= x:
			print(i)
			break
		s -= a[i - 1]
	else:
		print(0)
t = int(input())
for _ in range(t):
	solve()


from math import *
from bisect import bisect_left, bisect_right
from sys import stdin, stdout
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	ls = list(map(int, input().split()))
	ls.sort()
	ls.reverse()
	s = 0
	for i in range(len(ls)):
		s += ls[i]
		if s < (i + 1) * x:
			cnt = i
			break
	else:
		cnt = i + 1
	for i in range(len(ls)):
		if ls[i] < x:
			break
	print(str(max(cnt, i)) + '\n')


t = int(input())
for i in range(t):
	f = 0
	(n, x) = map(int, input().split())
	ls = list(map(int, input().split()))
	ls.sort(reverse=True)
	for j in range(n):
		if (f + ls[j]) / (j + 1) >= x:
			if j < n - 1:
				f += ls[j]
			else:
				print(j + 1)
		else:
			print(j)
			break


from math import gcd, sqrt, ceil

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def main():
	for _ in range(ii()):
		(n, x) = mi()
		a = li()
		a.sort(reverse=True)
		s = 0
		ans = 0
		for i in range(n):
			if a[i] >= x:
				s += a[i] - x
			elif a[i] + s < x:
				break
			else:
				s -= x - a[i]
			ans += 1
		print(ans)
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	data = list(map(int, input().split()))
	under_zero = []
	saving = 0
	result = 0
	for i in data:
		now = i - x
		if now < 0:
			under_zero.append(now)
		else:
			saving += now
			result += 1
	under_zero.sort(reverse=True)
	for i in under_zero:
		if -i <= saving:
			saving -= -i
			result += 1
		else:
			break
	print(result)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(n, x) = getVars()
	a = getList()
	s = 0
	res = 0
	d = {}
	for i in range(n):
		if a[i] >= x:
			res += 1
			s += a[i] - x
		else:
			razn = x - a[i]
			if razn not in d:
				d[razn] = 0
			d[razn] += 1
	keys = list(d.keys())
	keys.sort()
	for k in keys:
		if s - k * d[k] >= 0:
			s -= k * d[k]
			res += d[k]
		else:
			res += s // k
			break
	print(res)


t = int(input(''))
for term in range(t):
	(n, x) = map(int, input().split())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	c = 0
	gone = 0
	for i in range(n):
		c += A[i]
		gone += 1
		if c / gone < x:
			gone -= 1
			break
	print(gone)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a, key=lambda b: -b)
	ans = 0
	s = 0
	for i in range(n):
		s += a[i]
		if s / (i + 1) >= x:
			ans = max(ans, i + 1)
	print(ans)


t = int(input())
for _ in range(0, t):
	(n, x) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	a.sort()
	ans = 0
	for i in range(len(a) - 1, -1, -1):
		if i != len(a) - 1:
			a[i] += a[i + 1]
		if a[i] >= x * (len(a) - i):
			ans = len(a) - i
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	l.reverse()
	f = -1
	arrOsum = [l[0]]
	for i in range(1, n):
		arrOsum.append(arrOsum[i - 1] + l[i])
	for i in range(1, n + 1):
		if arrOsum[i - 1] / i >= x:
			f = i
	if f == -1:
		print(0)
	else:
		print(f)


a = int(input())
for i in range(0, a):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	prevsum = sum(arr)
	while len(arr) > 0:
		avg = prevsum / len(arr)
		if avg >= x:
			ans = len(arr)
			break
		else:
			prevsum = prevsum - arr[0]
			arr.pop(0)
	print(ans)


t = int(input())
for t_itr in range(0, t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	total = sum(arr)
	cnt = n
	arr.sort()
	flag = 1
	for i in range(0, n):
		cnt = n - i
		if total / (n - i) >= x:
			flag = 0
			break
		total -= arr[i]
	print(cnt - flag)


t = int(input())
l1 = []
for i in range(t):
	n = list(map(int, input().split()))
	s = list(map(int, input().split()))
	l1.append([s, n])
for j in l1:
	s = 0
	r = 0
	j[0].sort()
	j[0].reverse()
	for k in j[0]:
		if k >= j[1][1]:
			s += 1
			r = r + k - j[1][1]
		else:
			r = r - j[1][1] + k
			if r >= 0:
				s += 1
	print(s)


t = int(input())
for k in range(t):
	vet = []
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if a[0] < x:
		print(0)
		continue
	y = 0
	for i in range(len(a)):
		if a[i] > x:
			y += a[i] - x
			a[i] = x
		elif y >= x - a[i]:
			y -= x - a[i]
			a[i] = x
	aux = 0
	for i in a:
		if i == x:
			aux += 1
	print(aux)


for i in range(int(input())):
	(n, x) = [int(i) for i in input().split(' ')]
	arr = [int(i) for i in input().split(' ')]
	arr.sort()
	running_sum = 0
	count = 0
	for i in range(n - 1, -1, -1):
		running_sum += arr[i]
		if running_sum / (n - i) < x:
			break
		count += 1
	print(count)


import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(n, x) = nm()
	a = nl()
	a = [i - x for i in a]
	a.sort(reverse=True)
	c = 0
	for i in range(n):
		if c + a[i] < 0:
			print(i)
			return
		c += a[i]
	print(n)
	return
T = ni()
for _ in range(T):
	solve()


t = int(input())
for i in range(0, t):
	(n, x) = map(int, input().split(' '))
	li = list(map(int, input().split()))
	li.sort()
	ans = 0
	su = 0
	for j in range(n - 1, -1, -1):
		su = su + li[j]
		avg = su / (ans + 1)
		if avg < x:
			break
		ans = ans + 1
	print(ans)


import sys

def sc(j, k):
	u = 0
	for o in range(len(j)):
		if j[o] >= k:
			u += 1
	return u
e = int(input())
for ee in range(e):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split(' ', n - 1)]
	a.sort()
	a.reverse()
	if a[0] < x:
		print('0')
		continue
	ans = a[0]
	max = 1
	for i in range(1, n):
		ans += a[i]
		if ans / (i + 1) >= x:
			max = i + 1
		else:
			break
	print(max)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	total = sum(a)
	if total / n >= x:
		print(n)
	else:
		for i in sorted(a):
			total -= i
			n -= 1
			if n == 0:
				break
			if total / n >= x:
				break
		print(n)


from sys import stdin

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, x) = [int(x) for x in inp().split()]
	ar = [int(x) for x in inp().split()]
	answers = []
	total = 0
	curr = 0
	totals = []
	if sum(ar) / n >= x:
		print(n)
		continue
	ar.sort(reverse=True)
	for i in range(n):
		total += ar[i]
		totals.append(total)
	for i in range(n):
		if totals[i] / x >= i + 1:
			answers.append(i + 1)
	if answers:
		print(max(answers))
	else:
		test = [j for j in ar if j >= x]
		print(len(test))


t = int(input())
while t:
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	m = []
	c = 0
	s = 0
	for i in range(n):
		if l[i] > x:
			s += l[i] - x
			c += 1
		elif l[i] < x:
			m.append(x - l[i])
		else:
			c += 1
	if len(m) != 0:
		for i in range(len(m) - 1, -1, -1):
			if s >= m[i]:
				s -= m[i]
				c += 1
	print(c)
	t -= 1


for t in range(int(input())):
	(n, x) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	a.sort(reverse=True)
	A = [0] * n
	tot = 0
	for i in range(n):
		tot += a[i]
		A[i] = tot
	d = False
	for i in range(n):
		if A[i] < x * (i + 1):
			print(i)
			d = True
			break
	if not d:
		print(n)


num = int(input())
k1 = 0
while k1 < num:
	neg = []
	sum = 0
	count = 0
	(n, m) = map(int, input().split())
	all_number = input().split()
	for i in range(len(all_number)):
		all_number[i] = int(all_number[i])
		all_number[i] = all_number[i] - m
		if all_number[i] >= 0:
			sum += all_number[i]
			count += 1
		else:
			neg.append(all_number[i])
	neg = sorted(neg)
	neg = neg[::-1]
	for i in range(len(neg)):
		sum += neg[i]
		if sum >= 0:
			count += 1
		else:
			break
	print(count)
	k1 += 1


for i in range(int(input())):
	(n, x) = list(map(int, input().split()))
	s = list(map(int, input().split()))
	s.sort(reverse=True)
	ans = 0
	summ = 0
	ch = 0
	for i in range(len(s)):
		summ += s[i]
		ans += 1
		if summ / ans < x:
			ch = 1
			break
	print(ans - ch)


def num_people(a, x):
	s = 0
	for (i, elem) in enumerate(a):
		s += elem
		if s / (i + 1) < x:
			return i
	return i + 1
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a.sort(reverse=True)
	print(num_people(a, x))


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	best = 0
	for i in a:
		if i >= x:
			best += 1
	pref = []
	pref.append(a[0])
	for i in range(1, n):
		pref.append(pref[i - 1] + a[i])
	for i in range(n):
		if pref[i] // (i + 1) >= x:
			best = max(best, i + 1)
	print(best)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	(k, i, su, avg) = (1, 0, 0, 0)
	l.reverse()
	while i < len(l):
		su += l[i]
		i += 1
		avg = su / k
		if avg < x:
			break
		k += 1
	print(k - 1)


def solve(arr, n, x, ans):
	arr.sort()
	give = 0
	total = 0
	for i in range(n - 1, -1, -1):
		need = max(0, x - arr[i])
		if give >= need:
			total += 1
			give -= need
		give += max(0, arr[i] - x)
	ans.append(total)

def main():
	ans = []
	t = int(input())
	for i in range(t):
		(n, x) = map(int, input().split())
		arr = list(map(int, input().split()))
		solve(arr, n, x, ans)
	for i in ans:
		print(i)
main()


for _ in range(int(input())):
	(n, minn) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	summ = sum(arr)
	ans = n
	for i in range(n):
		if minn <= summ / ans:
			break
		ans -= 1
		summ -= arr[i]
	print(ans)


from sys import stdin, stdout
for test in range(int(stdin.readline())):
	arr1 = [int(x) for x in stdin.readline().split()]
	n = arr1[0]
	x = arr1[1]
	arr = [int(x) for x in stdin.readline().split()]
	arr.sort()
	amt = 0
	ans = 0
	for i in reversed(range(n)):
		if arr[i] >= x:
			amt = amt + arr[i] - x
			ans = ans + 1
			arr[i] = x
		else:
			break
	temp = ans
	for i in reversed(range(n - temp)):
		req = x - arr[i]
		if req <= amt:
			amt = amt - req
			ans = ans + 1
			arr[i] = x
		else:
			break
	stdout.write(str(ans) + '\n')


def solve(arr, x):
	arr.sort(reverse=True)
	extra = 0
	ans = 0
	for p in arr:
		if p < x:
			if extra + p >= x:
				ans = ans + 1
				extra = extra - (x - p)
		else:
			ans = ans + 1
			extra = extra + (p - x)
	return ans
t = int(input())
for i in range(t):
	(n, x) = map(int, input().split(' '))
	ppls = list(map(int, input().split(' ')))
	print(solve(ppls, x))


def answer(n, x, a):
	a.sort(reverse=True)
	sa = [a[0]]
	for i in range(1, n):
		sa.append(a[i] + sa[-1])
	for i in range(n):
		if sa[i] >= (i + 1) * x:
			pass
		else:
			return i
	return n

def main():
	T = int(input())
	n = [0] * T
	x = [0] * T
	a = [0] * T
	for j in range(T):
		(n[j], x[j]) = [int(i) for i in input().split()]
		a[j] = [int(i) for i in input().split()]
	for j in range(T):
		print(answer(n[j], x[j], a[j]))
main()


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	answer = 0
	freq = 0
	value = 0
	for i in range(n):
		value += arr[i]
		freq += 1
		if value / freq >= x:
			answer += 1
		else:
			break
	print(answer)


test = int(input())
for _ in range(test):
	(n, x) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	arr = sorted(arr, reverse=True)
	index = 0
	acum = 0
	while index < len(arr) and (acum + arr[index]) / (index + 1) >= x:
		acum += arr[index]
		index += 1
	print(index)


t = int(input())
while t > 0:
	t -= 1
	(n, x) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	arr.sort()
	ans = sum(arr)
	if x * n <= ans:
		print(n)
	else:
		cnt = -1
		for i in range(0, n):
			if x * (n - i) <= ans:
				cnt = n - i
				break
			else:
				ans -= arr[i]
		if cnt < 0:
			print(0)
		else:
			print(cnt)


t = int(input())
Mod = 100001

def test():
	ans = 0
	(n, x) = map(int, input().split())
	p = list(map(int, input().split()))
	p.sort()
	p.reverse()
	acum = p[0]
	if acum >= x:
		ans = 1
	for i in range(1, len(p)):
		acum += p[i]
		if acum / (i + 1) >= x:
			ans += 1
		else:
			break
	return ans
while t > 0:
	ans = test()
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	b = 0
	c = 0
	for i in range(n):
		c += a[i]
		d = c / (i + 1)
		if d >= x:
			b += 1
		else:
			break
	print(b)


def solve(a, x):
	a.sort()
	n = sm = 0
	while a and sm + a[-1] >= (n + 1) * x:
		sm += a.pop()
		n += 1
	return n
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(solve(a, x))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	A = sorted(map(int, input().split()), reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		s += A[i]
		if s / (i + 1) >= x:
			ans = i + 1
	print(ans)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	(extra, count) = (0, 0)
	for i in range(n):
		if a[i] >= x:
			extra += a[i] - x
			count += 1
	a.reverse()
	for i in range(n):
		if a[i] < x and x - a[i] <= extra:
			count += 1
			extra -= x - a[i]
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)
	a = a[::-1]
	flag = 0
	count = 0
	sum1 = 0
	for i in range(n):
		sum1 = sum1 + a[i]
		count = count + 1
		if count * x <= sum1:
			flag = 1
			break
	if flag == 0:
		print(0)
	else:
		while i < n - 1:
			if (count + 1) * x <= sum1 + a[i + 1]:
				i = i + 1
				sum1 = sum1 + a[i]
				count = count + 1
			else:
				break
		print(count)


t = int(input())
for i in range(0, t):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	a = list(map(int, input().split()))
	a.sort()
	wealthyPeople = 0
	extra = 0
	for j in range(len(a) - 1, -1, -1):
		if a[j] >= x:
			wealthyPeople = wealthyPeople + 1
			extra = a[j] - x + extra
		elif extra >= x - a[j]:
			wealthyPeople = wealthyPeople + 1
			extra = extra - x + a[j]
	print(wealthyPeople)


test = int(input())
for _ in range(test):
	(n, x) = map(int, input().split())
	alist = list(map(int, input().split()))
	avg = sum(alist) / n
	if avg >= x:
		print(n)
		continue
	over_x = 0
	below = []
	count = 0
	for i in alist:
		if i >= x:
			over_x += i - x
		else:
			count += 1
			below.append(i)
	for i in sorted(below, reverse=True):
		need = x - i
		if over_x >= need:
			over_x -= need
			count -= 1
		else:
			break
	print(n - count)


t = int(input())
while t:
	t -= 1
	(m, n) = [int(x) for x in input().split(' ')]
	l = [int(x) for x in input().split(' ')]
	l.sort()
	sum = 0
	for i in l:
		sum += i
	a = 0
	while sum / (m - a) < n and a < m - 1:
		sum -= l[a]
		a += 1
	if a == m - 1:
		if sum >= n:
			print(1)
		else:
			print(0)
	else:
		print(m - a)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	res = 0
	c = 0
	d = 0
	for i in arr:
		res += i
		c += 1
		if res // c >= x:
			d += 1
	print(d)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	prefix_sum = [0 for i in range(n + 1)]
	for i in range(1, n + 1):
		prefix_sum[i] = prefix_sum[i - 1] + a[i - 1]
	total_m = sum(a)
	min_money = min(a)
	ans = 0
	for cand_people in range(min(n, total_m // x), -1, -1):
		if prefix_sum[cand_people] >= cand_people * x:
			ans = cand_people
			break
	print(ans)


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, x) = I()
	w = sorted(I())
	answer = n
	s = sum(w)
	for i in range(n):
		if x <= s / answer:
			break
		answer -= 1
		s -= w[i]
	print(answer)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, x) = map(int, sys.stdin.readline().split())
	l = list(map(int, sys.stdin.readline().split()))
	l.sort(reverse=True)
	s = 0
	ans = 0
	for i in range(n):
		if (s + l[i]) / (i + 1) >= x:
			ans += 1
			s += l[i]
		else:
			break
	print(ans)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = 0
	f = 0
	for i in range(len(l)):
		s += l[i]
		if s // (i + 1) < x:
			f = 1
			print(i)
			break
	if f != 1:
		print(i + 1)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	m = list(map(int, input().split()))
	m.sort()
	summ = sum(m)
	for i in range(len(m)):
		if summ / (len(m) - i) >= x:
			print(len(m) - i)
			break
		summ -= m[i]
	else:
		print(0)


n = int(input())
L2 = []
for k in range(n):
	L = [int(x) for x in input().split()]
	L1 = [int(x) for x in input().split()]
	L1.sort()
	Sum = 0
	i = len(L1) - 1
	count = 0
	while i > -1:
		Sum = Sum + L1[i]
		if Sum / (count + 1) < L[1]:
			break
		count += 1
		i -= 1
	L2.append(count)
for i in L2:
	print(i)


t = int(input())
while t > 0:
	(n, x) = map(int, input().split())
	list = [int(i) for i in input().split()]
	list.sort(reverse=True)
	(i, cnt, money) = (0, 0, 0)
	while i < n:
		if list[i] >= x:
			cnt += 1
			money += list[i] - x
		elif list[i] < x and x - list[i] > money:
			break
		else:
			cnt += 1
			money -= x - list[i]
		i += 1
	print(cnt)
	t -= 1


def solve(n, x, arr):
	arr.sort(reverse=True)
	c = 0
	maxpp = 0
	for i in range(n):
		c += arr[i]
		if c / (i + 1) >= x:
			maxpp = i + 1
		else:
			break
	return maxpp
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = solve(n, x, arr)
	print(ans)


from sys import stdin
for __ in range(int(stdin.readline())):
	(n, x) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	a.sort(reverse=True)
	pre = 0
	ans = 0
	for i in range(n):
		pre += a[i]
		if pre < x * (i + 1):
			break
		else:
			ans += 1
	print(ans)


t = int(input())
for t1 in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	totalOver = 0
	wealthCnt = 0
	totalLess = 0
	middleClassCnt = 0
	for i in range(n):
		if a[i] >= x:
			totalOver += a[i] - x
			wealthCnt += 1
		elif a[i] < x and totalOver - totalLess >= x - a[i]:
			totalLess += x - a[i]
			middleClassCnt += 1
		else:
			break
	print(wealthCnt + middleClassCnt)


for i in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if x > max(a):
		print(0)
	elif sum(a) >= n * x:
		print(n)
	else:
		a = sorted(a, reverse=True)
		c = n
		sum1 = sum(a)
		for i in range(n):
			if sum1 >= x * c:
				print(c)
				break
			else:
				sum1 -= a[-1]
				a.pop()
				c -= 1


import os
import heapq
import sys, threading
import math as mt
import operator
from copy import copy
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, x) = inpt()
		ar = inpt()
		ar.sort(reverse=True)
		ans = 0
		sm = 0
		for i in range(n):
			sm += ar[i]
			val = sm / (i + 1)
			if val >= x:
				ans = i + 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	if sum(a) / n >= x:
		print(n)
	else:
		a.sort(reverse=True)
		if a[0] < x:
			print(0)
		else:
			cnt = 1
			sa = a[0]
			tmp = 1
			while sa + a[tmp] >= x * (1 + tmp) and tmp < len(a) - 1:
				sa += a[tmp]
				tmp += 1
				cnt += 1
			print(cnt)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, x) = li()
	l = li()
	l.sort(reverse=1)
	su = ans = 0
	for i in range(n):
		su += l[i]
		if su / (i + 1) >= x:
			ans = i + 1
	print(ans)


for _ in range(int(input())):
	(n, x) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	have = 0
	ans = 0
	g = []
	for i in range(n):
		if arr[i] >= x:
			have += arr[i] - x
			ans += 1
		else:
			g.append(arr[i])
	g.sort()
	g = g[-1::-1]
	for i in range(len(g)):
		req = x - g[i]
		if have >= req:
			ans += 1
			have -= req
	print(ans)


T = int(input())
for loop in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a.reverse()
	ns = 0
	flag = True
	for i in range(n):
		ns += a[i]
		if ns < (i + 1) * x:
			print(i)
			flag = False
			break
	if flag:
		print(n)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = sorted(arr, reverse=True)
	summ = 0
	count = 0
	for i in range(len(arr)):
		summ += arr[i]
		if summ / (i + 1) < k:
			break
		count += 1
	print(count)


t = int(input())
for m in range(t):
	(a, b) = input().split()
	n = int(a)
	x = int(b)
	l = list(map(int, input().split()))
	W = []
	P = []
	for i in range(n):
		if l[i] >= x:
			W.append(l[i])
		else:
			P.append(l[i])
	s = sum(W)
	P.sort(reverse=True)
	l = len(W)
	flag = -1
	for i in range(len(P)):
		s += P[i]
		if s / (l + i + 1) < x:
			break
		flag = i
	print(l + flag + 1)


from sys import stdin, stdout
q = int(input())
for k in range(q):
	(n, x) = list(map(int, stdin.readline().split()))
	money = list(map(int, stdin.readline().split()))
	money.sort()
	sum1 = 0
	money = money[::-1]
	for i in range(n):
		if money[i] > x:
			sum1 = sum1 + money[i] - x
			money[i] = x
		elif money[i] < x:
			d = x - money[i]
			if sum1 >= d:
				sum1 = sum1 - d
				money[i] = x
	cnt = 0
	for i in money:
		if i >= x:
			cnt = cnt + 1
	print(cnt)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	k = max(a)
	if k < x:
		print(0)
	else:
		s = sum(a)
		if s / n >= x:
			print(n)
		else:
			a.sort()
			for j in range(n, 0, -1):
				y = a[n - j]
				if (s - y) / (j - 1) >= x:
					print(j - 1)
					break
				s = s - y


cases = int(input())
for _ in range(cases):
	(num_people, wealthy_min) = [int(x) for x in input().split()]
	people: list = sorted([int(x) for x in input().split()], reverse=True)
	res: int = 0
	total: int = 0
	avg_w: float = 0
	for (idx, lad) in enumerate(people):
		total += lad
		avg_w = total / (idx + 1)
		if avg_w >= wealthy_min:
			res += 1
		else:
			break
	print(res)


for qq in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)
	ans = sm = 0
	for i in range(n):
		sm += a[i]
		if sm / (i + 1) >= m:
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	a = input()
	(n, x) = a.split(' ')
	(count, sum) = (0, 0)
	b = list(map(int, input().split()))
	for j in b:
		if j >= int(x):
			count += 1
			sum += j - int(x)
	b.sort(reverse=True)
	for j in b:
		if j < int(x):
			if sum >= int(x) - j:
				count += 1
				sum -= int(x) - j
	print(count)


from sys import stdin, stdout

def main():
	N = int(stdin.readline())
	for i in range(N):
		(n, x) = [int(x) for x in stdin.readline().split()]
		arr = [int(x) for x in stdin.readline().split()]
		res = 0
		arr = sorted(arr, reverse=True)
		summ = []
		for idx in range(len(arr)):
			if idx == 0:
				summ.append(arr[idx])
				continue
			summ.append(arr[idx] + summ[idx - 1])
		ind = -1
		for elesum in summ:
			ind += 1
			if elesum / float(ind + 1) >= x:
				res = ind + 1
			else:
				break
		stdout.write(str(res) + '\n')
main()


for _ in range(int(input())):
	(n, w) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	ss = a[0]
	if a[0] >= w:
		ans = 1
	else:
		print(0)
		continue
	for i in range(1, n):
		ss += a[i]
		if ss / (i + 1) >= w:
			ans += 1
		else:
			break
	print(ans)


T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	for i in range(len(a)):
		s += a[i]
		if s / (i + 1) < x:
			print(i)
			break
	else:
		print(len(a))


t = int(input())
for tt in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	sol = 0
	for i in range(n):
		s += a[i]
		if s / (i + 1) >= x:
			sol += 1
	print(sol)


import sys
input = sys.stdin.readline
from collections import *

def judge(i):
	return acc[n] - acc[i] >= (n - i) * x

def binary_search():
	(l, r) = (0, n - 1)
	while l <= r:
		m = (l + r) // 2
		if judge(m):
			r = m - 1
		else:
			l = m + 1
	return l
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	acc = [0]
	for ai in a:
		acc.append(acc[-1] + ai)
	print(n - binary_search())


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	c = list(map(int, input().split()))
	c.sort()
	c = c[::-1]
	if sum(c) < b:
		print(0)
	else:
		d = 0
		e = 1
		f = 0
		for i in range(a):
			d += c[i]
			if d / e < b:
				break
			else:
				e += 1
				f += 1
		print(f)


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	a.sort()
	i = n - 1
	s = 0
	count = 0
	while True:
		s += a[i]
		i -= 1
		count += 1
		if count * x > s:
			print(count - 1)
			break
		if i < 0:
			print(count)
			break


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	w = 0
	ans = 0
	need = 0
	a.sort(reverse=True)
	for i in range(n):
		w += a[i]
		need += x
		if w >= need:
			ans += 1
		else:
			break
	print(ans)


t = int(input())
for i in range(t):
	(n, w) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	s = 0
	for i in range(n):
		s += arr[i]
		if s // (i + 1) < w:
			i -= 1
			break
	print(i + 1)


T = int(input())
while T:
	(n, x) = map(int, input().strip().split())
	savings = list(map(int, input().strip().split()))
	total_sum = sum(savings)
	savings.sort()
	idx = 0
	while n > idx and total_sum / (n - idx) < x:
		total_sum -= savings[idx]
		idx += 1
	print(n - idx)
	T -= 1


n_tests = int(input())
for _ in range(n_tests):
	(n_people, min_money) = list(map(int, input().split()))
	peoples_money = list(map(int, input().split()))
	peoples_money = sorted(peoples_money)[::-1]
	rich_people = 0
	excess_money = 0
	for money in peoples_money:
		if money >= min_money:
			excess_money += money - min_money
			rich_people += 1
		else:
			persons_need = min_money - money
			if excess_money >= persons_need:
				excess_money -= persons_need
				rich_people += 1
			else:
				break
	print(rich_people)


tc = int(input())
for _ in range(tc):
	(n, x) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst.sort(reverse=True)
	(sum, count) = (0, 0)
	for i in lst:
		sum += i
		count += 1
		if sum < x * count:
			print(count - 1)
			break
	else:
		print(n)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	k = 0
	u = 1
	for j in range(n):
		k = k + a[j]
		if k // u < x:
			break
		u = u + 1
	print(u - 1)


T = int(input())
for i in range(T):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	wealthy = 0
	a.sort()
	for j in range(len(a)):
		a[j] = a[j] - x
	for money in reversed(a):
		if money == 0:
			wealthy += 1
			a.remove(money)
	net_pos_money = 0
	index = -1
	for j in range(len(a)):
		if a[j] > 0:
			index = j
			break
	if index == -1:
		print(wealthy)
		continue
	net_pos_money = sum(a[index:])
	wealthy = wealthy + len(a) - index
	b = a[:index]
	b.reverse()
	for k in range(len(b)):
		if net_pos_money + b[k] >= 0:
			wealthy = wealthy + 1
			net_pos_money = net_pos_money + b[k]
		else:
			break
	print(wealthy)


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def lts(a, sep=''):
	return '{}'.format(sep).join(a)
out = []

def main():
	T = iin()
	for _ in range(T):
		(n, x) = lin()
		a = [x - i for i in lin()]
		a.sort()
		sm = 0
		for i in range(n):
			sm += a[i]
			if sm > 0:
				out.append(str(i))
				break
		else:
			out.append(str(n))
main()
print('\n'.join(out))


t = int(input())
ans = []
for i in range(t):
	inpt = input()
	inpt = inpt.split(' ')
	(n, x) = inpt
	n = int(n)
	x = int(x)
	flag = True
	arr = input().split(' ')
	for j in range(n):
		arr[j] = int(arr[j])
	arr.sort(reverse=True)
	if sum(arr) / len(arr) >= x:
		ans.append(n)
	else:
		d = 0
		a = 0
		c = 0
		c2 = 0
		while a < n:
			c += arr[a]
			c2 = c / (a + 1)
			if c2 >= x:
				d = c // x
			a += 1
		ans.append(d)
for i in ans:
	print(i)


def check(a, x, n):
	a.sort()
	s = sum(a)
	for i in range(n):
		if x <= s / n:
			break
		n -= 1
		s -= a[i]
	return n
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	print(check(a, x, n))


i = int(input())
for j in range(0, i):
	arr = [int(num) for num in input().split()]
	minWealth = arr[1]
	arr2 = [int(num) for num in input().split()]
	arr2.sort()
	arr3 = arr2.copy()
	m = sum(arr3)
	k = 0
	while k < arr[0] and m / len(arr3) < minWealth:
		arr3.remove(arr2[k])
		m -= arr2[k]
		k += 1
	print(len(arr3))


def solve(n, x, arr):
	arr.sort(reverse=True)
	count = 0
	summ = 0
	while count < n and summ + arr[count] >= (count + 1) * x:
		summ += arr[count]
		count += 1
	return count
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(solve(n, x, arr))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	gr = n
	for i in range(n):
		if x <= a[i]:
			gr = i
			break
	greater = a[gr:]
	lesser = a[:gr]
	total = sum(greater)
	rich = len(greater)
	for i in range(len(lesser) - 1, -1, -1):
		avg = (total + lesser[i]) / (rich + 1)
		if avg < x:
			break
		else:
			total += lesser[i]
			rich += 1
	print(rich)


t = int(input())
while t:
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	m = []
	c = n
	s = sum(l)
	i = 0
	while s / c < x and i < n:
		s -= l[i]
		c -= 1
		i += 1
		if c == 0:
			break
	print(c)
	t -= 1


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = sorted([int(x) for x in input().split()], reverse=True)
	(s, y) = (0, 0)
	for i in range(n):
		s += arr[i]
		if s / (y + 1) >= x:
			y += 1
		else:
			break
	print(y)


t = int(input())
for it in range(t):
	nandx = list(map(int, input().split()))
	n = nandx[0]
	x = nandx[1]
	town = list(map(int, input().split()))
	town.sort()
	town = town[::-1]
	for i in range(n):
		town[i] = town[i] - x
	s = 0
	count = 0
	for i in range(n):
		if s + town[i] >= 0:
			s = s + town[i]
			count = count + 1
		else:
			break
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = [int(i) for i in input().split()]
	ar = [int(x) for x in input().split()]
	ar = sorted(ar)[::-1]
	cumsum = 0
	not_all = False
	for i in range(n):
		cumsum += ar[i]
		if cumsum / (i + 1) < x:
			not_all = True
			print(i)
			break
	if not not_all:
		print(n)


t = int(input())
for i in range(0, t):
	c = input()
	ncasos = int(c.split(' ')[0])
	x = int(c.split(' ')[1])
	d = list(input().split(' '))
	max = 0
	mayor = []
	for i in range(0, ncasos):
		d[i] = int(d[i])
		if d[i] >= x:
			max += d[i]
			mayor.append(int(d[i]))
	d.sort()
	if max != 0:
		while max / len(mayor) > x and len(mayor) < len(d):
			max += d[len(d) - len(mayor) - 1]
			mayor.append(d[len(d) - len(mayor) - 1])
		if max / len(mayor) < x:
			mayor.pop(len(mayor) - 1)
	print(len(mayor))


from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = inFile.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())

def solve(a, x):
	a = sorted(a)
	(low, high) = (-1, len(a))
	while low + 1 < high:
		mid = (low + high) // 2
		if sum(a[mid:]) / len(a[mid:]) >= x:
			high = mid
		else:
			low = mid
	return len(a[high:])
T = nextInt()
for _ in range(T):
	n = nextInt()
	x = nextInt()
	a = [nextInt() for i in range(n)]
	print(solve(a, x))


t = int(input())
for tt in range(t):
	import bisect
	(n, x) = [int(x) for x in input().split(' ')]
	a = sorted(list(map(int, input().split(' '))), reverse=True)
	St = []
	for i in range(n):
		St.append(x * (i + 1))
	sum_total = sum(a)
	bhul = True
	for i in range(n):
		min_required_sum = St[len(St) - i - 1]
		if sum_total >= min_required_sum:
			print(len(St) - i)
			bhul = False
			break
		elif a[len(a) - 1] >= x:
			print(0)
			bhul = False
			break
		else:
			sum_total -= a.pop()
			continue
	if bhul:
		print(0)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()))
	summa = sum(a)
	i = 0
	while i < n and summa / (n - i) < x:
		summa -= a[i]
		i += 1
	print(n - i)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	track_p = 0
	track_n = 0
	c = 0
	r = []
	s = sorted(a)
	track = 0
	for i in range(n - 1, -1, -1):
		track += s[i] - x
		if track >= 0:
			c += 1
	print(c)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	s = 0
	res = -1
	for i in range(n):
		s += a[i]
		if s / (i + 1) < x:
			if i == 0:
				res = -2
			res = i
			break
	if res == -1:
		print(n)
	elif res >= 0:
		print(res)


def solveSingleCase():
	input_line = input().split(' ')
	(n, x) = (int(i) for i in input_line)
	input_line = input().split(' ')
	wealth = [int(i) for i in input_line]
	wealth.sort(reverse=True)
	su = 0
	ans = 0
	for (num, i) in enumerate(wealth):
		su += i
		if su / (num + 1) >= x:
			ans += 1
	print(ans)
T = int(input())
t = 0
while t < T:
	solveSingleCase()
	t += 1


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	ans = 0
	cnt = a[0]
	flag = True
	for i in range(1, n):
		if cnt >= x * i:
			pass
		else:
			ans = i - 1
			flag = False
			break
		cnt += a[i]
	if flag and cnt >= x * n:
		ans = n
	elif flag:
		ans = n - 1
	print(ans)


t = int(input())
while t > 0:
	l = list(map(int, input().split()))
	n = l[0]
	x = l[1]
	s = list(map(int, input().split()))
	total_sum = sum(s)
	s.sort(reverse=True)
	z = 0
	count = 0
	if total_sum < x:
		print(0)
	else:
		for i in range(len(s)):
			temp = float((s[i] + z) / (i + 1))
			if temp >= x:
				z = z + s[i]
				count = count + 1
			else:
				break
		print(count)
	t = t - 1


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(n, mn) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = 0
	ans = 0
	s = 0
	a.sort(reverse=True)
	for i in range(0, n):
		s = s + a[i]
		m = s / (i + 1)
		if m < mn:
			break
		else:
			ans = ans + 1
	print(ans)


for _ in range(int(input())):
	(n, x) = i = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	a.reverse()
	temp = 0
	cnt = 0
	for i in a:
		if i >= x:
			cnt += 1
			temp += i - x
		elif i + temp >= x:
			temp -= x - i
			cnt += 1
	print(cnt)


q = int(input())
for _ in range(q):
	(n, x) = map(int, input().split())
	s = [int(i) for i in input().split()]
	s.sort(reverse=True)
	a = 0
	for k in range(n):
		a += s[k]
		if a < (k + 1) * x:
			print(k)
			break
	if a >= n * x:
		print(n)


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	saving = list(map(int, input().split()))
	saving.sort(reverse=True)
	s = 0
	c = 0
	for d in saving:
		if (s + d) / (c + 1) < x:
			break
		else:
			s += d
			c += 1
	print(c)


nTests = int(input())
for _ in range(nTests):
	(n, target) = [int(x) for x in input().split()]
	ppl = [int(x) for x in input().split()]
	ppl = sorted(ppl, reverse=True)
	total = 0
	i = 0
	for i in range(n):
		total += ppl[i]
		if total / (i + 1) < target:
			break
	else:
		i += 1
	print(i)


def solve():
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=1)
	s = sum(l)
	a = s / n
	while n > 0 and a < k:
		n -= 1
		if n == 0:
			break
		s -= l.pop()
		a = s / n
	return n
T = int(input())
for __ in range(T):
	print(solve())


import math
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	(s, res) = (0, 0)
	for i in range(len(a)):
		s += a[i]
		if s / (i + 1) >= x:
			res = i + 1
	print(res)


a = int(input())
for _ in range(a):
	(x, y) = map(int, input().split())
	li = list(map(int, input().split()))
	li.sort(reverse=True)
	sum1 = 0
	count1 = 0
	for i in range(x):
		count1 += 1
		sum1 += li[i]
		if sum1 / count1 < y:
			count1 -= 1
			break
	print(count1)


t = int(input())
for z in range(t):
	q = input().split()
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	n = int(q[0])
	x = int(q[1])
	count = 0
	s = 0
	for i in range(n):
		s += a[i]
		if s * 1.0 / (i + 1) >= x:
			count += 1
	print(count)


import sys
input = iter(sys.stdin.readlines()).__next__
T = int(input())
for _ in range(T):
	(n, x) = map(int, input().split())
	a = sorted(map(int, input().split()), reverse=True)

	def max_w():
		numer = 0
		denom = 0
		i = 0
		while i < n:
			numer += a[i]
			denom += 1
			if numer < x * denom:
				break
			i += 1
		return i
	print(max_w())


T = int(input())
t = 0
while t < T:
	t += 1
	(n, x) = map(int, input().split())
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	cnt = 0
	sm = 0
	for i in range(n):
		sm += a[i]
		avg = sm / (i + 1)
		if avg < x:
			break
		cnt += 1
	print(cnt)


import sys
readLine = lambda : sys.stdin.readline()
readInt = lambda : int(sys.stdin.readline())
readInts = lambda : [int(x) for x in sys.stdin.readline().split(' ')]

def main():
	solns = []
	t = readInt()
	for _ in range(t):
		(n, x) = readInts()
		a = readInts()
		a.sort()
		a.reverse()
		acc = 0
		count = 0
		for (i, e) in enumerate(a, start=1):
			if acc + e >= i * x:
				count = i
				acc += e
		solns.append(str(count))
	print('\n'.join(solns))
main()


def solve(a, x):
	a.sort(reverse=True)
	rich_surplus = 0
	count = 0
	for v in a:
		if v > x:
			rich_surplus += v - x
			count += 1
		elif v == x:
			count += 1
		elif v < x:
			if rich_surplus >= x - v:
				rich_surplus -= x - v
				count += 1
			else:
				return count
	return count
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = [int(v) for v in input().split()]
	print(solve(a, x))


def main():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	s = 0
	k = 0
	flag = True
	while flag:
		if k == n:
			flag = False
		elif s + a[k] >= (k + 1) * x:
			s += a[k]
			k += 1
		else:
			flag = False
	return k
for i in range(int(input())):
	print(main())


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	b = sorted(list(map(int, input().split())))
	j = 0
	p = sum(b)
	while j < n:
		if p / (n - j) >= m:
			break
		else:
			p += -b[j]
			j += 1
	print(n - j)


from math import floor
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	a = a[::-1]
	i = n - 1
	s = sum(a)
	res = 0
	while i >= 0:
		if floor(s / (i + 1)) >= x:
			res = i + 1
			break
		s -= a[i]
		i -= 1
	print(res)


t = int(input())
for i in range(t):
	(n, x) = [int(s) for s in input().split()]
	array = [int(s) for s in input().split()]
	rest = 0
	need = []
	ans = 0
	for i in range(len(array)):
		if array[i] >= x:
			rest += array[i] - x
			ans += 1
		else:
			need.append(x - array[i])
	need = sorted(need)
	i = 0
	counter = 0
	while rest >= 0 and i < len(need):
		if rest >= need[i]:
			counter += 1
			rest -= need[i]
			i += 1
		else:
			break
	print(ans + counter)


import sys

def main():
	t = int(input())
	for _ in range(t):
		(n, x) = map(int, sys.stdin.readline().split())
		nums = list(map(int, sys.stdin.readline().split()))
		nums.sort()
		sumVal = sum(nums)
		ans = n
		for i in nums:
			if sumVal / ans >= x:
				break
			sumVal -= i
			ans -= 1
		print(ans)
	return
main()


import sys
import math

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def binary_search(array, x):
	(left, right) = (-1, len(array))
	while left + 1 != right:
		middle = (left + right) // 2
		if array[middle] >= x:
			right = middle
		elif array[middle] < x:
			left = middle
	return right

def c_mod(n1, k1, mod1):
	num = den = 1
	for i in range(n1 - k1):
		num = num * (n1 - i) % mod1
		den = den * (i + 1) % mod1
	return num * pow(den, mod1 - 2, mod1) % mod1

def c12(n1, k1):
	num = den = 1
	for i in range(n1 - k1):
		num = num * (n1 - i)
		den = den * (i + 1)
	return num // den

def v_sistemu(x, k):
	x = int(x)
	z = ''
	while x:
		z += str(x % k)
		x //= k
	return z[::-1]

def iz_sistemi(x, k):
	x = str(x)[::-1]
	ans = 0
	for i in range(len(x)):
		ans += int(x[i]) * pow(k, i)
	return ans

def solve_of_problem():
	(n, x) = idata()
	data = sorted(idata())[::-1]
	ans = -1
	if data[0] < x:
		print(0)
		return
	for i in range(1, n):
		data[i] += data[i - 1]
		z = data[i] / (i + 1)
		if z < x:
			ans = i
			break
	if ans == -1:
		print(n)
	else:
		print(ans)
	return
for ______ in range(int(ii())):
	solve_of_problem()


import math
import random
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, combinations_with_replacement, permutations
MAX_INT = 2 ** 62 - 1
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

def read_n_int() -> list:
	return list(map(int, input().split()))

def read_int() -> int:
	return int(input())

def main():
	t = read_int()
	for _ in range(t):
		(n, x) = read_n_int()
		money = read_n_int()
		total = sum(money)
		if total / n >= x:
			print(n)
			continue
		money.sort()
		cur_sum = 0
		for (i, m) in enumerate(money, 1):
			cur_sum += m
			if n == i or (total - cur_sum) / (n - i) >= x:
				print(n - i)
				break
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	li = []
	li.extend(list(map(int, input().split())))
	li.sort()
	li.reverse()
	c = 0
	if len(li) == 1:
		c = 1 if li[0] >= x else 0
	else:
		s = sum(li)
		for i in range(len(li), 0, -1):
			if s >= x * i:
				c = i
				break
			s -= li[i - 1]
	print(c)


def main():
	op = ''
	t = int(input())
	for i in range(t):
		(n, x) = map(int, input().split(' '))
		ip = [int(item) for item in input().split(' ')]
		ip.sort(reverse=True)
		sumip = ip[0]
		cnt = 0
		if ip[0] >= x:
			cnt = 1
		for i in range(1, n):
			sumip += ip[i]
			if sumip / (i + 1) >= x:
				cnt += 1
			else:
				break
		op += str(cnt) + '\n'
	print(op)
	return op
main()


from sys import stdin

def solve(n, x, A):
	A.sort(reverse=True)
	if A[0] < x:
		return 0
	(ac, i, sz) = (A[0], 1, 1)
	while i < n and (ac + A[i]) / (sz + 1) >= x:
		ac += A[i]
		sz += 1
		i += 1
	return sz

def main():
	r = stdin.readline
	cases = int(r())
	for case in range(cases):
		(n, x) = map(int, r().strip().split())
		A = list(map(int, r().strip().split()))
		print(solve(n, x, A))
main()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	l = []
	sm = 0
	nm = 0
	for i in a:
		if i >= x:
			sm += i
			nm += 1
		else:
			l.append(i)
	l = sorted(l)
	l = l[::-1]
	ans = nm
	sm_now = sm
	now = nm
	for i in range(len(l)):
		now += 1
		sm_now += l[i]
		if sm_now >= now * x:
			ans += 1
		else:
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	for i in a:
		if i >= x:
			count += i - x
	ans = 0
	b = list()
	for i in range(n):
		if a[i] >= x:
			ans += 1
		else:
			b.append(a[i])
	b.sort(reverse=True)
	for i in range(len(b)):
		if x - b[i] > count:
			break
		else:
			count = count - (x - b[i])
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	lst = list(map(int, input().split()))
	lst.sort()
	count = 0
	s = sum(lst)
	l = len(lst)
	for j in range(a):
		res = s / l
		if res >= b:
			print(l)
			break
		else:
			count += 1
			x = lst[j]
			s = s - x
			l = l - 1
	if count == a:
		print('0')


import sys

def wealthy(burles, n, x):
	rich = 0
	wealth = 0
	for i in burles:
		if (wealth + i) // (rich + 1) >= x:
			rich += 1
			wealth += i
		else:
			break
	return rich
t = int(input())
for i in range(t):
	(n, x) = map(int, sys.stdin.readline().split())
	burles = list(map(int, sys.stdin.readline().strip().split()))
	burles.sort(reverse=True)
	print(wealthy(burles, n, x))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, x) = mints()
	a = list(mints())
	a.sort(reverse=True)
	s = 0
	r = 0
	for i in range(n):
		s += a[i]
		if s >= x * (i + 1):
			r = i + 1
		else:
			break
	print(r)
for i in range(mint()):
	solve()


t = int(input())
for _ in range(t):
	(n, x) = input().split()
	(n, x) = (int(n), int(x))
	a = input().split()
	a = [int(ai) for ai in a]
	a.sort(reverse=True)
	for i in range(1, n):
		a[i] += a[i - 1]
	i = 0
	while i < n:
		if a[i] / (i + 1) < x:
			break
		i += 1
	print(i)


t = int(input())
for e in range(t):
	(n, x) = map(int, input().rstrip().split())
	arr = list(map(int, input().rstrip().split()))
	arr.sort(reverse=True)
	count = 0
	summ = 0
	s = 0
	d = 1
	for i in range(n):
		summ = summ + arr[i]
		s = summ / d
		d += 1
		if s >= x:
			count += 1
			continue
		else:
			break
	print(count)


t = int(input().strip())
for _ in range(t):
	(n, x) = map(int, input().strip().split(' '))
	a = list(map(int, input().strip().split(' ')))
	a.sort()
	(sm, trailAvg) = (0, 0)
	for i in range(n):
		sm += a[n - 1 - i]
		trailAvg = sm / (i + 1)
		if trailAvg < x:
			break
	ans = (i, i + 1)[trailAvg >= x]
	print(ans)


from sys import stdin
inp = stdin.readline
t = int(inp().strip())
for _ in range(t):
	(n, x) = [int(x) for x in inp().strip().split()]
	a = [int(x) for x in inp().strip().split()]
	a.sort(reverse=True)
	ans = 0
	total = 0
	for i in range(1, n + 1):
		total += a[i - 1]
		if total / i >= x:
			ans = i
	print(ans)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))[:a]
	l.sort(reverse=True)
	s = 0
	c = 0
	for j in l:
		if (s + j) // (c + 1) >= b:
			s += j
			c += 1
		else:
			break
	print(c)


import sys
import random
from math import log2, log, ceil
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a > 0:
		return gcd(b % a, a)
	return b

def primefs(n):
	if n == 1:
		return 1
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]
spf_sieve()

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, x) = int_array()
	a = int_array()
	a.sort()
	this = sum(a)
	ans = n
	i = 0
	while ans > 0 and this / ans < x:
		this -= a[i]
		ans -= 1
		i += 1
	print(ans)


t = int(input())
for q in range(t):
	(n, x) = map(int, input().split())
	mas = list(map(int, input().split()))
	ans = []
	mas2 = []
	for i in range(n):
		if mas[i] >= x:
			ans.append(mas[i])
		else:
			mas2.append(mas[i])
	suma = sum(ans)
	kol = len(ans)
	if kol == 0:
		print(0)
		continue
	mas2.sort()
	mas2 = mas2[::-1]
	for i in range(len(mas2)):
		new = suma + mas2[i]
		if new / (kol + 1) >= x:
			suma = new
			kol += 1
		else:
			break
	print(kol)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(key=lambda b: b - x, reverse=True)
	ans = 0
	stored = 0
	for i in range(n):
		if a[i] >= x:
			ans += 1
			stored += a[i] - x
		elif stored >= x - a[i]:
			stored -= x - a[i]
			ans += 1
	print(ans)


for t in range(int(input())):
	(n, x) = map(int, input().split())
	arr = sorted(list(map(int, input().split())))[::-1]
	h = 0
	a = 0
	while h >= 0 and a < n:
		if arr[a] - x + h >= 0:
			h += arr[a] - x
			a += 1
		else:
			break
	print(a)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	l = sorted(list(map(int, input().split())))
	s = sum(l)
	for i in l:
		if s >= n * k:
			break
		(s, n) = (s - i, n - 1)
	print(n)


def funct(a, x, n):
	a.sort(reverse=True)
	summ = 0
	count = 0
	while count < n:
		summ = summ + a[count]
		count += 1
		if summ / count < x:
			return count - 1
	return n
n = int(input())
for i in range(n):
	m = input().split()
	o = int(m[0])
	x = int(m[1])
	b = input().split()
	a = []
	for j in b:
		a.append(int(j))
	print(funct(a, x, o))


t = int(input())
for i in range(t):
	n_m = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	sum_n = 0
	for j in range(n_m[0]):
		sum_n += a[n_m[0] - j - 1]
		if sum_n / (j + 1) >= n_m[1]:
			count += 1
		else:
			break
	print(count)


t = int(input())
for q in range(t):
	(n, threshold) = map(int, input().split())
	money = list(map(int, input().split()))
	count = 0
	if sum(money) / n > threshold:
		print(n)
		continue
	money.sort(reverse=True)
	s = 0
	lastindex = 0
	for x in range(n):
		s += money[x]
		if s / (x + 1) >= threshold:
			count += 1
		else:
			break
	print(count)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(n, k) = invr()
	ara = inara()
	ara.sort(reverse=True)
	ans = 0
	tot = 0
	for i in range(n):
		tot += ara[i]
		if tot / (i + 1) >= k:
			ans = i + 1
	print(ans)


for t in range(int(input())):
	(n, x) = map(int, input().strip().split())
	v = list(map(int, input().strip().split()))
	v.sort()
	s = 0
	c = 0
	for i in range(n - 1, -1, -1):
		s += v[i] - x
		c += 1
		if s < 0:
			c -= 1
			break
	print(c)


def max_wealthy(n_people, people, target):
	people = sorted(people, reverse=True)
	s = 0
	for i in range(1, n_people + 1):
		s += people[i - 1]
		if s / i < target:
			return i - 1
	return n_people
t = int(input())
for _ in range(t):
	(n, t) = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	print(max_wealthy(n, p, t))


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	extra = 0
	flag = 0
	if a[0] < x:
		print(0)
	else:
		for i in range(n):
			if a[i] > x:
				extra = extra + a[i] - x
			else:
				extra = extra - x + a[i]
				if extra < 0:
					flag = 1
					break
		if flag == 0:
			print(i + 1)
		else:
			print(i)


t = int(input())
for x in range(t):
	(n, x) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	aux = 0
	flag = False
	if a[0] < x:
		print(0)
		continue
	for i in range(n):
		if a[i] > x:
			aux += a[i] - x
			a[i] = x
		elif aux >= x - a[i]:
			aux -= x - a[i]
			a[i] = x
	out = 0
	print(a.count(x))


def solve(n, x, list):
	if int(sum(list) / n) >= x:
		return n
	elif max(list) < x:
		return 0
	else:
		list.sort()
		count = 1
		j = 2
		for i in range(n - 1, 1, -1):
			list[i - 1] = list[i - 1] + list[i]
			if float(list[i - 1] / j) >= x:
				count += 1
			j += 1
		return count
t = int(input())
output = []
for i in range(t):
	(n, x) = [int(x) for x in input().split()]
	list = [int(y) for y in input().split()]
	output.append(solve(n, x, list))
for i in range(t):
	print(output[i])


from sys import stdin, stdout
import bisect
import math

def main():
	for _ in range(int(stdin.readline())):
		(n, x) = map(int, stdin.readline().split())
		arr = [int(k) for k in stdin.readline().split()]
		arr.sort(reverse=True)
		total = 0
		counter = 0
		ind = 0
		for i in range(n):
			total = total + arr[i]
			res = total / (i + 1)
			if res >= x:
				continue
			else:
				counter = 1
				ind = i - 1
				break
		if counter == 1:
			print(ind + 1)
		else:
			print(n)
main()


from sys import stdin, stdout
from collections import *
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, k) = mp()
	l = li()
	x = sorted(l, reverse=True)
	a = 0
	ans = 0
	i = 0
	while i < n and (a + x[i]) / (i + 1) >= k:
		a += x[i]
		ans += 1
		i += 1
	print(ans)
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort()
	sm = 0
	c = 1
	ans = 0
	for t in range(n - 1, -1, -1):
		sm += l[t]
		if sm / c >= x:
			ans += 1
		c += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = list(map(int, input().split()))
	x.sort()
	(count, ans) = (0, 0)
	for i in range(n - 1, -1, -1):
		count += x[i]
		if count // (n - i) >= k:
			ans += 1
		else:
			break
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = sorted(list(map(int, input().split())), reverse=True)
	x = 0
	s = 0
	m = x
	for i in range(n):
		if (s + l[i]) / (x + 1) >= k:
			s += l[i]
			x += 1
		else:
			m = max(m, x)
			if l[i] >= k:
				x = 1
				s = l[i]
			else:
				x = 0
				s = 0
	m = max(x, m)
	print(m)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	total = sum(arr)
	if int(total / n) >= x:
		print(n)
	else:
		flag = 0
		for j in range(n - 1):
			total -= arr[j]
			val = int(total / (n - j - 1))
			if val >= x:
				print(n - j - 1)
				flag = 1
				break
		if flag == 0:
			print(0)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	(n, x) = li()
	a = li()
	a.sort()
	c = 0
	ans = 0
	for i in range(n):
		if a[i] >= x:
			c = c + a[i] - x
	a.sort(reverse=True)
	for i in range(n):
		if a[i] < x:
			if c >= x - a[i]:
				c = c - (x - a[i])
				a[i] = x
	for i in range(n):
		if a[i] >= x:
			ans += 1
	print(ans)
for _ in range(int(input())):
	case()


test = int(input())
for t in range(test):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	arr = list(map(int, input().split()))
	arr.sort()
	sums = 0
	avg = 0
	ans = 0
	for i in range(len(arr) - 1, -1, -1):
		sums += arr[i]
		avg = sums / (n - i)
		if avg >= x:
			ans += 1
		else:
			break
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	s = sum(arr)
	count = 0
	prev_min = 0
	index = 0
	while index < n:
		l = n - index
		s -= prev_min
		if s / l >= x:
			count += 1
		prev_min = arr[index]
		index += 1
	print(count)


t = int(input())
for x in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	rich = 0
	extra = 0
	a.sort(reverse=True)
	for rev in a:
		if rev >= x:
			rich += 1
			extra += rev - x
		elif x - rev <= extra:
			rich += 1
			extra -= x - rev
		else:
			break
	print(rich)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = 0
	l = []
	count = 0
	for i in range(n):
		p = arr[i] - x
		if p > 0:
			s += p
			count += 1
		else:
			l.append(p)
	l = sorted(l, reverse=True)
	for x in l:
		if s + x < 0:
			break
		else:
			s = s + x
			count += 1
	print(count)


def func(arr, k):
	sum = 0
	for i in range(len(arr)):
		sum += arr[i]
	if sum / len(arr) >= k:
		return len(arr)
	length = len(arr)
	arr = sorted(arr)
	i = 0
	while length > 0 and sum / length < k and (i < len(arr)):
		sum -= arr[i]
		i += 1
		length -= 1
	return length
k = int(input())
for p in range(k):
	(n, m) = map(int, input().split())
	array = list(map(int, input().split()))
	print(func(array, m))


def solve(wealthy, people):
	good = []
	bad = []
	for p in people:
		if p >= wealthy:
			good.append(p)
		else:
			bad.append(p)
	if len(good) == 0:
		return 0
	if len(bad) == 0:
		return len(good)
	s = sum(good)
	nr = len(good)
	cond = True
	bad.sort()
	while cond:
		p = bad.pop(len(bad) - 1)
		if (p + s) / (nr + 1) >= wealthy:
			s += p
			nr += 1
			if len(bad) == 0:
				cond = False
		else:
			cond = False
	return nr

def main():
	t = int(input())
	for _ in range(t):
		(a, w) = [int(x) for x in input().split(' ')]
		p = [int(x) for x in input().split(' ')]
		print(solve(w, p))
main()


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	a = a[::-1]
	q = 0
	i = 1
	while i < n + 1:
		q += a[i - 1]
		if q / i >= x:
			i += 1
		else:
			break
	print(i - 1)


import sys
from queue import LifoQueue
input = sys.stdin.readline
t = int(input())
for r in range(t):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l = sorted(l, reverse=True)
	summ = 0
	count = 0
	for i in range(n):
		summ += l[i]
		if summ / (i + 1) >= x:
			count += 1
		else:
			summ = l[i]
			if summ >= x:
				count += 1
			else:
				summ = 0
	print(count)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	k = list(map(int, input().split()))
	a = []
	c = 0
	ans = 0
	for i in k:
		if i >= x:
			c += i - x
			ans += 1
		else:
			a.append(x - i)
	a = sorted(a)
	for i in a:
		if c >= i:
			c -= i
			ans += 1
	print(ans)


def main():
	cases = int(input())
	for case in range(1, cases + 1):
		(n, x) = [int(i) for i in input().split()]
		savings = [int(x) for x in input().split()]
		savings = sorted(savings)[::-1]
		i = 1
		if max(savings) >= x:
			max_w = 1
		else:
			max_w = 0
		tot = savings[0]
		divid = savings[0]
		while divid >= x and i < n:
			tot += savings[i]
			divid = tot / (i + 1)
			if divid >= x:
				max_w = i + 1
			i += 1
		print(max_w)
main()


import itertools
T = int(input())
for t in range(T):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	m = 0
	s = sum(a)
	for i in range(len(a), 0, -1):
		if s / i >= x:
			m = i
			break
		s -= a[i - 1]
	print(int(m))


t = int(input())
for _ in range(t):
	(n, x) = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	if max(a) < x:
		print(0)
		continue
	higher = 0
	count = 0
	a.sort(reverse=True)
	for i in a:
		if i < x:
			break
		higher += i - x
		count += 1
	for i in a:
		if i < x and x - i <= higher:
			higher -= x - i
			count += 1
		if higher <= 0:
			break
	print(count)


t = int(input())
for i in range(t):
	arr = []
	(n, t) = input().split(' ')
	n = int(n)
	t = int(t)
	arr = [int(x) for x in input().split(' ')]
	arr.sort(reverse=True)
	s = 0
	max = 0
	for i in range(n):
		s = s + arr[i]
		if t * (i + 1) <= s:
			max = i + 1
	print(max)


import bisect
t = int(input())
for test in range(t):
	(n, x) = [int(x) for x in input().split()]
	savings = [int(x) for x in input().split()]
	savings.sort()
	(required, y, ans) = ([], 0, 0)
	for i in range(n):
		if savings[i] >= x:
			ans += 1
			y += savings[i]
		else:
			required.append(savings[i])
	required.sort(reverse=True)
	for i in range(len(required)):
		y += required[i]
		if y / (ans + 1) < x:
			y -= required[i]
			break
		else:
			ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	lst = 0
	ans = 0
	for i in range(n):
		if a[i] >= x:
			lst = i
			ans += 1
	cursum = 0
	ptr = 0
	for i in range(lst + 1, n):
		while cursum + (a[i] - x) < 0 and ptr <= lst:
			cursum += a[ptr] - x
			ptr += 1
		cursum += a[i] - x
		if cursum >= 0:
			ans += 1
	print(ans)


t = int(input())
for w in range(t):
	(n, x) = (int(i) for i in input().split())
	l = sorted([int(i) for i in input().split()])
	s = sum(l)
	if s >= n * x:
		print(n)
	else:
		for i in range(n):
			s -= l[i]
			if s >= x * (n - i - 1):
				print(n - i - 1)
				break


t = int(input())

def bs(a, x):
	(l, r) = (0, len(a))
	while l + 1 != r:
		m = (l + r) // 2
		if x <= sum(a[0:m + 1]) / (m + 1):
			l = m
		else:
			r = m
	return r
for i in range(t):
	f = 0
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=1)
	b = bs(a, x)
	if b == 1:
		if a[0] < x:
			print(0)
		else:
			print(1)
	else:
		print(b)


def solve():
	n = list(map(int, input().split()))
	a = int(n[0])
	x = int(n[1])
	v = list(sorted(map(int, input().split()), reverse=True))
	count = 0
	ans = 0
	for i in range(a):
		count += v[i]
		if count / (i + 1) >= x:
			ans += 1
		else:
			break
	print(ans)
t = input().split()
t = int(t[0])
for _ in range(t):
	solve()


import sys
for _ in range(int(input())):
	(n, x) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	s_arr = reversed(sorted(arr))
	save = 0
	cnt = 0
	for i in s_arr:
		if save + i - x >= 0:
			cnt += 1
			save += i - x
		else:
			break
	print(cnt)


import math
import bisect
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	summ = 0
	count = 0
	for i in range(n):
		summ += arr[i]
		if summ / (i + 1) >= k:
			if i + 1 > count:
				count = i + 1
	if count == n:
		print(n)
	else:
		for j in range(n - 1):
			summ -= arr[j]
			if summ / (n - 1 - j) >= k:
				if n - 1 - j > count:
					count = n - 1 - j
		print(count)


import math
from sys import stdin
mx = math.inf
mn = -math.inf

def i():
	return int(stdin.readline().strip())

def f():
	return float(stdin.readline().strip())

def s():
	return stdin.readline().strip()

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

def arf():
	return list(map(float, stdin.readline().split()))

def ars():
	return list(map(str, stdin.readline().split()))

def main():
	(n, x) = ari()
	arr = ari()
	arr.sort(reverse=True)
	(cnt, s) = (0, 0)
	for i in range(n):
		s += arr[i]
		if s / (i + 1) >= x:
			cnt += 1
		else:
			break
	print(cnt)
t = 1
t = i()
for _ in range(t):
	main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	s = sum(a)
	counter = 0
	for i in range(n):
		if s / (n - i) >= k:
			counter = n - i
			break
		else:
			s = s - a[i]
	print(counter)


t = int(input())
while t:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	sumsofar = 0
	ans = n
	for i in range(0, n):
		sumsofar += arr[i]
		if sumsofar < k * (i + 1):
			ans = i
			break
	print(ans)


t = int(input())
for i in range(t):
	(n, x) = map(int, input().split())
	a = list(map(float, input().split()[:n]))
	b = 0
	c = []
	d = 0
	e = 0
	for j in range(n):
		if a[j] >= x:
			b = b + 1
			d = d + a[j] - x
		else:
			c.append(x - a[j])
	c.sort()
	for j in range(len(c)):
		if d >= c[j]:
			d = d - c[j]
			b = b + 1
	print(b)


rich_counters = []
T = int(input())
for i in range(T):
	n_x = input()
	n = int(n_x.split(' ')[0])
	x = int(n_x.split(' ')[1])
	a = list(map(lambda x: int(x), input().split(' ')))
	sorted_a = sorted(a, reverse=True)
	check_list = []
	rich_counter = 0
	sum_ = 0
	len_ = 0
	for item in sorted_a:
		sum_ += item
		len_ += 1
		if sum_ / len_ >= x:
			rich_counter += 1
	rich_counters.append(rich_counter)
for counter in rich_counters:
	print(counter)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	sum = 0
	avg = 0
	cnt = 0
	for i in range(len(a)):
		sum = sum + a[i]
		avg = sum / (i + 1)
		if avg < x:
			break
		else:
			cnt += 1
	print(cnt)


t = int(input())
for test in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	p = []
	r = []
	found = 0
	nr = 0
	for z in a:
		if z < x:
			p.append(z - x)
		else:
			found += z - x
			nr += 1
	p.sort(reverse=True)
	s = 0
	newr = 0
	for e in p:
		if found + e >= 0:
			found += e
			newr += 1
		else:
			break
	print(nr + newr)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, x) = LI()
		a = LI()
		a = sorted(a, reverse=True)
		r = n
		t = 0
		for i in range(n):
			t += a[i]
			if t / (i + 1) < x:
				r = i
				break
		rr.append(r)
	return JA(rr, '\n')
print(main())


from _collections import deque
import sys
sys.setrecursionlimit(10000)
import math
import heapq
import bisect
r = int(input())
t = -1

def input():
	global t
	t += 1
	return data[t]
data = sys.stdin.readlines()
for _ in range(r):
	(n, x) = map(int, input().split())
	a = sorted(list(map(int, input().split())), reverse=True)
	d = 0
	i = 0
	while i < n and a[i] >= x:
		d += a[i] - x
		i += 1
	while i < n and d - (x - a[i]) >= 0:
		d -= x - a[i]
		i += 1
	print(i)


test_cases = int(input())

def handle():
	(_, x) = input().split(' ')
	x = int(x)
	values = sorted([int(s) for s in input().split(' ')], reverse=True)
	count = 0
	summation = 0
	for value in values:
		if value >= x:
			summation += value
			count += 1
		elif count > 0 and (summation + value) / (count + 1) >= x:
			summation += value
			count += 1
		else:
			break
	return count
for _ in range(test_cases):
	print(handle())


t = int(input())
while t != 0:
	t -= 1
	(n, x) = [int(y) for y in input().split()]
	a = [int(y) for y in input().split()]
	a = sorted(a)
	s = sum(a)
	k = n
	j = 0
	while s // k < x:
		s -= a[j]
		j += 1
		k -= 1
		if k == 0:
			break
	print(n - j)


t = int(input())
import heapq as hq
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:n]
	heap = []
	hq.heapify(heap)
	for num in arr:
		hq.heappush(heap, -num)
	sums = -hq.heappop(heap)
	count = 1
	ans = 0
	temp = sums
	while heap and sums >= k:
		ans += 1
		count += 1
		num = -hq.heappop(heap)
		sums = (temp + num) / count
		temp += num
	if sums >= k:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	(S, N, flag, i) = (sum(a), len(a), 0, 0)
	while N > 0:
		if S / N >= x:
			print(N)
			flag = 1
			break
		else:
			S -= a[i]
			N -= 1
			i += 1
	if not flag:
		print(0)


T = int(input())
for i in range(T):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	s = sum(arr)
	ans = 0
	for i in arr:
		if s / n >= x:
			ans = n
			break
		else:
			s -= i
			n -= 1
	print(ans)


from itertools import accumulate
for ii in range(int(input())):
	(n, x) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr = sorted(arr, reverse=True)
	psum = list(accumulate(arr))
	count = 0
	for i in range(1, n + 1):
		if psum[i - 1] >= x * i:
			count = i
	print(count)


def cando():
	(number_of_people, minimum_as_wealthy) = map(int, input().split())
	savings = list(map(int, input().split()))
	savings.sort(reverse=True)
	total = 0
	for (i, e) in enumerate(savings):
		total += e
		if total / (i + 1) < minimum_as_wealthy:
			return i
	return len(savings)
T = int(input())
for t in range(T):
	print(cando())


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = sum(arr) / n
	if s >= k:
		print(n)
		continue
	arr.sort(reverse=True)
	a = 0
	count = 0
	for i in range(n):
		a += arr[i]
		if a / (i + 1) < k:
			break
		count += 1
	print(count)


def main():
	t = int(input())
	for _ in range(t):
		(n, x) = [int(elem) for elem in input().split()]
		savings = [int(elem) for elem in input().split()]
		savings.sort(reverse=True)
		total = sum(savings)
		counter = n
		list_pos = counter - 1
		x = float(x)
		while True:
			if not counter:
				break
			average = total / counter
			if average >= x:
				break
			total -= savings[list_pos]
			counter -= 1
			list_pos -= 1
		print(counter)
main()


from itertools import accumulate
t = int(input())
for _ in range(t):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	a = sorted(a)[::-1]
	ct = 0
	if a[0] < x:
		print('0')
	else:
		pf = list(accumulate(a))
		for i in range(n):
			if pf[i] / (i + 1) >= x:
				ct += 1
		print(ct)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	counter = 0
	cur_sum = 0
	flag = 0
	for i in l:
		counter += 1
		cur_sum += i
		if cur_sum / counter >= x:
			pass
		else:
			flag = 1
			break
	if flag:
		print(counter - 1)
	else:
		print(counter)


import math
for w in range(int(input())):
	x = list(map(int, input().split()))
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if x[0] == 1:
		if a[0] >= x[1]:
			print('1')
		else:
			print('0')
	else:
		cont = 0
		soma = 0
		if a[0] >= x[1]:
			cont += 1
			soma += a[0]
			for u in range(1, x[0]):
				if (soma + a[u]) / (cont + 1) >= x[1]:
					cont += 1
					soma += a[u]
				else:
					break
			print(cont)
		else:
			print(0)


import collections, math, bisect
local = False
if local:
	file = open('input.txt', 'r')
	import time

def inp():
	if local:
		return file.readline().rstrip()
	else:
		return input().rstrip()

def ints():
	return [int(_) for _ in inp().split()]
if local:
	start = time.time()
t = int(inp())
for _ in range(1, t + 1):
	(n, x) = ints()
	arr = ints()
	arr.sort()
	greater = summed = eq = 0
	l = -1
	for i in range(n - 1, -1, -1):
		if arr[i] > x:
			greater += 1
			summed += arr[i]
		elif arr[i] < x:
			l = i
			break
		else:
			eq += 1
	if l == -1:
		print(n)
		continue
	elif greater == 0:
		print(eq)
		continue
	while l >= 0:
		summed += arr[l]
		if summed / (greater + 1) >= x:
			greater += 1
			l -= 1
		else:
			break
	print(greater + eq)
if local:
	fin = (time.time() - start) * 1000
	print('{:.2f}'.format(fin) + 'ms')