Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# vim: fileencoding=utf-8


def main():
    n, k = map(int, input().split())
    aList = list(map(int, input().split()))
    hyoukaList = []
    c = 1
    for i in aList:
        hyoukaList.append(i)
        b = hyoukaList[0]

        if c <= k:
            c += 1
            continue

        hyoukaList = hyoukaList[1:]
        if b < i:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


Fixed submission:
# vim: fileencoding=utf-8


def main():
    n, k = map(int, input().split())
    aList = list(map(int, input().split()))
    hyoukaList = []
    c = 1
    for i in range(n):
        if i < k:
            continue
        b = aList[i - k]
        a = aList[i]

        if b < a:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# vim: fileencoding=utf-8


def main():
    n, k = map(int, input().split())
    aList = list(map(int, input().split()))
    hyoukaList = aList[:k]
    beforeHyouka = 1
    for i in hyoukaList:
        beforeHyouka *= i

    for i in aList[k:]:
        t = hyoukaList[1:]
        t.append(i)
        hyoukaList = t

        hyouka = 1
        for i in hyoukaList:
            hyouka *= i

        if beforeHyouka < hyouka:
            print("Yes")
        else:
            print("No")
        beforeHyouka = hyouka


if __name__ == "__main__":
    main()


Fixed submission:
# vim: fileencoding=utf-8


def main():
    n, k = map(int, input().split())
    aList = list(map(int, input().split()))
    hyoukaList = []
    c = 1
    for i in range(n):
        if i < k:
            continue
        b = aList[i - k]
        a = aList[i]

        if b < a:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# vim: fileencoding=utf-8


def main():
    n = int(input())
    li = list(map(int, input().split()))
    res = 0
    li.sort(reverse=True)
    tmp = [li[0]]
    for e in li[1:]:
        res += tmp[0]
        tmp = tmp[1:]
        tmp.append(e)
        tmp.append(e)
    print(res)


if __name__ == "__main__":
    main()


Fixed submission:
# vim: fileencoding=utf-8


def main():
    n = int(input())
    li = list(map(int, input().split()))
    res = 0
    li = li + li
    li.sort()
    tmp = int(len(li) / 2)
    print(sum(li[-tmp:-1]))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, Q: int, A: "List[int]"):
    p = [K] * N
    for i in range(Q):
        q = A[i]
        p = list(map(lambda x: x -1, p))
        p[q-1] += 1

    for i in range(N):
        if p[i] > 0:
            print(YES)
        else:
            print(NO)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, Q: int, A: "List[int]"):
    p = [Q] * N
    for i in range(Q):
        p[A[i]-1] -= 1

    for i in range(N):
        if K - p[i]  > 0:
            print(YES)
        else:
            print(NO)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, S: "List[str]"):
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                continue
            if i - 1 >= 0:
                if S[i - 1][j] == "#":
                    continue
            if i + 1 < H:
                if S[i + 1][j] == "#":
                    continue
            if j - 1 >= 0 and S[i][j - 1] == "#":
                continue
            if j + 1 < W and S[i][j + 1] == "#":
                continue
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [list(next(tokens)) for _ in range(W)]  # type: "List[str]"
    solve(H, W, S)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, S: "List[str]"):
    for i in range(H):
        for j in range(W):
            if S[i][j] == ".":
                continue
            if i - 1 >= 0:
                if S[i - 1][j] == "#":
                    continue
            if i + 1 < H:
                if S[i + 1][j] == "#":
                    continue
            if j - 1 >= 0 and S[i][j - 1] == "#":
                continue
            if j + 1 < W and S[i][j + 1] == "#":
                continue
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [list(next(tokens)) for _ in range(H)]  # type: "List[str]"
    solve(H, W, S)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# vim: fileencoding=utf-8


def main():
    s = input()
    p = 700
    if s[0] == 'o';
        p += 100
    if s[1] == 'o';
        p += 100
    if s[2] == 'o';
        p += 100
    print(p)


if __name__ == '__main__':
    main()


Fixed submission:
# vim: fileencoding=utf-8


def main():
    s = input()
    p = 700
    if s[0] == "o":
        p += 100
    if s[1] == "o":
        p += 100
    if s[2] == "o":
        p += 100
    print(p)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, A: "List[int]"):
    ans = 0
    for i in range(X-1, 0, -1):
        if i in A:
            ans += 1
    c = 0
    for i in range(X+1, N):
        if i in A:
            c += 1
    if ans > c:
        ans = c
    print(ans)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':
 

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, A: "List[int]"):
    ans = 0
    for i in range(X-1, 0, -1):
        if i in A:
            ans += 1
    c = 0
    for i in range(X+1, N):
        if i in A:
            c += 1
    if ans > c:
        ans = c
    print(ans)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int):
    p = 1
    for i in range(1,N+1):
        p *= i
    print(p % MOD)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int):
    p = 1
    for i in range(1,N+1):
        p = p * i % MOD
    print(p)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# vim: fileencoding=utf-8


