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

Fixed submission:
from collections import deque

def main():
    h,w=map(int,input().split())
    maze=[list(input()) for i in range(h)]
    d=[[-1]*w for i in range(h)]
    que=deque([])
    dd=((1,0),(0,1),(-1,0),(0,-1))
    for i in range(h):
        for j in range(w):
            if maze[i][j]=="#":
                que.append((i,j))           
                d[i][j]=0
    ans=0
    while que:
        p=que.popleft()
        ans=d[p[0]][p[1]]
        for dx,dy in dd:
            nx=p[0]+dx
            ny=p[1]+dy
            if 0<=nx and nx<h and 0<=ny and ny<w and maze[nx][ny]!="#" and d[nx][ny]==-1:
                d[nx][ny]=ans+1
                que.append((nx,ny))  
    return ans
if __name__=='__main__':
    print(main())

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

def main():
    h,w=map(int,input().split())
    maze=[list(input()) for i in range(h)]
    d=[[float("inf")]*w for i in range(h)]
    que=deque([])
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    for i in range(h):
        for j in range(w):
            if maze[i][j]=="#":
                que.append((i,j))           
                d[i][j]=0
    while que:
        p=que.popleft()
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            if 0<=nx and nx<h and 0<=ny and ny<w and maze[nx][ny]!="#" and d[nx][ny]==float("inf"):
                d[nx][ny]=d[p[0]][p[1]]+1
                que.append((nx,ny))  
    ans=0
    for i in range(h):
        ans=max(ans,d[i])
    return ans
if __name__=='__main__':
    print(main())

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

def main():
    h,w=map(int,input().split())
    maze=[list(input()) for i in range(h)]
    d=[[float("inf")]*w for i in range(h)]
    que=deque([])
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    for i in range(h):
        for j in range(w):
            if maze[i][j]=="#":
                que.append((i,j))           
                d[i][j]=0
    while que:
        p=que.popleft()
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            if 0<=nx and nx<h and 0<=ny and ny<w and maze[nx][ny]!="#" and d[nx][ny]==float("inf"):
                d[nx][ny]=d[p[0]][p[1]]+1
                que.append((nx,ny))  
    ans=0
    for i in range(h):
        ans=max(ans,d[i])
if __name__=='__main__':
    print(main())
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k=map(int,input())
if b-a<=k and c-b<=k and d-c<=k and e-d<=k:
    print('Yay!')
else:
    print(':(')
Problem p03077 (python)

