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

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

colors=[]
if list(filter(lambda x:x<3200, a)):
    f=lambda x:x<400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:400<=x<800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:800<=x<1200
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1200<=x<1600
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1600<=x<2000
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2000<=x<2400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2400<=x<2800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2800<=x<3200
    colors.append(1 if list(filter(f, a)) else 0)

    print(sum(colors), sum(colors)+len(list(filter(lambda x:3200<=x, a))))

else:
    print(1, n)

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

colors=[]
if list(filter(lambda x:x<3200, a)):
    f=lambda x:x<400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:400<=x<800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:800<=x<1200
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1200<=x<1600
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:1600<=x<2000
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2000<=x<2400
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2400<=x<2800
    colors.append(1 if list(filter(f, a)) else 0)
    f=lambda x:2800<=x<3200
    colors.append(1 if list(filter(f, a)) else 0)

    print(sum(colors), sum(colors)+len(list(filter(lambda x:3200<=x, a)))

else:
    print(1, n)
Problem p03698 (python)

Fixed submission:
s = input()

str=[]
for char in s:
    str.append(char)

str.sort()

for char in str:
    if str.count(char) > 1:
        print("no")
        break
else:
    print("yes")

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

str=[]
for char in s:
    str.append(char)

str.sort()

for char in str:
    if str.count(char) > 1:
        print "no"
        break
else:
    print "yes"
Problem p03699 (python)

Fixed submission:
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

s.sort(key=lambda x:x%10)

if sum(s) % 10 != 0:
    print(sum(s))
elif s[-1] % 10>0:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
elif filter(lambda x:x%10>0,s) == False:
    print(0)
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))

Buggy submission (verdict: Runtime Error):
n = int(input())
s=[]
for i in range(n):
    s.append(int(input()))

if sum(s) % 10 != 0:
    print(sum(s))
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))

Buggy submission (verdict: Runtime Error):
n = int(input())
s=[]
for i in range(n):
    s.append(int(input())

if sum(s) % 10 != 0:
    print(sum(s))
else:
    print(sum(s)-min(filter(lambda x:x%10>0,s)))
Problem p03712 (python)

Fixed submission:
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input())

print("#" * (w+2))

for i in range(h):
    print("#"+a[i]+"#")

print("#" * (w+2))

Buggy submission (verdict: Runtime Error):
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input())

print("#" * (w+2))

for i in range(h):
    print("#"+a+"#")

print("#" * (w+2))

Buggy submission (verdict: Runtime Error):
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        a.append(input().split(" "))

print("#" * (w+2))

for i in range(h):
    print("#", end="")
    for j in range(w):
        print(aline[i][j], end="")
    print("#")

print("#" * (w+2))

Buggy submission (verdict: Runtime Error):
(h, w) = map(int, input().split(" "))

a=[]
for i in range(h):
        aline[i] = input().split(" ")

print("#" * (w+2))

for i in range(h):
    print("#", end="")
    for j in range(w):
        print(aline[i][j], end="")
    print("#")

print("#" * (w+2))
Problem p03713 (python)

Fixed submission:
(h, w) = map(int, input().split(" "))

ans=[]
### case1  000
ans.append(0 if h%3==0 else w)
###case 2 tate 000
ans.append(0 if w%3==0 else h)

