Problem p02727 (python)

Fixed submission:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,a,b,c=map(int,input().split())
    p=sorted(list(map(int,input().split())), reverse=True)[:x]
    q=sorted(list(map(int,input().split())), reverse=True)[:y]
    r=sorted(list(map(int,input().split())), reverse=True)
    print(sum(sorted((p+q+r), reverse=True)[:x+y]))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,a,b,c=map(int,input().split())
    p=sorted(list(map(int,input().split())), reverse=True)[:x]
    q=sorted(list(map(int,input().split())), reverse=True)[:y]
    r=sorted(list(map(int,input().split())), reverse=True)
    print(sum(sorted(p+q+r), reverse=True)[:x+y])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    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)

    ptn1 = 0
    ptn2 = 0
    ptn1 = sum(q[:y])
    ptn2 = sum(p[:x])
    idxr = 0
    idxp = 0
    for i in range(x):
        if r[idxr] > p[idxp]:
            ptn1 += r[idxr]
            idxr += 1
        else:
            ptn1 += p[idxp]
            idxq += 1
    idxr = 0
    idxq = 0
    for i in range(y):
        if r[idxr] > q[idxq]:
            ptn2 += r[idxr]
            idxr += 1
        else:
            ptn2 += q[idxq]
            idxq += 1

    print(max(ptn1,ptn2))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    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)

    ptn1 = 0
    ptn2 = 0
    ptn1 = sum(q[:y])
    ptn2 = sum(p[:x])
    idxr = 0
    idxp = 0
    for i in range(x):
        if r[idxr] > p[idxp]:
            ptn1 += r[idxr]
            idxr += 1
        else:
            ptn1 += p[idx]
            idxq += 1
    idxr = 0
    idxq = 0
    for i in range(y):
        if r[idxr] > q[idxq]:
            ptn2 += r[idxr]
            idxr += 1
        else:
            ptn2 += q[idxq]
            idxq += 1

    print(max(ptn1,ptn2))
if __name__ == '__main__':
    main()