func_code_string: #include <bits/stdc++.h>   using namespace std;   set<long long int> st;   set<long long int>::iterator it;   long long int cnt[200010];   int main() {     long long int n, a, b, x, y, z, p, m, d, mn, mx, t, i;     scanf( %lld , &t);     while (t--) {       scanf( %lld , &n);       p = 0;       for (i = 1; i <= n; i++) {         scanf( %lld , &a);         st.insert(a);         cnt[a]++;         p = max(p, cnt[a]);       }       x = st.size();       if (x == 1) {         if (p >= 2) {           cout << 1 << endl;         } else           cout << 0 << endl;       } else {         x = x - 1;         if (p <= x)           cout << p << endl;         else {           d = p - x;           if (d > 1)             cout << x + 1 << endl;           else             cout << x << endl;         }       }       for (i = 1; i <= n; i++) cnt[i] = 0;       st.clear();     }     return 0;   }   