def getmin(h, w):
    area=9999999999999
    for i in range(h//3-3, h//3+2):
        for j in range(w//2 -3, w//2 +3):
            areas=[ i * w, j * (h-i), (w-j)*(h-i)]
            area = max(areas)-min(areas) if area > max(areas)-min(areas) else area
    return area

ans.append(getmin(h, w))
ans.append(getmin(w, h))

print(min(ans))

Buggy submission (verdict: Runtime Error):
(h, w) = map(int, input().split(" "))

ans=[]
### case1  000
ans.append(0 if h%3==0 else w)
###case 2 tate 000
ans.append(0 if w%3==0 else h)

def getmin(h, w):
    area=9999999999999
    for i in range(h):
        for j in range(w):
            areas=[ i * w, j * (h-i), (w-j)*(h-i)]
            area = min(areas) if area > min(areas)
    return area

ans.append(getmin(h, w))
ans.append(getmin(w, h))

print(min(ans))
Problem p03720 (python)

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

count = [0 for i in range(0,n)]

for i in range(0, m):
    a, b = map(int, input().split(" "))
    count[a-1] += 1
    count[b-1] += 1

for i in range(0, n):
    print(count[i])

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

count = [0 for i in range(0,n)]

for i in range(0, m):
    a, b = map(int, input().split(" "))
    count[a] += 1
    count[b] += 1

for i in range(0, n):
    print(count[i])

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

count = [0 for i in range(0,n)]

for i in range(0, m):
    a, b = map(int, input().split(" "))
    count[a] L= 1
    count[b] += 1

for i in range(0, n):
    print(count[i])
Problem p03721 (python)

Fixed submission:
n, k = map(int, input().split(" "))
 
nums=[]
for i in range(0, n):
    a, b = map(int, input().split(" "))
    nums.append([a, b])

nums.sort(key=lambda x:x[0])
#print(nums)
sum = 0
for i in range(0, n):
    sum +=nums[i][1]
    if sum >= k:
        print(nums[i][0])
        break

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

nums=[]
for i in range(0, n):
    a, b = map(int, input().split(" "))
    nums.extend = [a for i in range(0, b)]
    nums.sort()

print(nums[k-1])

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

nums=[]
for i in range(0, n):
    a, b = map(int, input().split(" "))
    nums.extend = [a for i in range(0, b)]
    nums.sort()

print(nums[k-1])
Problem p03731 (python)

Fixed submission:
N, T = map(int, input().split(" "))
t = list(map(int, input().split(" ")))

shower = 0

for i in range(0, N-1):
    if t[i+1]-t[i] >= T:
        shower += T
    else:
        shower += t[i+1]-t[i]

shower += T
print(shower)

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

shower = 0

for i in range(1, N+1):
    if t[i] >= T:
        shower += T
    else:
        shower += t[i]

print(shower)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().filter(" "))
t = list(map(int, input().filter(" ")))

shower = 0

for i in range(1, N):
    if t[i+1]-t[i] >= T:
        shower += T
    else:
        shower += t[i+1]-t[i]

print(shower)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().filter(" "))
t = list(map(int, input().filter(" ")))

shower = 0

for i in range(1, N+1):
    if t[i+1]-t[i] >= T:
        shower += T
    else:
        shower += t[i+1]-t[i]

print(shower)

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


for i in range(1, c):
    if (a * i) % b == c:
        print("YES")
        break
else:
    print("NO")

a* (任意の整数) % b = cとできるか？
Problem p03737 (python)

Fixed submission:
s1, s2, s3 = input().split(" ")
    
print(s1[0].upper()+s2[0].upper()+s3[0].upper())

Buggy submission (verdict: Runtime Error):
    s1, s2, s3 = input().split(" ")
     
    print(s1[0].upper()+s2[0].upper()+s3[0].upper())

Buggy submission (verdict: Runtime Error):
s1, s2, s3 = input().split(" ")

print(s1[0].upper()+s2[0].upper()s3[0].upper())

Buggy submission (verdict: Runtime Error):
s1, s2, s3 = input().split(" ")

print(s1[0].upper+s1[1:]+s2[0].upper+s2[1:]+s3[0].upper+s3[1:])
Problem p03759 (python)

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

if b-a == c-b:
    print("YES");
else:
    print("NO");

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

if b-a == c-b:
    print("YES");
else:
    print("NO");
Problem p03773 (python)

Fixed submission:
a, b = map(int, input().split(" "));
print( (a+b) % 24);

Buggy submission (verdict: Runtime Error):
from math import factorial

