Harryxun/stf_run huggingface dataset:
d,g=map(int,input().split())
pc={_:(list(map(int,input().split()))) for _ in range(d)}
bin_lst=[]
d2=d**2-1
buf_lst=[]
lst_cnt=[]
for x in range(d2):
    buf=bin(x)[2:]
    len_buf=len(buf)
    if len_buf<d:
        buf='0'*(d-len_buf)+buf
    bin_lst.append(buf)
for x in bin_lst:
    cnt=0
    buf_int=0
    for y in range(d):
        if x[y]=="1":
            buf_lst=pc[y]
            buf_int+=(y+1)*100*buf_lst[0]+buf_lst[1]
            cnt+=buf_lst[0]
    if buf_int<g:
        buf_index=x.rfind("0")
        buf_lst=pc[buf_index]
        i=buf_lst[0]
        for z in range(1,i):
            if buf_int+(buf_index+1)*100*z>=g:
                buf_int+=(buf_index+1)*100*z
                cnt+=z
                break
    if buf_int>=g:
        lst_cnt.append(cnt)
print(min(lst_cnt))

### FIXED CODE ###

d,g=map(int,input().split())
pc={_:(list(map(int,input().split()))) for _ in range(d)}
bin_lst=[]
d2=2**d
for x in range(d2):
    buf=bin(x)[2:]
    len_buf=len(buf)
    if len_buf<d:
        buf='0'*(d-len_buf)+buf
    bin_lst.append(buf)
lst_cnt=[]
buf_lst=[]
for x in bin_lst:
    cnt=0
    buf_int=0
    len_x=len(x)
    for y in range(d):
        if x[y]=="1":
            buf_lst=pc[y]
            buf_int+=(y+1)*100*buf_lst[0]+buf_lst[1]
            cnt+=buf_lst[0]
    if buf_int<g:
        buf_index=x.rfind("0")
        buf_lst=pc[buf_index]
        i=buf_lst[0]
        for z in range(1,i):
            if buf_int+(buf_index+1)*100*z>=g:
                buf_int+=(buf_index+1)*100*z
                cnt+=z
                break
    if buf_int>=g:
        lst_cnt.append(cnt)
print(min(lst_cnt))
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
top, bottom = 0, M-1

if len(A) == 1:
    for _ in range(M):
        A[0] //= 2
else:
    for _ in range(M):
        A[top] //= 2
        print(top, bottom)
        if A[top] >= A[bottom]:
            bottom -= 1
            continue
        else:
            top += 1
