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

# 東京海上日動 プログラミングコンテスト2020 C

import sys
n, k = map(int, input().split())
A = list(map(int, input().split()))
 
for r in range(k):
    B = [0 for i in range(n+1)]
    for i in range(n):    
        d_min = max(0, i - A[i])
        d_max = min(n, i + A[i] + 1)
        B[d_min] += 1
        B[d_max] -= 1
        # print(d_min, d_max, B)
    t = 0
    flag = True
    for i in range(n):
        t += B[i]
        if A[i] != t:
            flag = False
        A[i] = t
    if flag:
        break
    # print(A, B)

print(' '.join(map(str, A)))

### FIXED CODE ###

# 東京海上日動 プログラミングコンテスト2020 C
import numpy as np
from numba import njit
n, k = map(int, input().split())
A = np.array(list(map(int, input().split())), dtype=np.int64)

@njit
def imos(n, A):
    B = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        left = max(0, i - A[i])
        right = min(n, i + A[i] + 1)
        B[left] += 1
        B[right] -= 1
    B = np.cumsum(B)
    return B[:-1]

def solve(n,k,A):
    for i in range(k):
        A = imos(n, A)
        min_A = min(A)
        if min_A == n:
            return A
    return A

ANS = solve(n, k, A)
print(' '.join(map(str, ANS)))
### BUGGY CODE ###

n, k = map(int, input().strip().split())
xs = list(map(int, input().strip().split()))


def min_for_interval(interval):
    left = interval[0]
    right = interval[-1]

    if left < 0:
        if right < 0:
            return abs(left)
        else:
            l_r = 2 * abs(left) + abs(right)
            r_l = 2 * abs(right) + abs(left)
            return min(l_r, r_l)
    else:
        return right


min_time = 1e9
for i in range(0, n - k + 1):
    interval = xs[i:i + k]
    min_time = min(min_for_interval(interval), min_time)

print(min_time)


### FIXED CODE ###

n, k = map(int, input().strip().split())
xs = list(map(int, input().strip().split()))


def min_for_interval(left, right):
    if left < 0:
        if right < 0:
            return abs(left)
        else:
            l_r = 2 * abs(left) + abs(right)
            r_l = 2 * abs(right) + abs(left)
            return min(l_r, r_l)
    else:
        return right


min_time = 1e9
for i in range(0, n - k + 1):
    left = xs[i]
    right = xs[i + k - 1]
    min_time = min(min_for_interval(left, right), min_time)

print(min_time)
### BUGGY CODE ###

S = input()
Q = int(input())
for i in range(Q):
    query = list(input().split())
    if query[0] == '1':
        S = S[::-1]
    elif query[1] == '1':
        S = query[2] + S
    else:
        S += query[2]
print(S)


### FIXED CODE ###

from collections import deque
S = deque(list(input()))
Q = int(input())
cnt = 0
for i in range(Q):
    query = list(input().split())
    if query[0] == '1':
        cnt += 1
    elif query[1] == '1':
        if cnt % 2 == 0:
            S.appendleft(query[2])
        else:
            S.append(query[2])
    else:
        if cnt % 2 == 0:
            S.append(query[2])
        else:
            S.appendleft(query[2])
if cnt % 2 != 0:
    S.reverse()
print(''.join(S))
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

s = input()
q = int(input())
# print(s,q)
head = True
for i in range(q):
    query = input().split(' ')
    # print(query)
    if query[0]=='1':
        head = not head
    else:
        if query[1]=='1':
            if head:
                s = query[2]+s
            else:
                s += query[2]
        else:
            if head:
                s += query[2]
            else:
                s = query[2]+s
    # print(s)
if head:
    print(''.join(s))
else:
    print(''.join(s[::-1]))

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

s = input()
q = int(input())
# print(s,q)
head = True
right = ''
left = ''
for i in range(q):
    query = input().split(' ')
    # print(query)
    if query[0]=='1':
        head = not head
    else:
        if query[1]=='1':
            if head:
                left += query[2]
            else:
                right += query[2]
        else:
            if head:
                right += query[2]
            else:
                left += query[2]
    # print(left,  right)
