Buggy python submission (verdict: Runtime Error):
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]
 
P.sort()
Q.sort()
R.sort()
 
P = P[A-X:]
Q = Q[B-Y:]

ans = 0
while True:
    if P and Q:
        if P[-1] > Q[-1] and X > 0:
            if P[-1] > R[-1]:
                ans += P.pop()
            else:
                ans += R.pop()
            X -= 1
        else:
            if Q[-1] > R[-1]:
                ans += Q.pop()
            else:
                ans += R.pop()
            Y -= 1
    elif P and R:
        if P[-1] > R[-1]:
                ans += P.pop()
        else:
            ans += R.pop()
        X -= 1
    elif Q and R:
        if Q[-1] > R[-1]:
                ans += Q.pop()
        else:
            ans += R.pop()
        Y -= 1
    elif P:
        ans += P.pop()
        X -= 1
    elif Q:
        ans += Q.pop()
        Y -= 1
        
    if X == 0 and Y == 0:
            break
print(ans)

Fixed submission:
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

P.sort(reverse=True)
Q.sort(reverse=True)

res = P[:X] + Q[:Y] + R
res.sort(reverse=True)

print(sum(res[:X+Y]))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

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

P = [0]*(10**5) + P[A-X:]
Q = [0]*(10**5) + Q[B-Y:]
R = [0]*(10**5) + R

ans = 0
while True:
    if P[-1] > Q[-1]:
        if P[-1] > R[-1]:
            ans += P.pop()
        else:
            ans += R.pop()
        X -= 1
    else:
        if Q[-1] > R[-1]:
            ans += Q.pop()
        else:
            ans += R.pop()
        Y -= 1
    if X == 0 and Y == 0:
        break
print(ans)

Fixed submission:
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

P.sort(reverse=True)
Q.sort(reverse=True)

res = P[:X] + Q[:Y] + R
res.sort(reverse=True)

print(sum(res[:X+Y]))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

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

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

ans = 0

while True:
    if X > 0 and Y > 0:
        if P[-1] > Q[-1]:
            if P[-1] > R[-1]:
                ans += P.pop()
                X -= 1
            else:
                ans += R.pop()
        else:
            if Q[-1] > R[-1]:
                ans += Q.pop()
                Y -= 1
            else:
                ans += R.pop()
    elif X > 0 and Y == 0 and R:
        X -= 1
        if P[-1] < R[-1]:
            ans += R.pop()
        else:
            ans += P.pop()
    elif X == 0 and Y > 0 and R:
        Y -= 1
        if Q[-1] < R[-1]:
            ans += R.pop()
        else:
            ans += Q.pop()
    else:
        break
print(ans)

Fixed submission:
from sys import stdin
X,Y,A,B,C = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
Q = [int(x) for x in stdin.readline().rstrip().split()]
R = [int(x) for x in stdin.readline().rstrip().split()]

P.sort(reverse=True)
Q.sort(reverse=True)

res = P[:X] + Q[:Y] + R
res.sort(reverse=True)

print(sum(res[:X+Y]))