def main():
    k, s = map(int, input().split())
    c = 0
    for i in range(k + 1):
        for j in range(k + 1):
            for l in range(k + 1):
                if i + j + l == s:
                    c += 1
    print(c)


if __name__ == "__main__":
    main()


Fixed submission:
# vim: fileencoding=utf-8


def main():
    k, s = map(int, input().split())
    c = 0
    for i in range(k + 1):
        for j in range(k + 1):
            z = s - i - j
            if z >= 0 and z <= k:
                c += 1
    print(c)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

sm=1
sm_lst=[]
for i in range(n):
    sm*=a[i]
    if i>=k:
        sm//=a[i-k]
        if sm > sm_lst[i-1]:
            print("Yes")
        else:
            print("No")
    sm_lst.append(sm)


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k,n):
        if a[i] > a[i-k]:
            print("Yes")
        else:
            print("No")
Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
alphabet="abcdefghijklmnopqrstuvwxyz"
l=[]
a=1
sm=0
for i in range(15):
    a*=26
    sm+=a
    l.append(sm)

for i in range(len(l)):
    if n<=l[i]:
        cl=i
        break

if cl==0:
    print(alphabet[n-1])
    sys.exit()
ans=""
n-=l[cl-1]

for i in range(cl):
    num=n//(26**(cl-i))
    if num%(26**(cl-i))!=0:
        ans=ans+alphabet[num]
    else:
        ans=ans+"z"
    n-=((26**(cl-i))*num)

if n!=0:
    ans=ans+alphabet[n-1]
else:
    ans=ans+"z"
print(ans)

Fixed submission:
import sys
n=int(input())
alphabet="abcdefghijklmnopqrstuvwxyz"
l=[]
a=1
sm=0
for i in range(15):
    a*=26
    sm+=a
    l.append(sm)

for i in range(len(l)):
    if n<=l[i]:
        cl=i
        break

if cl==0:
    print(alphabet[n-1])
    sys.exit()
ans=""
n-=l[cl-1]

#最後の１文字以外を決める
for i in range(cl):
    num=(n-1)//(26**(cl-i))
    ans=ans+alphabet[num]
    n-=(26**(cl-i))*num

if n!=0:
    ans=ans+alphabet[n-1]
else:
    ans=ans+"z"
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
n=int(input())
alphabet="abcdefghijklmnopqrstuvwxyz"
l=[]
a=1
sm=0
for i in range(15):
    a*=26
    sm+=a
    l.append(sm)

for i in range(len(l)):
    if n<=l[i]:
        cl=i
        break

if cl==0:
    print(alphabet[n-1])
    sys.exit()
ans=""
n-=l[cl-1]

for i in range(cl):
    num=n//(26**(cl-i))
    ans=ans+alphabet[num]
    n-=((26**(cl-i))*num)

ans=ans+alphabet[n-1]
print(ans)

Fixed submission:
import sys
n=int(input())
alphabet="abcdefghijklmnopqrstuvwxyz"
l=[]
a=1
sm=0
for i in range(15):
    a*=26
    sm+=a
    l.append(sm)

for i in range(len(l)):
    if n<=l[i]:
        cl=i
        break

if cl==0:
    print(alphabet[n-1])
    sys.exit()
ans=""
n-=l[cl-1]

#最後の１文字以外を決める
for i in range(cl):
    num=(n-1)//(26**(cl-i))
    ans=ans+alphabet[num]
    n-=(26**(cl-i))*num

if n!=0:
    ans=ans+alphabet[n-1]
else:
    ans=ans+"z"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

a0b=[0]*n
c=[0]*30
for i in range(n):
    a0b[i]=bin(a[i])
    st=str(a0b[i])
    for j in range(len(st)-2):
        z=a0b[i][-1-j]
        z=int(z)
        c[j]+=z

c_al=[0]*30
al=0
for i in range(len(c)):
    if c[i]%2==1:
        al+=2**i

#c_alは全体の排他的論理和
ans=[0]*n
for i in range(n):
    ans[i]=al^a[i]
L=[str(a) for a in ans]
L=" ".join(L)
print(L)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))

c=a[0]
for i in range(n-1):
    c=c^a[i+1]

ans=[0]*n
for i in range(n):
    ans[i]=c^a[i]
L=[str(a) for a in ans]
L=" ".join(L)
print(L)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))

