Harryxun/stf_run huggingface dataset:
N=int(input())
ls=[[int(s) for s in input().split()] for i in range(N)]
flag2=0
for i in range(N):
  if ls[i][2]!=0:
    a=ls[i][0]
    b=ls[i][1]
    h_base=ls[i][2]
    ls.pop(i)
    break
else:
  flag2=1
if flag2==0:
  for x in range(101):
    for y in range(101):
      ##x,yの高さを計算
      h=h_base+abs(x-a)+abs(y-b)
      ##他の条件と合うか？
      flag=1
      for e in ls:
        if h!=e[2]+abs(x-e[0])+abs(y-e[1]):
          flag=0
          break
      if flag==1:
        ans=[x,y,h]
        break
    if flag==1:
      break
else:
  xsum=0
  ysum=0
  for e in ls:
    xsum+=e[0]
    ysum+=e[1]
  ans=[5050-xsum,5050-ysum,1]
print(*ans)  
      
        
      
      
    
  

### FIXED CODE ###

N=int(input())
ls=[[int(s) for s in input().split()] for i in range(N)]
ans=[0,0,0]
for i in range(N):
  if ls[i][2]!=0:
    a=ls[i][0]
    b=ls[i][1]
    h_base=ls[i][2]
    ls.pop(i)
    break
for x in range(101):
  for y in range(101):
    ##x,yの高さを計算
    h=h_base+abs(x-a)+abs(y-b)
    ##他の条件と合うか？
    flag=1
    for e in ls:
      if (h!=e[2]+abs(x-e[0])+abs(y-e[1]) and e[2]>0): 
        flag=0
        break
      if (h>e[2]+abs(x-e[0])+abs(y-e[1]) and e[2]==0):
        flag=0
        break
    if flag==1:
      ans=[x,y,h]
      break
  if flag==1:
    break
print(*ans)
int = list(map(int,input().split()))

k = int[0]
x = int[1]

p = range(x + 1 - k,x + k)

print(list[p])

### FIXED CODE ###

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

k = int[0]
x = int[1]

p=x + 1 
q=p - k
r=x + k

s =list(range(q,r))
print(*s)
N = int(input())
D = list(map(int, input().split()))
if (D[0]!=0) or (0 in D[1:]):
  print(0)
else:
  mapping = dict()
  max_ = 0
  for n in D[1:]:
    if n in mapping:
      mapping[n]+=1
    else:
      mapping[n]=1
      if max_ < n :
        max_ = n
  ans=1
  for i in range(1,max_):
    ans *= mapping[i]**(mapping[i+1])
print(ans)

### FIXED CODE ###

N = int(input())
D = list(map(int, input().split()))
if (D[0]!=0) or (0 in D[1:]):
  print(0)
else:
  mapping = dict()
  max_ = 0
  for n in D[1:]:
    if n in mapping:
      mapping[n]+=1
    else:
      mapping[n]=1
      if max_ < n :
        max_ = n
  ans=1
  for i in range(1,max_):
    if (i in mapping) and (i+1 in mapping):
      ans *= mapping[i]**(mapping[i+1])
    else:
      ans = 0
      break
  print(ans % 998244353)
string = str(input())

pairs = 0
limit = len(string)-4
secondLimit = len(string)
substringArray = list()
substringArray.append(string[0])
for i in range(1, secondLimit):
  substringArray.append(substringArray[i-1] + string[i])

for i in range(0,limit):
  for j in range(i+3,secondLimit):
    print(substringArray[j][i:])
    if j >= 3 and int(substringArray[j][i:]) % 673 == 0:
      pairs += 1
print(pairs)

### FIXED CODE ###

number = str(input())[::-1]
remainderDictionary = {0: 1}
    
sum = 0
x = 1
for i in number:
  x = (x * 10) % 2019
  sum += int(i) * x
  sum %= 2019
  remainderValue = remainderDictionary.get(sum,0) + 1
  remainderDictionary[sum] = remainderValue
     
ans = 0
for i in remainderDictionary:
  value = remainderDictionary[i]
  ans += value * (value - 1) // 2 # N C 2
