#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0)->sync_with_stdio(0); int t; cin >> t; while (t --) { int n, k; cin >> n >> k; vector<int> d(n); for (int i = 0; i < n ; ++i) { cin >> d[i]; } int gt = 0; for (int i = 0; i < n ; ++i) { gt += d[i] >= k; } sort(d.begin(), d.end()); auto check = [&](int m) { multiset<int> vals; for (int i = 0; i < n - m; ++i) vals.insert(d[i]); int cnt = 0; while (vals.size()) { ++cnt; auto it = vals.end(); --it; int big = *it; vals.erase(it); auto comp = vals.lower_bound(k - big); if (comp == vals.begin()) continue; --comp; vals.erase(comp); } return cnt <= m; }; int l = gt, r = n; int ans = gt; while (l <= r) { int m = l + (r - l) / 2; if (check(m)) { ans = m; r = m - 1; } else { l = m + 1; } } cout << ans - 1 << '\n'; } }