Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

i = 0
j = 0

while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
        if i+j == C:
            break
        if i == X-1:
            if Q[j] > R[i+j]:
                break
    else:
        j += 1
        if i+j == C:
            break
        if j == Y-1:
            if P[i] > R[i+j]:
                break
    if i+j == C:
        break

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

Fixed submission:
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

P.append(10**9+1)
Q.append(10**9+1)
R.append(0)


i = 0
j = 0


while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

P.remove(10**9+1)
Q.remove(10**9+1)
R.remove(0)

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

i = 0
j = 0

while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)


Fixed submission:
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

P.append(10**9+1)
Q.append(10**9+1)
R.append(0)


i = 0
j = 0


while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

P.remove(10**9+1)
Q.remove(10**9+1)
R.remove(0)

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

i = 0
j = 0

while min(P[i],Q[j])<R[i+j] and i+j<C:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)

Fixed submission:
X, Y, A, B, C = map(int,input().split())
P = [int(_) for _ in input().split()]
Q = [int(_) for _ in input().split()]
R = [int(_) for _ in input().split()]

P.sort()
Q.sort()
R.sort()
R.reverse()

P = P[A-X:]
Q = Q[B-Y:]

P.append(10**9+1)
Q.append(10**9+1)
R.append(0)


i = 0
j = 0


while min(P[i],Q[j])<R[i+j]:
    if P[i] < Q[j]:
        i += 1
    else:
        j += 1
    if i+j == C:
        break

P.remove(10**9+1)
Q.remove(10**9+1)
R.remove(0)

ans = 0
for e in P[i:]:
    ans = ans + e
for e in Q[j:]:
    ans = ans + e
for a in range(i+j):
    ans = ans + R[a]

print(ans)