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: Wrong Answer)

fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut abucket = vec![vec![]; n];
	let mut bbucket = vec![vec![]; n];
	let a: Vec<usize> = s
		.by_ref()
		.take(n)
		.map(|a| a.parse::<usize>().unwrap() - 1)
		.collect();
	let b: Vec<usize> = s
		.by_ref()
		.take(n)
		.map(|a| a.parse::<usize>().unwrap() - 1)
		.collect();
	for i in 0..n {
		abucket[a[i]].push(i);
		bbucket[b[i]].push(i);
	}
	let mut af = std::collections::BTreeSet::new();
	let mut bf = std::collections::BTreeSet::new();
	for i in 0..n {
		if abucket[i].len() > 0 {
			af.insert((abucket[i].len(), i));
		}
		if bbucket[i].len() > 0 {
			bf.insert((bbucket[i].len(), i));
		}
	}
	let mut ans = vec![0; n];
	while let Some(mut a) = af.iter().rev().next().cloned() {
		let mut it = bf.iter().rev();
		let mut rm = vec![];
		let mut any = false;
		while let Some(b) = it.next().cloned() {
			if b.1 == a.1 {
				continue;
			}
			let min = std::cmp::min(a.0, b.0);
			for _ in 0..min {
				let i = abucket[a.1].pop().unwrap();
				ans[i] = b.1;
			}
			rm.push((b, min));
			af.remove(&a);
			if a.0 - min != 0 {
				a = (a.0 - min, a.1);
				af.insert(a);
			} else {
				any = true;
				break;
			}
		}
		if !any {
			println!("No");
			return;
		}
		for (b, min) in rm {
			bf.remove(&b);
			if b.0 - min != 0 {
				bf.insert((b.0 - min, b.1));
			}
		}
	}
	let mut s = String::new();
	for ans in ans {
		s.push_str(&format!("{} ", ans + 1));
	}
	s.pop();
	println!("Yes\n{}", s);
}