Buggy python submission (verdict: Runtime Error):
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and (cs[-1] > ps[-1] or cs[-1] > qs[-1]):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot



Fixed submission:
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and ((ps and cs[-1] > ps[-1]) or (qs and cs[-1] > qs[-1])):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot

Buggy python submission (verdict: Runtime Error):
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and (cs[-1] > ps[-1] or cs[-1] > qs[-1]):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        assert False
# print ps, qs

print tot



Fixed submission:
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and ((ps and cs[-1] > ps[-1]) or (qs and cs[-1] > qs[-1])):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot

Buggy python submission (verdict: Runtime Error):
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x][::-1]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y][::-1]
cs = sorted(map(int, raw_input().split()), reverse=True)

tot = sum(ps) + sum(qs)

while cs and (cs[0] > ps[0] or cs[0] > qs[0]):
    if ps and qs:
        if ps[0] < qs[0]:
            tot -= ps.pop(0)
            tot += cs.pop(0)
        else:
            tot -= qs.pop(0)
            tot += cs.pop(0)
    elif ps:
        tot -= ps.pop(0)
        tot += cs.pop(0)
    elif qs:
        tot -= qs.pop(0)
        tot += cs.pop(0)
    else:
        assert False
# print ps, qs

print tot



Fixed submission:
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and ((ps and cs[-1] > ps[-1]) or (qs and cs[-1] > qs[-1])):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot