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

Fixed submission:
a = input()
b = input()
c = list(b)
d = 0
e = c.count(".")
f = 0
for i in range(len(c)+1): #左からi個を白にする　0<=i<=len(c)
    if i == 0:
        ans = e
    else:
        if c[i-1] == ".":
            d = d + 1 #dは左からi個のうちの白の個数を指す
        f = (i - d) + (e - d) #左側の(i-d)個の黒を白にし、右側(e-d)個の白を黒にする
        ans = min(ans, f)
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = list(b)
e = []
for i in range(len(c)+1):  #左からi個を白にする
    if i == 0: #全て黒に変える場合
        e.append(c.count("."))
        ans = e[0]
    else:
        if c[i-1] == ".":
            d = d + 1
        e.append(((i - d) + (c.count(".") - d)))
        if ans >= e[i]:
            ans = e[i]
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = list(b)
e = []
for i in range(len(c)+1):  #左からi個を白にする
    if i == 0: #全て黒に変える場合
        e.append(c.count("."))
        ans = e[0]
        print(e)
    else:
        if c[i-1] == ".":
            d = d + 1
        e.append(((i - d) + (c.count(".") - d)))
        print(e)
        if ans >= e[i]:
            ans = e[i]
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = list(b)
if len(c) >= 2:
    while c[0] == "." :
        del c[0]
        if (c[0] == ".") & len(c) == 1:
            break
    while c[len(c)-1] == "#":
        del c[len(c)-1]
        if (c[len(c)-1] == "#") & len(c) == 1:
            break    
    if c.count(".") <= c.count("#"): #白が黒より少ない場合
       d = c.count(".")
    elif c.count(".") > c.count("#"): #白が黒より多い場合
       d = c.count("#")
else: 
    d = 0
print(d)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = list(b)
while c[0] == "." :
    del c[0]
    if (c[0] == ".") & len(c) == 1:
        break
while c[len(c)-1] == "#":
    del c[len(c)-1]
    if (c[len(c)-1] == "#") & len(c) == 1:
        break    
if c.count(".") <= c.count("#"): #白が黒より少ない場合
   d = c.count(".")
elif c.count(".") > c.count("#"): #白が黒より多い場合
   d = c.count("#")
print(d)
Problem p03962 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a == b:
    if a == c:
        print(1)
    else: print(2)
elif a == c:
	print(2)
elif b == c:
  print(2)
else: print(3)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a == b:
    if a == c:
        print(1)
    else: print(2)
elif a == c:
	print(2)
    else: print(3)
elif b == c:
  print(2)
  else: print(3)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a == b:
    if a == c:
        print(1)
    else: print(2)
elif a == c:
    print(2)
	else: print(3)
Problem p03963 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = b * (b-1) ** (a-1)
print(c)
Problem p04029 (python)

Fixed submission:
N = int(input())
candy_sum = int((1+N)*N/2)
print(candy_sum)

Buggy submission (verdict: Runtime Error):
# ６月６日
a = int(input())
b = int(input())
c = int(input())
d = (a+b)*c//2
print(d)

Buggy submission (verdict: Runtime Error):
# ６月６日
a = int(input())
b = int(input())
c = int(input())
d = (a+b)*c//2
print(d)
Problem p03076 (python)

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


def orders(nums):
  r = [10 - (num % 10) for num in nums if (num % 10)]
  if r:
  	return sum(nums) + sum(r) - max(r)
  return sum(nums)

print(orders(nums))

Buggy submission (verdict: Runtime Error):
nums = [int(input()) for _ in range(5)]


def orders(nums):
  r = [10 - (num % 10) for num in nums if (num % 10)]
  return sum(nums) + sum(r) - max(r)

print(orders(nums))
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (a*500 + b*100 + c*50) == X:
                cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
for a in range(A+1):
#     _a = a*500
    for b in range(B+1):
#         _b = b*100 + _a
#         if _b > X: break
        for c in range(C+1):
#             _c = c*50 + _a + _b
#             if _c > X: break
#             if _c == X:
            if (a*500 + b*100 + c*50) == X:
                cnt+=1
print(cnt)

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

