peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
s = input()
for i in s:
  if i == '9':
    print('Yes')
    exit()
print('No')
# Judge status: Wrong Answer
import sys
input=sys.stdin.readline
from bisect import bisect_right, bisect_left
n=int(input())
a = [list(map(int, input().split())) for _ in range(3)]
a[0].sort()
a[2].sort()



cnt=0
for i in range(n):
    index_1 = bisect_right(a[0],a[1][i])
    index_2 = n-bisect_left(a[2],a[1][i])
    cnt+=index_1*index_2
print(cnt)
# Judge status: Wrong Answer
N = int(input())
ans = ((N//1000)+1)*1000-N
print(ans)
# Judge status: Wrong Answer
x = int(input())
n = x//11
k = x%11
if k<=6:
    print(2*n+1)
else:
    print(2*n+2)
# Judge status: Wrong Answer
o = input()
e = input()
lis = []
for i in range(min(len(o),len(e))):
    lis.append(o[i])
    lis.append(e[i])
if len(o)>len(e):
    lis.append(o[-1])
elif len(o)==len(e):
    lis.append(o[-1])
    lis.append(e[-1])

print(''.join(lis))
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
for i, b in enumerate(B):
	count += min(A[i], b)
	b -= A[i]
	if b > 0:
		x = min(A[i + 1], b)
		A[i + 1] -= x
		count += x
print(count)
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n):
    k = i + 1
    for j in range(i + 1, n):
        while k + 1 < n and l[k + 1] < l[i] + l[j]:
            k += 1
        cnt += k - j
print(cnt)
# Judge status: Accepted
n = int(input())
lst = [int(input()) for _ in range(n)]

lst2 = sorted(lst)
saidai = max(lst2)

for i in range(n):
    if lst[i] != saidai:
        print(lst2[-1])
    else:
        print(lst2[-2])
# Judge status: Accepted
n=int(input())
A=[]
for i in range(n):
    a=int(input())
    A.append(a-1)
t = 0
r = 0
while True:
    t = A[t]
    r += 1
    if t == 1:
        print(r)
        break
    if r == n:
        print(-1)
        break
# Judge status: Accepted
c = input()
l = ["a","e","i","o","u"]
if c in l:
  print("vowel")
else:
  print("consonant")
# Judge status: Accepted
w,a,c=map(int,input().split())

b=w+a
d=w+c

if a>c:
  if a>d:
    print(abs(d-a))
  else:
    print('0')

else:
  if c>b:
    print(abs(c-b))
  else:
    print('0')
# Judge status: Wrong Answer
n = int(input())
ans = 0
for a in range(1, n):
  ans += (n - 1) 
print(ans)
# Judge status: Accepted
def resolve():
    a, b = map(int, input().split())
    input_data = [int(_) for _ in input().split()]
    input_data.sort(reverse=True)
    sum_data = sum(input_data)
    converge = sum_data * (1 / (4 * b))

    if(converge > input_data[b - 1]):
        print("No")
    else:
        print("Yes")
resolve()
# Judge status: Accepted
n, m = map(int, input().split(" "))
a = map(int, input().split(" "))

z = n - sum(a)

print(z if z >=0 else -1)
# Judge status: Accepted
# 解説を読んだ。
n = int(input())
maximum_x = int(n ** (0.5))

move = 0


def gen():
    for x in range(1, maximum_x + 1):
        if n % x == 0:
            yield x + int(n/x) - 2


print(min(gen()))
# Judge status: Accepted
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A).most_common()
CC = sorted(C,key=lambda x: -x[0])
AA = 0
BB = 0
for cc in CC:
    if AA == 0 and cc[1] >= 4:
        AA = cc[0]
        BB = cc[0]
        break
    if AA == 0 and cc[1] >= 2:
        AA = cc[0]
        continue
    if BB == 0 and cc[1] >= 2:
        BB = cc[0]
        break
print(AA*BB)
# Judge status: Accepted
N = input().strip()
k = len(N)
a = int(N[0])
if k==1:
    cmax = a
else:
    cnt = 0
    for i in range(k):
        cnt += int(N[i])
    cmax = max((a-1)+9*(k-1),cnt)
print(cmax)
# Judge status: Accepted
k,x = list(map(int, input().split()))
print("Yes" if 500*k - x >= 0 else "No")
# Judge status: Wrong Answer
import sys
stdin = sys.stdin
from itertools import accumulate

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
h = na()
f = h[0]
b = False
for hi in h[1:]:
    if hi > f:
        f = hi
        b = False
    elif hi == f - 1 and not b:
        f = hi
        b = True
    elif hi == f:
        b = True
    else:
        print("No")
        quit()
