Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from sys import setrecursionlimit

setrecursionlimit(1000000)

N, u, v = map(int, input().split())

node = [[] for _ in range(N)]
for _ in range(N - 1):
  A, B = [int(s) - 1 for s in input().split()]
  node[A].append(B)
  node[B].append(A)

def tak(node, u, v, p):
  #print('tak %d %d %d' % (u, v, p))
  if p > N:
    return float('inf')
  if u == v:
    return p
  return max(aok(node, n, v, p) for n in node[u])

def aok(node, u, v, p):
  #print('aok %d %d %d' % (u, v, p))
  if u == v:
    return p
  return min(tak(node, u, n, p + 1) for n in node[v])

print(tak(node, u - 1, v - 1, 0))

### FIXED CODE ###

def calc_destination(start, edges, N):
    destination = [-1] * (N + 1)
    destination[start] = 0
    q = [start]
    while len(q) != 0:
        current = q.pop()
        for n in edges[current]:
            if destination[n] != -1:
                continue
            destination[n] = destination[current] + 1
            q.append(n)
    return destination

def main():
    N, u, v = map(int, input().split())

    if u == v:
        print(0)
        return

    edges = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        A, B = map(int, input().split())
        edges[A].append(B)
        edges[B].append(A)

    tak = calc_destination(u, edges, N)
    aok = calc_destination(v, edges, N)

    result = 0
    for i in range(1, N + 1):
        aoki = aok[i]
        if tak[i] >= aoki:
            continue
        if aoki > result:
            result = aoki
    print(result - 1)

main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque
H,W,K = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
sx-=1;sy-=1;gx-=1;gy-=1
Pond = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp = list(temp)
  Pond.append(temp)
#print(Pond)
Q = deque([])
Q.append([sx,sy])
reach = [[INF]*W for _ in range(H)]
reach[sx][sy] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
while Q:
  nx,ny = Q.popleft()
  step = K
  for i in range(4):
    tx,ty = nx,ny
    for fac in range(1,K+1):
      tx = nx + fac*dxdy[i][0]
      ty = ny + fac*dxdy[i][1]
      #print(i,tx,ty)
      if 0>tx or tx>=H or 0>ty or ty>=W or Pond[tx][ty] == "@": #or reach[tx][ty] != INF:
        #print(i,tx,ty,reach[2][0])
        break #範囲外やハスがあった、到達済みの場合には終了
      #print(i,tx,ty)
      if reach[nx][ny] + 1 > reach[tx][ty]: #もし現時点よりもステップが大きい場合はだめ。
        #同じ場合は向き的に得している場合もあるので残す。
        break
      reach[tx][ty] = reach[nx][ny] + 1
      Q.append([tx,ty])
  if nx == gx and ny == gy:
    print(reach[gx][gy])
    exit()
#print(reach)
ans = reach[gx][gy]
if ans == INF:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

from collections import deque
H,W,K= map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
sx-=1;sy-=1;gx-=1;gy-=1 #0index
Pond = []
for i in range(H):
  temp = str(input())
  temp = list(temp)
  Pond.append(temp)
#print(Pond)
INF = float("inf")
reach = [[INF for _ in range(W)] for _ in range(H)]
reach[sx][sy] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
Q = deque([(sx,sy)])
while Q:
  x,y = Q.popleft()
  #print(x,y)
  #step = reach[x][y]
  for j in range(4):
    for i in range(1,K+1):
      fac = i
      nx = x+fac*dxdy[j][0]
      ny = y+fac*dxdy[j][1]
      #print(nx,ny)
      if nx<0 or nx>=H or ny<0 or ny>= W or Pond[nx][ny] == "@":
        break
      if reach[x][y]+1 > reach[nx][ny]: #すでに余裕をもって到達済み
        break
      if reach[x][y]+1 < reach[nx][ny]:
        reach[nx][ny] = min(reach[x][y]+1,reach[nx][ny])
        Q.append((nx,ny))
      if nx == gx and ny == gy:
        #print(reach)
        print(reach[nx][ny])
        exit()
