Language: C++

#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;
 
#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

#define int long long
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    map<int,int> am, bm;
    rep(i,N){ cin >> A[i]; am[A[i]]++;}
    rep(i,N){ cin >> B[i]; bm[B[i]]++;}
        
    bool ok = true;
    for(auto i = am.begin(); i!=am.end(); i++){
        if(i->second + bm[i->first] >= N+1) ok =false;
    }
    

    random_device rnd;
//    rnd(); // 0から2^32-1

    if(!ok) No;
    else{
        Yes;
/*        if(A[0]==B[0]){

            int a;
            for(a=0; a<N; a++) if(B[a]!=A[0]) break;
            dump(a);
            
            for(int j=0; j<N; j++){
                cout << B[(N-a+j)%N] << " ";
            }
            
        }else*/{
            auto B1 = B;
            int m;
            if(N%2==0) m=3; else m=2;
            for(int _=0; _<N; _+=,){
                int i = (_+N*3/4)%N;
                rotate(B1.begin(), B1.begin()+i, B1.end());
                bool good = true;
                rep(i,N){
                    if(A[i]==B1[i]){ good = false; break;}
                }
                if(good){
                    rep(i,N) cout << B1[i] << " ";
                    return;
                }
            }
        }
    }
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed;
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:90:34: error: expected primary-expression before ',' token
   90 |             for(int _=0; _<N; _+=,){
      |                                  ^
a.cc:90:35: error: expected primary-expression before ')' token
   90 |             for(int _=0; _<N; _+=,){
      |                                   ^