peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N,X= map(int, input().split())
L=list(map(int, input().split()))
D, ans=0, 0
for i in range(N):
    if D<=X:
        ans+=1
        D+=L[i]
    else:
        break
if D<=X:
    ans+=1
print(ans)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
b = []
for i in A:
    print(A.count(i+1))
# Judge status: Accepted
A,B=map(int,input().split())

if A==1:
  A=14
if B==1:
  B=14
  
if A>B:
  print('Alice')
elif A==B:
  print('Draw')
else:
  print('Bob')
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
  n = n - a[i]
if n < 0:
  print(-1)
else:
  print(n)
# Judge status: Accepted
import math
def main():
    r = int(input())
    print(math.pi*r*2)

if __name__ == "__main__":
    main()
# Judge status: Accepted
print('YNEOS'[eval(input().replace(*' *'))!=175::2])
# Judge status: Wrong Answer
N,A,B,C,D = map(int,input().split())
S = input()

goal = max(C,D)
if '##' in S[A-1:goal]:
  print("No")
  exit()

ok = True
# 追い越す必要がある
if D < C:
  # 間に3マスあきがない or (.D.)でない
  if not ('...' in S[B-1:D]):
    print(S[B-1:D])
    ok = False

# 必要がない場合は問題ない

if ok:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n=int(input())

memo = 0

if n == 1 or n ==2:
    print(n)
    exit()


for i in range(1,n):
    memo += i
    if n <= memo:
        check = i
        break

ans = []

for i in range(check,0,-1):
    n -= i
    #print(i,n)
    ans.append(i)
    if n < i:
        ans.append(n)
        break
ans.sort()

for i in ans:
    print(i)
# Judge status: Accepted
A, B = list(map(int, input().split()))
count = 0
for i in range(A, B + 1):
    str_i = str(i)
    if str_i[0] == str_i[4] and str_i[1] == str_i[3]:
        count += 1
