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

Fixed submission:
N,W=map(int,input().split())
w,v=[0]*N,[0]*N

for i in range(N):
    w[i],v[i]=map(int,input().split())
V=sum(v)
dp=[[float('inf') for i in range(V+1)] for j in range(N+1)]

dp[0][0]=0
for i in range(N):
    for j in range(V+1):
        if j-v[i]>=0:
            dp[i+1][j]=dp[i][j-v[i]]+w[i]
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])

for j in range(V+1):
    if dp[N][j]<=W:
        res=j
print(res)

Buggy submission (verdict: Runtime Error):
#import sys
#input=sys.stdin.readline
N,W=map(int,input().split())
w,v=[0]*N,[0]*N

for i in range(N):
    w[i],v[i]=map(int,input().split())
V=sum(v)
dp=[[float('inf')*(V+1)] for i in range(N+1)] #初期化はfor より *の方が早い

dp[0][0]=0
for i in range(N):
    for j in range(V+1):
        if j-v[i]>=0:
            dp[i+1][j]=dp[i][j-v[i]]+w[i]
        dp[i+1][j]=min(dp[i][j],dp[i+1][j])

for j in range(V+1):
    if dp[N][j]<=W:
        res=j
print(res)
# stdinなし
Problem p03165 (python)

Fixed submission:
s=list(input())
t=list(input())

lens=len(s)
lent=len(t)

dp=[[0]*(lent+1) for _ in range(lens+1)]

for i in range(lens):
    for j in range(lent):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

ans=''
i,j=lens,lent

while i>=0 and j>=0:
    if dp[i-1][j]==dp[i][j]:i-=1
    elif dp[i][j-1]==dp[i][j]:j-=1
    else:
        ans=s[i-1]+ans
        i,j=i-1,j-1
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())

lens=len(s)
lent=len(t)

dp=[[0]*(lent+1) for _ in range(lens+1)]

for i in range(lens):
    for j in range(lent):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
#print(dp[-1][-1])

ans=''
i=-1
tmp=dp[-1][-1]
for j in range(lent,-1,-1):
    if dp[i-1][j-1]<tmp:
        ans+=t[j-1]
        tmp=dp[i-1][j-1]
        i-=1
print(ans[::-1])
Problem p03219 (python)

