#include <bits/stdc++.h> using namespace std; #define int long long #define F first #define S second const int INF = 1e18; signed main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while(t--){ int n; cin>>n; int k; cin>>k; vector<int>d(n); for(int i = 0;i<n;i++)cin>>d[i]; sort(d.begin(),d.end()); int l = 0; int r = n; while(l<=r){ int mid = (l+r)/2; int m = n-mid; int boxes = 0; int j = m-2; vector<int>used(m,0); for(int i = m-1;i>=0;i--){ j = min(i-1,j); if(used[i])continue; if(d[i]>=k){ boxes = INF; break; } while(j>=0 && d[j]+d[i]>=k)j--; if(j<0)boxes++; else{ used[j] = 1; boxes++; } } if(boxes>mid)l = mid+1; else r = mid-1; } cout<<l-1<<endl; } }