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

Fixed submission:
n,m,v,p = map(int, input().split())
a = list( map(int, input().split()))

a.sort(reverse=True)

def isok(i):

    if i <= (p-1):
        return True

    points = a.copy()

    points[i] += m

    adding_point = m*v-m*p

    if points[i] < points[p-1]:
        return False

    j = n-1
    while adding_point > 0:

        if j <= p-2:
            return False

        if i == j:
            j -= 1
            continue
        adding_point -= min(m, points[i]- points[j])

        j -= 1

    return True

if isok(n-1):
    print(n)
    exit()

ok = p-1
ng = n-1

while ng - ok > 1:
    mid = (ok+ng)//2

    if isok(mid):
        ok = mid
    else:
        ng = mid
print(ok+1)

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

a.sort(reverse=True)
# a = np.array(a)

def isok(i):

    if i <= (p-1):
        return True

    points = a.copy()

    points[i] += m

    adding_point = m*v-m*p

    if points[i] < points[p-1]:
        return False

    j = n-1
    while adding_point > 0:

        if j <= p-2:
            return False

        if i == j:
            j -= 1
            continue
        adding_point -= min(m, points[i]- points[j])

        j -= 1

    return True

if isok(n-1):
    print(n)
    exit()

ok = p-1
ng = n-1

while ng - ok > 1:
    mid = (ok+ng)//2

    if isok(mid):
        ok = mid
    else:
        ng = mid
print(ok+1)
Problem p02843 (python)

Fixed submission:
x = int(input())

if x < 100:
    print(0)
    exit()

shimo2 = int(str(x)[-2:])
ue = int(str(x)[:-2])

nums = [0]*6

for i in [5,4,3,2,1]:
    nums[i] = shimo2//i
    shimo2 -= nums[i]*i


if ue >= sum(nums):
    print(1)
else:
    print(0)

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

shimo2 = int(str(x)[-2:])
ue = int(str(x)[:-2])

nums = [0]*6

for i in [5,4,3,2,1]:
    nums[i] = shimo2//i
    shimo2 -= nums[i]*i

if ue >= sum(nums):
    print(1)
else:
    print(0)
Problem p02865 (python)

Fixed submission:
n = int(input())

if n % 2 == 0:
    print(n//2 -1)
else:
    print(n//2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
from collections import defaultdict

def main():
        
    n = int(input())
    a = np.array(list(map(int, input().split())))
    b = np.array(list(map(int, input().split())))

    a_sort = np.sort(a)
    b_sort = np.sort(b)

    # 1. 回数関係なくそもそも不可能なやつ → no
    # 2-a. サイクルは1つだとしても，完璧じゃない組み合わせが1つ以上許容されるやつ → yes
    # 2-b. サイクルが2以上にわけられるやつ → yes

    # 1
    if (a_sort > b_sort).any():
        print('No')
        exit()

    # 2-a
    if (a_sort[1:] <= b_sort[:-1]).any():
        print('Yes')
        exit()

    # 2-b （startをとりあえず1とかにする）
    d = defaultdict(int)
    for i in range(n):
        d[a[i]] = b[i]

    from_ = 1
    count = 0
    while True:
        count += 1
        from_ = d[from_]
        if from_ == 1:
            break

    if count != n:
        print('Yes')
    else:
        print('No')

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

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

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

n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = np.sort(np.array(l))[::-1]

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        ans += np.count_nonzero(lsorted[second+1:] > (lsorted[longest] - lsorted[second]) )
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = sorted(l, reverse=True)

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        se
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        for third in lsorted[second+1:]:
            if lsorted[longest] - lsorted[second] - third >= 0:                
                break
            else:
                ans += 1

print(ans)
Problem p02889 (python)

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

n, m, l = map(int, input().split())

def warshall_floyd(dp):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k][j])
    return dp

dp = [[float('inf')]*n for _ in range(n)]

for _ in range(m):
    a, b, c = map(int,input().split())
    dp[a-1][b-1] = dp[b-1][a-1] = c

for i in range(n):
    dp[i][i] = 0

dp = warshall_floyd(dp)

dp2 = [[float('inf')]*n for _ in range(n)]

