Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline
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()))
red = sorted(p)
green = sorted(q)
no = sorted(r)
red.reverse()
green.reverse()
no.reverse()

c_r = 0
c_g = 0
c_n = 0
ans = 0

while (c_r < X) and (c_g < Y) and (c_n < C):
  tmp = min(red[X-c_r-1],green[Y-c_g-1])
  if tmp > no[c_n]:
    break
  else:
    ans += no[c_n]
    c_n += 1
    if red[X-c_r] > green[Y-c_g]:
      c_g += 1
    else:
      c_r += 1

if c_r == X:
  while (c_n < C) and (c_g < Y):
    if green[c_g] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_g += 1
      c_n += 1
elif c_g == Y:
  while (c_n < C) and (c_r < X):
    if red[c_r] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_r += 1
      c_n += 1

if c_r != X:
  ans += sum(red[0:X-c_r])
if c_g != Y:
  ans += sum(green[0:Y-c_g])
print(ans)

Fixed submission:
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()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline
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()))
red = sorted(p, reverse = True)
green = sorted(q, reverse = True)
no = sorted(r, reverse = True)

c_r = 0
c_g = 0
c_n = 0
ans = 0

while (c_r < X) and (c_g < Y) and (c_n < C):
  tmp = min(red[X-c_r-1],green[Y-c_g-1])
  if tmp > no[c_n]:
    break
  else:
    ans += no[c_n]
    c_n += 1
    if red[X-c_r] > green[Y-c_g]:
      c_g += 1
    else:
      c_r += 1

if c_r == X:
  while (c_n < C) and (c_g < Y):
    if green[c_g] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_g += 1
      c_n += 1
elif c_g == Y:
  while (c_n < C) and (c_r < X):
    if red[c_r] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_r += 1
      c_n += 1

if c_r != X:
  ans += sum(red[0:X-c_r-1])
if c_g != Y:
  ans += sum(green[0:Y-c_g-1])
print(ans)


Fixed submission:
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()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()) for _ in range(X))
q = list(map(int, input().split()) for _ in range(Y))
r = list(map(int, input().split()))
red = sorted(p, reverse = True)
green = sorted(q, reverse = True)
no = sorted(r, reverse = True)

c_r = 0
c_g = 0
c_n = 0
ans = 0

while (c_r < X) and (c_g < Y) and (c_n < C):
  tmp = min(red[X-c_r-1],green[Y-c_g-1])
  if tmp > no[c_n]:
    break
  else:
    ans += no[c_n]
    c_n += 1
    if red[X-c_r] > green[Y-c_g]:
      c_g += 1
    else:
      c_r += 1

if c_r == X:
  while (c_n < C) and (c_g < Y):
    if green[c_g] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_g += 1
      c_n += 1
elif c_g == Y:
  while (c_n < C) and (c_r < X):
    if red[c_r] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_r += 1
      c_n += 1

if c_r != X:
  ans += sum(red[0:X-c_r-1])
if c_g != Y:
  ans += sum(green[0:Y-c_g-1])
print(ans)

Fixed submission:
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()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))

Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()) for _ in range(X))
q = list(map(int, input().split()) for _ in range(Y))
r = list(map(int, input().split()))
new = p + q + r
new = sorted(new, reverse = True)
print(sum(new[0:X+Y]))


Fixed submission:
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()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()) for _ in range(X))
q = list(map(int, input().split()) for _ in range(Y))
r = list(map(int, input().split()))
new = p + q + r
new = sorted(new, reverse = True)
print(sum(new[0:X+Y]))

Fixed submission:
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()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()) for _ in range(X))
q = list(map(int, input().split()) for _ in range(Y))
r = list(map(int, input().split()))
red = sorted(p, reverse = True)
green = sorted(q, reverse = True)
no = sorted(r, reverse = True)

c_r = 0
c_g = 0
c_n = 0
ans = 0

while (c_r < X) and (c_g < Y) and (c_n < C):
  tmp = min(red[X-c_r-1],green[Y-c_g-1])
  if tmp > no[c_n]:
    break
  else:
    ans += no[c_n]
    c_n += 1
    if red[X-c_r] > green[Y-c_g]:
      c_g += 1
    else:
      c_r += 1

if c_r == X:
  while (c_n < C) and (c_g < Y):
    if green[c_g] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_g += 1
      c_n += 1
elif c_g == Y:
  while (c_n < C) and (c_r < X):
    if red[c_r] > no[c_n] :
      break
    else:
      ans += no[c_n]
      c_r += 1
      c_n += 1

if c_r != X:
  ans += sum(red[0:X-c_r-1])
if c_g != Y:
  ans += sum(green[0:Y-c_g-1])
print(ans)
  
  
    
  
  
  
  
  
  
  

Fixed submission:
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()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))