Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  x, y, a, b, c = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0,
  
  s = 0
  while True:
    if sum([ca, cb, cc]) == x+y:
      break
      
    a = la[0] if len(la) > 0 and ca < x else -1
    b = lb[0] if len(lb) > 0 and cb < y else -1
    c = lc[0] if len(lc) > 0            else -1
            
    if a >= b and a >= c:
      s += a
      del la[0]
      ca += 1
      continue
      
    if b >= a and b >= c:
      s += b
      del lb[0]
      cb += 1
      continue
      
    if c >= b and c >= a:
      s += c
      del lc[0]
      cc += 1
  print(s)

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-


def main():
  x, y, na, nb, nc = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0
  
  lx = la[:x] + lb[:y] + lc
  lx.sort(reverse=True)
  print(sum(lx[:x+y]))

if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  x, y, a, b, c = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0,
  
  s = 0
  while True:
    if sum([ca, cb, cc]) == x+y:
      break
      
    a = la[0] if len(la) > 0 and ca < x else -1
    b = lb[0] if len(lb) > 0 and cb < y else -1
    c = lc[0] if len(lc) > 0            else -1
            
    if a >= b and a >= c:
      s += a
      la.pop(0)
      ca += 1
      continue
      
    if b >= a and b >= c:
      s += b
      lb.pop(0)
      cb += 1
      continue
      
    if c >= b and c >= a:
      s += c
      lc.pop(0)
      cc += 1
  print(s)

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-


def main():
  x, y, na, nb, nc = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0
  
  lx = la[:x] + lb[:y] + lc
  lx.sort(reverse=True)
  print(sum(lx[:x+y]))

if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  x, y, a, b, c = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0,
  
  s = 0
  while True:
    if sum([ca, cb, cc]) == x+y:
      break
      
    a = la[0] if len(la) > 0 and ca < x else -1
    b = lb[0] if len(lb) > 0 and cb < y else -1
    c = lc[0] if len(lc) > 0            else -1
            
    if a >= b and a >= c:
      s += a
      la.pop(0)
      ca += 1
      continue
      
    if b >= a and b >= c:
      s += b
      lb.pop(0)
      cb += 1
      continue
      
    if c >= b and c >= a:
      s += c
      lc.pop(0)
      cc += 1
  print(s)

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-


def main():
  x, y, na, nb, nc = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0
  
  lx = la[:x] + lb[:y] + lc
  lx.sort(reverse=True)
  print(sum(lx[:x+y]))

if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  x, y, a, b, c = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0,
  
  lx = []
  while True:
    if sum([ca, cb, cc]) == x+y:
      break
      
    a = la[0] if len(la) > 0 and ca < x else -1
    b = lb[0] if len(lb) > 0 and cb < y else -1
    c = lc[0] if len(lc) > 0            else -1
            
    if a >= b and a >= c:
      lx.append(a)
      la.pop(0)
      ca += 1
      continue
      
    if b >= a and b >= c:
      lx.append(b)
      lb.pop(0)
      cb += 1
      continue
      
    if c >= b and c >= a:
      lx.append(c)
      lc.pop(0)
      cc += 1
  print(sum(lx))

if __name__=='__main__':
  main()


Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-


def main():
  x, y, na, nb, nc = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0
  
  lx = la[:x] + lb[:y] + lc
  lx.sort(reverse=True)
  print(sum(lx[:x+y]))

if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  x, y, a, b, c = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0,
  
  lx = []
  while True:
    if sum([ca, cb, cc]) == x+y:
      break
      
    if len(la) > 0 and ca < x:
      a = la[0]
    else:
      a = -1
      
    if len(lb) > 0 and cb < y:
      b = lb[0]
    else:
      b = -1
      
    if len(lc) > 0:
      c = lc[0]
    else:
      c = -1
      
    if len(la) > 0 and ca < x and a >= b and a >= c:
      lx.append(a)
      la.pop(0)
      ca += 1
      continue
      
    if len(lb) > 0 and cb < y and b >= a and b >= c:
      lx.append(b)
      lb.pop(0)
      cb += 1
      continue
      
    if len(lc) > 0 and c >= b and c >= a:
      lx.append(c)
      lc.pop(0)
      cc += 1
  print(sum(lx))

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-


def main():
  x, y, na, nb, nc = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0
  
  lx = la[:x] + lb[:y] + lc
  lx.sort(reverse=True)
  print(sum(lx[:x+y]))

if __name__=='__main__':
  main()