Fixed submission:
x,y=map(int,input().split())
print(x+y//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=[abs((t-int(i)*6/1000)-a) for i in input().split()]
print(h.index(min(h))+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
tmp=[]
tmp=[abs(int(t-h[i]*0.006)-a) for i in range(n)]
print(tmp.index(min(tmp))+1)
Problem p03220 (python)

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=[abs(t-6e-3*int(i)-a) for i in input().split()]
print(h.index(min(h))+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=[abs((t-int(i)*0.006)-a) for i in open(0).readline().split()]
print(h.index(min(h))+1)
Problem p03241 (python)

Fixed submission:
# 2019/08/01

n,m=map(int,input().split())

def divisors(n,m):
    div=[]
    end=int(pow(m,0.5))
    for i in range(1,end+1):
        if m%i==0:
            div.append(i)
            div.append(m//i)
    div.sort(reverse=True)
    return div

res=divisors(n,m)
for e in res:
    if m//n>=e:
        print(e)
        break

Buggy submission (verdict: Runtime Error):
# 2019/08/01

from fractions import gcd

n,m=map(int,input().split())

def divisors(n,m):
    div=[]
    end=min(m//n,int(pow(m,0.5)))
    for i in range(2,end+1):
        if m%i==0:
            div.append(i)
    return div

res=divisors(n,m)
print(res[-1])
Problem p03244 (python)

Fixed submission:
# 2019/07/24

from collections import Counter

n=int(input())
v=list(map(int,input().split()))

even=[]
odd=[]

for i in range(n):
    if i%2==0:even.append(v[i])
    else:odd.append(v[i])

e=Counter(even).most_common(2)
if len(e)<2:e=[e[0][0]]
else:e=list([e[0][0]]+[e[1][0]])
o=Counter(odd).most_common(2)
if len(o)<2:o=[o[0][0]]
else:o=list([o[0][0]]+[o[1][0]])

ans=float('inf')
for i in e:
    for j in o:
        cnt=0
        if i==j:continue
        for k in range(n):
            if k%2==0 and v[k]!=i:
                cnt+=1
            elif k%2==1 and v[k]!=j:
                cnt+=1
        ans=min(cnt,ans)

if ans==float('inf'):ans=n//2
print(ans)

Buggy submission (verdict: Runtime Error):
# 2019/07/24

from collections import Counter

n=int(input())
v=list(map(int,input().split()))

even=[]
odd=[]

for i in range(n):
    if i%2==0:even.append(v[i])
    else:odd.append(v[i])

e=Counter(even).most_common(2)
e=list([e[0][0]]+[e[1][0]])
o=Counter(odd).most_common(2)
o=list([o[0][0]]+[o[1][0]])
ans=float('inf')
for i in e:
    for j in o:
        cnt=0
        if i==j:continue
        for k in range(n):
            if k%2==0 and v[k]!=i:
                cnt+=1
            elif k%2==1 and v[k]!=j:
                cnt+=1
        ans=min(cnt,ans)

print(ans)
Problem p03266 (python)

Fixed submission:
# 2019/09/10
# かんにんぐ

n,k=map(int,input().split())
cnt=0
a=n//k
b=(n+(k//2))//k if k%2==0 else 0
print(a**3+b**3)

Buggy submission (verdict: Runtime Error):
# 2019/09/10
# かんにんぐ

n,k=map(int,input().split())
cnt=0
num=[0]*(n+1)
for i in range(1,n+1):
    num[i%k]+=1

for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k:continue
    cnt+=num[a]*num[b]*num[c]
    
print(cnt)
Problem p03268 (python)

Fixed submission:
# 2019/09/10
# かんにんぐ

n,k=map(int,input().split())
cnt=0
num=[0]*(k+1)
for i in range(1,n+1):
    num[i%k]+=1

for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k:continue
    cnt+=num[a]*num[b]*num[c]
    
print(cnt)

Buggy submission (verdict: Runtime Error):
# 2019/09/10
# かんにんぐ

n,k=map(int,input().split())
cnt=0
num=[0]*(n+1)
for i in range(1,n+1):
    num[i%k]+=1

for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k:continue
    cnt+=num[a]*num[b]*num[c]
    
print(cnt)
Problem p03284 (python)

Fixed submission:
n,k=map(int,input().split())
print(0 if n%k==0 else 1)

Buggy submission (verdict: Runtime Error):
n=int(input())
flag=False
for i in range(n//4+1):
    for j in range(n//7+1):
        sum=4*i+7*j
        if sum==n:
            flag=True
print('Yes' if flag else'No')
Problem p03328 (python)

Fixed submission:
a,b=map(int,input().split())
n=(b-a)
S=(n*(n+1))//2
ans=S-b
print(ans)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
i=2
a=1
while a+i<A:
    a+=i
    i+=1
    ans=a+i
print(ans-A)
Problem p03331 (python)

Fixed submission:
def wa(t):
    sum=0
    while t>0:
       sum+=t%10
       t//=10
    return sum

n=int(input())
ans=[]
for i in range(1,n):
    ans.append(wa(i)+wa(n-i)) 
    if wa(i)+wa(n-i)==1:
        print(i)
print(min(ans))

Buggy submission (verdict: Runtime Error):
def wa(t):
    sum=0
    while t>0:
       sum+=t%10
       t=t//10
    return sum

n=int(input())
ans=[]
for i in range(2,n+1-2):
    ans.append(wa(i)+wa(n-i)) 
print(min(ans))
Problem p03339 (python)

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

cnt=s[1:].count('E')
ans=[cnt]

for i in range(1,n):
    if s[i-1]=='W':cnt+=1
    if s[i]=='E':cnt-=1
    ans+=[cnt]

print(min(ans))

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
from collections import Counter

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

A=[0]+list(accumulate(a))
res=0
for e in Counter(A).values():
	res+=e*(e-1)//2
print(res)
Problem p03352 (python)

Fixed submission:
x=int(input())
ans=[1] #1を入れないとエラー

for p in range(2,x+1):
    b=2
    while p**b<=x:
        ans.append(p**b)
        b+=1
print(max(ans))

Buggy submission (verdict: Runtime Error):
x=int(input())
ans=[]

for p in range(2,x+1):
    b=2
    while p**b<=x:
        ans.append(p**b)
        b+=1
print(max(ans))
Problem p03393 (python)

Fixed submission:
# 2019/08/12

s=input()
if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

st=set(s)

if len(s)<26:
    for i in range(97,97+26+1):
        if chr(i) in st:continue
        print(s+chr(i))
        exit()

s=list(s)
res=[s.pop()]

def solve(s):
    for _ in range(len(s)):
        tmp=s.pop()
        if tmp>res[-1]:
            res.append(tmp)
            res.sort()
        else:            
            for e in res:
                if e<tmp:continue
                s.append(e)
                return s

print(''.join(solve(s)))

Buggy submission (verdict: Runtime Error):
# 2019/08/12

s=input()
if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

st=set(s)
"""
if len(s)<26:
    for i in range(97,97+26+1):
        if chr(i) in st:continue
        print(s+chr(i))
        exit()
"""
s=list(s)
res=[s.pop()]

def solve(s):
    for _ in range(len(s)):
        tmp=s.pop()
        if tmp>res[-1]:
            res.append(tmp)
            res.sort()
        else:            
            for e in res:
                if e<tmp:continue
                s.append(e)
                return s

print(''.join(solve(s)))

Buggy submission (verdict: Runtime Error):
# 2019/08/12

s=input()
if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()

st=set(s)
if len(s)<26:
    for i in range(97,97+26+1):
        if chr(i) in st:continue
        print(s+chr(i))
        exit()
s=list(s)
tmp=[]

def solve(s):
    for _ in range(26):
        for j in range(25,-1,-1):
            if s[j-1]>s[j]:
                tmp.append(s[j])
                s[j]=''
            else:
                if s[j]=='z':
                    s[j]=''
                    for e in tmp:
                        if e<s[j-1]:continue
                        s[j-1]=e
                        return s
                else:
                    s[j]=chr(ord(s[j-1])+1)
                    return s


print(''.join(solve(s)))
Problem p03469 (python)

Fixed submission:
print('2018'+input()[4:])

Buggy submission (verdict: Runtime Error):
n=int(input())
d={int(input()) for i in range(n)}
print(len(d))
Problem p03485 (python)

Fixed submission:
import math
a,b = [int(i) for i in input().split()]
avg=math.ceil((a+b)/2)
print(avg)

Buggy submission (verdict: Runtime Error):
a,op,b = [i for i in input().split()]
a=int(a)
b=int(b)

error = ['?','=','!']
if op == '+' :
  print(a+b)
elif op == '-':
  print(a-b)
elif op == '*':
  print(a*b)
elif op == '/':
  if b == 0 :
    print('error')
  else:
    print(int(a/b))
elif op in error:
  print('error')
Problem p03556 (python)

Fixed submission:
n=int(input())
i=1
while i**2<=n:
    ans=i**2
    i+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
i=1
while i**2<n:
    ans=i**2
    i+=1
print(ans)
Problem p03599 (python)

Fixed submission:
# 2019/08/07

a,b,c,d,e,f=map(int,input().split())

max_a=f//100*a
max_b=f//100*b
min_ab=min(a,b)*100
max_c=(f-min_ab)//c
max_d=(f-min_ab)//d


def solve():
    cnt=0   
    ans=0   
    for i in range(max_a):
        if i*a>f:break
        for j in range(max_b):
            if i==j==0:continue
            if (i*a+j*b)*100>f:break

            for k in range(max_c):
                if (i*a+j*b)*100+k*c>f:break
                for l in range(max_d):
                    if k==l==0:continue
                    if (i*a+j*b)*100+k*c+l*d>f:break
                    w=(i*a+j*b)*100
                    s=k*c+l*d
                    D=s/w
                    if D>e/100:break
                    if cnt<D:
                        ans=(w+s,s)
                        cnt=D
                    if D==e/100:
                        return ans
    return ans
ans=solve()
if ans==0:
    print(min(a,b)*100,0)
else:print(*ans)

Buggy submission (verdict: Runtime Error):
# 2019/08/07

a,b,c,d,e,f=map(int,input().split())

max_a=f//100*a
max_b=f//100*b
min_ab=min(a,b)*100
max_c=(f-min_ab)//c
max_d=(f-min_ab)//d


def solve():
    cnt=0   
    ans=0   
    for i in range(max_a):
        if i*a>f:break
        for j in range(max_b):
            if i==j==0:continue
            if (i*a+j*b)*100>f:break

            for k in range(max_c):
                if (i*a+j*b)*100+k*c>f:break
                for l in range(max_d):
                    if k==l==0:continue
                    if (i*a+j*b)*100+k*c+l*d>f:break
                    w=(i*a+j*b)*100
                    s=k*c+l*d
                    D=s/w
                    if D>e/100:break
                    if cnt<D:
                        ans=(w+s,s)
                        cnt=D
                    if D==e/100:
                        return ans
    return ans
ans=solve()
if ans is None:print(0,0)
else:print(*ans)

Buggy submission (verdict: Runtime Error):
# 2019/08/07

a,b,c,d,e,f=map(int,input().split())

max_a=f//100*a
max_b=f//100*b
min_ab=min(a,b)*100
max_c=(f-min_ab)//c
max_d=(f-min_ab)//d


def solve():
    cnt=0   
    ans=0   
    for i in range(max_a):
        if i*a>f:return ans
        for j in range(max_b):
            if i==j==0:continue
            if (i*a+j*b)*100>f:break

            for k in range(max_c):
                if (i*a+j*b)*100+k*c>f:break
                for l in range(max_d):
                    if k==l==0:continue
                    if (i*a+j*b)*100+k*c+l*d>f:break
                    w=(i*a+j*b)*100
                    s=k*c+l*d
                    D=s/w
                    if D>e/100:break
                    if cnt<D:
                        ans=(w+s,s)
                        cnt=D
                    if D==e/100:
                        return ans
    return ans
print(*solve())
Problem p03606 (python)

Fixed submission:
n=int(input())
sum=0
for i in range(n):
  l,r = [int(j) for j in input().split()]
  sum+=r-l+1
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
    ans+=(eval(input().replace(' ','-')[::-1]))+1
print(ans)
Problem p03720 (python)

Fixed submission:
n,m=map(int,input().split())
ls=[0]*(n+1)
for i in range(m):
    a,b= map(int,input().split())
    ls[a]+=1
    ls[b]+=1
for j in range(1,n+1):
    print(ls[j])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
s={}
for i in range(m):
    a,b=map(int,input().split())
    s[a]=s.get(a,0)+1
    s[b]=s.get(b,0)+1
for i in range(1,n+1):
    print(s[i])
Problem p03721 (python)

Fixed submission:
from heapq import heappop,heappush

input=open(0).readline
n,k=map(int,input().split())
res={}
for i in range(n):
    a,b=map(int,input().split())
    res[a]=res.get(a,0)+b

que=[]
for key,val in res.items():
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val>=k:
        print(key)
        exit()
    k-=val

Buggy submission (verdict: Runtime Error):
from heapq import heappop,heappush

input=open(0).readline
n,k=map(int,input().split())
res={}
for i in range(n):
    a,b=map(int,input().split())
    res[a]=res.get(a,0)+b

que=[]
for key,val in res.items():
    heappush(que,(key,val))

while k:
    key,val=heappop(que)
    if val<=k:
        print(key)
        exit()
    k-=val
Problem p03994 (python)

Fixed submission:
# 2019/09/17

s=list(input())
n=len(s)
k=int(input())

cnta=0
min_l=10000

for i in range(n):
    cnt=123-ord(s[i])
    if cnt>k:continue
    if s[i]=='a':
        cnta+=1
        continue
    s[i]='a'
    k-=cnt
    if k==0:break
else:
    last=s[-1]
    while cnta>=0:
        tmp=ord(last)-97
        kk=(k-cnta*26)%26
        
        min_l=min(min_l,(tmp+kk)%26)
        cnta-=1
    else:
        s[-1]=chr(min_l+97)
        
print(''.join(s))

Buggy submission (verdict: Runtime Error):
# 2019/09/17

s=list(input())
n=len(s)
k=int(input())

for i in range(n):
    cnt=123-ord(s[i])
    if cnt>k:continue
    s[i]='a'
    k-=cnt
    if k==0:break
else:
    if k:
        s[-1]=chr(ord(s[i])+k)

print(''.join(s))
Problem p02852 (python)

Fixed submission:

n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
board[left] = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while board[left] is None:
        left += 1
        if left == i:
            break
    if left < i:
        board[i] = left
# print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))

Buggy submission (verdict: Runtime Error):
n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while s[left]:
        left += 1
        if left >= i:
            break
    if left < i:
        board[i] = left
# print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))

Buggy submission (verdict: Runtime Error):
n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while s[left]:
        left += 1
        if left >= i:
            break
    if left < i:
        board[i] = left
print(board)
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while True:
        step = j - board[j]
        steps.append(step)
        j = board[j]
        if j==0:
            break
    print(' '.join(str(s) for s in steps[::-1]))

Buggy submission (verdict: Runtime Error):
n, m = [int(s) for s in input().split()]
s = [int(s) for s in input()]
board = [None]*(n+1)
left = 0
for i in range(1,n+1):
    if s[i]:
        continue
    left = max(left, i-m)
    while s[left]:
        left += 1
        if left >= i:
            break
    if left < i:
        board[i] = left
if board[n] is None:
    print(-1)
else:
    steps = []
    j = n
    while j > 0:
        step = j - board[j]
        steps.append(step)
        j = board[j]
    print(' '.join(str(s) for s in steps[::-1]))

Buggy submission (verdict: Runtime Error):
def f():
    n, m = [int(s) for s in input().split()]
    s = [int(s) for s in input()]
    board = [None]*(n+1)
    left = 0
    for i in range(1,n+1):
        if s[i]:
            continue
        left = max(left, i-m)
        while s[left] and left<i:
            left += 1
        if left < i:
            board[i] = left
    if board[n] is None:
        print(-1)
        return
    steps = []
    j = n
    while j > 0:
        step = j - board[j]
        steps.append(step)
        j = board[j]
    print(' '.join(str(s) for s in steps[::-1]))

f()
Problem p02947 (python)

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            # ans += factorial(counter) / factorial(2) / factorial(counter-2)
            ans += cmb(counter,2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    # ans += factorial(counter) / factorial(2) / factorial(counter-2)
    ans += cmb(counter,2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            ans += factorial(counter) / factorial(2) / factorial(counter-2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    ans += factorial(counter) / factorial(2) / factorial(counter-2)

print(int(ans))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
C = collections.Counter(A)
ans = 0
for c in C.keys():
    if C[c] >= 2:
        ans += factorial(C[c]) / factorial(2) / factorial(C[c]-2)

print(int(ans))

Buggy submission (verdict: Runtime Error):

import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
B = []
for a in A:
    B.append("".join(sorted(a)))
B = sorted(B)
C = collections.Counter(B)
ans = 0
for c in C.keys():
    if C[c] >= 2:
        ans += factorial(C[c]) / factorial(2) / factorial(C[c]-2)

print(int(ans))

Buggy submission (verdict: Runtime Error):

import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
B = []
for a in A:
    B.append("".join(sorted(a)))
B = sorted(B)
C = collections.Counter(B)
ans = 0
for c in C.keys():
    if C[c] >= 2:
        ans += factorial(C[c]) / factorial(2) / factorial(C[c]-2)

print(int(ans))
Problem p02952 (python)

Fixed submission:

import sys
sys.setrecursionlimit(4100000)
a = str(input())
a = a
length = len(a)
b = len(a)
ans = 0
if b == 1:
    print(a)
else:
    for i in reversed(range(1,b+1)):
        if i%2 == 1 and i == b:
            temp = ""
            for k in range(i-1):
                temp += "9"
            ans += int(a[b-i:]) - int(temp)

        elif i%2 == 1:
            temp = 9*10**(i)//10

            ans += temp
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
a = str(input())
a = a
length = len(a)
b = len(a)
ans = 0
for i in reversed(range(1,b+1)):
    if i%2 == 1 and i == b:
        temp = ""
        for k in range(i-1):
            temp += "9"
        ans += int(a[b-i:]) - int(temp)

    elif i%2 == 1:
        temp = 9*10**(i)//10

        ans += temp
print(ans)
Problem p02953 (python)

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
current = a[0]
good = True
for i in range(1,n):
    if a[i] < a[i-1]:
        good = False
        break
    if a[i] == a[i-1]:
        continue
    if a[i] > a[i-1]:
        a[i] = a[i] - 1
if good:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(i) for i in input().split()]
current = a[0]
good = True
for i in range(1,n):
    if a[i] < a[i-1]:
        good = False
        break
    if a[i] == a[i-1]:
        continue
    if a[i] > a[i-1]:
        a[i] = a[i] - 1
if good:
    print("Yes")
else:
    print("No")
Problem p02971 (python)

Fixed submission:
# Setup
import sys
import heapq
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(input()) for i in range(n)]
heap = []
for i in range(n):
    heapq.heappush(heap,-a[i])
for i in range(n):
    temp = heapq.heappop(heap)
    if -a[i] == temp:
        temp2 = heapq.heappop(heap)
        print(-temp2)
        heapq.heappush(heap,temp)
        heapq.heappush(heap,temp2)
    else:
        print(-temp)
        heapq.heappush(heap,temp)

Buggy submission (verdict: Runtime Error):
# Setup
import sys
sys.setrecursionlimit(4100000)
n = int(input())
a = [int(input()) for i in range(n)]
heap = []
for i in range(n):
    heapq.heappush(heap,-a[i])
for i in range(n):
    temp = heapq.heappop(heap)
    if -a[i] == temp:
        temp2 = heapq.heappop(heap)
        print(-temp2)
        heapq.heappush(heap,temp)
        heapq.heappush(heap,temp2)
    else:
        print(-temp)
        heapq.heappush(heap,temp)
Problem p02995 (python)

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import fractions
a,b,c,d = [int(i) for i in input().split()]
lcm = (c * d) // fractions.gcd(c, d)
# a = 9-9//2-9//3+9//lcm
# b = 4-4//2-4//3+4//lcm
a -= 1
e = b-b//c-b//d+b//lcm
f = a-a//c-a//d+a//lcm
print(e-f)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import math
a,b,c,d = [int(i) for i in input().split()]
lcm = (c * d) // math.gcd(c, d)
# a = 9-9//2-9//3+9//lcm
# b = 4-4//2-4//3+4//lcm
a -= 1
e = b-b//c-b//d+b//lcm
f = a-a//c-a//d+a//lcm
print(e-f)