Buggy python submission (verdict: Runtime Error):
import collections
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)


q1 = collections.deque(aas)
q2 = collections.deque(bbs)
q3 = collections.deque(ccs)

rq1 = collections.deque()
rq2 = collections.deque()
while(q3 and q2 and q1 and len(rq1) < x and len(rq2) < y):
	if q3[0] > max(q1[0], q2[0]):
		if q2[0] >= q1[0]:
			rq1.append(q3.popleft())
		else:
			rq2.append(q3.popleft())
	else:
		if q2[0] >= q1[0]:
			rq2.append(q2.popleft())
		else:
			rq1.append(q1.popleft())

while(len(rq1) < x):
	if q3 and q3[0] > q1[0]:
		rq1.append(q3.popleft())
	else:
		rq1.append(q1.popleft())
while(len(rq2) < y):
	if q3 and q3[0] > q2[0]:
		rq1.append(q3.popleft())
	else:
		rq1.append(q2.popleft())

print sum(rq1) + sum(rq2)


Fixed submission:
import collections
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)
aas = aas[:x]
bbs = bbs[:y]

r = (aas + bbs)
r.sort()

i = 0
j = 0
while(j < len(ccs) and i < len(r)):
	if ccs[j] > r[i]:
		r[i] = ccs[j]
		i+=1
	j+=1

print sum(r)

Buggy python submission (verdict: Time Limit Exceeded):
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))
aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)

for i in range(1,len(aas)): aas[i] += aas[i-1]
for i in range(1,len(bbs)): bbs[i] += bbs[i-1]
for i in range(1,len(ccs)): ccs[i] += ccs[i-1]


r = 0

for a in range(x + 1):
	for b in range(y + 1)[::-1]:
		m = (aas[a-1] if a-1 >= 0 else 0) + (bbs[b-1] if b-1 >=0 else 0)
		c = x + y - (a + b)
		if c == 0:
			m += 0
		elif c > 0 and c-1 < len(ccs): 	 	
			m += ccs[c-1]
		else: 
			m+= -float('inf')
			break
		r = max(r, m)

print r


Fixed submission:
import collections
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)
aas = aas[:x]
bbs = bbs[:y]

r = (aas + bbs)
r.sort()

i = 0
j = 0
while(j < len(ccs) and i < len(r)):
	if ccs[j] > r[i]:
		r[i] = ccs[j]
		i+=1
	j+=1

print sum(r)

Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))
aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)

for i in range(1,len(aas)): aas[i] += aas[i-1]
for i in range(1,len(bbs)): bbs[i] += bbs[i-1]
for i in range(1,len(ccs)): ccs[i] += ccs[i-1]


r = 0
for a in range(x+1):
	for b in range(y+1):
		m = (aas[a-1] if a-1 >= 0 else 0) + (bbs[b-1] if b-1 >=0 else 0)
		c = x + y - (a + b)
		if c > 0 and c-1 < len(ccs): 	 	
			m += ccs[c-1]
		else: 
			if c: m+= -float('inf')

		r = max(r, m)

print r


Fixed submission:
import collections
x,y,aa,bb,cc = map(int,raw_input().split(' '))

aas = map(int, raw_input().split(' '))
bbs = map(int, raw_input().split(' '))
ccs = map(int, raw_input().split(' '))

aas.sort(key = lambda x:-x)
bbs.sort(key = lambda x:-x)
ccs.sort(key = lambda x:-x)
aas = aas[:x]
bbs = bbs[:y]

r = (aas + bbs)
r.sort()

i = 0
j = 0
while(j < len(ccs) and i < len(r)):
	if ccs[j] > r[i]:
		r[i] = ccs[j]
		i+=1
	j+=1

print sum(r)