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

import re
s = input()
n = len(s)
while len(re.findall("10|01", s)) > 0:
    s = re.sub("10|01", "", s)
print(n - len(s))

### FIXED CODE ###

import sys
s = sys.stdin.read().strip()
n = len(s)
print(2 * min(s.count("0"), s.count("1")))
### BUGGY CODE ###

n = int(input())
s = list(input())
ansl = []
for i in range(1,n):
    ans = 0
    count = 0
    for j in range(n-i):
        #print(s[j],s[j+i])
        if s[j] == s[j+i]:
            count += 1
        else:
            if count > 0:
                if count > ans:
                    ans = min(count,i)
                count = 0
    if count > ans:
        ans = min(count,i)
    ansl.append(ans)
if len(ansl) > 0:
    print(max(ansl))

### FIXED CODE ###

n = int(input())
s = list(input())
ansl = []
for i in range(1,n):
    ans = 0
    count = 0
    for j in range(n-i):
        #print(s[j],s[j+i])
        if s[j] == s[j+i]:
            count += 1
        else:
            if count > 0:
                if count > ans:
                    ans = min(count,i)
                count = 0
    if count > ans:
        ans = min(count,i)
    ansl.append(ans)
print(max(ansl))
### BUGGY CODE ###

from math import factorial

x, y = map(int, input().split())
if y > x:
  x, y = y, x

a = (x+y)/3
b = (2*y-x)/3
if (x+y)%3 == 0 and (2*y-x)%3 == 0 and a*b >= 0:
  answer = factorial(a) // factorial(b) // factorial(a - b)
  print(answer % (10**9+7))
else:
  print(0)

### FIXED CODE ###

x, y = map(int, input().split())
if y > x:
  x, y = y, x

def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

a = (x+y)//3
b = (2*y-x)//3
if (x+y)%3 == 0 and (2*y-x)%3 == 0 and a*b >= 0:
  print(cmb(a, b, p))
else:
  print(0)
### BUGGY CODE ###

S = input()
Q = int(input())
Q_lst = []
for i in range(Q):
    Q_lst.append(input().split())
for i in range(len(Q_lst)):
    if Q_lst[i] == ["1"]: #T == 1
        S = S[::-1]
    elif Q_lst[i][1] == "1":    #T == 2, F == 1
        S = Q_lst[i][2] + S
    else:   #F == 2
        S = S + Q_lst[i][2]
print(S)

### FIXED CODE ###

S = input()
Q = int(input())
reverse = 1
head = ""
tail = ""
for i in range(Q):
    a = input().split()
    if a[0] == "1":
        reverse *= -1
    elif a[1] == "1":
        if reverse == 1:
            head += a[2]
        else:
            tail += a[2]
    else:
        if reverse == 1:
            tail += a[2]
        else:
            head += a[2]
# for i in range(Q):
#     a = input().split()
#     if a[0] == "1":
#         reverse *= -1
#     elif a[1] == "1":
#         if reverse == 1:
#             S = a[2] + S
#         else:
#             S = S + a[2]
#     else:
#         if reverse == 1:
#             S = S + a[2]
#         else:
#             S = a[2] + S
S = head[::-1] + S + tail
if reverse == -1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

import bisect

N = int(input())
A = [int(i) for i in input().split(' ')]
B = [int(i) for i in input().split(' ')]
C = [int(i) for i in input().split(' ')]

my_list = []
A.sort()
B.sort()
C.sort()

count = 0
for a in A:
    i = bisect.bisect_right(B,a)
    for b in B[i::]:
        j = bisect.bisect_right(C,b)
        count += len(C[j::])
        
print(count)

### FIXED CODE ###

import bisect

N = int(input())
A = [int(i) for i in input().split(' ')]
B = [int(i) for i in input().split(' ')]
C = [int(i) for i in input().split(' ')]

A.sort()
B.sort()
C.sort()

count = 0
for b in B:
    i = bisect.bisect_left(A,b)
    j = bisect.bisect_right(C,b)
    count += i * (N - j)

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

from collections import defaultdict
from heapq import heapify, heappop
import heapq
n,m,s,t =list(map(int,input().split()))

