Buggy python submission (verdict: Runtime Error):
import bisect
 
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()

x_list = p[-x:]
y_list = q[-y:]
r_list = r[-(x+y):]
 
while (min(x_list[0], y_list[0]) < r_list[-1]):
    if x_list[0] > y_list[0]:
        i = bisect.bisect_right(r, y_list[0])
        y_list.pop(0)
        target = r_list.pop(i)
        bisect.insort(y_list, target)
    else:
        i = bisect.bisect_right(r_list, x_list[0])
        x_list.pop(0)
        target = r_list.pop(i)
        bisect.insort(x_list, target)
 
    if len(r_list) == 0:
        break
 
print(sum(x_list) + sum(y_list))

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()
 
x_list = p[-x:]
y_list = q[-y:]
all_apple = x_list + y_list + r
all_apple.sort()
 
print(sum(all_apple[-(x+y):]))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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()

x_list = p[-x:]
y_list = q[-y:]

while (min(x_list[0], y_list[0]) < r[-1]):
    if x_list[0] > y_list[0]:
        i = bisect.bisect_right(r, y_list[0])
        y_list.pop(0)
        target = r.pop(i)
        bisect.insort(y_list, target)
    else:
        i = bisect.bisect_right(r, x_list[0])
        x_list.pop(0)
        target = r.pop(i)
        bisect.insort(x_list, target)

    if len(r) == 0:
        break

print(sum(x_list) + sum(y_list))

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()
 
x_list = p[-x:]
y_list = q[-y:]
all_apple = x_list + y_list + r
all_apple.sort()
 
print(sum(all_apple[-(x+y):]))

Buggy python submission (verdict: Runtime Error):
import bisect

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()

x_list = p[-x:]
y_list = q[-y:]

while (min(x_list[0], y_list[0]) < r[-1]):
    if x_list[0] > y_list[0]:
        i = bisect.bisect_left(r, y_list[0])
        y_list.pop(0)
        target = r.pop(i)
        bisect.insort(y_list, target)
    else:
        i = bisect.bisect_left(r, x_list[-1])
        x_list.pop(0)
        target = r.pop(i)
        bisect.insort(x_list, target)

    if len(r) == 0:
        break

print(sum(x_list) + sum(y_list))

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()
 
x_list = p[-x:]
y_list = q[-y:]
all_apple = x_list + y_list + r
all_apple.sort()
 
print(sum(all_apple[-(x+y):]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

x_list = p[:x]
y_list = q[:y]

while (min(x_list[-1], y_list[-1]) < r[0]):
    if x_list[-1] > y_list[-1]:
        y_list.pop()
        y_list.append(r[0])
        y_list.sort(reverse=True)
        r.pop(0)
    else:
        x_list.pop()
        x_list.append(r[0])
        x_list.sort(reverse=True)
        r.pop(0)
    if len(r) == 0:
        break

print(sum(x_list) + sum(y_list))

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()
 
x_list = p[-x:]
y_list = q[-y:]
all_apple = x_list + y_list + r
all_apple.sort()
 
print(sum(all_apple[-(x+y):]))