print(ans)
n=int(input())
a=[]
for _ in range(n):
    a.append(list(map(int,input().split())))
dp=[0]*n
for i in range(3):
  dp[i]=a[0][i]
for k in range(1,n):
    m=[0]*3
    for i in range(3):
        for j in range(3):
            if i!=j:
                m[i]=max(m[i],dp[j]+a[k][i])
    dp=m
print(max(m))


### FIXED CODE ###

n=int(input())
a=[]
for _ in range(n):
    a.append(list(map(int,input().split())))
for i in range(1,n):
    a[i][0]+=max(a[i-1][1],a[i-1][2])
    a[i][1]+=max(a[i-1][0],a[i-1][2])
    a[i][2]+=max(a[i-1][1],a[i-1][0])
print(max(a[n-1]))
T,X = map(int,input())

print(T/X)

### FIXED CODE ###

T,X = map(int,input().split())

print(T/X)
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np
 
DIV_NUM = 1000000000 + 7
 
INPUT_NUMS = list(map(int, input().split()))
N=int(INPUT_NUMS[0])
K=int(INPUT_NUMS[1])
 
A = [int(x) for x in input().split()]
AA = np.array(A)
if N==1:
    print(0)
    exit()
 
tree = np.array([0] * (N+1) )
 
# https://atcoder.jp/contests/chokudai_S001/submissions/6789704
def BIT_update(tree,x):
    while x <= N:
        tree[x] += 1
        x += x&(-x)
def BIT_sum(tree,x):
    s = 0
    while x:
        s += tree[x]
        x -= x&(-x)
    return s
 
answer = N*(N-1)//2
for x in AA:
    answer -= BIT_sum(tree,int(x))
    BIT_update(tree,int(x))
 
B = sorted(A)
 
q=0
p=B[0]
r=0
for i in range(1,N):
    if B[i]>p:
        p=B[i]
        r=i
    q += r
 
# print(answer,K)
answer = answer % DIV_NUM
answer = int(answer)
answer = (answer * K) % DIV_NUM
q = q % DIV_NUM
answer = answer + q * K * (K-1) // 2
answer = answer % DIV_NUM
print(answer)
 

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

DIV_NUM = 1000000000 + 7

INPUT_NUMS = list(map(int, input().split()))
N=int(INPUT_NUMS[0])
K=int(INPUT_NUMS[1])

A = [int(x) for x in input().split()]
AA = np.array(A)
if N==1:
    print(0)
    exit()

# https://kira000.hatenadiary.jp/entry/2019/02/23/053917
def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt

answer = bubble_sort(AA)

B = sorted(A)
q=0
p=B[0]
r=0
for i in range(1,N):
    if B[i]>p:
        p=B[i]
        r=i
    q += r

# print(answer,K)
answer = answer % DIV_NUM
answer = int(answer)
answer = (answer * K) % DIV_NUM
q = q % DIV_NUM
answer = answer + q * K * (K-1) // 2
answer = answer % DIV_NUM
print(answer)
print(y+x)

### FIXED CODE ###

x, y = input().split()
print(y+x)
def main():
    import fractions
    def gcd(li):
        fractions.reduce(fractions.gcd, li)

    n, k, *a = map(int, open(0).read().split())
    g = gcd(a)
    if max(a)>=k and k%g==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    import fractions, functools
    def gcd(li):
        return functools.reduce(fractions.gcd, li)

    n, k, *a = map(int, open(0).read().split())
    g = gcd(a)
    if max(a)>=k and k%g==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == "__main__":
    main()
import numpy as np

x = map(int,input().split())
x.sort()
sum = np.sum(x)
print('%s %s %s'%(max(x),min(x),sum))


### FIXED CODE ###

