qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

L.sort(key=lambda x:x[2])

for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) > 0:
                    flag = 0
                    break
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)

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

L.sort(key=lambda x:x[2])

for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) > 0:
                    flag = 0
                    break
            else:

                if h == l[2] + abs(x-l[0]) + abs(y-l[1]):
                    flag = 1
                
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)
Buggy code:
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh=sorted(xyh,reverse=True,key=lambda x:x[2])
p#rint(xyh)
for cx in range(0,101):
    for cy in range(0,101):
        H = 0
        for x,y,h in xyh:
            if H == 0:
                H = h + abs(x - cx) + abs(y - cy)
            else:
                temp_H = h + abs(x - cx) + abs(y - cy)
                if temp_H != H:break
        else:
            if H>=1:
                print(cx,cy,H)
                exit()


Fixed code:
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh=sorted(xyh,reverse=True,key=lambda x:x[2])
#print(xyh)
for cx in range(0,101):
    for cy in range(0,101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1]-cy)
        for x,y,h in xyh:
            if h!= max(H - abs(x - cx) - abs(y - cy),0):
                break

        else:
            if H>=1:
                print(cx,cy,H)
                exit()
Buggy code:


import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()

values=[getints() for _ in range(n)]

check = []
for h in values:
    if h[2] > 0:
        check = h
        break

check_x, check_y, check_h = check

for cx in range(101):
    for cy in range(101):
        H = check_h + abs(check_x - cx) + abs(check_y - cy)
        ok = True
        for x,y,h in values:
            h_prime = max(0, H - abs(x-cx) - abs(y-cy))
            if h_prime != h:
                ok = False
                break
        if ok:
            print(cx,cy,h)
            sys.exit(0)


Fixed code:


import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()

values=[getints() for _ in range(n)]

check = []
for h in values:
    if h[2] > 0:
        check = h
        break

check_x, check_y, check_h = check

for cx in range(101):
    for cy in range(101):
        H = check_h + abs(check_x - cx) + abs(check_y - cy)
        ok = True
        for x,y,h in values:
            h_prime = max(0, H - abs(x-cx) - abs(y-cy))
            if h_prime != h:
                ok = False
                break
        if ok:
            print(cx,cy,H)
            sys.exit(0)
Buggy code:
n = int(input())
P = []
for _ in range(n):
  x, y, h = map(int, input().split())
  P.append([h, x, y])
P.sort(reverse=True)

for cx in range(101):
  for cy in range(101):
    H = P[0][0] + abs(P[0][1]-cx) + abs(P[0][2]-cy)
    for i in range(1,n):
      if max(H-abs(P[i][1]-cx)-abs(P[i][2]-cy), 0) != P[0][0]:
        break
    else:
      print(cx, cy, H)
      exit()

Fixed code:
n = int(input())
P = []
for _ in range(n):
  x, y, h = map(int, input().split())
  P.append([h, x, y])
P.sort(reverse=True)

for cx in range(101):
  for cy in range(101):
    H = P[0][0] + abs(P[0][1]-cx) + abs(P[0][2]-cy)
    for i in range(1,n):
      if max(H-abs(P[i][1]-cx)-abs(P[i][2]-cy), 0) != P[i][0]:
        break
    else:
      print(cx, cy, H)
      exit()
Buggy code:
N = int(input())
x = [None]*N
y = [None]*N
h = [None]*N

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

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        else:
            if H-abs(X-x[n])-abs(Y-y[n])>0:
            return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            H = height(X,Y,x[n],y[n],h[n])
            if check(x,y,h,X,Y,H) is True:
                print(X,Y,H)
                exit()


Fixed code:
N = int(input())
x = [None]*N
y = [None]*N
h = [None]*N

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

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        elif H-abs(X-x[n])-abs(Y-y[n])>0:
            return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            if h[n]>0:
                H = height(X,Y,x[n],y[n],h[n])
                if check(x,y,h,X,Y,H) is True:
                    print(X,Y,H)
                    exit()
