Problem:
Score : 600 points

Problem Statement

Given are two sequences A and B, both of length N.
A and B are each sorted in the ascending order.
Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it.

Constraints

1\leq N \leq 2 \times 10^5

1\leq A_i,B_i \leq N

A and B are each sorted in the ascending order.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_N

Output

If there exist no reorderings that satisfy the condition, print No.

If there exists a reordering that satisfies the condition, print Yes on the first line.
After that, print a reordering of B on the second line, separating terms with a whitespace.

If there are multiple reorderings that satisfy the condition, you can print any of them.

Sample Input 1

6
1 1 1 2 2 3
1 1 1 2 2 3

Sample Output 1

Yes
2 2 3 1 1 1

Sample Input 2

3
1 1 2
1 1 3

Sample Output 2

No

Sample Input 3

4
1 1 2 3
1 2 3 3

Sample Output 3

Yes
3 3 1 2

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

    //For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v[200001];

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            int ar[n+1],ar2[n+1];
            map<int,int> mp,mp2,mp3;
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
                ++mp[ar[i]];
            }
            for(i=1;i<=n;++i)
            {
                cin>>ar2[i];
                ++mp2[ar2[i]];
                ++mp3[ar2[i]];
            }
            for(auto it:mp)
            {
                if(it.s+mp2[it.f] > n)
                {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            shuffle(ar2+1,ar2+n+1,rng);
            if(mp.size()<=10)
            {
                sort(ar2+1,ar2+n,greater<int>());
            }
            int ans[n+1];
            
            for(i=1;i<=n;++i)
                ans[i]=ar2[i];
            for(i=1;i<=n;++i)
            {
                if(ans[i]!=ar[i])
                    continue;
                for(j=1;j<=n;++j)
                {
                    if(i==j)
                        continue;
                    if(ar[j]!=ans[i] && ans[j]!=ar[i])
                    {
                        swap(ans[i],ans[j]);
                        break;
                    }
                }
            }
            cout<<"Yes"<<endl;
            for(i=1;i<=n;++i)
                cout<<ans[i]<<" ";
            cout<<endl;
        }
        return 0;
    }