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 Rust (1.42.0) (judge verdict: Accepted)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use std::collections::BinaryHeap;

use competitive::prelude::*;

#[argio(output = AtCoder)]
fn main(n: usize, a: [Usize1; n], b: [Usize1; n]) -> () {
    let mut mm = BTreeMap::<usize, (i64, i64)>::new();

    for &a in a.iter() {
        mm.entry(a).or_default().0 += 1;
    }
    for &b in b.iter() {
        mm.entry(b).or_default().1 += 1;
    }

    let mut q = BinaryHeap::new();
    let mut free = vec![];
    let mut any = vec![];

    for (k, v) in mm.into_iter() {
        if v.0 == 0 {
            for _ in 0..v.1 {
                free.push(k);
            }
        } else if v.1 == 0 {
            for _ in 0..v.0 {
                any.push(k);
            }
        } else {
            q.push((v.0 + v.1, v.0, v.1, k));
        }
    }

    let mut ans = vec![];

    while let Some((s, a, b, k)) = q.pop() {
        let next = q.pop();
        if next.is_none() {
            if free.is_empty() {
                println!("No");
                return;
            }

            let l = free.pop().unwrap();
            ans.push((k, l));
            if a == 1 {
                for _ in 0..b {
                    free.push(k);
                }
            } else {
                q.push((s - 1, a - 1, b, k));
            }

            continue;
        }

        let (t, c, d, l) = next.unwrap();

        ans.push((k, l));

        if a == 1 {
            for _ in 0..b {
                free.push(k);
            }
        } else {
            q.push((s - 1, a - 1, b, k));
        }

        if d == 1 {
            for _ in 0..c {
                any.push(l);
            }
        } else {
            q.push((t - 1, c, d - 1, l));
        }
    }

    for (k, l) in any.into_iter().zip(free) {
        ans.push((k, l));
    }

    ans.sort();

    println!("Yes");
    for i in 0..n {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i].1 + 1);
    }
    println!();
}
*/

fn main() {
    let exe = "/tmp/binC1E6E81C";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";