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

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
if a.count(0)>0:
  print(0)
else:
  ans=a[0]
  flag=0
  for i in range(1,N):
    ans*=a[i]
    if ans>10**18:
      flag+=1
      print(-1)
      break
  if flag==0:
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=map(int,input().split())
p=list(map,input().split())
x=np.prod(p)
if x<10**18:
  print(x)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
p=list(map(int,input().split()))
x=np.prod(p,axis=1)
if x<10**18:
  print(x)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
lista=[]
p=input().split()
for i in range(N):
  print(p[i])
  lista.append(p[i])
if np.prod(lista)<10**18:
  print(np.prod(lista))
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
p=list(int,input().split())
x=np.prod(p)
if x<10**18:
  print(x)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
p=[int(input()) for i in range(N)]
x=np.prod(p)
if x<10**18:
  print(x)
else:
  print(-1)
Problem p02675 (python)

Fixed submission:
N=int(input())
if N%10==3:
  print("bon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
N=int(input())
N_mozi="N"
for i in range N_mozi:
  if i<len(N_mozi)+1:
    continue
  else:
    end_N=i
if end_N==2 or end_N==4 or end_N==5 or end_N==7 or end_N==9:
  print("hon")
elif end_N==3:
  print("bon")
else:
  print("pon")
Problem p02705 (python)

Fixed submission:
import math
a=int(input())
print(2*math.pi*a)

Buggy submission (verdict: Runtime Error):
import math
a=int(input())
print(2.math.pi*a)
Problem p02706 (python)

Fixed submission:
import numpy as np
N,M=map(int,input().split())
p=list(map(int,input().split()))
if np.sum(p)>N:
  print(-1)
else:
  print(N-np.sum(p))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
p=list(map(int,input().split()))
if np.sum(p)>M:
  print(-1)
else:
  print(N-np.sum(p))
Problem p02687 (python)

Fixed submission:
s = str(input())

a = ''

if s == 'ABC':
    a = 'ARC'
elif s == 'ARC':
    a = 'ABC'

print(a)

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


def calc(x, y):
    if x - 1 >= 0:
        return (x - 1, y)
    elif y - 1 >= 0:
        return (x, y - 1)


answers = []
for i in range(n):
    s = list(map(str, input().split()))
    old_a = a
    old_b = b
    old_c = c

    if s == 'AB':
        a, b = calc(a, b)
    elif s == 'AC':
        a, c = calc(a, c)
    elif s == 'BC':
        b, c = calc(b, c)

    if a > old_a:
        answers.append('A')
    elif b > old_b:
        answers.append('B')
    elif c > old_c:
        answers.append('C')

    if a >= 0 and b >= 0 and c >= 0:
        print('No')
        quit()


print('Yes')
for ans in answers:
    print(ans)
Problem p02702 (python)

Fixed submission:
s = input()[::-1]

cnts = [0] * 2019
cnts[0] = 1

n, d = 0, 1

for char in s:
    n = (n + int(char) * d) % 2019
    d = d * 10 % 2019
    cnts[n] += 1

ans = 0
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
j = len(s)
l = []
for i in range(j):
    for ii in range(i, j):
        ss = int(s[i:ii + 1])
        if not ss:
            continue
        sss = ss / 2019
        if sss.is_integer():
            l.append(ss)

print(len(l))

Buggy submission (verdict: Runtime Error):
s = str(input())
j = len(s)
l = []
for i in range(j):
    for ii in range(i, j):
        ss = int(s[i:ii + 1])
        sss = ss / 2019
        if sss.is_integer():
            l.append(ss)

print(len(l))

Buggy submission (verdict: Runtime Error):
s = str(input())
j = len(s)
l = []
for i in range(j):
    for ii in range(i, j):
        ss = int(s[i:ii + 1])
        sss = ss / 2019
        if sss.is_integer():
            l.append(ss)

print(len(l))
Problem p02641 (python)

Fixed submission:
import sys
input = sys.stdin.readline


def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))
    assert N == len(p)
    if N == 0:
        print(X)
        exit()
    abs_list = []
    abs_list2 = list(range(-100, 100))
    abs_list2.sort()
    abs_list2 = sorted(abs_list2, key=abs)
    for i in p:
        abs_list.append(i-X)
    abs_list.sort()
    abs_list = sorted(abs_list, key=abs)
    # print(abs_list)
    # print(abs_list2)
    for i in range(N):
        if abs_list[i] != abs_list2[i]:
            print(X+abs_list2[i])
            exit()
    print(X+abs_list2[N])