print(count)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    if N % 2 == 0:
        return A[0] + sum(A[1:N // 2]) * 2
    return A[0] + sum(A[1:N // 2]) * 2 + A[N // 2]


print(main())
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())

while a > 0:
  c = c - b
  if c <= 0:
    print('Yes')
    exit()
  a = a - d

print("no")
# Judge status: Accepted
k = int(input())
dic = dict()
cnt = 1
num1 = 7 % k
num2 = 70 % k
while True:
    if dic.get(num1):break
    if (num1) == 0:
        print(cnt)
        exit()
    
    dic[num1] = 1
    num1 = (num1 + num2) %k
    num2 = (num2 * 10) %k
    cnt += 1
    #print(num1, num2)
print(-1)
# Judge status: Accepted
n=int(input())
A=[[0]*2 for i in range(n)]
for i in range(n):
  A[i]=list(map(int,input().split()))
a=0
for i in range(n-1):
  for j in range(i+1,n):
    a=a+((A[i][0]-A[j][0])**2+(A[i][1]-A[j][1])**2)**(1/2)
print(a/n*2)
# Judge status: Accepted
a,b,c = map(int, input().split())
print(max(a,b,c) * 9 +a + b + c)
# Judge status: Accepted
N = int(input())
S = input()

s1 = S[0:N//2]
s2 = S[N//2:]

if s1 == s2:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

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

N, M = map(int, input().split())
broken = set(int(input()) for _ in range(M))

dp = [0] * (N + 1)
dp[0] = 1

for i in range(1, N + 1):
    if i not in broken:
        dp[i] = dp[i - 1] + (dp[i - 2] if i - 2 >= 0 else 0)
        dp[i] %= (10 ** 9 + 7)

print(dp[-1])
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
flag = 0
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      flag = 1
print("APPROVED") if flag == 0 else print("DENIED")
# Judge status: Wrong Answer
n = int(input())
a = [input() for i in range(n)]
ac = 0
wa = 0
tle = 0
re = 0
for s in a:
  if s=='AC':
    ac+=1
  if s=='WA':
    wa+=1
  if s=='TLE':
    tle+=1
  if s=='RE':
    re+=1
print(f'AC × {ac}')
print(f'WA × {wa}')
print(f'TLE × {tle}')
print(f'RE × {re}')
# Judge status: Wrong Answer
S=list(map(int,input().split()))
S1=str(S[0])
S2=str(S[1])
S3=S1*S[1]
S4=S2*S[0]
if S[0]<=S[1]:
    print(S3)
else:
    print(S4)
# Judge status: Accepted
N,W=map(int,input().split())
list1=[list(map(int,input().split())) for i in range(N)]

dp=[[0 for i in range(W+1)] for j in range(N+1)] # dpリストを作る。dpの要素の数字は価値を表す。

for i in range(N): # １つ１つの商品について
    for w in range(W+1):
        if w>=list1[i][0]:
            dp[i+1][w]=max(dp[i][w],dp[i][w-list1[i][0]]+list1[i][1])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[-1][-1])
# Judge status: Wrong Answer
def resolve():
    X = int(input())
    res = (X // 11) * 2
    rem = X % 11
    if 0 < rem and rem <= 6:
        res += 1
    else:
        res += 2
    print(res)

if '__main__' == __name__:
    resolve()
# Judge status: Accepted
N = int(input())

P = [int(i) for i in input().split(" ")]
count = 0
for i in range(1,N-1):
    p_0 = P[i-1]
    p_1 = P[i]
    p_2 = P[i+1]
    
    bool_1 = p_1>p_0 and p_1<p_2
    bool_2 = p_1<p_0 and p_1>p_2
    
    if bool_1 or bool_2:
        count+=1
print(count)
# Judge status: Wrong Answer
N,K=map(int,input().split())
p=list(map(int,input().split()))
P=sorted([(1+i)/2 for i in p])
count=0
for i in range(K):
  count+=P[-1-i]
  
print(count)
# Judge status: Accepted
x,y,z = map(int,input().split())

x -= z
r = x // (y + z)
print(r)
# Judge status: Accepted
#!python3

def LI():
    return list(map(int, input().split()))

# input
N, K = LI()
A = LI()


def main():
    n = 0
    x = 1
    visit = [None] * N
    while visit[x - 1] is None:
        if n == K:
            print(x)
            return
        visit[x - 1] = n
        n += 1
        x = A[x - 1]
    
    v = n - visit[x - 1]
    s = (K - n) % v
    ans = visit.index(visit[x - 1] + s) + 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
A,B,C,K=(int(x) for x in input().split())
if K<=A:print(K)
elif K<=A+B:print(A)
else: print(A-(K-B-A))
# Judge status: Wrong Answer
n=int(input())
a=[99,111,222,333,444,555,666,777,888,999]
for i in range(len(a)-2):
    if n==a[i]:
        print(n)
        break
    if a[i]<n<a[i+1]:
        print(a[i+1])
        break
# Judge status: Accepted
import re

_S = input().replace('?', '_')[::-1]
T = input()[::-1]

pattern = ''
for c in T:
    pattern += '[_' + c + ']'

match = re.search(pattern, _S)
if not match:
    print('UNRESTORABLE')
else:
    S = _S[:match.start()] + T + _S[match.end():]
    S = S.replace('_', 'a')
    print(S[::-1])
# Judge status: Wrong Answer
s=input()
slist=list(s)
a=slist.count('a')
b=slist.count('a')
c=slist.count('a')
if(max(a,b,c)>(len(s)//2)+1):
	print("NO")
else:
	print("YES")
# Judge status: Accepted
r,g,b = map(int, input().split())


if ((r*100) + (g*10) + b) % 4 == 0:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
import math

n = int(input())

dp = [10**18] * (n+1)
dp[0] = 0

for i in range(1, n+1):
    dp[i] = dp[i-1] + 1

for i in range(n-1):
    s = n-i
    for j in range(int(math.log(s, 9)+1)):
        dp[i+9**j] = min(dp[i+9**j], dp[i]+1)
    for k in range(int(math.log(s, 6)+1)):
        dp[i+6**k] = min(dp[i+6**k], dp[i]+1)

print(dp[-1])
# Judge status: Wrong Answer
s = input()

ans = float("inf")
for i in range(len(s)-2):
    num = int(s[i:i+3])
    if abs(754-num) < ans:
        ans = abs(754-num)

print(ans)
# Judge status: Wrong Answer
n,m = map(int, input().split())
fn = 1
ln = n
for i in range(m):
    l,r = map(int, input().split())
    fn = max(fn,l)
    ln = min(ln,r)    
print(ln-fn+1 if ln-fn>0 else 0)
# Judge status: Accepted
N,A,B,C,D=map(int, input().split())
S=input()
if S.find("##", A, B)<0 and S.find("##", C, D)<0:
    if C<D:
        print("Yes")
    else:
        if S.find("...", B-2, D+1)>=0:
            print("Yes")
        else:
            print("No")
else:
    print("No")
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())

1 <= a,b,c,d <= 100

if abs(a-b) <= d and abs(b-c) <= d:
    result = ("Yes")
else:
    result = ("No")

print(result)
# Judge status: Accepted
import math

H = int(input())
W = int(input())
N = int(input())

k = max([H,W])
ans = math.ceil(N/k)

print(ans)
# Judge status: Wrong Answer
s = int(input())
j= -1
for i in range(-s, s):
    if i**5-j**5 == s:
        if i == abs(j)+1 or j == abs(i)+1:
            print(i, j)
            j += 1
            break
# Judge status: Wrong Answer
import math

a,b,h,m = list(map(int,input().split()))
h = h % 12
theta = m*6 - h*30
arc = a** 2 + b**2 - 2*a*b*math.cos(math.radians(theta))
print(arc**0.5)
# Judge status: Wrong Answer
S=input()
boin=["a","b","c","d","e"]
if S in boin:
    print("vowel")
else:
    print("consonant")
# Judge status: Wrong Answer
n, m, x = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]
X = [x for i in range(m)]

ans = 10**10
for b in range(2**n):
  skils = [0]*m
  tmp = 0
  
  for i in range(n):
    if b&(1<<i):
      for j in range(m):
        skils[j] += li[i][j+1]
      tmp += li[i][0]

        
  if skils>=X:
    ans = min(ans, tmp)

    
if ans == 10**10:
  print(-1)
  exit()
print(ans)
# Judge status: Accepted
n=int(input())
num=[]
for i in range(n-1):
    num.append(list(map(int,input().split())))
for i in range(n-1):
    ans=0
    for j in range(i,n-1):
        if ans<=num[j][1]:
            ans=num[j][1]
        else:
            ans=num[j][1]+((-((ans-num[j][1])//-num[j][2]))*num[j][2])
        ans+=num[j][0]
    print(ans)
print(0)
# Judge status: Accepted
n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
ans=[]
cand=[xy[i][0]+xy[i][1] for i in range(n)]
#print(cand)
ans.append(max(cand)-min(cand))
cand=[-xy[i][0]+xy[i][1]for i in range(n)]
ans.append(max(cand)-min(cand))
cand=[-xy[i][0]-xy[i][1] for i in range(n)]
ans.append(max(cand)-min(cand))
cand=[xy[i][0]-xy[i][1] for i in range(n)]
ans.append(max(cand)-min(cand))
print(max(ans))
# Judge status: Accepted
k = (int)(input())
s=input()
if len(s)>k:
    print(s[:k]+'...')
else:
    print(s)
# Judge status: Accepted
N,W = map(int,input().split())
w_list = []
v_list = []
for _ in range(N):
    w,v = map(int,input().split())
    w_list.append(w)
    v_list.append(v)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(1,N+1):
    w = w_list[i-1]
    v = v_list[i-1]
    for j in range(1,W+1):
        if j-w >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)
        else:
            dp[i][j] = dp[i-1][j]
print(dp[N][W])
# Judge status: Accepted
l, r, d = map(int,input().split())

c = 0
for i in range(l, r+1):
    if i % d == 0:
        c += 1

print(c)
# Judge status: Wrong Answer
N = int(input())
A = input().split()

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

for j in range(0, N, 2):
  B.append(A[j])

print(" ".join(B))
# Judge status: Accepted
N = int(input())
V = list(map(int, input().split()))
V.sort()

ans = V[0]
for i in range(1, N):
    ans = (ans + V[i]) / 2.0

print(ans)
# Judge status: Accepted
import itertools
import copy
from collections import deque
import heapq
n = int(input())
ma = []
mi = []
for i in range(n):
    a,b = map(int,input().split())
    mi.append(a)
    ma.append(b)
mi.sort()
ma.sort()
if n % 2 == 1:
    ans = ma[(n+1)//2-1]-mi[(n+1)//2-1] + 1
else:
    ans = (ma[n//2]+ma[n//2-1]-mi[n//2]-mi[n//2-1])+1
print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
a = list(map(int,input().strip().split()))
if Counter(a).most_common(1)[0][1] != 1:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
from fractions import *
n,*a=map(int,open(0).read().split())
mod=10**9+7
b=a[0]
for i in a:
    b=b*i//gcd(b,i)
print(sum(b//i for i in a)%mod)
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline

res = list(map(int, input().split()))
if len(set(res)) == 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A, B, C, K = map(int, input().split())
a = min(K,A)
K-=a
b = min(K,B)
K-=b
c = K
print(a-c)
# Judge status: Accepted
n = int(input())
sum = 0

for i in range(1, n+1):
    if i%3 != 0 and i%5 != 0:
        sum += i

print(sum)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1

print(ans)
# Judge status: Wrong Answer
C = input('')
chr(ord(C) + 1)
# Judge status: Accepted
N,t = int(input()),1

while t*(t+1) < N*2:
	t += 1
for i in range(1,t+1):
	if t*(t+1)//2-i != N:
		print(i)
# Judge status: Accepted
alp=[chr(i) for i in range(97,123)]
n=int(input())

for i in range(1,12):
    if n>26**i:
        n-=26**i
    else:
        keta=i
        break
#その桁数の名前のなかでn番目
n-=1
lst=[]
#このnを26進数で表し、0~25にa~zをあてはめる
for i in range(keta):
    p,n=divmod(n,26**(keta-i-1))
    lst.append(alp[p])
    
print("".join(lst))
# Judge status: Wrong Answer
listA=[]

while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        

money = min(listA[1]) + min(listA[2]) 
wari = 100000
for k in range(listA[0][2]):
    a = listA[k+3][0]
    b = listA[k+3][1]
    if wari > listA[1][a-1] + listA[2][b-1] - listA[k+3][2]:
        wari = listA[1][a-1] + listA[2][b-1] - listA[k+3][2]

if money <= wari:
    print(money)
        
else:
    print(wari)
# Judge status: Wrong Answer
a, b, c = input().split()
print(max(int(a+b)+int(c), int(a)+int(b+c)))
# Judge status: Accepted
a,b,m = input().split()
a = int(a)
b = int(b)
m = int(m)

al = input().split()
bl = input().split()
ml = [list(map(int, input().split())) for i in range(m)]

al = list(map(int, al))
bl = list(map(int, bl))

als = sorted(al)
bls = sorted(bl)

tmp = als[0] + bls[0]

comp = 0
fp = tmp
for i in ml:
  comp = al[i[0]-1] + bl[i[1]-1] - i[2]
  if comp < fp:
    fp = comp

print(fp)
# Judge status: Accepted
n=int(input())
ans=0
for i in range(1,n+1):
    x,y=i,(n//i)*i
    ans+=((n//i)*(x+y)//2)
print(ans)
# Judge status: Wrong Answer
x,y = map(int, input().split())

for t in range(101):
    k = x-t
    if y==t*2+k*4:
        print("Yes")
        exit()
print("No")
# Judge status: Wrong Answer
import numpy as np
import itertools
import numba as njit


n,m,q = map(int, input().split())
l = [list(map(int,input().split())) for _ in range(q)]
a,b,c,d = zip(*l)

temp = np.arange(1,m+1)
A = list(itertools.product(temp, repeat=n))
ans=0

for i in range(len(A)):
  ans_temp = 0
  for j in range(q):
    if A[i][b[j]-1]-A[i][a[j]-1]==c[j]:
      ans_temp += d[j]
  ans=max(ans,ans_temp)
  
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
a = [int(x) for x in input().split()]

b = [x%4 for x in a]
from collections import Counter
bco = Counter(b)

if bco[0] >= N//2 :
    print("Yes")
else :
    fe = N//2 - bco[0]
    if N%2 == 0 :
        if bco[2] >= 2*fe :
            print("Yes")
        else :
            print("No")
    else :
        if bco[2] >= 2*fe + 1 :
            print("Yes")
        else :
            print("No")
# Judge status: Wrong Answer
import itertools
import functools
import math

def OK():
    N = int(input())

    sum = 0
    cnt = 0
    for i in range(1,N+1):
        for j in range(1,N+1):
            chk = math.gcd(i,j)
            for k in range(1,N+1):
                sum += math.gcd(chk,k)

    print(sum)

OK()
# Judge status: Wrong Answer
def main():
    N = int(input())
    num = 0
    for i in range(1, N + 1):
        if i % 2 == 1:
            count = 0
            for j in range(i, N + 1):
                if i // j == 0:
                    count += 1
            if count == 8:
                num += 1
    print(num)
main()
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
d={}
ans=0
for a in A:
    try:
        if d[a]<a:
            d[a]+=1
            ans-=1
        elif d[a]==a:
            ans+=1
    except KeyError:
        d[a]=1
        ans+=(a-1)
print(ans)
# Judge status: Accepted
N, K = list(map(int, input().split()))
print(min(abs(N - (K*(N//K+1))), abs(N - (K*(N//K)))))
# Judge status: Accepted
from sys import stdin

def main():
    N,M  = map(int,stdin.readline().split())
    if(N < M):
        res = str(N)
        print(res*M)
    else:
        res = str(M)
        print(res*N)
        
main()
# Judge status: Accepted
import sys, math
from pprint import pprint
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

def combmod(n, k):
	p, q = 1, 1
	for i in range(1, k+1):
		p = p * (n-i+1) % mod
		q = q * i % mod
	return p * pow(q, mod-2, mod) % mod

X, Y = rl()

if (X+Y) % 3 != 0:
	print(0)
	exit()
if not (1/2 <= Y/X <= 2):
	print(0)
	exit()
n = (X+Y)//3
k = X-n
print(combmod(n,k))
# Judge status: Accepted
N, K, S = map(int, input().split())
INF = 10**9

if K == 0:
    if S == INF:
        print(' '.join([str(INF-1) for _ in range(N)]))
    else:
        print(' '.join([str(INF) for _ in range(N)]))
    exit()

if S == INF:
    ans = [INF] * K
    ans.extend([INF-1] * (N-K))
else:
    ans = [S] * K
    ans.extend([INF] * (N-K))
print(' '.join([str(x) for x in ans]))
# Judge status: Accepted
L = int( input() )
ret = ( L / 3 ) ** 3
print( ret )
# Judge status: Accepted
p=998244353
n=int(input())
d=list(map(int,input().split()))
dep = [0]*n
for x in d:
  dep[x] += 1

ans = 1 if d[0]==0 and dep[0]==1 else 0
for i in range(1,n):
  ans *= (dep[i-1]%p) ** dep[i] % p
  ans %= p

print(ans)
# Judge status: Wrong Answer
A,B,K=map(int,input().split())
c=0
for i in range(1,abs(A-B)+1):
  if A%i==0 and B%i==0:
    c+=1
  if c==K:
    print(i)
    exit()
# Judge status: Accepted
S = input()
print(S.replace('2017','2018'))
# Judge status: Accepted
n, y = map(int, input().split())
y //= 1000
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - i - j
        if y == 10 * i + 5 * j + k:
            print(i, j, k)
            exit()
print(-1, -1, -1)
# Judge status: Wrong Answer
K = int(input())
Sub = input()

if len(Sub) <= K:
  print(Sub)
elif len(Sub) > K:
  print(Sub[0:K-1]+"...")
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
MOD = 998244353

nodes = [0] * N

for d in D:
  nodes[d] += 1

ans = 0
if nodes[0]==1 and D[0]==0:
  pre_n = 1
  ans = 1
  for n in nodes:
    ans = (ans * pre_n**n) % MOD
    pre_n = n

print(ans)
# Judge status: Accepted
s1 = str(input())
s2 = str(input())

if s1 == s2[::-1]:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
l = set(a)
dict = {}
for x in l:
    dict.update({x:0})
for b in a:
    dict[b] += 1
ans = 0
for i in dict:
    if dict[i] < i:
        ans += dict[i]
    else:
        ans += abs(dict[i]-i)
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
c = [0 for _ in range(n+1)]
for i in range(n):
  c[i] += 1
ans = n - sum(c)
for i in range(n):
  if c[i] > i:
    ans += c[i] - i
  else:
    ans += c[i]
print(ans)
# Judge status: Accepted
n = int(input())

if n % 2 == 0:
  print(n/2 /n)
else:
  print((n//2+1) /n)
# Judge status: Wrong Answer
import math
a, b, x = map(int, input().split())

atan0 = math.degrees(math.atan((a*b**2)/(2*x)))

print(atan0)
# Judge status: Accepted
n=int(input())
for i in range(100,1000):
    if i >= n and i%100//10 == i%10 == i//100:
        print(i)
        break
# Judge status: Accepted
X,A,B=map(int,input().split())
if A-B>=0:
    print("delicious")
elif -A+B<=X:
    print("safe")
else:
    print("dangerous")
# Judge status: Accepted
from collections import Counter
N = int(input())
blue_cards = Counter(input() for _ in range(N))
M = int(input())
red_cards = Counter(input() for _ in range(M))
ans = 0
for blue_word, blue_count in blue_cards.items():
    tmp_ans = blue_count
    if blue_word in red_cards.keys():
        tmp_ans -= red_cards[blue_word]
    if tmp_ans > ans:
        ans = tmp_ans
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
print((a+b-1)//b)
# Judge status: Wrong Answer
a, b, c = input().split()
print(a+b[0]+c)
# Judge status: Accepted
def main():
  x,y,a,b,c=map(int,input().split())
  ps=sorted(list(map(int,input().split())))
  qs=sorted(list(map(int,input().split())))
  rs=sorted(list(map(int,input().split())))
  points=sorted(ps[-x:]+qs[-y:])
  return sum(sorted(points+rs)[-x-y:])
print(main())
# Judge status: Accepted
s = list(input())
t = list(input())

len_s = len(s)
len_t = len(t)
count = 0
biggest = 0

for i in range(len_s-len_t+1):
  now = s[i:i+len_t]

  for j in range(len_t):
    if t[j] == now[j]:
      count += 1
      
  if biggest < count:
    biggest = count
    count = 0
  else:
    count = 0
    
print(len_t - biggest)
# Judge status: Wrong Answer
n=int(input())
if n//9==0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a = input()
if a=="SUN":
  print(7)
elif a=="MON":
  print(6)
elif a=="TUE":
  print(5)
elif a=="WED":
  print(4)
elif a=="THU":
  print(3)
elif a=="FRI":
  print(2)
elif a=="SAT":
  print(1)
# Judge status: Accepted
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = S()
    ans = 0


    for i in range(len(s)//2):
        if s[i] != s[-(i+1)]:
            ans += 1

    print(ans)
main()
# Judge status: Wrong Answer
import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
    gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[1])

if n == 2:
    print(max(a[1], a[0]))
else:
    print(max(gcd))
# Judge status: Wrong Answer
from math import atan as arctan
from math import degrees


def main():
    a, b, x = map(int, input().split(" "))
    bottom_area = x / a
    if bottom_area == a * b / 2:
        print("45.0000000000")
    elif bottom_area > a * b / 2:
        print(abs(degrees(arctan((2 * x / (a ** 3)) - (2 ** b / a)))))
    else:
        print(max(90 - degrees(arctan(2 * x / a / (b ** 3))),degrees(arctan(2 * x / a / (b ** 3)))))


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.reverse()
B.reverse()
count = 0
for i in range(N):
  if A[i] <= B[i]  <= A[i] + A[i+1]:
    count += B[i]
    A[i], A[i+1] = 0, A[i+1] - (B[i] - A[i])
  elif B[i] > A[i] + A[i+1]:
    count += A[i] + A[i+1]
    A[i], A[i+1] = 0, 0
  elif B[i] < A[i]:
    count += B[i]
    A[i] = A[i] - B[i]
print(count)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    x.append(X)
    y.append(Y)

    if max(x) < min(y):
        ans = "No War"
    else:
        ans = "War"

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
l = [None] * N
m = -float("inf")
m2 = -float("inf")
for i in range(N):
    l[i] = int(input())
    
    if (l[i] > m):
        m2 = m
        m = l[i]
    elif (l[i] > m2):
        m2 = l[i]


for el in l:
    if el == m:
        print(m2)
    else:
        print(m)
# Judge status: Accepted
K, A, B = map(int, input().split())

if(B-A <= 2):
    print(K+1)
else:
    m = max(0, (K-(A-1))//2)*(B-A)+(K+1)-2*max(0, (K-(A-1))//2)
    print(m)
# Judge status: Accepted
n = int(input())

str_set = set([ input() for i in range(n) ])
print(len(str_set))
# Judge status: Accepted
import bisect

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

lisL.sort()
ans = 0
for i in range(N):
    for j in range(i+1,N):
        ab = lisL[i] + lisL[j]
        ans += bisect.bisect_left(lisL[j+1:],ab)

print(ans)
# Judge status: Accepted
x, y = map(int,input().split())
print(x + int(y / 2))
# Judge status: Wrong Answer
N = input()

result = 0
carry = 0
for c in N[::-1]:
    t = int(c) + carry
    if t <= 11 - t:
        result += t
        carry = 0
    else:
        result += 10 - t
        carry = 1
result += carry
print(result)