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

Fixed submission:
T=input()

result=[]

for i in range(len(T)):
    if T[i]=='?':
        if i==len(T)-1:
            result.append('D')
        elif i==0:
            if T[i+1]=='P':
                result.append('D')
            else:
                result.append('P')
        elif result[i-1]=='P':
            result.append('D')
        else:
            if T[i+1]=='P':
                result.append('D')
            else:
                result.append('P')
    else:
        result.append(T[i])

print(''.join(result))

Buggy submission (verdict: Runtime Error):
T=input()

result=[]

for i in range(len(T)):
    if T[i]=='?':
        if i==len(T)-1:
            result.append('D')
        elif result[i-1]=='P':
            result.append('D')
        else:
            if T[i+1]=='P':
                result.append('D')
            else:
                result.append('P')
    else:
        result.append(T[i])

print(''.join(result))
Problem p02678 (python)

Fixed submission:
from collections import defaultdict
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline


road_dict=defaultdict(list)

N,M=map(int,input().split())

for _ in range(M):
    A,B=map(int,input().split())
    road_dict[A].append(B)
    road_dict[B].append(A)

result_dict=defaultdict(int)

next_list=[]
for i in road_dict[1]:
    if i not in result_dict:
        result_dict[i]=1
        next_list.append(i)

taisho_list=next_list[:]

while True:
    next_list=[]

    if len(taisho_list)==0:
        break

    for j in taisho_list:
        for k in road_dict[j]:
            if k not in result_dict:
                result_dict[k]=j
                next_list.append(k)
    taisho_list=next_list[:]


print('Yes')
for k in range(2,N+1):
    print(result_dict[k])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline


road_dict=defaultdict(list)

N,M=map(int,input().split())

for _ in range(M):
    A,B=map(int,input().split())
    road_dict[A].append(B)
    road_dict[B].append(A)

result_dict=defaultdict(list)

def next_tansaku(kiten,counter):
    for i in road_dict[kiten]:
        if (i not in result_dict) or (result_dict[i][1]>counter):
            result_dict[i]=[kiten,counter]
            road_dict[kiten].remove(i)
            next_tansaku(i,counter+1)


next_tansaku(1,0)

print('Yes')
for k in range(2,N+1):
    print(result_dict[k][0])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
input = sys.stdin.readline


road_dict=defaultdict(list)

N,M=map(int,input().split())

for _ in range(M):
    A,B=map(int,input().split())
    road_dict[A].append(B)
    road_dict[B].append(A)
    
result_dict=defaultdict(list)

def next_tansaku(kiten,counter):
    for i in road_dict[kiten]:
        if (i not in result_dict) or (result_dict[i][1]>counter):
            result_dict[i]=[kiten,counter]
            next_tansaku(i,counter+1)


next_tansaku(1,0)

print('Yes')
for k in range(2,N+1):
    print(result_dict[k][0])
Problem p02690 (python)

Fixed submission:
X=int(input())

a=0
b=0

while True:
    hantei_p=(X+b**5)**0.2
    hantei_n=(X-b**5)**0.2

    if abs(int(hantei_p)-hantei_p)<1:
       a=int(hantei_p)
       if a**5-b**5==X:
           print("{} {}".format(a,b))
           break
    if isinstance(hantei_n**0.2,float):
        if abs(int(hantei_n)-hantei_n)<1:
            a=int(hantei_n)
            if a**5+b**5==X:
                print("{} {}".format(a,-b))
                break
    
    b +=1

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

a=0
b=0

while True:
    hantei_p=X+b**5
    hantei_n=X-b**5

    if hantei_p**0.2==int(hantei_p**0.2):
       a=int(hantei_p**0.2)
       print("{} {}".format(a,b))
       break
    if hantei_n**0.2==int(hantei_n**0.2):
       a=int(hantei_n**0.2)
       print("{} {}".format(a,-b))
       break
    
    b +=1
