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

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N, M = list(map(int, input().split()))
a = list(map(int, input().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 素因数分解に基づくlcm
def fact_lcm(numbers):
    d = defaultdict(int)
    for a in numbers:
        b = factorization(a)
        for bb in b:
            d[bb[0]] = max(d[bb[0]],bb[1])
    return(dict(d))

d = fact_lcm(a)
c = 1

for dd in d.items():
    c *= dd[0]**dd[1]

cc = c // 2

for aa in a:
    if cc % aa == 0:
        print(0)
        sys.exit()

print((M-cc) // c + 1)



### FIXED CODE ###

from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

N, M = list(map(int, input().split()))
a = list(map(int, input().split()))

# """nを素因数分解"""
# """2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#
#     if temp!=1:
#         arr.append([temp, 1])
#
#     if arr==[]:
#         arr.append([n, 1])
#
#     return arr
#
# # 素因数分解に基づくlcm
# def fact_lcm(numbers):
#     d = defaultdict(int)
#     for a in numbers:
#         b = factorization(a)
#         for bb in b:
#             d[bb[0]] = max(d[bb[0]],bb[1])
#     return(dict(d))
#
# d = fact_lcm(a)
# c = 1
#
# for dd in d.items():
#     c *= dd[0]**dd[1]

# リストのlcm
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

c = lcm_list(a)

cc = c // 2

for aa in a:
    if cc % aa == 0:
        print(0)
        sys.exit()

print((M-cc) // c + 1)
### BUGGY CODE ###

def main():
  x = int(input())
  y = [int(t) for t in input().split()]
  for i in range(x):
  	print(y.count(i+1))
main()

### FIXED CODE ###

def main():
  import collections
  x = int(input())
  y = [int(t) for t in input().split()]
  c = collections.Counter(y)
  for i in range(x):
  	print(c[i+1])
main()
### BUGGY CODE ###

import itertools
N, A = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
 
for i in range(1, N+1):
    check = list(itertools.combinations(x,i))
    for j in check:
        if sum(j) % len(j) == 0 and (sum(j) // len(j)) == A:
            ans +=1
print(ans)

### FIXED CODE ###

N, A = [int(_) for _ in input().split()]
x = [int(_) for _ in input().split()]
 
dp = [[0] * (sum(x)+1) for j in range(N+1)]
 
dp[0][0] = 1
for i in range(1, N+1):
    for j in list(range(1, N+1))[::-1]:
        for k in list(range(x[i-1], sum(x[:i])+1))[::-1]:
            dp[j][k] += dp[j-1][k - x[i-1]]
 
print(sum([dp[i][i*A] for i in range(1, N+1) if i*A <= sum(x)]))
### BUGGY CODE ###

N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    while a*f > m:
      a -= 1
      now_cost += 1
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)

### FIXED CODE ###

N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)
### BUGGY CODE ###

S = int(input())
n = int(S**0.5)
for i in range(n,0,-1):
    if S%i==0:
        L = i
        H = S//i
        break
x1 = 0
y1 = 0
x2 = L
y2 = 0
x3 = L
y3 = H
print(x1,y1,x2,y2,x3,y3)

### FIXED CODE ###

S = int(input())
if S<=10**9:
    print(0,0,0,1,S,0)
else:
    a = S%(10**9)
    x = 10**9
    y = 1
    if a==0:
        z = 0
    else:
        z = 10**9-a
    w = (S+y*z)//(10**9)
    print(0,0,x,y,z,w)
### BUGGY CODE ###

N = int(input())
A = tuple(map(int,input().split()))
for i in range(1,N+1):
  print(A.index(i)+1,end=" ")

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [[i+1,A[i]] for i in range(N)]
B.sort(key=lambda x: x[1])
for j in range(N):
  if j == N-1:
    print(B[j][0])
  else:
    print(B[j][0] ,end=" ")
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
triangle = 0
while len(l) >= 3:
  max_l = l.pop()
  for i in range(1, len(l)):
    rest_l = max_l - l[i]
    inf = -1
    sup = i
    while sup - inf > 1:
      x = (inf + sup) // 2
      if l[x] > rest_l:
        sup = x
      else:
        inf = x
    triangle += i - sup
print(triangle)

### FIXED CODE ###

from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()
triangle = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    index = bisect_left(l, l[i] + l[j], j + 1, n) - 1
    triangle += index - j
print(triangle)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
b = []
for i in range(len(A)):
    if i % 2 == 0:
        b.append(A[i])
    else:
        b.insert(0, A[i])
if n % 2 == 1:
    b.reverse()
print(' '.join(map(str, b)))


### FIXED CODE ###

class Cell:
    def __init__(self, entity, next, prev):
        self.entity = entity
        self.next = next
        self.prev = prev


n = int(input())
A = list(map(int, input().split()))
cell = Cell(A[0], None, None)
top = cell
last = cell

cnt = 0
for i in range(1, len(A)):
    cnt += 1
    if i % 2 == 0:
        tmp = last
        last = Cell(A[i], None, last)
        tmp.next = last
    else:
        tmp = top
        top = Cell(A[i], top, None)
        tmp.prev = top

b = []
cell = top
while(True):
    b.append(cell.entity)
    if not(cell.next):
        break
    cell = cell.next
if n % 2 == 1:
    b.reverse()
print(' '.join(map(str, b)))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
prime_judge = [0]*(max(a)+1)
for p in a:
  prime_judge[p] += 1
  if prime_judge[p] == 1:
    for j in range(2*p, max(a)+1, p):
      prime_judge[j] += 2

print(prime_judge.count(1))



### FIXED CODE ###

import collections

n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
c = collections.Counter(a)
data = sorted(list(set(a)))
max_ = max(a)+1
prime_bool = [True]*max_
prime_bool[0] = False

for i in range(len(data)):
  p = data[i]
  if prime_bool[p]:
    #print(p)
    k = 2
    while k*p < max_:
      prime_bool[k*p] = False
      k += 1

count = 0
for i in range(len(prime_bool)):
  if prime_bool[i]:
    if c[i] == 1:
      count += 1
print(count)
#print(prime_bool)
### BUGGY CODE ###

import numpy as np
import math
import collections
import bisect


a, b, c, d = map(int, input().split())

dp = np.array([[[1 for k in range(2)] for i in range(d + 1)] for j in range(c + 1)])
dp[:, :, 1] = 0
dp[0:a, :, :] = 0
dp[:, 0:b, :] = 0
#dp = list(dp)

for i in range(a, c + 1):
    for j in range(b, d + 1):
        # print(i, j, dp[i][j])
        if a == i and b == j:
            continue
        dp[i][j][0] = (i * dp[i][j - 1][0] % 998244353 + dp[i][j - 1][1] % 998244353) % 998244353
        dp[i][j][1] = (j * (dp[i - 1][j][0] % 998244353 + dp[i - 1][j][1] % 998244353)) % 998244353

print((dp[c][d][0] + dp[c][d][1]) % 998244353)


### FIXED CODE ###

#import numpy as np
import math
import collections
import bisect


def main():
    a, b, c, d = map(int, input().split())

    dp0 = [[1 for i in range(d + 1)] for j in range(c + 1)]
    dp1 = [[0 for i in range(d + 1)] for j in range(c + 1)]
    for i in range(c + 1):
        for j in range(d + 1):
            if j < b or i < a:
                dp0[i][j] = 0
                dp1[i][j] = 0
    for i in range(a, c + 1):
        for j in range(b, d + 1):
            # print(i, j, dp[i][j])
            if a == i and b == j:
                continue
            dp0[i][j] = ((i * dp0[i][j - 1]) % 998244353 + dp1[i][j - 1]) % 998244353
            dp1[i][j] = (j * (dp0[i - 1][j] + dp1[i - 1][j]) % 998244353) % 998244353

    print((dp0[c][d] + dp1[c][d]) % 998244353)


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

N=int(input())
count=0
s=[]
for i in range(N):
  a=input()
  if(a not in s):
    count+=1
    s.append(a)
print(count)

### FIXED CODE ###

N=int(input())
S=[input() for i in range(N)]
S.sort()
count=1
s=[]
for i in range(N-1):
  if(S[i]!=S[i+1]):
    count+=1
print(count)
### BUGGY CODE ###

n = int(input())
CSF = [list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
	time = CSF[i][1]+CSF[i][0]
	for j in range(i+1,n-1):
		while (time-CSF[j][1])%CSF[j][2] != 0 or time-CSF[j][1]<0:
			time += 1
		time += CSF[j][0]
	print(time)
print(0)

### FIXED CODE ###

from math import ceil

n = int(input())
CSF = [list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
	time = CSF[i][1]+CSF[i][0]
	for j in range(i+1,n-1):
		if (time-CSF[j][1])%CSF[j][2] != 0 or time-CSF[j][1]<0:
			time = max(CSF[j][1],CSF[j][2]*(ceil(time/CSF[j][2])))
		time += CSF[j][0]
	print(time)
print(0)
### BUGGY CODE ###

n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
import collections

P=collections.defaultdict(int)
PI=[collections.defaultdict(int) for _ in range(n)]
for i in range(n):
  a=A[i]
  for j in range(2,int(a**0.5)+1):
    while a%j==0:
      PI[i][j]+=1
      a//=j
  if a>1:
    PI[i][a]=1
  for p in PI[i].keys():
    P[p]=max(P[p],PI[i][p])
ans=0
for i in range(n):
  mul=1
  for p in P.keys():
    mul=(mul*pow(p,P[p]-PI[i][p],mod))%mod


  ans=(ans+mul)%mod
print(ans)

### FIXED CODE ###

n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**50000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)
### BUGGY CODE ###

s = input()
l = len(s)
X, Y = (int(x) for x in input().split())
F = s.split("T")
X -= F[0].count("F")
y_move = [f.count("F") for f in F[1::2]]
x_move = [f.count("F") for f in F[2::2]]

dpy = [[False] * (2 * l + 5) for _ in range(len(y_move) + 1)]
dpx = [[False] * (2 * l + 5) for _ in range(len(x_move) + 1)]
dpx[0][0] = dpy[0][0] = True

for i in range(1, len(x_move) + 1):
    for x in range(-l - 2, l + 2):
        if -l <= x - x_move[i - 1] <= l:
            dpx[i][x] |= dpx[i - 1][x - x_move[i - 1]]
        if -l <= x + x_move[i - 1] <= l:
            dpx[i][x] |= dpx[i - 1][x + x_move[i - 1]]

for i in range(1, len(y_move) + 1):
    for y in range(-l - 2, l + 2):
        if -l <= y - y_move[i - 1] <= l:
            dpy[i][y] |= dpy[i - 1][y - y_move[i - 1]]
        if -l <= y + y_move[i - 1] <= l:
            dpy[i][y] |= dpy[i - 1][y + y_move[i - 1]]

if dpx[- 1][X] and dpy[- 1][Y]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

s = input()
l = len(s)
X, Y = (int(x) for x in input().split())
F = s.split("T")
x_move = [f.count("F") for f in F[2::2]]
y_move = [f.count("F") for f in F[1::2]]
x_set = set()
x_set.add(F[0].count("F"))
y_set = set()
y_set.add(0)
for move in x_move:
    x_set = set(x + move for x in x_set) | set(x - move for x in x_set)
for move in y_move:
    y_set = set(y + move for y in y_set) | set(y - move for y in y_set)

if X in x_set and Y in y_set:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

H, W, D = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]
target = [[0,0] for _ in range(H*W+1)]
ans = 0
for i in range(H):
    for j in range(W):
        target[grid[i][j]][0] = i+1
        target[grid[i][j]][1] = j+1
for i in range(Q):
    tmp = 0
    current = LR[i][0]
    while current != LR[i][1]:
        tmp += abs(target[current][0]-target[current+D][0])+abs(target[current][1]-target[current+D][1])
        current += D
    print(tmp)

### FIXED CODE ###

H, W, D = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]
target = [[0,0] for _ in range(H*W+1)]
ruiseki = [[i+1] for i in range(D)]
ans = 0
for i in range(H):
    for j in range(W):
        target[grid[i][j]][0] = i+1
        target[grid[i][j]][1] = j+1
for i in range(D):
    tmp = ruiseki[i][0]
    ruiseki[i][0] = 0
    cnt = 0
    while tmp+D <= H*W:
        dist = abs(target[tmp][0]-target[tmp+D][0])+abs(target[tmp][1]-target[tmp+D][1])
        ruiseki[i].append(ruiseki[i][cnt]+dist)
        cnt += 1
        tmp += D
for i in range(Q):
    current = LR[i][0]
    tmp = D if current%D == 0 else current%D
    tmp -= 1
    print(ruiseki[tmp][((current-1)//D)+((LR[i][1]-current)//D)]-ruiseki[tmp][((current-1)//D)])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(500000)

N, M = map(int,input().split())

g = [[] for _ in range(N)]
for i in range(M):
  a,b = map(int,input().split())
  a -= 1; b -= 1
  g[a].append(b)
  g[b].append(a)#番号を修正。0スタートに。
#print(g)  
reach = [0 for _ in range(N)] #0からの距離を記録。0未到達。
par = [-1 for _ in range(N)] #親の位置を記録

def dfs(v):
  #reach[v] = 1 #今の点は到達した。これいるかな？
  for i in range(len(g[v])): #点vから行ける点をすべて探索
    u = g[v][i] #今探索している点
    if u == 0:
      continue
    if reach[u] != 0:
      if reach[u] > reach[v] + 1: #距離が近ければ更新
        reach[u] = reach[v] + 1
        par[u] = v
        dfs(u)
      else:
        continue
    reach[u] = reach[v] + 1 #探索中の点の到達を記録。
    par[u] = v
    dfs(u)

dfs(0)
#print(reach,par)
if 0 not in reach[1:]:
  print("Yes")
  for i in range(1,N):
    ans = par[i]+1
    print(ans)
else:
  print("No")

### FIXED CODE ###

import sys
import heapq

N, M = map(int,input().split())

g = [[] for _ in range(N)]
for i in range(M):
  a,b = map(int,input().split())
  a -= 1; b -= 1
  g[a].append(b)
  g[b].append(a)#番号を修正。0スタートに。
#print(g)

INF = float('inf')
reach = [INF for _ in range(N)] #0からの距離を記録。INF未到達。
reach[0] = 0
par = [-1 for _ in range(N)] #親の位置を記録

Q =[]
heapq.heappush(Q, (0,0)) #0からの距離と頂点を入れる。

while Q:
  d,v = heapq.heappop(Q)
  for i in range(len(g[v])): #点vから行ける点をすべて探索
    u = g[v][i] #今探索している点
    #print(v,u)
    if u == 0: #始点の場合はスルー
      continue
    if reach[u] != INF: #到達済みならスキップ
      continue
    reach[u] = d + 1 #探索中の点の到達を記録。
    par[u] = v
    heapq.heappush(Q, (reach[u],u))

#print(reach,par)
if INF not in reach[1:]:
  print("Yes")
  for i in range(1,N):
    ans = par[i]+1
    print(ans)
else:
  print("No")
### BUGGY CODE ###

import sys
N = int(input())
A = list(map(int, input().split()))
Q = int(input())


for q in range(Q):
    b, c = map(int, input().split())
    for n in range(N):
        if b == A[n]:
            A[n] = c
    print(sum(A))

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
Q = int(input())
ans = []
s = sum(A)
for _ in range(Q):
    b, c = map(int, input().split())
    n = cnt[b]
    if b in cnt:
        cnt[c] += cnt[b]
        del cnt[b]
    s += (c-b)*n
    print(s)
### BUGGY CODE ###

from collections import deque
import numba
from numba import jit

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [input() for i in range(H)]

queue = deque()
queue.append((Ch-1, Cw-1, 0))
inf = float("inf")
table = [[inf] * W for i in range(H)]
table[Ch-1][Cw-1] = 0
walk_move = ((-1, 0), (0, -1), (1, 0), (0, 1))
magic_move = []
for i in range(-2, 3):
  for j in range(-2, 3):
    if not i and not j:
      continue
    else:
      magic_move.append([i, j])
@jit
def main():
  while queue:
    x, y, cost = queue.popleft()
    for i,j in walk_move:
      dx = x+i
      dy = y+j
      if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost:
        queue.appendleft((dx, dy, cost))
        table[dx][dy] = cost
    for k,l in magic_move:
      dx = x+k
      dy = y+l
      if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost+1:
        queue.append((dx, dy, cost+1))
        table[dx][dy] = cost+1
  return table[Dh-1][Dw-1]

ans = main()
if ans == inf:
  print("-1")
else:
  print(table[Dh-1][Dw-1])


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [input() for i in range(H)]

queue = deque()
queue.append((Ch-1, Cw-1, 0))
inf = float("inf")
table = [[inf] * W for i in range(H)]
table[Ch-1][Cw-1] = 0
walk_move = ((-1, 0), (0, -1), (1, 0), (0, 1))
magic_move = []
for i in range(-2, 3):
  for j in range(-2, 3):
    if not i and not j:
      continue
    else:
      magic_move.append([i, j])

while queue:
  x, y, cost = queue.popleft()
  for i,j in walk_move:
    dx = x+i
    dy = y+j
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost:
      queue.appendleft((dx, dy, cost))
      table[dx][dy] = cost
  for k,l in magic_move:
    dx = x+k
    dy = y+l
    if 0 <= dx <= H-1 and 0 <= dy <= W-1 and maze[dx][dy] == "." and table[dx][dy] > cost+1:
      queue.append((dx, dy, cost+1))
      table[dx][dy] = cost+1

ans = table[Dh-1][Dw-1]
if ans == inf:
  print("-1")
else:
  print(table[Dh-1][Dw-1])
### BUGGY CODE ###

from collections import Counter
#from scipy.special import comb
# a = comb(n, r)
# >> cannot use in Contest (like AtCoder)


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n
    if n <= 1:
        return 0

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


N = int(input())
data = list(map(int, input().split()))
count = Counter(data)
#print(count) > Counter({1: 4, 2: 2, 4: 2})
countMost = count.most_common()

lis = [0] * (2 * 10 ** 5)
tot = 0
for i, v in countMost:
    #print(i, v)
    lis[i - 1] = v
    tot += cmb(v, 2)
#print('TOT', tot)
# print(lis[0])
for i, v in enumerate(data):
    num = lis[v - 1]
    if (num == 2):
        #    print('a')
        ans = tot - 1
    else:
        ans = tot - cmb(num, 2) + cmb(num-1, 2)

    print(ans)
'''
dataSort = data.sort()
print(countMost)
print(len(countMost))
'''


### FIXED CODE ###

from collections import Counter
#from scipy.special import comb
# a = comb(n, r)
# >> cannot use in Contest (like AtCoder)


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n
    if n <= 1:
        return 0

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


N = int(input())
data = list(map(int, input().split()))
count = Counter(data)
#print(count) > Counter({1: 4, 2: 2, 4: 2})
countMost = count.most_common()

lis = [0] * (2 * 10 ** 5)
combination = [0] * (2 * 10 ** 5)
tot = 0
for i, v in countMost:
    #print(i, v)
    lis[i - 1] = v
    val = cmb(v, 2)
    tot += val
    combination[i - 1] = val
#print('TOT', tot)
# print(lis[0])
for i, v in enumerate(data):
    num = lis[v - 1]
    if (num == 2):
        #    print('a')
        ans = tot - 1
    else:
        ans = tot - combination[v-1] + cmb(num-1, 2)

    print(ans)
'''
dataSort = data.sort()
print(countMost)
print(len(countMost))
'''
### BUGGY CODE ###

import math
import sys


sys.setrecursionlimit(1000000)

X, Y = map(int, input().split())

# いけない
if (X + Y) % 3 != 0:
    print(0)
    exit()
if 2*Y < X:
    print(0)
    exit()
if Y > 2*X:
    print(0)
    exit()

# 何段目
dan = (X + Y) // 3

# 端から
x = X + Y
y = 0
while True:
    x -= 1
    y += 1
    if x - 2*y == 0:
        break


def comb(n, r):
    return (math.factorial(n)) // (math.factorial(n - r) * math.factorial(r))


dic = {}


# def comb(n, r, d):
#     if r == 0 or r == n:
#         return 1
#     if r == 1:
#         return n
#     if (n, r) in d:
#         return d[(n, r)]
#     d[(n, r)] = comb(n-1, r, d) + comb(n-1, r-1, d)
#     return d[(n, r)]


print(comb(dan, x - X) % 1000000007)


### FIXED CODE ###

import math
import sys


sys.setrecursionlimit(1000000)

X, Y = map(int, input().split())

# いけない
if (X + Y) % 3 != 0:
    print(0)
    exit()
if 2*Y < X:
    print(0)
    exit()
if Y > 2*X:
    print(0)
    exit()

# 何段目
dan = (X + Y) // 3

# 端から
x = X + Y
y = 0
while True:
    x -= 1
    y += 1
    if x - 2*y == 0:
        break


def comb(n, r):
    return (math.factorial(n)) // (math.factorial(n - r) * math.factorial(r))


dic = {}


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

# print(comb(dan, x - X) % 1000000007)
print(cmb(dan, x - X, mod))
### BUGGY CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    for i in range(N):
        if A[i] == B[i]:
            j = 0
            while j < N:
                if A[i] != B[j] and A[j] != B[i]:
                    B[i], B[j] = B[j], B[i]
                    break                
                j += 1
            if A[i] == B[i]:
                print("No")
                return

    print('Yes')
    print(*B)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###


from collections import Counter
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    CNT = Counter(A+B)
    num = CNT.most_common()[0][1]
    if num > N:
        print("No")
        return 

    j, pre = 0, -1
    for i in range(N):
        if A[i] != pre:
            j = 0
        if A[i] == B[i]:
            while j < N:
                if A[i] != B[j] and A[j] != B[i]:
                    B[i], B[j] = B[j], B[i]
                    break
                j += 1
        pre = A[i]

    print('Yes')
    print(*B)


if __name__ == "__main__":
    resolve()