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

from sys import stdin


def main():
    X, Y, A, B, C = list(map(int, stdin.readline().split()))
    p = list(map(int, stdin.readline().split()))
    q = list(map(int, stdin.readline().split()))
    r = list(map(int, stdin.readline().split()))

    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)

    oisisa = 0
    x, y, z = 0, 0, 0

    for i in range(0, X + Y):
        m_p = p[0] if len(p) > 0 else 0
        m_q = q[0] if len(q) > 0 else 0
        m_r = r[0] if len(r) > 0 else 0
        m = max( [m_p, m_q, m_r] )

        if m_p == m:
            # pから取る
            oisisa += p.pop(0)
            x += 1

        elif m_q == m:
            # qから取る
            oisisa += q.pop(0)
            y += 1
        else:
            # rから取る
            oisisa += r.pop(0)
            z += 1

        if x >= X:
            p = []
        if y >= Y:
            q = []

        if x + y + z == X + Y:
            print(oisisa)
            return


if __name__ == "__main__":
    main()


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

from sys import stdin


def main():
    X, Y, A, B, C = list(map(int, stdin.readline().split()))
    p = list(map(int, stdin.readline().split()))
    q = list(map(int, stdin.readline().split()))
    r = list(map(int, stdin.readline().split()))

    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)

    oisii = []
    oisii.extend(p[0:X])
    oisii.extend(q[0:Y])
    oisii.extend(r)
    oisii.sort(reverse=True)
    print( sum( oisii[0:X+Y]) )


if __name__ == "__main__":
    main()

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

from sys import stdin


def main():
    X, Y, A, B, C = list(map(int, stdin.readline().split()))
    p = list(map(int, stdin.readline().split()))
    q = list(map(int, stdin.readline().split()))
    r = list(map(int, stdin.readline().split()))

    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)

    oisisa = 0
    x, y, z = 0, 0, 0
    for i in range(0, X + Y):
        m_p = p[0] if len(p) > 0 else 0
        m_q = q[0] if len(q) > 0 else 0
        m_r = r[0] if len(r) > 0 else 0
        m = max( [m_p, m_q, m_r] )

        if x < X and m_p == m:
            # pから取る
            oisisa += p.pop(0)
            x += 1

        elif y < Y and m_q == m:
            # qから取る
            oisisa += q.pop(0)
            y += 1
        else:
            # rから取る
            oisisa += r.pop(0)
            z += 1

        if x >= X:
            p = []
        if y >= Y:
            q = []

        if x + y + z == X + Y:
            print(oisisa)
            return


if __name__ == "__main__":
    main()


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

from sys import stdin


def main():
    X, Y, A, B, C = list(map(int, stdin.readline().split()))
    p = list(map(int, stdin.readline().split()))
    q = list(map(int, stdin.readline().split()))
    r = list(map(int, stdin.readline().split()))

    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)

    oisii = []
    oisii.extend(p[0:X])
    oisii.extend(q[0:Y])
    oisii.extend(r)
    oisii.sort(reverse=True)
    print( sum( oisii[0:X+Y]) )


if __name__ == "__main__":
    main()