qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
xx = [0] * n
yy = [0] * n
hh = [0] * n
for i in range(n):
    x, y, h = map(int, input().split())
    xx[i], yy[i], hh[i] = x, y, h
    if h > 0:
        x0, y0, h0 = x, y, h

for cx in range(101):
    for cy in range(101):
        f = True
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        for i in range(1, n):
            if hh[i] != max(h - abs(xx[i] - cx) - abs(yy[i] - cy), 0):
                f = False
                break
        if f:
            print("{} {} {}".format(cx, cy, h))
            exit(0)


Fixed code:
n = int(input())
xx = [0] * n
yy = [0] * n
hh = [0] * n
for i in range(n):
    x, y, h = map(int, input().split())
    xx[i], yy[i], hh[i] = x, y, h
    if h > 0:
        x0, y0, h0 = x, y, h

for cx in range(101):
    for cy in range(101):
        f = True
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        for i in range(n):
            if hh[i] != max(h - abs(xx[i] - cx) - abs(yy[i] - cy), 0):
                f = False
                break
        if f:
            print("{} {} {}".format(cx, cy, h))
            exit(0)
Buggy code:
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort(key=lambda x: x[2], reverse=True)
for c_x in range(100):
    for c_y in range(100):
        H = -1
        H_upper = 10**9
        for i, v in enumerate(A):
            if v[2] == 0:
                H_upper = min(H_upper, abs(c_x - v[0]) + abs(c_y - v[1]))
                if H_upper < H:
                    break
            else:
                tmp_H = abs(c_x - v[0]) + abs(c_y - v[1]) + v[2]
                if H == -1:
                    H = tmp_H
                elif H != tmp_H:
                    break
            if i == N-1:
                print(c_x, c_y, H)


Fixed code:
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort(key=lambda x: x[2], reverse=True)
for c_x in range(101):
    for c_y in range(101):
        H = -1
        H_upper = 10**9
        for i, v in enumerate(A):
            if v[2] == 0:
                H_upper = min(H_upper, abs(c_x - v[0]) + abs(c_y - v[1]))
                if H_upper < H:
                    break
            else:
                tmp_H = abs(c_x - v[0]) + abs(c_y - v[1]) + v[2]
                if H == -1:
                    H = tmp_H
                elif H != tmp_H:
                    break
            if i == N-1:
                if H == -1:
                    print(c_x, c_y, H_upper)
                else:
                    print(c_x, c_y, H)
Buggy code:
N = int(input())
XYH = []
for i in range(N):
    tmp = list(map(int, input().split()))
    if tmp[2] == 0:
        continue
    XYH.append(tmp)

def calc(XYH):
    tmp = 0
    res = [0,0,0]
    for tarx in range(101):
        for tary in range(101):
            xyh = XYH[0]
            tarh = xyh[2] + abs(xyh[0] - tarx) + abs(xyh[1] - tary)
            if all(h==max(h - abs(tarx - x) - abs(tary - y), 0) for x, y, h in XYH):
                print(" ".join(x,y,h))
                return
    
calc(XYH)

Fixed code:
N = int(input())
XYH = []
for i in range(N):
    tmp = list(map(int, input().split()))
    if tmp[2] != 0:
        xyh = tmp
    XYH.append(tmp)

def calc(XYH, xyh):
    for tarx in range(101):
        for tary in range(101):
            tarh = xyh[2] + abs(xyh[0] - tarx) + abs(xyh[1] - tary)
            if all(h==max(tarh - abs(tarx - x) - abs(tary - y), 0) for x, y, h in XYH):
                return list(map(str, [tarx, tary, tarh]))
    