n, a, b = map(int, input().split(" "));
v = list(map(int, input().split(" ")))


def product(iterable):
    prod = 1
    for n in iterable:
        prod *= n
    return prod

def npr(n, r):
    return product(range(n - r + 1, n + 1))

def ncr(n, r):
    if r > n // 2:
        r = n - r
    return npr(n, r) // factorial(r)

v.sort();
revv=list(reversed(v))
print(sum(v[-a:])/a)

revpos=revv.index(v[-a]);
num=v.count(v[-a]);
ans=0;
for i in range(a-revpos, b-revpos+1):
    ans+=ncr(num, i);
print(ans);

Buggy submission (verdict: Runtime Error):
import math;

n, m = map(int, input().split(" "));
ab = [];
for i in range(0, n):
    ab.append(input().split(" "));

cd = [];
for i in range(0, m):
    cd.append(input().split(" "));

for i in range(0, n):
    dist=9999999999999
    nearm=0;
    for j in range(0, m):
         dist2 = math.fabs(int(ab[i][0]) - int(cd[j][0])) + math.fabs(int(ab[i][1]) - int(cd[j][1]));
         if dist2 < dist:
            dist = dist2;
            nearm=j;
    print(nearm + 1);

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split(" ");
print( (a+b) % 24)
Problem p03437 (python)

Fixed submission:
import sys
def gcd(a, b):
        while b:
                a, b = b, a % b
        return a
def lcm(a, b):
    return a * b // gcd (a, b)

x,y = map(int, input().split())
temp = x
if x == y:
    print(-1)
    sys.exit()
while True:
    temp += x
    if temp % y != 0:
        print(temp)
        sys.exit()
    elif temp > lcm(x, y):
        print(-1)
        sys.exit()

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
temp = x
if x == y:
    print(-1)
    sys.exit()
while True:
    temp **= 2
    if temp % y != 0:
        print(temp)
        sys.exit()
    elif temp > 100000000000000000:
        print(-1)
        sys.exit()
Problem p03260 (python)

Fixed submission:
numbers = input()
num_a = int(numbers.split()[0])
num_b = int(numbers.split()[1])
if (num_a * num_b) % 2 == 0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
nums = map(int, input().split())
if nums[0] * nums[1] % 2:
  return "Yes"
return "No"

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if a * b % 2:
  return "Yes"
return "No"

Buggy submission (verdict: Runtime Error):
return input() * input() % 2
Problem p03261 (python)

Fixed submission:
falsify = "Yes"
c = int(input())
w = []
for i in range(c):
  w.append(input())
if len(set(w)) != len(w):
  falsify = "No"
for i in range(len(w) - 1):
  if w[i][-1] != w[i+1][0]:
    falsify = "No"
print(falsify)

Buggy submission (verdict: Runtime Error):
c = int(input())
w = []
for i in range(c):
  w.append(input())
if len(set(w)) != len(w):
  print("No")
  return
for i in range(len(w) - 1):
  if w[i][-1] != w[i+1][0]:
    print("No")
    return
print("Yes")
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
A=abs(a-b)
B=abs(b-c)
C=abs(c-a)
if (C<=d) or (A<=d and B<=d):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input()split())
A=abs(a-b)
B=abs(b-c)
C=abs(c-a)
if (C<=d) or (A<=d and B<=d):
  print("Yes")
else:
  print("No")
Problem p03377 (python)

