Buggy python submission (verdict: Time Limit Exceeded):
import bisect


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = sorted(list(map(int, input().split())), reverse=True)
    for i in q:
        bisect.insort_right(p, i)
    for i in range(min(a + b, c)):
        if p[i] < r[i]:
            p[i] = r[i]
        else:
            break
    print(sum(p))


if __name__ == '__main__':
    resolve()


Fixed submission:
import heapq


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = [-int(x) for x in input().split()]
    heapq.heapify(p)
    heapq.heapify(r)
    for i in q:
        heapq.heappush(p, i)
    ans = 0
    while p and r:
        ans += max(heapq.heappop(p), -heapq.heappop(r))
    ans += sum(p)
    print(ans)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = sorted(list(map(int, input().split())), reverse=True)
	p = sorted(p + q)
    for i in range(min(a + b, c)):
        if p[i] < r[i]:
            p[i] = r[i]
        else:
            break
    print(sum(p))


if __name__ == '__main__':
    resolve()


Fixed submission:
import heapq


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = [-int(x) for x in input().split()]
    heapq.heapify(p)
    heapq.heapify(r)
    for i in q:
        heapq.heappush(p, i)
    ans = 0
    while p and r:
        ans += max(heapq.heappop(p), -heapq.heappop(r))
    ans += sum(p)
    print(ans)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Runtime Error):
import heapq


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = sorted(list(map(int, input().split())), reverse=True)
    heapq.heapify(p)
    for i in q:
        heapq.heappush(p, i)
    ans = 0
    for i in range(min(a + b, c)):
        ans += max(heapq.heappop(p), r[i])
    if len(p):
        ans += sum(p)
    print(ans)


if __name__ == '__main__':
    resolve()


Fixed submission:
import heapq


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = [-int(x) for x in input().split()]
    heapq.heapify(p)
    heapq.heapify(r)
    for i in q:
        heapq.heappush(p, i)
    ans = 0
    while p and r:
        ans += max(heapq.heappop(p), -heapq.heappop(r))
    ans += sum(p)
    print(ans)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Runtime Error):
import heapq


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = sorted(list(map(int, input().split())), reverse=True)
    heapq.heapify(p)
    for i in q:
        heapq.heappush(p, i)
    ans = 0
    for i in range(min(a + b, c)):
        ans += max(heapq.heappop(p), r[i])
    print(ans + sum(p))


if __name__ == '__main__':
    resolve()


Fixed submission:
import heapq


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = [-int(x) for x in input().split()]
    heapq.heapify(p)
    heapq.heapify(r)
    for i in q:
        heapq.heappush(p, i)
    ans = 0
    while p and r:
        ans += max(heapq.heappop(p), -heapq.heappop(r))
    ans += sum(p)
    print(ans)


if __name__ == '__main__':
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = sorted(list(map(int, input().split())), reverse=True)
    for i in q:
        bisect.insort_right(p, i)
    for i in range(min(a + b, c)):
        if p[i] < r[i]:
            p[i] = r[i]
        else:
            break
    print(sum(p))


if __name__ == '__main__':
    resolve()


Fixed submission:
import heapq


def resolve():
    x, y, a, b, c = map(int, input().split())
    p = sorted(list(map(int, input().split())))[-x:]
    q = sorted(list(map(int, input().split())))[-y:]
    r = [-int(x) for x in input().split()]
    heapq.heapify(p)
    heapq.heapify(r)
    for i in q:
        heapq.heappush(p, i)
    ans = 0
    while p and r:
        ans += max(heapq.heappop(p), -heapq.heappop(r))
    ans += sum(p)
    print(ans)


if __name__ == '__main__':
    resolve()