func_code_string: #include <bits/stdc++.h>   using namespace std;   int T;   int N, X, Y, Ord[100005];   bool print;   int A[100005], Freq[100005], Freq2[100005], F[100005];   vector<int> V;   vector<int> Ap[100005];   set<pair<int, int> > S1, S2;   int Res[100005];   void Read() {     scanf( %d%d%d , &N, &X, &Y);     for (int i = 1; i <= N; i++) {       scanf( %d , &A[i]);       F[A[i]]++;       Ord[i] = i;     }   }   int missing() {     for (int i = 1; i <= N + 1; i++)       if (F[i] == 0) return i;     return -1;   }   bool cmp(int a, int b) { return F[A[a]] < F[A[b]]; }   void Solve() {     sort(Ord + 1, Ord + N + 1, cmp);     int miss = missing();     Freq[miss] = N - Y;     int cnt = 0, pos = 0, cnt2 = 0;     for (int i = 1; i <= N && cnt < Y - X; i++) {       pos = i;       if ((Freq[A[Ord[i]]] + Freq2[A[Ord[i]]] + 2) > N - X) {         if (cnt2 == N - Y || (Freq[A[Ord[i]]] + Freq2[A[Ord[i]]] + 1) > N - X)           continue;         Freq2[A[Ord[i]]]++;         cnt2++;         continue;       }       Freq[A[Ord[i]]]++;       Freq2[A[Ord[i]]]++;       cnt++;     }     if (cnt < Y - X) {       printf( NO n );       return;     }     for (int i = pos + 1; i <= N && cnt2 < N - Y; i++) {       if (Freq2[A[Ord[i]]] + 1 + Freq[A[Ord[i]]] > N - X) {         continue;       }       Freq2[A[Ord[i]]]++;       cnt2++;     }     if (cnt2 < N - Y) {       if (print) printf( NO n );       return;     }     if (print) printf( YES n );     for (int i = 1; i <= N + 1; i++) {       if (Freq[i] > 0) {         S1.insert(make_pair(Freq[i], i));       }       if (Freq2[i] > 0) S2.insert(make_pair(Freq2[i], i));     }     int total = N - X;     while (S1.size() > 0) {       set<pair<int, int> >::iterator it = S1.end();       --it;       set<pair<int, int> >::iterator it2 = S2.end();       --it2;       if ((it->first) * 2 == (it2->first) * 2 && (it->first) * 2 == total) {         --it;         --it2;         if (((it->second) != (it2->second)) ||             ((it->first) * 2 != total || (it2->first) * 2 != total)) {           ++it;           ++it2;         } else           ++it;       }       if ((it2->second) == (it->second)) --it2;       Ap[it2->second].push_back(it->second);       pair<int, int> a = *it;       pair<int, int> b = *it2;       --a.first;       --b.first;       S1.erase(it);       S2.erase(it2);       if (a.first > 0) S1.insert(a);       if (b.first > 0) S2.insert(b);       --total;     }     for (int i = 1; i <= N; i++) {       if (Ap[A[i]].size() > 0) {         int val = Ap[A[i]].back();         Res[i] = val;         Ap[A[i]].pop_back();       }     }     cnt = 0;     for (int i = 1; i <= N; i++) {       if (Res[i] == 0) {         Res[i] = A[i];       }       if (print) printf( %d  , Res[i]);     }     if (print) printf(  n );   }   int main() {     int T;     int ind = 0;     scanf( %d , &T);     print = true;     while (T--) {       ++ind;       Read();       Solve();       for (int i = 1; i <= N + 1; i++) {         Ap[i].clear();         Freq[i] = 0;         F[i] = 0;         Freq2[i] = 0;         Res[i] = 0;       }       S1.clear();       S2.clear();       V.clear();     }     return 0;   }   