s = left[::-1]+s+right
if head:
    print(s)
else:
    print(s[::-1])
### BUGGY CODE ###

n=int(input())

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

z=[0]*((10**5)+1)

for i in range(n):
  z[a[i]]+=1

q=int(input())

y=[]


for i in range(q):
  b,c=map(int,input().split())
  z[c]+=z[b]
  z[b]=0
  #print(z)
  sam=0
  for j in range(len(z)):
    sam+=z[j]*j
  y.append(sam)

for i in range(len(y)):
  print(y[i])

### FIXED CODE ###

n=int(input())

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

z=[0]*((10**5)+1)

for i in range(n):
  z[a[i]]+=1

q=int(input())

y=[]

sam=sum(a)

for i in range(q):
  b,c=map(int,input().split())
  z[c]+=z[b]
  sam-=z[b]*b
  sam+=z[b]*c
  z[b]=0
  #print(z)
  
  y.append(sam)

for i in range(len(y)):
  print(y[i])
### BUGGY CODE ###

n,k,q=(int(x) for x in input().split())
a=[]
p=[]
for i in range(0,q):
    temp=int(input())
    a.append(temp)
for j in range(0,n):
    p.append(a.count(j+1))
for m in range(0,n):
    c=k+(-1)*(sum(p))+p[m]
    #print('No %d point is %d'% (m,c))
    if c >0:
        print('Yes')
    else:
        print('No')
#print(p)


### FIXED CODE ###

n,k,q=(int(x) for x in input().split())
a=[]
p=[0]*n
for i in range(0,q):
    temp=int(input())
    p[temp-1]+=1
border=-k+q

res = '\n'.join('Yes' if p[j]> border else 'No' for j in range(0,n))

print(res)
### BUGGY CODE ###

from bisect import bisect
from operator import itemgetter

n, a, b = map(int, input().split())
ppp = map(int, input().split())
qqq = [i for i, p in sorted(enumerate(ppp, start=1), key=itemgetter(1))]
INF = 10 ** 15

dp = [(0, 0)]
for i in qqq:
    s = bisect(dp, (i,))
    ndp = [(j, cost + b) for j, cost in dp[:s]]
    stay_cost = dp[s - 1][1]
    ndp.append((i, stay_cost))
    ndp.extend((j, cost + a) for j, cost in dp[s:] if stay_cost > cost + a)
    dp = ndp
print(dp[-1][1])


### FIXED CODE ###

from bisect import bisect
from operator import itemgetter

n, a, b = map(int, input().split())
ppp = map(int, input().split())
qqq = [i for i, p in sorted(enumerate(ppp, start=1), key=itemgetter(1))]
INF = 10 ** 15

dp = [(0, 0)]
for i in qqq:
    ndp = []
    s = bisect(dp, (i,))
    tmp_min = INF
    for j, cost in dp[:s]:
        cost += b
        ndp.append((j, cost))
        tmp_min = cost
    stay_cost = dp[s - 1][1]
    if tmp_min > stay_cost:
        ndp.append((i, stay_cost))
        tmp_min = stay_cost
    for j, cost in dp[s:]:
        cost += a
        if tmp_min > cost:
            ndp.append((j, cost))
            tmp_min = cost
    dp = ndp

print(dp[-1][1])
### BUGGY CODE ###

N,K = map(int,input().split())
li = [0 for _ in range(K)]