print(-1)
### BUGGY CODE ###

import collections

N = int(input())
A = sorted(list(map(int,input().split())), reverse = True)
edge = []

for i in range(N):
    a = A[i]
    if A.count(a) >= 2 and a not in edge:
        edge.append(a)
        if len(edge) == 2:
            print(edge[0]*edge[1])
            exit()
        if A.count(a) >= 4:
            print(a*a)
            exit()
print(0)


### FIXED CODE ###

import collections

N = int(input())
A = list(map(int,input().split()))
B = collections.Counter(A)
C = []
for a,c in B.items():
    C += [a] * (c//2)
C.sort()

if len(C) >= 2:
    print(C[-1]*C[-2])
else:
    print(0)
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = int(input())
print(0)
l = input()
r = l
if L == "Vacant":
    exit()

ng = 0
ok = n
while True:
    mid = (ng + ok) // 2
    print(mid)
    q = input()
    if q == "Vacant":
        exit()
    if (q == l) ^ ((mid - ng)%2 == 1):
        ng = mid
        l = q
    else:
        ok = mid
        r = q

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = int(input())
print(0)
l = input()
r = l
if l == "Vacant":
    exit()

ng,ok = 0,n
while True:
    mid = (ng + ok) // 2
    print(mid)
    q = input()
    if q == "Vacant":
        exit()
    if (q == l) ^ ((mid - ng)%2 == 1):
        ng = mid
        l = q
    else:
        ok = mid
        r = q
### BUGGY CODE ###

def solve():
    N = int(input())
    A = tuple(map(int, input().split()))

    from itertools import accumulate
    CA = list(accumulate(A))

    mindiff = CA[-1]

    for c in range(1,N-2):
        # left side
        p = 0
        q = CA[-1]
        left = 0
        # for i in range(0, c):
        while True:
            pi = CA[left]
            qi = CA[c] - CA[left]
            if abs(pi- qi) >= abs(p - q):
                break
            p = pi; q = qi
            left += 1

        # right side
        r = 0
        s = CA[-1]
        right = c+1
        # for i in range(c+1, N):
        while True:
            ri = CA[right] - CA[c]
            si = CA[-1] - CA[right]
            if abs(ri- si) >= abs(r - s):
                break
            r = ri; s = si
            right += 1
    
        mindiff = min(mindiff, max(p, q, r, s) - min(p, q, r, s))
    return mindiff
print(solve())

### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split()))

from itertools import accumulate
CA = list(accumulate(A))

mindiff = CA[-1]
left = 0
right = 2
for c in range(1,N-1):
    # left side
    p = CA[left]
    q = CA[c] - CA[left]
    while True:
        pi = CA[left+1]
        qi = CA[c] - CA[left+1]
        if abs(pi- qi) >= abs(p - q):
            break
        p = pi; q = qi
        left += 1

    # right side
    r = CA[right] - CA[c]
    s = CA[-1] - CA[right]
    while True:
        ri = CA[right+1] - CA[c]
        si = CA[-1] - CA[right+1]
        if abs(ri- si) >= abs(r - s):
            break
        r = ri; s = si
        right += 1

    mindiff = min(mindiff, max(p, q, r, s) - min(p, q, r, s))
print(mindiff)
### BUGGY CODE ###

import numpy as np
from numba import njit


@njit("i1(i1,i1[:])", cache=True)
def solve(N, D):
    ans = 0
    for i in range(1 << N):
        clocks = np.zeros((N + 2), dtype=np.int8)
        clocks[-1] = 24
        for j in range(N):
            if i >> j & 1:
                clocks[j + 1] = D[j]
            else:
                clocks[j + 1] = 24 - D[j]
        clocks.sort()
        ans = max(ans, np.min(np.diff(clocks)))
    return ans


N = int(input())
D = np.array(input().split(), dtype=np.int8)
if N >= 24:
    print(0)
else:
    print(solve(N, D))


### FIXED CODE ###

from collections import Counter
from itertools import product


N = int(input())
D = list(map(int, input().split()))
D_cnt = Counter(D)
if N >= 24 or D_cnt[0] > 0 or D_cnt[12] > 1 or any(D_cnt[i] > 2 for i in range(1, 12)):
    print(0)
    exit()
clock = [0, 24]
undet = []
if 12 in D_cnt:
    clock.append(12)
for i in range(1, 12):
    if D_cnt[i] == 2:
        clock.append(i)
        clock.append(24 - i)
    elif D_cnt[i] == 1:
        undet.append(i)

ans = 0
for rp in product([0, 1], repeat=len(undet)):
    candidate = clock[:]
    for j, is_flipped in enumerate(rp):
        candidate.append(undet[j]) if is_flipped else candidate.append(24 - undet[j])
    candidate.sort()
    ans = max(ans, min(ca - cb for cb, ca in zip(candidate, candidate[1:])))
print(ans)
### BUGGY CODE ###

def main():
    n=int(input())
    a=sorted(map(int,input().split()), reverse=True)
    ans=0
    mod=10**9+7
    for i in range(n-1):
        if a[i] == 0:
            break
        for j in range(i+1,n):
            if a[j] == 0:
                break
            ans += a[i]*a[j]
            ans %= mod
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from itertools import accumulate
def main():
    mod=10**9+7
    n=int(input())
    a=list(map(int,input().split()))
    aa=[0]+list(accumulate(a))
    ans=0
    for i in range(n-1):
        ans += a[i]*(aa[-1]-aa[i+1])%mod
    print(ans%mod)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np

N = int(input())
L = list(map(int, input().split()))

L = np.array(sorted(L, reverse=True))

ans = 0

for n in range(0,N-2):
    if L[n] > L[n+1] + L[n+2]:
        pass
    else:
        for o in range(n+1,N-1):
            ans += np.sum(L[o+1:]>L[n]+-L[o])
                
print(int(ans))

### FIXED CODE ###

import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) -m-1