Problem p02691 (python)

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

result=0

D={}

for j in range(N):
    if j+A[j] in D:
        D[j+A[j]] += 1
    else:
        D[j+A[j]]=1

for j in range(N):
    if j-A[j] in D:
        result += D[j-A[j]]

print(result)

Buggy submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())

S=['']*N
for i in range(N):
    S[i]=input()

result=[]
kekka=True


for i in range(N):
    if (A==0 and B==0 and S[i]=='AB') or (C==0 and B==0 and S[i]=='BC') or (A==0 and C==0 and S[i]=='AC'):
        kekka=False
        break
    else:
        if S[i]=='AB':
            if A==0:
                A += 1
                B -= 1
                result.append('A')
            elif B==0:
                A -=1
                B +=1
                result.append('B')
            elif A==1 and B==1 and C==0:
                if S[i+1]=='AC':
                    A += 1
                    B -= 1
                    result.append('A')
                else:
                    A -=1
                    B +=1
                    result.append('B')
            elif A>B:
                A -=1
                B +=1
                result.append('B')
            else:
                A +=1
                B -=1
                result.append('A')
        elif S[i]=='AC':
            if A==0:
                A += 1
                C -= 1
                result.append('A')
            elif C==0:
                A -=1
                C +=1
                result.append('C')
            elif A==1 and C==1 and B==0:
                if S[i+1]=='AB':
                    A += 1
                    C -= 1
                    result.append('A')
                else:
                    A -=1
                    C +=1
                    result.append('C')
            elif A>C:
                A -=1
                C +=1
                result.append('C')
            else:
                A +=1
                C -=1
                result.append('A') 
        elif S[i]=='BC':
            if B==0:
                B += 1
                C -= 1
                result.append('B')
            elif C==0:
                B -=1
                C +=1
                result.append('C')
            elif B==1 and C==1 and A==0:
                if S[i+1]=='AB':
                    B += 1
                    C -= 1
                    result.append('B')
                else:
                    B -=1
                    C +=1
                    result.append('C')
            elif B>C:
                B -=1
                C +=1
                result.append('C')
            else:
                B +=1
                C -=1
                result.append('B')

if kekka ==False:
    print('No')
else:
    print('Yes')
    for i in range(len(result)):
        print(result[i])
Problem p03160 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

N=int(input())
H=list(map(int,input().split()))

cost_list=[0 for _ in range(N)]

cost_list[1]=abs(H[1]-H[0])

if N==2:
    print(cost_list[1])

else:
    for k in range(2,N):
        cost_list[k]=min(cost_list[k-1]+abs(H[k]-H[k-1]),cost_list[k-2]+abs(H[k]-H[k-2]))

    print(cost_list[N-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

N=int(input())
H=list(map(int,input().split()))

cost_list={}

def cost(k):
    if k==0:
        result=0
        cost_list[k]=result
    elif k==1:
        result=abs(H[1]-H[0])
        cost_list[k]=result
    elif k in cost_list:
        result=cost_list[k]
    else:
        result=min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))
        cost_list[k]=result
    
    return result

print(cost(N-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

N=int(input())
H=list(map(int,input().split()))

cost_list={}

def cost(k):
    if k==0:
        result=0
        cost_list[k]=result
    elif k==1:
        result=abs(H[1]-H[0])
        cost_list[k]=result
    elif k in cost_list:
        result=cost_list[k]
    else:
        result=min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))
        cost_list[k]=result
    
    return result

print(cost(N-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

N=int(input())
H=list(map(int,input().split()))

cost_list=[0 for _ in range(N)]

def cost(k):
    if k==0:
        result=0
    elif k==1:
        result=abs(H[1]-H[0])
    elif cost_list[k]>0:
        result=cost_list[k]
    else:
        result=min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))
        cost_list[k]=result
    
    return result

