Harryxun/stf_run huggingface dataset:
import copy
from collections import deque
from collections import defaultdict

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

line=defaultdict(list)
q=deque
next=deque()

ans=[-1]*(N+1)
ans[0]=0
ans[1]=0
for i in range(N):
  a,b=map(int, input().split())
  line[a].append(b)
  line[b].append(a)

#print(line)
    
next.append(1)
a=1
while len(next)>0:
  q=copy.copy(next)
  next.clear()
  chk=q.popleft()
  for i in range(len(line[chk])):
    #print('chk',chk)
    #print('line[chk][i]',line[chk][i])
    if ans[line[chk][i]]==-1:
      ans[line[chk][i]]=chk
      next.append(line[chk][i]) 
  if -1 not in ans:break
  #print('next',next)
#print(ans)
if -1 in ans:print('No')
else:
  print('Yes')
  for i in range(2,N+1):  
    print(ans[i])
    


### FIXED CODE ###

import copy
from collections import deque
from collections import defaultdict

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

line=defaultdict(list)
q=deque
next=deque()

ans=[-1]*(N+1)
ans[0]=0
ans[1]=0
for i in range(M):
  a,b=map(int, input().split())
  line[a].append(b)
  line[b].append(a)

#print(line)
    
next.append(1)
a=1
while len(next)>0:
  q=copy.copy(next)
  #print(q)
  next.clear()
  while len(q)>0:
    chk=q.popleft()
    #print('qpop',q)
    for i in range(len(line[chk])):
      #print('chk',chk)
      #print('line[chk][i]',line[chk][i])
      if ans[line[chk][i]]==-1:
        ans[line[chk][i]]=chk
        next.append(line[chk][i]) 
  if -1 not in ans:break
  #print('next',next)
#print(ans)
if -1 in ans:print('No')
else:
  print('Yes')
  for i in range(2,N+1):  
    print(ans[i])
N = int(input())
arr = list(map(int, input().split()))
arr2 = [0]*(max(arr)+1)
if len(arr2) == 3:
    arr2 = [0]*4
for i in range(N):
    arr2[arr[i]] += 1
ans = arr2[1] + arr2[2] + arr2[3]
tmp = ans
for i in range(4,len(arr2)):
    tmp = tmp - arr2[i-3] + arr2[i]
    if ans < tmp:
        ans = tmp
print(ans)

### FIXED CODE ###

N = int(input())
arr = list(map(int, input().split()))
arr2 = [0]*(max(arr)+1)
if max(arr) < 4:
    print(len(arr))
    exit()
for i in range(N):
    arr2[arr[i]] += 1
ans = arr2[1] + arr2[2] + arr2[3]
tmp = ans
for i in range(4,len(arr2)):
    tmp = tmp - arr2[i-3] + arr2[i]
    if ans < tmp:
        ans = tmp
print(ans)
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = p_acc[k-1]
ans = 0
for i in range(n-k):
    ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
    if p_acc[i+k] - p_acc[i] == ans_max:
        ans = i
print((p_acc[ans+k] - p_acc[ans] + k) / 2)


### FIXED CODE ###

from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_acc = list(accumulate(p))
ans_max = p_acc[k-1]
ans = 0
if n > k:
    for i in range(n-k):
        ans_max = max(ans_max, p_acc[i+k] - p_acc[i])
        if p_acc[i+k] - p_acc[i] == ans_max:
            ans = i
    print((p_acc[ans+k] - p_acc[ans] + k) / 2)
else:
    print((sum(p) + n) / 2)
import sys
sys.setrecursionlimit(9000)
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    def rep(r,c,nest):
        global cnt
        f=s[r][c]
        if f=='.':return
        s[r][c]='.'
        if r>0:
            if s[r-1][c]==f:rep(r-1,c,False)
        if r<a[0]-1:
            if s[r+1][c]==f:rep(r+1,c,False)
        if c>0:
            if s[r][c-1]==f:rep(r,c-1,False)
        if c<a[1]-1:
            if s[r][c+1]==f:rep(r,c+1,False)
        if nest==True:
            cnt+=1 
    for i in range(a[0]):
        s.append(list(input()))
    for i in range(a[0]):
        for j in range(a[1]):
            rep(i,j,True)
    print(cnt)

### FIXED CODE ###