print("Yes")
# Judge status: Wrong Answer
w, a, b = map(int, input().split())
if a <= b and b <= a+w:
    print(0)
elif b <= a+w and a <= b:
    print(0)
elif b + w < a:
    print(min(abs(a-b-w), abs(b-a-w)))
# Judge status: Accepted
A, B, C, K = map(int, input().split())
if K <= A:
    print(K)
elif K <= A+B:
    print(A)
else:
    print(A-(K-A-B))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

a.sort()

side1=0
side2=0
num=0

for num in range(n-1):
    if a[num]==a[num+1]:
        side2=side1
        side1=a[num]
        a[num+1]=0

print(side1*side2)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
if (abs(a-b)<=b and abs(b-c)<=b) or abs(a-c)<=b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
ans = 0
chk = 0
for i in range(n):
  a = int(input())
  p = chk+a
  ans += p//2
  if a > 0:
    chk = p%2
  else:
    chk = 0
print(ans)
# Judge status: Accepted
import sys
import math
from decimal import Decimal

def main():
    a, b, c = [int(_) for _ in input().split()]

    a_sq = Decimal(a).sqrt()
    b_sq = Decimal(b).sqrt()
    c_sq = Decimal(c).sqrt()

    if a_sq + b_sq < c_sq:
        print("Yes")
    else:
        print("No")
main()
# Judge status: Accepted
n,m = map(int, input().split())
a = [input() for _ in range(n)]

for _ in range(m):
  b = input()
  for i in a:
    if i.find(b) >= 0: break
    print("No")
    exit()
    
print("Yes")
# Judge status: Wrong Answer
D = int(input())

e = 25 - D

print('Chiristmas',end = ' ')
for i in range(e):
    print('Eve', end=' ')
# Judge status: Wrong Answer
n=int(input())
a=int(input())
if a==0:
    if n%500==0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")
# Judge status: Accepted
#DP-C

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

dp=[[0]*3 for i in range(n)]
dp[0]=l[0]
#print(dp)

for i in range(1,n):
    for j in range(3):
        for k in range(3):
            #同じ活動の場合を除く
            if j!=k:
                dp[i][j]=max(dp[i-1][k]+l[i][j],dp[i][j])
print(max(dp[-1]))
# Judge status: Accepted
a,b,x=map(int,input().split())
if a<=x<=a+b:print("YES")
else:print("NO")
# Judge status: Accepted
A,B,K=map(int, input().split())
if B-A+1-2*K<1:
  for i in range(A,B+1):
    print(i)
else:
  for i in range(K):
    print(A+i)
  for i in range(K):
    print(B-K+i+1)