print(cost(N-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

N=int(input())
H=list(map(int,input().split()))

def cost(k):
    if k==0:
        return 0
    elif k==1:
        return abs(H[1]-H[0])
    else:
        return min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))

print(cost(N-1))

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))

def cost(k):
    if k==0:
        return 0
    elif k==1:
        return abs(H[1]-H[0])
    else:
        return min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))

print(cost(N-1))
Problem p03165 (python)

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


result=''
dp=[[0]*len(t) for _ in range(len(s))]

for i in range(len(s)):
    for j in range(len(t)):
        if i==0:
            if s[i]==t[j]:
                dp[i][j]=1
            else:
                dp[i][j]=dp[i][j-1] if j>=1 else 0
        elif j==0:
            if s[i]==t[j]:
                dp[i][j]=1
            else:
                dp[i][j]=dp[i-1][j]
        else:
            if s[i]==t[j]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])

i=len(s)-1
j=len(t)-1

L=dp[i][j]

while L>=1:
    if i==0 and dp[i][j]==1:
        result+=s[i]
        L-=1
    elif j==0 and dp[i][j]==1:
        result+=t[j]
        L-=1
    elif dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        result+=t[j]
        L-=1
        i-=1
        j-=1


print(result[::-1])

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


result=''
dp=[[0]*len(t) for _ in range(len(s))]

for i in range(len(s)):
    for j in range(len(t)):
        if i==0:
            if s[i]==t[j]:
                dp[i][j]=1
            else:
                dp[i][j]=dp[i][j-1] if j>=1 else 0
        elif j==0:
            if s[i]==t[j]:
                dp[i][j]=1
            else:
                dp[i][j]=dp[i-1][j]
        else:
            if s[i]==t[j]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max(dp[i-1][j],dp[i][j-1])

i=len(s)-1
j=len(t)-1

L=dp[i][j]

while L>=1:
    if i==0 and dp[i][j]==1:
        result+=s[i]
        L-=1
    elif j==0 and dp[i][j]==1:
        result+=t[i]
        L-=1
    elif dp[i][j]>dp[i-1][j]:
        result+=s[i]
        i-=1
        L-=1
    elif dp[i][j]>dp[i][j-1]:
        result+=t[j]
        j-=1
        L-=1
    elif dp[i][j]>dp[i-1][j-1]:
        result+=t[j]
        L-=1
        i-=1
        j-=1
    else:
        i-=1
        j-=1


print(result[::-1])
Problem p03246 (python)

Fixed submission:
from collections import defaultdict

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

result=0

dic_a=defaultdict(int)
dic_b=defaultdict(int)

for i in range(n//2):
    dic_a[v[i*2]]+=1
    dic_b[v[i*2+1]]+=1


#それぞれの最大値を取得
max_a=max(dic_a.items(),key=lambda x:x[1])
max_b=max(dic_b.items(),key=lambda x:x[1])

if max_a[0] != max_b[0]:
    result=n-max_a[1]-max_b[1]

elif len(dic_a)==1 and len(dic_b)==1:
    result=n//2

else:
    dic_a.pop(max_a[0])
    max_a2=max(dic_a.items(),key=lambda x:x[1])

    dic_b.pop(max_b[0])
    max_b2=max(dic_b.items(),key=lambda x:x[1])

    result=min(n-max_a2[1]-max_b[1],n-max_a[1]-max_b2[1])

print(int(result))

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

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

result=0

dic_a=defaultdict(int)
dic_b=defaultdict(int)

for i in range(n//2):
    dic_a[v[i*2]]+=1
    dic_b[v[i*2+1]]+=1


#それぞれの最大値を取得
max_a=max(dic_a.items(),key=lambda x:[1])
max_b=max(dic_b.items(),key=lambda x:[1])

if max_a[0] != max_b[0]:
    result=n-max_a[1]-max_b[1]

elif len(dic_a)==1 and len(dic_b)==1:
    result=n//2

elif len(dic_a)==1:
    dic_b.pop(max_b[0])
    max_b=max(dic_b.items(),key=lambda x:[1])
    result=n-max_a[1]-max_b[1]

elif len(dic_b)==1:
    dic_a.pop(max_a[0])
    max_a=max(dic_a.items(),key=lambda x:[1])
    result=n-max_a[1]-max_b[1]

else:
    dic_a.pop(max_a[0])
    max_a2=max(dic_a.items(),key=lambda x:[1])

    dic_b.pop(max_b[0])
    max_b2=max(dic_b.items(),key=lambda x:[1])

    if max_a2>max_b2:
        result=n-max_a2-max_b
    else:
        result=n-max_a-max_b2

print(result)
Problem p02639 (python)

Fixed submission:
l=list(map(int,input().split()))
print(l.index(0)+1)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input()))
print(l.index(0))
Problem p02640 (python)