''' DFS(TLE)
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    def rep(r,c,nest):
        global cnt
        f=s[r][c]
        if f=='.':return
        s[r][c]='.'
        if r>0:
            if s[r-1][c]==f:rep(r-1,c,False)
        if r<a[0]-1:
            if s[r+1][c]==f:rep(r+1,c,False)
        if c>0:
            if s[r][c-1]==f:rep(r,c-1,False)
        if c<a[1]-1:
            if s[r][c+1]==f:rep(r,c+1,False)
        if nest==True:
            cnt+=1 
    for i in range(a[0]):
        s.append(list(input()))
    for i in range(a[0]):
        for j in range(a[1]):
            rep(i,j,True)
    print(cnt)
'''
#
''' BFS(List)
import queue
dr=[0,0,1,-1]
dc=[1,-1,0,0]
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    for i in range(a[0]):
        s.append(list(input()))
    q=queue.Queue()
    for i in range(a[0]):
        for j in range(a[1]):
            if s[i][j]=='.':continue
            f=s[i][j]
            l=[[i,j]]
            while len(l)!=0:
                next_depth=[]
                for cor in l:
                    for k in range(4):
                        r=cor[0]+dr[k]
                        c=cor[1]+dc[k]
                        if 0<=r<a[0] and 0<=c<a[1] and s[r][c]==f:
                            s[r][c]='.'
                            next_depth.append([r,c])
                l=next_depth
            cnt+=1
    print(cnt)
'''
#
''' BFS(Queue) '''
import queue
dr=[0,0,1,-1]
dc=[1,-1,0,0]
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    for i in range(a[0]):
        s.append(list(input()))
    q=queue.Queue()
    for i in range(a[0]):
        for j in range(a[1]):
            if s[i][j]=='.':continue
            f=s[i][j]
            q.put([i,j])
            while not q.empty():
                cor=q.get()
                for k in range(4):
                    r=cor[0]+dr[k]
                    c=cor[1]+dc[k]
                    if 0<=r<a[0] and 0<=c<a[1] and s[r][c]==f:
                        s[r][c]='.'
                        q.put([r,c])
            cnt+=1
    print(cnt)
n = int(input())
x=y = list(map(int, input().split()))
y.sort()
if n % 2 != 0:
    a,b,c = y[n//2-1],y[n//2],y[n//2+1]
    m = b
else:
    a,b = y[n//2-1],y[n//2]    
    m = (a+b)/2
for i in range(n):
    if x[i] < m :
        if n%2==0:
            tm = b
        else:
            tm = (b+c)/2
    if i == n//2+1:
        if n%2==0:
            tm = a
        else:
            tm = (a+c)/2
    if x[i] > m:
        if n%2==0:
            tm = a
        else:
            tm = (a+b)/2
    print(tm)

        
    

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
y = list(x)
y.sort()
if n % 2 != 0:
    a,b,c = y[n//2-1],y[n//2],y[n//2+1]
    m = b
else:
    a,b = y[n//2-1],y[n//2]    
    m = (a+b)/2
for i in range(n):
    if i == n//2:
        if n%2==0:
            tm = a
        else:
            tm = (a+c)/2
    if x[i] < m :
        if n%2==0:
            tm = b
        else:
            tm = (b+c)/2
    else:
        if n%2==0:
            tm = a
        else:
            tm = (a+b)/2
    print(int(tm))
n = map(int, input())
a = map(int, input())
if n%500 < a;
    print('YES')
else
    print('NO')

### FIXED CODE ###

n = int(input())
a = int(input())
if n % 500 <= a:
  print("Yes")
else:
  print("No")
p,q,r=map(int,input().split())
print(sum(p,q,r)-max(p,q,r))

### FIXED CODE ###

p=list(map(int,input().split()))
print(sum(p)-max(p))
n, k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input))
    a.append(list(map(int, input().split())))

aa = [0]*n

for j in a:
    for t in j:
        aa[t - 1] += 1

ans = 0

for z in aa:
    if z == 0:
        ans += 0

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

aa = [0]*n

for j in a:
    for t in j:
        aa[t - 1] += 1

ans = 0

for z in aa:
    if z == 0:
        ans += 1
    else:
        ans += 0

print(ans)
# input
S = set(input())

if S = set(a, b, c):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

# input
S = set(input())

if S == set(['a', 'b', 'c']):
    print('Yes')
else:
    print('No')
from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n):
    if memo[n] >= 0:
        rst = memo[n]
    else:
        tmp = n
        one = 0
        while tmp > 0:
            one += tmp & 1
            tmp >>= 1
        m = n % one
        rst = 1 if m == 0 else 1 + dfs(m)
        memo[n] = rst
    return rst


N = int(input())
X = input()
# X = list(map(int, list(input())))
# one = Counter(X)[1]


memo = [-1] * (1 << (N + 1))
memo[0] = 0

x = int(X, 2)
for i in range(N):
    ans = dfs(x ^ (1 << ((N - 1) - i)))
    print(ans)


### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n):
    if memo[n] >= 0:
        rst = memo[n]
    else:
        tmp = n
        one = 0
        while tmp > 0:
            one += tmp & 1
            tmp >>= 1
        m = n % one
        rst = 1 if m == 0 else 1 + dfs(m)
        memo[n] = rst
    return rst


N = int(input())
# X = input()
X = list(map(int, list(input())))
one = Counter(X)[1]


if one > 1:
    Sm = 0
    mm = one - 1
    tm = 1
    for i in range(N - 1, -1, -1):
        tm %= mm
        if X[i] == 1:
            Sm += tm
            Sm %= mm
        tm *= 2

Sp = 0
mp = one + 1
tp = 1
for i in range(N - 1, -1, -1):
    tp %= mp
    if X[i] == 1:
        Sp += tp
        Sp %= mp
    tp *= 2


memo = [-1] * (2 * (10 ** 5) + 10)
memo[0] = 0

# x = int(X, 2)
# for i in range(N):
#     ans = dfs(x ^ (1 << ((N - 1) - i)))
#     print(ans)
for i in range(N):
    if one == 1:
        if X[i] == 0:
            m = (Sp + pow(2, N - 1 - i, mp)) % mp
            if m == 0:
                print(1)
            else:
                print(1 + dfs(m))
        else:
            print(0)
        continue

    if X[i] == 0:
        m = (Sp + pow(2, N - 1 - i, mp)) % mp
    else:
        m = (Sm - pow(2, N - 1 - i, mm)) % mm
    
    if m == 0:
        print(1)
    else:
        print(1 + dfs(m))
a,*_,e,k=map(int,input(input().split()));print([':(','Yey!'][e-a<=k])

### FIXED CODE ###

a,*_,e,k=[int(input())for x in' '*6];print([':(','Yay!'][e-a<=k])
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [ [] for i in range(M)], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << N):
    price_combi, exp_combi, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range(N):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ cnt_ls.append(x) for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