if __name__ == '__main__':
    main()

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


def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))
    assert N == len(p)
    if N == 0:
        print(X)
        exit()
    abs_list = []
    abs_list2 = list(range(-100, 100))
    abs_list2.sort()
    abs_list2 = sorted(abs_list2, key=abs)
    for i in p:
        abs_list.append(i-X)
    abs_list.sort()
    abs_list = sorted(abs_list, key=abs)
    # print(abs_list)
    # print(abs_list2)
    for i in range(len(abs_list2)):
        if abs_list[i] != abs_list2[i]:
            print(X+abs_list2[i])
            exit()


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

Fixed submission:
import sys
input = sys.stdin.readline


def main():
    A, B = map(int, input().split())
    print(A*B)


if __name__ == '__main__':
    main()

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


def main():
    limit = 10**18
    N = int(input())
    A = list(map(int, input().split()))
    assert N == len(A)
    answer = 1
    for i in A:
        answer *= i
        if answer > limit:
            print("-1")
            exit()
        elif answer == 0:
            print(answer)
            exit()
    print(answer)


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

Fixed submission:
n = int(input())
s = input()
r,g,b =0,0,0
ls = len(s)
for i in range(ls):
    if s[i]=='R':
        r+=1
    elif s[i]=='G':
        g+=1
    elif s[i]=='B':
        b+=1
cnt =0
for j in range(1,ls-1):
    for i in range(j):
        k = 2*j-i
        if k<ls:
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                cnt+=1
print(r*g*b-cnt)

Buggy submission (verdict: Runtime Error):
import sys
import collections


def main():
    input = sys.stdin.readline
    N = int(input())
    S = input()
    A = S.count('R')*S.count('G')*S.count('B')
    total = 0
    for j in range(1, N-1):
        for i in range(j):
            k = 2*j-i
            order += 1
            if k < len(S):
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    total += 1
    print(A - total)


def main2():
    N = int(input())
    S = input()
    A = S.count('R')*S.count('G')*S.count('B')
    order = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            order += 1
            if 2*j-i < N:
                if S[i] != S[j] and S[i] != S[2*j-i] and S[j] != S[2*j-i]:
                    A -= 1
    print(A)
    print(order)


if __name__ == "__main__":
    main()
Problem p02730 (python)

Fixed submission:
import sys
input = sys.stdin.readline


