Harryxun/stf_run huggingface dataset:
N = int(input())
p = []
if N > 0:
    for i in range(500):
        if (2**(2*i)-1)/3 < N <= (2**(2*(i+1))-1)/3:
            q = 2*i + 1
if N < 0:
    for i in range(1,500):
        if -(2**(2*i+1)-2)/3 <= N < -(2**(2*i-1)-2)/3:
            q = 2*i
if N == 0:
    q = 1
def cal(n,i):
    if i % 2 != 0:
        if (2**(i-1)-1)/3 < n <= (2**(i+1)-1)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
    elif n == 0:
        p.append(0)
        i = i-1
        if i > 0:
            cal(n,i)
    else:
        if -(2**(i+1)-2)/3 <= n < -(2**(i-1)-2)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
            
    return p
ans = cal(N,q)
for i in range(len(ans)):
    ans[i] = str(ans[i])
print(''.join(ans))

### FIXED CODE ###

N, K = map(int,input().split())
if N % K == 0:
    print(0)
else:
    print(1)
A = int(input())
B = int(input())
C = int(input())
X = int(input())

value = 0
for a in range(0, A+1):
	for b in range(0, B+1):
        for c in range(0, C+1):
            if 500*a + 100*b + 50*c == X:
                value += 1
print(value)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

value = 0
for a in range(0, A+1):
    for b in range(0, B+1):
        for c in range(0, C+1):
            if 500*a + 100*b + 50*c == X:
                value += 1
print(value)
import sys
from bisect import bisect_left
import numpy as np
from math import ceil


def main():
    read = sys.stdin.read

    N, K, *A = map(int, read().split())

    A.sort()
    m = bisect_left(A, 0)
    z = bisect_left(A, 1) - m
    p = N - m - z

    M = m * p
    Z = z * (N - z) + z * (z - 1) // 2

    if K <= M:
        left = A[0] * A[-1] - 1
        right = 0
        minuses = np.array(A[:m], np.int64)
        pluses = np.array(A[-p:], np.int64)
        while left + 1 < right:
            mid = ceil((left + right) / 2)
            a = (p-np.searchsorted(pluses, np.ceil(mid / minuses), side='left')).sum()
            if a < K:
                left = mid
            else:
                right = mid

        print(right)
    elif K <= M + Z:
        print(0)
    else:
        print(n)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import numpy as np


def test(a, K):
    from itertools import combinations
    answer = []
    for i, j in combinations(a, 2):
        answer.append(i * j)
    answer.sort()
    print(answer[K - 1])


