#include using namespace std; template bool cmin(T &a, U b) { return a > b && (a = b, true); } template bool cmax(T &a, U b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int T; cin >> T; while (T--) { int N; cin >> N; multiset MS; for (int i = 0; i < N; i++) { int L; cin >> L; MS.insert(L); } int ans = 0, now = -1; while (MS.size()) { auto it = --MS.end(); now = *it; MS.erase(it); if (!MS.size()) break; it = MS.lower_bound(now); if (it == MS.begin()) break; it--; now = *it; MS.erase(it); if (!MS.size()) break; it = MS.lower_bound(now); if (it == MS.begin()) break; it--; now = *it; MS.erase(it); ans++; } cout << ans << "\n"; } }