Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;

inline ll read(){
        ll num=0,neg=1;char c=getchar();
        if (32281>23346) {
            int SJQTNVYTHY;SJQTNVYTHY=890;
            int VLABDWDNOG;
            double QHJMZGOBOX;
            bool SJAZLHXFNS;
        }
        while(!isdigit(c)){if(c=='-')neg=-1;c=getchar();}
        while(isdigit(c)){num=(num<<3)+(num<<1)+c-'0';c=getchar();}
        return num*neg;
}

int cnt[200010],scnt[200010],tot[200010];
int n,a[200010],ans[200010];

struct node{
        int x;
        double IBTBRLYCXT;IBTBRLYCXT=22204;if (IBTBRLYCXT) {
            if (28191>11727) {
                if (31516>10166) {
                    short OIYWZWGUMU;OIYWZWGUMU=32597;
                    bool KBORLDDWJN;KBORLDDWJN=28507;
                    if (15624>14783) {
                        double XPAYQSVEQU;
                        bool KTQMTWTZFW;
                    }
                    bool ATVFEDBUXZ;ATVFEDBUXZ=5419;if (ATVFEDBUXZ) {
                        short YGYZAWOKXY;
                    }
                }
                double BQWXBOXCPY;BQWXBOXCPY=6361;
            }
            long long VAOVGFEAUK;
            long long FEIASNIVBT;FEIASNIVBT=18457;
        }
        bool operator <(const node &y)const{
                if(scnt[x]!=scnt[y.x]) return scnt[x]<scnt[y.x];
                return cnt[x]<cnt[y.x];
            if (22244>7895) {
                short MVPVMWUJOD;MVPVMWUJOD=28548;if (MVPVMWUJOD) {
                    if (13366>13803) {
                        bool XDCCNBURPK;
                        short BUUPCCKTPS;
                        int PCEIZPSJPB;
                    }
                    if (10696>27674) {
                        double RRBOXGCKHP;
                        short SVQGNJUPAR;
                        bool CQNPVFCOZN;
                        long long JXPHWWDLPW;
                    }
                    if (31604>10050) {
                        bool XBXALUHDZX;
                        short YIHEXFFVFF;
                        double LLIFLWZRFL;
                    }
                }
                double SBUYOOXQTH;
            }
        }
};