for i in range(n):
    for j in range(n):
        if dp[i][j] <= l:
            dp2[i][j] = 1
    dp2[i][i] = 0
dp2 = warshall_floyd(dp2)

q = int(input())

ans = [0]*q
for i in range(q):
    s, t = map(int,input().split())
    tmp = dp2[s-1][t-1]
    ans[i] = -1 if tmp == float('inf') else tmp - 1

print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
n, m, l = map(int, input().split())
abc = [tuple(map(int,input().split())) for i in range(m)]
q = int(input())
st = [tuple(map(int,input().split())) for i in range(q)]

lmod = 10^len(str(l))

def warshall_floyd(dp):
    #d[i][j]: iからjへの最短距離 + lmod * 補給回数
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dp[i][j] = min(dp[i][j],dp[i][k] + dp[k][j])
                if dp[i][j]%lmod >= l:
                    dp[i][j] = dp[i][j] - l + lmod 

    return dp


dp = [[float('inf') for i in range(n)] for i in range(n)] 
for a,b,c in abc:
    a = a - 1
    b = b - 1
    if c > l:
        c = float('inf')     
    
    dp[a][b] = c
    dp[b][a] = c
for i in range(n):
    dp[i][i] = 0

dp_ = warshall_floyd(dp)



for s,t in st:
    s = s-1
    t = t-1
    if dp_[s][t] == float('inf'):
        print(-1)
    else:
        print(dp_[s][t]//lmod)
Problem p02900 (python)

Fixed submission:
import fractions
a,b=map(int, input().split())
n = fractions.gcd(a,b)


def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


divs = divisor(n)
ans = 0

for d in divs:
    ans += is_prime(d)


print(ans+1)

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


def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


divs = divisor(n)
ans = 0

for d in divs:
    ans += is_prime(d)


print(ans+1)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, q = map(int, input().split())
ab = [tuple(map(int,input().split())) for i in range(n-1)]
px = [tuple(map(int,input().split())) for i in range(q)]

es = [[] for i in range(n)]
for a,b in ab:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

ans = [0]*n

# DFS for tree (再帰はpypyの方が遅かったりするので注意)
def dfs(v=0, parent=-1):# どこからきたかの情報を入れとく
    for to in es[v]:
        if to == parent: continue # 今回はcontinue

        ans[to] += ans[v]
        dfs(to, v)


for p, x in px:
    ans[p-1] += x

dfs(0)

print(*ans, sep=' ')

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

tree_dict = {}
for i in range(n-1):
    a, b = map(int, input().split())
    if tree_dict.get(a) == None:
        tree_dict[a] = {}
    tree_dict[a][len(tree_dict[a])] = b

ans = [0]*(n+1)

def add(p_, x_,):
    for i in range(len(tree_dict[p_])):
        ans[  tree_dict[p_][i] ] += x_
        if tree_dict.get(tree_dict[p_][i]) != None:
            add(tree_dict[p_][i], x_)

p = [0]* q
x = [0]* q
for j in range(q):
    p, x = map(int, input().split())
    ans[p] += x
    if tree_dict.get(p) != None:
        add(p,x)

print(*ans[1:])
Problem p02971 (python)

Fixed submission:
import numpy as np

n = int(input())
a = [int(input()) for _ in range(n)]
na = np.array(a)
maxI = np.argmax(na)
maxA = na[maxI]
nb = np.copy(na)
nb[maxI] = 0
maxA2 = np.max(nb)
for i in range(n):
    if i != maxI:
        print(na[maxI])
    else:
       print(maxA2)

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

n = int(input())
a = [int(input()) for _ in range(n)]
na = np.array(a)
for i in range(n):
    nb = np.copy(na)
    nb[i] = 0
    print(np.max(nb))

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

n = int(input())
a = [int(input()) for _ in range(n)]
na = np.array(a)
for i in range(n):
    print(np.max(a[:i] + a[i+1:]))

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

n = int(input())
a = [int(input()) for _ in range(n)]
na = np.array
for i in range(n):
    print(np.max(a[:i] + a[i+1:]))
Problem p02975 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

sa = set(a)
sa = list(sa)

if len(sa)>3:
    print('No')
    exit()

if len(sa)==3:
    aa = sa[0]
    bb = sa[1]
    cc = sa[2]
    if a.count(aa) != n/3 or a.count(bb) != n/3 or a.count(cc) != n/3:
        print('No')
        exit()
    if aa^bb^cc!=0:
        print('No')
        exit()

if len(sa)==2:
    aa = sa[0]
    bb = sa[1]
    if bb != 0 and aa != 0:
        print('No')
        exit()
    else:
        if aa==0:
            aa = bb
    if a.count(0) != n/3 or a.count(aa)!=n/3*2:
        print('No')
        exit()

if len(sa)==1:
    aa = sa[0]
    if aa != 0:
        print('No')
        exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

sa = set(a)
sa = list(sa)

if len(sa)>3:
    print('No')
    exit()

if len(sa)==3:
    aa = sa[0]
    bb = sa[1]
    cc = sa[2]
    if a.count(aa) != n/3 or a.count(bb) != n/3 or a.count(cc) != n/3:
        print('No')
        exit()
    if aa^bb^cc!=0:
        print('No')
        exit()

if len(sa)==2:
    aa = sa[0]
    bb = sa[1]
    if bb != 0 and aa != 0:
        print('No')
        exit()
    else:
        if bb ==0:
            zero =bb
        else:
            aa = bb
    if a.count(zero) != n/3 or a.count(aa)!=n/3*2:
        print('No')
        exit()

if len(sa)==1:
    aa = sa[0]

    if aa != 0:
        print('No')
        exit()

print('Yes')
Problem p02999 (python)

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

if X < A:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
N,X=map(int, input().split()) 
L=list(map(int, input().split())) 
D = 0
for i in range(N):
  D = D + L[i]
  print(L[i])
  if D > X:
    print(i+1)
    break
  if D == X:
    print(i+2)
    break

Buggy submission (verdict: Runtime Error):
N,X=map(int, input().split()) 
L=list(map(int, input().split())) 
D = 0
for i in range(N+1):
  D = D + L[i]
  if D > X:
    print(i+1)
    break
Problem p03006 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

x = [0]*n
y = [0]*n
for i in range(n):
    xx,yy= map(int, input().split())
    x[i] = xx-1
    y[i] = yy-1

if n==1:
    print(1)
    exit()

from collections import defaultdict
d = defaultdict(lambda:0)

for i in range(n):
    for j in range(n):
        if i==j:continue

        p = x[j]-x[i]
        q = y[j]-y[i]

        d[p*10**9+q] +=1

dv = d.values()
mad =max(dv)

print(n-mad)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

x = [0]*n
y = [0]*n
for i in range(n):
    xx,yy= map(int, input().split())
    x[i] = xx-1
    y[i] = yy-1

from collections import defaultdict
d = defaultdict(lambda:0)

for i in range(n):
    for j in range(n):
        if i==j:continue

        p = x[j]-x[i]
        q = y[j]-y[i]

        d[p*10**9+q] +=1

dv = d.values()
mad =max(dv)

print(n-mad)
Problem p03079 (python)

Fixed submission:
a, b, c=map(int, input().split()) 
if a == b == c:
   print("Yes")
else:
   print("No")

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s=list(input())
g = [1] * (N + 2)
for i in range(Q):
    Point, RL = input().split()
    for j in range(len(s)):
        if Point == s[j]:
            if RL=="L":
                g[j] = g[j] + g[j+1]
                g[j+1] = 0
            else:
                g[j+2] = g[j+2] + g[j+1]
                g[j+1] = 0
            g[0] = 0
            g[N+1] = 0
print(sum(g))
Problem p03151 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))
d = [0]*n