Fixed submission:
l=list(map(int,input().split()))
n=l[0]
legs=l[1]
if(n==0 and legs==0):
    print("Yes")
if(legs%2==0 and l[0]*4>=l[1] and l[0]*2<=l[1]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
n=l[0]
legs=l[1]
(2*a)+(2*(n-a))==legs
if(l[1]%2!=0):
    print("No")
if(l[1]%2==0 and l[0]*4>=l[1]):
    print("Yes")
else:
    print("No")
Problem p02658 (python)

Fixed submission:
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        if a[n-1] == 0:
            ans = 0
        else:
            ans = -1
        break

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = list(map(int,input().split()))
a = a.sort(reverse=True)
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        ans = -1
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = list(map(int,input().split()))
a = a.sort(reverse=true)
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 1000000000000000000:
        ans = -1
        break
print(ans)
Problem p02660 (python)

Fixed submission:
n = int(input())

ans = 0
for i in range(2,int(n**0.5)+1):
    count = 1
    loop = 1
    while n % i == 0:
        n = int(n/i)
        count -= 1
        if count == 0:
            ans += 1
            loop += 1
            count = loop

if n > 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
def prime_sieve(n):
    if n == 1:
        return []
    else:
        x = list(range(2,n+1))
        y = []
        while x[0]<pow(n,1/2):
            y += [x[0]]
            a = x[0]
            for i in x:
                if i % a == 0:
                    del x[x.index(i)]
        for i in x:
            y += [i]
        return y

n = int(input())
ans = 0
for i in prime_sieve(n):
    count = 1
    while n%i == 0:
        n /= i
        count -= 1
        loop = 1
        if count == 0:
            ans += 1
            loop += 1
            count = loop


print(ans)
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
t = [0 for i in range(n+1)]
b = [1]
c = a[1]
d = 0
e=1
length = 0
first = 0
ans = 0


while t[d] < 1:
    t[d]=e
    b += [c]
    c = a[c]
    d = c
    e+=1

if d != 0:
    length = e - t[d]
    first = b.index(d)
if k <= first:
    ans = b[k]
elif d == 0:
    ans = 1
else:
    ans = b[(k - first) % length + first]
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [1]
c = a[1]
d = 0
e=0
length = 0
first = 0
ans = 0


while c not in b:
    b += [c]
    c = a[c]
    d = c
    e+=1

if d != 0:
    length = e - b.index(d)
    first = b.index(d)
if k <= first:
    ans = b[k]
elif d == 0:
    ans = 1
else:
    ans = b[(k - first) % length + first]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [1]
c = a[1]
d = 0
length = 0
first = 0
ans = 0

while c not in b:
    b += [c]
    c = a[c]
    d = c

length = len(b)-b.index(d)
first = b.index(d)
if k <= first:
    ans = b[k]
elif length == 0:
    ans = 1
else:
    ans = b[(k-first)%length+first]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [1]
c = a[1]
d = 0
length = 0
first = 0
ans = 0

while c not in b:
    b += [c]
    c = a[c]
    d = c

length = len(b)-b.index(d)
first = b.index(d)
if k <= first:
    ans = b[k]
else:
    ans = b[(k-first)%length+first]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [1]
c = a[1]
d = 0
length = 0
first = 0
ans = 0

while c not in b:
    b += [c]
    c = a[c]
    d = c

length = len(b)-b.index(d)
first = b.index(d)
ans = b[(k-first)%length+first]
print(ans)
Problem p02709 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
place = [0]*n
active = sorted(a,reverse=True)
for i in range(n):
    place[i] = a.index(active[i])
    a[a.index(active[i])] = -1

#dp[x][y] x,y:0~n+1 (x[-1]=x[n+1]=0にすることで端の処理を楽にする)
dp = [[0 for i in range(n+2)]for j in range(n+2)]

for i in range(n):
    dp[0][i+1] = dp[0][i]+active[i]*abs(n-i-1-place[i])
    dp[i+1][0] = dp[i][0]+active[i]*abs(place[i]-i)



def check(mat):
    for i in range(len(mat)):
        print(mat[i])
    print("\n")


for i in range(n):
    for x in range(i+2):
        y = i+1 - x
        if x != 0 and y != 0:
            dp[x][y] = max(dp[x-1][y]+active[i]*abs(place[i]-x+1),dp[x][y-1]+active[i]*abs(n-y-place[i]))
            if i == n-1:
                ans = max(ans,dp[x][y])

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
aj = [a[0]]
for i in range(1,n-1):
    if a.index(b[i]) < n/2:
        aj += [b[i]]
    else:
        aj = [b[i]]+aj
if aj[0] == b[n-1]:
    aj += [b[n]]
else:
    aj = [b[n]]+aj

ans = 0
for i in range(n):


print(ans)
Problem p03161 (python)

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

dp = [1000000000 for i in range(n)]
dp[0] = 0

for i in range(n):
    for j in range(k+1):
        if i+j<n:
            dp[i + j] = min(dp[i] + abs(h[i] - h[i + j]), dp[i + j])
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = np.full
dp[0] = 0

for i in range(n):
    for j in range(k+1):
        if i+j<n:
            dp[i + j] = min(dp[i] + abs(h[i] - h[i + j]), dp[i + j])
print(dp[n-1])
Problem p02639 (python)

Fixed submission:
c=list(map(int, input().split()))
for i in range(len(c)):
    if(c[i]==0):
        a = i+1
        print(a)

Buggy submission (verdict: Runtime Error):
c=list(map(int, input().split()))
c = str(c)
c = c.find(0)
print(c)

Buggy submission (verdict: Runtime Error):
c=list(map(int, input().split()))
print(c.find(0))

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

index = a.find(0)
print(index)

Buggy submission (verdict: Runtime Error):
a=list(map(int, input().split()))
index = input.a(0)
print(a)
Problem p02640 (python)

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

for i in range(a+1):
    if (a-i)*2+(i)*4 == b:
        print('Yes')
        break
    if i==a:
        print('No')

Buggy submission (verdict: Runtime Error):
#a,b=map(int, input().split()) 

for i in range(a):
    if (a-i)*2+(i)*4 == b:
        print('Yes')
        break
if i==a-1:
    print('No')

Buggy submission (verdict: Runtime Error):
#a,b=map(int, input().split()) 

for i in range(a):
    if (a-i)*2+(i)*4 == b:
        print('Yes')
        break
  
 print('No')

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split()) 
if i in range(a):
    if((a-i)*2 + (i)*4 == b):
        print('Yes')
    else:
        print('No')