### FIXED CODE ###

N, M, X = map(int, input().split(' '))
price, exp, rst = [], [], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp.append(ls[1:])
for i in range(1 << N):
    price_combi, exp_combi, exp_rst, cnt = [], [], [0] * M, []
    for j in range(N):
        if (i >> j) & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in range(len(exp_combi)):
        for t in range(M):
            exp_rst[t] += exp_combi[s][t]
    [cnt.append(i) for i in exp_rst if i >= X]
    if len(cnt) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)
N,K = map(int,input().split())
import math
def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(1,K+1):
    print(c(N-K+1,i)*c(K-1,i-1)%1000000007)

### FIXED CODE ###

N,K = map(int,input().split())
import math
def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(1,K+1):
    if N-K+1>=i:
        print(c(N-K+1,i)*c(K-1,i-1)%1000000007)
    else:
        print(0)
A_B_C = input().split()
A = int(A_B_C[0])
B = int(A_B_C[1])
C = int(A_B_C[2])

left = 0
if A >= (B+C):
  left = 0
else:
  left = C - (A-B)
  
 print(left)

### FIXED CODE ###

A_B_C = input().split()
A = int(A_B_C[0])
B = int(A_B_C[1])
C = int(A_B_C[2])

left = 0
if A >= (B+C):
  left = 0
else:
  left = C - (A-B)
print(left)
W,H,x,y = map(int,input().split())
if y == H*x/W or y == H - H*x/W:
    print(W*H,1.split())
else:
    print(W*H,0.split())

### FIXED CODE ###

W,H,x,y = map(int,input().split())
if x == W/2 and y == H/2:
    a = 1
else:
    a = 0
print(W*H/2,a)
#!/usr/bin/env python3
import sys