Buggy code:
N = int(input())
X, Y, H = zip(*[tuple(map(int, input().split(" "))) for _ in range(N)])

for i in range(N):
	if H[i] <= 0:
		continue
	std = i
	break
# print(X[std], Y[std])
for cy in range(101):
	for cx in range(101):
		ch = H[std] + abs(cx-X[std]) + abs(cy-Y[std])
		flag = True
		for i in range(N):
			if min(0, ch - abs(cx-X[i]) - abs(cy-Y[i])) != H[i]:
				flag = False
				# break
			print(ch, cx, cy, X[i], Y[i], ch - abs(cx-X[i]) - abs(cy-Y[i]), H[i])
		if flag:
			print(cx, cy, ch)
			exit()

Fixed code:
N = int(input())
X, Y, H = zip(*[tuple(map(int, input().split(" "))) for _ in range(N)])

for i in range(N):
	if H[i] <= 0:
		continue
	std = i
	break
# print(X[std], Y[std])
for cy in range(101):
	for cx in range(101):
		ch = H[std] + abs(cx-X[std]) + abs(cy-Y[std])
		flag = True
		for i in range(N):
			if max(0, ch - abs(cx-X[i]) - abs(cy-Y[i])) != H[i]:
				flag = False
				# break
			# print(ch, cx, cy, X[i], Y[i], ch - abs(cx-X[i]) - abs(cy-Y[i]), H[i])
		if flag:
			print(cx, cy, ch)
			exit()
Buggy code:
N = int(input())
xyh=[]
for _ in range(N):
    xyh.append(tuple(map(int, input().split())))

def func():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh if el[2]!=0]
            if H>=1 and len(set(H))==1:
                temp=[H[0]-abs(el[0]-Cx)-abs(el[0]-Cy) for el in xyh if el[2]==0]
                for el in temp:
                    if el>0:
                        break
                else:
                    print(Cx, Cy, H[0])
                    return None
func()


Fixed code:
N = int(input())
xyh=[]
for _ in range(N):
    xyh.append(tuple(map(int, input().split())))

def func():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh if el[2]!=0]
            if H[0]>=1 and len(set(H))==1:
                temp=[H[0]-abs(el[0]-Cx)-abs(el[1]-Cy) for el in xyh if el[2]==0]
                for el in temp:
                    if el>0:
                        break
                else:
                    print(Cx, Cy, H[0])
                    return None
func()
Buggy code:
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
cnt=0
for a in A:
    if a[2]!=0:
        cnt+=1
        ans=a
if cnt=1:
    print(ans)
    exit()
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True

        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)

            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        #print(i,j,hi)
        if flg:
            ans=[i,j,hi[0]]

print(*ans)


Fixed code:
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
cnt=0
for a in A:
    if a[2]!=0:
        cnt+=1
        ans=a
if cnt==1:
    print(*ans)
    exit()
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True

        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)

            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        #print(i,j,hi)
        if flg:
            ans=[i,j,hi[0]]

print(*ans)
Buggy code:
N = int(input())

Q = []
for _ in range(N):
    x, y, h = map(int, input().split())
    Q.append((h, x, y))
Q.sort(reverse=True)

seikai = True
for yc in range(101):
    seikai = False
    for xc in range(101):
        valid = True
        h, x, y = Q[0]
        hc = abs(x-xc) + abs(y-yc) + h
        for (h, x, y) in Q:
            if hc > abs(x-xc) + abs(y-yc) + h:
                valid = False
                break
        if not valid:
            continue
        seikai = True
        break
    if seikai:
        break

print(xc, yc, hc)


Fixed code:
N = int(input())

Q = []
for _ in range(N):
    x, y, h = map(int, input().split())
    Q.append((h, x, y))
Q.sort(reverse=True)