print(sum(A))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
heap = [-i for i in list(map(int, input().split()))]
heapq.heapify(heap)
for i in range(M):
    heapq.heappush(heap, -(-heapq.heappop(heap)//2))
print(-sum(heap))
N,K,X,Y=int(input())
if N>=K+1:
  print(int(K＊X+(N-K)＊Y))
else:
  print(int(N＊X))

### FIXED CODE ###

n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n>k:
  print(k * x + (n - k) * y)
else:
  print(n * x)
one = []
ten = []

menu = [int(input()) for i in range(5)]

for i in range(5):
    one.append(menu[i] % 10)
    ten.append(menu[i] // 10)

for i in range(5):
    if one[i] == 0:
        one[i] = 10000000

one_min = min(one)

for i in range(5):
    if one[i] == 10000000:
        one[i] = 0

for i in range(5):
    if one_min == one[i]:
        one_min_idx = i

total = 0

for i in range(5):
    if one_min_idx != i:
        if one[i] == 0:
            total += ten[i] * 10
        else:
            total += ten[i] * 10 + 10

total += menu[one_min_idx]

print(total)


### FIXED CODE ###

one = []

menu = [int(input()) for i in range(5)]

for i in range(5):
    one.append(10 - menu[i] % 10)

for i in range(5):
    if one[i] == 10:
        one[i] = 0

total = 0
cnt = 0
for i in range(5):
    if cnt == 0 and one[i] == max(one):
        total += menu[i]
        cnt = 1
    else:
        total += menu[i]
        total += one[i]

print(total)
#!/usr/bin/env python3

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

print(max(a) - min(a))

### FIXED CODE ###

#!/usr/bin/env python3

r, g, b = map(int, input().split())
num = (100 * r) + (10 * g) + (1 * b)

if num % 4 == 0:
    print("YES")
else:
    print("NO")
L,R = map(int,input().split())
L_mod = L % 2019
A = 2019 - L_mod
if A <= R-L:
  print(0)
else:
  ans = 2018
  for i in range(R-L+1):
    for j in range(i+1,R-L+1):
      temp = (L_mod + i) * (L_mod + j) % 2019
      if temp <= ans:
        ans = temp
print(ans)
  

### FIXED CODE ###

L,R = map(int,input().split())
L_mod = L % 2019
A = 2019 - L_mod
if A <= R-L:
  print(0)
else:
  ans = 2018
  for i in range(R-L+1):
    for j in range(i+1,R-L+1):
      temp = (L_mod + i) * (L_mod + j) % 2019
      if temp <= ans:
        ans = temp
  print(ans)
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/

import math
import statistics

n,d = map(int, input().split())
print((n + d * 2) // (d * 2 + 1)

### FIXED CODE ###

# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/

import math
import statistics

n,d = map(int, input().split())
print((n + d * 2) // (d * 2 + 1))
a=list(input())
b=list(input())
c=list(input())
next=a[0]
del a[0]
while True:
    if len(a)==0 and next=="a":
        print("A")
        break
    if len(b)==0 and next=="b":
        print("B")
        break
    if len(c)==0 and next=="c":
        print("C")
        break
    if next=="a":
        next=a[0]
        del a[0]
    if next=="b":
        next=b[0]
        del b[0]
    if next=="c":
        next=c[0]
        del c[0]


### FIXED CODE ###

sa=list(input())
sb=list(input())
sc=list(input())
owner="a"
while True:
    if owner=="a":
        if len(sa):
            owner=sa[0]
            del sa[0]
        else:
            break
    elif owner=="b":
        if len(sb):
            owner=sb[0]
            del sb[0]
        else:
            break
    else:
        if len(sc):
            owner=sc[0]
            del sc[0]
        else:
            break
if owner=="a":
    print("A")
elif owner=="b":
    print("B")
else:
    print("C")
import math
ans=0
N = int(input())
A = [int(i) for i in input().split()] 
B=A
L=[1]*N
R=[1]*N
L[0]=1
L[1]=A[0]
R[N-1]=1
R[N-2]=A[N-1]
for i in range(2,N):
    L[i]=math.gcd(L[i-1],A[i-1])
    R[N-i-1]=math.gcd(R[N-i],A[N-i])
for i in range(N):
    c=math.gcd(L[i],R[i])
    if c>ans:
        ans=c
print(ans)
    

### FIXED CODE ###

from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
left,right = [a[0]]+[0]*(n-1),[0]*(n-1)+[a[n-1]]
arr = [0]*n
for i in range(0,n-1):
  left[i+1] = gcd(left[i],a[i+1])
  right[n-2-i] = gcd(right[n-1-i],a[n-2-i])
arr[0] = right[1]
arr[n-1] = left[n-2]
for i in range(1,n-1):
  arr[i] = gcd(left[i-1],right[i+1])
print(max(arr))
h, w = map(int, input().split())
grid = ['#' * (h + 2)]
for _ in range(h):
    grid.append('#' + input() + '#')
grid.append('#' * (h+2))
def right(cnt, i, j):
    if grid[i][j + 1] == '.':
        cnt = right(cnt+1, i, j + 1)
    return cnt
        
def left(cnt, i, j):
    if grid[i][j - 1] == '.':
        cnt = left(cnt + 1, i, j - 1)
    return cnt
        
def up(cnt, i, j):
    if grid[i + 1][j] == '.':
        cnt = up(cnt + 1, i + 1, j)
    return cnt

def down(cnt, i, j):
    if grid[i - 1][j] == '.':
        cnt = down(cnt + 1, i - 1, j)
    return cnt

cnt = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == '.':
            tmp = 1
            tmp = right(tmp, i, j)
            tmp = left(tmp, i, j)
            tmp = up(tmp, i, j)
            tmp = down(tmp, i, j)
            cnt = max(cnt, tmp)
print(cnt)



### FIXED CODE ###

h, w = map(int, input().split())
grid = ['#' * (h + 2)]
for _ in range(h):
    grid.append('#' + input() + '#')
grid.append('#' * (h + 2))
lgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
rgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
dgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
ugrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == '#':
            lgrid[i][j] = 0
            ugrid[i][j] = 0
        else:
            lgrid[i][j] = lgrid[i][j-1] + 1
            ugrid[i][j] = ugrid[i-1][j] + 1
        if grid[i][w+1-j] == '#':
            rgrid[i][w+1-j] = 0
        else:
            rgrid[i][w+1-j] = rgrid[i][w+2-j] + 1
        if grid[h+1-i][j] == '#':
            dgrid[h+1-i][j] = 0
        else:
            dgrid[h+1-i][j] = dgrid[h+2-i][j] + 1        
cnt = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        tmp = lgrid[i][j]+rgrid[i][j]+ugrid[i][j]+dgrid[i][j] - 3
        cnt = max(cnt, tmp)
print(cnt)
while True:
    x = int(input())
    if x == 0:
        break
    print(sum(int(i) for i in x))



### FIXED CODE ###

while True:
  x = sum(map(int, input()))

  if x == 0:
    break

  print(x)
n = input()
low = list(map(int, input().split()))
for i in range(n)
	count = 0
	tmp = low[i]
	while tmp % 2 == 0:
		tmp = tmp % 2 
		count = count + 1
        
print(count)

### FIXED CODE ###

n=int(input())
#print(n)
low = list(map(int,input().split()))
#print("INPUT = ")
#print(low)
count = 0
for i in range(n):
	tmp = int(low[i])
	while tmp % 2 == 0 and tmp !=0:
		tmp = tmp// 2
		count = count + 1
#		print("COUNT=", count, "TMP=",tmp)
#print("ANS = ")
print(count)
from itertools import combinations as comb
def get_ans(m, n):
    ans = sum(1 for nums in comb(range(1, min(m+1,n-2)), 2) if n-sum(nums)>0 and n-sum(nums) not in nums))
    return ans
      
while True:
    m, n = (int(x) for x in input().split())
    if m==0 and n==0:
        quit()
    ans = get_ans(m, n)
    print(ans)


### FIXED CODE ###

from itertools import combinations as comb
def get_ans(m, n):
    ans = sum(1 for nums in comb(range(1, min(m+1,n-2)), 2) if ((n-sum(nums)>0) and (n-sum(nums) > max(nums)) and (n-sum(nums)<=m)))
    return ans
      
while True:
    m, n = (int(x) for x in input().split())
    if m==0 and n==0:
        quit()
    ans = get_ans(m, n)
    print(ans)
# coding: utf-8
import sys
sys.setrecursionlimit(1000000)
N,M,K=map(int,input().split())
MOD=998244353


#a**n mod p を再帰的に求める
def modPow(a,n,p):
    if n == 1:
        #n=1ならaを返す
        return a % p

    elif n % 2 == 1:
        #nが奇数ならば a * modPow(a,n-1(偶数),p)を返す
        return a * modPow(a,n-1,p) % p

    else:
        #nが偶数なら modPow(a,n//2,p) * modPow(a,n//2,p)とすると速い
        t = modPow(a,n//2,p)
        return t * t % p

fac=[None for i in range(N)]
finv=[None for i in range(N)]
inv=[None for i in range(N)]

def COMinit(num):
    global fac
    global finv
    global inv
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1

    for i in range(2,num):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def COM(n,k):
    if n<k:
        return 0
    elif n<0 or k<0:
        return 0
    else:
        return int(fac[n] * (finv[k] * finv[n - k] % MOD) % MOD)


COMinit(N)

ans=0

for i in range(K+1):
    ans+=COM(N-1,N-1-K+i)*M*modPow(M-1,N-1-K+i,MOD)
    ans=ans%MOD
print(ans)

### FIXED CODE ###

# coding: utf-8
import sys
sys.setrecursionlimit(1000000)
N,M,K=map(int,input().split())
MOD=998244353

MAX_N=N+10

#a**n mod p を再帰的に求める
def modPow(a,n,p):
    if n==0:
        return 1
    if n == 1:
        #n=1ならaを返す
        return a % p

    elif n % 2 == 1:
        #nが奇数ならば a * modPow(a,n-1(偶数),p)を返す
        return a * modPow(a,n-1,p) % p

    else:
        #nが偶数なら modPow(a,n//2,p) * modPow(a,n//2,p)とすると速い
        t = modPow(a,n//2,p)
        return t * t % p

fac=[None for i in range(MAX_N)]
finv=[None for i in range(MAX_N)]
inv=[None for i in range(MAX_N)]

def COMinit(num):
    global fac
    global finv
    global inv
    fac[0]=1
    fac[1]=1
    finv[0]=1
    finv[1]=1
    inv[1]=1

    for i in range(2,num):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def COM(n,k):
    if n<k:
        return 0
    elif n<0 or k<0:
        return 0
    else:
        return int(fac[n] * (finv[k] * finv[n - k] % MOD) % MOD)


COMinit(MAX_N)

ans=0

for i in range(K+1):
    v=COM(N-1,N-1-K+i)%MOD
    v*=M
    v=v%MOD
    v*=modPow(M-1,N-1-K+i,MOD)
    v=v%MOD
    ans+=v
    ans=ans%MOD
print(ans)
a = int(input())
b = (input())

print(6 - (a+b))

### FIXED CODE ###

a = int(input())
b = int(input())

print(6 - (a+b))
S = input()
hug = 0
if len(S) % 2 == 0:
  for i in range(len(S/2)):
    if not S[i] == S[-i-1]:
      hug += 1
    else:
      pass
else:
  for i in range(len((S+1)/2)):
    if not S[i] ==S[-i-1]:
      hug += 1
    else:
      pass
print(hug)
  

### FIXED CODE ###

S = input()
hug = 0
if len(S) % 2 == 0:
  for i in range(int(len(S)/2)):
    if not S[i] == S[-i-1]:
      hug += 1
    else:
      pass
else:
  for i in range(int((len(S)+1)/2)):
    if not S[i] ==S[-i-1]:
      hug += 1
    else:
      pass
print(hug)
import sys

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()
ans=cmb(N,3)
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (L[i]+L[j])<=L[k]:
                ans-=(N-k)
                break


print(int(ans))

### FIXED CODE ###

from operator import mul
from functools import reduce
import bisect

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()
ans=cmb(N,3)
ans2=0
for i in reversed(range(2,N)):
    for j in reversed(range(1,i)):
        a=bisect.bisect_right(L,L[i]-L[j])
#        print('{0}:{1}'.format(a,j))
#        print(a)
        if(a<j):
            ans2+=(j-a)
    

print(ans2)
n=int(input())
sum=0
while (n != 0):
  sum = sum + n % 10; 
  n = n/10; 
if(sum%9==0):
  print("Yes")
else:
  print("No)    
     
    

### FIXED CODE ###

n=str(input())
sum=0
for i in range(len(n)):
    sum+=int(n[i]); 
if(sum%9==0):
  print("Yes")
else:
  print("No")
n = int(input())
d = list(map(int,input().split()))
p = 0
q = 0
m = 0
a = 0
d.sort()
if (len(d))%2 == 0:
  m = int(((d[(len(d)//2)-1])+(d[len(d)//2]))/2)
else:
  m = int(d[(len(d)//2)])
for i in range(len(d)):
  if int(d[i])>=m:
    if int(d[i]) == int(d[i+1]):
      break
    else:
      p = int(d[i])
      q = int(d[i-1])
      break
  else:
    a = 0
print(p-q)


### FIXED CODE ###

n = int(input())
d = sorted(list(map(int,input().split())))
print(d[n//2]-d[n//2-1])
st = input().strip().split()

mul = int(st[0])

b = 0
for x in st[1]:
  if x == '.':
  else: b = b*10 + x

print(a*b//100)

### FIXED CODE ###

st = input().strip().split()
 
a = int(st[0])
b = 0
d = 0
 
for x in st[1]:
  if x == '.':
    d = 1
  else:
    b = b*10 + int(x)
    d = d*10

print(a*b//d)
from collections import defaultdict
def generate_primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def main():  
    n = int(input())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    primes = generate_primes(max(A))
    for a in A:
        for p in primes:
            if a < p: break
            if a % p == 0:
                d[p] += 1
    d[1] = 0
    m = max(d.values())
    if m == n:
        print('not coprime')
    elif m >= 2:
        print('setwise coprime')
    else:
        print('pairwise coprime')
    

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    d, t, s = map(int, input().split())  
    print('Yes' if s * t >= d else 'No')

if __name__ == '__main__':
    main()
li = list(str(input()))
for i in len(li):
  if(li[i] == "B" and not i == 0):
    li[i-1] = ""
    li[i] = ""
print("".join(li))

### FIXED CODE ###

li = list(input())
ans = ""
for i in li:
  if i == "0":
    ans = ans + "0"
  elif i == "1":
    ans = ans + "1"
  elif i == "B":
    ans = ans[:len(ans)-1]
print(ans)
x1,y1,x2,y2 = map(int,input().split())
print(((x1-x2)**2+(y1-y2)**2)**0.5)


### FIXED CODE ###

x1,y1,x2,y2 = map(float,input().split())
print(((x1-x2)**2+(y1-y2)**2)**0.5)
input()
nums = map(int,input().split())

if 0 in nums:
    print(0)
    exit 0

result=1
for i in nums:
    result *= i

if result > (10**18):
    print(-1)
else:
    print(result)

### FIXED CODE ###

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

if nums.count(0):
    print(0)
    exit(0)

result=1
for i in nums:
    result *= i
    if result > (10**18):
        print(-1)
        exit(0)
print(result)
pre = None
for i in list(input()):
	if i == pre:
      	print("Bad")
        exit()
    pre = i
print("Good")

### FIXED CODE ###

pre = 0
for i in list(input()):
    if i == pre:
        print("Bad")
        exit()
    pre = i
print("Good")
N = int(input())
l = list(map(int,input().split()))
for n in range(N-2,0,-1):
  if l[n] > l[n+1]:
    l[n] -= 1
  if l[n] > l[n+1]:
    print('No')
    sys.exit()
print('Yes')

### FIXED CODE ###

import sys
N = int(input())
l = list(map(int,input().split()))
for n in range(N-2,0,-1):
  if l[n] > l[n+1]:
    l[n] -= 1
  if l[n] > l[n+1]:
    print('No')
    sys.exit()
print('Yes')
import numpy as np
N, M, C= map(int, input().split())
B = []
B.append(list(map(int, input().split())))
arrB = np.array(B)
#A = np.array()
#for i in range(N):
#    A[i] = input()


#a = list()
#for i in range(M):
#    a.append(map(int, input().split()))

#a = list(a)

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

arrA = np.array(A)

D = np.empty((0,M), int)
for i in range(N):
    D = np.append(D, arrB*arrA[i], axis=0)
#    C.append(arrB*arrA[i])


F = np.empty((0,N), int)
for i in range(N):
    F = np.append(F, np.sum(D[i]))

E = F + C
t=0
for i in range(N):
    if E[i]>0:
        t = t+1
    else:
        t =t



#print(arrB)
#print(arrA)
#print(D)
#print(E)
#print(F)
print(t)


### FIXED CODE ###

H, W= map(int, input().split())
h, w= map(int, input().split())

A = h * W
B = H * w

a = H * W - (A + B - h * w)
print(a)
from collections import deque

H, W = map(int, input().split())
grid = [list(input()) for i in range(H)]

# 初期が黒('#')の位置からの距離
dist = [[-1]*H for _ in range(W)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

d = 0
while len(black_cells) > 0:
    # キューとして使うのでpop()ではなくpopleft()
    h, w = black_cells.popleft()  # 黒いセルの座標
    d = dist[h][w]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_h = h + dy
        new_w = w + dx
        if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
            continue
        if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
            dist[new_h][new_w] = d+1
            black_cells.append((new_h, new_w))

print(d)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [list(input()) for i in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append([h, w, 0])

ans = 0
while len(black_cells) > 0:
    one_black_cell = black_cells.popleft()  # キューとして使うのでpop()ではなくpopleft()
    for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
        nh = one_black_cell[0] + dy
        nw = one_black_cell[1] + dx
        d = one_black_cell[2]
        if nh < 0 or H <= nh or nw < 0 or W <= nw:
            continue
        if grid[nh][nw] == '.':
            grid[nh][nw] = '#'
            black_cells.append([nh, nw, d + 1])
        ans = d

print(ans)
import collections
import sys

def solve(n, A, B):
  Ac = {}
  ABc = {}
  for a in A:
    Ac[a] = 1 + Ac.get(a, 0)
    ABc[a] = 1 + ABc.get(a, 0)
  Bc = {}
  for b in B:
    Bc[b]  = 1 + Bc.get(b, 0)
    ABc[b] = 1 + ABc.get(b, 0)
  cAB = sorted([(c, ab) for ab, c in ABc.items()])
  #print(cAB)
  pool = collections.deque()  #[bbbb]   # [(b, count)], FIFO to match at the end

  matched = {}  # {a: bbbb}    # {a: {b, count}
  current = n   # how many are not matched yet
  for c, ab in cAB[::-1]:
    if c > current + len(pool):
      print('No')
      return
    matched[ab] = []
    while c > current:
      # take c - current from pool, add to matched
      c -= 1
      matched[ab].append(pool.popleft())
    # add (ab, Bc[ab]) to pool
    current -= Bc[ab]
    for _ in range(Bc[ab]):
      pool.append(ab)
  #print(pool, matched)
  skipped = []
  for c, ab in cAB:
    # take c - matched[ab] from pool, add to matched
    nn = Ac[ab]-len(matched[ab])
    while skipped and  Ac[ab]-len(matched[ab]) > 0:
      matched[ab].append(skipped.pop())
    while Ac[ab]-len(matched[ab]) > 0:
      p = pool.popleft()
      if p == ab:
        skipped.append(p)
      else:
        matched[ab].append(p)
      #print(ab, pool, matched, skipped)

  ans = []
  for a, bb in sorted(matched.items()):
    ans += [str(b) for b in bb]
  print('Yes')
  print(' '.join(ans))


def main():
  input = sys.stdin.readline
  n = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  solve(n, A, B)

main()


### FIXED CODE ###

import collections
import sys

def solve(n, A, B):
  Ac = {}
  ABc = {}
  Bc = {}
  for a in A:
    Ac[a] = 1 + Ac.get(a, 0)
    ABc[a] = 1 + ABc.get(a, 0)
    Bc[a] = Bc.get(a, 0)
  for b in B:
    Ac[b] = Ac.get(b, 0)
    Bc[b]  = 1 + Bc.get(b, 0)
    ABc[b] = 1 + ABc.get(b, 0)
  cAB = sorted([(c, ab) for ab, c in ABc.items()])
  #print(cAB)
  pool = collections.deque()  #[bbbb]   # [(b, count)], FIFO to match at the end

  matched = {}  # {a: bbbb}    # {a: {b, count}
  current = n   # how many are not matched yet
  for c, ab in cAB[::-1]:
    if c > current + len(pool):
      print('No')
      return
    matched[ab] = []
    while c > current:
      # take c - current from pool, add to matched
      c -= 1
      matched[ab].append(pool.popleft())
    # add (ab, Bc[ab]) to pool
    current -= Bc[ab]
    for _ in range(Bc[ab]):
      pool.append(ab)
  #print(pool, matched)
  skipped = []
  for c, ab in cAB:
    # take c - matched[ab] from pool, add to matched
    nn = Ac[ab]-len(matched[ab])
    while skipped and  Ac[ab]-len(matched[ab]) > 0:
      matched[ab].append(skipped.pop())
    while Ac[ab]-len(matched[ab]) > 0:
      p = pool.popleft()
      if p == ab:
        skipped.append(p)
      else:
        matched[ab].append(p)
      #print(ab, pool, matched, skipped)

  ans = []
  for a, bb in sorted(matched.items()):
    ans += [str(b) for b in bb]
  print('Yes')
  print(' '.join(ans))


def main():
  input = sys.stdin.readline
  n = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  solve(n, A, B)

main()
n = input()
a = input().split( )

b = []
j = 0
k = 1

for i in range(int(n)):
    if k == int(a[i]):
	b.append(a[i])
	j += 1
	k += 1

if 0 == len(b):
    print(-1)
else:
    print(int(n)-len(b))

### FIXED CODE ###

n = int(input())
a = input().split( )

b = []
j = 0
k = 1

for i in range(n):
  if k == int(a[i]):
    b.append(int(a[i]))
    j += 1
    k += 1

if 0 == len(b):
  print(-1)
else:
  print(int(n)-len(b))
S=input()
print("Yes" if S[2] == S[3] and S[4]=S[5] else "No")


### FIXED CODE ###

S=input()
print("Yes" if S[2] == S[3] and S[4]==S[5] else "No")
input()
s=input.split()
a=[]
for i in s:
 a.append(int(i))
a.sort()
input()
s=input.split()
b=[]
for i in s:
 b.append(int(i))
b.sort()
while len(a)>0:
    if a[0]==b[0]:
        del(a[0])
        del(b[0])
        if len(b)==0:
            break
    elif a[0]<b[0]:
        del(a[0])
    else:
        a=[]
if len(b)==0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

lena=int(input())
s=input().split()
a=[]
for i in s:
 a.append(int(i))
a.sort()
lenb=int(input())
s=input().split()
b=[]
for i in s:
 b.append(int(i))
b.sort()
i=0
j=0
while i<lena:
    if a[i]==b[j]:
        i+=1
        j+=1
        if j==lenb:
            break
    elif a[i]<b[j]:
        i+=1
    else:
        break
if j==lenb:
    print("YES")
else:
    print("NO")
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(n)]
ans = 0

for i in set(s):
  num = s.count(i) - t.count(i)
  if num > ans :
    ans = num
    
    
print(ans)




### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
ans = 0

for i in set(s):
  num = s.count(i) - t.count(i)
  if num > ans :
    ans = num
    
    
print(ans)
print("ACL" * int(input())

### FIXED CODE ###

print("ACL" * int(input()))