def solve(X: int):
    dp = [[False]*(X+1) for _ in range(7)]
    price = [100,101,102,103,104,105]
    X = 10000

    for i in range(7):
        dp[i][0] = True

    ## i番目まででjを払えるか
    for i in range(6):
        for j in range(X+1):
            if j >= price[i]:
                for k in range(1,j//price[i]+1):
                    if j-k*price[i]>=0:
                        dp[i+1][j] |= dp[i][j] or dp[i][j-k*price[i]]
                    if dp[i+1][j]:
                        break
            else:
                dp[i+1][j] = dp[i][j]

    if dp[6][X]:
        print(1)
    else:
        print(0)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(X: int):
    dp = [[-1]*(X+1) for _ in range(7)]
    price = [100,101,102,103,104,105]
    m = [10**5]*6

    for i in range(7):
        dp[i][0] = 10**5

    ## i番目まででjを払えるか
    for i in range(6):
        for j in range(X+1):
            if dp[i][j]>=0:
                dp[i+1][j] = m[i]
            elif j < price[i] or dp[i+1][j-price[i]]<=0:
                dp[i+1][j] = -1
            else:
                dp[i+1][j] = dp[i+1][j-price[i]]-1

    if dp[6][X]>=0:
        print(1)
    else:
        print(0)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))

    res = -f_inf
    for now in range(n):
        cnt = 0
        score = [0]
        visited = set()
        for j in range(k):
            next_now = P[now] - 1
            if next_now not in visited:
                score.append(score[-1] + C[next_now])
                visited.add(next_now)
                now = next_now
                cnt += 1
            else:
                break
        if k - cnt == 0:
            res = max(res, max(score[1:]))
        else:
            if score[-1] <= 0:
                res = max(res, max(score[1:]))
            else:
                q, r = divmod(k, cnt)
                res = max(res, max(score[1:r + 1]) + score[-1] * q)
    print(res)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    C = list(map(int, input().split()))

    res = -f_inf
    for now in range(n):
        cnt = 0
        score = [0]
        visited = set()
        for j in range(k):
            next_now = P[now] - 1
            if next_now not in visited:
                score.append(score[-1] + C[next_now])
                visited.add(next_now)
                now = next_now
                cnt += 1
            else:
                break
        score.pop(0)
        if k - cnt == 0:
            res = max(res, max(score))
        else:
            if score[-1] <= 0:
                res = max(res, max(score))
            else:
                q, r = divmod(k, cnt)
                if r == 0:
                    res = max(res, max(score) + score[-1] * (q - 1))
                else:
                    res = max(res, max(score[:r]) + score[-1] * q, max(score[r:]) + score[-1] * (q - 1))
    print(res)


if __name__ == '__main__':
    resolve()
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d=[0]
w=set([0])
x=0
for i in range(n):
    if a[x]-1 not in w:
        d.append(a[x]-1)
        w.add(a[x]-1)
        x=a[x]-1
    else:
        f=a[x]-1
        break

#print(d)
if k<len(d):
    print(d[k])
else:
    x=k-len(d)
    y=d.index(d[f])
    z=len(d)-y+1
    #print(d,y)
    #exit()
    print(d[y+x%z]+1)


### FIXED CODE ###

n,k=map(int,input().split())
a=[int(i) for i in input().split()]
d=[0]
w=set([0])
x=0
for i in range(n):
    if a[x]-1 not in w:
        d.append(a[x]-1)
        w.add(a[x]-1)
        x=a[x]-1
    else:
        f=a[x]-1
        break

#print(d)
if k<len(d):
    print(d[k]+1)
else:
    x=k-len(d)
    y=d.index(f)
    z=len(d)-y
    #print(d,f,x,y,z)
    #exit()
    print(d[y+x%z]+1)
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
N += 1
i = 0
cnt = 0
while X - D >= 0:
  D += L[i]
  i += 1
  cnt += 1
if cnt == 0:
  print(cnt+1)
else:
  print(cnt)

### FIXED CODE ###

N, X = map(int, input().split())
L = list(map(int, input().split()))
D = [0]
cnt = 1
for i in range(1,N+1):
  D.append(D[i-1]+L[i-1])
  if X >= D[i]:
    cnt += 1
print(cnt)
N = int(input())
p = list(map(int,input().split()))

ans=1
for i in range(1,N):
  p_prev = sorted(p[0:i])
  if p[i] < p_prev[0]:
    ans += 1
    
print(ans)

### FIXED CODE ###

a,b=map(int,input().split())

bg=max(a,b)
sm=min(a,b)

print(str(sm)*bg)
import math
def main():
    N = int(input())
    A = [int(n) for n in input().split()]
    fore = [0]*N
    back=[0]*N
    fore[0] = A[0]
    back[-1] = A[-1]
    for i in range(1, N):
        fore[i] = math.gcd(fore[i-1], A[i])
    for i in reversed(list(range(0, N-1))):
        back[i] = math.gcd(back[i+1], A[i])
    maximum = 0
    for i in range(N):
        f = fore[i-1] if i != 0 else 0
        b = back[i+1] if i != N-1 else 0
        m = math.gcd(f, b)
        maximum = max(m, maximum)
    print(maximum)
main()

### FIXED CODE ###