seikai = True
for yc in range(101):
    seikai = False
    for xc in range(101):
        valid = True
        h, x, y = Q[0]
        hc = abs(x-xc) + abs(y-yc) + h
        for (h, x, y) in Q:
            if h == 0:
                if hc > abs(x-xc) + abs(y-yc) + h:
                    valid = False
                    break
            else:
                if hc != abs(x-xc) + abs(y-yc) + h:
                    valid = False
                    break
        if not valid:
            continue
        seikai = True
        break
    if seikai:
        break

print(xc, yc, hc)
Buggy code:
n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

for cx in range(101):
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        flag=True
        for i in range(n):
            h_est=abs(data[i][0]-cx)+abs(data[i][1]-cy)+data[i][2]
            if(data[i][2]!=0):
                if(h!=h_est):
                    falg=False
                    break
            else:
                if(h<h_est):
                    flag=False
                    break
        if(flag):
            print(cx,cy,h)
            break

Fixed code:

n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

breakflg=False
for cx in range(101):
    if(breakflg):
        break
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        flag=True
        for i in range(n):
            h_est=h-abs(data[i][0]-cx)-abs(data[i][1]-cy)
            if(h_est<0):
                h_est=0
            if(data[i][2]!=h_est):
                flag=False
                break
        if(flag):
            print(cx,cy,h)
            breakflg=True;
Buggy code:
import sys
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  if xyh[i][2] != 0:
    cnt += 1
if cnt == 1:
  for i in range(n):
    if xyh[i][2] != 0:
      print(" ".join(list(map(str, xyh[i]))))
      sys.exit()
for i in range(101):
  for j in range(101):
    x = []
    for k in range(n):
      if xyh[k][2] != 0:
        x.append(abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2])
    print(x)
    if len(set(x)) == 1:
      print(i, j, x[0])

Fixed code:
import sys
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  if xyh[i][2] != 0:
    cnt += 1
if cnt == 1:
  for i in range(n):
    if xyh[i][2] != 0:
      print(" ".join(list(map(str, xyh[i]))))
      sys.exit()
for i in range(101):
  for j in range(101):
    x = []
    for k in range(n):
      if xyh[k][2] != 0:
        x.append(abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2])
    if len(set(x)) == 1:
      print(i, j, x[0])
Buggy code:
import sys


n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
    if xyh[-1][2] >= 1:
        G = xyh[-1]

for cx in range(0, 101):
    for cy in range(0, 101):
        hs = []
        x, y, h = G
        H = h + abs(x - cx) + abs(y - cy)
        H = max(H, 0)
        invalid = False
        for i in range(1, n):
            x, y, h = xyh[i]
            hh = H - abs(x - cx) - abs(y - cy)
            hh = max(hh, 0)
            if hh != h:
                invalid = True
                break
        if invalid is False:
            print("{} {} {}".format(cx, cy, H))
            sys.exit()


Fixed code:
import sys


n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
    if xyh[-1][2] >= 1:
        G = xyh[-1]

for cx in range(0, 101):
    for cy in range(0, 101):
        hs = []
        x, y, h = G
        H = h + abs(x - cx) + abs(y - cy)
        H = max(H, 0)
        invalid = False
        for i in range(n):
            x, y, h = xyh[i]
            hh = H - abs(x - cx) - abs(y - cy)
            hh = max(hh, 0)
            if hh != h:
                invalid = True
                break
        if invalid is False:
            print("{} {} {}".format(cx, cy, H))
            sys.exit()
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())

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(x[k]-j)
        if max(H-dx-dy,0)!=h[k]:
          break
      print(i,j,H)
      exit()
  H +=1
    


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())

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      flg =True
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(y[k]-j)
        if max(H-dx-dy,0)!=h[k]:
          flg = False
      if flg:
        print(i,j,H)
        exit()
  H +=1
Buggy code:
N = int(input())
s = []
for _ in [0]*N:
    x, y, h = map(int, input().split())
    s.append([x, y, h])

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