print(count)
### BUGGY CODE ###

t = list(input())
le = len(t)
for i in range(le):
    c = t[i]
    if t[i] == '?':
        c = 'D'
        if i > 0 and t[i - 1] == 'P':
            c = 'D'
        elif i == 0 and le > 1 and t[i + 1] == 'D' or i == 0 and le > 1 and t[i + 1] == '?':
            c = 'P'
        elif i < le - 1 and t[i + 1] == 'D' or i < le - 1 and t[i + 1] == '?':
            c = 'P'
    t = t[:i] + [c] + t[i + 1:]
print(''.join(t))   
        

### FIXED CODE ###

t = input()
le = len(t)
tt = []
for i in range(le):
    c = t[i]
    if t[i] == '?':
        c = 'D'
        if i > 0 and tt[i - 1] == 'P':
            c = 'D'
        elif i == 0 and le > 1 and t[i + 1] == 'D' or i == 0 and le > 1 and t[i + 1] == '?':
            c = 'P'
        elif i < le - 1 and t[i + 1] == 'D' or i < le - 1 and t[i + 1] == '?':
            c = 'P'
    tt.append(c)
print(''.join(tt))
### BUGGY CODE ###

def multiply(arr):
    ans = 1
    for i in arr:
        ans *= i
    if ans > 1000000000000000000:
            return -1
    return ans
n = int(input())
nums = list(map(int, input().split(' ')))
print(multiply(nums))

### FIXED CODE ###

def multiply(arr):
    ans = 1
    if 0 in arr:
        return 0
    for i in arr:
        ans *= i
        if ans > 1000000000000000000:
            return -1
    return ans
