#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using pii = pair<int ,int>; using vpii = vector<pair<int, int>>; using pipii = pair<int, pii>; ll a[100001]; void solve() { int n, d = 0, e = 0, f = 0; ll k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a+n); int j = 0; while (j<n && a[j] < k) j++; e = n - j; for (int i = 0; i < n; i++) { j--; while (j > i && a[i] + a[j] >= k) { j--; f++; } if (i >= j) { break; } d++; } f++; int x =0; if (d * 3 >= n) x = (n-1)/3; else { x = d, e-=d; if (e < 0) { f += e, e=0; } if (e <= f) x += (e + f - 1) / 2; else x += e-1; } cout << x << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--) solve(); return 0; }