Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from collections import deque

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 = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
R = sorted(P+Q+R, reverse=True)[:X+Y]

print(sum(R)

Fixed submission:
# -*- coding: utf-8 -*-

from collections import deque

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()))

def sort(L):
  if len(L)==1:
    return L
  left = sort(L[:len(L)//2])
  right = sort(L[len(L)//2:])
  result = []
  left.append(-1)
  right.append(-1)
  left_index = 0
  right_index = 0
  while len(result)<len(L):
    if left[left_index]>=right[right_index]:
      result.append(left[left_index])
      left_index += 1
    else:
      result.append(right[right_index])
      right_index += 1
  return result

P = sort(P)[:X]
Q = sort(Q)[:Y]
R = sort(R)

P_index = X-1
Q_index = Y-1
R_index = 0

while True:
  if P[P_index] <= Q[Q_index] and R[R_index]>P[P_index]:
    P[P_index] = R[R_index]
    P_index = max(0, P_index-1)
    R_index += 1
  elif P[P_index] > Q[Q_index] and R[R_index]>Q[Q_index]:
    Q[Q_index] = R[R_index]
    Q_index = max(0, Q_index-1)
    R_index += 1
  else:
    break
  if R_index>=len(R):
    break

print(sum(P)+sum(Q))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

from collections import deque

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()))

def sort(L):
  if len(L)==1:
    return L
  left = sort(L[:len(L)//2])
  right = sort(L[len(L)//2:])
  result = []
  left.append(-1)
  right.append(-1)
  left_index = 0
  right_index = 0
  while len(result)<len(L):
    if left[left_index]>=right[right_index]:
      result.append(left[left_index])
      left_index += 1
    else:
      result.append(right[right_index])
      right_index += 1
  return result

P = sort(P)[:X]
Q = sort(Q)[:Y]
R = sort(P+Q+R)[:X+Y]
print(sum(R))

Fixed submission:
# -*- coding: utf-8 -*-

from collections import deque

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()))

def sort(L):
  if len(L)==1:
    return L
  left = sort(L[:len(L)//2])
  right = sort(L[len(L)//2:])
  result = []
  left.append(-1)
  right.append(-1)
  left_index = 0
  right_index = 0
  while len(result)<len(L):
    if left[left_index]>=right[right_index]:
      result.append(left[left_index])
      left_index += 1
    else:
      result.append(right[right_index])
      right_index += 1
  return result

P = sort(P)[:X]
Q = sort(Q)[:Y]
R = sort(R)

P_index = X-1
Q_index = Y-1
R_index = 0

while True:
  if P[P_index] <= Q[Q_index] and R[R_index]>P[P_index]:
    P[P_index] = R[R_index]
    P_index = max(0, P_index-1)
    R_index += 1
  elif P[P_index] > Q[Q_index] and R[R_index]>Q[Q_index]:
    Q[Q_index] = R[R_index]
    Q_index = max(0, Q_index-1)
    R_index += 1
  else:
    break
  if R_index>=len(R):
    break

print(sum(P)+sum(Q))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from collections import deque

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()))

def sort(L):
  if len(L)==1:
    return L
  left = sort(L[:len(L)//2])
  right = sort(L[len(L)//2:])
  result = []
  left.append(-1)
  right.append(-1)
  left_index = 0
  right_index = 0
  while len(result)<len(L):
    if left[left_index]>=right[right_index]:
      result.append(left[left_index])
      left_index += 1
    else:
      result.append(right[right_index])
      right_index += 1
  return result

P = sort(P)[:X]
Q = sort(Q)[:Y]
R = sort(R)

P_index = -1
Q_index = -1
R_index = 0

while True:
  if P[P_index] <= Q[Q_index] and R[R_index]>P[P_index]:
    P[P_index] = R[R_index]
    P_index -= 1
    R_index += 1
  elif P[P_index] > Q[Q_index] and R[R_index]>Q[Q_index]:
    Q[Q_index] = R[R_index]
    Q_index -= 1
    R_index += 1
  else:
    break
  if R_index>=len(R):
    break

print(sum(P)+sum(Q))
      

Fixed submission:
# -*- coding: utf-8 -*-

from collections import deque

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()))

def sort(L):
  if len(L)==1:
    return L
  left = sort(L[:len(L)//2])
  right = sort(L[len(L)//2:])
  result = []
  left.append(-1)
  right.append(-1)
  left_index = 0
  right_index = 0
  while len(result)<len(L):
    if left[left_index]>=right[right_index]:
      result.append(left[left_index])
      left_index += 1
    else:
      result.append(right[right_index])
      right_index += 1
  return result

P = sort(P)[:X]
Q = sort(Q)[:Y]
R = sort(R)

P_index = X-1
Q_index = Y-1
R_index = 0

while True:
  if P[P_index] <= Q[Q_index] and R[R_index]>P[P_index]:
    P[P_index] = R[R_index]
    P_index = max(0, P_index-1)
    R_index += 1
  elif P[P_index] > Q[Q_index] and R[R_index]>Q[Q_index]:
    Q[Q_index] = R[R_index]
    Q_index = max(0, Q_index-1)
    R_index += 1
  else:
    break
  if R_index>=len(R):
    break

print(sum(P)+sum(Q))