print(" ".join(calc(XYH, xyh)))
Buggy code:
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    xs = list()
    ys = list()
    hs = list()

    # See:
    # https://beta.atcoder.jp/contests/abc112/submissions/3360331
    # https://img.atcoder.jp/abc112/editorial.pdf
    # https://www.youtube.com/watch?v=CURWJ1Dr44A
    for i in range(n):
        xi, yi, hi = map(int, input().split())
        xs.append(xi)
        ys.append(yi)
        hs.append(hi)

        if hi >= 1:
            pos = i

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            is_consistent = True
            candidate_height = abs(xs[pos] - cx) + abs(ys[pos] - cy) + hs[pos]

            for i in range(n):
                each_height = max(abs(xs[i] - cx) + abs(ys[i] - cy) + hs[i], 0)

                if candidate_height != each_height:
                    global is_consistent
                    is_consistent = False
                    break

            if is_consistent:
                print(cx, cy, candidate_height)
                exit()


if __name__ == '__main__':
    main()


Fixed code:
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    xs = list()
    ys = list()
    hs = list()

    # See:
    # https://beta.atcoder.jp/contests/abc112/submissions/3360331
    # https://img.atcoder.jp/abc112/editorial.pdf
    # https://www.youtube.com/watch?v=CURWJ1Dr44A
    for i in range(n):
        xi, yi, hi = map(int, input().split())
        xs.append(xi)
        ys.append(yi)
        hs.append(hi)

        # Record a position satisfying the task conditions.
        if hi > 0:
            pos = i

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            is_consistent = True
            candidate_height = abs(xs[pos] - cx) + abs(ys[pos] - cy) + hs[pos]

            for i in range(n):
                each_height = max(candidate_height - abs(xs[i] - cx) - abs(ys[i] - cy), 0)

                if hs[i] != each_height:
                    is_consistent = False
                    break

            if is_consistent:
                print(cx, cy, candidate_height)
                exit()


if __name__ == '__main__':
    main()
Buggy code:
import sys
input = sys.stdin.readline

N=int(input())
xyh = sorted([ list(map(int,input().split())) for _ in range(N)],key = lambda x:-x[2])

if N==1:
    print(xyh[0],xyh[1],xyh[2])
else:
    for cx in range(1,56):
        for cy in range(101):
            flag = 0
            dx = abs(cx - xyh[0][0])
            dy = abs(cy - xyh[0][1])
            hmax = xyh[0][2]+dx+dy
            for i in range(1,N):
                if max(hmax -( abs(cx - xyh[i][0])+abs(cy - xyh[i][1])),0) !=  xyh[i][2]:
                    flag = 1
                    break
            if flag == 0:
                print(cx,cy,hmax)
                exit()

        


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

N=int(input())
xyh = sorted([ list(map(int,input().split())) for _ in range(N)],key = lambda x:-x[2])

if N==1:
    print(xyh[0],xyh[1],xyh[2])
else:
    for cx in range(101):
        for cy in range(101):
            flag = 0
            dx = abs(cx - xyh[0][0])
            dy = abs(cy - xyh[0][1])
            hmax = xyh[0][2]+dx+dy
            for i in range(1,N):
                if max(hmax -( abs(cx - xyh[i][0])+abs(cy - xyh[i][1])),0) !=  xyh[i][2]:
                    flag = 1
                    break
            if flag == 0:
                print(cx,cy,hmax)
                exit()
Buggy code:
N = int(input())
info = [list(map(int, input().split())) for _ in range(N)]

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                d.append(H)
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))
        else:
            d = list(set(d))
            if len(d) == 1 and 1 <= d[-1] and d[-1] < h_max:
                print(h_max)
                print(c_x, c_y, d[-1])
                exit()

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for m in info:
            x, y, h = m[0], m[1], m[2]
            if h > 0:
                H = f(x, y, c_x, c_y) + h
                d.append(H)
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))
        else:
            d = list(set(d))
            if len(d) == 1 and 1 <= d[-1] and d[-1] <= h_max:
                print(c_x, c_y, d[-1])
                exit()
Buggy code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

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