def main():
    S = input().strip()
    N = len(S)
    for i in range(N):
        if S[i] != S[N-i-1]:
            print("No")
            exit()
    for i in range((N-1)//2):
        if S[i] != S[(N-1)//2-i-1] or S[(N+3)//2+i-1] != S[N-i-1]:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()

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


def main():
    S = input().strip()
    for i in range((len(S)-1)//2-1):
        if S[i] == S[(len(S)-1)//2-i-1] and S[(len(S)+3)//2+i-1] == S[len(S)-i-1]:
            answer = "Yes"
        else:
            print("No")
            exit()
    print(answer)


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

Fixed submission:
import sys
import math
input = sys.stdin.readline


def main():
    A, B = map(int, input().split())
    for i in range(1000):
        if math.floor((i+1) * 0.08) == A and math.floor((i+1) * 0.1) == B:
            print(i+1)
            exit()
    print("-1")


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline


def main():
    A, B = map(int, input().split())
    for i in range(10000):
        if math.floor((i+1) * 0.08) == A and math.floor((i+1) * 0.1) == B:
            print(i+1)
            exit(-1)
    print("-1")


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

Fixed submission:
import sys
input = sys.stdin.readline


def main():
    K, X = map(int, input().split())
    print("Yes") if 500*K >= X else print("No")


if __name__ == '__main__':
    main()

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


def main():
    K, X = map(int, input().split())
    print("Yes") if 500*K >= X else print("No")


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

Fixed submission:
s = str(input())
s_ = list(s)
for i in range(len(s)):
  if s_[i]=='?':
    s_[i]='D'
S = "".join(s_)
print(S)

Buggy submission (verdict: Runtime Error):
s = str(input())
s_ = list(s)
for i in range(len(s)):
  if i==0 and len(s)==1 and s_[i]=='?':
    s_[i]='D'
  elif i==0 and s_[i]=='?' and s_[i+1]=='D':
      s_[i]='P'
  elif i==0 and s_[i]=='?' and s_[i+1]=='P':
      s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='P':
    s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='D':
    if i=len(s)-1:
      s_[i]='D'
    if s_[i+1]=='D':
      s_[i]='P'
    elif s_[i+1]=='?':
      s_[i]='P'
      s_[i+1]='D'
    else:
      s_[i]='D'
    
S = "".join(s_)
print(S)

Buggy submission (verdict: Runtime Error):
s = str(input())
s_ = list(s)
for i in range(len(s)):
  if i==0 and len(s)==1 and s_[i]=='?':
    s_[i]='D'
  elif i==0 and s_[i]=='?' and s_[i+1]=='D':
      s_[i]='P'
  elif i==0 and s_[i]=='?' and s_[i+1]=='P':
      s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='P':
    s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='D':
    if s_[i+1]=='D':
      s_[i]='P'
    elif s_[i+1]=='?':
      s_[i]='P'
      s_[i+1]='D'
    else:
      s_[i]='D'
    
S = "".join(s_)
print(S)

Buggy submission (verdict: Runtime Error):
s = str(input())
s_ = list(s)
for i in range(len(s)):
  if i==0 and s_[i]=='?' and s_[i+1]=='D':
      s_[i]='P'
  elif i==0 and s_[i]=='?' and s_[i+1]=='P':
      s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='P':
    s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='D':
    if s_[i+1]=='D' or s_[i+1]=='?':
      s_[i]='P'
      s_[i+1]='D'
    else:
      s_[i]='D'
    
S = "".join(s_)
print(S)

Buggy submission (verdict: Runtime Error):
s = str(input())
s_ = list(s)
for i in range(len(s)):
  if s_[i]=='?' and i>0 and s_[i-1]=='P':
    s_[i]='D'
  elif s_[i]=='?' and s_[i+1]=='D':
    s_[i]='P'
  elif s_[i]=='?' and s_[i+1]=='P':
    s_[i]='D'
  elif s_[i]=='?':
    s_[i]='P'
    
S = "".join(s_)
print(S)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    print(x)
    exit()
nums = [n for n in range(-1, 102) if n not in ps]

abs_plus = sorted([n-x for n in nums if n-x >= 0])
abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
if abs_plus == []:
    print(x-abs_minus[0])
elif abs_minus == []:
    print(x+abs_plus[0])
elif abs_plus[0] >= abs_minus[0]:
    print(x-abs_minus[0])
else:
    print(x+abs_plus[0])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 100:
    print("")
elif n > 0:
    ps = list(map(int, input().split()))
else:
    print(x)
nums = [n for n in range(1, 101) if n not in ps]

abs_plus = sorted([n-x for n in nums if n-x >= 0])
abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
if abs_plus == []:
    print(x-abs_minus[0])
elif abs_minus == []:
    print(x+abs_plus[0])
elif abs_plus[0] >= abs_minus[0]:
    print(x-abs_minus[0])
else:
    print(x+abs_plus[0])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    ps = []
nums = [n for n in range(1, 101) if n not in ps]

if x in nums:
    print(x)
else:
    abs_plus = sorted([n-x for n in nums if n-x >= 0])
    abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
    if abs_plus == []:
        print(x-abs_minus[0])
    elif abs_minus == []:
        print(x+abs_plus[0])
    elif abs_plus[0] >= abs_minus[0]:
        print(x-abs_minus[0])
    else:
        print(x+abs_plus[0])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    ps = []
nums = [n for n in range(1, 101) if n not in ps]

if x in nums:
    print(x)
else:
    abs_plus = sorted([n-x for n in nums if n-x >= 0])
    abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
    if abs_plus[0] >= abs_minus[0]:
        print(x-abs_minus[0])
    else:
        print(x+abs_plus[0])
Problem p02660 (python)

Fixed submission:
import math
import numpy as np
n = int(input())
fac = []
sqrt_n = math.sqrt(n)
for i in range(2, int(sqrt_n)):
    if not n % i:
        fac.append(0)
    while not n % i:
        n /= i
        fac[-1] += 1
if n > sqrt_n:
    fac.append(1)
num = 0
for f in fac:
    num += np.count_nonzero(f >= np.cumsum(range(1, f+1)))
print(num)

Buggy submission (verdict: Runtime Error):
import sympy
n = int(input())
i = 0
remove_nums = [1]
while True:
    divisors = sympy.divisors(int(n))
    z_cand = [d for d in divisors if d not in remove_nums]
    if z_cand == []:
        break
    z = min(z_cand)
    remove_nums.append(z)
    n = n/z
    i += 1
print(i)
Problem p02837 (python)

Fixed submission:
import numpy as np
import math





n= int(input())



xandy=np.ones((n,n))

xandy=xandy*(-1)

flag=0
for i in range(0,n):
    a=int(input())
    for j in range(0,a):
        x,y= map(int, input().split())
        xandy[i][x-1]=y

max=0


for l in range(0,2**n):
    i=2**n-1-l
    flag=1
    if max<bin(i).count("1"):
        for j in range(0,n):
       
        #iを2進数表示した時kの位置ででの0-1が対応してあるか立っているか？
            if  bin( i& 2**j).count("1")>0:
                 for k in range(0,n):
                      if  xandy[j][k]!=-1 and xandy[j][k]!=(i >> k)%2:
                          flag=0 
                          break
                       
            if flag==0:
                break
        if flag==1 and max<bin(i).count("1"):
             max=bin(i).count("1")
         

print(max)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math





n= int(input())



xandy=np.ones((n,n))

xandy=xandy*(-1)

flag=0
for i in range(0,n):
    a=int(input())
    for j in range(0,a):
        x,y= map(int, input().split())
        xandy[i][x-1]=y

max=0


for l in range(0,2**n):
    i=2**n-1-l
    flag=1
    if max<bin(i).count("1"):
        for j in range(0,n):
       
        #iを2進数表示した時kの位置ででの0-1が対応してあるか立っているか？
            if  bin( i& 2**j).count("1")>0:
                 for k in range(0,n):
                      if  xandy[j][k]!=-1 and xandy[j][k]!=(i >> k)%2:
                          flag=0 
                        break
                       
            if flag==0:
                break
        if flag==1 and max<bin(i).count("1"):
             max=bin(i).count("1")
         

print(max)
Problem p02646 (python)

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
d = int(d)
dv = v - w
dv = int(dv)
d = abs(d)
if dv > 0 and abs(d) <= abs(dv) * T:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
d = int(d)
dv = v - w
dv = int(dv)
d = abs(d)
if abs(d) % abs(dv) == 0 and abs(d) <= int(dv) * T:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
d = int(d)
dv = v - w
dv = int(dv)
d = abs(d)
if int(d) % abs(dv) == 0 and int(d) <= int(dv) * T:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
d = int(d)
dv = v - w
d = abs(d)
if int(d) % int(dv) == 0 and  int(d) <= int(dv) * T:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = input()
T = int(t)

d = b - a
dv = v - w
if int(d) % int(dv) == 0:
    if int(d) <= int(dv) * T:
        print('YES')
else:
    print('NO')
Problem p02675 (python)

Fixed submission:
N = input()
s = int(N) % 10
if s == 3:
    print('bon')
if s == 0:
    print('pon')
if s == 1:
    print('pon')
if s == 6:
    print('pon')
if s == 8:
    print('pon')

if s == 2:
    print('hon')
if s == 4:
    print('hon')
if s == 5:
    print('hon')
if s == 7:
    print('hon')
if s == 9:
    print('hon')

Buggy submission (verdict: Runtime Error):
n = print()
 
s = int(n) % 10
 
if s == 3:
	print('bon')
if s == 1:
	print('pon')
if s == 2:
    print('hon')
if s == 4:
    print('hon')
if s == 5:
    print('hon')
if s == 6:
    print('pon')
if s == 7:
    print('hon')
if s == 8:
    print('pon')
if s == 9:
    print('hon')
if s == 0:
    print('pon')

Buggy submission (verdict: Runtime Error):
n = print()

s = int(n) % 10

if s == 3:
  print('bon')
if s == 1:
  print('pon')
if s == 2:
  print('hon')
if s == 4:
  print('hon')
if s == 5:
  print('hon')
if s == 6:
  print('pon')
if s == 7:
  print('hon')
if s == 8:
  print('pon')
if s == 9:
  print('hon')
if s == 0:
  print('pon')

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

s = N % 10

if s in [3]
	print('bon')
if s in [0, 1, 6, 8]
	print('hon')
if s in [2, 4, 5, 7, 9]
    print('pon')
Problem p02705 (python)

Fixed submission:
n = input()
pi = 3.142592
R = 2 * pi * int(n)
print(R)

Buggy submission (verdict: Runtime Error):
n = input()
pi = 3.142592
R = 2 * pi * n
print(R)
Problem p02706 (python)

Fixed submission:
x, y = map(int, input().split())
array = list(map(int, input().split()))
su = sum(array)
a = x - su
if a > -1:
    print(a)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().spilit())
array = list(map(int, input().spilit()))
su = sum(array)
a = x - su
if a > -1:
    print(a)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().spilit())
array = list(map(int, input().spilit()))
su = sum(array)
a = x - su
if a > -1:
	print(a)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().spilit())
array = list(map(int, input().spilit()))
su = sum(array)
a = x - su
if a > -1:
  print(a)
else:
  print(-1)
Problem p02645 (python)

Fixed submission:
S = input()
print(S[0:3])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = list(map(int, input().split()))
b = []

for k in range(K):
    b = [0 for _ in range(N)]
    for i in range(N):
        for j in range(max(i-a[i], 0), min(i+a[i]+1, N)):
            b[j] += 1
    a = b
    
ans = " ".join([str(i) for i in a])
print(ans)
Problem p02949 (python)

Fixed submission:
import collections


def bellman_ford(es, n, start):
    infinity = float("inf")
    m = len(es)

    d = [infinity] * (n + 1)
    d[start] = 0

    for _ in range(m):
        updated = False

        for u, v, w in es:
            if d[u] == infinity: continue

            dd = d[u] + w

            if dd < d[v]:
                d[v] = dd
                updated = True

        if not updated: break

    for u, v, w in es:
        if d[u] < infinity and d[u] + w < d[v]:
            return None, True

    return d, False


N, M, P = [int(e) for e in input().split()]

Es = [None] * M

for i in range(M):
    a, b, c = ([int(e) for e in input().split()])
    Es[i] = (a - 1, b - 1, P - c)

q = collections.deque()
q.append(N - 1)

valid = [False] * N
valid[N - 1] = True

while 0 < len(q):
    cur = q.popleft()

    for u, v, _ in Es:
        if cur == v and not valid[u]:
            valid[u] = True
            q.append(u)

es_tmp = []
for e in Es:
    if valid[e[0]] and valid[e[1]]:
        es_tmp.append(e)

Es = es_tmp

distances, le = bellman_ford(Es, N - 1, 0)

if le:
    print(-1)
else:
    print(max(-distances[-1], 0))

Buggy submission (verdict: Runtime Error):
INFINITY = float("inf")

N, M, P = [int(e) for e in input().split()]
Es = [None] * M

for i in range(M):
    Es[i] = ([int(e) for e in input().split()])
    Es[i][2] = P - Es[i][2]

d = [INFINITY] * (M + 1)
d[1] = 0

for _ in range(M):
    for e in Es:
        u, v, w = e
        dd = d[u] + w
        if dd < d[v]:
            d[v] = dd

circle_exists = False

for e in Es:
    u, v, w = e

    if v != N:
        continue

    if d[u] + w < d[v]:
        circle_exists = True
        break


if circle_exists:
    print(-1)
else:
    print(max(0, -d[N]))

Buggy submission (verdict: Runtime Error):
INFINITESIMAL = float("-inf")

N, M, P = [int(e) for e in input().split()]
Es = [None] * M

for i in range(M):
    Es[i] = ([int(e) for e in input().split()])
    Es[i][2] -= P

d = [INFINITESIMAL] * (M + 1)
d[1] = 0

for _ in range(M):
    for e in Es:
        u, v, w = e
        dd = d[u] + w
        if d[v] < dd:
            d[v] = dd

circle_exists = False

for e in Es:
    u, v, w = e

    if v != N:
        continue

    if d[v] < d[u] + w:
        circle_exists = True
        break


if circle_exists:
    print(-1)
elif d[N] < 0:
    print(0)
else:
    print(d[N])
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()

p = list(map(int, input().split()))
l = []
for i in range(-100,102):
  l.append(i)

L = []
for i in l:
  if i not in p:
    L.append(i)

l = []
for i in L:
  l.append([i, abs(x-i)])
a = min(l, key = lambda t: t[1])
print(list(a)[0])

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
l = []
for i in range(1,101):
  l.append(i)
L = []
for i in l:
  if i not in p:
    L.append(i)
l = []
for i in L:
  l.append([i, abs(x-i)])
a = min(l, key = lambda t: t[1])
print(list(a)[0])
Problem p02705 (python)

Fixed submission:
import math
s = int(input())
print(s * 2 * math.pi)

Buggy submission (verdict: Runtime Error):
import math
s = int(input())
print(s * 2 * math.pie)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
k = int(input())
s = 0
l = []
for i in range(k):
  for j in range(k):
    l.append(math.gcd(i+1,j+1))
for h in range(k):
  for n in l:
    s += math.gcd(h+1, n)
print(s)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
n,k = map(int, input().split())
s = 0
for i in range(k):
  for j in range(k):
    for h in range(k):
      s += gcd(i+1,j+1,h+1)
print(s)
Problem p02772 (python)

Fixed submission:
n=int(input())
a = list(map(int, input().split()))
for i in a:
  if i % 2==0:
    if i % 3 == 0 or i % 5 ==0:
      continue
    else:
      print('DENIED')
      exit()
      
print('APPROVED')

Buggy submission (verdict: Runtime Error):
n=int(input())
a = list(map(int, input().split()))
for i in a:
  if a % 2=0:
    if a%3=0 or a%5=0:
      print('APPROVED')
      exit()
print('DENIED')
Problem p02783 (python)

Fixed submission:
H,A = map(int, input().split())
c = 0
while True:
  H = H - A
  c = c+1
  if H <= 0:
    print(c)
    break

Buggy submission (verdict: Runtime Error):
H = input()
A = input()
c = 0
while true:
  H = H - A
  c = c+1
  if H < 0:
    print(c)