Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02729 (python)

Fixed submission:
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())
 
n,m=IA()
def f1(n):
    res=1
    for i in range(1,n+1):
        res*=i
    return res
def f(n):
    if n<2:return 0
    return f1(n)//(f1(n-2)*f1(2))

print(f(n)+f(m))

Buggy submission (verdict: Runtime Error):
import math

 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())

n,m,K=IA()
a=["" for i in range(0,n)]
for i in range(0,n):
    a[i]=input()

ans=n*m+1
for k in range(0,1<<(n-1)):
    res=0
    temp=[]
    for j in range(0,(n-1)):
        if (k&(1<<(j)))!=0:
            temp.append(j)
            res+=1
    le=len(temp) 
    if le==0:
        temp.append(n-1)
        
    if temp[le-1]!=n-1:
        temp.append(n-1)
    le=len(temp) 
    #print(k)  
    #print(temp)


    
    sum1=[0 for i in range(0,11)]
    flag=0
    for j in range(0,m):
        last=0
        for t in range(0,le):
            for w in range(last,temp[t]+1):
                ## print(str(w)+" "+str(j))
                if a[w][j]=='1':
                    sum1[t]+=1
            last=temp[t]+1
            if sum1[t]>K:
                
                res+=1
                last=0
                sum1=[0 for i in range(0,11)]
                for t1 in range(0,le):
                    for w1 in range(last,temp[t1]+1):
                        if a[w1][j]=='1':
                            sum1[t1]+=1
                    if sum1[t]>K:
                        flag=1
                        res=n*m+1
                        break
                    last=temp[t]+1
                    
                break
        if flag==1:break
       
    ans=min(res,ans)
                
            
    
print(ans)
Problem p02771 (python)

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

if a == b and b == c and c == a:
    print("No")

elif a != b and b != c and c != a:
    print("No")

else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
#import numpy as np
n = int(input())
input = sys.stdin.readline
#a = np.array(list(map(int, input().split())))
a = list(map(int, input().split()))
for i in a:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            print('DENIED')
            exit()
print('APPROVED')
Problem p02829 (python)

Fixed submission:
a = input()
b = input()

list = ['1','2','3']
list.remove(a)
list.remove(b)

print(list[0])

Buggy submission (verdict: Runtime Error):
import fractions
a,b = map(lambda x: int(x), input().split())

print(int(a * b / fractions.gcd(a, b)))
Problem p02831 (python)

Fixed submission:
a,b = map(lambda x: int(x), input().split())
c = a
d = b
if a < b:
    a, b = b, a
while a % b != 0:
    a, b = b, a % b