def solv(Xs):
    for x in range(101):
        for y in range(101):
            Cx, Cy, h = tuple(Xs)
            H = h + abs(x - Cx) + abs(y - Cy)
            for Cx, Cy, h in Xs:
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    break
            else:
                return (x, y, H)


print("%d %d %d" % solv(Xs))


Fixed code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

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


def solv(Xs):
    for x in range(101):
        for y in range(101):
            Cx, Cy, h = tuple(Xs[0])
            H = h + abs(x - Cx) + abs(y - Cy)
            for Cx, Cy, h in Xs:
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    break
            else:
                return (x, y, H)


print("%d %d %d" % solv(Xs))
Buggy code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
"""
Xs = [list(map(int, x.split(" "))) for x in input]
Xs.sort(key=lambda x:x[2], reverse=True)

for x in range(101):
    for y in range(101):
        h= Xs[0][2]
        Cx = Xs[0][0]
        Cy = Xs[0][1]
        H = h + abs(x - Cx) + abs(y - Cy)
        for i in range(len(Xs)):
            if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                break
            if i == len(Xs)-1:
                print("%d %d %d" % (x, y, H))


Fixed code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

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


def solv(Xs):
    for x in range(101):
        for y in range(101):
            h= Xs[0][2]
            Cx = Xs[0][0]
            Cy = Xs[0][1]
            H = h + abs(x - Cx) + abs(y - Cy)
            for i in range(len(Xs)):
                h = max(H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]), 0)
                if h != Xs[i][2]:
                    break
                if i == len(Xs)-1:
                    print("%d %d %d" % (x, y, H))
                    exit(0)


solv(Xs)
Buggy code:
n = int(input())
info = [tuple(map(int, input().split()))]
nonzeroinfo = []
for x, y, h in info:
    if h > 0:
        nonzeroinfo.append((x, y, h))
zeroinfo = []
for x, y, h in info:
    if h == 0:
        zeroinfo.append((x, y, h))
def checknonzero(x, y, h):
    for a, b, c in nonzeroinfo:
        if h != abs(x-a) + abs(y-b) + c:
            return False
    return True
def checkzero(x, y, h):
    for a, b, _ in zeroinfo:
        if abs(x-a) + abs(y-b) < h:
            return False
    return True
for x in range(101):
    for y in range(101):
        x1, y1, h1 = nonzeroinfo[0]
        h = abs(x-x1) + abs(y-y1) + h1
        ret1 = checknonzero(x, y, h)
        ret2 = checkzero(x, y, h)
        if ret1 and ret2:
            print(x, y, h)
            exit()

Fixed code:
n = int(input())
info = [tuple(map(int, input().split())) for _ in range(n)]
nonzeroinfo = []
for x, y, h in info:
    if h > 0:
        nonzeroinfo.append((x, y, h))
zeroinfo = []
for x, y, h in info:
    if h == 0:
        zeroinfo.append((x, y, h))
def checknonzero(x, y, h):
    for a, b, c in nonzeroinfo:
        if h != abs(x-a) + abs(y-b) + c:
            return False
    return True
def checkzero(x, y, h):
    for a, b, _ in zeroinfo:
        if abs(x-a) + abs(y-b) < h:
            return False
    return True
for x in range(101):
    for y in range(101):
        x1, y1, h1 = nonzeroinfo[0]
        h = abs(x-x1) + abs(y-y1) + h1
        ret1 = checknonzero(x, y, h)
        ret2 = checkzero(x, y, h)
        if ret1 and ret2:
            print(x, y, h)
            exit()
Buggy code:
N = int(input())

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

X.sort(key = lambda item: item[2] ,reverse = True)

for i in range(101):
    for j in range(101):
        h = X[0][2] + abs(X[0][0] - i) + abs(X[0][1] - j)
        
        ok = True
        for k in range(N):
            if X[0][2] != h - abs(X[k][0] - i) - abs(X[k][1] - j)
                ok = False
        
        if ok:
            print(i,j)
            exit()

Fixed code:

N = int(input())

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

X.sort(key = lambda item: item[2] ,reverse = True)

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

        ok = True
        for k in range(N):
            if X[k][2] != max((h - abs(X[k][0] - i) - abs(X[k][1] - j)), 0):
                ok = False

        if ok:
            print(i, j, h)
            exit()
Buggy code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
a=[]
for x in range(101):
  for y in range(101):
    c=[]
    for t in l:
      if l[2]:
        c.append(t[2]+abs(x-t[0])+abs(y-t[1]))
    f=0
    if len(set(c))==1:
      f=1
      h=c[0]
      for t in l:
        if l[2]==0:
          if h-abs(x-t[0])-abs(y-t[1])>0:
            f=0
    if f:
      print(x,y,h)
      exit()

Fixed code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
a=[]
for x in range(101):
  for y in range(101):
    c=[]
    for t in l:
      if t[2]:
        c.append(t[2]+abs(x-t[0])+abs(y-t[1]))
    f=0
    if len(set(c))==1:
      f=1
      h=c[0]
      for t in l:
        if t[2]==0:
          if h-abs(x-t[0])-abs(y-t[1])>0:
            f=0
    if f:
      print(x,y,h)
      exit()
Buggy code:
N = int(input())
p = list(list(map(int,input().split()))for _ in range(N))

for i in range(N):
    if p[i][2]:
        tmp = i
        break

for Cx in range(101):
    for Cy in range(101):
        H = p[tmp][2] + abs(Cx-p[tmp][0]) + abs(Cy-p[tmp][1])
        flag = True
        for x,y,h in p:
            if h != max(abs(Cx-x) + abs(Cy-y) + H , 0):
                flag = False
                break
        if flag:
            print(Cx,Cy,H)
    


Fixed code:
N = int(input())
p = list(list(map(int,input().split()))for _ in range(N))

for i in range(N):
    if p[i][2]:
        tmp = i
        break

for Cx in range(101):
    for Cy in range(101):
        H = p[tmp][2] + abs(Cx-p[tmp][0]) + abs(Cy-p[tmp][1])
        flag = True
        for x,y,h in p:
            if h != max(H -abs(Cx-x) - abs(Cy-y), 0):
                flag = False
                break
        if flag:
            print(Cx,Cy,H)
Buggy code:
n=int(input())
zahyo=[list(map(int,input().split())) for i in range(n)]

zahyo.sort(key=lambda x:x[2], reverse = 1)
mx,my,mh=zahyo[0]
for Cx in range(101):
    for Cy in range(101):
        H = mh+abs(mx-Cx)+abs(my-Cy)
        if all(h == max(H-abs(x-Cx)+abs(y-Cy),0) for x,y,h in zahyo):
            print(Cx,Cy,h)
            break
            

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

zahyo.sort(key=lambda x:x[2], reverse = 1)
mx,my,mh=zahyo[0]
for Cx in range(101):
    for Cy in range(101):
        H = mh+abs(mx-Cx)+abs(my-Cy)
        if all(h == max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in zahyo):
            print(Cx,Cy,H)
            break
Buggy code:
n = int(input())
x = []
y = []
h = []
ans = [0,0,0]
for i in range(n):
	xyh = list(map(int, input().split()))
	x.append(xyh[0])
	y.append(xyh[1])
	h.append(xyh[2])


for i in range(101):
	for j in range(101):
		height = abs(i-x[0]) + abs(j-y[0]) + h[0]
		flag = 0
		for k in range(n):
			if height != abs(i-x[k]) + abs(i-y[k]) + h[k]:
				flag = 1
				break
			
		if flag == 0:
			ans = [i,j,height]
			break
		
	
print('{0} {1} {2}'.format(ans[0], ans[1], ans[2]))

Fixed code:
n = int(input())
x = []
y = []
h = []
ans = [0,0,0]
for i in range(n):
	xyh = list(map(int, input().split()))
	x.append(xyh[0])
	y.append(xyh[1])
	h.append(xyh[2])

for i in range(101):
	for j in range(101):
		for k in range(n):
			if h[k] != 0:
				height = abs(i-x[k]) + abs(j-y[k]) + h[k]
				break
			
		flag = 0
		for k in range(n):
			if h[k] != max(height- abs(i-x[k]) - abs(j-y[k]) , 0):
				flag = 1
				break
			
		if flag == 0:
			ans = [i,j,height]
			break
		
	
print('{0} {1} {2}'.format(ans[0], ans[1], ans[2]))
Buggy code:
def calcCh(cx, cy, x, y, h):
    return abs(x-cx)+abs(y-cy)+h
def calcH(cx, cy, ch, x, y, h):
    return max(ch - calcCh(cx, cy, x, y, 0), 0)
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh = sorted(xyh, key = lambda x: x[2])[::-1]
lst = [[x, y] for x in range(101) for y in range(101)]
for Cx, Cy in lst:
    Ch = calcCh(Cx, Cy, *xyh[0])
    if all(Ch == calcH(Cx, Cy, Ch, *xyh[i]) for i in range(n)):
        break
print(Cx, Cy, Ch)

Fixed code:
def calcCh(cx, cy, x, y, h):
    return abs(x-cx)+abs(y-cy)+h
def calcH(cx, cy, ch, x, y, h):
    return max(ch - calcCh(cx, cy, x, y, 0), 0)
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh = sorted(xyh, key = lambda x: x[2])[::-1]
lst = [[x, y] for x in range(101) for y in range(101)]
for Cx, Cy in lst:
    Ch = calcCh(Cx, Cy, *xyh[0])
    if all(xyh[i][2] == calcH(Cx, Cy, Ch, *xyh[i]) for i in range(n)):
        break
print(Cx, Cy, Ch)
Buggy code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for w in range(n):
   if l[w][2]>0:
     k=w
     break
for x in range(101):
  for y in range(101):
    a=max(l[z][2]-(abs(l[0][0]-x)-abs(l[0][1]-y)),0)
    c=0
    for z in range(1,n):
      if max(l[z][2]-(abs(l[0][0]-x)-abs(l[0][1]-y)),0)==a:c+=1
    if c==n-1:print(x,y,l[k][2]+(abs(l[k][0]-x)+abs(l[k][1]-y))

Fixed code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for w in range(n):
   if l[w][2]>0:
     k=w
     break
for x in range(101):
  for y in range(101):
    a=l[k][2]+abs(l[k][0]-x)+abs(l[k][1]-y)
    c=0
    for z in range(n):
      if max((a-abs(l[z][0]-x)-abs(l[z][1]-y)),0)==l[z][2]:c+=1
      if c==n:
        print(x,y,a)
Buggy code:
# vim: fileencoding=utf-8


def main():

    n = int(input())
    li = []
    for i in range(n):
        x, y, h = map(int, input().split())
        li.append({"x": x, "y": y, "h": h})
    li.sort(key=lambda x: x["h"], reverse=True)

    tops = []
    for i in range(101):
        for j in range(101):
            h = li[0]["h"] + abs(li[0]["x"] - i) + abs(li[0]["y"] - j)
            tops.append({"x": i, "y": j, "h": h})

    for i in range(1, n):
        tmp = []
        for j in range(len(tops)):
            x = li[i]["x"]
            y = li[i]["y"]
            h = li[i]["h"]
            topX = tops[j]["x"]
            topY = tops[j]["y"]
            topH = tops[j]["h"]
            if h == max(topH - abs(topX - x) - abs(topY - y), 0):
                tmp.append(tops[j])
        tops = tmp
    print(list(tops[0].values()))


if __name__ == "__main__":
    main()


Fixed code:
# vim: fileencoding=utf-8


def main():

    n = int(input())
    li = []
    for i in range(n):
        x, y, h = map(int, input().split())
        li.append({"x": x, "y": y, "h": h})
    li.sort(key=lambda x: x["h"], reverse=True)

    tops = []
    for i in range(101):
        for j in range(101):
            h = li[0]["h"] + abs(li[0]["x"] - i) + abs(li[0]["y"] - j)
            tops.append({"x": i, "y": j, "h": h})

    for i in range(1, n):
        tmp = []
        for j in range(len(tops)):
            x = li[i]["x"]
            y = li[i]["y"]
            h = li[i]["h"]
            topX = tops[j]["x"]
            topY = tops[j]["y"]
            topH = tops[j]["h"]
            if h == max(topH - abs(topX - x) - abs(topY - y), 0):
                tmp.append(tops[j])
        tops = tmp
    print(f"{tops[0]['x']} {tops[0]['y']} {tops[0]['h']}")


if __name__ == "__main__":
    main()
Buggy code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        for x, y, h in lis:
            judge = True
            if h > 0 and sh + abs(sx - i) + abs(sy - j) != h + abs(x - i) + abs(y - i):
                break
            elif sh +  abs(sx - i) + abs(sy - j) > h + abs(x - i) + abs(y - j):
                break
        else:
            print(i, j, sh + abs(sx - i) + abs(sy - j))
            exit()

Fixed code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        high = sh + abs(sx - i) + abs(sy - j)
        judge = True
        for x, y, h in lis:
            if h > 0 and high != h + abs(x - i) + abs(y - j):
                judge = False
                break
            if h == 0 and high > abs(x - i) + abs(y - j):
                judge = False
                break
        if judge:
            print(i, j, sh + abs(sx - i) + abs(sy - j))
            exit()
Buggy code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

for i in range(101):
    for j in range(101):
        for k in range(n):
            x, y, h = xyh[k]
            if h:
                H = h + abs(x - i) + abs(y - j)
                break

        ans = True
        for k in range(n):
            x, y, h = xyh[k]
            if h != max(H - abs(x - i) - abs(y - i), 0):
                ans = False
                break
        if ans:
            print(i, j, H)
            exit()


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

for cx in range(101):
    for cy in range(101):
        for k in range(n):
            x, y, h = xyh[k]
            if h:
                H = h + abs(x - cx) + abs(y - cy)
                break

        ans = True
        for k in range(n):
            x, y, h = xyh[k]
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                ans = False
                break
        if ans:
            print(cx, cy, H)
            exit()
Buggy code:
def main():
    n = int(input())
    X,Y,H = [],[],[]
    xyh = [list(map(int, input().split())) for _ in range(n)]
    xyh = sorted(xyh, key=lambda x:x[2], reverse=True)
    for i in range(n):
        X.append(xyh[i][0])
        Y.append(xyh[i][1])
        H.append(xyh[i][2])

    for cx in range(101):
        for cy in range(101):
            judge = True
            h = H[0]+abs(X[0]-cx)+abs(Y[0]-cy)
            if h == 79:
                print(cx,cy)
            for i in range(n):
                if H[i] != max(h-abs(X[i]-cx)-abs(Y[i]-cy),0):
                    judge = False
                    break
            if judge:
                print(cx,cy,h)
                return


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = int(input())
    X,Y,H = [],[],[]
    xyh = [list(map(int, input().split())) for _ in range(n)]
    xyh = sorted(xyh, key=lambda x:x[2], reverse=True)
    for i in range(n):
        X.append(xyh[i][0])
        Y.append(xyh[i][1])
        H.append(xyh[i][2])

    for cx in range(101):
        for cy in range(101):
            judge = True
            h = H[0]+abs(X[0]-cx)+abs(Y[0]-cy)
            for i in range(n):
                if H[i] != max(h-abs(X[i]-cx)-abs(Y[i]-cy),0):
                    judge = False
                    break
            if judge:
                print(cx,cy,h)
                return


if __name__ == '__main__':
    main()