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

import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

a.sort()
b.sort()

ans = 0
time = 0

while time <= k:
    if a and b:
        tmp_a = time+a[0]
        tmp_b = time+b[0]
        if tmp_a <= k and tmp_b <= k and a[0] <= b[0]:
            time += a[0]
            a.pop(0)
            ans += 1
        elif tmp_a <= k and tmp_b <= k and b[0] <= a[0]:
            time += b[0]
            b.pop(0)
            ans += 1
        elif tmp_a <= k:
            time += a[0]
            a.pop(0)
            ans += 1
        elif tmp_b <= k:
            time += b[0]
            b.pop(0)
            ans += 1
        else:
            break
    elif a:
        tmp_a = time+a[0]
        if tmp_a <= k:
            time += a[0]
            a.pop(0)
            ans += 1
        else:
            break
    elif b:
        tmp_b = time+b[0]
        if tmp_b <= k:
            time += b[0]
            b.pop(0)
            ans += 1
        else:
            break
    else:
        break

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]: # 前のループで求めたjから走査すれば良い（毎回Mから始める必要はない）
        j -= 1
    ans = max(ans, i + j)

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

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math


#N,K=map(int,input().split())
N=int(input())
S=input()
Q=int(input())


def segfunc(x,y):
    return (x|y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=seg[2*i+1]|seg[2*i+2]

def update(k,b):
    k += num-1
    if seg[k]=={b}:
        return ()
    seg[k] = {b}
    while k:
        k = (k-1)>>1
        seg[k] = seg[k*2+1]|seg[k*2+2]

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=set()
    while q-p>1:
        if p&1 == 0:
            res = res|seg[p]
        if q&1 == 1:
            res = res|seg[q]
            q -= 1
        p = p>>1
        q = (q-1)>>1
    if p == q:
        res = res|seg[p]
    else:
        res = res|seg[p]|seg[q]
    return res

#num:n以上の最小の2のべき乗
n=N
num =2**(n-1).bit_length()
seg=[set()] * (2*num)

for i in range(N):
    seg[i+num-1]={ord(S[i])}
for k in range(num-2,-1,-1):
    seg[k] = seg[k*2+1]|seg[k*2+2]


for q in range(Q):
    type, i, c = input().split()
    if type=="1":
        update(int(i)-1,ord(c))
    else:
        print(len(query(int(i)-1,int(c))))
    #print(seg)


### FIXED CODE ###

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math


#N,K=map(int,input().split())
N=int(input())
S=input()
Q=int(input())
Query=[input().split() for i in range(Q)]

def segfunc(x,y):
    return (x|y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=seg[2*i+1]|seg[2*i+2]

def update(k,b):
    k += num-1
    if seg[k]=={b}:
        return ()
    seg[k] = {b}
    while k:
        k = (k-1)>>1
        seg[k] = seg[k*2+1]|seg[k*2+2]

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=set()
    while q-p>1:
        if p&1 == 0:
            res = res|seg[p]
        if q&1 == 1:
            res = res|seg[q]
            q -= 1
        p = p>>1
        q = (q-1)>>1
    if p == q:
        res = res|seg[p]
    else:
        res = res|seg[p]|seg[q]
    return res

#num:n以上の最小の2のべき乗
n=N
num =2**(n-1).bit_length()
seg=[set()] * (2*num)

for i in range(N):
    seg[i+num-1]={ord(S[i])}
for k in range(num-2,-1,-1):
    seg[k] = seg[k*2+1]|seg[k*2+2]
for type, i, c in Query:
    if type=="1":
        update(int(i)-1,ord(c))
    else:
        print(len(query(int(i)-1,int(c))))
    #print(seg)
### BUGGY CODE ###

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

def ea(a, b) :
    if a%b == 0 :
        return b
    else :
        return ea(b, a%b)

def gcd(list1) :
    for m in range(N-2) :
        list1 = [ea(list1[0], list1[1])] + list1[2:]
    else :
        return list1[0]


ans = 1
for n in range(N) :
    ans = max(ans, gcd(Alist[:n]+Alist[n+1:]))
print(ans)

### FIXED CODE ###

from functools import lru_cache
n = int(input())
aa = list(map(int, input().split()))

@lru_cache(maxsize=10**9)
def gcd(a, b) :
    if b == 0 : return a
    elif a%b : return gcd(b, a%b)
    else : return b

l = [0]
r = [0]
for i in range(n) :
    l.append(gcd(l[-1], aa[i]))
    r.append(gcd(r[-1], aa[-i-1]))

m = [gcd(l[i],r[-i-2]) for i in range(n)]
print(max(m))
### BUGGY CODE ###

n = int(input())
s = [sorted(input()) for i in range(n)]
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
s = sorted([sorted(input()) for i in range(n)])
a = []
last = s[0]
count = 1
for i in range(1, n):
    if s[i] == last:
        count += 1
    else:
        a.append(count)
        count = 1
    last = s[i]
a.append(count)
ans = 0
for i in a:
    if i > 1:
        ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

import sys

def srch(id1, id2, D, L):
    cnt = 0

    S = [id1]
    while(len(S) > 0):
        u = S.pop()
        #print("cnt:{} id2:{} u:{} D:{} S:{}".format(cnt, id2, u, D[u], S))
        if L[u] == -1:
            L[u] = cnt
            cnt += 1
            if u == id2:
                return
            if D[u] is not None:
                A = D[u][:]
                while(len(A)):
                    u1 = A.pop()
                    if L[u1] == -1:
                        S.append(u1)
    

def main():
    istr = sys.stdin.read()
    ilist = []
    for i in istr.splitlines():
        ilist.append(list(map(int,i.split())))
    #print(ilist)
    unum, fnum = ilist[0]

    Dst = [[] for i in range(unum)]
    fnum += 1
    for n in range(1, fnum):
        uid, fid = ilist[n]
        Dst[uid].append(fid)
        Dst[fid].append(uid)
    
    qnum = ilist[fnum][0]
    fnum += 1
    #print("fnum={} qnum={}".format(fnum,qnum))
    for q in range(fnum, (fnum + qnum)):
        id1, id2 = ilist[q]
        F = [-1] * (unum)
        #print("\n[{}] id1={:2} id2={:2} D:{}".format(q,id1, id2, Dst))
        srch(id1, id2, Dst, F)
        if F[id2] != -1:
            print("yes")
        else:
            print("no")

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def Grouping(F):
    n = len(F)
    G = [None for i in range(n)]
    for u in range(n):
        if G[u] is None:
            G[u] = u
            S = [u]
            while(len(S) > 0):
                u1 = S.pop()
                for u2 in F[u1]:
                    if G[u2] is None:
                        G[u2] = u
                        S.append(u2)
    return G

def main():
    istr = sys.stdin.read()
    ilist = istr.splitlines()
    unum, fnum = list(map(int,ilist[0].split()))

    F = [[]  for i in range(unum)]
    fnum += 1
    for n in range(1, fnum):
        uid, fid = map(int,ilist[n].split())
        F[uid].append(fid)
        F[fid].append(uid)
    
    G = Grouping(F)

    qnum = int(ilist[fnum])
    fnum += 1
    for q in range(fnum, (fnum + qnum)):
        id1, id2 = map(int,ilist[q].split())
        if G[id1] == G[id2]:
            print("yes")
        else:
            print("no")

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input=sys.stdin.readline

def is_prime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False
    return True

def make(n):
    ans=[]
    for i in range(2,n+1):
        if is_prime(i):
            ans.append(i)
    return ans

if __name__ == '__main__':
    Q=int(input())
    Queries=[list(map(int,input().split())) for i in range(Q)]

    for l,r in Queries:
        count=0
        p_list=make(r)
        for i in range(l,r+1,2):
            if i in p_list:
                if (i+1)//2 in p_list:
                    count+=1
        print(count)

### FIXED CODE ###

import sys
input=sys.stdin.readline

def Eratosthenes():
    num=[True for i in range(100001)]
    num[0]=False
    num[1]=False
    for i in range(2,100001):
        if num[i]:
            for j in range(2*i,100001,i):
                num[j]=False
    return num

if __name__ == '__main__':
    Q=int(input())
    Queries=[list(map(int,input().split())) for i in range(Q)]
    p_list=Eratosthenes()
    dp=[0 for _ in range(100001)]
    for i in range(3,100000):
        if p_list[i] and p_list[(i+1)//2]:
            dp[i+1]=dp[i]+1
        else:
            dp[i+1] = dp[i]
    for l,r in Queries:
        print(dp[r+1]-dp[l])
### BUGGY CODE ###

n = int(input())
spotStrList = input().split()
result = 0
spotList = ['0']
for x in range(n):
    spotList.append(spotStrList[x])
spotList.append('0')

def travelfrom(spotNum, skipNum):
    if spotNum == skipNum:
        return 0
    elif spotNum == skipNum -1:
        return abs(int(spotList[spotNum+2])-int(spotList[spotNum]))
    else:
        return abs(int(spotList[spotNum+1])-int(spotList[spotNum]))
              
for i in range(n):
    for spot in range(n+1):
        result += travelfrom(spot,i+1)
    print(result)
    result=0

### FIXED CODE ###

distanceSum = 0
spotCount = int(input())
spotList = input().split()
spotList = [int(i) for i in spotList]
spotList.append(0)

def calcDistance(num): # 配列num-1番のスポットから配列num番目のスポットへの距離を計算
    if num == 0: #開始地点から配列0番＝最初のスポット
        return abs(spotList[num])
    elif num == spotCount: #最後スポットから開始地点
        return abs(spotList[num-1])
    else:
        return abs(spotList[num]-spotList[num-1])

def calcSkipEffect(num): #配列num番をスキップした時の移動距離への影響を計算
    if num == 0: #最初のスポットの時だけの例外
        return abs(spotList[num+1])-abs(spotList[num])-abs(spotList[num+1]-spotList[num])
    else:
        return abs(spotList[num+1]-spotList[num-1])-abs(spotList[num]-spotList[num-1])-abs(spotList[num+1]-spotList[num])

for i in range(spotCount+1): #総移動回数はスポット数+1
    distanceSum += calcDistance(i)
    
for j in range(spotCount): #配列0～n-1番までの各スポットについて実行
    print(str(distanceSum + calcSkipEffect(j)))
### BUGGY CODE ###

import random
import time
import numpy as np

def decrease(day, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(day):
        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (now - date[i])
        ret += tmp
        satisfy.append(tmp)

    return ret

def change(_from, _to, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(_to):
        if d < _from:
            ret += satisfy[d]
            continue

        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (now - date[i])
        ret += tmp
        satisfy[d] = tmp

    return ret

def Main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    
    dissatisfy=[]
    schedule = []
    score = 0
    start = time.time()

    #最大値を足すだけ
    for i in range(D):
        schedule.append(np.argmax(s[i]))
        score += np.max(s[i])
    
    ans = score - decrease(D, schedule, c, s, dissatisfy)
    
    while time.time() - start < 1.9:
        contest = random.randint(0, 25)
        day = random.randint(0, D - 1)
        save = dissatisfy.copy()
        dec = change(day + 1, D, schedule, c, s, dissatisfy)
        score2 = score - s[day][schedule[day]] + s[day][contest]

        if ans < score2 - dec:
            ans = score2 - dec
            score = score2
            schedule[day] = contest
        else:
            dissatisfy = save
        
    for i in range(D):
        print(schedule[i] + 1)

if __name__ == "__main__":
    Main()

### FIXED CODE ###

d = int(input())
c = list(map(int, input().split()))

for _ in range(d):
    s = list(map(int, input().split()))
    ret = -20000
    ans = 1
    for i in range(26):
        tmp = s[i] - c[i] * 200
        if ret < tmp:
            ret = tmp
            ans = i + 1
    print(ans)
### BUGGY CODE ###

import math

H, W, A, B = map(int, input().split())

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def solve():
    ans = 0
    an = H + B - A - 1
    ar = B
    bn = W + A - B - 2
    br = W - B - 1
    for i in range(W-B):
        a = comb(an, ar)
        b = comb(bn, br)
        ans += a * b
        an += 1; ar += 1
        bn -= 1; br -= 1
    return ans%(10**9+7)

print(solve())


### FIXED CODE ###

MAX = 510000
MOD = 1000000007

fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
        
def comb(n, r):
    if n < r:           return 0
    if n < 0 or r < 0:  return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD

def solve():
    ans = 0
    an = H + B - A - 1
    ar = B
    bn = W + A - B - 2
    br = W - B - 1
    for i in range(W-B):
        a = comb(an, ar)
        b = comb(bn, br)
        ans += (a * b) % MOD
        an += 1; ar += 1
        bn -= 1; br -= 1
    return ans % MOD

H, W, A, B = map(int, input().split())

comb_init()
print(solve())
### BUGGY CODE ###

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

for i in range(n):
    i = i + 1
    if(i == n):
        print(0)
    else:
        print(l_a.count(i))

### FIXED CODE ###

import collections

n = int(input())
l_a = list(map(int, input().split()))
k_a = collections.Counter(l_a)

for i in range(n):
    print(k_a[i+1])
### BUGGY CODE ###

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

p=[0]*n
p[0]=1
now=1
cnt=0
while 0 in p and cnt<=m:
    for to in l[now-1]:
        if p[to]==0:
            p[to]=now
            cnt+=1
    now=to+1
if 0 in p:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(p[i])

### FIXED CODE ###

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

from collections import deque

p=[0]*n
ans=[0]*n
d=deque()
d.append(0)
while len(d)!=0:
    now=d.popleft()
    for to in l[now]:
        if p[to]==0:
            p[to]=p[now]+1
            d.append(to)
            ans[to]=now
print("Yes")
for i in range(1,n):
    print(ans[i]+1)
### BUGGY CODE ###

n = int(input())
s = list(input())
l = set()
for i in range(n - 2):
    for j in range(i+1, n - 1):
        for k in range(j+1, n):
            l.add(s[i] + s[j] + s[k])
            #print(s[i] + s[j] + s[k])
print(len(l))



### FIXED CODE ###

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

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            #print(str(i) + str(j)+ str(k))
            fi = s.find(str(i))
            if fi < 0:
                continue
            fj = s[fi+1:].find(str(j))
            if fj < 0:
                continue
            fk = s[(fi+1)+(fj+1):].find(str(k))
            if fk < 0:
                continue
            #print(str(i) + str(j)+ str(k), str(fi) + str(fj)+ str(fk))
            ans += 1
print(ans)
### BUGGY CODE ###

k = int(input())
s = 7
counter = 0
mod_box=[]


if k % 2 == 0:
    print(-1)

else:
    m = s % k
    counter += 1
    if m == 0:
        print(counter)
    else:
        while True:
            mod_box.append(m)
            m = (10 * m + 7) % k
            counter += 1
            if m == 0:
                print(counter)
                break
            elif m in mod_box:
                print(-1)

        
    


### FIXED CODE ###

k = int(input())
m = 7%k

for i in range(1, 10**6+1):
    if m == 0:
        print(i)
        exit()
    else:
        m = (10 * m + 7) % k

print(-1)
### BUGGY CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
# dp[i] i個の石で手番の時の勝ち負け
dp = [0]*(k+1)
# 貰う
for i in range(1, k+1):
    for j in range(n):
        if i-A[j] < 0:
            continue
        dp[i] = max(dp[i], 1 if dp[i-A[j]] == 0 else 0)
print('First' if dp[k] else 'Second')


### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
# dp[i] i個の石で手番の時の勝ち負け
dp = [0]*(k+1)
# 貰う
for i in range(1, k+1):
    for j in range(n):
        if i-A[j] < 0:
            continue
        dp[i] = max(dp[i], 1 if dp[i-A[j]] == 0 else 0)
print('First' if dp[k] else 'Second')
### BUGGY CODE ###

N = int(input())
s = list(input())

cnt = 0
prej = N
for i in range(N):
    if s[i] == "R":
        continue
    for j in list(range(i+1,prej))[::-1]:
        if s[j] == "W":
            continue
        if i >= j:
            break
        cnt += 1 
        prej = j
        break
print(cnt)

### FIXED CODE ###


N = int(input())
s = list(input())

reds = 0
for c in s:
    reds += 1 if c == "R" else 0

whites = 0
for i in range(reds):
    whites += 1 if s[i] == "W" else 0

print(whites)
### BUGGY CODE ###

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

S = set(range(N))

for _ in range(M):
  A, B = map(int, input().split())
  A = A - 1
  B = B - 1
  A_height = H[A]
  B_height = H[B]
  
  if A_height <= B_height:
    S = S - set([A])
  
  if B_height <= A_height: 
    S = S - set([B])
    
  
  
print(len(S)) 
 

### FIXED CODE ###

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


A_list = []
B_list = []
Remove_list = []

for _ in range(M):
  A, B = map(int, input().split())
  A_list.append(A - 1)
  B_list.append(B - 1)

for A, B in zip(A_list, B_list):
  A_height = H[A]
  B_height = H[B]
  
  if A_height <= B_height:
    Remove_list.append(A)
  
  if B_height <= A_height: 
    Remove_list.append(B)
  
S = set(range(N))
S = S - set(Remove_list)

print(len(S))
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))

# print( (max(sum(P[i:i+K]) for i in range(0, N-K+1)) + K)/2 )

result = 0
for i in range(0, N-K+1):
    tmp = sum(P[i:i+K])
    if (tmp > result):
        result = tmp

print((result+K)/2)

### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))

# print( (max(sum(P[i:i+K]) for i in range(0, N-K+1)) + K)/2 )

tmp = sum(P[0:K])
result = tmp

for i in range(1, N-K+1):
    tmp += (P[i+K-1] - P[i-1])
    if (tmp > result):
        result = tmp

print((result+K)/2)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
      if max(a) == a[i]:
            print(sorted(a)[-2])
      else:
            print(max(a))


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

m1 = max(a)
m2 = sorted(a)[-2]
for i in range(n):
      if m1 == a[i]:
            print(m2)
      else:
            print(m1)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] >= 0:
        res *= A[i];
    if res > 1e+18:
        res = -1

if res > 1e+18: print("-1")
else          : print(res)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
res = 1
for i in range(N):
    if A[i] == 0:
        res = 0
    if res < 0:
        continue
    res *= A[i];
    if res > 1e+18:
        res = -1

print(res)
### BUGGY CODE ###

n=int(input())

a=1
while True:
    t=a*(a-1)//2
    if t>n:
        print("No")
        exit()
    if t==n:
        print("Yes")
        break
    a+=1
print(a)
s=set()
for i in range(1,1+n):
    s.add(i)
l=[0]*(n+1)
ans=[set()]

for i in range(a):
    ll=set()
    for j in ans[:i+1]:
        for p in s&j-ll:
            if p not in ll:
                ll.add(p)
                if l[p]==1:
                    s.remove(p)
                else:
                    l[p]+=1
                break

    for p in s:
        if len(ll)>=n*2//a:
            break
        else:
            if l[p]==0:
                ll.add(p)
                l[p]+=1

    ans.append(ll)
    print(n*2//a,*ll)

### FIXED CODE ###

def main():
    n=int(input())
    m=int((2*n)**0.5)
    if m*(m+1)==n*2:
        print("Yes")
        m+=1
        print(m)
    else:
        print("No")
        exit()
    
    ans=[[m-1] for i in range(m)]
    c=1
    for i in range(m):
        for j in range(i+1,m):
            ans[i].append(c)
            ans[j].append(c)
            c+=1
    for i in ans:
        print(*i)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
xy=[]
for a in range(X):
    for b in range(Y):
        xy.append(A[a]+B[b])
xy=sorted(xy,reverse=True)
xy=xy[:K]
xyz=[]
for x in xy:
    for c in range(Z):
        xyz.append(x+C[c])
xyz=sorted(xyz,reverse=True)
for i in range(K):
    print(xyz[i])


### FIXED CODE ###

X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)
xy=[]
for a in A:
    for b in B:
        xy.append(a+b)
xy=sorted(xy,reverse=True)
xy=xy[:K]
xyz=[]
for c in C:
    for x in xy:
        xyz.append(x+c)
xyz=sorted(xyz,reverse=True)
for i in range(K):
    print(xyz[i])
### BUGGY CODE ###

from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = Counter([int(_) for _ in stdin.readline().rstrip().split()])
Q = int(stdin.readline().rstrip())
BC = [list(map(int, stdin.readline().rstrip().split())) for _ in range(Q)]
ans = []
for bc in BC:
    if bc[1] not in A:
        A[bc[1]] = A[bc[0]]
    else:
        A[bc[1]] += A[bc[0]]
    A.pop(bc[0], None)
    ans.append(sum(k*v for k, v in A.items()))
for a in ans:
    print(a)

### FIXED CODE ###

from collections import Counter
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
CA = Counter(A)
Q = int(stdin.readline().rstrip())
ans = sum(A)
for i in range(Q):
    b, c = [int(_) for _ in stdin.readline().rstrip().split()]
    ans += (c-b)*CA[b]
    CA[c] += CA[b]
    CA[b] = 0
    print(ans)
### BUGGY CODE ###

# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
#S =input().strip()
*S, = input() 
count =0
flag =1
while len(S) >=2 and flag==1:
    flag =0
    for i in range(len(S)-1):
        if S[i:i+2] ==["1","0"] or S[i:i+2] ==["0","1"]:
            #print(S[i:2])
            del S[i:i+2]
            #print(S,end=" ")
            count +=2
            #print(count)
            flag =1
            break
print(count)

### FIXED CODE ###

#計算でもとまるのか・・・
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
#*S, = input() 
S =input().strip()
c1 =S.count("1")
c0 =S.count("0")
print(min(c0,c1)*2)
### BUGGY CODE ###

n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

i = 0
j = len(ls) - 1
k = j - 1
res = []

while i < len(ls) - 1:
    while i < j:
        while i < k:
            if ls[j] - ls[i] < ls[k]:
                res.append((ls[i], ls[j], ls[k]))
                k -= 1
            else:
                break
        j -= 1
        k = j - 1
    i += 1
    j = len(ls) - 1
    k = j - 1
print(len(res))

### FIXED CODE ###

import bisect

n = int(input())
ls = [int(elem) for elem in input().split()]
ls = sorted(ls)

cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = bisect.bisect_left(ls, ls[i] + ls[j])
        k -= 1
        cnt += k - j
print(cnt)