MAX_VAL = 10**20
uvab =  [list(map(int,input().split())) for _ in range(m)]
jpy_cost = defaultdict(dict)
snuke_cost = defaultdict(dict)


for u,v,a,b in uvab:
    u=u-1
    v=v-1
    jpy_cost[u][v] = a
    jpy_cost[v][u] =a
    snuke_cost[u][v]=b
    snuke_cost[v][u]=b


# Dijktra's shortest path algorithm. Prints the path from source to target.


def dijkstra(adj, source):
    INF = MAX_VAL
    dist = [INF for x in range(n)]
    dist[source] = 0
    PQ = []
    heapq.heappush(PQ, [dist[source], source])

    while (PQ):
        u_dist,u_id = heapq.heappop(PQ)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(PQ, [dist[v], v])
    return dist


jpy_dijk =  dijkstra(jpy_cost,s-1)
snuke_dijk = dijkstra(snuke_cost,t-1)
#
# print(s,t)
# print(jpy_dijk)
# print(snuke_dijk)
# print([jpy_dijk[i]+snuke_dijk[i] for i in range(n)])

#ord n
res = []
min_val = MAX_VAL
for i in reversed(range(n)):
    #都市  i で両替
    val = jpy_dijk[i]+ snuke_dijk[i]
    assert val < MAX_VAL
    min_val=min(min_val,val)
    res.append(min_val)
#ord n
for x in reversed(res):
    print(10**15-  x)


### FIXED CODE ###

from collections import defaultdict
from heapq import heapify, heappop
import heapq
n,m,s,t =list(map(int,input().split()))

MAX_VAL = 10**20
uvab =  [list(map(int,input().split())) for _ in range(m)]
jpy_cost = defaultdict(dict)
snuke_cost = defaultdict(dict)


for u,v,a,b in uvab:
    u=u-1
    v=v-1
    jpy_cost[u][v] = a
    jpy_cost[v][u] =a
    snuke_cost[u][v]=b
    snuke_cost[v][u]=b


# Dijktra's shortest path algorithm. Prints the path from source to target.


def dijkstra(adj, source):
    INF = MAX_VAL
    dist = [INF for x in range(n)]
    dist[source] = 0
    PQ = []
    heapq.heappush(PQ, [dist[source], source])

    while (PQ):
        u_dist,u_id = heapq.heappop(PQ)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(PQ, [dist[v], v])
    return dist


jpy_dijk =  dijkstra(jpy_cost,s-1)
snuke_dijk = dijkstra(snuke_cost,t-1)
#
# print(s,t)
# print(jpy_dijk)
# print(snuke_dijk)
# print([jpy_dijk[i]+snuke_dijk[i] for i in range(n)])

#ord n
res = []
min_val = MAX_VAL
for i in reversed(range(n)):
    #都市  i で両替
    val = jpy_dijk[i]+ snuke_dijk[i]
    assert val < MAX_VAL
    min_val=min(min_val,val)
    res.append(min_val)
#ord n
for x in reversed(res):
    print(10**15-  x)
### BUGGY CODE ###

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

reverse = False