ans=1
i=0
while ans<=10**18:
    ans*=a[i]
    i+=1
    
if ans>10**18:
    print("-1")
else:
    print(ans)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))


if 0 in a:
    print(0)
else:
    ans=1
    i=0
    while ans<=10**18 and i<n:
        ans*=a[i]
        i+=1

    if ans>10**18:
        print("-1")
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
ans=1
for i in range(n):
    ans*=a[i]

if ans>10**18:
    print("-1")
else:
    print(ans)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))


if 0 in a:
    print(0)
else:
    ans=1
    i=0
    while ans<=10**18 and i<n:
        ans*=a[i]
        i+=1

    if ans>10**18:
        print("-1")
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, k= int(input().split())

if a>=k:
    print(k)
elif a+b>=k:
    print(a)
else:
    print(2*a-k-b)

Fixed submission:
a, b, c, k= map(int, input().split())

if a>=k:
    print(k)
elif a+b>=k:
    print(a)
else:
    print(2*a-k+b)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b=map(int,input().split())

fly=0
l=[]
while fly<b:
    fly += k
    l.append(fly)

if l[-1]>=a and l[-1]<=b:
    print('OK')
elif l[-2]>=a and l[-2]<=b:
    print('OK')
else:
    print('NG')

Fixed submission:
k = int(input())
a, b=map(int,input().split())

fly=0
l=[]
while fly<b:
    fly += k
    l.append(fly)
    
if len(l)==1:
    if k>=a and k<=b:
        print('OK')
    else:
        print('NG')
else:
    if l[-1]>=a and l[-1]<=b:
        print('OK')
    elif l[-2]>=a and l[-2]<=b:
        print('OK')
    else:
        print('NG')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

b =[0]*n

for i in a:
    b[a[i]-1] += 1

for i in b:
    print(i)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

b =[0]*n

for i in range(n-1):
    b[a[i]-1] += 1

for i in b:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
g =[math.gcd(math.gcd(i+1, j+1), l+1) for i in range(k) for j in range(k) for l in range(k)]
print(sum(g))

Fixed submission:
import math
k = int(input())

sm=0
for i in range(1,k+1):
    for l in range(1,k+1):
        gcdab=math.gcd(i,l)
        for m in range(1,k+1):
            sm+=math.gcd(gcdab,m)

print(sm)

Buggy python submission (verdict: Runtime Error):
from fractions import math

k = int(input())

g =[gcd(math.gcd(i+1, j+1), l+1) for i in range(k) for j in range(k) for l in range(k)]
print(sum(g))

Fixed submission:
import math
k = int(input())

sm=0
for i in range(1,k+1):
    for l in range(1,k+1):
        gcdab=math.gcd(i,l)
        for m in range(1,k+1):
            sm+=math.gcd(gcdab,m)

print(sm)

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

k = int(input())

g =[math.gcd(math.gcd(i+1, j+1), l+1) for i in range(k) for j in range(k) for l in range(k)]
print(sum(g))

Fixed submission:
import math
k = int(input())

sm=0
for i in range(1,k+1):
    for l in range(1,k+1):
        gcdab=math.gcd(i,l)
        for m in range(1,k+1):
            sm+=math.gcd(gcdab,m)

print(sm)

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

k = int(input())

g = 0

for i in range(k):
    for j in range(k):
        for l in range(k):
            y = math.gcd(i+1, j+1)
            z = math.gcd(y, l+1)
            g += z

print(g)

Fixed submission:
import math
k = int(input())

sm=0
for i in range(1,k+1):
    for l in range(1,k+1):
        gcdab=math.gcd(i,l)
        for m in range(1,k+1):
            sm+=math.gcd(gcdab,m)

print(sm)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
"""
rcount=0
gcount=0
bcount=0
for i in range(n):
    if s[i]=="R":
        rcount+=1
    elif s[i]=="G":
        gcount+=1
    else:
        bcount+=1
"""
al=s.count("R")*s.count("G")*s.count("B")

for i in range(n-2):
    for k in range(i+1,n):
        dis=k-i
        l=k+dis
        if k+dis>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)


Fixed submission:
n = int(input())
s = input()

al=s.count("R")*s.count("G")*s.count("B")

for i in range(n-2):
    for k in range(i+1,n-1):
        l=k+(k-i)
        if l>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

rcount=0
gcount=0
bcount=0
for i in range(n):
    if s[i]=="R":
        rcount+=1
    elif s[i]=="G":
        gcount+=1
    else:
        bcount+=1

al=rcount*bcount*gcount

for i in range(n-2):
    for k in range(i+1,n):
        dis=k-i
        l=k+dis
        if k+dis>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)