n = int(input())
nums = list(map(int, input().split(' ')))
print(multiply(nums))
### BUGGY CODE ###

def floor(a):
    return int(a)

if __name__ == '__main__':
    abn = input()
    abn = abn.split()
    a = int(abn[0])
    b = int(abn[1])
    n = int(abn[2])

    max_amount = 0
    for i in range(1,n+1):
        amount = floor(a*i/b) -a*floor(i/b)
        max_amount = max(max_amount,amount)

    print(max_amount)


### FIXED CODE ###

def floor(a):
    return int(a)

if __name__ == '__main__':
    abn = input()
    abn = abn.split()
    a = int(abn[0])
    b = int(abn[1])
    n = int(abn[2])

    x = min(b-1,n)
    ans = floor(a*x/b)-a*floor(x/b)

    print(ans)
### BUGGY CODE ###

import itertools
import sys


def main():
    input = sys.stdin.readline
    n = int(input())
    L = map(int, input().split())
    cnt = 0

    ls = itertools.combinations(L, 3)

    for l in ls:
        if sum(l) > max(l)*2:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import bisect
import sys

input = sys.stdin.readline

n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)
### BUGGY CODE ###

N, P = [int(_c) for _c in input().split(" ")]

if N == 1:
    print(P)
else:
    _max = 1
    M = 10 ** 6
    for i in range(1, M + 1):
        var = i ** N
        if P % var == 0:
            _max = i
        if var > P:
            break

    print(_max)

### FIXED CODE ###

N, P = [int(_c) for _c in input().split(" ")]

if N == 1:
    print(P)
else:
    _max = 1
    M = int(P ** (1 / N) + 1.0 * 1e-9)
    for i in range(1, M + 1):
        if P % (i ** N) == 0:
            _max = i

    print(_max)
### BUGGY CODE ###

#!/usr/bin/python3
from operator import attrgetter
import sys
class Point:
    pass

class Node:
    pass

def kdtree(points, depth=0):
    if not points:
        return
    # dimension
    if depth % 2 == 0:
        points.sort(key=attrgetter('x'))
    else:
        points.sort(key=attrgetter('y'))

    median = len(points)//2

    node = Node()
    node.location = points[median]
    node.left = kdtree(points[:median], depth + 1)
    node.right = kdtree(points[median + 1:], depth + 1)
    return node

def find(sx, tx, sy, ty, node, depth, result):
    if node == None:
        return
    if sx <= node.location.x <= tx and sy <= node.location.y <= ty:
        result.append(node.location.id)

    if depth % 2 == 0:
        if sx <= node.location.x:
            find(sx, tx, sy, ty, node.left, depth + 1, result)
        if node.location.x <= tx:
            find(sx, tx, sy, ty, node.right, depth + 1, result)
    else:
        if sy <= node.location.y:
            find(sx, tx, sy, ty, node.left, depth + 1, result)
        if node.location.y <= ty:
            find(sx, tx, sy, ty, node.right, depth + 1, result)

# main
n = int(input())
points = []
for i in range(n):
    point = Point()
    point.id = i
    point.x, point.y = map(int, sys.stdin.readline().split())
    points.append(point)
tree = kdtree(points)
q = int(input())
for i in range(q):
    sx, tx, sy, ty = map(int, sys.stdin.readline().split())
    result = []
    find(sx, tx, sy, ty, tree, 0, result)
    result.sort()
    for i in result:
        print(i)
    print()

### FIXED CODE ###

#!/usr/bin/python3
from sys import stdin
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right
readline = stdin.readline