cnt = 0
for a in range(min([A,-(-X//500)])+1):
  _tmp = a*500
  if _tmp > x: break
  for b in range(min([B,-(-X//100)])+1):
	_tmp += b*100
	if _tmp > x: break
    for c in range(min([C,-(-X//50)])+1):
	  _tmp += c*50
	  if _tmp > x: break
	  if _tmp == X:
        cnt+=1
print(cnt)
Problem p03470 (python)

Fixed submission:
N = int(input())
D = sorted([int(input()) for _ in range(N)])
if len(D) > 1:
    i,prev = 0,None
    while i < (len(D)-1):
        if D[i] == D[i+1]: 
            D.pop(i+1)
        else:
            prev = D[i]
            i +=1
print(len(D))

Buggy submission (verdict: Runtime Error):
N = int(input())
D = sorted([int(input()) for _ in range(N)])
if len(D) == 1: print(1)
i,prev = 1,D[0]
while i != (len(D)-1):
    if D[i] == prev: 
        D.pop(i)
    else:
        i +=1
        prev = D[i]
print(len(D))

Buggy submission (verdict: Runtime Error):
N = int(input())
D = sorted([int(input()) for _ in range(N)])
i,prev = 1,D[0]
while i != (len(D)-1):
    if D[i] == prev: 
        D.pop(i)
    else:
        i +=1
        prev = D[i]
print(len(D))
Problem p03493 (python)

Fixed submission:
s = input()
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
s = input()
print(count('1'))
Problem p03494 (python)

Fixed submission:
n = input()
l = [int(x) for x in input().split()]
cnt = 0
while len([True for x in l if x%2==0]) == len(l):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
l = input().split()
cnt = 0
while len([True for x in l if x%2==0]):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = input()
l = input().split()
cnt = 0
while len([True for x in l if l%2==0]):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
l = input().split()
cnt = 0
while len([True for x in l if l%2==0]):
  l = [x/2 for x in l]
  cnt += 1
print(cnt)
Problem p03109 (python)

Fixed submission:
s = input()
b = s.split("/")
a = []
for i in b:
    a.append(int(i))
if (a[0] * 10000 + a[1] * 100 + a[2] <= 20190430):
    print("Heisei")
else:
    print("TBD")

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]
q = [int(input()) for _ in range(q)]
for qi in q:
    qans = 10**18
    ai = bisect_left(s, qi)
    bi = bisect_left(t, qi)
    ac = []
    bc = []
    for i in range(2):
        if (0 <= ai + i < a):
            ac.append(ai + i);
        if (0 <= ai - i < a):
            ac.append(ai - i);
    for i in range(2):
        if (0 <= bi + i < b):
            bc.append(bi + i);
        if (0 <= bi - i < b):
            bc.append(bi - i);
    for i in ac:
        for j in bc:
            aa = s[i];
            bb = t[j];
            if (max(aa, bb) <= qi):
                qans = min(qans, qi - min(aa, bb))
            elif (qi <= min(aa, bb)):
                qans = min(qans, max(aa, bb) - qi)
            else:
                qans = min(qans, min(abs(aa - qi), abs(bb - qi)) * 2 + max(abs(aa - qi), abs(bb - qi)))
    print(qans)
Problem p03206 (python)

Fixed submission:
print("Christmas "+("Eve "*(25-int(input()))))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
d = sorted([int(input()) for _ in range(n)],reverse=True)
ret = 9999999999
#print(d)
for i in range(n-k+1):
    #print(i,i+k-1)
    ret = min(ret,d[i]-d[i+k-1])
print(ret)
Problem p03219 (python)

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

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

if w == 1:
    print(1)
    exit(0)

case = []

def createCase(s):
    if (len(s) == w-1):
        case.append(s)
        return
    if len(s) != 0 and s[-1] == "1" :
        createCase(s+"0")
    else:
        createCase(s+"0")
        createCase(s+"1")

createCase("")

for i in range(len(case)):
    case[i] = "0"+case[i]+"0"

# print(case)

move = [[0]*3 for _ in range(w)]

for i in range(w):
    for j in case:
        if j[i] == j[i+1] == "0":
            move[i][1] += 1
        if j[i+1] == "1":
            move[i][2] += 1
        if j[i] == "1":
            move[i][0] += 1

# print(move)

dp = [[0]*w for _ in range(h)]

fib = [0, 1, 2, 3, 5, 8, 13, 21]

dp[0][0] = fib[w-1]
dp[0][1] = fib[w-2]

for i in range(1, h):
    dp[i][0] = (dp[i-1][0]*move[0][1] + dp[i-1][1]*move[1][0]) % 1000000007
    for j in range(1, w-1):
        dp[i][j] = (dp[i-1][j]*move[j][1] + dp[i-1][j-1]*move[j-1][2] + dp[i-1][j+1]*move[j+1][0]) % 1000000007
    dp[i][-1] = (dp[i-1][-2]*move[-2][2] + dp[i-1][-1]*move[-1][1]) % 1000000007

# print(dp)

print(dp[-1][k-1])

Buggy submission (verdict: Runtime Error):
a

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
city = [[] for _ in range(n+1)]
ret = ["" for _ in range(m)]
def createSix(s):
    while len(s) != 6:
        s = "0" + s
    return s
for i in range(m):
    a,b = map(int, input().split())
    city[a].append((b, i))
for i in range(m):
    city[i].sort()
print(city)
for i in range(n+1):
    for j in range(len(city[i])):
        ret[city[i][j][1]] = createSix(str(i)) + createSix(str(j+1))
for i in ret:
    print(i)

Buggy submission (verdict: Runtime Error):
t = int(input())
a,b = map(int, input().split())
ss = list(map(int, input().split()))
p = 0
mi= 99999999999999

for i in range(len(ss)):
    if mi > abs(b - (a - 0.006*ss[i])):
        p = i
        mi = abs(b - (a - 0.006*ss[i]))
print(p+1)
Problem p03063 (python)

Fixed submission:
N = int(input())
S = input()
S = '.' + S

b_tot, w_tot = 0, 0
for s in S:
    if s == '.':
        w_tot += 1
    else:
        b_tot += 1

b_left, w_left = 0, 0
tmp = 3 * 10**5
for s in S:
    if s == '.':
        w_left += 1
    else:
        b_left += 1
    tmp = min(tmp, b_left + w_tot - w_left)
print(tmp)

Buggy submission (verdict: Runtime Error):
b_tot, w_tot = 0, 0
for s in S:
    if s == '.':
        w_tot += 1
    else:
        b_tot += 1
b_left, w_left = 0, 0
tmp = 3 * 10**5
for s in S:
    if s == '.':
        w_left += 1
    else:
        b_left += 1
    tmp = min(tmp, b_left + w_tot - w_left)
print(tmp)
Problem p03138 (python)

Fixed submission:
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = max(len(K_bin), len(bin(max(A))[2:]))
K_bin = K_bin.zfill(digit)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の0の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '0':
            C[i] += 1
ideal = ''
for c in C:
    binary = '1' if c > N//2 else '0'
    ideal += binary
dp = [[0 for _ in range(2)] for _ in range(digit)]
cands = [0]
gain = [2**i for i in range(digit)][::-1]

def calc(s):
    ret = 0
    for i in range(digit):
        tmp = C[i] if s[i] == '1' else N-C[i]
        ret += tmp * gain[i]
    return ret

for i in range(digit):
    if K_bin[i] == '1':
        cands.append(calc(K_bin[:i] + '0' + ideal[i+1:]))
print(max(max(cands), calc(K_bin)))

Buggy submission (verdict: Runtime Error):
from itertools import product
N, K = map(int, input().split())
A = list(map(int, input().split()))
K_bin = bin(K)[2:]
digit = len(K_bin)
B = [bin(a)[2:].zfill(digit) for a in A]
# d桁目の1の個数の，全てのA_iについての総和
C = [0] * digit
for b in B:
    for i, s in enumerate(b):
        if s == '1':
            C[i] += 1
GAIN = [2**i for i in range(digit)][::-1]
maxval = 0
for comb in product(('01'), repeat=digit):
    comb = ''.join(comb)
    if int(comb, 2) > K:
        break
    tmpval = 0
    for i in range(digit):
        res = C[i] if comb[i] == '0' else (N - C[i])
        tmpval += GAIN[i] * res
    maxval = max(maxval, tmpval)
print(maxval)
Problem p03139 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(min(A, B), end=' ')
print(max(A+B-N, 0))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000000000000000)
N, M = map(int, input().split())
T = {}
D = [0 for _ in range(N+1)]
P = [0 for _ in range(N+1)]
root_id = {i for i in range(1, N+1)}
for _ in range(N+M-1):
    a, b = map(int, input().split())
    if a not in T:
        T[a] = [b]
    else:
        T[a].append(b)
    if b in root_id:
        root_id.remove(b)
root_id = root_id.pop()

def setdep(i, p, d):
    if D[i] == 0:
        D[i] = d
        P[i] = p
    else:
        if D[i] > d:
            T[p].remove(i)
            return None
        else: # D[i] < d:
            T[P[i]].remove(i)
            P[i] = p
    if i not in T:
        return None
    for j in T[i]:
        setdep(j, i, d+1)

setdep(root_id, 0, 1)
for p in P[1:]:
    print(p)
Problem p03147 (python)

Fixed submission:
def get_nonzero_range(A):
    start, end = None, None
    N = len(A)
    for i in range(N):
        if A[i] != 0:
            start = i
            for j in range(i+1, N):
                if A[j] == 0:
                    end = j
                    return start, end
    else:
        return start, end

N = int(input())
H = list(map(int, input().split()))
H.append(0)
num = 0
while True:
    start, end = get_nonzero_range(H)
    if start == None:
        break
    else:
        for i in range(start, end):
            H[i] -= 1
        num += 1
print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
num = 0
while H:
    # リストHの0でない要素を探す
    for i in range(N):
        if H[i] != 0:
            while H[i] != 0:
                H[i] -= 1
                i += 1
    num += 1
print(num)
Problem p03148 (python)

Fixed submission:
N, K = map(int, input().split())
TD = []
for _ in range(N):
    TD.append(list(map(int, input().split())))
TD.sort(key=lambda x: -x[1])

removable_list = []
S = set()
base_pt = 0
for t, d in TD[:K]:
    if t in S:
        removable_list.append([t, d])
    else:
        S.add(t)
    base_pt += d
kind = len(S)
removable_list.sort(key=lambda x: x[1])

addable_list = []
for t, d in TD[K:]:
    if t in S:
        continue
    addable_list.append([t, d])
    S.add(t)

pt = [base_pt + kind*kind]
l = min(len(removable_list), len(addable_list))

for rl, al in zip(removable_list[:l], addable_list[:l]):
    kind += 1
    base_pt += al[1] - rl[1]
    pt.append(base_pt + kind*kind)
print(max(pt))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
TD = []
for _ in range(N):
    TD.append(list(map(int, input().split())))
TD.sort(key=lambda x: -x[1])

tmp_list = TD[:K]
removable_list = []
S = set()
base_pt = 0
for t, d in tmp_list:
    if t in S:
        removable_list.append([t, d])
    else:
        S.add(t)
    base_pt += d
kind = len(S)
removable_list.sort(key=lambda x: x[1])

pt = [base_pt + kind*kind]
i = 0
for t, d in TD[K:]:
    if t in S:
        continue
    kind += 1
    base_pt += d - removable_list[i][1]
    pt.append(base_pt + kind*kind)
    i += 1
print(max(pt))
Problem p03155 (python)

Fixed submission:
N = int(input())
H = int(input())
W = int(input())
print((N-H+1) * (N-W+1))

Buggy submission (verdict: Runtime Error):
def trace(i, j, S, col, num_color):
    next_col = 1 - col
    num_color[col] += 1
    S[i][j] = 2
    if S[i-1][j] == next_col:
        trace(i-1, j, S, next_col, num_color)
    if S[i][j-1] == next_col:
        trace(i, j-1, S, next_col, num_color)
    if S[i+1][j] == next_col:
        trace(i+1, j, S, next_col, num_color)
    if S[i][j+1] == next_col:
        trace(i, j+1, S, next_col, num_color)
    return num_color[0] * num_color[1]

def main():
    H, W = map(int, input().split())
    # 黒0，白1，padding2
    S = [[2] * (W+2)]
    for _ in range(H):
        S.append([2] + [0 if s == '#' else 1 for s in input()] + [2])
    S.append([2] * (W+2))
    num_comb = 0
    for i in range(1, H+1):
        for j in range(1, W+1):
            if S[i][j] == 0:
                num_color = [0, 0]
                num_comb += trace(i, j, S, 0, num_color)
    print(num_comb)

main()

Buggy submission (verdict: Runtime Error):
def trace(i, j, S, col, num_color):
    next_col = 1 - col
    num_color[col] += 1
    S[i][j] = 2
    if S[i-1][j] == next_col:
        trace(i-1, j, S, next_col, num_color)
    if S[i][j-1] == next_col:
        trace(i, j-1, S, next_col, num_color)
    if S[i+1][j] == next_col:
        trace(i+1, j, S, next_col, num_color)
    if S[i][j+1] == next_col:
        trace(i, j+1, S, next_col, num_color)
    return num_color[0] * num_color[1]

H, W = map(int, input().split())
# 黒0，白1，padding2
S = [[2] * (W+2)]
for _ in range(H):
    S.append([2] + [0 if s == '#' else 1 for s in input()] + [2])
S.append([2] * (W+2))
# print(S)
num_comb = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == 0:
            num_color = [0, 0]
            num_comb += trace(i, j, S, 0, num_color)
print(num_comb)
Problem p03166 (python)

Fixed submission:
from sys import setrecursionlimit; setrecursionlimit(10**9)
N, M = map(int, input().split())
edge = {i:[] for i in range(1, N+1)}
starts = set(i for i in range(1, N+1))
for _ in range(M):
    x, y = map(int, input().split())
    edge[x].append(y)
    starts -= {y}

memo = [-1] * (N+1)

def rec(e):
    if memo[e] != -1:
        return memo[e]
    ret = 0
    for f in edge[e]:
        ret = max(ret, rec(f) + 1)
    memo[e] = ret
    return ret

max_d = 0
for s in starts:
    max_d = max(max_d, rec(s))
print(max_d)

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit; setrecursionlimit(10**9)
N, M = map(int, input().split())
edge = {i:[] for i in range(1, M+1)}
starts = set(i for i in range(1, N+1))
for _ in range(M):
    x, y = map(int, input().split())
    edge[x].append(y)
    starts -= {y}

memo = [-1] * (N+1)

def rec(e):
    if memo[e] != -1:
        return memo[e]
    ret = 0
    for f in edge[e]:
        ret = max(ret, rec(f) + 1)
    memo[e] = ret
    return ret

max_d = 0
for s in starts:
    max_d = max(max_d, rec(s))
print(max_d)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
edge = {}
starts = set(i for i in range(1, N+1))
for _ in range(M):
    x, y = map(int, input().split())
    if x not in edge:
        edge[x] = [y]
    else:
        edge[x].append(y)
    starts -= {y}

def rec(d, e, dp):
    dp[e] = max(dp[e], d)
    if e not in edge:
        return 0
    for f in edge[e]:
        rec(d+1, f, dp)
    return max(dp)

depth = []
for s in starts:
    depth.append(rec(0, s, [0]*(N+1)))
print(max(depth))
Problem p03192 (python)

Fixed submission:
N = input()
cnt = 0
for n in N:
    if n == '2':
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))
pro = 1
for a in A:
    if a:
        pro *= a
if pro % 2 == 1:
    print('first')
else:
    print('second')
Problem p03240 (python)

Fixed submission:
def manhattan(i, j, x, y):
    # (i, j)中央点の座標，(x, y)既知の座標
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    cand = [0, 0, 0]
    for i in range(101):
        for j in range(101):
            # 既知座標１点を得て，中心座標の高さを決定する
            for k in range(N):
                if H[k] != 0:
                    x, y, h = X[k], Y[k], H[k]
                    hmax = h + manhattan(i, j, x, y)
                    break
            # 残り既知座標N-1点について，矛盾がないか確かめる
            for k in range(N):
                x, y, h = X[k], Y[k], H[k]
                if h == 0:
                    if hmax > manhattan(i, j, x, y):
                        break
                else:
                    if hmax - h != manhattan(i, j, x, y):
                        break
            else:
                if cand[2] < hmax:
                    cand = [i, j, hmax]
    return cand

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

Buggy submission (verdict: Runtime Error):
def manhattan(i, j, x, y):
    # (i, j)中央点の座標，(x, y)既知の座標
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    for i in range(101):
        for j in range(101):
            # 既知座標１点を得て，中心座標の高さを決定する
            x, y, h = X[0], Y[0], H[0]
            hmax = h + manhattan(i, j, x, y)
            # 残り既知座標N-1点について，矛盾がないか確かめる
            for k in range(1, N):
                x, y, h = X[k], Y[k], H[k]
                if hmax - h != manhattan(i, j, x, y):
                    break
            else:
                return i, j, hmax

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

Buggy submission (verdict: Runtime Error):
def manhattan(i, j, x, y):
    # (i, j)中央点の座標，(x, y)既知の座標
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    for i in range(101):
        for j in range(101):
            # 既知座標１点を得て，中心座標の高さを決定する
            x, y, h = X[0], Y[0], H[0]
            hmax = h + manhattan(i, j, x, y)
            # 残り既知座標N-1点について，矛盾がないか確かめる
            for k in range(1, N-1):
                x, y, h = X[k], Y[k], H[k]
                if hmax - h != manhattan(i, j, x, y):
                    break
            else:
                return i, j, hmax

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))
Problem p03262 (python)

Fixed submission:
from fractions import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])

Buggy submission (verdict: Runtime Error):
from math import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])

Buggy submission (verdict: Runtime Error):
from math import gcd
N, O = map(int, input().split())
X = list(map(int, input().split()))
X.append(O)
X.sort()
diff = [x-y for x, y in zip(X[1:], X[:-1])]
# print(diff)
for i in range(N-1):
    diff[i+1] = gcd(diff[i], diff[i+1])
print(diff[N-1])
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = [-x for x in X[::-1]]
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = -X[::-1]
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = reversed(X)
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)