for i in range(Q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    if query[0] == '2':
        if query[1] == '1':
            if not reverse:
                S = query[2] + S
            else:
                S = S + query[2]
        if query[1] == '2':
            if not reverse:
                S = S + query[2]
            else:
                S = query[2] + S

if not reverse:
    print(S)
else:
    print(S[::-1])


### FIXED CODE ###

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

front = ''
back = S
reverse = False

for i in range(Q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    if query[0] == '2':
        if query[1] == '1':
            if not reverse:
                front = front + query[2]
            else:
                back = back + query[2]
        if query[1] == '2':
            if not reverse:
                back = back + query[2]
            else:
                front = front + query[2]

if not reverse:
    print(front[::-1] + back)
else:
    print(back[::-1] + front)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
note = dict()
ans = 0
for i in range(n):
    s = "".join(sorted(input()))
    if s in note.keys():
        ans += note[s]
        note[s] += 1
    else:
        note[s] = 1

print(ans)

### FIXED CODE ###

import sys
#input = sys.stdin.readline

n = int(input())
note = dict()
ans = 0
for i in range(n):
    s = "".join(sorted(sys.stdin.readline()))
    if s in note.keys():
        ans += note[s]
        note[s] += 1
    else:
        note[s] = 1

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

n = int(input())
A = [int(i) for i in input().split()]
B = []

for i in range(n):
    B.append(A[i])
    B.reverse()

C = [str(i) for i in B]   
print(' '.join(C))


### FIXED CODE ###

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

even = [A[i] for i in range(n) if i % 2 == 0]

odd = [A[i] for i in range(n) if i % 2 != 0]


if n % 2 == 0:
    odd.reverse()
    c = odd+even
else:
    even.reverse()
    c = even+odd
    
print(' '.join([str(i) for i in c]))
### BUGGY CODE ###

n = int(input())
answer_list = []
for x in range(1, 99, 1):
    for y in range(1, 99, 1):
        for z in range(1, 99, 1):
            formula = (x+y+z)**2 - (x*y + y*z + z*x)
            if formula <= n:
                answer_list.append(formula)
            else:
                break
for i in range(1, n+1, 1):
    print(answer_list.count(i))

### FIXED CODE ###

import math

n = int(input())
answer_lists = [0 for i in range(10001)]
for x in range(1, int(math.sqrt(n+1)), 1):
    for y in range(1, int(math.sqrt(n+1)), 1):
        for z in range(1, int(math.sqrt(n+1)), 1):
            formula = (x+y+z)**2 - (x*y + y*z + z*x)
            if formula <= n:
                answer_lists[formula] += 1
            else:
                break
for i in range(1, n+1, 1):
    print(answer_lists[i])
### BUGGY CODE ###

s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[(0,'') for j in range(ns+1)] for i in range(nt+1)] # dp[i][j] = max len and string using up to t[i],s[j]

for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=(dp[i-1][j-1][0]+1,dp[i-1][j-1][1]+t[i-1])
        else:
            a,b=dp[i-1][j],dp[i][j-1]
            c=max(a[0],b[0])
            if c==a[0]:
                dp[i][j]=a
            else:
                dp[i][j]=b

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

### FIXED CODE ###

#n,W=map(int, input().split())
s=input()
t=input()
ns=len(s)
nt=len(t)
dp=[[0 for j in range(ns+1)] for i in range(nt+1)]
    
for i in range(1,nt+1):
    for j in range(1,ns+1):
        if t[i-1]==s[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

cnt=dp[-1][-1]
ans=[]
ct,cs=nt,ns
while cnt>0:
    while dp[ct][cs]==dp[ct-1][cs] and ct>0:
        ct-=1
        
    while dp[ct][cs]==dp[ct][cs-1] and cs>0:
        cs-=1

    ans.append(t[ct-1])
    cnt-=1
    #print(ct,cs,t[ct-1])
    ct-=1
    cs-=1

print(''.join(ans[::-1]))
### BUGGY CODE ###

N,M=map(int,input().split(" "))
#Nはポーンの数 Mは入力の数
A=list(map(int,input().split(" ")))
A=sorted(A)
L=[A[s]-A[s+1] for s in range(M-1)]

if M<=N:
    print(0)
else:
    for s in range(N-1):
        L.remove(min(L))
    print(abs(sum(L)))

### FIXED CODE ###

N,M=map(int,input().split(" "))
A=list(sorted(map(int,input().split(" "))))
L=[A[s]-A[s+1] for s in range(M-1)]
if M>N:
    print(abs(sum(sorted(L)[N-1:])))
else:
    print(0)
### BUGGY CODE ###

k = int(input())
a = [int(i) for i in input().split()]
m = sum([i-1 for i in a])
l = []
for n in range(max(a), m+3):
    c = n
    for i in a:
        c -= c % i
    if c == 2: l.append(n)
    if c > 2: break
if len(l) == 0: print(-1)
else: print(l[0], l[-1])

### FIXED CODE ###

from math import floor, ceil
k = int(input())
a = [int(i) for i in input().split()]
l,r = 2,2
for ai in a[::-1]:
    xi = ceil(l/ai)
    yi = floor(r/ai)
    if xi > yi:
        print(-1)
        exit()
    l = xi * ai
    r = yi * ai + ai - 1
print(l, r)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
a = 0
b = []
for i in range(n-k+1):
    if a < sum(p[ i : i + k ]):
        a = sum(p[ i : i + k ])
        b = p[ i : i + k ]
        
x = 0
for i in b:
    for j in range(i+1):
        x += j/i
print(x)
    

### FIXED CODE ###

from itertools import accumulate
n, k = map(int, input().split())
P= list(map(int, input().split()))
e = [(1+p) / 2 for p in P]
ps =[0] + list(accumulate(e))
a = 0
for i in range(n+1- k):
    if a < ps[i+k] - ps[i]:
        a = ps[i+k] - ps[i]

print(a)
### BUGGY CODE ###

import sys
N=int(input())
A=list(map(int, input().split()))
for i in range(N):
  sys.stdout.write(str(A.index(i+1)+1))
  sys.stdout.write(" ")

### FIXED CODE ###

N=int(input())
As=list(map(int, input().split()))
man = [""] * N
for i in range(N):
  man[As[i]-1] = str(i+1)
result = ' '.join(man)
print(result)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
d=[0]*n
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    d[i]=1
for j in range(q):
  sm=0
  d2=d[l[j][0]-1:l[j][1]-1]
  print(sum(d2))


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
d=[0]*(n+1)
for i in range(1,n):
  if s[i]=="C" and s[i-1]=="A":
    d[i]=d[i-1]+1
  else:
    d[i]=d[i-1]

for j in range(q):
  l,r=map(int,input().split())
  print(d[r-1]-d[l-1])
### BUGGY CODE ###

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

divider = 10**9+7

ans = 0
for shift in range(0, 60+1):
    one_num = 0
    for a in A:
        one_num += (a>>shift) & 1
    ans += (2**shift)*one_num*(N-one_num)
print(ans%divider)


### FIXED CODE ###

import numpy as np

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

divider = 10**9+7

ans = 0
for shift in range(0, 60):
    one_num = np.count_nonzero(A & 1)
    ans += (2**shift)*one_num*(N-one_num)
    A >>= 1
print(ans%divider)
### BUGGY CODE ###

from itertools import permutations

N,M,R = map(int,input().split())
rseq = list(map(int,input().split()))
graph = [[-1]*N for x in range(N)]

for i in range(M):
    A,B,C = map(int,input().split())
    A,B = A-1,B-1
    graph[A][B] = graph[B][A] = C

#FloydWarshall
for k in range(N):
    for i in range(N):
        for j in range(N):
            if graph[i][k] == -1 or graph[k][j] == -1:
                continue
            new_dist = graph[i][k] + graph[k][j]
            if graph[i][j] == -1 or graph[i][j] > new_dist:
                graph[i][j] = new_dist

minimum = 200000000
for p in permutations(rseq):
    total = 0
    for i in range(1,R):
        total += graph[p[i]-1][p[i-1]-1]
        if total > minimum:
            break
    if total < minimum:
        minimum = total
print(minimum)


### FIXED CODE ###

from itertools import permutations
 
 
def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                # dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
                new_dist = dp[i][k] + dp[k][j]
                if dp[i][j] > new_dist:
                    dp[i][j] = new_dist
 
 
def main():
    N, M, R = [int(x) for x in input().split()]
    destinations = [int(x) for x in input().split()]
    dp = [[float('inf')]*(N+1) for _ in range(N+1)]
    for i in range(N+1):
        dp[i][i] = 0
    for _ in range(M):
        f, t, d = [int(x) for x in input().split()]
        dp[f][t] = dp[t][f] = d
 
    warshallFloyd(N+1, dp)
 
    minimum_cost = float('inf')
    for route in permutations(destinations, len(destinations)):
        cost = 0
        while len(route) > 1:
            f, t = route[0], route[1]
            cost += dp[f][t]
            if cost > minimum_cost:
                break
            route = route[1:]
        if cost < minimum_cost:
            minimum_cost = cost
    print(minimum_cost)
 
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import itertools
num = int(input())
num_list = [int(item) for item in input()]

res_list = itertools.combinations(num_list,3)

print(len((set(res_list))))

### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    N = int(input())
    S = input()

    cnt = 0
    for i in range(1000):
        words = '{:0>3}'.format(i)
        k = 0
        for item in S:
            if item == words[k]:
                # print(item, words[k])
                k += 1

            if k == 3:
                cnt +=1
                break

    print(cnt)



if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

N,x = map(int,input().split())
a = list(map(int,input().split()))
i = 0
answer = 0
if a[0] > x:
  answer = a[0] - x
  a[0] = x
while i < N-1:
    if a[i] + a[i+1] > x:
        answer = answer + a[i] + a[i+1] - x
        a[i+1] = x - a[i]
        i = i+1
print(answer)


### FIXED CODE ###

N,x = map(int,input().split())
a = list(map(int,input().split()))
i = 0
answer = 0
if a[0] > x:
  answer = a[0] - x
  a[0] = x
for i in range(N-1):
    if a[i] + a[i+1] > x:
        answer += a[i] + a[i+1] - x
        a[i+1] = x - a[i]
print(answer)
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    mod = 998244353
    dp = [0] * (n + 1)
    dp[1] = 1
    delta = []
    for _ in range(k):
        l, r = map(int, input().split())
        for i in range(l, r + 1):
            delta.append(i)
    delta.sort()
    for i in range(n):
        for d in delta:
            if i + d > n:
                break
            dp[i + d] += dp[i]
            dp[i + d] %= mod
    print(dp[n])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    mod = 998244353
    dp = [0] * (n + 1)
    dp[1] = 1
    dp[2] = -1
    left = [0] * k
    right = [0] * k
    for i in range(k):
        left[i], right[i] = map(int, input().split())
        right[i] += 1
    for i in range(1, n + 1):
        dp[i] += dp[i - 1]
        for j in range(k):
            if i + left[j] <= n:
                dp[i + left[j]] += dp[i]
            if i + right[j] <= n:
                dp[i + right[j]] -= dp[i]
        dp[i] %= mod
    print(dp[n])


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

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

P = 1

for i in range(N):
    P = P * A[i]
    
if P <= 1e18:
    print(P)
else:
    print(-1)


### FIXED CODE ###

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

P = 1
flag = 0

for i in range(N):
    P = P * newA[i]
    if P == 0:
        print(P)
        flag = 1
        break
    elif P > 1e18:
        print(-1)
        flag = 1
        break
        
if flag == 0:
    print(P)
### BUGGY CODE ###

def main():
    n =int(input())
    al = list(map(int,input().split()))

    res = 0
    bits = [[0]*2 for _ in range(60)]
    for a in al:
        for i in range(60):
            bits[i][int(bin(a >> i)[-1])] += 1

    res = 0

    for i in range(60):
        res += bits[i][0] * bits[i][1]  * (2 ** i)

    print(res % (10 ** 9 + 7))

if __name__ == "__main__":
    main()

### FIXED CODE ###


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

res = 0
bits = [0]*60
for a in al:
    i = 0
    b = a
    while b:
        bits[i] += b&1
        b = b >> 1
        i += 1

res = 0

for j in range(60):
    res += bits[j] * (n - bits[j])  * (2 ** j)

print(res % (10 ** 9 + 7))
### BUGGY CODE ###

N = int(input())
lst = [int(input()) for _ in range(N)]
for n in range(N):
    print(max(lst[0:n] + lst[n+1:]))

### FIXED CODE ###

N = int(input())
lst = [int(input()) for _ in range(N)]
sort_lst =sorted(lst, reverse=True)
for x in range(N):
    if sort_lst[0] == lst[x]:
        print(sort_lst[1])
    else:
        print(sort_lst[0])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
read = sys.stdin.read

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

def main():
  n, m, s, t = map(int, input().split())
  U, V, A, B = np.array(read().split(), dtype=np.int64).reshape(m, 4).T
  csr_yen = csr_matrix((A, (U, V)), shape=(n+1, n+1))
  csr_snuuk = csr_matrix((B, (U, V)), shape=(n+1, n+1))
  G_yen = dijkstra(csr_yen, directed=False, indices=s)
  G_snuuk = dijkstra(csr_snuuk, directed=False, indices=t)
  L = []
  U = 10**15
  now = U
  for i in range(n, 0, -1):
    now = min(now, int(G_yen[i]+G_snuuk[i]))
    L.append(U-now)
  print(*L[::-1], sep="\n")
  
if __name__ == "__main__":
  main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
import heapq

def dijkstra(n, start, edge):
    dist = [float("inf")]*n
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, v = heapq.heappop(que)
        if dist[v] < d:
            continue
        for nv, nd in edge[v]:
            if dist[nv] > d + nd:
                dist[nv] = d + nd
                heapq.heappush(que, (dist[nv], nv))
    return dist
    
n, m, s, t = map(int, input().split())
G_yen = [[] for _ in range(n+1)]
G_snuuk = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    G_yen[u].append((v, a))
    G_yen[v].append((u, a))
    G_snuuk[u].append((v, b))
    G_snuuk[v].append((u, b))
dijk_yen = dijkstra(n+1, s, G_yen)
dijk_snuuk = dijkstra(n+1, t, G_snuuk)
L = []
U = 10**15
now = U
for i in range(n, 0, -1):
    now = min(now, dijk_yen[i]+dijk_snuuk[i])
    L.append(U-now)
print(*L[::-1], sep="\n")
### BUGGY CODE ###

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

for i in range(N):
  if A[i] not in already:
    already.append(A[i])
  else:
    print('NO')
    break
else:
  print('YES')

### FIXED CODE ###

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

for i in range(N-1):
  if A[i] != A[i+1]:
    pass
  else:
    print('NO')
    break
else:
  print('YES')
### BUGGY CODE ###

def main():
    N = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))

    solve(N, As, Bs)