n = input()
x = list(map(int,input().split()))
x.sort()
print('%s %s %s'%(min(x),max(x),sum(x)))
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
n = 1
a.insert(0, -1)
a.append(N + 1)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def v(x):
    if x == -1:
        return 1
    else:
        q = x // 2
        r = x % 2
        ans = 0
        for i in range(x // 2 + 1):
            ans += cmb(q + r, r)
            r = r + 2
            q = q - 1
        return ans
for i in range(M + 1):
    if a[i + 1] - a[i] == 1:
        print(0)
        exit()

for i in range(M + 1):
    n *= v((a[i + 1] - 1) - (a[i] + 1))

print(n % 1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * (N + 1)
n[0] = 1
n[1] = 1

#listの中をinで探すのはくっそ遅い
if 1 in a:
    n[1] = 0

for i in range(2, N + 1):
    if i in a:
        continue
    else:
        n[i] = (n[i - 1] + n[i - 2]) % 1000000007

print(n[N])
n=int(input())
a=tuple(map(int,input().split()))

import fraction
from functools import reduce

def gcd(*numbers):
    return reduce(fraction.gcd, numbers)

dp=[]
for i in range(n):
    aa=list(a)
    del aa[i]
    dp.append(gcd(*aa))

print(max(dp))

### FIXED CODE ###

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

def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

l=[0]*(n+1)
r=[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])
for i in range(n,0,-1):
    r[i-1]=gcd(r[i],a[i-1])

m=[]
for i in range(n):
    m.append(gcd(l[i],r[i+1]))

print(max(m))
a, b = [int(x) for x in input.split()]
print(a * b, 2 * (a + b))

### FIXED CODE ###

a, b = [int(x) for x in input().split()]
print(a * b, 2 * (a + b))
from collections import deque

def cndP(w):
    if len(w)>1:
        x = w.pop()
        cndP(w.copy())
        w.append(x)
        s = 0
        while(len(w)>0):
            s += w.pop()
            st.add(s)
    else:
        st.add(w[0])
        
def pIsAccptbl(w,k,p):
    tr = 0
    c = 0
    d = w.copy()
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

n,k = [int(x) for x in input().split()]
w = deque()

for i in range(n):
    w.append(int(input()))
    
st = set()
cndP(w.copy())

### FIXED CODE ###

from collections import deque

def isPa(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP or minP == maxP):
            print(maxP)
            break
import math
a, b, c, d = map(int, input().split())
ans = b - a + 1
lcm = c * d // math.gcd(c, d)
def calc(d):
    global a, b
    c1 = (a - 1) // d
    c2 = b // d
    return c2 - c1
print(ans - calc(c) - calc(d) + calc(lcm))


### FIXED CODE ###

a, b, c, d = map(int, input().split())
ans = b - a + 1

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

def calc(d):
    global a, b
    c1 = (a - 1) // d
    c2 = b // d
    return c2 - c1

lcm = c * d // gcd(c, d)
print(ans - calc(c) - calc(d) + calc(lcm))
print(a//b,a%b,"{0:.5f}".format(a/b))

### FIXED CODE ###

a,b=list(map(int,input().split()))
print(a//b,a%b,"{0:.5f}".format(a/b))
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
 
import itertools
hoges = {}
for i in itertools.combinations(xy, 2):
    if i[0][0] - i[1][0] >= 0:
        hoge = (i[0][0] - i[1][0], i[0][1] - i[1][1])
    else:
        hoge = (i[1][0] - i[0][0], i[1][1] - i[0][1])
    hoges.setdefault(hoge, 0)
    hoges[hoge] += 1
# print(hoges)
max_v = max(hoges.values())
print(N - max_v)

### FIXED CODE ###

def fn(n):
  if n % 2 == 0:
    return n/2
  else:
    return 3*n + 1

s = int(input())
  
al = []
al.append(s)
cnum = s
for i in range(2,1000000):
  cnum = fn(cnum)
  if cnum in al[:-1]:
    print(i)
    exit()
  else:
    al.append(cnum)
n=int(input())
l=[int(input().split()) for _ in range(n)]

ans=1
a=l[0]
for i in range(n-1):
  if a<=l[i+1]:
    ans+=1
    a=max(a,l[i])

print(ans)

### FIXED CODE ###

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

ans=1
a=l[0]
for i in range(n-1):
  if a<=l[i+1]:
    ans+=1
    a=l[i+1]

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

n=int(input())
al=input().split()
al_i = [int(s) for s in al]

if (n == 2):
   print(gcd(al_i[0],al_i[1]))
   return

fg = [0] * n
bg = [0] * n

for x in range(n):
   if (x == 0):
       fg[0] = al_i[0]
       y = 1
   else:
      while y <= x:
         fg[y] = gcd(fg[y-1], al_i[y])
         y += 1

for x in range(n):
   if (x == 0):
      bg[0] = al_i[n-1]
      y = 1
   else:
      while y <= x:
         bg[y] = gcd(bg[y-1], al_i[n-1-y])
         y += 1

m = 0
gm = 0

for x in range(n):
   if (x == 0):
      g = bg[n-2]
   elif (x == n):
      g = fg[n-2]
   else:
      g = gcd(fg[x-1],bg[n-2-x])
   if (g > gm):
      gm = g

print(gm)


### FIXED CODE ###

a,b,t=(int(x) for x in input().split())
print(int((t+0.5)/a)*b)
import math
a, b, n = map(int, input().split())
if n < b:
    print(math.floor((a * n) / b))
else:
    print(math.floor((a * n) / (b - 1)))

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
if n < b:
    print(math.floor((a * n) / b))
else:
    print(math.floor(a * (b - 1) / b) - a * math.floor((b - 1) / b))
x =input().split()
for i in range(4): x[i] = int(x[i])
e =a+b
f =c+d
if e > f:
  print("Left")
elif e<f:
  print("Right")
else : print("Balanced")

### FIXED CODE ###

x =input().split()
for i in range(4): x[i] = int(x[i])
e =x[0]+x[1]
f =x[2]+x[3]
if e > f:
  print("Left")
elif e<f:
  print("Right")
else : print("Balanced")
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
p = map(int, input().split())

p = sorted(p)
print(sum(p:[K]))


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
p = map(int, input().split())

p = sorted(p)
print(sum(p[:K]))
n, l = map(int, input().split())
S = []
for i in n:
  S[i] = input()
ans = ''.jion(sorted(S))
print(ans)

### FIXED CODE ###

n, l = map(int, input().split())
k = [input() for x in range(n)]
print(''.join(sorted(k)))
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=split(readline())
    if sqrt(parseFloat(a))+sqrt(parseFloat(b))<sqrt(parseFloat(c))
        println("Yes")
    else
        println("No")
    end
end
main()

### FIXED CODE ###

from math import ceil,floor,sqrt
from collections import deque,Counter
from decimal import Decimal
a,b,c=[int(i) for i in input().split()]
print("Yes" if Decimal(a).sqrt()+Decimal(b).sqrt()<Decimal(c).sqrt() else "No")
N = int(input())
a = list(map(int, input().split()))

print(abs(max(a)-min(a))

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
 
print(abs(max(a)-min(a)))
T = input()
lenT = len(T)
a = T.replace("eraser","xxxxxx")
b = a.replace("dreamer","xxxxxxx")
c = b.replace("erase","xxxxx")
d = c.replace("dream","xxxxx")
D = d.count("x")
if D == lenT:
  print("YES")
else D < lenT:
  print("NO")

### FIXED CODE ###

S=str(input()) #Sの入力
Smojisuu=len(S)
c=S.count("eraser")
S=S.replace("eraser","xxxxxx",c)
d=S.count("erase")
S=S.replace("erase","xxxxx",d)
e=S.count("dreamer")
S=S.replace("dreamer","xxxxxxx",e)
f=S.count("dream")
S=S.replace("dream","xxxxx",f)
g=S.count("x")
if len(S)>g:
  print("NO")
elif len(S)==g:
  print("YES")
else:
  print("error")
N, A, B = input().split()

n = int(N / (A + B))

if(N <= A+B):
    print(A)
else:
    print(N - B*n)

### FIXED CODE ###

S = input()

if(S == "AAA"):
    print('No')
elif(S == "BBB"):
    print('No')
else:
    print('Yes')
s,t = map(int,input().split());print(max( for i in range(3))

### FIXED CODE ###

number = input()
lis = number.split()


for num in range(len(lis)-1):
    add = int(lis[num]) + int(lis[num+1])
    pull = int(lis[num]) - int(lis[num+1])
    product = int(lis[num]) * int(lis[num+1])


mostbig = max([add,pull,product])
print(mostbig)
import heapq
N,K=map(int,input().split())
A=list(map(int,input().split()))
hq=[]
for i in A:
    heapq.heappush(hq,-i)
while K>0:
    t1=heapq.heappop(hq)
    t2=heapq.heappop(hq)
    if t1==t2 or K<3:
        heapq.heappush(hq,t1/2)
        heapq.heappush(hq,t1/2)
        heapq.heappush(hq,t2)
        K-=1
    else:
        heapq.heappush(hq,t1/3)
        heapq.heappush(hq,t1/3)
        heapq.heappush(hq,t1/3)
        heapq.heappush(hq,t2)
        K-=2
print(int(-(heapq.heappop(hq)//1)))

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
low=0
high=max(A)
while high-low>1:
    mid=(low+high)//2
    cnt=0
    for i in A:
        cnt+=(i-1)//mid
    if cnt>K:
        low=mid
    else:
        high=mid
print(high)
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

sumlist1 = [[0]*N for _ in range(N)]
walist = [[0]*N for _ in range(N)]
loopcount = [0]*N

for h in range(N):
    sumlist1[h][0] = C[h]
    walist[h][0] = C[h]
    now = h
    l = 0
    for i in range(1,N):
        now = P[now]-1

        if sumlist1[h][i-1] < 0:
            sumlist1[h][i] = C[now]
        else:
            sumlist1[h][i] += sumlist1[h][i-1] + C[now]
        walist[h][i] += walist[h][i-1] + C[now]
        
        l += 1
        if now == h:
            break
    else:
        l += 1
    loopcount[h] = l
#print(sumlist1)

maxlist = [0]*N
for i in range(N):
    T = loopcount[i]
    wa = walist[i][T-1]
    #print(wa)

    loop = K//T
    amari = K%T

    if wa >= 0:
        if loop == 0:
            if amari != 0:
                maxlist[i] = wa*loop + max(sumlist1[i][:amari])
            else:
                maxlist[i] = max(sumlist1[i][:amari])
        else:
            if amari != 0:
                maxlist[i] = max(wa*loop + max(sumlist1[i][:amari]), wa*(loop-1) + max(sumlist1[i]))
            else:
                maxlist[i] = max(wa*loop, wa*(loop-1) + max(sumlist1[i]))
            

    else:
        if loop == 0:
            maxlist[i] = max(sumlist1[i][:amari])
        else:
            maxlist[i] = max(sumlist1[i])

print(max(maxlist))
print(sumlist1)

### FIXED CODE ###

import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9+7

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

sumlist1 = [[0]*N for _ in range(N)]
walist = [[0]*N for _ in range(N)]
loopcount = [0]*N

for h in range(N):
    sumlist1[h][0] = C[h]
    walist[h][0] = C[h]
    now = h
    l = 0
    for i in range(1,N):
        now = P[now]-1

        if sumlist1[h][i-1] < 0:
            sumlist1[h][i] = C[now]
        else:
            sumlist1[h][i] += sumlist1[h][i-1] + C[now]
        walist[h][i] += walist[h][i-1] + C[now]
        
        l += 1
        if now == h:
            break
    else:
        l += 1
    loopcount[h] = l
#print(sumlist1)

maxlist = [0]*N
for i in range(N):
    T = loopcount[i]
    wa = walist[i][T-1]
    #print(wa,T)

    loop = K//T
    amari = K%T

    if wa >= 0:
        if loop == 0:
            if amari != 0:
                maxlist[i] = wa*loop + max(sumlist1[i][:amari])
            else:
                maxlist[i] = max(sumlist1[i][:amari])
        else:
            if amari != 0:
                maxlist[i] = max(wa*loop + max(sumlist1[i][:amari]), wa*(loop-1) + max(sumlist1[i]))
            else:
                maxlist[i] = max(wa*loop, wa*(loop-1) + max(sumlist1[i][:T]))
            

    else:
        if loop == 0:
            maxlist[i] = max(sumlist1[i][:amari])
        else:
            maxlist[i] = max(sumlist1[i])

print(max(maxlist))
#print(sumlist1)
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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
ans=p+q
ans.sort(reverse=True)
ans=[0]+ans
nowi=x+y
r=[0]+r
nowr=0
while nowr<=c+1 and nowi>0 and r[nowr+1]>ans[nowi]:
  nowi+=-1
  nowr+=1
ans_=0
for i in range(nowi+1):
  ans_+=ans[i]
for j in range(nowr+1):
  ans_+=r[j]
print(ans_)

### 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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
ans=p+q+r
ans.sort(reverse=True)
print(sum(ans[:x+y]))
if N == 0:
    P = []
else:
    P = [int(x) for x in input().split()]

for i in range(100):
    q = X - i
    if q not in P:
        print(q)
        break
    q = X + i
    if q not in P:
        print(q)
        break

### FIXED CODE ###

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

if N == 0:
    P = []
else:
    P = [int(x) for x in input().split()]

for i in range(100):
    q = X - i
    if q not in P:
        print(q)
        break
    q = X + i
    if q not in P:
        print(q)
        break
cards = [input() for i in range(3)]

now = 0
index =[0,0,0]
dic={"a":0,"b":1,"c":2}

while True:
    if index[now] == len(cards[now]):
        break
    idx = index[now]
    index[now] += 1
    now = dic[cards[now][idx]]
    

print("ABC"[now])


### FIXED CODE ###

import math 
a = int(input())
b = int(input())
c = int(input())

print(math.floor((a+b)*c/2))
from sys import stdin
import itertools
import bisect
N = int(stdin.readline().rstrip())
L = [int(x) for x in stdin.readline().rstrip().split()]
L.sort()
ans = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = l[j]
        k = bisect.bisect_left(L, a+b)
        ans += (k-j-1)
print(ans)

### FIXED CODE ###

from sys import stdin
import itertools
import bisect
N = int(stdin.readline().rstrip())
L = [int(x) for x in stdin.readline().rstrip().split()]
L.sort()
ans = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        k = bisect.bisect_left(L, a+b)
        ans += (k-j-1)
print(ans)
A = list(map(int, input().split()))
print(sort(A))

### FIXED CODE ###

A = list(map(int, input().split()))
A.sort()
print(A[0],A[1],A[2])
import sys

n, gap = int(input()), []
data = [int(i) for i in sys.stdin.readlines()]
cnt, g = 0, 0
while g <= n//9:
    g = 3 * g + 1
    gap.append(g)
m = len(gap)
gap = gap[::-1]
for i in gap:
    for idx in range(i, n):
        j = idx - i
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+i] = data[j]
            j -= i
            cnt += 1
        data[j+i] = v
print(m)
print(" ".join(map(str, gap)))
print(cnt)
for i in range(n):
    print(data[i])



### FIXED CODE ###

import sys

def shellSort(data, cnt, g, n):
    for idx in range(g, n):
        j = idx - g
        v = data[idx]
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt

n, gap = int(input()), []
a = ([int(i) for i in sys.stdin.readlines()], 0)
g = 0
while g <= n//9:
    g = 3 * g + 1
    gap.append(g)
m = len(gap)
for i in gap[::-1]:
    a = shellSort(a[0], a[1], i, n)
print(m)
print(" ".join(map(str, gap[::-1])))
print(a[1])
for i in range(n):
    print(a[0][i])
#coding : utf-8

N,Y = [int(i) for i in input().split()]
flag = 0

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j) and flag == 0:
            print(i,j,N-i-j)
            flag = 1
            break
if flag == 0:
    print(-1,-1,-1)

### FIXED CODE ###

#coding : utf-8

s = input()
s = '2018' + s[4:]
print(s)
s = input()
q = int(input())
for _ in range(q):
  t = input()
  if t[0]=='1':
    s = s[::-1]
  else:
    if t[2]=='1':
      s = t[4:] + s
    else:
      s = s + t[4:]
print(s)

### FIXED CODE ###

s = input()
print('YNeos'[s=='AAA' or s=='BBB'::2])
import math
N = int(input())
print((N*2)//math.gcd(N,2))

### FIXED CODE ###

import math
N = int(input())
if N%2==0:
    print(N)
else:
    print(N*2)