mod = 10**9+7
ans = 0
for i in range(K,0,-1):
    mm = K//i
    mm = mm**N

    for j in range(2,(K//i)+1):
        mm -= li[i*j-1]    
    li[i-1] = mm


    ans += i*mm
    ans %= mod

print(ans)

### FIXED CODE ###

#!/usr/bin/env python3

def pow(N,R,mod):
    ans = 1
    i = 0
    while((R>>i)>0):
        if (R>>i)&1:
            ans *= N
            ans %= mod
        N = (N*N)%mod
        i += 1
    return ans%mod


def main():
    N,K = map(int,input().split())
    li = [0 for _ in range(K)]

    mod = 10**9+7
    ans = 0
    for i in range(K,0,-1):
        mm = K//i
        mm = pow(mm,N,mod)

        for j in range(2,(K//i)+1):
            mm -= li[i*j-1]    
        li[i-1] = mm


        ans += (i*mm)%mod
        ans %= mod

    print(ans)

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

A,B,C,D,E,F=map(int,input().split())
weight=100*A
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range((i*A+j*B)*E//C+1):
            for l in range((i*A+j*B)*E//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))


### FIXED CODE ###

A,B,C,D,E,F=map(int,input().split())
weight=100*A
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range((i*A+j*B)*E//C+1):
            for l in range((i*A+j*B)*E//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))
### BUGGY CODE ###

import collections
import itertools


def p_c():
    n = int(input())
    ans = 0

    l = [collections.Counter(input()) for _ in range(n)]

    b = list(itertools.combinations(l, 2))
    for i in b:
        if i[0] == i[1]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_c()

### FIXED CODE ###

from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()
### BUGGY CODE ###

import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
for _ in range(M):
  B,C = map(int,input().split())
  index = min(bisect.bisect_left(A,C), B)
  if index==0:
    continue
  A = [C for i in range(index)] + A[index:]
  A.sort()
print(sum(A))

### FIXED CODE ###

import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))
D = []
for _ in range(M):
  D.append(list(map(int,input().split())))
D.sort(key=lambda x:x[1], reverse=True)
cnt = 0
ans = []
for d in D:
  b,c = d[0],d[1]
  ans += [c for _ in range(b)]
  cnt += b
  if cnt>=N:
    break
ans = ans[:min(cnt,N)] + A
ans.sort(reverse=True)
print(sum(ans[:N]))
### BUGGY CODE ###

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

MOD = 10 ** 9 + 7

def gcd(x, y):
  return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
  return x * y // gcd(x, y)

tmp = A[0]
for i in range(1, N):
  tmp = lcm(A[i], tmp)
#print(tmp)

answer = 0
for a in A:
  answer += tmp // a
print(answer % MOD)

### FIXED CODE ###

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

MOD = 10 ** 9 + 7

def gcd(x, y):
  return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
  return x * y // gcd(x, y)

tmp = A[0]
for i in range(1, N):
  tmp = lcm(A[i], tmp)
#print(tmp)

answer = 0
for a in A:
  answer += tmp // a
print(answer % MOD)
### BUGGY CODE ###

from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1
for i in range(N):
    ans *= A[i]
    
if ans > pow(10, 18):
    ans = -1
    
print(ans)


### FIXED CODE ###

from sys import stdin

N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))

ans = 1

if 0 in A:
    ans = 0

if ans:
    for a in A:
        ans *= a
        if ans > pow(10, 18):
            ans = -1
            break

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

N,S = map(int, input().split())
A = [int(a) for a in input().split()]
mod = 998244353

A.sort()
num = 0
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    num += A[i]
    for j in range(i+1, 0, -1):
        for k in range(A[i], min(num, S)+1):
            dp[j][k] += dp[j-1][k-A[i]]

ans = 0
for i in range(1, N+1):
    ans += dp[i][S]*pow(2, N-i, mod)
    ans %= mod
print(ans)

### FIXED CODE ###

N,S = map(int, input().split())
A = [int(a) for a in input().split()]
mod = 998244353

dp = [[0]*(S+1) for _ in range(N+1)]
#dp[i][j]:集合{A[k]|k=0,1,,,i}の部分集合の部分集合のうち、要素の総和がjになるものの個数
dp[0][0] = 1
for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2*dp[i][j] #A[i]を使わない場合、集合{A[k]|k=0,1,,,i}の部分集合の数が2倍だけ増える
        dp[i+1][j] %= mod
        if j+A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j] #A[i]を使う場合、総和がjになる部分集合にA[i]を足せばよいので、個数はdp[i][j]だけ増える
            dp[i+1][j+A[i]] %= mod

print(dp[N][S])
### BUGGY CODE ###

s=input()
n = len(s)
k = int(input())

subs = set()
for i in range(n):
    for j in range(i+1,n+1):
        subs.add(s[i:j])
print(sorted(list(subs))[k-1])


### FIXED CODE ###

import collections
import string
import heapq
s=input()
n = len(s)
k = int(input())

m = ['zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz','zzzzzzz']
subs = []
for i in range(n):
    for j in range(i+1, min(i+6, n+1)):
        sub = s[i:j]
        if sub not in subs:
            subs.append(sub)
            subs.sort()
            subs = subs[:5]
print(subs[k-1])
### BUGGY CODE ###

from collections import deque 
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
a = deque(a)
if a.count(min(a)) >= 2:
    ans = 0
else:
    ans = 1
ln = [i for i in a if a.count(i) >= 2]
while a:
    v = a.popleft()
    if v not in ln:
        x = 0
        for j in a:
            if v % j == 0:
                break
            else:
                x += 1
            if x == len(a):
                ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
import bisect
n = int(input()) #リストの要素数
a = list(map(int, input().split())) #リストの要素
cnt = Counter(a) #aの要素数についての辞書
a.sort()#aを小さい順にソート
ans = 0
mx = 10 ** 6
p = [0] * (mx + 1)
for i in a:
    if p[i] == 0:
        for j in range(mx + 1):
            x = i * j
            if x > mx:
                break
            p[x] = 1 #pの中でaの要素iの倍数として表現できるものに１
        if cnt[i] == 1:
            ans += 1 #pの中で任意のiの倍数として表現できず、かつ１つのみ存在するものをカウント
print(ans)
### BUGGY CODE ###

n, m = [int(i) for i in input().split()]

a = {}
py = []
for mi in range(m):
    pi, yi = [int(i) for i in input().split()]
    if pi in a:
        a[pi].append(yi)
    else:
        a[pi] = [yi]
    py.append((pi, yi))

for av in a.values():
    av.sort()

for pyi in py:
    sp = str(pyi[0]).zfill(6)
    sy = str(a[pyi[0]].index(pyi[1]) + 1).zfill(6)
    print(sp + sy)

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
ipyo = [[i] + [int(_) for _ in input().split()] + [0] for i in range(m)]

ipyo.sort(key=lambda x: x[2])

cnt = [0] * n
for v in ipyo:
    p = v[1]
    cnt[p - 1] += 1
    v[3] = cnt[p - 1]

ipyo.sort(key=lambda x: x[0])

for v in ipyo:
    print('{0:06d}'.format(v[1]) + '{0:06d}'.format(v[3]))
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

int1 = lambda x: int(x) - 1
N, M = map(int, input().split())

if M == 0:
    print(-1)
    exit()

UV = np.array([tuple(map(int1, input().split())) for _ in range(M)]) * 3
frm = UV[:, 0].repeat(3) + np.tile(np.arange(3), M)
to = UV[:, 1].repeat(3) + np.tile((np.arange(3) + 1) % 3, M)

S, T = map(int1, input().split())
matr = csr_matrix((np.ones(3 * M, dtype=int), (frm, to)), shape=(3 * N, 3 * N))
way = dijkstra(matr, indices=3 * S).astype(int)

res = way[3 * T]
print(res // 3 if res >= 0 else -1)


### FIXED CODE ###

import sys
from collections import deque

input = sys.stdin.buffer.readline
int1 = lambda x: int(x) - 1

N, M = map(int, input().split())
G = [[] for _ in range(3 * N)]
for _ in range(M):
    u, v = map(int1, input().split())
    G[u * 3].append(v * 3 + 1)
    G[u * 3 + 1].append(v * 3 + 2)
    G[u * 3 + 2].append(v * 3)

S, T = map(int1, input().split())
S *= 3
T *= 3

# bfs
d = deque([S])
distance = [0] * (3 * N)
while d:
    v = d.popleft()
    dist_v = distance[v]
    if v == T:
        print(dist_v // 3)
        exit()
    for x in G[v]:
        if not distance[x]:
            d.append(x)
            distance[x] = dist_v + 1
print(-1)
### BUGGY CODE ###

def e_colorful_blocks(MOD=998244353):
    N, M, K = [int(i) for i in input().split()]
    # dp[i][k]: i 番目まで見たときに、同じ色で塗られている組が k 組である
    dp = [[0] * (K + 1) for _ in range(N)]
    dp[0][0] = M

    for i in range(N - 1):
        for k in range(min(i, K) + 1):
            if k == K:
                dp[i + 1][k] += dp[i][k] * (M - 1)  # 異なる色で塗るしかない
                dp[i + 1][k] %= MOD
            else:
                dp[i + 1][k] += dp[i][k] * (M - 1)  # 左と異なる色で塗る
                dp[i + 1][k + 1] += dp[i][k]  # 左と同じ色で塗る
                dp[i + 1][k] %= MOD
                dp[i + 1][k + 1] %= MOD
    return sum([dp[N - 1][k] for k in range(K + 1)]) % MOD

print(e_colorful_blocks())

### FIXED CODE ###

def e_colorful_blocks(MOD=998244353):
    N, M, K = [int(i) for i in input().split()]

    class Combination(object):
        """素数 mod に対する二項係数の計算"""
        __slots__ = ['mod', 'fact', 'factinv']

        def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_val_arg + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], -1, mod))
            for i in range(max_val_arg, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.fact, self.factinv = mod, fac, inv[::-1]

        def combination(self, n, r):
            return (0 if n < 0 or r < 0 or n < r
                    else self.fact[n] * self.factinv[r] * self.factinv[n - r] % self.mod)

    ans = 0
    comb = Combination(max(N, M), MOD).combination
    for x in range(K + 1):
        a = (M * pow(M - 1, N - 1 - x, MOD)) % MOD
        b = comb(N - 1, x)
        ans = (ans + a * b) % MOD
    return ans

print(e_colorful_blocks())
### BUGGY CODE ###

N,M = (int(i) for i in input().split())
A = [0]*(N+1)
B = [0]*(N+1)

ans = 0
for i in range(N):
    A[i],B[i] = (int(j) for j in input().split())

for j in range(1,M+1):
    max = -1
    temp = -1
    for i in range(N):
        if A[i]<=j and B[i] > max :
            max = B[i]
            temp = i
    if temp != -1:
        ans+=B[temp]
        A[temp] = M+1

print(ans)


### FIXED CODE ###

from heapq import heappush,heappop

N,M = (int(i) for i in input().split())
a = [0] *N
b = [0] *N
T = []
list = [[] for i in range(M+1)]

for i in range(N):
    a[i],b[i] = map(int,input().split())
    if a[i] <= M:
        list[a[i]].append(b[i])

k = 0
ans = 0
for j in range(1,M+1):
    for i in list[j]:
        heappush(T,-1 * i)
    if T != []:
        ans += -1 * heappop(T)

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

# coding: utf-8

S = input()
Q = int(input())


rev = False
for _ in range(Q):
    line = input()

    if line[0] == "1":
        rev = not rev

    else:
        if line[2] == "1":
            if rev:
                S = S + line[4]
            else:
                S = line[4] + S
        else:
            if rev:
                S = line[4] + S
            else:
                S = S + line[4]

if rev:
    print(S[::-1])
else:
    print(S)
    

### FIXED CODE ###

# coding: utf-8

S = input()
Q = int(input())


heads = {}
tails = {}
h = 0
t = 0
rev = False
for _ in range(Q):
    line = input()

    if line[0] == "1":
        rev = not rev

    else:
        if line[2] == "1":
            if rev:
                # S = "".join([S, line[4]])
                tails[t] = line[4]
                t += 1
            else:
                # S = "".join([line[4], S])
                heads[h] = line[4]
                h += 1
        else:
            if rev:
                # S = "".join([line[4], S])
                heads[h] = line[4]
                h += 1
            else:
                # S = "".join([S, line[4]])
                tails[t] = line[4]
                t += 1

head = [None] * h
tail = [None] * t

for i in range(h):
    head[i] = heads[i]
head = head[::-1]

for i in range(t):
    tail[i] = tails[i]

head_joint = "".join(head)
tail_joint = "".join(tail)
joint = "".join([head_joint, S, tail_joint])

if rev:
    print(joint[::-1])
else:
    print(joint)
### BUGGY CODE ###

import numpy as np
import copy
 
N, W = map(int, raw_input().split())
dp = np.zeros((W+1, N))

w, v = map(int, raw_input().split())

dp[w][0] = v

for i in range(1, N):
    w, v = map(int, raw_input().split())
    for j in range(W+1):
        dp_pre = dp[j]
        if j-w > -1:
            dp_update = dp[j-w][i-1] + v
        else:
            dp_update = 0
        dp[j][i] = max(dp[j][i-1], dp_update)

print int(dp[-1][-1])

### FIXED CODE ###

def main():

    N, W = map(int, raw_input().split())
    dp = [0]*(W+1)
 
    for i in xrange(N):
        w, v = map(int, raw_input().split())
        for j in xrange(W, w-1, -1):
            x = dp[j-w] + v
            if x > dp[j]:
                dp[j] = x
 
    print dp[-1]

main()
### BUGGY CODE ###

n,M = list(map(int,input().split()))
m = [[0]*n for _ in range(n)]
dp = [0]*n
from collections import deque
que = deque()
for _ in range(M):
  a,b = list(map(int,input().split()))
  m[a-1][b-1] = 1
  m[b-1][a-1] = 1
  if a == 1:
    que.append(b-1)
    dp[b-1] = 1
  if b == 1:
    que.append(a-1)
    dp[a-1] = 1

while que:
  c = que.popleft()
  for i in range(n):
    if m[c][i] == 1 and dp[i] == 0 :
      dp[i] = c+1
      que.append(i)

for i in range(1,n):
  if dp[i] == 0:exit(print('No'))

print('Yes')
for i in range(1,n):
  print(dp[i])


### FIXED CODE ###

n,M = list(map(int,input().split()))

m = [[] for _ in range(n)]
dp = [0]*n
from collections import deque
que = deque()
for _ in range(M):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  m[a].append(b)
  m[b].append(a)
  if a == 0:
    que.append(b)
    dp[b] = 1
  if b == 0:
    que.append(a)
    dp[a] = 1

while que:
  c = que.popleft()
  for i in m[c]:
    if dp[i] == 0 :
      dp[i] = c+1
      que.append(i)

#[exit(print('No')) for i in range(1,n)  if dp[i] == 0]

print('Yes')
[print(dp[i]) for i in range(1,n)]
### BUGGY CODE ###

def gcd(a, b):
    while b != a:
        if a < b:
            while a < b:
                b = b - a
        elif b < a:
            while b < a:
                a = a - b
    return a

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

    
n = int(input())
a = [int(x) for x in input().split(" ")]

while len(a) > 1:
    a = m(a)

print(a[0])


### FIXED CODE ###

def gcd(a, b):
    while b != a:
        if a < b:
            b = b % a
            if b == 0:
                return a
        elif b < a:
            a = a % b
            if a == 0:
                return b
    return a

def m(a):
    a.sort()
    l = len(a)
    b = []
    for i in range(l // 2):
        b.append(gcd(a[i], a[l - i - 1]))
    if l % 2 == 1:
        b.append(a[l // 2])
    return list(set(b))

    
n = int(input())
a = [int(x) for x in input().split(" ")]

while len(a) > 1:
    a = m(a)

print(a[0])
### BUGGY CODE ###

from time import time
from random import randrange

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
start = time()

for i in range(n):
    if A[i] != B[i]:
        continue
    while time() - start < 1.9:
        j = randrange(n)
        if A[i] != B[j] and A[j] != B[i]:
            B[i], B[j] = B[j], B[i]
            break
    else:
        print("No")
        exit(0)

print("Yes")
print(*B)


### FIXED CODE ###

import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
from random import randrange
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if Counter(A + B).most_common()[0][1] > n:
        print("No")
        return

    for i in range(n):
        if A[i] != B[i]:
            continue
        while 1:
            j = randrange(0, n)
            if A[i] != B[j] and A[j] != B[i]:
                B[i], B[j] = B[j], B[i]
                break
    print("Yes")
    print(*B)
resolve()