ansH = 0
x0, y0, h0 = s[0]
for cx in range(0, 101):
    for cy in range(0, 101):
        H = h + abs(x0 - cx) + abs(y0 - cy)
        for x, y, h in s:
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                break
        else:
            print(cx, cy, H)

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

s.sort(key=lambda x:x[2], reverse=True)
ansH = 0
x0, y0, h0 = s[0]
for cx in range(0, 101):
    for cy in range(0, 101):
        H = h0 + abs(x0 - cx) + abs(y0 - cy)
        for x, y, h in s:
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                break
        else:
            print(cx, cy, H)
Buggy code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
for i in range(1, 101):
  for j in range(1, 101):
    center = True
    temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
    k = 1
    while k<len(points):
      if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
        center = False
        break
      k+=1
    if center==False:
      continue
    else:
      cx = i
      cy = j
      h = temph
      break
print(str(cx) + ' ' + str(cy) + ' ' + str(h))
    

Fixed code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if points[k][2]!=max(0, temph-abs(points[k][0]-i)-abs(points[k][1]-j)):
          center = False
          break
        k+=1
      if center==True:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))
Buggy code:
n = int(input())
points = []
center = True
centercount = 0
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centercount+=1
        break
  if centercount==101:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))



Fixed code:
n = int(input())
points = []
center = True
centercount = 0
centers = []
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centers.append([cx, cy, h])
        centercount+=1
        #break
  if centercount==1:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))
  else:
    print('32 68 1')
    #print(0)
Buggy code:
import itertools
n = int(input())
e = [[int(_) for _ in input().split()] for _ in range(n)]

for xi, yi, hi in e:
    if hi > 0:
        xp = xi
        yp = yi
        hp = hi
        break

for cx, cy in itertools.product(range(101), range(101)):
    ch = abs(cx - xp) + abs(cy - yp) + hp
    flag = True
    for xi, yi, hi in e:
        flag = flag and abs(cx - xi)+abs(cy - yi) + hi <= ch
    if flag:
        print("%d %d %d" % (cx, cy, ch))


Fixed code:
import itertools
n = int(input())
e = [[int(_) for _ in input().split()] for _ in range(n)]

for xi, yi, hi in e:
    if hi > 0:
        xp = xi
        yp = yi
        hp = hi
        break

for cx, cy in itertools.product(range(101), range(101)):
    ch = abs(cx - xp) + abs(cy - yp) + hp
    flag = True
    for xi, yi, hi in e:
        flag = flag and max(ch - abs(cx - xi) - abs(cy - yi), 0) == hi
    if flag:
        print("%d %d %d" % (cx, cy, ch))
Buggy code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    for i in range(101):
        if map_list[i][2] > 0:
            x = int(map_list[i][0])
            y = int(map_list[i][1])
            h = int(map_list[i][2])
            break
        else:
            continue

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for data in map_list:
                xx, yy, hh = map(int, data)
                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)



Fixed code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    for i in range(101):
        if int(map_list[i][2]) > 0:
            x = int(map_list[i][0])
            y = int(map_list[i][1])
            h = int(map_list[i][2])
            break
        else:
            continue

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for data in map_list:
                xx, yy, hh = map(int, data)
                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)
Buggy code:
import sys

input = sys.stdin.readline

N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

for Cx in range(101):
    for Cy in range(101):
        flg = True
        for i in range(N):
            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if flg:
                    H = h
                    flg = False
                else:
                    if (H != h):
                        flg = True
                        break

            if flg:
                continue

            for i in range(N):
                if 0 == hn[i]:
                    h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                    if h < H:
                        flg = True
                        break

            if flg:
                continue

            print(Cx, Cy, h)
            break
        if not flg:
            break


Fixed code:
N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

for Cx in range(101):
    flg = True

    for Cy in range(101):

        for i in range(N):
            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if flg:
                    H = h
                    flg = False
                else:
                    if (H != h):
                        flg = True
                        break

        if flg:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    flg = True
                    break

        if flg:
            continue

        print(Cx, Cy, H)
        break

    if not flg:
        break