qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import math, sys
n = int(input())
xyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))

for i in range(100 + 1):
    for j in range(100 + 1):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if h > 100:
            continue
        ok = True
        for k in range(1, len(xyh)):
            if xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j) != h:
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)


Fixed code:
import sys
n = int(input())
xyh = []
fxyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))
    if xyh[-1][2]:
        fxyh = xyh[-1]


for i in range(100 + 1):
    for j in range(100 + 1):
        h = fxyh[2] + abs(fxyh[0] - i) + abs(fxyh[1] - j)
        if 1 > h:
            continue
        ok = True
        for k in range(n):
            if xyh[k][2] != max(0, h - abs(xyh[k][0] - i) - abs(xyh[k][1] - j)):
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)
Buggy code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    points = sorted(
        [[int(i) for i in input().split()] for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    print(points)
    hoge = 101
    for cx in range(hoge):
        for cy in range(hoge):
            x, y, z = points[0]
            h = max(z + abs(x - cx) + abs(y - cy), 0)
            # print(h, [max(z + abs(x - cx) + abs(y - cy), 0) for x, y, z in points])
            if h == 0:
                continue
            if all(
                [h == max(z + abs(x - cx) + abs(y - cy), 0) for x, y, z in points[1:]]
            ):
                print(cx, cy, h)
                break


if __name__ == "__main__":
    main()


Fixed code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    points = sorted(
        [[int(i) for i in input().split()] for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    hoge = 101
    for cx in range(hoge):
        for cy in range(hoge):
            x, y, z = points[0]
            h = z + abs(x - cx) + abs(y - cy)

            if h < 1:
                continue
            if all([z == max(h - abs(x - cx) - abs(y - cy), 0) for x, y, z in points]):
                print(cx, cy, h)
                return


if __name__ == "__main__":
    main()
Buggy code:
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
A.sort(reverse = True, key = lambda x: x[2])

for i in range(n):
    for j in range(n):
        px, py, ph = A[0]
        H = ph + abs(px - i) +abs(py - j)
        if all(h == max(H - abs(x - i) - abs(y - j) , 0) for x, y, h in A):
            print(i, j, H)

Fixed code:
n = int(input())
xyh = [[int(i) for i in input().split()] for i in range(n)]
xyh.sort(reverse=True, key=lambda x:x[2])

for i in range(101):
    for j in range(101):
        px, py, ph = xyh[0]
        H = ph + abs(px - i) + abs(py - j)
        if all(h == max(H - abs(x - i) - abs(y - j), 0) for x, y, h in xyh):
            print(i, j, H)
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)
print(xyh)

for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            #print(cx, cy, i, hh)
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) <= hres:
                ok = -1
                break
    if ok == 0:
        break
print(cx, cy, hres)

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)
#print(xyh)

for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            #print(cx, cy, i, hh)
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) < hres:
                ok = -1
                break
    if ok == 0:
        print(cx, cy, hres)
        break
Buggy code:
n = int(input())
a = []
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for x in range(101):
	for y in range(101):
		h = a[n - 1][0] + abs(x - a[0][2]) + abs(y - a[0][1])
		for k in range(n):
			d = h - abs(x - a[k][2]) - abs(y - a[k][1])
			if a[k][0] != max(d, 0):
				break
			if k == n - 1:
				print(x, y, h)
				exit()

Fixed code:
n = int(input())
a = []
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for x in range(101):
	for y in range(101):
		h = a[n - 1][0] + abs(x - a[n - 1][2]) + abs(y - a[n - 1][1])
		for k in range(n):
			d = h - abs(x - a[k][2]) - abs(y - a[k][1])
			if a[k][0] != max(d, 0):
				break
			if k == n - 1:
				print(x, y, h)
				exit()
Buggy code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del now
      else:
        cnt += 1
  step += 1
  if step == n:
    print('TLE')
print(' '.join(list(map(str,can[0]))))

Fixed code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] > abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
print(' '.join(list(map(str,can[0]))))
Buggy code:

Copy
Copy
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

Fixed code:

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))
Buggy code:
n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(n):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
            if zero_p <= 0:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
print(ans)

Fixed code:
n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(len(s_list)):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            if len(zero_list) > 0:
                zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
                if zero_p <= 0:
                    ttt = h + abs(x_ - x) + abs(y_ - y)
                    ans = str(x) + " " + str(y) + " " + str(ttt)
                    break
            else:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
                
print(ans)
Buggy code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
kk = h.index(max(h))
for i in range(101):
    for j in range(101):
        H = h[kk] + abs(x[k] - i) + abs(y[k] - j)
        for k in range(n):
            if h[k] > 0:
                if H != abs(x[k]-i)+abs(y[k]-j)+h[k]:
                    H = -1
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    H = -1
        if H != -1:
            print(i, j, H)