Fixed submission:
A, B, X=map(int,input().split())
if A<=X<=(A+B):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N=int(input())
X=[int(i) for i in input().split()]
for i in range(N):
  x=X.copy()
  del x[i]
  x.sort()
  print(x[N//2-1])
Problem p03379 (python)

Fixed submission:
N=int(input())
X=[int(i) for i in input().split()]
x=X.copy()
x.sort()
mina=x[N//2-1]
minb=x[N//2]
for i in range(N):
  if mina<X[i]:
    print(mina)
  else :
    print(minb)

Buggy submission (verdict: Runtime Error):
N=int(input())
X=[int(i) for i in input().split()]
for i in range(N):
  x=X.copy()
  del x[i]
  x.sort()
  print(x[N//2-1])
Problem p03399 (python)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
if A<=B:
  min1=A
else:
  min1=B
if C<=D:
  min2=C
else:
  min2=D
  
print(min1+min2)

Buggy submission (verdict: Runtime Error):
N=int(input())
list_A=[int(A) for A in input().split()]
list_A.insert(0,0)
list_A.insert(N+1,0)
money=0
for i in range(N+1):
  money+=abs(list_A[i+1]-list_B[i])
for i in range(1,N+1):
  Money=money-abs(list_A[i]-list_A[i-1])-abs(list_A[i+1]-list_A[i])+abs(list_A[i+1]-list_A[i-1])
  print(Money)

Buggy submission (verdict: Runtime Error):
N=int(input())
D=int(input())
X=int(input())
S=0
for i in range(1,N):
  A=int(input())
  A_=(D//A)+1
  S+=A_
print(S+X)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
D=input()
if A<=B:
  min1=int(A)
else:
  min1=int(B)
if C<=D:
  min2=int(C)
else:
  min2=int(D)
  
print(min1+min2+"\n")

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
D=input()
if A<=B:
  min1=int(A)
else:
  min1=int(B)
if C<=D:
  min2=int(C)
else:
  min2=int(D)
min_=min1+min2
print(int(min)_)
Problem p03401 (python)

Fixed submission:
N=int(input())
list_A=[int(A) for A in input().split()]
list_A.insert(0,0)
list_A.insert(N+1,0)
money=0
for i in range(N+1):
  money+=abs(list_A[i+1]-list_A[i])
for i in range(1,N+1):
  Money=money-abs(list_A[i]-list_A[i-1])-abs(list_A[i+1]-list_A[i])+abs(list_A[i+1]-list_A[i-1])
  print(Money)

Buggy submission (verdict: Runtime Error):
N=int(input())
list_A=[int(A) for A in input().split()]
list_A.insert(0,0)
list_A.insert(N+1,0)
money=0
for i in range(N+1):
  money+=abs(list_A[i+1]-list_B[i])
for i in range(1,N+1):
  Money=money-abs(list_A[i]-list_A[i-1])-abs(list_A[i+1]-list_A[i])+abs(list_A[i+1]-list_A[i-1])
  print(Money)
Problem p03260 (python)

Fixed submission:
a,b=list(map(int,input().split()))
if a%2==1 and b%2==1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
r=0
W=[]
for i in range(N):
    W.append(input())

for i in range(N-1):
    if W[i+1][0]!=W[i][-1]:
        r = r+1
for i in range(N):
    for p in range(N):
        if W[i]==W[p]:
            r = r+1
if r == N:
    print('Yes')
else:
    print('No')
Problem p03280 (python)

Fixed submission:
A,B=list(map(int,input().split()))
C=(A-1)*(B-1)
print(C)

Buggy submission (verdict: Runtime Error):
S=input()
K=int(input())
l=len(S)
r=0
q=0
if l==1:
    print(int(S))
else:
    for i in range(0,l-1):
        if int(S[i]) != 1:
            r=int(S[i])
            q=i
            break
    if q>K:
        print(1) 
    else:
        print(r)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if a>1 and b>1:
  C=(a-1)*(b-1)
else:
  break
print(C)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A>1 and B>1:
  C=(A-1)*(B-1)
else:
  break
print(C)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A=int(input())
B=int(input())
C=(A-1)*(B-1)
print("{}".format(C))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A=int(input())
B=int(input())
C=(A-1)*(B-1)
print(C)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=(A-1)*(B-1)
print(C)
Problem p03260 (python)

Fixed submission:
a, b = (int(i) for i in input().split())
if a % 2 and b % 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split())  
if a%2 and b%2:
  	print("Yes")
  else:
    print("No")
Problem p03260 (python)

Fixed submission:
import sys
l = list(map(int, input().split()))
if (l[0] * l[1]) % 2 == 0:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
l = map(int, input().split())
a = l[0] * l[1]
if a % 2 == 0:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
l = map(int, raw_input().split())
if (l[0] * l[1]) % 2 == 0:
    print("No")
else:
    print("Yes")
Problem p03351 (python)

Fixed submission:
a, b, c, d = [int(i) for i in raw_input().split()]
if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
    print "Yes"
else:
    print "No"

Buggy submission (verdict: Runtime Error):
a, b, c, d = [int(i) for i in raw_input()]
if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
    print "Yes"
else:
    print "No"
Problem p03385 (python)

Fixed submission:
inp = raw_input()

c = set([i for i in inp])
if len(c) == 3:
    print "Yes"
else:
    print "No"

Buggy submission (verdict: Runtime Error):
a, b, k = [int(c) for c in raw_input().split()]
data = []

for i in range(k):
    data.append(a+i)
for i in range(k-1, -1, -1):
    if b-i <= data[-1]: continue
    data.append(b-i)
print " ".join(str(d) for d in data)

Buggy submission (verdict: Runtime Error):
a, b, k = [int(c) for c in raw_input().split()]
data = []

for i in range(k):
    data.append(a+i)
for i in range(k-1, -1, -1):
    if b-i <= data[-1]: continue
    data.append(b-i)
print " ".join(str(d) for d in data)

Buggy submission (verdict: Runtime Error):
inp = raw_input()

c = set([i for i in c])
if len(c) == 3:
    print "Yes"
else:
    print "No"
Problem p03260 (python)

Fixed submission:
a, b = map(int,(input().split(" ")))
if ((a%2) * (b%2)) != 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int,(input().split(",")))
if ((a%2) * (b%2)) != 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int(input()))
if ((a%2) * (b%2)) != 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int(input()))
if a%2 == 1:
  if b%2 == 1:
  	print("Yes")
    else:
      print("No")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int(input()))
if (a%2 * b%2) == 1:
  print("Yes")
else:
  print("No")
Problem p03261 (python)

Fixed submission:
n = int(input())
flag = True
s = []
words = []
w1 = input()
words.append(w1)
e = w1[-1]

for i in range(n-1):
    wi = input()
    if e != wi[0]:
        flag = False
    for w in words:
        if w == wi:
            flag = False
    words.append(wi)
    e = wi[-1]


if flag:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
flag = True
s = []
w1 = input()
e = w1[-1]
for i in range(n-1):
  wi = input()
  if e != wi[-1]:
    flag = False
  
  e = wi[-1]
  
if flag:
  print("Yes")
  
else:
  print("No")
Problem p03262 (python)

Fixed submission:
import numpy as np
import fractions
from functools import reduce
N,X = map(int,input().rstrip().split())
x = []
x = list(map(int,input().rstrip().split()))
x.append(X)
x.sort()


mini = []
for i in range(len(x)-1):
	mini.append(x[i+1] - x[i])
print(reduce(fractions.gcd, mini))

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

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

N,X = map(int,input().rstrip().split())
x = []
x = list(map(int,input().rstrip().split()))
x.append(X)
x = sorted(x)

if N==1:
	print(abs(X-x[0]))
	exit()
print(gcd(*x))

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

N,X = map(int,input().rstrip().split())


x = list(map(int,input().rstrip().split()))
x.append(X)

to = []
for i in range(len(x)-1):
	to.append(x[i+1] - x[i])

gcd = functools.reduce(math.gcd, to)
print(gcd)

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

N,X = map(int,input().rstrip().split())


x = list(map(int,input().rstrip().split()))
x.append(X)
x = sorted(x)

to = []
for i in range(len(x)-1):
	to.append(x[i+1] - x[i])

gcd = functools.reduce(math.gcd, to)
print(gcd)

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

N,X = map(int,input().rstrip().split())


x = list(map(int,input().rstrip().split()))
x.append(X)
x = sorted(x)
mini = x[1] - x[0]


to = []
for i in range(len(x)-1):
	to.append(x[i+1] - x[i])
	if mini > x[i+1] - x[i]:
		mini =  x[i+1] - x[i]
		

gcd = functools.reduce(math.gcd, to)
print(gcd)
Problem p03452 (python)

Fixed submission:
import sys
from collections import defaultdict

sys.setrecursionlimit(1000000)

N, M = map(int, sys.stdin.readline().split())
E = defaultdict(list)

for _ in range(M):
    l, r, d = map(int, sys.stdin.readline().split())
    l -= 1
    r -= 1
    E[l].append((r, d))
    E[r].append((l, -d))

xs = [None] * N

def dfs(i, x):
    xs[i] = x
    mi, ma = x, x
    for j, d in E[i]:
        if xs[j] is None:
            res = dfs(j, x + d)
            if res is None:
                return None
            else:
                mi2, ma2 = res
                mi = min(mi2, mi)
                ma = max(ma2, ma)
        else:
            if xs[j] - x != d:
                return None
    return mi, ma

for i in range(N):
    if xs[i] is None:
        res = dfs(i, 0)
        if res is None:
            break
        else:
            mi, ma = res
            if ma - mi > 1e9:
                break
else:
    print('Yes')
    sys.exit()
print('No')

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

N, M = map(int, sys.stdin.readline().split())
E = defaultdict(list)

for _ in range(M):
    l, r, d = map(int, sys.stdin.readline().split())
    l -= 1
    r -= 1
    E[l].append((r, d))
    E[r].append((l, -d))

xs = [None] * N

def dfs(i, x):
    xs[i] = x
    mi, ma = x, x
    for j, d in E[i]:
        if xs[j] is None:
            res = dfs(j, x + d)
            if res is None:
                return None
            else:
                mi2, ma2 = res
                mi = min(mi2, mi)
                ma = max(ma2, ma)
        else:
            if xs[j] - x != d:
                return None
    return mi, ma

for i in range(N):
    if xs[i] is None:
        res = dfs(i, 0)
        if res is None:
            break
        else:
            mi, ma = res
            if ma - mi > 1e9:
                break
else:
    print('Yes')
    sys.exit()
print('No')
Problem p03261 (python)

Fixed submission:
N = int(input())
a = []
for i in range(N):
    a.append(input())
flag = True
for j in range(N-1):
    a_i = a[j]
    a_ii = a[j+1]
    if a_i[-1] != a_ii[0]:
        flag = None
        break
    for k in range(j+1, N):
        if a[j] == a[k]:
            flag = None
            break
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys

a = []
for line in sys.stdin:
    a.append(int(line))
N = len(a)
count = 0
flag = True
for i in range(N):
    a_i = a[i]
    a_ii = a[i+1]
    if ai[-1] != a_ii[0]:
        flag = None
        break
    for j in range(i+1, N):
        if a[i] == a[j]:
            flag = None
            break
if flag:
    print('Yes')
else:
    print('No')
Problem p03502 (python)

Fixed submission:
N = str(input())
ans = 0
for i in N:
    ans += int(i)
if (int(N) % ans == 0):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = str(input())
ans = 0
for i in N:
    ans += int(i)
if (N % ans == 0):
    print('Yes')
else:
    print('No')
Problem p03544 (python)

Fixed submission:
N = int(input())


def fibn(a, b, k, n):
    if k < n:
        return fibn(b, a+b, k+1, n)
    else:
        return a+b
if N == 1:
    print(1)
else:
    print(fibn(2,1,2,N))

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


 def fibn(a, b, k, n):
     if k < n:
         return fibn(b, a+b, k+1, n)
     else:
         return a+b

 print(fibn(2,1,2,N))