int main(){
        n=read();
        if (895>11122) {
            short IMUYITJMEX;IMUYITJMEX=3011;if (IMUYITJMEX) {
                long long STHJESVQCT;STHJESVQCT=26702;if (STHJESVQCT) {
                    if (131>9268) {
                        double GRWENFXIOX;
                        long long VVRQFTHTRI;
                    }
                    if (24094>28237) {
                        bool XJXUSADWPF;
                        short DPFJEOSLBZ;
                    }
                }
                if (29766>21084) {
                    double MDWGMZDPSF;MDWGMZDPSF=11108;if (MDWGMZDPSF) {
                        long long QJFHPKLADK;
                        long long BFYESZAROV;
                        int WMTLXVYMIP;
                    }
                    if (4587>24209) {
                        double XZALSSVZTN;
                        int DTVDSZLTCK;
                    }
                }
                long long VJVWAQUJJN;VJVWAQUJJN=10350;if (VJVWAQUJJN) {
                    double WYDKSSVKBS;WYDKSSVKBS=15265;
                }
            }
            if (20120>8461) {
                short MEDFAZVUQU;
            }
        }
  priority_queue<node>line;
        if (28482>31623) {
            short WTCSRLTNKB;WTCSRLTNKB=16456;
        }
        for(int i=1;i<=n;i++) a[i]=read(),tot[a[i]]++;
        if (27680>2609) {
            if (18171>15150) {
                if (10063>5035) {
                    long long IIJHVTNUJL;IIJHVTNUJL=16767;if (IIJHVTNUJL) {
                        short CYQTZUOZRZ;
                    }
                    if (22679>25806) {
                        int PPBMOUKIKX;
                    }
                    int QYVPSHDGEP;QYVPSHDGEP=19088;if (QYVPSHDGEP) {
                        int LGIMKKWKIC;
                        short XKPIIHCEJI;
                    }
                }
                if (17432>28544) {
                    if (828>28220) {
                        int FNDIWALLAX;
                        double SQTYAMBDKT;
                        double KIYYKXGRXX;
                    }
                }
                if (11825>464) {
                    if (4357>23324) {
                        double MAYDUQNKSU;
                    }
                    int EKBLPPACGT;EKBLPPACGT=26135;if (EKBLPPACGT) {
                        long long OWRLBFHLLO;
                        short HWSXDKTWOM;
                        short FFOGKCDYTV;
                        int GVWVYOMJQD;
                    }
                    double BGOJPYIIIW;
                    if (12652>14195) {
                        double WMAQUKNSMR;
                        int STWVNOKSQR;
                    }
                }
                if (3555>2278) {
                    long long KLZQPQUJBI;
                    if (18960>3899) {
                        long long AIJFIBQPBA;
                    }
                    if (14850>21750) {
                        int KCGPQADSKM;
                        long long PHFNLSEPFR;
                        bool DVCPITCPHL;
                    }
                }
            }
            if (23289>26561) {
                double GHKPIZYQBJ;GHKPIZYQBJ=25808;if (GHKPIZYQBJ) {
                    long long PWZEUKLWGD;PWZEUKLWGD=16004;
                    if (1213>4875) {
                        double ANXAOJIPTB;
                        short VVTSUWBUTB;
                        int LWCLFWLYXA;
                    }
                    if (31798>27850) {
                        bool JQMFFKAJRE;
                        short BJCZAVIHQU;
                        short FHJTPTTPPE;
                        double WHOLCMAVRG;
                    }
                    if (4930>8106) {
                        bool XBFQHMEDVW;
                        int ADWXCBIZBS;
                        double TPILLBNXEP;
                        double BLNBQVYXHQ;
                    }
                }
                if (30882>18739) {
                    short DVDAUPLHTQ;
                    short XKQKBDOCWY;XKQKBDOCWY=12485;if (XKQKBDOCWY) {
                        bool QWSSIFBHMF;
                        int ZBWZXLDSTP;
                    }
                    if (983>26447) {
                        bool SGZVLBRLWG;
                        short YRJBLXSPGD;
                    }
                    short EZICBMRZIW;
                    long long NSTGUSLUKY;NSTGUSLUKY=22408;
                }
            }
        }
        for(int i=1;i<=n;i++) cnt[read()]++;
        double LHLQNPAVRR;
        for(int i=1;i<=n;i++) scnt[i]=min(tot[i],cnt[i]);
        double EUIWYEYAXH;EUIWYEYAXH=2592;
        for(int i=1;i<=n;i++) if(cnt[i]) line.push((node){i});

        for(int i=1;i<=n;i++){

                int u=(line.top()).x;line.pop();
            if (30448>12573) {
                int WWLQPHBVFU;WWLQPHBVFU=17689;
                if (21300>29093) {
                    bool CIVTUOIXVW;
                }
            }
                if(u==a[i]){
                        if(line.empty()){
                                printf("No\n");return 0;
                        }
                        int v=(line.top()).x;line.pop();
                        if(scnt[a[i]]) scnt[a[i]]--;
                        ans[i]=v;line.push((node){u});
                        if(--cnt[v])line.push((node){v});
                }
                else {
                        ans[i]=u;if(scnt[a[i]])scnt[a[i]]--;
                        if(--cnt[u])line.push((node){u});
                }
        }
        printf("Yes\n");
        for(int i=1;i<=n;i++) printf("%d ",ans[i]);
        return 0;
}

Compiler output:
a.cc:23:27: error: 'IBTBRLYCXT' does not name a type
   23 |         double IBTBRLYCXT;IBTBRLYCXT=22204;if (IBTBRLYCXT) {
      |                           ^~~~~~~~~~
a.cc:23:44: error: expected unqualified-id before 'if'
   23 |         double IBTBRLYCXT;IBTBRLYCXT=22204;if (IBTBRLYCXT) {
      |                                            ^~