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

Fixed submission:
N = int(input())
L = [input() for i in range(3)]
ans = [0] * N
tmp = []
for i in range(N):
  for j in range(3):
      tmp.append(L[j][i])
  ans[i] = len(set(tmp)) - 1
  tmp = []
print(sum(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [input() for i in range(3)]
ans = [0] * N.
tmp = []
for i in range(N):.
  for j in range(3):
      tmp.append(L[j][i])
  ans[i] = len(set(tmp)) - 1
  tmp = []
print(sum(ans))
Problem p03150 (python)

Fixed submission:
L = input()
A = 'keyence'

for i in range(len(L)):
    for j in range(i, len(L)):
        if L[:i] + L[j:] == A:
            print("YES")
            exit()
print("NO")

Buggy submission (verdict: Runtime Error):
L = list(input())
A = list("keyence")

prev = -1
for i, a in A:
  curr = L.index(a)
  if prev < current:
    continue
  else:
    print("NO")
    exit()
print("YES")
Problem p03160 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
print(dp[-1])

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

def minStep(num, prev, cost):
  if num <= 0:
    cost += abs(prev - H[0])
    return cost
  a1 = abs(prev - H[num-1])
  a2 = abs(prev - H[num-2])
  if a1 < a2:
    cost += a1
    return minStep(num-1, H[num-1], cost)
  cost += a2
  return minStep(num-2, H[num-2], cost)

print(minStep(N-1, H[N-1], 0))
Problem p03164 (python)

Fixed submission:
n,w=map(int, input().split())
m=10**5+1
x=[list(map(int, input().split())) for i in range(n)]
dp=[[float('inf')]*m for i in range(n+1)]
dp[0][0]=0
for i in range(n):
    for j in range(m):
        if j>=x[i][1]:
            dp[i+1][j]=min(dp[i][j],dp[i][j-x[i][1]]+x[i][0])
        else:
            dp[i+1][j]=dp[i][j]
ans=0
for i in range(m):
    if dp[-1][i]<=w:ans=max(ans,i)
print(ans)

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

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

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input())
print(X + Y // 2)
Problem p03231 (python)

Fixed submission:
from fractions import gcd
N, M = map(int, input().split(" "))
S = input()
T = input()
G = gcd(N, M)
L = N * M // G
for i in range(G):
  if S[i*N//G] != T[i*M//G]:
    print(-1)
    exit(0)
print(L)

Buggy submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split(" "))
S = input()
T = input()
G = gcd(N, M)
L = N * M // G
for i in range(G):
  if S[i*N//G] != T[i*M//G]:
    print(-1)
    exit(0)
print(L)
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
  exit()
else:
  A = int(input())
  B = int(input())
  print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1
  print("Hello World")
  exit()
else:
  A = int(input())
  B = int(input())
  print(A+B)
Problem p03243 (python)

Fixed submission:
N = input()
ans = []
for i in range(len(N)):
  ans.append(N[0])
if int(''.join(ans)) >= int(N):
    print(''.join(ans))
    exit()
ans = []
for i in range(len(N)):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
N = input()
ans = []
for i in len(N):
  ans.append(N[0])
if int(''.join(ans) > int(N):
    print(''.join(ans))
    exit()
for i in len(N):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))
Problem p03251 (python)

Fixed submission:
N, M, X, Y = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
minB = min(B)
maxA = max(A)
for i in range(X, Y+1):
  if maxA < i and minB >= i and X < i and i <= Y:
    print("No War")
    exit()
print("War")

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
minB = min(B)
maxA = max(A)
for i in range(maxA, minB+1):
  if X < i and Y =< i:
    print("No War")
    exit()
  else:
    print("War")
    exit()
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
L.append(X)
L.sort()
cand = []
def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x

for i in range(N):
    cand.append(abs(L[i] - L[i+1]))

for i, can in enumerate(cand):
    if i == 0:
        tmp = can
        continue
    tmp = gcd(tmp, can)
print(tmp)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
L = []
for i in range(N):
    L.append(abs(X - A[i]))
for i in range(N-1)
    L.append(A[i+1] - A[i])
print(min(L))
Problem p03316 (python)

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

Buggy submission (verdict: Runtime Error):
N = input()
ans = 0
for n in N:
  ans += int(ans)
if int(N) % ans == 0:
  print("Yes")
else:
  print("No")
Problem p03353 (python)

Fixed submission:
A = list(input())
K = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, i+K+1):
        L.append(''.join(A[i:j]))
L = list(set(L))
L.sort()
print(L[K-1])

Buggy submission (verdict: Runtime Error):
A = input()
N = int(input())
L = []
for i in range(len(A)):
    for j in range(i+1, len(A)):
        L.append(A[i:j])
L = list(set(L))
L.sort()
print(L[N-1])
Problem p03363 (python)

Fixed submission:
from math import factorial as f
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in dic.keys():
    if dic[key] > 1:
        cnt += f(dic[key]) // f(2) // f(dic[key] - 2)
print(int(cnt))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in dic.keys():
    if dic[key] > 1:
        cnt += comb(dic[key], 2, exact=True)
print(int(cnt))

Buggy submission (verdict: Runtime Error):
from math import factorial
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    L.append(L[-1] + A[i])
L.sort()
ind = list(set(L))
for i in ind:
    n = L.count(i)
    if n > 1:
        cnt += factorial(n) / factorial(2) / factorial(n - 2)
print(int(cnt))

Buggy submission (verdict: Runtime Error):
from math import factorial
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    L.append(L[-1] + A[i])
ind = list(set(L))
for i in ind:
    n = L.count(i)
    if n > 1:
        cnt += factorial(n) / factorial(2) / factorial(n - 2)
print(int(cnt))
Problem p03385 (python)

Fixed submission:
n = list(set(list(input())))
n.sort()
if 'abc' == ''.join(n):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = set(list(input()))
n.sort()
if 'abc' == ''.join(n):
  print("Yes")
else:
  print("No")
Problem p03387 (python)

Fixed submission:
A, B, C = map(int, input().split())
N = [A, B, C]
maxN = max(N)
sumN = sum(N)
if (3 * maxN - sumN) % 2 != 0:
    maxN += 1
print((3 * maxN - sumN) // 2)

Buggy submission (verdict: Runtime Error):
import math

A, B, C = map(int, input().split())
maxN = max([A, B, C])
minN = min([A, B, C])
for n in [A, B, C]:
    if n != maxN and n != minN:
        midN = n
diff1 = maxN - midN
diff2 = maxN - minN

if (diff1 % 2 == 0 and diff2 % 2 == 0) or (diff1 % 2 != 0 and diff2 % 2 != 0):
    print((diff1 + diff2) // 2)
else:
    print(math.ceil((diff1 + diff2) / 2) + 1)
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split(" "))
for i in range(N+1):
  for j in range(N+1-i):
    k = N-i-j
    if Y == (10000*k + 5000*j + 1000*i):
      print(k,j,i)
      exit(0)
print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
import itertools
L = input()
s = ['+','-']
t = ['+','-']
u = ['+','-']
for a, b, c in itertools.product(s, t, u):
   f = L[0] + a + L[1] + b + L[2] + c + L[3] 
   if eval(f) == 7:
       print(f+'=7')
       exit(0)
Problem p03474 (python)

Fixed submission:
A, B = map(int, input().split())
S = input()
s = S.split("-")
if len(s) != 2:
    print("No")
    exit()
if len(s[0]) == A and len(s[1]) == B:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
S = input()
s1, s2 = S.split("-")
if len(s1) == A and len(s2) == B:
    print("Yes")
else:
    print("No")
Problem p03547 (python)

Fixed submission:
X, Y = input().split()
if X > Y:
  print(">")
elif X < Y:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())
if X > Y:
  print(">")
elif X < Y:
  print("<")
else:
  print("=")
Problem p03730 (python)

Fixed submission:
A, B, C = map(int, input().split(" "))
l = []
for i in range(10000000):
  tmp = A*i%B
  if tmp in l:
    break
  l.append(tmp)
if C in l:
  print("YES")
else:
  print("NO")

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

for i in range(1, 100000):
  if A * i % B == C:
    print("Yes")
    exit(0)
print("No"
Problem p03854 (python)

Fixed submission:
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
S = input()
S.replace("dreamer", "").replace("eraser", "").replace("dream","").r
eplace("erase", "")
if len(S) == 0:
  print("YES")
else:
  print("NO")
Problem p03651 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N, A = map(int, input().split())
tmp = input()
ary = [int(a) for a in tmp.split()]

maximum = max(ary)


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


g = None
for a in ary:
    if g is None:
        g = a
        continue
    g = gcd(g, a)

if A % g == 0 and A <= maximum:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
arys = []
for i in range(N):
    tmp = input()
    ary = [int(a) - 1 for a in tmp.split()]
    arys.append(ary)


s = set([i for i in range(M)])
min_num = None
while len(s) > 0:
    dic = {}
    for ary in arys:
        del_i = None
        for i, a in enumerate(ary):
            if a in s:
                if a not in dic:
                    dic[a] = 1
                else:
                    dic[a] += 1
                break
            del_i = i
        if del_i is not None:
            ary = ary[del_i + 1:]
    max_v = None
    max_k = None
    for k, v in dic.items():
        if max_v is None or max_v < v:
            max_v = v
            max_k = k
    if min_num is None or min_num > max_v:
        min_num = max_v
    s.remove(max_k)
print(min_num)
Problem p03071 (python)

Fixed submission:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

A,B=na()
if(A==B):
    print(A+B)
elif(A>B):
    if(A-1>B):
        print(A+A-1)
    else:
        print(A+B)
elif(B>A):
    if(B-1>A):
        print(B+B-1)
    else:
        print(A+B)

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
N,K=na();S=ns()
l=[]
N=len(S)
if(S[0]=="0"):
    l.append(0)
b=S[0]
ct=1
for i in S[1:]:
    if(b!=i):
        l.append(ct)
        ct=1
        b=i
    else:
        ct+=1
l.append(ct)

len_l=len(l)
if(len_l//2 <= K):
    print(sum(l))
    exit()
res = sum(l[:2*K+1])
ans=res
if(len_l%2==0):
    l.append(0)
    len_l+=1
g = K * 2 + 1
for i in range(K*2+1,len_l-1,2):
    ans -= l[i-g] + l[i+1-g]
    ans += l[i] + l[1+i]
    res = max(ans,res)
#print(l)
print(res)
Problem p03103 (python)

Fixed submission:
N,M=list(map(int,input().split()))
A=[]
for i in range(N):
    A.append(list(map(int,input().split())))
# print(A)
A.sort()
#print(A)
res,count=0,0
for i in range(N):
    res+=A[i][0]*A[i][1]
    count+=A[i][1]
    if(count==M):
        break 
    if(count>M):
        res-=A[i][0]*A[i][1]
        count-=A[i][1]
        for j in range(1,A[i][1]+1):
            res+=A[i][0]
            count+=1
            if(count==M):
                print(res)
                exit()

print(res)
exit()

Buggy submission (verdict: Runtime Error):
N,M=list(map(int,input().split()))
A=[]
for i in range(N):
    A.append(list(map(int,input().split())))
# print(A)
A.sort()
#print(A)
res,count=0,0
for i in range(N):
    res+=A[i][0]*A[i][1]
    count+=A[i][1]
    if(count==M):
        break 
    if(count>M):
        res-=A[i][0]*A[i][1]
        count-=A[i][1]
        for j in range(1,A[i][1]+1):
            res+=A[i][0]
            count+=1
            if(count==M):
                print(res)
                exit()

print(res)
exit()a
Problem p03244 (python)

Fixed submission:
import collections
n=int(input())
N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
if (n<=2):
    print("0")
elif (len(list_even)==most_even and len(list_odd)==most_odd and c_odd.most_common()[0][0]==c_even.most_common()[0][0]):
    print(most_odd)
else:
    if(c_odd.most_common()[0][0]==c_even.most_common()[0][0]):
        M=max(c_odd.most_common()[1][1],c_even.most_common()[1][1])
        print(min((len(list_even)+len(list_odd)-M-most_odd),(len(list_even)+len(list_odd)-M-most_even)))
    else:
        print(len(list_even)+len(list_odd)-most_even-most_odd)
#c_odd.most_common()[0][0]==c_even.most_common()[0][0]

Buggy submission (verdict: Runtime Error):
import collections
N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
print(len(list_even)+len(list_odd)-most_even-most_odd)

Buggy submission (verdict: Runtime Error):
import collections

N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
print(len(list_even)+len(list_odd)-most_even-most_odd)
Problem p03262 (python)

Fixed submission:

from functools import reduce
from fractions import gcd

N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
Y = [abs(i-X) for i in x]

print(reduce(gcd, Y, 0))

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

N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
Y = [i-X for i in x]

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

print(gcd_list(Y))

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

N,X = map(int,input().split(" "))
x = list(map(int,input().split(" ")))
Y = [i-X for i in x]

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

print(gcd_list(Y))

#Yの最大公約数を求める
Problem p03304 (python)

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

if d==0:
    R=n
else:
    R=2*(n-d)

print(R*(m-1)/n**2)

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

if d==0:
    R=n
else:
    R=2*(n-d)

print(R(m-1)/n**2)
Problem p03029 (python)

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

apple = A * 3 + P
print(apple // 2)

Buggy submission (verdict: Runtime Error):
import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

is_ok = 0
for patterns in itertools.product((0, 1), repeat=M):
    patterns = list(patterns)
    on_light = 0
    for i, light in enumerate(connected_switches):
        turned_sw = 0
        for switch_id in light:
            turned_sw += patterns[switch_id]
        if turned_sw % 2 == conditions[i] if i in conditions else -1:
            on_light += 1
    if on_light == M:
        is_ok += 1

print(is_ok)
Problem p03031 (python)

Fixed submission:
import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

ok = 0
for patterns in itertools.product((0, 1), repeat=N):
    patterns = list(patterns)
    is_lighting = True
    for i, lights in enumerate(connected_switches):
        turned_sw = sum([patterns[x] for x in lights])
        if turned_sw % 2 != conditions[i]:
            is_lighting = False
            break
    if is_lighting:
        ok += 1

print(ok)

Buggy submission (verdict: Runtime Error):
import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

ok = 0
for patterns in itertools.product((0, 1), repeat=M):
    patterns = list(patterns)
    is_lighting = True
    for i, lights in enumerate(connected_switches):
        turned_sw = sum([patterns[x] for x in lights])
        if turned_sw % 2 != conditions[i]:
            is_lighting = False
            break
    if is_lighting:
        ok += 1

print(ok)

Buggy submission (verdict: Runtime Error):
import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

is_ok = 0
for patterns in itertools.product((0, 1), repeat=M):
    patterns = list(patterns)
    on_light = 0
    for i, light in enumerate(connected_switches):
        turned_sw = 0
        for switch_id in light:
            turned_sw += patterns[switch_id]
        if turned_sw % 2 == conditions[i] if i in conditions else -1:
            on_light += 1
    if on_light == M:
        is_ok += 1

print(is_ok)

Buggy submission (verdict: Runtime Error):
import itertools


N, M = map(int, input().split())
connected_switches = [[int(x) - 1 for x in input().split()[1:]] for x in range(M)]
conditions = list(map(int, input().split()))

is_ok = 0
for patterns in itertools.product((0, 1), repeat=M):
    patterns = list(patterns)
    on_light = 0
    for i, light in enumerate(connected_switches):
        turned_sw = 0
        for switch_id in light:
            turned_sw += patterns[switch_id]
        if turned_sw % 2 == conditions[i]:
            on_light += 1
    if on_light == M:
        is_ok += 1

print(is_ok)

Buggy submission (verdict: Runtime Error):
import itertools


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

lights = []
for i in range(M):
    lights.append([int(x) - 1 for x in input().split()[1:]])

patterns = list(map(int, input().split()))

is_ok = 0
for mode in itertools.product((0, 1), repeat=M):
    mode = list(mode)
    on = 0
    for i, light in enumerate(lights):
        sw = 0
        for x in light:
            sw += mode[x]
        if sw % 2 == patterns[i]:
            on += 1
    if on == M:
        is_ok += 1

print(is_ok)
Problem p03239 (python)

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

c = set()
for i in range(0, N):
    ci, ti = map(int, input().split())
    if ti > T:
        continue
    c.add(ci)

if c:
    print(min(c))
else:
    print('TLE')

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

c = set()
for i in range(0, N):
    ci, ti = map(int, input().split())
    if ti > T:
        continue
    c.add(ci)

print(min(c))
Problem p03240 (python)

Fixed submission:
N = int(input())

points = [None] * N
for i in range(0, N):
    points[i] = list(map(int, input().split()))

h_max = max([h for x, y, h in points])

for H in range(h_max + 100, h_max - 1, -1):
    for Cx in range(101):
        for Cy in range(101):
            ok = True
            for X, Y, h1 in points:
                h2 = max(H - abs(X - Cx) - abs(Y - Cy), 0)
                if h1 != h2:
                    ok = False
                    break
            if ok:
                print('{} {} {}'.format(Cx, Cy, H))
                exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
points.sort(key=lambda x: x[2])
h_max = points[0][2]

for Cx in range(101):
    for Cy in range(101):
        kouho = set()
        for x, y, h in points:
            if len(kouho) > 1:
                break  # 頂点が一意でない

            if h > 0:
                """観測点の高さが1以上なら頂点高を予測"""
                kouho.add(h + abs(x - Cx) + abs(y - Cy))
            else:
                """観測点の高さが0なら式を満たしているかチェック"""
                if list(kouho)[0] - abs(x - Cx) - abs(y - Cy) != 0:
                    kouho = set()
                    break

        if len(kouho) == 1:
            print('{} {} {}'.format(Cx, Cy, list(kouho)[0]))
            exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
h_max = max(h for x, y, h in points)

for Cx in range(101):
    for Cy in range(101):
        kouho = set()
        for x, y, h in points:
            if len(kouho) > 1:
                break  # 頂点が一意でない

            if h > 0:
                kouho.add(h + abs(x - Cx) + abs(y - Cy))
            else:
                if list(kouho)[0] - abs(x - Cx) - abs(y - Cy) != 0:
                    kouho = set()
                    break

        if len(kouho) == 1:
            print('{} {} {}'.format(Cx, Cy, list(kouho)[0]))
            exit()

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

points = []
for i in range(0, N):
    xi, yi, hi = map(int, input().split())
    points.append((xi, yi, hi))

cand = {}
for CX in range(101):
    for CY in range(101):
        Hs = set()
        for x, y, h in points:
            H = h + abs(x - CX) + abs(y - CY)
            Hs.add(H)
        if len(Hs) == 1:
            cand[H] = (CX, CY, H)

CX, CY, H = cand[max(cand)]
print('{} {} {}'.format(CX, CY, H))
Problem p03457 (python)

Fixed submission:
n = int(input())

feasible = True
x = 0
y = 0
t = 0

for i in range(n):
    cp_t, cp_x, cp_y = map(int, input().split())
    if not feasible:
        continue

    step = abs(x - cp_x) + abs(y - cp_y)
    dt = cp_t - t
    if dt < step:
        feasible = False
    if (dt - step) % 2 != 0:
        feasible = False
    x = cp_x
    y = cp_y
    t = cp_t

if feasible:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import itertools

a = int(input())
b = int(input())
c = int(input())
x = int(input())

ok = set()

for a_num in range(a + 1):
    for b_num in range(b + 1):
        for c_num in range(c + 1):
            price = a_num * 500 + b_num * 100 + c_num * 50
            if price == x:
                ok.add((a_num, b_num, c_num))

print(len(ok))