for i in range(n):
    d[i] = a[i]-b[i]

d.sort()

if sum(d)<0:
    print(-1)
    exit()

cnt_neg = 0
for i in range(n):
    if d[i]<0:cnt_neg+=1

if cnt_neg==0:
    print(0)
    exit()
else:
    ans = cnt_neg

last=n-1
for neg in range(n):
    if d[neg]>=0:break

    while d[neg]<0:
        tmp = min(-d[neg], d[last])
        d[neg] += tmp
        d[last] -= tmp
        if d[last] == 0:
            last-=1
            ans+=1

if d[last] != a[last]-b[last] and d[last]!=0 : ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))
b = list( map(int, input().split()))
d = [0]*n

for i in range(n):
    d[i] = a[i]-b[i]

d.sort()

if sum(d)<0:
    print(-1)
    exit()

cnt_neg = 0
for i in range(n):
    if d[i]<0:cnt_neg+=1

if cnt_neg==0:
    print(0)
    exit()
else:
    ans = cnt_neg

last=n-1
for neg in range(n):
    print(d)
    if d[neg]>=0:break

    while d[neg]<0:
        tmp = min(-d[neg], d[last])
        d[neg] += tmp
        d[last] -= tmp
        if d[last] == 0:
            last-=1
            ans+=1

