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

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int,input().split()))+[10**7]
a.sort()
e = np.zeros(10**6+1)
ans = 0
for i in range(n):
    if e[a[i]] == 0:
        e[::a[i]] = 1
        if a[i] != a[i+1]:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))+[10**7]
a.sort()
e = np.zeros(2*10**5+1)
ans = 0
for i in range(n):
    if e[a[i]] == 0 and a[i] != a[i+1]:
        ans += 1
    e[::a[i]] = 1
print(ans)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]*(n+1)
cnt = 0
temp = 1
rep = 0
while 1:
    cnt += 1
    if b[temp] == 0:
        b[temp] = cnt
    else:
        rep = cnt-b[temp]
        # print(rep,cnt-1,b[temp])
        # print(b)
        break
    temp = a[temp]
# print((k-b[temp]+1) % rep)
if (k-b[temp]+1) >= 0:
    for i in range((k-b[temp]+1) % rep):
        temp = a[temp]
    print(temp)
    exit()
else:
    temp = 1
    for i in range(k):
        temp = a[temp]
    print(temp)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]*(n+1)
cnt = 0
temp = 1
rep = 0
while 1:
    cnt += 1
    if b[temp] == 0:
        b[temp] = cnt
    else:
        rep = cnt-b[temp]
        # print(rep,cnt-1,b[temp])
        # print(b)
        break
    temp = a[temp]
# print((k-b[temp]+1) % rep)
if (k-b[temp]+1) >= 0:
    for i in range((k-b[temp]+1) % rep):
        temp = a[temp]
    print(temp)
    exit()
else:
    temp = 1
    for i in k:
        temp = a[temp]
    print(temp)
Problem p02692 (python)

Fixed submission:
n,a,b,c = map(int,input().split())
s = [input() for i in range(n)]+[0]
# if [a,b,c].count(0) >= 2:
#     print("No")
ans = ""

# print("Yes")
for i in range(n):
    if s[i] == "AB":
        if a==1 and b==1 and s[i+1] =="BC":
            ans+="B"
            b+=1
            a-=1
        elif a<=b:
            ans+="A"
            a+=1
            b-=1
        else:
            ans+="B"
            b+=1
            a-=1
    if s[i] == "AC":
        if a==1 and c==1 and s[i+1] =="BC":
            ans+="C"
            c+=1
            a-=1
        elif a<=c:
            ans+="A"
            a+=1
            c-=1
        else:
            ans+="C"
            c+=1
            a-=1       
    if s[i] == "BC":
        if b==1 and c==1 and s[i+1] =="AC":
            ans+="C"
            c+=1
            b-=1
        elif b<=c:
            ans+="B"
            b+=1
            c-=1
        else:
            ans+="C"
            c+=1
            b-=1   
    if a<0 or b<0 or c<0:
        print("No") 
        exit()
print("Yes")
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n,a,b,c = map(int,input().split())
s = [input() for i in range(n)]+[0]
# if [a,b,c].count(0) >= 2:
#     print("No")
ans = ""

# print("Yes")
for i in range(n):
    if s[i] == "AB":
        if a==1 and b==1 and if s[i+1] =="BC":
            ans+="B"
            b+=1
            a-=1
        elif a<=b:
            ans+="A"
            a+=1
            b-=1
        else:
            ans+="B"
            b+=1
            a-=1
    if s[i] == "AC":
        if a==1 and c==1 and s[i+1] =="BC":
            ans+="C"
            c+=1
            a-=1
        elif a<=c:
            ans+="A"
            a+=1
            c-=1
        else:
            ans+="C"
            c+=1
            a-=1       
    if s[i] == "BC":
        if b==1 and c==1 and s[i+1] =="AC":
            ans+="C"
            c+=1
            b-=1
        elif b<=c:
            ans+="B"
            b+=1
            c-=1
        else:
            ans+="C"
            c+=1
            b-=1   
    if a<0 or b<0 or c<0:
        print("No") 
        exit()