Fixed submission:
n = int(input())
s = input()

al=s.count("R")*s.count("G")*s.count("B")

for i in range(n-2):
    for k in range(i+1,n-1):
        l=k+(k-i)
        if l>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

rcount=0
gcount=0
bcount=0
for i in range(n):
    if s[i]=="R":
        rcount+=1
    elif s[i]=="G":
        gcount+=1
    else:
        bcount+=1

al=rcount*bcount*gcount

for i in range(n-2):
    for k in range(i+1,n):
        dis=k-i
        l=k+dis
        if k+dis>n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)


Fixed submission:
n = int(input())
s = input()

al=s.count("R")*s.count("G")*s.count("B")

for i in range(n-2):
    for k in range(i+1,n-1):
        l=k+(k-i)
        if l>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

rcount=0
gcount=0
bcount=0
for i in range(n):
    if s[i]=="R":
        rcount+=1
    elif s[i]=="G":
        gcount+=1
    else:
        bcount+=1

al=rcount*bcount*gcount

for i in range(n-2):
    for k in range(i+1,n):
        dis=k-i
        if k+dis<=n-1:
            l=k+dis
            if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
                al-=1

print(al)


Fixed submission:
n = int(input())
s = input()

al=s.count("R")*s.count("G")*s.count("B")

for i in range(n-2):
    for k in range(i+1,n-1):
        l=k+(k-i)
        if l>=n:
            continue
        if s[i]!=s[k] and s[i]!=s[l] and s[k]!=s[l]:
            al-=1

print(al)
Buggy python submission (verdict: Runtime Error):
X, Y, Z = input()
A = X
B = Y
C = Z

B2 = A
A2 = B

A3 = C
C3 = A2

print(A3, B2, C3)

Fixed submission:
X, Y, Z =(map(int,input().split()))
A = X
B = Y
C = Z

B2 = A
A2 = B

A3 = C
C3 = A2

print(A3, B2, C3)
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())

a = N // K
b = abs(N - (K*a))
c = abs(N - (K*(a+1)))
print(min(b, c))

Fixed submission:
N,K=(map(int,input().split()))

a = N // K
b = abs(N - (K*a))
c = abs(N - (K*(a+1)))
print(min(b, c))
Buggy python submission (verdict: Runtime Error):
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]

p_idx=0
q_idx=0
plen=len(p)
qlen=len(q)
for i in range(c):
    #処理が終わる時
    if p[p_idx]>r[i] and q[q_idx]>r[i]:
        break
    #全部入れ替わる
    if p_idx==plen and q_idx==qlen:
        break
    if q_idx==qlen:
        if p[p_idx]>r[i]:
            break
        else:
            p[p_idx]=r[i]
            p_idx+=1
    if p_idx==plen:
        if q[q_idx]>r[i]:
            break
        else:
            q[q_idx]=r[i]
            q_idx+=1
    if p[p_idx]<=q[q_idx]:
        p[p_idx]=r[i]
        p_idx+=1
    if q[q_idx]<=p[p_idx]:
        q[q_idx]=r[i]
        q_idx+=1

ans=sum(p)+sum(q)
print(ans)

Fixed submission:
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]
p.extend(q)
p.sort()

idx=0
for i in range(len(p)):
    if p[i]>r[idx]:
        break
    else:
        p[i]=r[idx]
        idx+=1
        if c==idx:
            break

print(sum(p))

Buggy python submission (verdict: Runtime Error):
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]

p_idx=0
q_idx=0
plen=len(p)
qlen=len(q)
for i in range(c):
    #処理が終わる時
    if p[p_idx]>r[i] and q[q_idx]>r[i]:
        break
    #全部入れ替わる
    if p_idx==plen and q_idx==qlen:
        break
    #どちらかが全部入れ替わる
    #それ以外
    if p[p_idx]<=q[q_idx] or q_idx==qlen:
        if p[p_idx]>r[i]:
            break
        else:
            p[p_idx]=r[i]
            p_idx+=1
    if q[q_idx]<=p[p_idx] or p_idx==plen:
        if q[q_idx]>r[i]:
            break
        else:
            q[q_idx]=r[i]
            q_idx+=1

ans=sum(p)+sum(q)
print(ans)

Fixed submission:
x, y, a, b ,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
sm=0
p.sort()
q.sort()
r.sort(reverse=True)

p=p[(a-x):]
q=q[(b-y):]
p.extend(q)
p.sort()

idx=0
for i in range(len(p)):
    if p[i]>r[idx]:
        break
    else:
        p[i]=r[idx]
        idx+=1
        if c==idx:
            break

print(sum(p))