#include <bits/stdc++.h> using namespace std; #define fwd(i, a, n) for(int i = (a); i < (n); i++) #define rep(i, n) fwd(i, 0, n) #define all(X) X.begin(), X.end() #define sz(X) int(size(X)) #define pb push_back #define eb emplace_back #define st first #define nd second using pii = pair<int, int>; using vi = vector<int>; using ll = long long; using ld = long double; #ifdef LOC auto SS = signal(6, [](int) {* (int *) 0 = 0;}); #define DTP(x, y) auto operator << (auto& o, auto a) -> decltype(y, o) {o << "("; x; return o << ")";} DTP(o << a.st << ", " << a.nd, a.nd); DTP(for(auto i : a) o << i << ", ", all(a)); void dump(auto... x) {((cerr << x << ", "), ...) << "\n";} #define deb(x...) cerr << setw(4) << __LINE__ << ":[" #x "]: ", dump(x) #else #define deb(...) 0 #endif void solve() { int n; cin >> n; int k; cin >> k; int ans = 0; multiset<int> V; for(int i = 1; i <= n; i++){ int x; cin >> x; if(x > k) { ans++; }else{ V.insert(x); } } // sort(all(V)); while(!V.empty()) { int x = *V.begin(); ans++; V.erase(V.begin()); if(V.empty()) break; auto it = V.lower_bound(k-x); if(it == V.begin()) { int p = *V.rbegin(); V.erase(V.lower_bound(p)); } else { it = prev(it); V.erase(it); if(!V.empty()) { int p = *V.rbegin(); V.erase(V.lower_bound(p)); } } } cout << ans-1 << "\n"; } int32_t main(){ cin.tie(0)->sync_with_stdio(0); cout << fixed << setprecision(10); int t; cin >> t; while(t--) { solve(); } return 0; }