use std::collections::{HashMap, BinaryHeap}; fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); for _ in 0..t { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut l = String::new(); std::io::stdin().read_line(&mut l).ok(); let mut mapping: HashMap = HashMap::new(); l.trim().split_whitespace() .map(|s| s.parse::().unwrap()).for_each(|i| { if let Some(x) = mapping.get_mut(&i) { *x += 1; } else { mapping.insert(i, 1); } }) ; let mut l: BinaryHeap = mapping.iter().map(|pair| *pair.1).collect(); let mut result: usize = 0; for _ in 0..n/3 { if l.len() < 3 { break; } let mut a = l.pop().unwrap(); let mut b = l.pop().unwrap(); let mut c = l.pop().unwrap(); if a > 1 { a -= 1; l.push(a); } if b > 1 { b -= 1; l.push(b); } if c > 1 { c -= 1; l.push(c); } result += 1; } println!("{}", result); } }