Problem p02743 (python)

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


d = c - a - b

if d > 0 and d ** 2 > 4 * a * b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

# num = H * W


if H == 0 or W == 0:
    print(int(0))

elif H == 1 or W == 1:
    print(int(1))

elif H % 2 == 0 and W % 2 == 0:
    print(int(H/2 * W))

elif H % 2 == 0:
    print(int(H/2 * W))

elif W % 2 == 0:
    print(int(W/2) * H)

elif H % 2 != 0 and W % 2 != 0:
    key = W // 2
    ans = H * key
    print(int(ans + (H-H//2)))
    # else:
    #     num = H // 2
    #     ans = num * W
    #     print(int(ans + (H-(num))))
Problem p02818 (python)

Fixed submission:
A, B, K = map(int, input().split())
quant = A + B

if quant - K <= 0:
    print('0 0')
else:
    rnt = A - K  # RemainNumTime
    a = max(rnt, 0)
    b = min(B + rnt, B)
    print(str(a) + ' ' + str(b))

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
quant = A + B

if quant - K <= 0:
    print('0 0')
else:
    RNT = A - K  # RemainNumTime
    a = max(RNT, 0)
    b = min(B + RNT, B)
    print(a + ' ' + b)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
quant = A + B

if quant - K <= 0:
    print('0 0')
else:
    RNT = A - K  # RemainNumTime
    a = max(RNT, 0)
    b = min(B + RNT, B)
    print(f'{a} {b}')
Problem p03076 (python)

Fixed submission:
dishes = [input() for _ in range(5)]


def tanuki(dishes):
    if all([i[-1] == '0' for i in dishes]):
        return sum([int(i) for i in dishes])

    sum_dishes = 0
    last_dish = 0
    last_tmp = 0
    for idx, dish in enumerate(dishes):
        tmp = 10 - int(dish[-1])
        dish = int(dish)
        if tmp == 10:
            sum_dishes += dish
        elif tmp > last_tmp:
            sum_dishes += last_dish + last_tmp
            last_dish = dish
            last_tmp = tmp
            last_idx = idx
        else:
            sum_dishes += dish + tmp
    return sum_dishes + int(dishes[last_idx])


print(tanuki(dishes))

Buggy submission (verdict: Runtime Error):

dishes = [input() for _ in range(5)]

sum_dishes = 0
last_dish = 0
last_tmp = 0
for idx, dish in enumerate(dishes):
    tmp = 10 - int(dish[-1])
    dish = int(dish)
    if tmp == 10:
        sum_dishes += dish
    elif tmp > last_tmp:
        sum_dishes += last_dish + last_tmp
        last_dish = dish
        last_tmp = tmp
        last_idx = idx
    else:
        sum_dishes += dish + tmp

print(sum_dishes + int(dishes[last_idx]))

Buggy submission (verdict: Runtime Error):

dishes = [input() for _ in range(5)]

sum_dishes = []
last_dish = 0
last_tmp = 0
for idx, dish in enumerate(dishes):
    tmp = 10 - int(dish[-1])
    dish = int(dish)
    if tmp == 10:
        sum_dishes.append(dish)
    elif tmp > last_tmp:
        sum_dishes.append(last_dish + last_tmp)
        last_dish = dish
        last_tmp = tmp
        last_idx = idx
    else:
        sum_dishes.append(dish + tmp)

print(sum(sum_dishes) + int(dishes[last_idx]))
Problem p03238 (python)

Fixed submission:
N = int(input())


if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A + B)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())

d = {}
for _ in range(N):
    Ns = [int(i) for i in input().split()]
    time = Ns[1]
    if time <= T:
        d[Ns[0]] = time
if d:
    print(min(d))
else:
    print('TLE')
Problem p03352 (python)

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

sq = int(math.sqrt(X))
m = 1
for b in range(2, sq+1):  # ここで2が1になると1のp乗となり永遠にループが回り続ける
    p = 2
    tmp = b ** p
    while tmp <= X:
        m = max(tmp, m)
        p += 1
        tmp = b ** p
print(m)

Buggy submission (verdict: Runtime Error):
from math import log, sqrt
max_num = 1
for i in range(2, int(sqrt(X)) + 1):
    max_num = max(max_num, i ** int(log(X, i)))

print(max_num)