Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)

z = sorted(p+q+r,reverse=True)
ans = 0
c = 0
for i in z:
    if x+y-c==0:
        break
    elif p and i == p[0] and x>0:
        ans+=i
        p.pop(0)
        x -= 1
    elif q and i == q[0] and y>0:
        ans += i
        q.pop(0)
        y -= 1
    elif i == r[0] and x+y-c>0:
        ans += i
        r.pop(0)
        c += 1
print(ans)

Fixed submission:
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())))
q = sorted(list(map(int,input().split())))
r = sorted(list(map(int,input().split())))

z = sorted(p+q+r,reverse=True)
ans = 0
c = 0
for i in z:
    if x+y-c==0:
        break
    elif p and i == p[-1] and x>0:
        ans+=i
        p.pop()
        x -= 1
    elif q and i == q[-1] and y>0:
        ans += i
        q.pop()
        y -= 1
    elif i == r[-1] and x+y-c>0:
        ans += i
        r.pop()
        c += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)

z = sorted(p+q+r,reverse=True)
ans = 0
c = 0
for i in z:
    if x+y-c==0:
        break
    elif p and i == p[0] and x>0:
        ans+=i
        p.pop(0)
        x -= 1
    elif q and i == q[0] and y>0:
        ans += i
        q.pop(0)
        y -= 1
    elif i == r[0] and x+y-c>0:
        ans += i
        r.pop(0)
        c += 1
print(ans)

Fixed submission:
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())))
q = sorted(list(map(int,input().split())))
r = sorted(list(map(int,input().split())))

z = sorted(p+q+r,reverse=True)
ans = 0
c = 0
for i in z:
    if x+y-c==0:
        break
    elif p and i == p[-1] and x>0:
        ans+=i
        p.pop()
        x -= 1
    elif q and i == q[-1] and y>0:
        ans += i
        q.pop()
        y -= 1
    elif i == r[-1] and x+y-c>0:
        ans += i
        r.pop()
        c += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)

z = sorted(p+q+r,reverse=True)
ans = 0
c = 0
for i in z:
    if x+y-c==0:
        break
    elif i in p and x>0:
        ans+=i
        p.pop(0)
        x -= 1
    elif i in q and y>0:
        ans += i
        q.pop(0)
        y -= 1
    elif i in r and x+y-c>0:
        ans += i
        c += 1
print(ans)

Fixed submission:
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())))
q = sorted(list(map(int,input().split())))
r = sorted(list(map(int,input().split())))

z = sorted(p+q+r,reverse=True)
ans = 0
c = 0
for i in z:
    if x+y-c==0:
        break
    elif p and i == p[-1] and x>0:
        ans+=i
        p.pop()
        x -= 1
    elif q and i == q[-1] and y>0:
        ans += i
        q.pop()
        y -= 1
    elif i == r[-1] and x+y-c>0:
        ans += i
        r.pop()
        c += 1
print(ans)