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

import sys
input = sys.stdin.readline
from heapq import merge

n, k, q = map(int, input().split())
A = list(map(int, input().split())) + [-1]
ans = float("inf")
for a in A:
  L = []
  S = []
  for t in A:
    if t >= a:
      L.append(t)
    else:
      L.sort()
      S.append(L[:max(len(L)-k+1, 0)])
      L = []
  K = list(merge(*S))
  if len(K) < q:
    continue
  y = K[q-1]
  ans = min(ans, y-a)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
A = list(map(int, input().split())) + [-1]
ans = float("inf")
for a in A:
  L = []
  K = []
  for t in A:
    if t >= a:
      L.append(t)
    else:
      L.sort()
      for c in range(len(L)-k+1):
        K.append(L[c])
      L = []
  K.sort()
  if len(K) < q:
    continue
  else:
    y = K[q-1]
    ans = min(ans, y-a)
print(ans)
### BUGGY CODE ###

def nibuntansaku(l,x):
    n = len(l)
    def hantei(med):
        if med == -1:
            return False
        elif med == n:
            return True
        elif l[med] > x:
            return True
        else:
            return False
    left = -1
    right =n
    while right-left >1:
        med = (left+right)//2
        if right == med or left == med:
            break
        if hantei(med):
            right = med
        else:
            left = med
    ret =[0,0]
    if left == -1:
        ret[0] = 10**11
        ret[1] = l[right] -x
    elif right == n:
        ret[0] = x -l[left]
        ret[1] = 10**11
    else:
        ret[0] = x - l[left]
        ret[1] = l[right] -x
    return ret


A,B,Q =[int(i)for i in input().split()]
S =[int(input())for _ in range(A)]
T =[int(input())for _ in range(B)]

for _ in range(Q):
    x = int(input())
    slef,sri = nibuntansaku(S,x)
    tlef,tri = nibuntansaku(T,x)
    lmax,lmin = max(slef,tlef),min(slef,tlef)
    rmax,rmin = max(sri,tri),min(sri,tri)
    ans = min(lmax,rmax,2*lmin+rmin,2*rmin+lmin)
    print(ans)


### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
A,B,C =map(int,input().split())
s =[-10**11] + [int(input())for _ in range(A)] +[10**11]
t =[-10**11] + [int(input())for _ in range(B)] +[10**11]