def test():
    import random
    for _ in range(10000):
        As = [random.randint(0, 10) for _ in range(10)]
        Bs = [random.randint(0, 10) for _ in range(10)]
        try:
            solve(10, As, Bs)
        except:
            print(10)
            print(*As)
            print(*Bs)
            solve(10, As, Bs)


def solve(N, As, Bs):
    from collections import Counter
    As_counter = Counter(As)
    Bs_counter = Counter(Bs)

    A_indices = dict()
    for i, A in enumerate(As):
        if A in A_indices:
            A_indices[A].append(i)
        else:
            A_indices[A] = [i]
    B_indices = dict()
    for i, B in enumerate(Bs):
        if B in B_indices:
            B_indices[B].append(i)
        else:
            B_indices[B] = [i]

    B_count = sorted(Bs_counter.items(), key=lambda t: t[1], reverse=True)

    if max((As_counter + Bs_counter).values()) > N:
        print("No")
    else:
        print("Yes")
        filling_order = []
        for elem, count in B_count[N//2:] + B_count[:N//2]:
            if elem in A_indices:
                filling_order += A_indices[elem]

        delset = set(filling_order)
        filling_order += list(set(range(N)) - delset)

        index = 0
        ans = [0] * N
        for elem, _ in B_count:
            count = Bs_counter[elem]
            for i in range(index, index + count):
                ans[filling_order[i]] = elem
            index += count

        import random
        while True:
            for i, (a, b) in enumerate(zip(ans, As)):
                if a == b:
                    t = random.randint(0, N)
                    ans[i], ans[i-t] = ans[i-t], ans[i]
                    break
            else:
                break

        print(*ans)

main()

### FIXED CODE ###

# Rotationによる解。
from collections import Counter

N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

elem_max_count = max((Counter(As) + Counter(Bs)).values())
if elem_max_count > N:
    print("No")
    exit()

# Bs[-index:] > As[:index] を満たすようなindexを二分探索
# 参考: https://twitter.com/catupper/status/1305163805802917889?s=20

ok = 0
ng = N + 1
while ng - ok > 1:
    mid = (ok + ng) // 2
    isok = True
    for b, a in zip(Bs[-mid:], As[:mid]):
        if b <= a:
            isok = False
            break
    
    if isok:
        ok = mid
    else:
        ng = mid

print("Yes")
print(*(Bs[-ok:] + Bs[:-ok]))