Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]

def pick(list1,list2,number):
    list_f = list1.copy()
    list_f2 = list1.copy()
    list_s = list2.copy()
    list_f2.extend(list_s)
    list_f2.sort(reverse = True)
    total_deli = 0
    for i in range(number):
        delic = list_f2[0]
        total_deli += int(delic)
        if(delic not in list_f):
            list_s.remove(delic)
        list_f2.remove(delic)
    return total_deli, list_s


ans1 = 0
ans2 = 0
ans3 = 0
clear_apple = []

#パターン1：赤リンゴから緑のリンゴへ
ans1,clear_apple = pick(p,r,x)
ans2,clear_apple = pick(q,clear_apple,y)
ans3 = ans1 + ans2

#パターン2：緑のリンゴから赤のリンゴへ
ans1,clear_apple = pick(q,r,y)
ans2,clear_apple = pick(p,clear_apple,x)
ans2 = ans1 + ans2

ans = max(ans2,ans3)
print("{}".format(ans))

Fixed submission:
#coding:utf-8
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort(reverse = True)
q.sort(reverse = True)

p = p[0:x]
q = q[0:y]

p.extend(q)
p.extend(r)
p.sort(reverse = True)

ans = 0

for i in range(x + y):
  ans += p[i]
  
print("{}".format(ans))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import copy
x, y, a, b, c = map(int, input().split())
p = input().split()
q = input().split()
r = input().split()
p = [int(i) for i in p]
q = [int(i) for i in q]
r = [int(i) for i in r]

def pick(list1,list2,number):
    list_f = copy.copy(list1)
    list_f2 = copy.copy(list1)
    list_s = copy.copy(list2)
    list_f2.extend(list_s)
    list_f2.sort(reverse = True)
    total_deli = 0
    for i in range(number):
        delic = list_f2[0]
        total_deli += int(delic)
        if(delic not in list_f):
            list_s.remove(delic)
        list_f2.remove(delic)
    return total_deli, list_s


ans1 = 0
ans2 = 0
ans3 = 0
clear_apple = []

#パターン1：赤リンゴから緑のリンゴへ
ans1,clear_apple = pick(p,r,x)
ans2,clear_apple = pick(q,clear_apple,y)
ans3 = ans1 + ans2

#パターン2：緑のリンゴから赤のリンゴへ
ans1,clear_apple = pick(q,r,y)
ans2,clear_apple = pick(p,clear_apple,x)
ans2 = ans1 + ans2

ans = max(ans2,ans3)
print("{}".format(ans))

Fixed submission:
#coding:utf-8
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort(reverse = True)
q.sort(reverse = True)

p = p[0:x]
q = q[0:y]

p.extend(q)
p.extend(r)
p.sort(reverse = True)

ans = 0

for i in range(x + y):
  ans += p[i]
  
print("{}".format(ans))

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import copy
x, y, a, b, c = map(int, input().split())
p = input().split()
q = input().split()
r = input().split()
lis = [p,q,r]
coco = 0
for i in [len(p),len(q),len(r)]:
  for j in range(i):
    lis[coco][j] = int(lis[coco][j])
  coco += 1

def pick(list1,list2,number):
    list_f = copy.copy(list1)
    list_f2 = copy.copy(list1)
    list_s = copy.copy(list2)
    list_f2.extend(list_s)
    list_f2.sort(reverse = True)
    total_deli = 0
    for i in range(number):
        delic = list_f2[0]
        total_deli += int(delic)
        if(delic not in list_f):
            list_s.remove(delic)
        list_f2.remove(delic)
    return total_deli, list_s


ans1 = 0
ans2 = 0
ans3 = 0
clear_apple = []

#パターン1：赤リンゴから緑のリンゴへ
ans1,clear_apple = pick(p,r,x)
ans2,clear_apple = pick(q,clear_apple,y)
ans3 = ans1 + ans2

#パターン2：緑のリンゴから赤のリンゴへ
ans1,clear_apple = pick(q,r,y)
ans2,clear_apple = pick(p,clear_apple,x)
ans2 = ans1 + ans2

ans = max(ans2,ans3)
print("{}".format(ans))

Fixed submission:
#coding:utf-8
x, y, a, b, c = map(int, input().split())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]
r = [int(i) for i in input().split()]
p.sort(reverse = True)
q.sort(reverse = True)

p = p[0:x]
q = q[0:y]

p.extend(q)
p.extend(r)
p.sort(reverse = True)

ans = 0

for i in range(x + y):
  ans += p[i]
  
print("{}".format(ans))