for _ in range(C):
    x =int(input())
    ns = bisect.bisect_left(s,x)
    nt = bisect.bisect_left(t,x)
    sx =[s[ns-1],s[ns]]
    tx =[t[nt-1],t[nt]]
    lis =[sx,tx]
    ans = 10**11
    for i in range(8):
        p =i%2
        q =(i//2)%2
        r =i//4
        foo =abs(x-lis[p][q])+abs(lis[p][q]-lis[p-1][r])
        if foo < ans:
            ans = foo
    print(ans)
### BUGGY CODE ###

A,B,K = map(int, input().split())
if A - B > 200:
  [print(i) for i in range(A,A+K) if i - K < A]
  [print(i) for i in range(B+1-K,B+1) if i + K > B]
else:
  [print(i) for i in range(A,B+1) if i - K < A or i + K > B]

### FIXED CODE ###

A,B,K = map(int, input().split())
if B-A > 2 * K:
  [print(i) for i in range(A,A+K)]
  [print(i) for i in range(B+1-K,B+1)]
else:
  [print(i) for i in range(A,B+1) if i - K < A or i + K > B]
### BUGGY CODE ###

def prime(num):
    c=0
    for i in range(2,num+1):
        if num%i==0:
            c+=1
    if c==1:
        return True
    else:
        return False


def getFACT(number):
    arr=[i for i in range(2,number+1) if number%i==0]
    return arr


N=eval(input())
count=0
if prime(N)==True:
    count=1

else:
    factors=getFACT(N)
    for Z in factors:
        if N%Z==0:
            if prime(Z)==True:
                count+=1
                N=N//Z
            else:
                f=0
                psntFACT=getFACT(Z)
                for i in psntFACT:
                    if prime(i)==True:
                        f=1
                        break
                    

                if f==1:
                    count+=1
                    N=N//Z
        
        if N==1:
            break

print(count)
                                                      


### FIXED CODE ###

# Python program to print prime factors 

import math 

def primeFactors(n):
    A=[] 
    while n % 2 == 0:
        A.append(2)
        n = n // 2
        
 
    for i in range(3,int(math.sqrt(n))+1,2): 
        
        
        while n % i== 0: 
            A.append(i)
            n = n // i 
            
   
    if n > 2: 
        A.append(n)
    
    return A
        


N = int(input())
primes = set(primeFactors(N))
answer = 0
for p in primes:
    d = p
    while N%d == 0:
        answer += 1
        N //= d
        d *= p
 
print(answer)
### BUGGY CODE ###

from collections import deque

n, q = map(int, input().split( ))
Edg=[[] for i in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split( ))
    Edg[a].append(b)
Ans=[0 for i in range(n+1)]
P = [0 for i in range(n+1)]
for i in range(q):
    p, x = map(int, input().split( ))
    P[p]+=x
#print(*P)
Chld=[[] for i in range(n+1)]
for p in range(n+1):
    Task=deque()
    Task.append(p)
    while True:
        try:
            p_=Task.popleft()
            for child in Edg[p_]:
                Chld[p].append(child)
                Task.append(child)
        except:
            break
#print(Chld)
for p in range(n+1):
    tmp = P[p]
    Ans[p]+=tmp
    for c in Chld[p]:
            Ans[c]+=tmp

print(*Ans[1:])


### FIXED CODE ###

from collections import deque

n, q = map(int, input().split( ))
Edg=[[] for i in range(n+1)]
Done = [0 for _ in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split( ))
    Edg[a].append(b)
    Edg[b].append(a)


Ans=[0 for i in range(n+1)]
Pls = [0 for i in range(n+1)]


for i in range(q):
    p, x = map(int, input().split( ))
    Pls[p]+=x

root=1

Task=deque()

Task.append(root)

while len(Task)>0:
    p_=Task.popleft()
    tmp = Pls[p_]
    Ans[p_]+=tmp
    Done[p_] = 1
    for child in Edg[p_]:
        if not Done[child]:
            Task.append(child)
            Pls[child]+=tmp


print(*Ans[1:])
### BUGGY CODE ###

r1,c1,r2,c2=map(int,input().split())

#O(10**12) orz

from scipy.misc import comb
mod=10**9+7
tret=0
for i in range(r1,r2+1):
    for j in range(c1,c2+1):
        # print(i,j)
        tret+=comb(i+j,i,exact=True)
        tret%=mod
        
print(tret)
        

### FIXED CODE ###

r1,c1,r2,c2=map(int,input().split())

mod = 10**9+7
MAX_N = 3*10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%mod

def comb(n,k,mod):
    if n<k:return 0
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

ans=0
ans+=comb(c1+r1,r1,mod)
ans%=mod
ans-=comb(c1+r2+1,r2+1,mod)
ans%=mod
ans-=comb(c2+r1+1,r1,mod)
ans%=mod
ans+=comb(c2+r2+2,r2+1,mod)
ans%=mod

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

n,m,k=map(int,input().split())
edge=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edge[a].append(b)
    edge[b].append(a)

edgeb=[[] for _ in range(n)]

for _ in range(k):
    c,d=map(int,input().split())
    c,d=c-1,d-1
    edgeb[c].append(d)
    edgeb[d].append(c)

from collections import deque
label=[-1]*n

i=0
for start in range(n):
    if label[start]!=-1:
        continue
    else:
        i+=1
        label[start]=i    
    dist_friends=[-1]*n
    dist_friends[start]=0
    f=deque([start])

    while f:
        v=f.popleft()        

        for e in edge[v]:
            if dist_friends[e]==-1:
                dist_friends[e]=dist_friends[v]+1
                label[e]=i
                f.append(e)   

Renketsu=[0]*(n+1)

for i in label:
    Renketsu[i]+=1

Block=[0]*n
for i in range(len(edgeb)):
    E=edgeb[i]
    for j in E:
        if label[i]==label[j]:
            Block[i]+=1

ans=[]
for k in range(n):
    ans.append(Renketsu[label[k]]-1 - len(edge[k]) - Block[k])
print(*ans)

### FIXED CODE ###

n,m,k=map(int,input().split())
edge=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edge[a].append(b)
    edge[b].append(a)

from collections import deque
label=[-1]*n

i=0
for start in range(n):
    if label[start]!=-1:
        continue
    else:
        i+=1
        label[start]=i    
    f=deque([start])
    while f:
        v=f.popleft()        
        for e in edge[v]:
            if label[e]==-1:
                label[e]=i
                f.append(e)   

Renketsu=[0]*(n+1)

for i in label:
    Renketsu[i]+=1

Block=[0]*n
for _ in range(k):
    c,d=map(int,input().split())
    c,d=c-1,d-1
    if label[c]==label[d]:
        Block[c]+=1
        Block[d]+=1

ans=[]
for k in range(n):
    ans.append(Renketsu[label[k]]-1 - len(edge[k]) - Block[k])
print(*ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

#input
N, M = map(int, input().split())
s = [0] * M
t = [0] * M
for i in range(M):
    s[i], t[i] = map(int, input().split())

#output
#（便宜的に地点から-1としておく）
u = [[]] * N
for v in s:
    u[v-1] = [t-1 for i, t in enumerate(t) if s[i] == v]

#地点vにたどり着く確率をp[v]とする。
p = [0] * N
p[0] = 1
for v in range(N):
    for i in range(v):
        if v in u[i]:
            p[v] += p[i]/len(u[i])

#期待値をゴールから逆順に求めていく。点vからゴールまでの移動距離の期待値をq[v]とする。
q = [0] * N
q[N-1] = 0
for v in reversed(range(N)):
    for i in u[v]:
        q[v] += (1 + q[i])/len(u[v])

v = [0] * N
for i in range(N):
    a = len(u[i])
    if a > 1:
        b = max([q[e] for e in u[i]])
        v[i] = p[i]*(q[i] - (1+b))/(a-1)
        
print(q[0]+min(v))

### FIXED CODE ###

import sys
input = sys.stdin.readline

#input
N, M = map(int, input().split())
u = [[] for i in range(N-1)]
#（便宜的に地点から-1としておく）
for i in range(M):
    s, t = map(int, input().split())
    u[s-1].append(t-1)

#output
#地点vにたどり着く確率をp[v]とする。
p = [0] * N
p[0] = 1
for x, y in enumerate(u):
    for z in y:
        p[z] += p[x]/len(y)

#期待値をゴールから逆順に求めていく。点vからゴールまでの移動距離の期待値をq[v]とする。
q = [0] * N
q[N-1] = 0
for x, y in list(enumerate(u))[::-1]:
    q[x] = sum(q[z] for z in y)/len(y) + 1

v = [0] * N
for i in range(N-1):
    a = len(u[i])
    if a > 1:
        b = max(q[c] for c in u[i])
        v[i] = p[i]*(q[i] - (1+b))/(a-1)

print(q[0]+min(v))
### BUGGY CODE ###

x,y = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
score = 0
for i in range(y):
  li[x - 1] //= 2
  if len(li) > 2:
    if li[x - 1] < li[x - 2]:
      li.sort()
for j in li:
  score += j
print(score)

### FIXED CODE ###

import heapq

n, m = map(int,input().split())
li = list(map(lambda x: int(x)*(-1),input().split()))

heapq.heapify(li)

for i in range(m):
    a = heapq.heappop(li)
    a = (-a) // 2
    heapq.heappush(li,-a)

print(-sum(li))
### BUGGY CODE ###

import numpy as np

N, X = map(int, input().split())
S = list(map(int, input().split()))


MOD = 1000000007
numbers = S[:]
numbers.sort()


dp = np.zeros((N+1, X+1), dtype=int)
dp = np.arange(X+1)
dp_n = []
for i, n  in enumerate(numbers):
    dp_n = np.zeros((X+1), dtype=np.int64)
    dp_n += [dp[x % n] for x in range(X+1)]
    dp_n = dp_n % MOD
    dp_n += dp * i % MOD
    dp_n = dp_n % MOD
    dp = dp_n

print(int(dp_n[X] % MOD))


### FIXED CODE ###

N, X = map(int, input().split())
S = list(map(int, input().split()))

MOD = 1000000007
numbers = S[:]
numbers.sort(reverse=True)


dp = {X: 1}

for i, n in enumerate(numbers):
    tmp_dp = {}
    for k, v in dp.items():
        if k < n:
            tmp_dp[k] = (tmp_dp.get(k,0)+v*(N-i))
        else:
            tmp_dp[k]=(tmp_dp.get(k,0)+v*(N-i-1)) 
            tmp_dp[k%n]=(tmp_dp.get(k%n,0)+v) 
    dp = tmp_dp.copy()
        
ans = 0
for k, v in dp.items():
    ans += k *  v

print(ans % MOD)
### BUGGY CODE ###

a, b, n = map(int, input().split())
current = 0
for x in range(n+1):
  temp = (a*x)//b - a*(x//b)
  current = max(current, temp)
print(current)
  

### FIXED CODE ###

a, b, n = map(int, input().split())
x = min(b-1,n)
print((a*x)//b - a*(x//b))
### BUGGY CODE ###


def gcd(a, b):
    while b: a, b = b, a % b
    return a


def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1 << 32 else [2, 3, 5, 7, 11, 13, 17] if n < 1 << 48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
                                                                                     31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1


def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g):
                return g
            elif isPrimeMR(n // g):
                return n // g
            return findFactorRho(g)


def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


def f(n):
    A = primeFactor(n)
    ret = n
    for key, value in A:
        ret *= (value+1)
    return ret


N = int(input())
DP = [0] * (N+1)
ans = 1
DP[1] = 1
for i in range(2, N+1):
    A = primeFactor(i)
    a = 1
    if len(A) == 1:
        for key, value in A.items():
            a = i * (value+1)
    else:
        for key, value in A.items():
            a *= DP[key**value]
    DP[i] = a
    ans += a


print(ans)

### FIXED CODE ###

N = int(input())

Ans = [2 * i for i in range(N+1)]
Ans[0] = 0
Ans[1] = 1
ans = N * (N + 1) - 1
for i in range(2, N+1):
    if i * 2 > N+1:
        break
    for j in range(2 * i, N+1, i):
        Ans[j] += j
        ans += j

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

N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
if 10**18 < ans:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
M = 10**18
ans = 1
for a in A:
    ans *= a
    if M < ans:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

# 初期入力
import sys
input = sys.stdin.readline
N,Q = (int(x) for x in input().split())
S =input().strip()
l =[]
r =[]
for i in range(Q):
    l1,r1 = (int(x) for x in input().split())
    l.append(l1 -1)
    r.append(r1-2) #"AC"のAの位置と比べるため－２

# ACのindex(左端)
import re
import numpy as np
x =[m.start() for m in re.finditer('AC', S)]
x =np.array(x)
#
for i in range(Q):
    ans = np.count_nonzero( (x >=l[i]) & (x <=r[i]) )
    print(ans)

### FIXED CODE ###

# 初期入力
import sys
input = sys.stdin.readline
N,Q = (int(x) for x in input().split())
S =input().strip()
l =[]
r =[]
for i in range(Q):
    l1,r1 = (int(x) for x in input().split())
    l.append(l1 -1) #indexは０始まりだからー１
    r.append(r1 -1) #"AC"のAの位置と比べるため－２

# ACのindex(左端)
import re
import numpy as np
index =0
t =[0]*N

for i in range(N-1):
    t[i+1] = t[i] +np.count_nonzero(S[i:i+2] =="AC")

#
for i in range(Q):
    ans = t[ r[i]] - t[ l[i]] 
    print(ans)
### BUGGY CODE ###

while 1:
	n = int(raw_input())
	if n == 0:
		break
	bridge = [0 for i in range(n)]
	gold = [0 for i in range(n)]
	for i in range(n):
		gold[i], bridge[i] = map(int,raw_input().split(" "))
	dp = {0:0}
	for i in range(n):
		tmp_dp = dict()
		for k,v in dp.iteritems():
			for j in range(n):
				bit = 1 << j
				if (k & bit != 0) or (k|bit in tmp_dp):
					continue
				if v + gold[j] <= bridge[j]:
					tmp_dp[k|bit] = v + gold[j]
		dp = tmp_dp
	print "Yes" if (2**n - 1) in dp else "No"

### FIXED CODE ###

while 1:
	n = int(raw_input())
	if n == 0:
		break
	land = [map(int,raw_input().split(" ")) for i in range(n)]
	land.sort(key = lambda x:(x[1],x[0]))
	gold = 0
	for i in range(n):
		gold += land[i][0]
		if gold > land[i][1]:
			print "No"
			break
	else:
		print "Yes"
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = ""
for i in range(n):
    b = b + str(a.index(i+1) + 1) + " "
print(b)

### FIXED CODE ###

n = int(input())
b = ""
ans = [0 for i in range(n)]
a = list(map(int,input().split()))
for i in range(n):
    ans[a[i]-1] = i+1
for i in range(n):
    b += str(ans[i])
    if i != n-1:
        b += " "
print(b)
### BUGGY CODE ###

n = int(input())
pn = list(map(int, input().split()))
ans = 1
for i in range(n-1):
  if min(pn[:i+1]) >= pn[i+1]:
    ans +=1
print(ans)

### FIXED CODE ###

n = int(input())
plist = list(map(int,input().split()))
min = n + 1
count = 0
for i in range(n):
  if plist[i] <= min:
    min = plist[i]
    count += 1
print(count)
### BUGGY CODE ###



G = [301,91,58,31,7,4,1]

def insertion_sort(array,g):
    for i in range(g,len(array)-1):
        v = array[i]
        j = i-g
        while j>=0 and array[j] > v:
            array[j+g] = array[j]
            j = j-g
            array[-1] += 1
        array[j+g] = v

def shell_sort(array,G):
    for i in G:
        insertion_sort(array,i)


n = int(input())
arr = [int(input()) for i in range(n)] + [0]
Gn = [i for i in G if i <= n]


shell_sort(arr,Gn)
print(len(Gn))
print(' '.join([str(i) for i in Gn]))
print(arr[-1])
[print(i) for i in arr[:-1]]

### FIXED CODE ###



G = [120001,60001,30001,15001,3001,901,601,301,91,58,31,7,4,1]

def insertion_sort(array,g):
    for i in range(g,len(array)-1):
        v = array[i]
        j = i-g
        while j>=0 and array[j] > v:
            array[j+g] = array[j]
            j = j-g
            array[-1] += 1
        array[j+g] = v

def shell_sort(array,G):
    for i in G:
        insertion_sort(array,i)


n = int(input())
arr = [int(input()) for i in range(n)] + [0]
Gn = [i for i in G if i <= n]


shell_sort(arr,Gn)
print(len(Gn))
print(' '.join([str(i) for i in Gn]))
print(arr[-1])
[print(i) for i in arr[:-1]]
### BUGGY CODE ###

A,B=map(int,input().split())
lst=[]
i=2
while A>1 and B>1:
    if A%i==0 and B%i==0:
        flag=1
        for l in lst:
            if i%l==0:
                flag=0
                break
        if flag:
            A=A//i
            B=B//i
            lst.append(i)
    i+=1

lst+=[1]
#print(lst)
print(len(lst))


### FIXED CODE ###

A,B=map(int,input().split())
lst=set()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if A==B==1:
    print(1)
else:
    print(len(set([i[0] for i in factorization(A)])&set([i[0] for i in factorization(B)]))+1)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = []
if n%2==0 :
    for i in range(n):
        if(i%2):
            b.insert(0,a[i])
        else:
            b.append(a[i])

if n%2!=0 :
    for i in range(n):
        if(i%2):
            b.append(a[i])
        else:
            b.insert(0,a[i])


print(*b)

### FIXED CODE ###

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

if n%2==0 :
    print(*(a[1::2][::-1]+a[0::2]))
else:
    print(*(a[0::2][::-1]+a[1::2]))
### BUGGY CODE ###

import sys
import collections
e=sys.stdin.readlines()
N,M,Q=map(int,e[0].split())
dp=[[0]*-~N for _ in[0]*-~N]
for k,c in collections.Counter(e[1:M+1]).items():
    L,R=map(int,k.split())
    for i in range(1,L+1):
        for j in range(R,N+1):
            dp[i][j] += c
ans=''
for x in e[M+1:]:
    p,q=map(int,x.split())
    ans+=str(dp[p][q])+'\n'
print(ans[:-1])

### FIXED CODE ###

import sys
def main():
    s = sys.stdin.readlines()
    N, M, Q = map(int, s[0].split())
    x = [[0] * N for _ in [0] * N]
    for e in s[1:M + 1]:
        L, R = map(int, e.split())
        x[L - 1][R - 1] += 1
    for k in range(1, N):
        for i in range(N - k):
            j = i + k
            x[i][j] += x[i][j - 1] + x[i + 1][j] - x[i + 1][j - 1]
    res = []
    for e in s[M + 1:]:
        p, q = map(int, e.split())
        res.append(x[p - 1][q - 1])
    print('\n'.join(map(str, res)))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())), reverse=True)