# Judge status: Accepted
from sys import stdin
A, B = [int(x) for x in stdin.readline().rstrip().split()]
if A<=8 and B<=8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
#CODE FESTIVAL 2017 qual A
"""
やるか・やらないかだけで、結果的にできるものは同じ。順序に関係はない。
縦・横にいくつ使うかを全探索で求まった。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m,k = map(int,readline().split())

for i in range(n+1):
    for j in range(m+1):
        dup = i*j*2
        res = i*m + j*n - dup
        if k == res:
            print("Yes")
            exit()

print("No")
# Judge status: Accepted
N, A, B = list(map(int, input().split()))

ret = 0
for n in range(1, N+1):
  tmp_n = n
  tmp_cond = 0
  while tmp_n > 0:
    tmp_cond += tmp_n % 10
    tmp_n //= 10
  if A <= tmp_cond <= B:
    ret += n

print(ret)
# Judge status: Accepted
x,y,z=(map(int,input().split()))
if(y<x):
    x,y=y,x
if(z>=x and z<=y):
    print("Yes")
else:
    print('No')
# Judge status: Accepted
s = int(input())
L = [s]
cnt = 2
while True:
    if s%2 == 0:
        s = s/2
        if s in L:
            print(cnt)
            break
        else:
            L.append(s)
            cnt += 1
    else:
        s = 3*s+1
        if s in L:
            print(cnt)
            break
        else:
            L.append(s)
            cnt += 1
# Judge status: Accepted
from decimal import Decimal
a, b, c = (Decimal(x).sqrt() for x in map(int, input().split()))
print('Yes' if a+b < c else 'No')
# Judge status: Wrong Answer
n = int(input())
s = []
for i in range(n):
    s += [int(input())]

if sum(s) % 10 != 0:
    print(sum(s))
    f = 0
else:
    a = []
    for i in range(n):
        if s[i] % 10 != 0:
            a += [s[i]]
        if (sum(s) - sum(a)) % 10 != 0:
            print(sum(s) - sum(a))
            f = 0
            exit()
        else:
            f = 1
if f:
    print(0)
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())

ans = min(n, k) * x
n -= min(n, k)

ans += n * y

print(ans)
# Judge status: Accepted
x = int(input())

ans = (x // 11) * 2
if 0 < x % 11 < 7:
    ans += 1
elif 6 < x % 11:
    ans += 2

print(ans)
# Judge status: Accepted
N = input()

if N[0]!='7' and N[1] != '7' and N[2] != '7' :
    print('No')

else :
    print('Yes')
# Judge status: Wrong Answer
s=input()
a=753
ans=999
for i in range(len(s)-2):
  n=int(s[i:i+3])
  print(n)
  tmp=abs(a-n)
  if tmp<ans:
    ans=tmp
print(ans)
# Judge status: Accepted
n = int(input())
S = [input() for _ in range(n)]
ans = 0
c = {}

for s in S:
    s = "".join(sorted(s))
    if s not in c.keys():
        c[s] = 1
    else:
        ans += c[s]
        c[s] += 1


print(ans)
# Judge status: Wrong Answer
w,a,b=map(int,input().split())
if len(sorted(set(range(a,a+w+1)) | set(range(b,b+w+1)))) ==0:
  print("0")
elif b>=a+w:
  print(b-a-w)
elif a>=b+w:
  print(a-b-w)
# Judge status: Accepted
from collections import deque

s = deque(str(input()))
q = int(input())

t = 0
for i in range(q):
    o = list(map(str, input().split()))
    if o[0] == "1":
        t += 1
    else:
        if o[1] == "1" and t%2 == 0 or o[1] == "2" and t%2 == 1:
            s.appendleft(o[2])
        else:
            s.append(o[2])

if t%2 == 1:
    s.reverse()

print("".join(s))
# Judge status: Accepted
n = input()
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import copy
n,k,*A = map(int,open(0).read().split())
for _ in range(min(50,k)):
    B = [0] * (n+1)
    for i,d in enumerate(A):
        start = max(0,i-d)
        B[start] += 1
        end = min(n,i+d+1)
        B[end] -= 1
    light = 0 
    for i,b in enumerate(B[:n]):
        light += b
        A[i] = light

print(*A)
# Judge status: Accepted
s=input()
n=int(input())
front=""
back=s
reverse=False

for i in range(n):
  t=input().split()
  if t[0]=="1":
    reverse=not reverse
  else:
    if (t[1]=="1")^reverse:
      front=front+t[2]
    else:
      back=back+t[2]
if reverse:
  print(back[::-1]+front)
else:
  print(front[::-1]+back)
# Judge status: Wrong Answer
x = int(input())
for i in range(100000):
    if(100*i <= x and 105*i >= x):
        print(1)
else:
    print(0)
# Judge status: Accepted
n = int(input())
answer = 0
while answer < n:
    answer += 111
print(answer)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,c,k=map(int,input().split())
    ans=0
    person=0
    wait=-10**9
    T=[int(input())for _ in range(n)]
    T.sort()
    for i in range(n):
        if T[i]-wait<=k and person+1<=c:
            person+=1
        else:
            ans+=1
            person=1
            wait=T[i]
    print(ans)

if __name__=='__main__':
    main()
# Judge status: Wrong Answer
import math
N, D = map(int, input().split(' '))
X_ls = []
cnt = 0
 
for i in range(N):
    X_ls.append(list(map(int, input().split(' '))))
 
for i in range(N - 1):
    for j in range(i+1, N):
        dist_squared, dist = 0, 0
        print(i,j)
        for y, z in zip(X_ls[i], X_ls[j]):
            dist_squared += (y - z) ** 2
        dist = math.sqrt(dist_squared)
        if dist - math.floor(dist) == 0:
            cnt += 1
print(cnt)
# Judge status: Accepted
a = int(input())
b = input()
print('red' if a < 3200 else b)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = map(int, input().split())

check = n - sum(list(a))
if check > 0:
    print(check)
else:
    print(-1)
# Judge status: Accepted
import numpy as np
from itertools import combinations

N, D = map(int, input().split())
X = [np.array(input().split(), dtype=np.int64) for _ in range(N)]

ans = 0
for x, y in combinations(X, 2):
  d = pow((x-y), 2).sum()
  if (d**0.5).is_integer():
    ans += 1
print(ans)
# Judge status: Wrong Answer
x=input("alphabet:")
if x=="z":
    print("")
if x!="z":
    print(chr(ord(x)+1))
# Judge status: Accepted
sx,sy, tx,ty = map(int, raw_input().split())
def f(sx,sy,tx,ty):
	path = ['D']
	path += ['R'] * (abs(tx - sx) + 1)
	path += ['U'] * (abs(ty - sy) + 1)
	path += ['L'] * (abs(tx - sx) + 1)
	path += ['D'] * (abs(ty - sy))
	return path

	
def g(sx,sy,tx,ty):
	path = []
	path += ['R'] * (abs(tx - sx))
	path += ['U'] * (abs(ty - sy) + 1)
	path += ['L'] * (abs(tx - sx)+1)
	path += ['D'] * (abs(ty - sy)+1) 
	return path + ['R']


print ''.join(f(sx,sy, tx,ty) + g(sx,sy,tx,ty))
# Judge status: Wrong Answer
n = [int(i) for i in list(input())]
l = len(n)

ans =  (n[0]-1) + 9*(l-1)
print(ans)
# Judge status: Accepted
s = list(map(int, input().split()))
a = s.index(0) + 1
print(a)
# Judge status: Accepted
N, A, B = (int(x) for x in input().split())
Ans = [i if A <= sum(int(x) for x in list(str(i))) <= B else 0 for i in range(1,N+1)]
print(sum(Ans))
# Judge status: Accepted
s = input()
t = input()

s = s + s
if t in s:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
(X,Y,*e),*l=[list(map(int,input().split())) for _ in [0]*4]
s=sorted
P,Q,R=map(s,l)
print(sum(s(P[-X:]+Q[-Y:]+R)[-X-Y:]))
# Judge status: Wrong Answer
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))

a1 = list()
a2 = list()
a3 = list()
for i in range(3):
    a1.append(y1_list[i] - y2_list[i])
    a2.append(y2_list[i] - y3_list[i])
    
if a1[0] == a1[1] and a1[2] == a1[0]:
    if a2[0] == a1[1] and a2[2] == a1[0]:
        print("Yes")
        
    else:
        print("No")
else:
    print("no")
# Judge status: Wrong Answer
A=2
B=5

print(A*B)
# Judge status: Accepted
a, b = input().split()
n = int(a + b)
ans = "Yes" if n == int(n ** 0.5) ** 2 else "No"
print(ans)
# Judge status: Accepted
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
	print(x)
	exit(0)
if x in p:
	a,b = 0,0
	for i in range(1,102):
		if x - i in p:
			continue
		else:
			a = x - i
			break
	for j in range(1,102):
		if x + j in p:
			continue
		else:
			b = x + j
			break
	if a < 0:
		print(b)
	elif b > 101:
		print(a)
	elif abs(x-a) <= abs(x-b):
		print(a)
	else:
		print(b)
else:
	print(x)
# Judge status: Wrong Answer
A,B,C,K = map(int,input().split())
print(A,B,C,K)
res = 0
if A>=K:
  res= 1*A
else:
  for b in range(K-A,B+1):
    c = K-A-b
    if c >= 0:
      ans = 1*A + 0*b + (-1)*c
      res = max(res,ans)
    else:
      break
print(res)
# Judge status: Accepted
a, b = map(int, input().split())
if a > 0:
    print('Positive')
elif a <= 0 and b >= 0:
    print('Zero')
else:
    if (b-a)%2 == 0:
        print('Negative')
    else:
        print('Positive')
# Judge status: Accepted
N, K = map(int, input().split())
m = N % K
if m > 0:
    _m = abs(m - K)
    if _m < m:
        m = _m
print(m)
# Judge status: Wrong Answer
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,A,B = LI()

num = N//(A+B)
print(num*A + N-(num*(A+B)))
# Judge status: Accepted
n = int(input())
S = list(input())
ans = 0

for i in range(1,n-1):
  L = S[:i]
  R = S[i:]
  UL = set(L)
  UR = set(R)
  ans = max(ans, len(UL & UR))

print(ans)
# Judge status: Wrong Answer
import bisect

n = int(input())
alist = [int(input()) for _ in range(n)]

l = [alist[0],]
if n > 1:
  for a in alist[1:]:
    if l[-1] < a:
      l[-1] = a
    else:
      if l[0] >= a:
        l = [a] + l
      else:
        pos = bisect.bisect_right(l, a)
        l[pos-1] = a
print(len(l))
# Judge status: Accepted
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, D = map(int, input().split())
    if N < (D * 2 + 1):
        ans = 1
    else:
        q, r = divmod(N, D * 2 + 1)
        ans = q + 1 if r > 0 else q
    print(ans)


if __name__ == '__main__':
    solve()
# Judge status: Wrong Answer
H , A = map(int, input().split())
ans = 0
while(H >= 0):
  H = H - A
  ans + 1
print(ans)
# Judge status: Accepted
S = input()
T = input()

n = 0

for a in range(len(S)) :

    if not S[a] == T[a] :
        n += 1

print(n)
# Judge status: Accepted
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
elif H%2==1 and W%2==1:
    print((H*W)//2+1)
else:
    print((H*W)//2)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

if A[0]:
    if N==0 and A[0]==1:
        print(1)
    else:
        print(-1)
    exit()

B=[0 for _ in range(N)]

B.append(A[-1])
for i in range(N)[::-1]:
    B[i]=B[i+1]+A[i]

r=1
ans=1
for i in range(1,N+1):
    t=min(r*2,B[i])
    ans+=t
    r=t-A[i]
    if r<0:
        print(-1)
        exit()

print(ans)
# Judge status: Wrong Answer
# -*- coding: <encoding name> -*-

n = int(input())
l = list(map(int, input().split()))
s = sum(l)
print('Yes' if (n - 1) > s else 'No')
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x = int(input())
    if x == 0:
        print(1)
    else:
        print(0)

if __name__=='__main__':
    main()
# Judge status: Wrong Answer
s = input()
print('A' + s[0] + 'B')
# Judge status: Wrong Answer
def main():
    s=sorted(input())
    print("Yes" if s[0]==s[1] and s[2]==s[3] else "No")
    
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
S = input();
str = 'keyence';
ans = 'NO'
if S[0:7] == str :
    ans = 'YES';
elif S[-7:0] == str :
    ans = 'YES';
else :
    for i in range(1,8) :
        if S[0:i] == str[0:i] and S[-7+i:0] == str[-7+i:0] :
            ans = 'YES';
            break;

print(ans);
# Judge status: Wrong Answer
n = int(input())

ans = 1

for i in range(n):
    ans *= i+1
    ans = ans%10000007
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

stk = []
ret = 0

for item in a:
    if not stk:
        stk.append(item)
        if len(stk) > ret:
            ret = len(stk)
    else:
        while stk and stk[-1] < item:
            stk.pop()
        stk.append(item)
        if len(stk) > ret:
            ret = len(stk)

print(ret)
# Judge status: Wrong Answer
x,y = map(int,input().split())
ax = abs(x)
ay = abs(y)
if ax == ay and x != y:
    a = 1
elif x > y and 0 <= y:
    a = ax - ay + 1
elif x > y and 0 > y:
    if ay > ax and x >= 0:
        a = ay - ax + 1
    elif ay > ax and x < 0:
        a = ay - ax + 2
    elif ax > ay:
        a = ax - ay + 1
elif y > x and x < 0 and ay > ax:
    a = ay - ax + 1
elif y > x and x < 0 and y > 0 and ax > ay:
    a = ax - ay + 1
else:
    a = y-x
print(a)
# Judge status: Accepted
import itertools

n, m, q = map(int, input().split())  # x = 1, y = 2
abcd = list(list(map(int, input().split())) for _ in range(q))

# print(n, m, q, abcd)

combis = list(itertools.combinations_with_replacement(range(1, m + 1), n))
# print(combis)
max_sum = 0
for patt in combis:
    sumv = 0
    for abc in abcd:
        [a, b, c, d] = abc
        if c == (patt[b - 1] - patt[a - 1]):
            sumv += d
    if max_sum < sumv:
        max_sum = sumv

print(max_sum)
# Judge status: Wrong Answer
S = input()
T = input()

reg = [None]*26
reg_flag = [0]*26

for i in range(len(S)):
    index = ord(S[i])-97
    if reg_flag[index] == 0:
        reg[index] = T[i]
        reg_flag[index] = 1

        index_T = ord(T[i])-97
        if reg_flag[index_T] == 0:
            reg[index_T] = S[i]
            reg_flag[index_T] = 1

    if reg[index] == T[i]:
        pass
    else:
        print('No')
        exit()

print('Yes')
# Judge status: Accepted
import fractions

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

print(a*b//fractions.gcd(a, b))
# Judge status: Accepted
x = int(input())
y = 0
k = 0
while True:
    y += x
    k += 1
    if y % 360 == 0:
        break
print(k)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))
P = round(sum(X)/N)
ans = sum(list(map(lambda x: (x-P)**2, X)))
print(ans)
# Judge status: Wrong Answer
X, Y, A, B, C = map(int, input().split())
p = sorted(map(int, input().split()), reverse=True)[: X]
q = sorted(map(int, input().split()), reverse=True)[: Y]
r = list(map(int, input().split()))

all = p + q + r
all.sort(reverse=True)
print((all[:X + Y]))
# Judge status: Accepted
s=list(input())
n=len(s)
p=[]
q=[]
cnt_p=0
cnt_q=0

if n%2!=0:
  m=(n-1)//2
  p.extend(['0','1']*m)
  p.append('0')
  q.extend(['1','0']*m)
  q.append('1')
else:
  m=n//2
  p.extend(['0','1']*m)
  q.extend(['1','0']*m)
for i in range(n):
  if s[i]==p[i]:
    cnt_p+=1
  else:
    cnt_q+=1
print(min(cnt_p,cnt_q))
# Judge status: Wrong Answer
N=list(map(int,list(input())))

L=[0,1,2,3,4,5,5,4,3,2]

ans=0
mi=0
m=0
j=0
a=0
for i in N:
  ans+=L[i]
  if i>=6:
    if j==1:
      m+=1
    else:
      j=1
      m=0
  else:
    if j==1:
      mi+=m
      if m!=0:
        a+=1
    j=0
  
  
print(ans-2*mi-a)
# Judge status: Accepted
y, m, d = map(int, input().split("/"))
if y <= 2018:
    print("Heisei")
elif y == 2019 and m <= 4:
    print("Heisei")
else:
    print("TBD")
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
num_of_t = n // (a + b)
if num_of_t == 0:
    if a >= n:
        print(n)
    else:
        print(a)
    exit()
print(a * num_of_t + n - num_of_t * (a + b))
# Judge status: Accepted
N,A,B = map(int, input().split(" "))
distance = abs(B - A)
res=0
if distance % 2 == 0:
  res = distance//2
else:
  res = distance//2 + min(min(A,B)-1, N-max(A,B))+1
print(res)
# Judge status: Wrong Answer
INT_MAX=10**18+7
x=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
GETA=123
###############################################################################
import math as M
n,k=INPUT()
print(M.ceil(M.log(n,k)))
# Judge status: Accepted
from itertools import permutations
from math import sqrt,factorial
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

def distance(point1, point2):
    return sqrt((point1[0]-point2[0])**2 + (point1[1]-point2[1])**2)

ans = 0
per = permutations(xy, n)
persize = factorial(n)
cost = 0
for i in per:
    cpoint = i[0]
    for j in i[1:]:
        cost += distance(cpoint, j)
        cpoint = j
ans = cost/persize
print(ans)
# Judge status: Accepted
n,k = map(int,input().split())
x = [int(i) for i in input().split()]
a = [abs(i) for i in x]
ans = float("inf")

for i in range(n-k+1):
    if x[i] * x[i+k-1] < 0:
        t = min(a[i],a[i+k-1])*2 + max(a[i],a[i+k-1])
    else:
        t = max(a[i],a[i+k-1])
    ans = min(t, ans)

print(ans)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int, input().split()))

mon=1000
kabu=0

for i in range(N-1):
    if A[i] < A[i+1]:
        kabu = mon//A[i]
        mon = mon - (kabu*A[i])
    else:
        mon += kabu*A[i]
        kabu = 0
    #print(mon)
    #print(kabu)
    #print("----")

mon += kabu*A[N-1]

print(mon)
# Judge status: Wrong Answer
X = input()
Sn = 0
Tn = 0
for ch in X:
    if ch == "S":
        Sn += 1
    if ch == "T":
        if Sn > 0:
            Sn -= 1
        else:
            Tn += 0
print(Sn + Tn)
# Judge status: Accepted
n, m = map(int, input().split())
h = list(map(int, input().split()))
gon = [1]*n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1]==h[b-1]:
        gon[a-1], gon[b-1] = 0, 0
    else:
        low = a if h[a-1]<h[b-1] else b
        gon[low-1] = 0
        
print(gon.count(1))
# Judge status: Wrong Answer
A, B, C = map(int,input().split())
if A == B == C:
  print("No")
elif A != B != C:
  print("No")
else:
  print("Yes")