func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> ad[100009];   vector<int> idx;   deque<int> vec;   int cnt[100009];   int ans[100009];   vector<pair<int, int> > arr, arr2;   int val[100009];   set<int> s;   int main() {     int a, b, c, d, e, i, j, k, l, n, m, x, y, t, p, X;     scanf( %d , &t);     for (p = 1; p <= t; p++) {       scanf( %d%d%d , &n, &x, &y);       c = y - x;       m = n + 1;       arr.clear();       arr2.clear();       for (i = 0; i <= m; i++) {         cnt[i] = 0;         ad[i].clear();         ans[i] = -1;       }       s.clear();       for (i = 1; i <= n; i++) {         scanf( %d , &a);         val[i] = a;         cnt[a]++;         ad[a].push_back(i);         s.insert(i);       }       for (i = 1; i <= m; i++) {         if (cnt[i] == 0) {           X = i;           break;         }       }       if (c == 0) {         for (i = 1; i <= n; i++) {           if (x) {             ans[i] = val[i];             x--;           } else {             ans[i] = X;           }         }         printf( YES n );         for (i = 1; i <= n; i++) {           printf( %d  , ans[i]);         }         printf(  n );         continue;       }       for (i = 1; i <= m; i++) {         if (cnt[i] > 0) {           arr.push_back({cnt[i], i});         }       }       sort(arr.begin(), arr.end());       m = arr.size();       c = y - x;       for (i = 0; i < m; i++) {         if (c == 0) {           break;         }         b = c / (m - i);         if (c % (m - i) != 0) {           b++;         }         b = min(b, arr[i].first);         c -= b;         arr2.push_back({b, arr[i].second});       }       sort(arr2.begin(), arr2.end());       c = y - x;       m = arr2.size();       if (m == 1) {         a = arr2[0].second;         l = arr2[0].first;         if (l > (n - cnt[a])) {           printf( NO n );           continue;         }         b = l;         for (i = 1; i <= n; i++) {           if (val[i] != a && b > 0) {             ans[i] = a;             b--;           }         }         for (i = 0; i < l; i++) {           b = ad[a][i];           ans[b] = X;         }       } else {         l = 0;         if (arr2[m - 1].first > (c - arr2[m - 1].first)) {           l = arr2[m - 1].first - (c - arr2[m - 1].first);           for (i = 0; i < m; i++) {             a = arr2[i].second;             b = arr2[i].first;             for (j = 0; j < b; j++) {               s.erase(ad[a][j]);             }           }           a = arr2[m - 1].second;           b = ad[a].size();           for (j = 0; j < b; j++) {             s.erase(ad[a][j]);           }           b = s.size();           if (l > b) {             printf( NO n );             continue;           }           arr2[m - 1].first -= l;           a = arr2[m - 1].second;           for (i = 0; i < l; i++) {             d = *s.begin();             s.erase(d);             ans[d] = a;           }           b = arr2[m - 1].first;           d = b + l;           for (i = b; i < d; i++) {             k = ad[a][i];             ans[k] = X;           }         }         vec.clear();         idx.clear();         for (i = 0; i < m; i++) {           a = arr2[i].second;           b = arr2[i].first;           if (i == m - 1) {             for (j = 0; j < b; j++) {               vec.push_front(a);             }           } else {             for (j = 0; j < b; j++) {               vec.push_back(a);             }           }           for (j = 0; j < b; j++) {             idx.push_back(ad[a][j]);           }         }         d = idx.size();         for (i = 0; i < d; i++) {           a = idx[i];           ans[a] = vec[i];         }       }       for (i = 1; i <= n; i++) {         if (ans[i] == -1) {           if (x) {             ans[i] = val[i];             x--;           } else {             ans[i] = X;           }         }       }       if (x > 0) {         printf( NO n );         continue;       }       printf( YES n );       for (i = 1; i <= n; i++) {         printf( %d  , ans[i]);       }       printf(  n );     }   }   