print("Yes")
for i in ans:
    print(i)
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
w
Problem p02720 (python)

Fixed submission:
from collections import deque
k = int(input())
ans = 0
num = ["0","1","2","3","4","5","6","7","8","9"]
dq = deque(["1","2","3","4","5","6","7","8","9"])
# print(num[k:k+2])
if k<=12:
    print(k)
else:
    while 1:
        ans += 1
        a = dq.popleft()
        if ans == k:
            print(int(a))
            exit()
        for i in num[max(0,int(a[-1])-1):min(10,int(a[-1])+2)]:
            dq.append(a+i)

Buggy submission (verdict: Runtime Error):
muri
Problem p02722 (python)

Fixed submission:
n = int(input())
div = []
div2 = []
ans = 0
for i in range(1,10**6+1):
    if n%i == 0:
        div+=[i,n//i]
    if (n-1)%i == 0:
        div2+=[i,(n-1)//i]
div = set(div)
div2 = set(div2)
# print(div)
a = [1]
for i in div:
    if i > 1:    
        t = n
        while t:
            if t%i == 0:
                t = t//i
            else:
                if t%i == 1:
                    ans += 1
                    a += [i]
                break
# for i in div2:
#     if i > 1:    
#         t = n-1
#         while t:
#             if t == 1:
#                 ans += 1
#                 a += [i]
#             t //= i
#         # if n%(i-1) == 1:
#         #     ans += 1
#         #     a += [i-1]
# print(ans)
# print(a)
# print(div)
# print(div2)
for i in div2:
    a+=[i]
a = set(a)
# print(a)
print(len(a)-1)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans = 1
a = (prime_factorize(n))
b = collections.Counter(prime_factorize(n-1))
for i in b.values():
    ans *= (i+1)
for i in range(len(a)):
    for j in range(i):
        if a[i]%a[j] == 1:
            ans += 1
            a[i] //= a[j]
print(ans)
Problem p02747 (python)

Fixed submission:
s = str(input())
if len(s)%2 == 1:
    print("No")
    exit()
for i in range(0,len(s),2):
    if s[i] == 'h' and s[i+1] == 'i':
        continue
    else:
        print("No")
        exit()
print("Yes")
# n = int(input())
# ans = 0

# for i in range(n):
#     print(i)


# print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
for i in range(0,len(s),2):
    if s[i] == 'h' and s[i+1] == 'i':
        continue
    else:
        print("No")
        exit()
print("Yes")
# n = int(input())
# ans = 0

# for i in range(n):
#     print(i)


# print(ans)
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
ans = [99]*n
for i in range(m):
    s,c = map(int,input().split())
    if ans[s-1] == 99 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        exit()
if ans[0] == 0 and n != 1:
    print(-1)
    exit()
if ans[0] == 99 and n != 1:
    ans[0] = 1
for i in range(n):
    if ans[i] == 99:
        ans[i] = 0


print("".join([str(i) for i in ans]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ans = [0]*n
for i in range(n):
    s,c = map(int,input().split())
    if ans[s-1] == 0 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print(-1)
        exit()
if ans[0] == 0:
    print(-1)
    exit()
print("".join([str(n) for n in ans]))
Problem p02780 (python)

Fixed submission:
n,k = map(int,input().split())
p = [0]*k + list(map(int,input().split()))
ans = 0
for i in range(k,len(p)):
    p[i] = p[i]*(p[i]+1)/2 / p[i]
    p[i] = p[i] + p[i-1]
for i in range(len(p)-1,k-1,-1):
    p[i] = p[i] - p[i-k]
# print(p)
print(max(p))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(len(p)):
    p[i] = p[i]*(p[i]+1)/2 / p[i]
for i in range(n-k+1):
    p[i] = sum(p[i:i+k])
# print(p)
print(max(p[:n-k]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
for i in range(len(p)):
    p[i] = p[i]*(p[i]+1)/2 / p[i]
for i in range(n-k+1):
    p[i] = sum(p[i:i+k])

print(max(p[:k-1]))
Problem p02786 (python)

Fixed submission:
import math
import sys
h = int(input())
ans = 0
num = 0
if h == 1:
    print(1)
    sys.exit()
for i in range(41,0,-1):
    if 2**i <= h:
        num = 2**i
        rep = i
        # print(i)
        break
for i in range(rep+1):
    ans += 2**i
# print(num)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
h = int(input())
ans = 0
num = 0
for i in range(41,0,-1):
    if 2**i <= h:
        num = 2**i
        rep = i
        # print(i)
        break
for i in range(rep+1):
    ans += 2**i
# print(num)
print(ans)
Problem p02795 (python)

Fixed submission:
import math
h = int(input())
w = int(input())
n = int(input())
print(min(math.ceil(n/h),(math.ceil(n/w))))

Buggy submission (verdict: Runtime Error):
n,k,s = map(int,input().split())
ans = [s]*k + [(s%(10**6)+1) for i in range(n-k)]
 
print(" ".join(map(str,ans)))
Problem p02802 (python)

Fixed submission:
import math
n,m = map(int,input().split())
ps_ls = [list(input().split()) for i in range(m)]
ans_wa = 0
ans_ac = 0
strk_wa = 0
frag = 1
for i in range(m):
    ps_ls[i][0] = int(ps_ls[i][0])
ps_ls.sort(key=lambda x: x[0])

for i in range(m-1):
    if ps_ls[i][1] == "WA" and frag == 1:
        strk_wa += 1

    if ps_ls[i][1] == "AC":
        if frag == 1:
            ans_ac += 1
        frag = 0
        ans_wa += strk_wa
        strk_wa = 0
    if ps_ls[i][0] != ps_ls[i+1][0]:
        strk_wa = 0
        frag = 1
if ps_ls != []:
    if ps_ls[-1][1] == "AC":
        if frag == 1:
                ans_ac += 1
        ans_wa += strk_wa

print(ans_ac,ans_wa)

Buggy submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
ps_ls = [list(input().split()) for i in range(m)]
ans_wa = 0
ans_ac = 0
strk_wa = 0
frag = 1
for i in range(m):
    ps_ls[i][0] = int(ps_ls[i][0])
ps_ls.sort(key=lambda x: x[0])

for i in range(m-1):
    if ps_ls[i][1] == "WA" and frag == 1:
        strk_wa += 1

    if ps_ls[i][1] == "AC":
        if frag == 1:
            ans_ac += 1
        frag = 0
        ans_wa += strk_wa
    if ps_ls[i][0] != ps_ls[i+1][0]:
        strk_wa = 0
        frag = 1
if ps_ls[-1][1] == "AC":
    if frag == 1:
            ans_ac += 1
    ans_wa += strk_wa

print(ans_ac,ans_wa)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = lcm(ans,i)
for i in a:
    if (ans//i) % 2 == 0:
        print(0)
        exit()
print(((m//(ans//2))+1)//2)

Buggy submission (verdict: Runtime Error):
from math import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = lcm(ans,i)
for i in a:
    if (ans//i) % 2 == 0:
        print(0)
        exit()
print(((m//(ans//2))+1)//2)
Problem p02818 (python)

Fixed submission:
a,b,k = map(int,input().split())
aa = max((a-k),0)
bb = b
if k > a:
    bb = max(b-(k-a),0)
print(aa,bb)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
aa = max((a-k),0)
if k > a:
    bb = max(b-(k-a),0)
print(aa,bb)
Problem p02900 (python)

Fixed submission:
from fractions import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a,b = map(int,input().split())
c = gcd(a,b)
d = factorization(c)
print(len(d)+1-(c==1))

Buggy submission (verdict: Runtime Error):
from math import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a,b = map(int,input().split())
c = gcd(a,b)
d = factorization(c)
print(len(d)+1-(c==1))
Problem p02903 (python)

Fixed submission:
h,w,a,b  = map(int,input().split())
lst_a  = [[1]*a + [0] * (w-a) for i in range(b)]
lst_b  = [[0]*a + [1] * (w-a)] * (h-b)
for i in lst_a:
 print(*i,sep="")
for i in lst_b:
 print(*i,sep="")

Buggy submission (verdict: Runtime Error):
import sys
h,w,a,b = map(int,input().split())
tempa = 0
tempb = [0]*w

list_tb = [[0 for i in range(w)] for j in range(h)]
if w % a != 0 or h % b != 0:
  print("No")
  sys.exit()

if h > 2:
  for i in range(h):
    tempa = 0
    for j in range(w):
      if tempa < a and tempb[j] < b:
        list_tb[i][j] = 1
        tempa += 1
        tempb[j] += 1
    if a != 0 and tempa == 0:
      print("No")
      sys.exit()
else:
  for j in range(w):
    if tempa < a:
      list_tb[0][j] = 1
      tempa += 1

for i in list_tb:
    print(*i,sep="")

Buggy submission (verdict: Runtime Error):
import sys
h,w,a,b = map(int,input().split())
tempa = 0
tempb = [0]*w

list_tb = [[0 for i in range(w)] for j in range(h)]
if w % a != 0 or h % b != 0:
  print("No")
  sys.exit()

if h > 2:
  for i in range(h):
    tempa = 0
    for j in range(w):
      if tempa < a and tempb[j] < b:
        list_tb[i][j] = 1
        tempa += 1
        tempb[j] += 1
else:
  for j in range(w):
    if tempa < a:
      list_tb[0][j] = 1
      tempa += 1

for i in list_tb:
    print(*i,sep="")
Problem p02971 (python)

Fixed submission:
n = int(input())
s=[int(input()) for i in range(n)]
s_sort=sorted(s,reverse=True)
for i in range(n):
    if s[i] == s_sort[0]:
        print(s_sort[1])
    else:
        print(s_sort[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
s=[''.join(int(input())) for i in range(n)]
s_sort=sorted(s,reverse=True)
for i in range(n):
    if s[i] == s_sort[0]:
        print(s_sort[1])
    else:
        print(s_sort[0])
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a,b,c,d = map(int,input().split())
lcm = int(c*d/gcd(c,d))
num_divb = int(b)-int(b//c)-int(b//d)+int(b//lcm)
num_diva = +(a-1)-int((a-1)//c)-int((a-1)//d)+int((a-1)//lcm)

print(int(num_divb)-int(num_diva))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
gcd_cd = c*d/math.gcd(c,d)
num_divb = int(b)-int(b/c)-int(b/d)+int(b/gcd_cd)
num_diva = -(a-1)+int((a-1)/c)+int((a-1)/d)-int((a-1)/gcd_cd)

print(int(num_divb)+int(num_diva))
Problem p03059 (python)

Fixed submission:
a,b,t = map(int,input().split())
print((t//a)*b)

Buggy submission (verdict: Runtime Error):
vb
Problem p03061 (python)

Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
l = [0]
r = [0]
ans = 0
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
for i in range(n-1):
    r.append(gcd(r[i],a[n-1-i]))
for i in range(n):
    ans = max(ans,gcd(l[i],r[-i-1]))
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
a = list(map(int,input().split()))
l = [0]
r = [0]
ans = 0
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
for i in range(n-1):
    r.append(gcd(r[i],a[n-1-i]))
for i in range(n):
    ans = max(ans,gcd(l[i],r[-i-1]))
print(ans)
Problem p03085 (python)

Fixed submission:
b = input()
if b == "A":
	print("T")
elif b == "T":
	print("A")
elif b == "C":
	print("G")
elif b == "G":
	print("C")

Buggy submission (verdict: Runtime Error):
a
Problem p03145 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(a*b//2)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int(input()))
print(a*b//2)
Problem p03160 (python)

Fixed submission:
n = int(input())
ls_h = list(map(int,input().split()))
ls_cos = [0]*n
ls_cos[1] = abs(ls_h[1]-ls_h[0])
for i in range(2,n):
    ls_cos[i] = min(ls_cos[i-2]+abs(ls_h[i]-ls_h[i-2]) , ls_cos[i-1]+abs(ls_h[i]-ls_h[i-1]))

print(ls_cos[-1])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ls_h = list(map(int,input().split()))
temp_min = 99999999
ls_cos = [0]*n
ls_cos[1] = abs(ls_h[1]-ls_h[0])
# print(ls_h)
for i in range(min(k,n)):
    ls_cos[i] = abs(ls_h[i]-ls_h[0])

k = min(k,n)
for i in range(k,n):
    temp_min = 99999999
    for j in range(1,k+1):
        # print(i,j)
        temp_min = min(temp_min,ls_cos[i-j]+abs(ls_h[i]-ls_h[i-j]))
    ls_cos[i] = temp_min
#     print(ls_cos)
# print(ls_cos)
print(ls_cos[-1])
Problem p03161 (python)

Fixed submission:
n,k = map(int,input().split())
ls_h = list(map(int,input().split()))
temp_min = 99999999
ls_cos = [0]*n
ls_cos[1] = abs(ls_h[1]-ls_h[0])
# print(ls_h)
for i in range(min(k,n)):
    ls_cos[i] = abs(ls_h[i]-ls_h[0])

k = min(k,n)
for i in range(k,n):
    temp_min = 10**11
    for j in range(1,k+1):
        # print(i,j)
        temp_min = min(temp_min,ls_cos[i-j]+abs(ls_h[i]-ls_h[i-j]))
    ls_cos[i] = temp_min
#     print(ls_cos)
# print(ls_cos)
# if 99999999 in ls_cos:
#     print(ls_cos[9999999])
print(ls_cos[-1])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ls_h = list(map(int,input().split()))
temp_min = 99999999
ls_cos = [0]*n
ls_cos[1] = abs(ls_h[1]-ls_h[0])
# print(ls_h)
for i in range(min(k,n)):
    ls_cos[i] = abs(ls_h[i]-ls_h[0])

k = min(k,n)
for i in range(k,n):
    temp_min = 99999999
    for j in range(1,k+1):
        # print(i,j)
        temp_min = min(temp_min,ls_cos[i-j]+abs(ls_h[i]-ls_h[i-j]))
    ls_cos[i] = temp_min
#     print(ls_cos)
# print(ls_cos)
if 99999999 in ls_cos:
    print(ls_cos[9999999])
print(ls_cos[-1])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ls_h = list(map(int,input().split()))
temp_min = 99999999
ls_cos = [0]*n
ls_cos[1] = abs(ls_h[1]-ls_h[0])
for i in range(k):
    ls_cos[i] = abs(ls_h[i]-ls_h[0])

for i in range(2,n):
    temp_min = 99999999
    for j in range(1,min(k+1,i+1)):
        # print(j)
        temp_min = min(temp_min,ls_cos[i-j]+abs(ls_h[i]-ls_h[i-j]))
    ls_cos[i] = temp_min
# print(ls_cos)
print(ls_cos[-1])
Problem p03164 (python)

Fixed submission:
import bisect
N,W = map(int,input().split())
dp = [0]*(10**3+1)+[10**12]*(10**5)
for i in range(N):
    w,v = map(int,input().split())
    for j in range(len(dp)-1,1000,-1):
        dp[j] = min(dp[j],dp[j-v]+w)
print(bisect.bisect_right(dp,W)-1001)

Buggy submission (verdict: Runtime Error):
N,W = map(int,input().split())
dp = [0]*(W+1)
for i in range(N):
    w,v = map(int,input().split())
    for i in range(W,w-1,-1):
        dp[i] = max(dp[i],dp[i-w]+v)
print(dp[-1])
Problem p03325 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    while a[i] % 2 == 0:
        a[i] //= 2
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
d,n=map(int,input().split())
print((n+n//100)*(100**d))
Problem p03469 (python)

Fixed submission:
s = list(map(str,input()))
s[3] = "8"
print(*s,sep="")

Buggy submission (verdict: Runtime Error):
s = list(map(str,input()))
s[3] = "8"
print(*s[0:3],"8",*s[4:],sep="")

Buggy submission (verdict: Runtime Error):
s = str(input())
s[3] = "8"
print(s)

Buggy submission (verdict: Runtime Error):
s = str(input())
s[3] = 8
print(s)
Problem p03501 (python)

Fixed submission:
n,a,b = map(int,input().split())
print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
n,a,b = map(intm,input().split())
print(min(n*a,b))
Problem p03546 (python)

Fixed submission:
import numpy as np
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]
ans = 0
l = np.array(l)
for rep in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if l[i][j] > l[i][k]+l[k][j]:
                    l[i][j] = l[i][k]+l[k][j]
num = [i[1] for i in l] + [0]
for i in a:
    for j in i:
        ans += num[j]
print(ans)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]
ans = 0
l = np.array(l)
for rep in range(10):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if l[i][j] > l[i][k]+l[k][j]:
                    l[i][j] = l[i][k]+l[k][j]
num = [i[1] for i in l] + [0]
for i in a:
    for j in i:
        ans += num[j]
print(ans)
Problem p03547 (python)

Fixed submission:
x,y = map(str,input().split())
print(">") if ord(x)>ord(y) else print("<") if ord(x)<ord(y) else print("=")

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
print(">") if ord(x)>ord(y) else print("<") if ord(x)<ord(y) else print("=")
Problem p03633 (python)

Fixed submission:
import fractions
n = int(input())
t = [int(input()) for i in range(n)]
ans = 1
for i in t:
    ans = ans * i // fractions.gcd(ans,i)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
t = [int(input()) for i in range(n)]
ans = 1
for i in t:
    ans = ans * i // math.gcd(ans,i)
print(ans)
Problem p03994 (python)

Fixed submission:
s = list(input())
k = int(input())
for i in range(len(s)):
    if s[i] != "a" and (123-ord(s[i])) <= k:
        k -= (123-ord(s[i]))
        s[i] = "a"
    if i == len(s)-1:
        s[i] = (chr((((ord(s[i])+(k%26))-97)%26)+97))

print("".join(s))



# a = "z"
# a = ord(a)
# print(a)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
dls = list(map(str,input().split()))
while 1:
    s = str(n)
    for i in dls:
        if i in s:
            break
    else:
        print(n)
        exit()
    n += 1
Problem p02684 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 5 * 2)
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
top = -1
hist = []
finished = [True] + [False for _ in range(N)]
seen = [True] + [False for _ in range(N)]

def dfs(cur):
    global hist, finished, seen, top
    hist.append(cur)
    seen[cur] = True
    nex = A[cur]
    if seen[nex] and not finished[nex]:
        top = nex
        return
    dfs(nex)
    if not top == -1:
        return
    hist.pop()
    finished[cur] = True
    
dfs(1)
cycle = []
while not hist == []:
    i = hist.pop()
    cycle.append(i)
    if i == top:
        break

cycle.reverse()

cur = 1
while not cur == top and not K == 0:
    cur = A[cur]
    K -= 1

if cur == top:
    cur = cycle[K % len(cycle)]

print(cur)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
top = -1
hist = []
finished = [True] + [False for _ in range(N)]
seen = [True] + [False for _ in range(N)]

def dfs(cur):
    global hist, finished, seen, top
    hist.append(cur)
    seen[cur] = True
    nex = A[cur]
    if seen[nex] and not finished[nex]:
        top = nex
        return
    dfs(nex)
    if not top == -1:
        return
    hist.pop()
    finished[cur] = True
    
dfs(1)
cycle = []
while not hist == []:
    i = hist.pop()
    cycle.append(i)
    if i == top:
        break

cycle.reverse()

cur = 1
while not cur == top and not K == 0:
    cur = A[cur]
    K -= 1

if cur == top:
    cur = cycle[K % len(cycle)]

print(cur)