Fixed code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
kk = h.index(max(h))
for i in range(101):
    for j in range(101):
        H = h[kk] + abs(x[kk] - i) + abs(y[kk] - j)
        for k in range(n):
            if h[k] > 0:
                if H != abs(x[k]-i)+abs(y[k]-j)+h[k]:
                    H = -1
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    H = -1
        if H != -1:
            print(i, j, H)
Buggy code:
N = int(input())

XYHA = []

for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    XYHA.append([x,y,h])

for i in range(101):
    for j in range(101):
        HC = XYHA[0][2] + abs(XYHA[0][0] - i) + abs(XYHA[0][1] - j)

        for k in range(1, N):
            H = XYHA[k][2] + (XYHA[k][0] - i) + abs(XYHA[k][1] - j)

            if HC != H:
                break

            if k == N - 1:
                print(i,j,HC)
                exit()
print(0,0,0)

Fixed code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        continue
    XYHA.append([x,y,h])

for i in range(101):
    for j in range(101):
        HC = XYHA[0][2] + abs(XYHA[0][0] - i) + abs(XYHA[0][1] - j)
        for k in range(1, len(XYHA)):

            H = XYHA[k][2] + abs(XYHA[k][0] - i) + abs(XYHA[k][1] - j)

            if HC != H:
                break
            elif k == len(XYHA) - 1:
                print(i,j,HC)
                exit()

print(XYHA[0][0],XYHA[0][1],XYHA[0][2])
Buggy code:
# -*- coding: utf-8 -*-
import numpy as np
from operator import itemgetter
def solve():
    Z = sorted([tuple(map(int,input().split())) for _ in range(int(input()))], key=itemgetter(2) , reverse=True)
    x0, y0, h0 = Z[0]
    H = h0 + np.abs(np.arange(101, dtype=int).reshape(1,101)-x0) + np.abs(np.arange(101, dtype=int).reshape(101,1)-y0)
    return [' '.join(map(str, [i,j,h])) for (i,j),h in np.ndenumerate(H) if all(h == max(H[i,j]-abs(x-i)-abs(y-j),0) for x,y,h in Z)][0]

if __name__ == '__main__':
    print(solve())

Fixed code:
# -*- coding: utf-8 -*-
import numpy as np
from operator import itemgetter
def solve():
    Z = sorted([tuple(map(int,input().split())) for _ in range(int(input()))], key=itemgetter(2,0,1) , reverse=True)
    x0, y0, h0 = Z[0]
    H = h0 + np.abs(np.arange(101, dtype=int).reshape(101,1)-x0) + np.abs(np.arange(101, dtype=int).reshape(1,101)-y0)
    for (i,j), h in np.ndenumerate(H):
        if all(h == max(H[i,j]-abs(x-i)-abs(y-j), 0) for x,y,h in Z):
            return ' '.join(map(str, [i,j,h]))

if __name__ == '__main__':
    print(solve())
Buggy code:
N = int(input())
cordinate = [list(map(int, input().split())) for i in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        for k in cordinate:
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                print(i, j, H, tmp)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1 and H > 0:
            print(i, j , H)
            exit()

Fixed code:
N = int(input())
cordinate = [list(map(int, input().split())) for i in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                check = 1
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for x in zero_height:
                if H > abs(x[0] - i) + abs(x[1] - j):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()
Buggy code:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]
print(xyh)

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        print(height)
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

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

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()
Buggy code:
import sys

N = int(input())
H = [list(map(int, input().split())) for i in range(N)]

H.sort(key=lambda x: x[2], reverse=True)

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if Height[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()

Fixed code:
import sys

N = int(input())
H = [list(map(int, input().split())) for i in range(N)]

H.sort(key=lambda x: x[2], reverse=True)

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if H[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()
Buggy code:
N = int(input())

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

xyhs.sort(key=lambda x:x[2], reverse = True)
for cx in range(101):
	for cy in range(101):
		H = h + abs(x - cx) + abs(y - cy)
				
		for xyh in xyhs[1:]:
			x, y, h = xyh

			if h == 0:
				if H > abs(x - cx) + abs(y - cy):
					break
			else:
				if H != h + abs(x - cx) + abs(y - cy):
					break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()


Fixed code:
N = int(input())

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

xyhs.sort(key=lambda x:x[2], reverse = True)

for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)
				
		for xyh in xyhs[1:]:
			x, y, h = xyh

			if h == 0:
				if H > abs(x - cx) + abs(y - cy):
					break
			else:
				if H != h + abs(x - cx) + abs(y - cy):
					break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()
Buggy code:
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

t = []

for x in range(101):
    for y in range(101):
        H = []
        for i in array:
            if i[2] > 0:
                H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            t.append([x,y,H])

if len(t) >=2:
    x = 15/0
            
print("{0[0]} {0[1]} {0[2]}".format(t))


Fixed code:
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

t = []

for x in range(101):
    for y in range(101):
        H = []
        for i in array:
            if i[2] > 0:
                H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            t.append([x,y,H])

if len(t) >= 2:
    t = []
    for x in range(101):
        for y in range(101):
            H = []
            for i in array:
                if True:
                    H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                    H.append(H_i)
            Hset = set(H)
            H = list(Hset)[0]
            if(len(Hset)==1 and H>=0):
                t.append([x,y,H])
            
print("{0[0]} {0[1]} {0[2]}".format(t[0]))
Buggy code:
N = int(input())

xyh = []
for i in range(N):
    xyh.append(list(map(int,input().split())))

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
flag = True
for cy in range(101):
    for cx in range(101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0)
            if h2 != xyh[i][2]:
                flag = False
        if flag:
            answer = [cx, cy, H]
            break

print(answer)

Fixed code:
N = int(input())

xyh = []
for i in range(N):
    xyh.append(list(map(int,input().split())))

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
for cy in range(0, 101):
    for cx in range(0, 101):
        H = xyh_sorted[0][2] + abs(xyh_sorted[0][0] - cx) + abs(xyh_sorted[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh_sorted[i][0] - cx) - abs(xyh_sorted[i][1] - cy), 0)
            if h2 != xyh_sorted[i][2]:
                flag = False
                break
        if flag:
            answer = [cx, cy, H]
            break
    if flag:
        break

answerString = str(answer[0]) + " " + str(answer[1]) + " " + str(answer[2])
print(answerString)
Buggy code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:x[2],reverse=True)
sx,sy,sh=l[0]
for xx in range(0,101):
  for yy in range(0,101):
    hh=sh+abs(sx-xx)+abs(sy-yy)
    for ll in l[1:]:
      if ll[2]!=hh-abs(sx-xx)-abs(sy-yy):
        break
    else:
      print(xx,yy,hh)
    

Fixed code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:x[2],reverse=True)
sx,sy,sh=l[0]
for xx in range(0,101):
  for yy in range(0,101):
    hh=sh+abs(sx-xx)+abs(sy-yy)
    for ll in l[1:]:
      if ll[2]!=max(0,hh-abs(ll[0]-xx)-abs(ll[1]-yy)):
        break
    else:
      print(xx,yy,hh)