if d[last] != a[last]-b[last] and d[last]!=0 : ans+=1

print(ans)
Problem p03166 (python)

Fixed submission:
import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
N, M = [int(_) for _ in input().split()]

# 隣接関係は隣接リストで管理する
lst_edge = [[] for _ in range(N)]

for _ in range(M):
  x, y = map(int, input().split()) 
  # 最初のindexをゼロにする
  lst_edge[x-1].append(y-1)
        
# dp[v] := ノードvを始点とした時の有向パスの長さの最大値
# -1 未訪問で初期化。
dp = [-1] * N

# メモ化再帰
def rec(v):
  # 既に更新済み
  if dp[v] != -1:
    return dp[v]
  ans = 0
  lst_nv = lst_edge[v]
  for nv in lst_nv:
    ans = max(ans, rec(nv) + 1)
  dp[v] = ans
  return dp[v]
    
# 全ての点に対して更新する
ans = 0
for v in range(N):
  ans = max(ans, rec(v))
    
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [tuple(map(int,input().split())) for i in range(m)]
es = [[] for i in range(n)]
for i, (a,b) in enumerate(ab):
    a,b = a-1,b-1
    es[a].append(b)

dp = [-1]*n

def rec(start):
    if dp[start] != -1:
        return dp[start]
    ans = 0
    for next_node in es[start]:
        ans = max(ans, rec(next_node)+1 )
    dp[start] = ans

    return dp[start]

ans = 0
for i in range(n):
    ans = max(ans, rec(i))

print(ans)
Problem p03196 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

from collections import Counter;
def prime_factorize(n):
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m += 1
    if n > 1:
        d[n] += 1
    return d

soinsu = prime_factorize(p)

