func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     int l;     int r;     int val;   };   node tree[800010];   vector<int> pre[200010];   int ary[200010];   int n, q;   void pushup(int cur) {     tree[cur].val = min(tree[2 * cur].val, tree[2 * cur + 1].val);   }   void build(int l, int r, int cur) {     int m;     tree[cur].l = l;     tree[cur].r = r;     tree[cur].val = 0;     if (l == r) {       tree[cur].val = ary[l];       return;     }     m = (l + r) / 2;     build(l, m, 2 * cur);     build(m + 1, r, 2 * cur + 1);     pushup(cur);   }   int query(int pl, int pr, int cur) {     int res;     if (pl <= tree[cur].l && tree[cur].r <= pr) return tree[cur].val;     res = 1000000;     if (pl <= tree[2 * cur].r) res = min(res, query(pl, pr, 2 * cur));     if (pr >= tree[2 * cur + 1].l) res = min(res, query(pl, pr, 2 * cur + 1));     return res;   }   int main() {     int i, j, flag, p, l, r, res;     scanf( %d%d , &n, &q);     flag = 0;     for (i = 1; i <= n; i++) {       scanf( %d , &ary[i]);       if (ary[i] != 0) flag = 1;     }     if (flag == 0) {       printf( YES n );       for (i = 1; i <= n; i++) {         printf( %d  , q);       }       printf(  n );       return 0;     }     flag = 0;     for (i = 1; i <= n; i++) {       if (ary[i] == q) {         flag = 1;         break;       }     }     if (flag == 0) {       p = 0;       for (i = 1; i <= n; i++) {         if (ary[i] != 0)           p = ary[i];         else {           if (flag == 0) {             ary[i] = q;             flag = 1;           } else             ary[i] = p;         }       }       p = 0;       for (i = n; i >= 1; i--) {         if (ary[i] != 0)           p = ary[i];         else           ary[i] = p;       }     } else {       p = 0;       for (i = 1; i <= n; i++) {         if (ary[i] != 0)           p = ary[i];         else           ary[i] = p;       }       p = 0;       for (i = n; i >= 1; i--) {         if (ary[i] != 0)           p = ary[i];         else           ary[i] = p;       }     }     flag = 0;     for (i = 1; i <= n; i++) {       if (ary[i] == q) {         flag = 1;         break;       }     }     if (flag == 0) {       printf( NO n );       return 0;     }     for (i = 1; i <= n; i++) {       pre[ary[i]].push_back(i);     }     build(1, n, 1);     flag = 1;     for (i = 1; i <= q; i++) {       if (pre[i].size() > 1) {         for (j = 1; j < pre[i].size(); j++) {           l = pre[i][j - 1] + 1, r = pre[i][j] - 1;           if (l <= r) {             res = query(l, r, 1);             if (res < i) {               flag = 0;               break;             }           }         }         if (flag == 0) break;       }     }     if (flag) {       printf( YES n );       for (i = 1; i <= n; i++) {         printf( %d  , ary[i]);       }       printf(  n );     } else       printf( NO n );     return 0;   }   