print(c*d // b)

Buggy submission (verdict: Runtime Error):
import math
a,b = map(lambda x: int(x), input().split())

print(int(a * b / math.gcd(a, b)))
Problem p02833 (python)

Fixed submission:
n = int(input())
x = 10
count = 0
if n % 2 == 0:
    while x <= n :
        count += n // x
        x *= 5
    print(count)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n = int(input())
count = 0
def f(n) :
    if n < 2 :
        return 1
    else:
        return n * f(n-2)

a = f(n)
while a % 10 == 0:
    count+= 1
    a //= 10

print(count)
Problem p02879 (python)

Fixed submission:
a, b =  (int(x) for x in input().split())
if a > 9 or b > 9 :
  print('-1')
else :
  print(a*b)

Buggy submission (verdict: Runtime Error):
a, b =  (int(x) for x in input.split())
 
if a > 9 or b > 9 :
  print('-1')
else :
  print(a*b)

Buggy submission (verdict: Runtime Error):
a, b =  (int(x) for x in input.split())

if a > 9 or b > 9 :
  print(-1)
else :
  print(a*b)
Problem p02785 (python)

Fixed submission:
a,b = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
for i in range(b):
    if N:
        N.pop()
print(sum(N))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
for i in range(b):
    N.pop()
print(sum(N))
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
arr = [1,2,3]
arr.remove(a)
arr.remove(b)
print(arr[0])

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
arr = [1,2,3]
for i in arr:
  if i != a or i !=b:
	print(i)
Problem p02831 (python)

Fixed submission:
def gcd(a,b):
    return a if (b==0) else gcd(b,a%b)
a,b = map(int,input().split())
print(int((a*b)/gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math
a,b = input().split()
print(int((int(a)*int(b))/math.gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print(int((a*b)/math.gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
c = math.gcd(a,b)
print(int((a*b)/c))
Problem p03135 (python)

Fixed submission:
t,x = map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [int(i) for i in input().split()]
print("Yes" if max(s) < (sum(s) -max(s)) else "No")
Problem p02835 (python)

Fixed submission:
S = input().split(" ")
sum = 0
for i in S:
  sum = sum + int(i)
if(sum >21):
  print("bust")
else:
  print("win")

Buggy submission (verdict: Runtime Error):
S = input().split(" ")
sum = 0
for i in S:
  sum = sum + i
if(sum >21):
  print("bust")
else:
  print("win")
Problem p02766 (python)

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

i = 1
while n >= k**i:
    i += 1

print(i)

Buggy submission (verdict: Runtime Error):
i = 1
while n >= k**i:
    i += 1

print(i)
Problem p02820 (python)

Fixed submission:
# -*- coding: utf-8 -*-

################ DANGER ################
test = ""
#test = \
"""
5 2
8 7 6
rsrpr
ans 27
"""

"""
7 1
100 10 1
ssssppr
ans 211
"""

"""
30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr
ans 4996
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################  
        
n, k = map(int, input2().split())
r, s, p = map(int, input2().split())
t = list(input2())

rsp = {"r", "s", "p"}

for i in range(k, n-1):
    if t[i] == t[i-k]:
        t[i] = rsp - {t[i], t[i+1]}
        
if t[n-1] == t[n-1-k]:
    t[n-1] = rsp - {t[n-1]}

ans = (t.count("r") * p +
       t.count("s") * r +
       t.count("p") * s)

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

################ DANGER ################
test = ""
#test = \
"""
5 2
8 7 6
rsrpr
ans 27
"""

"""
7 1
100 10 1
ssssppr
ans 211
"""

"""
30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr
ans 4996
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
########################################  
        
n, k = map(int, input2().split())
r, s, p = map(int, input2().split())
t = list(input2())

rsp = {"r", "s", "p"}

for i in range(k, n):
    if t[i] == t[i-k]:
        t[i] = rsp - {t[i], t[i+1]}

ans = (t.count("r") * p +
       t.count("s") * r +
       t.count("p") * s)

print(ans)
Problem p02831 (python)

Fixed submission:
import fractions

test = ""
#test = \
"""
123 456
"""
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
    

a, b = map(int, input2().strip().split())
print(a * b // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

test = ""
#test = \
"""
123 456
"""
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
    

a, b = map(int, input2().strip().split())
print(a * b // math.gcd(a, b))
Problem p02847 (python)

Fixed submission:
a = input()

if a == "SUN":
    print(7)
if a == "MON":
    print(6)
if a == "TUE":
    print(5)
if a == "WED":
    print(4)
if a == "THU":
    print(3)
if a == "FRI":
    print(2)
if a == "SAT":
    print(1)

Buggy submission (verdict: Runtime Error):
from collections import deque

N, AB = map(int, open(0).read().split())
B = AB[1::2]

E = [[] for _ in range(N + 1)]
for a, b in zip([iter(AB)] * 2):
    E[a].append(b)

Q = deque([1])
C = [0] * (N + 1)
while Q:
    v = Q.popleft()
    c = 0
    for u in E[v]:
        c += 1 + (c + 1 == C[v])
        C[u] = c
        Q.append(u)

print(max(C))
for b in B:
    print(C[b])
Problem p02897 (python)

Fixed submission:
n = int(input())
print((n - n//2) / n)

Buggy submission (verdict: Runtime Error):
n=int(input);print((n-n//2)/n)
Problem p02959 (python)

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

count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        d = b[i] - a[i]

        if a[i + 1] < d:
            count += a[i + 1]
            a[i + 1] = 0
        else:
            count += d
            a[i + 1] -= d

    else:
        count += b[i]

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.append(0)
b = list(map(int, input().split()))

count = 0
for i in range(n):
    if a[i] < b[i]:
        count += a[i]
        d = b[i] - a[i]

        if a[i + 1] < d:
            count += a[i + 1]
            a[i + i] = 0
        else:
            count += d
            a[i + 1] -= d

    else:
        count += b[i]

print(count)
Problem p03038 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import numpy as np

# TESTCASE #
test = ""
#test = \
"""
3 2
5 1 4
2 3
1 5
ans:
14
"""

"""
10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4
ans:
338
"""

"""
3 2
100 100 100
3 99
3 99
ans:
300
"""

"""
11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000
ans:
10000000001
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
### MAIN ###
        
n, m = map(int, input2().split())
a = np.array(list(map(int, input2().split())), dtype="int64")
bcs = [tuple(map(int, input2().split()))[::-1] for _ in range(m)]

a.sort()
bcs = sorted(bcs, reverse=True)

i = 0
for query in bcs:
    #print(query)
    a[i:i+query[1]] = np.maximum(a[i:i+query[1]], query[0])
    i += query[1]
    #print(a)    
print(np.sum(a))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import numpy as np

# TESTCASE #
test = ""
#test = \
"""
3 2
5 1 4
2 3
1 5
ans:
14
"""

"""
10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4
ans:
338
"""

"""
3 2
100 100 100
3 99
3 99
ans:
300
"""

"""
11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000
ans:
10000000001
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
### MAIN ###
        
n, m = map(int, input2().split())
a = np.array(list(map(int, input2().split())), dtype="int64")
bcs = [tuple(map(int, input2().split()))[::-1] for _ in range(m)]

a.sort()
bcs = sorted(bcs, reverse=True)

i = 0
for query in bcs:
    #print(query)
    if a[i] < query[0]:
        a[i:i+query[1]] = np.maximum(a[i:i+query[1]], query[0])
        i += query[1]
        #print(a)
    
print(np.sum(a))
Problem p02831 (python)

Fixed submission:
import fractions
input_l = list(map(int,input().split()))
a = input_l[0]
b = input_l[1]
print(a * b // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import numpy as np
input_l = list(map(int,input().split()))
a = input_l[0]
b = input_l[1]
print(np.lcm(a,b))

Buggy submission (verdict: Runtime Error):
input_l = list(map(int,input().split()))
a = input_l[0]
b = input_l[1]
x = np.array([a,b])
import numpy as np

print(np.lcm(a,b))
Problem p02833 (python)

Fixed submission:
n = int(input())
if n%2 == 1:
    print(0)
    exit()
else:
    i = n//2
    count = 0
    while i > 0:
        i = i//5
        count += i
    print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%2 = 1:
    print(0)
    exit()
else:
    i = n/2
    count = 0
    while i > 0:
        i = i//5
        count += i
    print(count)
Problem p02847 (python)

Fixed submission:
# ABC 146 A
s = input()
if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Buggy submission (verdict: Runtime Error):
# ABC 146 C
import math
input_list = list(map(int, input().split()))
a = input_list[0]
b = input_list[1]
x = input_list[2]

a_check = math.floor(x / a)
try:
    b_check = math.floor(10 ** (x/b))
except:
    b_check = 1000000000

if (a_check < 1) | (b_check < 1):
    print(0)
    exit()
elif a_check <= b_check:
    n = a_check
elif b_check <= a_check:
    n = b_check

if n > 1000000000:
    n = 1000000000
    print(n)
    exit()
    
def n_check(n_):
    if a * n_ + b * len(str(n_)) <= x:
        return True

while n_check(n) != True:
    n -= 1
    n_check(n)
print(n)

Buggy submission (verdict: Runtime Error):
import math
input_list = list(map(int, input().split()))
a = input_list[0]
b = input_list[1]
x = input_list[2]

a_check = math.floor(x / a)
b_check = math.floor(pow(x / b, 10))

if (a_check < 1) | (b_check < 1):
    print(0)
    exit()
elif a_check <= b_check:
    n = a_check
elif b_check <= a_check:
    n = b_check

if n > 1000000000:
    n = 1000000000

def n_check(n_):
    if a * n_ + b * len(str(n_)) <= x:
        return True

while n_check(n) != True:
    n -= 1
    n_check(n)
print(n)
Problem p02860 (python)

Fixed submission:
n = int(input())
chars = input()
if n%2 == 0:
    k = n//2
    if chars[:k] == chars[k:]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
chars = input()
if n%2 ==0:
    k = n/2
    if chars[:k] == chars[k:]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Problem p02762 (python)

Fixed submission:
from collections import defaultdict
class UnionFind:
    def __init__(self, n=0):
        self.d = [-1 for _ in range(n)]
    
    def find(self, x): # find root
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return False
        if -self.d[x] < -self.d[y]: # swap
            t = x
            x = y
            y = t
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.d[self.find(x)]
    

def main():
    N, M, K = map(int, input().split())
    uf = UnionFind(N)

    deg = [0 for _ in range(N)]
    for _ in range(M): # friends
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        deg[a] += 1
        deg[b] += 1
        uf.unite(a, b)
    # print(uf.d)

    to = [[] for _ in range(N)]
    for _ in range(K): # block
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        to[c].append(d)
        to[d].append(c)

    ret = []
    for i in range(N):
        ans = uf.size(i) - 1 - deg[i]
        for u in to[i]:
            if uf.same(i, u): ans -= 1
        ret.append(str(ans))

    print(' '.join(ret))


main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
class UnionFind:
    def __init__(self, n=0):
        self.d = [-1 for _ in range(n)]
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return False
        if -self.d[x] < -self.d[y]: # swap
            t = self.d[x]
            self.d[x] = self.d[y]
            self.d[y] = t
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.d[self.find(x)]
    

def main():
    N, M, K = map(int, input().split())
    uf = UnionFind(N)

    deg = [0 for _ in range(N)]
    for _ in range(M): # friends
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        deg[a] += 1
        deg[b] += 1
        uf.unite(a, b)

    to = [[] for _ in range(N)]
    for _ in range(K): # block
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        to[c].append(c)
        to[d].append(d)


    ret = []
    for i in range(N):
        ans = uf.size(i) - 1 - deg[i]
        for u in to[i]:
            if uf.same(i, u): ans -= 1
        ret.append(str(ans))

    print(' '.join(ret))


main()
Problem p02862 (python)

Fixed submission:
from itertools import combinations
# from math import factorial as f
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

MOD = 10**9 + 7
def main():
    X, Y = map(int, input().split())
    a = 2 * X - Y
    if a % 3 != 0 or a < 0:
        print(0)
        return
    a = a // 3

    b = 2 * Y - X
    if b % 3 != 0 or b < 0:
        print(0)
        return
    b = b // 3

    total = a + b
    fac, ifac = make_tables(MOD, total)
    ans = cmb(a+b, min(a, b), MOD, fac, ifac)
    print(ans)


main()

Buggy submission (verdict: Runtime Error):
from itertools import combinations
# from math import factorial as f
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

MOD = 10**9 + 7
def main():
    X, Y = map(int, input().split())
    a = 2 * X - Y
    if a % 3 != 0:
        print(0)
        return
    a = a // 3

    b = 2 * Y - X
    if b % 3 != 0:
        print(0)
        return
    b = b // 3

    total = a + b
    fac, ifac = make_tables(MOD, total)
    ans = cmb(a+b, min(a, b), MOD, fac, ifac)
    print(ans)


main()
Problem p02729 (python)

Fixed submission:
import sys
from math import factorial

line = input()
N, M = (int(s) for s in line.split(' '))

total = 0
if N > 1:
  total += factorial(N) / factorial(N - 2) / 2
if M > 1:
  total += factorial(M) / factorial(M - 2) / 2

print(int(total))

Buggy submission (verdict: Runtime Error):
import sys
from math import factorial

N, M = (int(s) for s in sys.stdin.split(' '))

total = 0
if N > 1:
  total += factorial(N) / factorial(N - 2) / 2
if M > 1:
  total += factorial(M) / factorial(M - 2) / 2
  
print(total)
Problem p02951 (python)

Fixed submission:
a,b,c = list(map(int, input().split()))
print(max(0, c-(a-b)))

Buggy submission (verdict: Runtime Error):
    a,b,c = list(map(int, input().split()))
    print(max(0, c-(a-b)))

Buggy submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))
print(max(0, c-(a-b))
Problem p02881 (python)

Fixed submission:
# coding: utf-8
# Your code here!
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
list = make_divisors(n)
root = n**0.5
for i in range(len(list)-1):
    if (list[i] <= root and list[i+1] >root):
        a = list[i]
b = n //a
print(a+b-2)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
list = make_divisors(n)
root = int(n**0.5)+1
for i in range(len(list)-1):
    if (list[i] <= root and list[i+1] >root):
        a= list[i]
if n == 1:
    a=1
b = n //a
print(a+b-2)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
list = make_divisors(n)
root = int(n**0.5)+1
for i in range(len(list)):
    if (list[i] <= root and list[i+1] >root):
        a= list[i]
b = n //a
print(a+b-2)
Problem p02833 (python)

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

if N%2 != 0:
  answer = 0
else:
  answer = 0
  m = 1
  while math.floor(N)//(2*5**m) > 0:
    answer += math.floor(N//(2*5**m))
    m += 1 
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N%2 != 0:
  answer = 0
else:
  answer_2 = 0
  n = 1
  while (N/2)//(2**n) != 0:
    answer_2 += int((N/2)//(2**n))
    n += 1 
  answer_5 = 0
  m = 1
  while (N/2)//(5**m) != 0:
    answer_5 += int((N/2)//(5**m))
    m += 1 
answer = min(answer_2, answer_5)
print(answer)
Problem p03038 (python)

Fixed submission:
import numpy as np
N,M = map(int,input().split())
cards = list(map(int,input().split()))
exchange_lists=[]
for i in range (M):
  exchange_lists.append(list(map(int,input().split())))
exchange_lists.sort(key = lambda x:x[1],reverse=True)
cards.sort()
count = 0
for i in range(M):
  exchange=exchange_lists[i]
  num = 0
  for j in range(count,N):
    if (exchange[1] > cards[j])and(exchange[0] > num):
      cards[j] = exchange[1]
      count += 1
      num+=1
    else:
      break
  
print(np.sum(cards))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
cards = list(map(int,input().split()))
exchange_lists=[]
for i in range (M):
  exchange_lists.append(list(map(int,input().split())))
exchange_lists.sort(key = itemgetter(1))
def exchange_cards(cards,exchange):
  cards.sort()
  count = 0
  for i in range(len(cards)):
    if (exchange[1] > cards[i])and(exchange[0] > count):
      cards[i] = exchange[1]
      count += 1
    else:
      break
  return cards
      
for i in range(M):
  cards = exchange_cards(cards,exchange_lists[i])
print(np.sum(cards))