q = sorted(list(map(int,input().split())), reverse=True)
r = sorted(list(map(int,input().split())), reverse=True)
pq = sorted(p[:x] + q[:y])
ans = sum(pq)
i = 0
while i < min(a+b, c):
  if r[i] <= pq[i]:
    break
  ans += r[i] - pq[i]
print(ans)

### FIXED CODE ###

x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())), reverse=True)
q = sorted(list(map(int,input().split())), reverse=True)
r = sorted(list(map(int,input().split())), reverse=True)
pq = sorted(p[:x] + q[:y])
ans = sum(pq)
i = 0
while i < min(a+b, c):
  if r[i] <= pq[i]:
    break
  ans += r[i] - pq[i]
  i += 1
print(ans)
### BUGGY CODE ###

S = input()
S = list(S)
S.reverse()
T = []
n = len(S)
for i in range(n):
  T.append(S[i])
  mojiretu = ''.join(T)
  if mojiretu == "maerd" or mojiretu == "remaerd" or mojiretu == "esare" or mojiretu == "resare":
    T =[]
 
N = len(T)
if N == 0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

S = input()
S = list(S)
S.reverse()
T = []
n = len(S)
for i in range(n):
  T.append(S[i])
  mojiretu = ''.join(T)
  m = len(mojiretu)
  if mojiretu == "maerd" or mojiretu == "remaerd" or mojiretu == "esare" or mojiretu == "resare":
    T =[]
  elif m==8:
      break
N = len(T)
if N == 0:
  print("YES")
else:
  print("NO")
### BUGGY CODE ###

import numpy as np

N = int(raw_input())
A = map(lambda x:int(x), raw_input().split())

C = range(N)
A.sort()

A = np.asarray(A)
S = np.zeros_like(A)
s=0
for i in range(N):
    s += A[i]
    S[i] = s

F = np.ones(N, np.int)
for i in range(N):
    FLAG = False
    for j in range(i,N-1):
        if 2*S[j] < A[j+1]:
            FLAG=True
            break
    if FLAG:
        F[i] = 0

print F.sum()

### FIXED CODE ###

import numpy as np

N = int(raw_input())
A = map(lambda x:int(x), raw_input().split())

A.sort()

A = np.asarray(A)
S = np.zeros_like(A)
s=0
for i in range(N):
    s += A[i]
    S[i] = s

#print A
#print S
index = np.where(A[1:] - S[:-1]*2 > 0)[0]
if index.shape[0]:
    print N - index[-1]-1
else:
    print N