Buggy python submission (verdict: Time Limit Exceeded):
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)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
i = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if S[0] == r[0]:
    c += 1
    r.remove(r[0])
    ans += S[0]
    i += 1
  elif S[0] == p[0] and a < X:
    a += 1
    p.remove(p[0])
    ans += S[0]
    i += 1
  elif S[0] == q[0] and b < Y:
    b += 1
    q.remove(q[0])
    ans += S[0]
    i += 1
  S.remove(S[0])
print(ans)

Fixed submission:
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)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print(sum(S[:X+Y]))

Buggy python submission (verdict: Time Limit Exceeded):
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)
s = p[:X] + q[:Y] + r[:X+Y]
S = sorted(s, reverse = True)
i = 0
j = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if S[j] in r:
    c += 1
    r.remove(S[j])
    ans += S[j]
    i += 1
  elif S[j] in p and a < X:
    a += 1
    p.remove(S[j])
    ans += S[j]
    i += 1
  elif S[j] in q and b < Y:
    b += 1
    q.remove(S[j])
    ans += S[j]
    i += 1
  j += 1
print(ans)

Fixed submission:
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)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print(sum(S[:X+Y]))

Buggy python submission (verdict: Time Limit Exceeded):
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()))
s = p + q + r
S = sorted(s, reverse = True)
i = 0
j = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if S[j] in r:
    c += 1
    r.remove(S[j])
    ans += S[j]
    i += 1
  elif S[j] in p and a < X:
    a += 1
    p.remove(S[j])
    ans += S[j]
    i += 1
  elif S[j] in q and b < Y:
    b += 1
    q.remove(S[j])
    ans += S[j]
    i += 1
  j += 1
print(ans)

Fixed submission:
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)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print(sum(S[:X+Y]))

Buggy python submission (verdict: Runtime Error):
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()))
s = p + q + r
S = sorted(s, reverse = True)
i = 0
j = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if S[j] in r:
    c += 1
    r.remove(s[j])
    ans += S[j]
    i += 1
  elif S[j] in p and a < X:
    a += 1
    p.remove(S[j])
    ans += S[j]
    i += 1
  elif S[j] in q and b < Y:
    b += 1
    q.remove(S[j])
    ans += S[j]
    i += 1
  j += 1
print(ans)

Fixed submission:
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)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print(sum(S[:X+Y]))

Buggy python submission (verdict: Runtime Error):
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()))
s = p + q + r
S = sorted(s, reverse = True)
print(S)
i = 0
j = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if S[j] in r:
    c += 1
    r.remove(s[j])
    ans += S[j]
    i += 1
  elif S[j] in p and a < X:
    a += 1
    p.remove(S[j])
    ans += S[j]
    i += 1
  elif S[j] in q and b < Y:
    b += 1
    q.remove(S[j])
    ans += S[j]
    i += 1
  j += 1
print(ans)

Fixed submission:
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)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print(sum(S[:X+Y]))

Buggy python submission (verdict: Time Limit Exceeded):
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()))
s = p + q + r
s.sort()
s.reverse()
i = 0
j = 0
ans = 0
a = 0
b = 0
c = 0
while i < (X + Y):
  if s[j] in r:
    c += 1
    r.remove(s[j])
    ans += s[j]
    i += 1
  elif s[j] in p and a < X:
    a += 1
    p.remove(s[j])
    ans += s[j]
    i += 1
  elif s[j] in q and b < Y:
    b += 1
    q.remove(s[j])
    ans += s[j]
    i += 1
  j += 1
print(ans)

Fixed submission:
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)
S = sorted(p[:X] + q[:Y] + r[:X+Y], reverse = True)
print(sum(S[:X+Y]))