Fixed submission:
import math
n=int(input())
l=[int(input()) for i in range(5)]
print(math.ceil(n/min(l))+4)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=[int(input()) for i in range(5)]
print(math.ceil(n/min(l)+4)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=[int(input()) for i in range(6)]
print(math.ceil(n/min(l)+4)
Problem p03207 (python)

Fixed submission:
n=int(input())
p=[int(input()) for i in range(n)]
q=max(p)
print(int(sum(p))-int(max(p)/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[map(int,input() for i in range(n))]
q=max(p)
print(sum(p)-q/2)
Problem p03250 (python)

Fixed submission:
a=list(map(int,input().split()))
a_=sorted(a,reverse=True)
print(int(str(a_[0])+str(a_[1]))+a_[2])

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(max(int(str(a)+str(b))+c,int(str(a)+str(c))+b,int(str(b)+str(c))+a,int(str(b)+str(a)+c,int(str(c)+str(a)+b,int(str(c)+str(b)+a))
Problem p03295 (python)

Fixed submission:
from operator import itemgetter
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)
ab=sorted([(a[i],b[i]) for i in range(m)],  key=itemgetter(1))  
removed=-1
ans=0

for i,j in ab:
    if i>removed:
        ans+=1
        removed=j-1
print(ans)

Buggy submission (verdict: Runtime Error):
a=[]
b=[]
for i in range(m):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)
ab=sorted([(a[i],b[i]) for i in range(m)],  key=itemgetter(1))  

ans=0
last=0
for i in range(m):
    if last<ab[i][0]:
        last=ab[i][1]
        ans+=1
    else:
        last=ab[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n,m=map(int,input().split())
a=[]
b=[]
for i in range(m):
    a_,b_=map(int,input().split())
    a.append(a_)
    b.append(b_)
ab=sorted([(a[i],b[i]) for i in range(m)],  key=itemgetter(1))  

ans=0
last=0
for i in range(m):
    if last<a[i][0]:
        last=a[i][1]
        ans+=1
print(ans)
Problem p03329 (python)

Fixed submission:
n=int(input())
dp=[10**5]*(n+1)
dp[0]=0
for i in range(n+1):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[10**5]*n
dp[0]=0
for i in range(n+1):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[10**5]*n
dp[0]=0
for i in range(n+1):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n+1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**5]*n
dp[0]=0
for i in range(n):
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=6
    pow=1
    while pow<=n:
        dp[i]=min(dp[i],dp[i-pow]+1)
        pow*=9
print(dp[n-1])
Problem p03631 (python)

Fixed submission:
N=list(input())
N_=list(reversed(N))
if N==N_:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N=list(int(input()))
N_=reversed(N)
if N==N_:
    print('Yes')
else:
    print('No')
Problem p03767 (python)

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

a_li=a[1:2*n:2]
print(sum(a_li))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()


for i in range(n):
        sum=sum(a[2*i+1])
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()

if n>=2:
    for i in range(n):
        sum=sum(a[2*i+1])
    
else:
    print(a[1])
Problem p03805 (python)

Fixed submission:
import itertools
n,m=map(int,input().split())
p=[[False]*n for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    p[a][b]=True
    p[b][a]=True
ans=0
for i in itertools.permutations(range(n),n):
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans+=1
                break
            if not p[i[j]][i[j+1]]:
                break
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n,m=map(int,input().split())
p=[[False]*n for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    p[a][b]=True
    p[b][a]=True
ans=0
for i in itertools.permutations(range(1,n),n-1):
    list=[0]+[i]
    if all(p[list[j]][list[j+1]]==True for j in range(n)):
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n,m=map(int,input().split())
p=[[False]*n for i in range(n)]
ans=0
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b-=1
    p[a][b]=True
    p[b][a]=True

for i in itertools.permutations(range(n),n):
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans+=1
                break
            if not p[i[j]][i[j+1]]:
                break
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n,m=map(int,input().split())
p=[[False]*n for i in range(n)]
ans=0
for i in range(n):
    a,b=map(int,input().split())
    a-=1
    b-=1
    p[a][b]=True
    p[b][a]=True

for i in itertools.permutations(range(n),n):
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans+=1
                break
            if not p[i[j]][i[j+1]]:
                break
print(ans)
Problem p03835 (python)

Fixed submission:
K,S=map(int,input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        sumz=S-x-y
        if sumz>=0 and sumz<=K:    
            count+=1
print(count)

Buggy submission (verdict: Runtime Error):
K,S=map(int,input().split())
conut=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            while x+y+z==S:
                count+=1
print(count)

Buggy submission (verdict: Runtime Error):
K=int(input())
S=int(input())
conut=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count+=1
print(count)

Buggy submission (verdict: Runtime Error):
K,S=map(int,input().split())
conut=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count+=1
print(count)

Buggy submission (verdict: Runtime Error):
K,S=map(int,inpit().split())
conut=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count+=1
print(count)

Buggy submission (verdict: Runtime Error):
K,S=map(int,inpit().split())
conut=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count+=1
print(count)

Buggy submission (verdict: Runtime Error):
K,S=map(int,inpit().split())
conut=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z=S:
                count+=1
print(count)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ope = [list(map(int, input().split())) for _ in range(m)]
ope = sorted(ope, key=lambda x: x[1], reverse=True)
j = 0
for i in range(n):
    if a[i] < ope[j][1]:
        a[i] = ope[j][1]
        ope[j][0] -= 1
        if ope[j][0] == 0:
            j += 1
            if j == len(ope):
                break
    else:
        break
print(sum(a))

Buggy submission (verdict: Runtime Error):
11 3
1 1 1 1 1 1 1 1 1 1 1
3 1000000000
4 1000000000
3 1000000000
Problem p03207 (python)

Fixed submission:
N = int(input())
p = [int(input()) for i in range(N)]
print(sum(p) - max(p) // 2)

Buggy submission (verdict: Runtime Error):
N = input()
p = [int(input()) for i in range(N)]
print(sum(p) - max(p) // 2)
Problem p03013 (python)

Fixed submission:
import sys
import numpy as np
MOD = 1000000007
def main():
    n, m = [int(x) for x in input().split()]
    pattern = [1]
    broken = -1
    brokencnt = 0
    if brokencnt < m:
        broken = int(input())
        brokencnt += 1
    for i in range(1, n + 1):
        if i == broken:
            pattern.append(0)
            if brokencnt < m:
                broken = int(input())
                brokencnt += 1
            continue
        if i == 1:
            pattern.append(pattern[i - 1])
        if i > 1:
            pattern.append((pattern[i - 1] + pattern[i - 2]) % MOD)
    print(pattern[n])
main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 19 17:29:01 2019

@author: makigon
"""
mod = 10 ** 9 + 7
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

aset = set(a)
f = [0 for i in range(N)]
f[0] = 1
if 1 in a:
    f[1] = 0
else:
    f[1] = 1

for i in range(2,N):
    if i in a:
        continue
    else:
        f[i] = f[i-1]+f[i-2]
    f[i] %= mod

if N == 1:
    print(f[i-1])
else:       
    print((f[N-1]+f[N-2]) % mod)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

f = [0 for i in range(N)]
f[0] = 1
if 1 in a:
    f[1] = 0
else:
    f[1] = 1

for i in range(2,N):
    if i in a:
        continue
    else:
        f[i] = f[i-1]+f[i-2]
        
print((f[N-1]+f[N-2])%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

f = [0 for i in range(N)]
f[0] = 1
if 1 in a:
    f[1] = 0
else:
    f[1] = 1

for i in range(2,N):
    if i in a:
        continue
    else:
        f[i] = f[i-1]+f[i-2]
        
print((f[N-1]+f[N-2])%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]

f = [0 for i in range(N)]
f[0] = 1
f[1] = 1

for i in range(2,N):
    if i in a:
        continue
    else:
        f[i] = f[i-1]+f[i-2]
        
print(f[N-1]+f[N-2])
Problem p03038 (python)

Fixed submission:
#!/usr/bin/env python3.4

# abc127_d

import collections
import itertools
import functools

def main():
    # Input
    _, m = [int(s) for s in input().split()]
    cards = [int(s) for s in input().split()]
    acts = [[int(s) for s in input().split()] for _ in range(m)]
    # Get ans
    cards = collections.deque(sorted(cards))
    acts.sort(key=lambda a: a[1], reverse=True)
    for b, c in acts:
        for _ in range(b):
            if cards[0] >= c:
                break
            cards.popleft()
            cards.append(c)
    ans = sum(cards)
    # Output
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3.4

# abc127_d

import collections
import itertools
import functools

def find_index(iterable, func, from_i):
    i = from_i
    l = len(iterable)
    while i<l and not func(iterable[i]):
        i += 1
    return i

def main():
    # Input
    _, m = [int(s) for s in input().split()]
    cards = [int(s) for s in input().split()]
    acts = [[int(s) for s in input().split()] for _ in range(m)]
    # Get ans
    cards = collections.deque(sorted(cards))
    acts.sort(key=lambda a: a[1])
    i = 0
    for b, c in acts:
        i = find_index(cards, lambda card: card>=c, i)
        #print(i, cards[:i], cards[i:])
        change_num = min(b, i)
        #cards = cards[:i][change_num:] + [c]*change_num + cards[i:]
        for _ in range(change_num):
            cards.insert(i, c)
            cards.popleft()
        #print(cards)
    ans = sum(cards)
    # Output
    print(ans)

if __name__ == '__main__':
    main()
Problem p03045 (python)

Fixed submission:
#!/usr/bin/env python3.4

# abc126_e

import sys

sys.setrecursionlimit(10**5+4)

def main():
    # input
    n, m = [int(s) for s in input().split()]
    to = [list() for _ in range(n)]
    for _ in range(m):
        x, y, _ = [int(s) for s in input().split()]
        x -= 1
        y -= 1
        to[x].append(y)
        to[y].append(x)
    # get ans
    colors = [None] * n
    counter = 0
    def dfs(cur, c):
        if colors[cur] != None:
            return
        colors[cur] = c
        for i in to[cur]:
            dfs(i, c)
    for i in range(n):
        if colors[i] == None:
            dfs(i, counter)
            counter += 1
    ans = counter
    # output
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3.4

# abc126_e

import sys

sys.setrecursionlimit(10**5)

def main():
    # input
    n, m = [int(s) for s in input().split()]
    to = [list() for _ in range(n)]
    for _ in range(m):
        x, y, _ = [int(s) for s in input().split()]
        x -= 1
        y -= 1
        to[x].append(y)
        to[y].append(x)
    # get ans
    colors = [None] * n
    counter = 0
    def dfs(cur, c):
        if colors[cur] != None:
            return
        colors[cur] = c
        for i in to[cur]:
            dfs(i, c)
    for i in range(n):
        if colors[i] == None:
            dfs(i, counter)
            counter += 1
    ans = counter
    # output
    print(ans)

if __name__ == '__main__':
    main()
Problem p03108 (python)

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

bridges = []
for i in range(m):
    bridges.append([int(x) for x in input().split()])
'''
g = list(range(n+1))
ng = [1 for _ in range(n+1)]
gl = [[i] for i in range(n+1)]
ans = []
unconf = n*(n-1)//2
ans.append(unconf)


for x in reversed(bridges):
    a,b = x
    if g[a] != g[b]:
        tmp = ng[g[a]] * ng[g[b]]
        ng[g[a]] = ng[g[a]]+ng[g[b]]
        gl[g[a]] = gl[g[a]] + gl[g[b]]
        for y in gl[g[b]]:
            g[y] = g[a]
        unconf -= tmp
        ans.append(unconf)
    else:
        ans.append(unconf)


ans.reverse()
ans.pop(0)
for x in ans:
    print(x)
'''
def root(par, ifpar, a):
    while ifpar[a] != 1:
       a = par[a]
    return a 

def unite(cnt, par, ifpar, npar, depth, ra, rb):
    if depth[ra] >= depth[rb]:
        npar[ra] = npar[ra] + npar[rb]
        par[rb] = ra
        ifpar[rb] = 0
        if depth[ra] == depth[rb]:
            depth[ra] += 1
    else:
        npar[rb] = npar[rb] + npar[ra]
        par[ra] = rb
        ifpar[ra] = 0

par = list(range(n+1))
ifpar = [1 for _ in range(n+1)]
npar = [1 for _ in range(n+1)]
depth = [1 for _ in range(n+1)]

ans = []
unconf = n*(n-1)//2
ans.append(unconf)
cnt = 0

for x in reversed(bridges):
    a,b = x
    ra = root(par, ifpar, a)
    rb = root(par, ifpar, b)
    if ra != rb:
        tmp = npar[ra] * npar[rb]
        unite(cnt, par, ifpar, npar, depth, ra, rb)
        unconf -= tmp
    ans.append(unconf)
    cnt += 1

ans.reverse()
ans.pop(0)
for x in ans:
    print(x)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())

bridges = []
for i in range(m):
    bridges.append([int(x) for x in input().split()])

def root(par, a):
    while par[a] != -1:
       a = par[a]
    return a 

def unite(par, npar, depth, ra, rb):
    if depth[ra] >= depth[rb]:
        npar[ra] = npar[ra] + npar[rb]
        par[rb] = ra
        if depth[ra] == depth[rb]:
            depth[ra] += 1
    else:
        npar[rb] = npar[rb] + npar[ra]
        par[ra] = rb

par = [-1 for _ in range(n+1)]
npar = [1 for _ in range(n+1)]
depth = [1 for _ in range(n+1)]

ans = []
unconf = n*(n-1)//2
ans.append(unconf)

for x in reversed(bridges):
    a,b = x
    ra = root(par, ifpar, a)
    rb = root(par, ifpar, b)
    if ra != rb:
        tmp = npar[ra] * npar[rb]
        unite(par, ifpar, npar, depth, ra, rb)
        unconf -= tmp
    ans.append(unconf)

ans.reverse()
ans.pop(0)
for x in ans:
    print(x)
Problem p03329 (python)

Fixed submission:
import math

n = int(input())

dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
dp[1] = 1

for i in range(1,n+1):
    tmp = float('inf')
    tmp6, tmp9 = 1,1
    while tmp6 <= i:
        if dp[i-tmp6]+1 < tmp:
            tmp = dp[i-tmp6] + 1
        tmp6 *= 6
    while tmp9 <= i:
        if dp[i-tmp9] + 1 < tmp:
            tmp = dp[i-tmp9] + 1
        tmp9 *= 9
    dp[i] = tmp

'''
    for j in range(int(math.log(i,6))+1):
        if dp[i-6**j]+1 < tmp:
            tmp = dp[i-6**j] + 1
    for j in range(int(math.log(i,9))+1):
        if dp[i-9**j]+1 < tmp:
            tmp = dp[i-9**j]+1
'''
    #dp[i] = tmp

print(dp[n])

Buggy submission (verdict: Runtime Error):
import math

n = int(input())

ans = 0

while True:
    a = int(math.log(n,9))
    b = int(math.log(n,6))
    if a == b == 0:
        ans += n
        break
    else:
        if 9 ** a >= 6 ** b:
            n -= 9 ** a
            ans += 1
        else:
            n -= 6 ** b
            ans += 1

print(ans)
Problem p03705 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def FI(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline().split())
def S(): return input()

n, a, b = LI()

if a>b:
	print(0)
elif n==1 and a!=b:
	print(0)
else:
	mi = a*(n-1)+b
	ma = a+b*(n-1)
	print(ma-mi+1)

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def FI(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline().split())
def S(): return input()

n, a, b = LI()

if a>b:
	print(0)
elif n=1 and a!=b:
	print(0)
else:
	mi = a*(n-1)+b
	ma = a+b*(n-1)
	print(ma-mi+1)
Problem p03038 (python)

Fixed submission:
argN,argM = list(map(int,input().split()))
aryA = list(map(int,input().split()))
aryCB = [] 
for i in range(argM):
  aryBC = list(map(int,input().split()))
  #print(aryBC)
  aryBC.reverse()
  aryCB.append(aryBC[:])
#print(aryCB)
aryCB.sort(reverse=True)
#print(aryCB)

aryD = []
for i in range(len(aryCB)):
  if len(aryD) + aryCB[i][1] < argN:
    aryD += [aryCB[i][0]] * aryCB[i][1]
  elif len(aryD) < argN:
    wk = argN - len(aryD)
    aryD += [aryCB[i][0]] * wk

wkA = aryA[:] + aryD[:]
#print(wkA)
wkA.sort(reverse=True)
print(sum(wkA[:len(aryA)]))

Buggy submission (verdict: Runtime Error):
argN,argM = list(map(int,input().split()))
aryA = list(map(int,input().split()))
wkA = aryA[:]
wkA.sort()
#print(wkA)
for i in range(argM):
  argB,argC = list(map(int,input().split()))

  if wkA[argB - 1] < argC:
    wkA[0:argB] = [argC] * argB
  else:
    #二分探索
    ans = 0
    wkB = argB // 2
    maxB = argB
    minB = 1
    while (ans == 0 and maxB == minB):
      if wkA[wkB - 1] < argC:
        if wkA[wkB] >= argC:
          ans = wkB
        else:
          minB = wkB
      else:
        if wkA[wkB - 2] < argC:
          ans = wkB - 1
        else:
          maxB = wkB
      wkB = (maxB + minB) // 2
    if ans > 0:
      wkA[0:ans] = [argC] * ans
  wkA.sort()
  #print(wkA)

#print(wkA)
print(sum(wkA))
Problem p03127 (python)

Fixed submission:
from functools import reduce

def mgcd(a, b):
    while b:
        a, b = b, a % b
    return a

def gcd(*numbers):
    return reduce(mgcd, numbers)

input()

li = [int(i) for i in input().split(" ")]

print(gcd(*li))

Buggy submission (verdict: Runtime Error):
import fraction as math

from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

input()

li = [int(i) for i in input().split(" ")]

print(gcd(*li))

Buggy submission (verdict: Runtime Error):
import math

from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

input()

li = [int(i) for i in input().split(" ")]

print(gcd(*li))
Problem p03775 (python)

Fixed submission:
def getdigit(N):
  cnt = 0
  while(N>0):
    cnt += 1
    N //= 10
  return cnt

N = int(input())
for i in reversed(range(1,int(pow(N, 1/2))+1)):
  if(N % i == 0):
    print(max(getdigit(i), getdigit(N/i)))
    exit()

Buggy submission (verdict: Runtime Error):
def getdigit(N):
  cnt = 0
  while(N>0):
    cnt++
    N //= 10
  return cnt

N = int(input())
for i in reversed(range(1,sqrt(N)+1)):
  if(N % i == 0):
    print(max(getdigit(i), getdigit(N/i)))
    exit()
Problem p03250 (python)

Fixed submission:
l = list(map(int, input().split()))
print(9*max(l)+sum(l))

Buggy submission (verdict: Runtime Error):
def C(x, y):
    z = 1
    for i in range(x, x-y, -1):
        z *= i
    for i in range(y, 1, -1):
        z //= i
    return z
def H(x, y):
    return C(x+y-1, y) % 1000000007
n, m = list(map(int, input().split()))
p = 2
prime_factorization = []
while p * p <= m:
    count = 0
    while m % p == 0:
        m //= p
        count += 1
    if count > 0:
        prime_factorization.append(count)
    p += 1
if m > 1:
    prime_factorization.append(1)
ans = 1
for r in prime_factorization:
    ans *= H(n, r)
print(ans % 1000000007)