def main():
    n = int(readline())
    xy = [tuple(map(int, readline().split())) + (i,) for i in range(n)]
    # [..., (x_i, y_i, i), ...]
    # sort by x
    xy.sort()

    root = int(math.sqrt(len(xy)))

    low = [x for x, y, i in xy[::root]]
    high = [x for x, y, i in xy[root - 1::root]] + [float('inf')]

    xy = [sorted(xy[i:i + root], key=itemgetter(1)) for i in range(0, len(xy), root)]
    xy = [([y for x, y, i in xyi], xyi) for xyi in xy]
    for sx, tx, sy, ty in (map(int, readline().split()) for _ in range(int(readline()))):
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = xy[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <=tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            print('\n'.join(map(str,ret)))
        print()

main()
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]
mod = 10**9+7
res = [0]*(max(a)+1)
for i in a:
    for j in range(2,int(i**0.5)+1):
        cnt = 0
        while i%j==0:
            i//=j
            cnt+=1
        res[j] = max(res[j],cnt)
    if i!=1:
        res[i] = max(res[i],1)

d = 1
for i in range(max(a)+1):
    d *= max(i**res[i],1)
ans = 0
for i in range(n):
    ans = (ans+d//a[i])%mod
print(ans)

### FIXED CODE ###

import sys

n = int(input())
a = [int(x) for x in input().split()]
am = max(a)
mod = 10**9+7
if n==1:
    print(1)
    sys.exit()
li = [0]*(am+1)
lcm = 1
for k in range(n):
    z = a[k]
    for i in range(2,int(z**0.5)+1):
        x = 0
        while z%i==0:
            x += 1
            z//=i
        li[i] = max(li[i],x)
    if z!=1 and li[z]==0:
        li[z] = 1

for i in range(2,am+1):
    if li[i]>0:
        lcm = lcm * i**li[i] % mod

ans = 0
for i in range(n):
    m = pow(a[i],mod-2,mod)
    ans = (ans+(lcm*m)%mod)%mod
print(ans%mod)
### BUGGY CODE ###

import random
n, m, k = map(int, input().split())
# n, m, k = random.randint(1, 10**5), random.randint(1, 10**5), random.randint(10**8, 10**9)
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# a_list = [random.randint(1, 10**8) for i in range(n)]
# b_list = [random.randint(1, 10**7) for i in range(m)]
# print(n,m,k)
# print(a_list[0], b_list[0])
a_sum = [0]
b_sum = [0]
for i in range(1, max(n+1, m+1)):
    if i < n+1:
        a_sum.append(a_sum[i-1] + a_list[i-1])
    if i < m+1:
        b_sum.append(b_sum[i-1] + b_list[i-1])

ans = 0
for i in range(n+1):
    if a_sum[i] > k:
        break
    else:
        j = 0
        while j <= m and b_sum[j] <= k - a_sum[i]:
            j += 1
        j -= 1
    ans = max(ans, i+j)
        
print(ans)
# print(n+m) 

### FIXED CODE ###

import random
n, m, k = map(int, input().split())
# n, m, k = random.randint(1, 10**5), random.randint(1, 10**5), random.randint(10**8, 10**9)
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# a_list = [random.randint(1, 10**3) for i in range(n)]
# b_list = [random.randint(1, 10**3) for i in range(m)]
# print(n,m,k)
# print(a_list[0], b_list[0])
a_sum = [0]
b_sum = [0]
max_a = 0
for i in range(1, max(n+1, m+1)):
    if i < n+1:
        a_sum.append(a_sum[i-1] + a_list[i-1])
        if a_sum[i] <= k:
            max_a = i
    if i < m+1:
        b_sum.append(b_sum[i-1] + b_list[i-1])

ans = 0
j = m
for i in range(0, max_a+1):
    while b_sum[j] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)
# print(n+m)
### BUGGY CODE ###

import sys

x, y, z, k = map(int, sys.stdin.readline().split())

xlist = sorted(list([int(i)
                     for i in sys.stdin.readline().split()]), reverse=True)[:min(x, k)]
ylist = sorted(list([int(i)
                     for i in sys.stdin.readline().split()]), reverse=True)[:min(y, k)]
