Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = list(map(int, input().split()))
ret = (a + b) * [0]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
X = []
Y = []
A.sort()
B.sort()
C.sort()

X = A[(a - x):]
Y = B[(b - y):]

idxA = 0
idxB = 0
idxC = c - 1
for i in reversed(range(c)):
    if idxA == len(X) and idxB == len(Y):
        break
    if idxA == len(X):
        if C[i] > Y[idxB]:
            Y[idxB] = C[i]
            idxB += 1
        else:
            break
    if idxB == len(Y):
        if C[i] > X[idxA]:
            X[idxA] = C[i]
            idxA += 1
        else:
            break
    if C[i] <= min(X[idxA], Y[idxB]):
        break
    if X[idxA] <= Y[idxB]:
        X[idxA] = C[i]
        idxA += 1
    else:
        Y[idxB] = C[i]
        idxB += 1
print((sum(X) + sum(Y)))

Fixed submission:
x, y, a, b, c = list(map(int, input().split()))
ret = (a + b) * [0]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
X = []
Y = []
A.sort()
B.sort()
C.sort()

X = A[(a - x):]
Y = B[(b - y):]

idxA = 0
idxB = 0
idxC = c - 1
for i in reversed(range(c)):
    if idxA == x and idxB == y:
        break
    if idxA == x:
        if C[i] > Y[idxB]:
            Y[idxB] = C[i]
            idxB += 1
        else:
            break
    elif idxB == y:
        if C[i] > X[idxA]:
            X[idxA] = C[i]
            idxA += 1
        else:
            break
    elif C[i] <= min(X[idxA], Y[idxB]):
        break
    elif X[idxA] <= Y[idxB]:
        X[idxA] = C[i]
        idxA += 1
    else:
        Y[idxB] = C[i]
        idxB += 1
print((sum(X) + sum(Y)))

Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = list(map(int, input().split()))
ret = (a + b) * [0]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
X = []
Y = []
A.sort()
B.sort()
C.sort()
if a < x :
    X = ((x - a) * [0]) + A
else:
    X = A[(a - x):]
if b < y:
    Y = ((y - b) * [0]) + B
else:
    Y = B[(b - y):]
idxA = 0
idxB = 0
idxC = c - 1
for i in reversed(range(c)):
    if idxA == len(X) and idxB == len(Y):
        break
    if idxA == len(X):
        if C[idxC] > Y[idxB]:
            Y[idxB] = C[idxC]
            idxB += 1
        else:
            break
    if idxB == len(Y):
        if C[idxC] > X[idxA]:
            X[idxA] = C[idxC]
            idxA += 1
        else:
            break
    if C[idxC] < min(X[idxA], Y[idxB]):
        break
    if X[idxA] <= Y[idxB]:
        X[idxA] = C[idxC]
        idxA += 1
    else:
        Y[idxB] = C[idxC]
        idxB += 1
print((sum(X) + sum(Y)))

Fixed submission:
x, y, a, b, c = list(map(int, input().split()))
ret = (a + b) * [0]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
X = []
Y = []
A.sort()
B.sort()
C.sort()

X = A[(a - x):]
Y = B[(b - y):]

idxA = 0
idxB = 0
idxC = c - 1
for i in reversed(range(c)):
    if idxA == x and idxB == y:
        break
    if idxA == x:
        if C[i] > Y[idxB]:
            Y[idxB] = C[i]
            idxB += 1
        else:
            break
    elif idxB == y:
        if C[i] > X[idxA]:
            X[idxA] = C[i]
            idxA += 1
        else:
            break
    elif C[i] <= min(X[idxA], Y[idxB]):
        break
    elif X[idxA] <= Y[idxB]:
        X[idxA] = C[i]
        idxA += 1
    else:
        Y[idxB] = C[i]
        idxB += 1
print((sum(X) + sum(Y)))