def main():
    N = int(input())
    A = [int(n) for n in input().split()]
    fore = [0]*N
    back=[0]*N
    fore[0] = A[0]
    back[-1] = A[-1]
    for i in range(1, N):
        fore[i] = gcd(fore[i-1], A[i])
    for i in reversed(list(range(0, N-1))):
        back[i] = gcd(back[i+1], A[i])
    maximum = 0
    for i in range(N):
        f = fore[i-1] if i != 0 else 0
        b = back[i+1] if i != N-1 else 0
        m = gcd(f, b)
        maximum = max(m, maximum)
    print(maximum)
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
main()
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)[::-1]

waribiki = 0
index = 0

if len(A)==1:
    print(A[0]//pow(2,M))
    exit()

while waribiki < M:
    if index==0 and A[index] < 3: break
    if A[index]>2 and A[index+1]>2:
        x = A[index] // A[index+1]
        if x+waribiki>M: x = M-waribiki

    if A[index] > 2:
        A[index] = A[index]//pow(2, x)
        waribiki+=x

    index += 1
    if index==N:
        index=0



if waribiki < M:
    index = 0
    while waribiki < M:
        A[index] = A[index] // 2
        waribiki += 1

        index += 1
        if index==N: index=0

        if sum(A)==0:break


print(sum(A))


### FIXED CODE ###

#!/usr/bin/env python3
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(A)

if N == 1:
    MAX = heapq.heappop(A)//2**M 
    if MAX < 0:
        print(0)
    else:
        print(MAX)
    exit()

cnt = 0
while M > 0:
    MAX = heapq.heappop(A)
    if MAX % 2 == 0:
        heapq.heappush(A, MAX//2)
    else:
        heapq.heappush(A, MAX//2+1)

    M -= 1

print(-sum(A))
num = int(input())
a= input()
words = a.split()
ss = 0

for i in range(num):
  if "A" = words[i]:
    for q in range(i,num):
      if "B" = words[q]:
        for g in range(q,num):
          if "C" = words[g]:
            ss += 1
          
  

### FIXED CODE ###

num = int(input())
s=list(input())
ss = 0

for i in range(num):
  if "A" == s[i]:
    if i > num - 3:
      break
    if "B" == s[i + 1]:
      if "C" == s[i + 2]:
        ss += 1
print(ss)
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10000)
sys.set
N = int(input())
D = [deque([]) for _ in range(N)]
cnt = 0
AB = [0] * (N-1)
dic = {}
for n in range(N-1):
    a, b = [int(x) for x in input().strip().split()]
    AB[n] = (a-1, b-1)
    dic[(a, b)] = 0
    D[a-1].append(b-1)
    D[b-1].append(a-1)

print(max([len(d) for d in D]))

def dp(pp, p, c):
    global dic
    nc = 1
    for np in D[p]:
        if np == pp:
            continue
        if nc == c:
            nc += 1
        dic[(p, np)] = nc
        dp(p, np, nc)
        nc += 1
    return 0

dp(-1, 0, 0)
for ab in AB:
    print(dic[ab])

### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(100000)
N = int(input())
D = [deque([]) for _ in range(N)]
cnt = 0
AB = [0] * (N-1)
dic = {}
for n in range(N-1):
    a, b = [int(x) for x in input().strip().split()]
    AB[n] = (a-1, b-1)
    dic[(a, b)] = 0
    D[a-1].append(b-1)
    D[b-1].append(a-1)

print(max([len(d) for d in D]))

def dp(pp, p, c):
    global dic
    nc = 1
    for np in D[p]:
        if np == pp:
            continue
        if nc == c:
            nc += 1
        dic[(p, np)] = nc
        dp(p, np, nc)
        nc += 1
    return 0

dp(-1, 0, 0)
for ab in AB:
    print(dic[ab])
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
 
assert K > 50
 
print(114514)

### FIXED CODE ###

input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input() # 無視

equalized = 1
i = 0
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(str(i))
x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
ans1 = 0
ans2 = 0
p1.sort(reverse = True)
p2.sort(reverse = True)
p3.sort(reverse = True)
for i in range(0, max(x,y)):
  p3.append(0)
for i in range(0,x):
  ans1= ans1 + max(p1[i],p3[i])
  if(p3[i]>p1[i]):
    del p[i]
for i in range(0,y):
  ans2= ans2 + max(p2[i],p3[i])
  if(p3[i]>p2[i]):
    del p3[i]
print(ans1+ans2)



### FIXED CODE ###

x,y,a,b,c = map(int, input().split())
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))
p1.sort(reverse= True)
p2.sort(reverse= True)
ans =p1[:x]+p2[:y]+p3
ans.sort(reverse= True)
print(sum(ans[:x+y]))