Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
r = sorted(r,reverse = True)
p = p[A-X:]
q = q[B-Y:]
if X+Y<C:
    r = r[:X+Y]
px = 0
qx = 0
for i in range(C):
    if px == len(p) and qx == len(q):
        break
    if px == len(p):
        if min(q[qx],r[i])==q[qx]:
            q[qx] =r[i]
            qx += 1
        else:
            break
    if qx == len(q):
        if min(p[px],r[i])==p[px]:
            p[px] =r[i]
            px += 1
        else:
            break
    else:
        if min(p[px],q[qx],r[i]) ==p[px]:
            p[px] = r[i]
            px +=1
        elif min(p[px],q[qx],r[i]) ==q[qx]:
            q[qx] = r[i]
            qx += 1
        else:
            break
print(sum(p)+sum(q))

Fixed submission:
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
r = sorted(r,reverse = True)
p = p[A-X:]
q = q[B-Y:]
if X+Y<C:
    r = r[:X+Y]
px = 0
qx = 0
for i in range(C):
    if px == len(p) and qx == len(q):
        break
    elif px == len(p):
        if min(q[qx],r[i])==q[qx]:
            q[qx] =r[i]
            qx += 1
        else:
            break
    elif qx == len(q):
        if min(p[px],r[i])==p[px]:
            p[px] =r[i]
            px += 1
        else:
            break
    else:
        if min(p[px],q[qx],r[i]) ==p[px]:
            p[px] = r[i]
            px +=1
        elif min(p[px],q[qx],r[i]) ==q[qx]:
            q[qx] = r[i]
            qx += 1
        else:
            break
print(sum(p)+sum(q))

Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
r = sorted(r,reverse = True)
p = p[A-X:]
q = q[B-Y:]
if X+Y<C:
    r = r[:X+Y+1]
px = 0
qx = 0
for i in range(X+Y):
    if px == len(p) or qx ==len(q):
        break
    if min(p[px],q[qx],r[i]) ==p[px]:
        p[px] = r[i]
        px +=1
    elif min(p[px],q[qx],r[i]) ==q[qx]:
        q[qx] = r[i]
        qx += 1
    else:
        px += 1
        qx += 1
print(sum(p)+sum(q))

Fixed submission:
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
r = sorted(r,reverse = True)
p = p[A-X:]
q = q[B-Y:]
if X+Y<C:
    r = r[:X+Y]
px = 0
qx = 0
for i in range(C):
    if px == len(p) and qx == len(q):
        break
    elif px == len(p):
        if min(q[qx],r[i])==q[qx]:
            q[qx] =r[i]
            qx += 1
        else:
            break
    elif qx == len(q):
        if min(p[px],r[i])==p[px]:
            p[px] =r[i]
            px += 1
        else:
            break
    else:
        if min(p[px],q[qx],r[i]) ==p[px]:
            p[px] = r[i]
            px +=1
        elif min(p[px],q[qx],r[i]) ==q[qx]:
            q[qx] = r[i]
            qx += 1
        else:
            break
print(sum(p)+sum(q))