zlist = sorted(list([int(i)
                     for i in sys.stdin.readline().split()]), reverse=True)[:min(z, k)]


anslist = [0]
for i in range(min(x, k)):
    for j in range(min(y, k)):
        for l in range(min(z, k)):
            if (i+1)*(j+1)*(l+1) <= k:
                anslist.append(xlist[i]+ylist[j]+zlist[l])

anslist = sorted(anslist, reverse=True)
for i in range(k):
    print(anslist[i])


### FIXED CODE ###

import sys

x, y, z, k = map(int, sys.stdin.readline().split())

xlist = sorted(list([int(i)
                     for i in sys.stdin.readline().split()]), reverse=True)[:min(x, k)]
ylist = sorted(list([int(i)
                     for i in sys.stdin.readline().split()]), reverse=True)[:min(y, k)]
zlist = sorted(list([int(i)
                     for i in sys.stdin.readline().split()]), reverse=True)[:min(z, k)]


anslist = [0]
for i in range(min(x, k)):
    for j in range(min(y, k)):
        for l in range(min(z, k)):
            if (i+1)*(j+1)*(l+1) <= k:
                anslist.append(xlist[i] + ylist[j] + zlist[l])
            else:
                break

anslist = sorted(anslist, reverse=True)
for i in range(k):
    print(anslist[i])
### BUGGY CODE ###

import copy
n=int(input())
x=list(map(int,input().split()))
y=copy.copy(x)
s=0
for i in range(n):
    s=x[i]
    y.remove(s)
    y.sort()
    print(y[n//2-1])
    y.append(s)


### FIXED CODE ###

import statistics
n=int(input())
x=list(map(int,input().split()))
y=statistics.median(x)
xs=sorted(x)
for i in x:
    if i<y:
        print(xs[n//2])
    else:
        print(xs[n//2-1])
### BUGGY CODE ###

n = int(input())    

s = [1]*(n+1)
for i in range(2,n+1):
    for j in range(i,n+1,i):
        s[j] += 1
ans = 0

for i in range(1,n+1):
    ans += (i * s[i])

print(ans)


### FIXED CODE ###

from numba import njit
import numpy as np


@njit("i8(i8)")
def solve(n):
    ans = 1
    res = np.ones(n + 1, dtype=np.int64)
    for i in range(2, n + 1):
        for j in range(i, n + 1, i):
            res[j] += 1
        ans += i * res[i]
    return ans


N = int(input())
print(solve(N))
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
j=0 ;bef=-1
for i in range(n):
    if A[i]==B[i]:
        if bef!=A[i]:j=0
        while j<n:
            if A[i]!=B[j] and A[i]!=A[j]:
                B[i],B[j]= B[j],B[i]
                break
            j+=1
        else:
            print("No");exit()

print("Yes")
print(*B)

### FIXED CODE ###

import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
j=0 ;bef=-1
for i in range(n):
    if bef!=A[i]:j=0
    if A[i]==B[i]:
        
        while j<n:
            if A[i]!=B[j] and A[i]!=A[j]:
                B[i],B[j]= B[j],B[i]
                break
            j+=1
        else:
            print("No");exit()
    bef=A[i]

print("Yes")
print(*B)
### BUGGY CODE ###

N, K, Q = map(int, input().split())

start = [K] * N

for i in range(Q):
  a = int(input())
  for j in range(N):
    if j == a-1:
      start[j] += 0
    else:
      start[j] -= 1
        
for i in range(N):
  if start[i] > 0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

N, K, Q = map(int, input().split())

start = [K - Q] * N

for i in range(Q):
  a = int(input())
  start[a-1] += 1
     
for i in range(N):
  if start[i] > 0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

N = int(input())
num = 0

while(N != 0):
    num += N % 10
    N = N // 10
if num % 9 == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = input()
num = 0

for i in range(len(N)):
    num += int(N[i])
if num % 9 == 0:
    print("Yes")
else:
    print("No")