Buggy code:
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N
for i in range(N):
    x[i],y[i],h[i] = map(int,input().split())
    
import sys

for cx in range(1,101):
    for cy in range(1,101):
        H = [0]*N
        for i in range(N):
            H[i] = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
        if max(H) == min(H):
            print(cx,cy,max(H))
            sys.exit()

Fixed code:
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N
for i in range(N):
    x[i],y[i],h[i] = map(int,input().split())

import sys

for cx in range(0,101):
    for cy in range(0,101):
        H = [0]*N
        for i in range(N):
            H[i] = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
        for i in range(N):
            if h[i] == 0:
                H[i] = min(H)
        if max(H) == min(H):
            print(cx,cy,max(H))
            sys.exit()
Buggy code:
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for cx in range(1,101):
  for cy in range(1,101):
    x0,y0,h0=xyh[0]
    H=h0+abs(x0-cx)+abs(y0-cy)
    flag=True
    for x,y,h in xyh:
      if H!=h+abs(x-cx)+abs(y-cy):
        flag=False
    if flag:
      print(cx,cy,H)
      exit()

Fixed code:
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for cx in range(0,101):
  for cy in range(0,101):
    x0,y0,h0=xyh[0]
    H=h0+abs(x0-cx)+abs(y0-cy)
    if H==0:
      continue
    flag=True
    for x,y,h in xyh:
      if h!=max(H-abs(x-cx)-abs(y-cy),0):
        flag=False
    if flag:
      print(cx,cy,H)
      exit()
Buggy code:
N = int(input())
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))
H = 0
h = 0
flag = False
maxz = xyz[0][2]
maxy = xyz[0][1]
maxx = xyz[0][0]
for k in range(N):
    if xyz[k][2] > maxz:
        maxz = xyz[k][2]
        maxx = xyz[k][0]
        maxy = xyz[k][1]
for i in range(101):
    for j in range(101):
        H = maxz + abs(maxx-i) + abs(maxy-j)
        for k in xyz:
            h = H -abs(k[0]-i)-abs(k[1]-j)
            if h < 0:
                h = 0
            if h == k[2]:
                continue
            else:
                break
        if H != 0:
                flag = True
                print("{} {} {}".format(i, j, H))
                break
    if flag:
        break


Fixed code:
N = int(input())
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))
H = 0
h = 0
flag = False
maxz = xyz[0][2]
maxy = xyz[0][1]
maxx = xyz[0][0]
for k in range(N):
    if xyz[k][2] > maxz:
        maxz = xyz[k][2]
        maxx = xyz[k][0]
        maxy = xyz[k][1]
for i in range(101):
    for j in range(101):
        H = maxz + abs(maxx-i) + abs(maxy-j)
        for k in xyz:
            h = H -abs(k[0]-i)-abs(k[1]-j)
            if h < 0:
                h = 0
            if h == k[2]:
                continue
            else:
                break
        else:
            if H != 0:
                flag = True
                print("{} {} {}".format(i, j, H))
                break
    if flag:
        break