def main():
    read = sys.stdin.read

    N, K, *A = map(int, read().split())

    if N <= 10:
        test(A, K)
        exit()
    A.sort()
    A = np.array(A, np.int64)
    negative = A[A < 0]
    positive = A[A > 0]
    m = len(negative)
    p = len(positive)
    z = N - m - p

    M = m * p
    Z = z * (N - z) + z * (z - 1) // 2
    negative = -negative[::-1]
    # 負の数の操作(pythonの挙動)は頭がこんがらがるので正の数にして考える

    if K <= M:
        left = 1
        right = -A[0] * A[-1] + 1
        while left + 1 < right:
            mid = (left + right) // 2
            cnt = (p - np.searchsorted(positive, (mid + negative - 1) // negative, side='left')).sum()
            if cnt < K:
                right = mid
            else:
                left = mid
        print(-left)
    elif K <= M + Z:
        print(0)
    else:
        K -= M + Z
        left = 0
        right = max(A[0] * A[1], A[-1] * A[-2])
        positive2 = positive ** 2
        negative2 = negative ** 2
        while left + 1 < right:
            mid = (left + right) // 2
            a = np.searchsorted(negative, mid // negative, side='right').sum() - (mid >= negative2).sum()
            b = np.searchsorted(positive, mid // positive, side='right').sum() - (mid >= positive2).sum()

            if (a + b) // 2 < K:
                left = mid
            else:
                right = mid

        print(right)


if __name__ == '__main__':
    main()
import math
n, d = input().split()
points = []
for i in range(n):
  points.append([int(x) for x in input().split()])
print(len([p for p in points if math.sqrt(p[0]**2+p[1]**2) <= d]))

### FIXED CODE ###

import math
n, d = [int(i) for i in input().split()]
points = []
for i in range(n):
  points.append([int(x) for x in input().split()])
print(len([p for p in points if math.sqrt(p[0]**2+p[1]**2) <= d]))
from collections import defaultdict
n, m = map(int, input().split())
nums = [int(i) for i in input().split()]

num_freq = defaultdict(int)

for _ in range(m):
    b, c = map(int, input().split())
    num_freq[c] += b


new_list = []
for num, freq in sorted(num_freq.items(), key=lambda x: -x[0]):
    new_list += [num] * freq
    if len(new_list) > n:
        break
tmp = sorted(nums + new_list)[::-1]
print(sum(tmp[:n]))


### FIXED CODE ###

# from collections import defaultdict
# n, m = map(int, input().split())
# nums = [int(i) for i in input().split()]
#
# num_freq = defaultdict(int)
#
# for _ in range(m):
#     b, c = map(int, input().split())
#     num_freq[c] += b
#
#
# new_list = []
# for num, freq in sorted(num_freq.items(), key=lambda x: -x[0]):
#     new_list += [num] * freq
#     if len(new_list) >= n:
#         break
# tmp = sorted(nums + new_list)[::-1]
# print(sum(tmp[:n]))

# ↑と同じ処理なのに↑のはREになる
n, m = map(int, input().split())
nums = list(map(int, input().split()))
exc = []

for i in range(m):
    exc.append(list(map(int, input().split())))
exc.sort(key=lambda x: x[1], reverse=True)
e = []
count = 0
for i in range(m):
    freq = exc[i][0]
    e += [exc[i][1]] * freq
    count += freq
    if count >= n:
        break
cards = sorted(nums + e, reverse=True)
print(sum(cards[:n]))
A,B = map(int, input().strip().split(' '))
if A > B:
  print('GREATER')
elif A < B:
  print('LESS')
else:
  print('EQUAL')

### FIXED CODE ###

A = int(input().strip())
B = int(input().strip())
if A > B:
  print('GREATER')
elif A < B:
  print('LESS')
else:
  print('EQUAL')
import math
import sympy
n = int(input())
ans = 0

for c in range(1,n):
    ab = n - c
    ans += sympy.divisor_count(ab)
        
print(ans)


### FIXED CODE ###

import math
n = int(input())
ans = 0

for a in range(1, n):
    ans += math.floor((n-1)/a)
print(ans)
A,B=input().split()
A=int(A)
B=int(B)
if A*B%2==0 :
  print("Even")
  else :
    print("Odd")

### FIXED CODE ###

A,B=input().split()
A=int(A)
B=int(B)
if A*B%2==0 :
  print("Even")
else :
  print("Odd")
n = input()
a = map(int, raw_input().split())

    a.sort()
    a.reverse()
    max = 0
    ai = 0
    aj = 0
    for i in range(0, len(a)):
        for j in range(i + 1, len(a)):
            c = comb(a[i], a[j])
            if c > max:
                max = c
                ai = a[i]
                aj = a[j]
    print(str(ai) + " " + str(aj))
    
def comb(n, r):
    return f(n) / (f(n - r) * f(r)) 

def f(n):
    if n == 1:
        return 1
    else:
        return n * f(n - 1)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split(" ")]
m = max(a)
abs_min = m
abs_i = 0

for i in range(0, n):
    ab = abs((m + 1)//2 - a[i])
    if a[i] != m and abs_min > ab:
        abs_min = ab
        abs_i = i
        
print(m, a[abs_i])
s = [len(x) for x in input().split('T')]
x, y = map(int, input().split())
len_s = len(s)
sx = [s[i] for i in range(len_s) if i%2 == 0]
sy = [s[i] for i in range(len_s) if i%2 == 1]

x -= sx[0]
sx = sx[1:]

def is_reachable(p, s):
    origin = 8000
    n = len(s)
    reachable = [[False for _ in range(origin*2+1)] for i in range(n+1)]
    reachable[0][origin] = True

    for i in range(n):
        for j in range(origin*2+1):
            if not reachable[i][j] :
                continue
            if j-s[i] >= 0:
                reachable[i+1][j-s[i]] = True
            if j+s[i] <= origin*2:
                reachable[i+1][j+s[i]] = True
    return reachable[n][p+origin] or reachable[n][-p+origin]


if is_reachable(x, sx) and is_reachable(y, sy):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s = [len(x) for x in input().split('T')]
x, y = map(int, input().split())
len_s = len(s)
sx = [s[i] for i in range(len_s) if i % 2 == 0]
sy = [s[i] for i in range(len_s) if i % 2 == 1]

x -= sx[0]
sx = sx[1:]



def is_reachable(p, s):
    origin = 8000
    if origin+p < 0:
        return False
        
    n = len(s)
    reachable = [set() for i in range(n + 1)]
    reachable[0].add(origin)

    for i in range(n):
        for j in list(reachable[i]):
            if j - s[i] >= 0:
                reachable[i + 1].add(j - s[i])
            if j + s[i] <= origin * 2:
                reachable[i+1].add(j + s[i])
    return (origin+p) in reachable[n] or (origin-p) in reachable[n]


if is_reachable(x, sx) and is_reachable(y, sy):
    print('Yes')
else:
    print('No')
n=input()
if (n[0]==n[1] and n[1]=n[2]) or (n[1]==n[2] and n[2]==n[3]):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n=input()
if (n[0]==n[1] and n[1]==n[2]) or (n[1]==n[2] and n[2]==n[3]):
  print('Yes')
else:
  print('No')
n,k=map(int,input().split())
candle=list(map(int,input().split()))
com=list(itertools.product(["1","0"], repeat=n))
ans=2000000000
for i in range(n-k):
  if candle[i]<0 and candle[i+k-1]>0:
    temp=min(abs(candle[i]), candle[i+k-1])*2+max(abs(candle[i]), candle[i+k-1])
  else:
    temp=abs(candle[i+k-1]-candle[i])
  ans=min(temp, ans)
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
candle=list(map(int,input().split()))
ans=2000000000
for i in range(n-k+1):
  if candle[i]<0 and candle[i+k-1]>0:
    temp=min(abs(candle[i]), candle[i+k-1])*2+max(abs(candle[i]), candle[i+k-1])
  elif candle[i+k-1]<=0:
    temp=abs(candle[i])
  elif candle[i]>=0:
    temp=candle[i+k-1]
  ans=min(temp, ans)
print(ans)
n = int(input())
A = [int(a) for a in input().split()]

ans_r = 0
for a in A:
  ans_r += 1/a

print(1/ans)


### FIXED CODE ###

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

ans_r = 0
for a in A:
  ans_r += 1/a

print(1/ans_r)
X,Y = map(int,input())
ans = 0
while X <= Y:
	ans += 1
	X * = 2
print(ans)

### FIXED CODE ###

from math import log
a,b = input().split()
a = eval(a)
b = eval(b)
cnt = 0
while a <= b:
	cnt += 1
	a *= 2
print(cnt)
H, W = map(int, input().split())
s=[]
for row in range(H):
    s.append(input())
#print(s)



waiting=[]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
def func(xy):
    x, y = xy
    for i in range(4):
        if 0<=y+dy[i]<H and 0<=x+dx[i]<W:
            if walker[y+dy[i]][x+dx[i]] == None and s[y+dy[i]][x+dx[i]]=='.':
                walker[y + dy[i]][x + dx[i]]=walker[y][x]+1
                waiting.append((x+dx[i], y+dy[i]))
    if waiting:
        func(waiting.pop(0))
    else:
        return None

walker=[]
for row in range(H):
    walker.append([None]*W)
#print(walker)
walker[0][0]=0
func((0,0))
#print(walker)
if walker[H-1][W-1] != None:
    minimum=walker[H-1][W-1]

    white_count=0
    for row in range(H):
        white_count += s[row].count('.')
    #print(white_count)
    print(white_count-minimum-1)
else:
    print(-1)



### FIXED CODE ###

import sys
sys.setrecursionlimit(5000)

H, W = map(int, input().split())
s=[]
for row in range(H):
    s.append(input())
#print(s)



waiting=[]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
def func(xy):
    x, y = xy
    for i in range(4):
        if 0<=y+dy[i]<H and 0<=x+dx[i]<W:
            if walker[y+dy[i]][x+dx[i]] == None and s[y+dy[i]][x+dx[i]]=='.':
                walker[y + dy[i]][x + dx[i]]=walker[y][x]+1
                waiting.append((x+dx[i], y+dy[i]))
    if waiting:
        func(waiting.pop(0))
    else:
        return None

walker=[]
for row in range(H):
    walker.append([None]*W)
#print(walker)
walker[0][0]=0
func((0,0))
#print(walker)
if walker[H-1][W-1] != None:
    minimum=walker[H-1][W-1]

    white_count=0
    for row in range(H):
        white_count += s[row].count('.')
    #print(white_count)
    print(white_count-minimum-1)
else:
    print(-1)
N, K = [int(x) for x in input().split(' ')]
m = 10**9 + 7
import math
def combination(n, r):
  return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
  
for k in range(1, K+1):
  print(combination(N-K+1, k) * combination(k, k-1) % m)


### FIXED CODE ###

N, K = [int(x) for x in input().split(' ')]
m = 10**9 + 7
fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i
  
def combination(n, r):
  return fact[n] // fact[r] // fact[n-r]
  
for k in range(1, K+1):
  print(combination(N-K+1, k) % m * combination(K-1, k-1) % m)
N,M=map(int,input().split())
p=[]
S=[]
for i in range(M):
  p0,S0=map(int,input().split())
  p+=[p0]
  S+=[S0]
awlist=[0 for i in range(N)]
walist=[0 for i in range(N)]
wacount=0
account=0
for i in range(M):
  if s[i]=='WA' and awlist[s[i]]==0:
    walist[s[i]]+=1
  elif s[i]=='AC' and awlist[s[i]]==0:
    account+=1
    awlist[s[i]]=1
    wacount+=walist[s[i]]
Answer=[account,wacount]
print(*Answer)

### FIXED CODE ###

N,M=map(int,input().split())
p=[]
s=[]
for i in range(M):
  p0,S0=map(str,input().split())
  p0=int(p0)-1
  p+=[p0]
  s+=[S0]
awlist=[0 for i in range(N)]
walist=[0 for i in range(N)]
wacount=0
account=0
for i in range(M):
  if s[i]=='WA' and awlist[p[i]]==0:
    walist[p[i]]+=1
  elif s[i]=='AC' and awlist[p[i]]==0:
    account+=1
    awlist[p[i]]=1
    wacount+=walist[p[i]]
Answer=[account,wacount]
print(*Answer)
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = list('0' * N)
for i in range(M):
  if change[q[i][0]-1] == 0:
  	ans[q[i][0] - 1] = q[i][1]
    change[q[i][0]-1] = 1
  else:
    if ans[q[i][0] - 1] != q[i][1]:
      ans = -1
      break
      
try:
  print(int(ans))
except:
  print(-1)


### FIXED CODE ###

N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)
x=int(input())
if x = 7 and x = 5 and x = 3:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

x=int(input())
if x == 7 or x == 5 or x == 3:
  print("YES")
else:
  print("NO")
import sys
import numpy as np
from collections import defaultdict as dd
n,k = [int(x) for x in sys.stdin.readline().split()]
r = dd(int)
for i in range(n):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a] += b
r.sort()
c = 0
for i,j in r.items():
	c += j
	if c >= k:
		print(i)
		break

### FIXED CODE ###

import sys
import numpy as np
import collections
n,k = [int(x) for x in sys.stdin.readline().split()]
r = collections.defaultdict(int)
for i in range(n):
	a, b = [int(x) for x in sys.stdin.readline().split()]
	r[a] += b
d = sorted(r.items())
c = 0
for i,j in enumerate(d):
	c += j[1]
	if c >= k:
		print(int(j[0]))
		break
N = int(input())

P2 = list(range(2,30001,2))
P3 = list(range(3,30001,6))
for i in range(1,N+1):
  if (N-i*3)%2==0 and 3*i<=15000 and (N-3*i)<=5000:
    x = 3*i
    y = (N-i*3)
    break
if N==5 or N>6:
  ans = P2[:x]+P3[:y]
elif N==3:
  ans = [2,5,63]
elif N==4:
  ans = [2,5,20,63]
elif N==6:
  ans = [2,3,4,65,7,9]
print(*ans)

### FIXED CODE ###

N = int(input())

P2 = list(range(2,30001,2))
P3 = list(range(3,30001,6))
for i in range(1,5002):
  if (N-i*3)%2==0 and 0<(N-3*i)<=5000:
    x = 3*i
    y = (N-i*3)
    break
if N==5 or N>6:
  ans = P2[:x]+P3[:y]
elif N==3:
  ans = [2,5,63]
elif N==4:
  ans = [2,5,20,63]
elif N==6:
  ans = [2,3,4,185,7,9]
if N==19999:
  ans = P2[:14997]+P3[:5000]+[19,425]
print(*ans)
num=input()
data=list(input())

count=1
for i in range(num-1):
  if data[i]=!data[i+1]:
    count+=1
print(count)


### FIXED CODE ###

num=int(input())
data=list(input())
 
count=1
for i in range(num-1):
  if data[i] is not data[i+1]:
    count+=1
print(count)
from math import gcd
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
kyori_list = [abs(X-i) for i in x_list]
ans_gcd = kyori_list[0]
for i in kyori_list[1:]:
    ans_gcd = gcd(ans_gcd, i)
print(ans_gcd)

### FIXED CODE ###

from fractions import gcd
N, X = map(int, input().split())
x_list = list(map(int, input().split()))
kyori_list = [abs(X-i) for i in x_list]
ans_gcd = kyori_list[0]
for i in kyori_list[1:]:
    ans_gcd = gcd(ans_gcd, i)
print(ans_gcd)
W,H,x,y,r=map(int,input().split())
if x - r >= 0 and x + r <= W:
    if y - r >= 0 and y + r <= H:
        print "Yes"
    else:
        print "No"
else:
    print"No"

### FIXED CODE ###

W,H,x,y,r = map(int,input().split(" "))
if x - r >= 0 and x + r <= W:
    if y - r >= 0 and y + r <= H:
        print("Yes")
    else:
        print("No")
else:
    print("No")
import bisect

N,M = map(int, input().split())
A_list = list(map(int, input().split()))

A_list = sorted(A_list)
#print(A_list)

for i in range(M):
    val = A_list.pop()//2
    bisect.insort_left(A_list, val, lo=(N-M) + i )

print(sum(A_list))

### FIXED CODE ###

import heapq

N,M = map(int, input().split())
A_list = list(map(int, input().split()))
for i in range(N):
    A_list[i] *= -1

heapq.heapify(A_list)

for i in range(M):
    heapq.heappush(A_list, ((heapq.heappop(A_list) * -1 )// 2) * -1)

print(sum(A_list) * -1)
a,b,c=map(int,input().split())
if(a<b):
    w=a;a=b;b=w;
if(b<c):
    w=b;b=c;c=w;
if(a<b)
    w=a;a=b;b=w;
print(f"{a},{b},{c}");




### FIXED CODE ###

a=list(map(int,input().split()))
a.sort()
print(a[0],a[1],a[2])
# -*- coding: utf-8 -*-

while True:
    line = map(str, raw_input().split())
    H = int(line[0])
    W = int(line[1])
    if H+W:
        for i in range(H):
            if i == 0 or i == (H-1):
                print "#"*W
            elif:
                print "#" + "."*(W-2) +"#"
        print ""
    else:
        break

### FIXED CODE ###

# -*- coding: utf-8 -*-

while True:
    line = map(str, raw_input().split())
    H = int(line[0])
    W = int(line[1])
    if H+W:
        for i in range(H):
            if i == 0 or i == (H-1):
                print "#"*W
            else:
                print "#" + "."*(W-2) +"#"
        print ""
    else:
        break
l=int(input())
for i in range(1,20):
	if 2**i>l:
		r=i-1
		break
ans=[]
for i in range(r):
	ans.append((i+1,i+2,0))
	ans.append((i+1,i+2,2**i))
now=2**r-1
for i in range(r,0,-1):
	if 2**(i-1)+now<=l-1:
		ans.append((i,r+1,now+1))
		now+=2**(i-1)
print(r+1,len(ans))
for x in ans:
	print(*x)

### FIXED CODE ###

l=int(input())
for i in range(1,21):
	if 2**i>l:
		r=i-1
		break
ans=[]
for i in range(r):
	ans.append((i+1,i+2,0))
	ans.append((i+1,i+2,2**i))
now=2**r-1
for i in range(r,0,-1):
	if 2**(i-1)+now<=l-1:
		ans.append((i,r+1,now+1))
		now+=2**(i-1)
print(r+1,len(ans))
for x in ans:
	print(*x)
import sys

values = [int(input()) for i in range(int(input()))]

maxv = - sys.maxsize - 1
minv = values[0]

for value in enumerate(values):
    maxv = max(maxv, value - minv)
    minv = min(minv, value) 

print(maxv)



### FIXED CODE ###

values = [int(input()) for _ in range(int(input()))]
maxv = values[1] - values[0]
minv = values[0]

for val in values[1:]:
    maxv = max(maxv, val - minv)
    minv = min(minv, val)         # 今までの最小値を保持(自分と自分を比較しない様に、最大値の評価後に計算)
print(maxv)
# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 21:46:51 2018

@author: sk
"""

# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 21:46:51 2018

@author: sk
"""


b =str( input())

a = list(b)



if b[0]==b[1]:
  if b[1]==b[2]:
    print("Yes")
  else :
    print("No")

elif b[1]==b[2]:
  if b[2]==b[3]:
    print("Yes")
  else :
    print("No")
else:
prit("No")













### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 21:46:51 2018

@author: sk
"""

# -*- coding: utf-8 -*-
"""
Created on Sun Nov  4 21:46:51 2018

@author: sk
"""


b =str( input())

a = list(b)



if b[0]==b[1]:
  if b[1]==b[2]:
    print("Yes")
  else :
    print("No")

elif b[1]==b[2]:
  if b[2]==b[3]:
    print("Yes")
  else :
    print("No")
else:
  print("No")
t,x=map(float,input())
print(t/3)

### FIXED CODE ###

t,x=map(float,input().split())
print(t/x)
print(len([1 for i in range(1,int(input())+1) if str(i)%2 == 1]))

### FIXED CODE ###

print(len([1 for i in range(1,int(input())+1) if len(str(i))%2 == 1]))
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

import copy

pp = p[:]
qq = q[:]
rr = r[:]

count = 0
another_count = 0

check_r = []
check_g = []
# 赤く塗り替える
# 赤いりんごX
for i in range(X):
    max_red = 0
    if max(p)>=max(r):
        max_red = max(p)
        p.remove(max_red)
    else:
        max_red = max(r)
        check_r.append(max_red)
        r.remove(max_red)

    count += max_red


# 緑のりんごY
for i in range(Y):
    max_green = 0
    if max(q)>=max(r):
        max_green = max(q)
        q.remove(max_green)
    else:
        max_green = max(r)
        r.remove(max_green)
    count += max_green

#
# # 緑に塗り替える
# # 緑のりんごY
# for i in range(Y):
#     max_green = 0
#     if max(qq)>=max(rr):
#         max_green = max(qq)
#         qq.remove(max_green)
#     else:
#         max_green = max(rr)
#
#         rr.remove(max_green)
#
#     another_count += max_green
#
#
# # 赤いりんごX
# for i in range(X):
#     max_red = 0
#     if max(pp)>=max(rr):
#         max_red = max(pp)
#         pp.remove(max_red)
#     else:
#         max_red = max(rr)
#         check_g.append(max_red)
#         rr.remove(max_red)
#     another_count += max_red

print(count)
# print(another_count)


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p_sort = sorted(p, reverse=True)
q_sort = sorted(q, reverse=True)
r_sort = sorted(r, reverse=True)

del p_sort[X:]
del q_sort[Y:]

total_list = p_sort + q_sort + r_sort
total_list_sort = sorted(total_list, reverse=True)
del total_list_sort[(X+Y):]
print(sum(total_list_sort))
import numpy as np

N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
# b = np.bitwise_xor.reduce(a)
c = np.bitwise_xor(a, 0)
print(*c, sep=" ")

# for n in range(N):
#     print(np.bitwise_xor.reduce(a) ^ a[n])


### FIXED CODE ###

a = input()
if(a == a.upper()):
    print("A")
else:
    print("a")
n = int(input())
s = input()
ans = 0


for i in range(n-2):
    if s[i:i+3] == "ABC":
        res += 1

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

print(s.count('ABC'))
import collections

N = int(input())

S = collections.Counter(list(input()))
for i in range(N-1):
    c = collections.Counter(list(input()))
    S &= c

ans = []
for i in S.items():
    ans += i[0]*i[1]
A.sort()
print(*ans, sep="")

### FIXED CODE ###

import collections

N = int(input())

S = collections.Counter(list(input()))
for i in range(N-1):
    c = collections.Counter(list(input()))
    S &= c

ans = []
for i in S.items():
    ans += i[0]*i[1]
ans.sort()
print(*ans, sep="")
from math import floor

while True:
    e = int(input())
    if e == 0:
        break

    ans = 10 ** 10
    for z in range(floor(e ** (1 / 3)) + 1):
        for y in range(floor((e - z) ** (1 / 2)) + 1):
            x = e - y ** 2 - z ** 3
            if x < 0:
                continue
            ans = min(ans, x + y + z)
    print (ans)


### FIXED CODE ###

from math import floor

while True:
    e = int(input())
    if e == 0:
        break

    ans = 10 ** 10
    z = 0
    while z ** 3 <= e:
        y = floor((e - z **3) ** 0.5)
        x = e - y ** 2 - z ** 3
        ans = min(ans, x + y + z)
        z += 1
    print (ans)
N,X = map(int,input().split())
D = 0
ans = 1
while D <=X:
    D += int(input())
    ans+= 1
if D >X:
    ans-=1
print(ans)

### FIXED CODE ###

N,X = map(int,input().split())
D = 0
ans = 1
L = list(x for x in input().split())
for i in range(N):
    
    if D <=X:
        D+=int(L[i])
        ans+=1
    else:
        continue
if D >X:
    ans-=1
print(ans)