#include #include #include #include #include bool isBambooCol(int a, int b, int c) { // a,b,cが門松列かの判定 if (a == b || a == c || b == c) return false; if (b < a && b < c) return true; if (b > a && b > c) return true; return false; } void calc() { int bamboo_no; // 竹の本数 std::cin >> bamboo_no; // <個数, 竹の長さ> std::priority_queue > bamboo; std::map m; for (int i = 0; i < bamboo_no; i++) { int bamboo_length; std::cin >> bamboo_length; m[bamboo_length]++; } for (auto it = m.begin(); it != m.end(); it++) { bamboo.push({ it->second, it->first }); } long long ans = 0; while (!bamboo.empty()) { auto f = bamboo.top(); bamboo.pop(); if (bamboo.empty()) break; auto s = bamboo.top(); bamboo.pop(); if (bamboo.empty()) break; auto t = bamboo.top(); bamboo.pop(); ans++; f.first--; s.first--; t.first--; if(f.first != 0) bamboo.push(f); if(s.first != 0) bamboo.push(s); if(t.first != 0) bamboo.push(t); } std::cout << ans << std::endl; } int main() { int test_case; std::cin >> test_case; for (int i = 0; i < test_case; i++) { calc(); } return 0; }