ans =1
for k,v in soinsu.items():
    if v>=n:
        ans *= k**(v//n)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

def divisors(n): #sortはしてない
    ret = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            ret.add(m)
            ret.add(n//m)
        m += 1
    return ret

ndivs = list(divisors(p))
ndivs.sort()

ma = int(pow(p,1/n)) #でかい値の時はずれるので，適当に値を足した方がいい

from bisect import bisect_right
index = bisect_right(ndivs, ma)

if index < len(ndivs)-1: index+=1

for i in reversed(range(index)):
    if p%(pow(ndivs[i],n))==0:
        print(ndivs[i])
        exit()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, p = map(int, input().split())

def divisors(n): #sortはしてない
    ret = set()
    m = 1
    while m*m <= n:
        if n%m==0:
            ret.add(m)
            ret.add(n//m)
        m += 1
    return ret

ndivs = list(divisors(p))
ndivs.sort()

ma = int(pow(p,1/n)) #でかい値の時はずれるので，適当に値を足した方がいい
ma +=1

from bisect import bisect_right
index = bisect_right(ndivs, ma)

for i in reversed(range(index)):
    if p%(pow(ndivs[i],n))==0:
        print(ndivs[i])
        exit()
Problem p03229 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list(int(input()) for i in range(n))

a.sort()
if n%2==0:
    start = n//2-1
    left = 0
    right = n-1
    ans0 = abs(a[right]- a[start])
    while start != left:
        ans0+=abs(a[left]-a[right])
        right -= 1
        ans0+=abs(a[right]-a[left])
        left += 1

    start = n//2
    left = 0
    right = n-1
    ans1 = abs(a[left]- a[start])
    while start != right:
        ans1+=abs(a[right]-a[left])
        left += 1
        ans1+=abs(a[left]-a[right])
        right -= 1

    ans = max(ans0,ans1)
    print(ans)

if n%2==1:
    start = n//2
    left = 0
    right = n-1
    ans0 = abs(a[right]- a[start])
    while True:
        ans0+=abs(a[left]-a[right])
        right -= 1
        if start == right: break
        ans0+=abs(a[right]-a[left])
        left += 1


    left = 0
    right = n-1
    ans1 = abs(a[left]- a[start])
    while True:
        ans1+=abs(a[right]-a[left])
        left += 1
        if start == left: break
        ans1+=abs(a[left]-a[right])
        right -= 1

    ans = max(ans0,ans1)
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list(int(input()) for i in range(n))

a.sort()
if n%2==0:
    start = n//2-1
    left = 0
    right = n-1
    ans = abs(a[right]- a[start])
    while start != left:
        ans+=abs(a[left]-a[right])
        right -= 1
        ans+=abs(a[right]-a[left])
        left += 1

    print(ans)

if n%2==1:
    start = n//2
    left = 0
    right = n-1
    
    ans0 = abs(a[right]- a[start])
    while True:
        ans0+=abs(a[left]-a[right])
        right -= 1
        if start == right: break
        ans0+=abs(a[right]-a[left])
        left += 1
        
    ans1 = abs(a[left]- a[start])
    while True:
        ans1+=abs(a[right]-a[left])
        right -= 1
        if start == right: break
        ans1+=abs(a[left]-a[right])
        left += 1

    ans = max(ans0,ans1)
    print(ans)
Problem p03231 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

from fractions import gcd

gcdnm = gcd(n, m)
L = (n * m) // gcdnm

gcdd = gcd(L//n, L//m)
l = (L//n *L//m) // gcdd


if s[0]!=t[0]:
    print(-1)
    exit()

i = 1


while l//(L//n)*i < n and l//(L//m)*i <m:
    if s[l//(L//n)*i] != t[l//(L//m)*i]:
        print(-1)
        exit()
    i+=1

print(L)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

import math

gcdnm = math.gcd(n, m)
L = (n * m) // gcdnm

gcdd = math.gcd(L//n, L//m)
l = (L//n *L//m) // gcdd


if s[0]!=t[0]:
    print(-1)
    exit()

i = 1


while l//(L//n)*i < n and l//(L//m)*i <m:
    if s[l//(L//n)*i] != t[l//(L//m)*i]:
        print(-1)
        exit()
    i+=1

print(L)
Problem p03240 (python)

Fixed submission:
n = int(input())
xyh = [tuple(map(int,input().split())) for i in range(n)]

candidates =[]

for cx in range(101):
    for cy in range(101):
        ch = None
        for x,y,h in xyh:
            if h == 0:

                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                break

        else:
            xyh_c = (cx, cy, ch)
            candidates.append(xyh_c)

for xyh_c in candidates:
    cx, cy, ch = xyh_c
    for x,y,h in xyh:
        if h != max(ch - abs(x-cx) - abs(y-cy) ,0):
            break
    else:
        print(cx, cy, ch)
        exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh = [tuple(map(int,input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        ch = None
        okflag = True
        for x,y,h in xyh:
            if h == 0 or okflag == False:
                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                    okflag = False
                    break

        if okflag == True:
            xyh_c = (cx, cy, ch)
            candidates.append(xyh_c)

okflag = True
for xyh_c in candidates:
    cx, cy, ch = xyh_c
    for x,y,h in xyh:
        if h != max(ch - abs(x-cx) - abs(y-cy) ,0):
            okflag = False
            break

    if okflag == True:
        print(cx, cy, ch)
        exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh = [tuple(map(int,input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        ch = None
        okflag = True
        for x,y,h in xyh:
            if h == 0:
                if ch > abs(x-cx) + abs(y-cy):
                    okflag = False
                    break
                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                okflag = False
                break

        if okflag == True:
            print(cx, cy, ch)
            exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh = [tuple(map(int,input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        ch = None
        okflag = True
        for x,y,h in xyh:
            if h == 0:
                if ch <= abs(x-cx) + abs(y-cy):
                    okflag = False
                    break
                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                okflag = False
                break

        if okflag == True:
            print(cx, cy, ch)
            exit()