qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
pos = [list(map(int, input().split())) for _ in range(N)]
for cx in range(101):
    for cy in range(101):
        minH = 1 << 29
        se = set()
        for x,y,h in pos:
            a = -abs(x-cx)-abs(y-cy)
            if h <= a:
                break
            elif h == 0:
                minH = min(minH, -a)
            else:
                se.add(h-a)
        else:
            if len(se) == 0 and minH == 1:
                print(cx, cy, hh)
            elif len(se) == 1:
                hh = se.pop()
               if hh <= minH:
                   print(cx, cy, hh)

Fixed code:
N = int(input())
pos = [list(map(int, input().split())) for _ in range(N)]
for cx in range(101):
    for cy in range(101):
        minH = 1 << 30
        se = set()
        for x,y,h in pos:
            a = -abs(x-cx)-abs(y-cy)
            if h == 0 and a == 0:
                break
            elif h == 0:
                minH = min(minH, -a)
            else:
                se.add(h-a)
        else:
            if len(se) == 0 and minH == 1:
                print(cx, cy, minH)
            elif len(se) == 1:
                hh = se.pop()
                if hh <= minH:
                   print(cx, cy, hh)
Buggy code:
n = int(input())
hs = [list(map(int, input().split())) for _ in range(n)]
hs.sort(key = lambda x: x[2], reverse = True)

#print(hs)
def main():
    for x in range(101):
        for y in range(101):
            height = hs[0][2] + abs(x-hs[0][0]) + abs(y-hs[0][1])
            for i in range(n):
                if hs[i][2] != 0:
                    if hs[i][2] == height - abs(x-hs[i][0]) - abs(y-hs[i][1]):
                        pass
                    else:
                        break
                if i == n-1:
                    return x,y,height
print(main())

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

def main():
    for x in range(101):
        for y in range(101):
            height = hs[0][2] + abs(x-hs[0][0]) + abs(y-hs[0][1])
            for i in range(1,n):
                if max(height-(abs(x-hs[i][0]) + abs(y-hs[i][1])),0)== hs[i][2]:
                    pass
                else:
                    break
                
                if i ==n-1:
                    print(x,y,height)
                    return x,y,height
main()
Buggy code:
#C
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]

CX = 0
CY = 0
flag = 0
for CX in range(101):
    for CY in range(101):
        H = 0
        hmax = 0
        for i in range(N):
            x,y,h = XYH[i]
            if H == 0:
                if h != 0:
                    H = abs(CX-x)+abs(CY-y)+h
                    if H > hmax:
                        H = 0
                        break
                else:
                    hmax = max(hmax,abs(CX-x)+abs(CY-y)+h)
            else:
                if h != 0:
                    if H != abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
                else:
                    if H > abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
        if H >= 1:
            print(CX,CY,H)
            flag = 1
            break
    if flag == 1:
        break
            



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

CX = 0
CY = 0
flag = 0
for CX in range(101):
    for CY in range(101):
        H = 0
        hmax = -1
        for i in range(N):
            x,y,h = XYH[i]
            if H == 0:
                if h != 0:
                    H = abs(CX-x)+abs(CY-y)+h
                    if H > hmax and hmax >= 0:
                        H = 0
                        break
                else:
                    hmax = max(hmax,abs(CX-x)+abs(CY-y)+h)
            else:
                if h != 0:
                    if H != abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
                else:
                    if H > abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
        if H >= 1:
            print(CX,CY,H)
            flag = 1
            break
    if flag == 1:
        break
Buggy code:
if __name__=='__main__':
    n = int(input())
    c = [[int(i) for i in input().split()] for i in range(n)]
    # print(c)
    a = [[0 for i in range(101)] for i in range(101)]
    # print(a)
    for i in range(101):
        for j in range(101):
            a[i][j] = abs(i - c[0][0]) + abs(j - c[0][1]) + c[0][2]
    print(a)
    for i in range(101):
        if i!=100: continue

        flag = True
        for j in range(101):
            if j!=0: continue
            flag = True
            for p in range(1,n):
                h = abs(i-c[p][0])+ abs(j-c[p][1]) + c[p][2]
                if h != a[i][j]:
                    flag = False
                    break
            if flag:
                for p in range(n):
                    h = max(a[i][j] - abs(i-c[p][0])- abs(j-c[p][1]),0)
                    if h!= c[p][2]:
                        flag = False
                        break
            if flag:
                print(i,j,a[i][j])
                quit()


Fixed code:
if __name__=='__main__':
    n = int(input())
    c = [[int(i) for i in input().split()] for i in range(n)]
    # print(c)
    a = [[0 for i in range(101)] for i in range(101)]
    # print(a)
    for i in range(101):
        for j in range(101):
            for p in range(n):
                if c[p][2] != 0:
                    a[i][j] = abs(i - c[p][0]) + abs(j - c[p][1]) + c[p][2]
                    break


            for p in range(n):
                if c[p][2] != 0:
                    h = abs(i - c[p][0]) + abs(j - c[p][1]) + c[p][2]
                    if a[i][j] != h:
                        a[i][j] = -1
                        break
                if c[p][2] == 0:
                    h = abs(i - c[p][0]) + abs(j - c[p][1])
                    if a[i][j] > h:
                        a[i][j] = -1
                        break


    for i in range(101):
        for j in range(101):
            flag = True
            if a[i][j] == -1:continue
            # for p in range(n):
            #     h = abs(i-c[p][0])+ abs(j-c[p][1]) + c[p][2]
            #     if h != a[i][j]:
            #         flag = False
            #         break
            # if flag:
            for p in range(n):
                h = max(a[i][j] - abs(i-c[p][0])- abs(j-c[p][1]),0)
                if h!= c[p][2]:
                    flag = False
                    break
            if flag:
                print(i,j,a[i][j])
                quit()
Buggy code:
N = int(input())

X = []
Y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())

    if c > 0:
        p = i
    X.append(a)
    Y.append(b)
    h.append(c)

for Cx in range(101):
    for Cy in range(101):
        works = True
        H = h[p] + abs(X[p] - Cx) + abs(Y[p] - Cy)
        for i in range(N):

            if h[i] != max(H - abs(X[p] - Cx) - abs(Y[p] - Cy), 0):
                works = False
                break
        
        if works:
            print(Cx,Cy,H)
            quit()

Fixed code:
N = int(input())

X = []
Y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())

    if c > 0:
        p = i
    X.append(a)
    Y.append(b)
    h.append(c)

for Cx in range(101):
    for Cy in range(101):
        works = True
        H = h[p] + abs(X[p] - Cx) + abs(Y[p] - Cy)
        for i in range(N):
            if h[i] != max(H - abs(X[i] - Cx) - abs(Y[i] - Cy), 0):
                works = False
                break
        
        if works:
            print(Cx,Cy,H)
            quit()
Buggy code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
for i in range(N):
    h = xyh_list[i][2]
    if h != 0:
        no_zero_h = i
        break
else:


break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        x = xyh_list[no_zero_h][0]
        y = xyh_list[no_zero_h][1]
        h = xyh_list[no_zero_h][2]
        H = h + abs(x-i) + abs(y-j)
        
        if 1 <= H:
            for k in range(0,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                if h + abs(x-i) + abs(y-j) != H:
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
            
    if break_flag == 1:
        break

Fixed code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
for i in range(N):
    h = xyh_list[i][2]
    if h != 0:
        no_zero_h = i
        break


break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        x = xyh_list[no_zero_h][0]
        y = xyh_list[no_zero_h][1]
        h = xyh_list[no_zero_h][2]
        H = h + abs(x-i) + abs(y-j)
        
        if 1 <= H:
            for k in range(0,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                if (h != 0 and h + abs(x-i) + abs(y-j) != H) or (h == 0 and H - abs(x-i) - abs(y-j) > 0):
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
            
    if break_flag == 1:
        break
Buggy code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
xyh=sorted(xyh,key=lambda x:x[2])
for cx in range(101):
    for cy in range(101):
        h_a=h_b=10**10
        minh=10**9+2
        for i in range(n):
            x,y,h=xyh[i]
            if h!=0:
                h_a=h+abs(cx-x)+abs(cy-y)
                if h_b!=10**9+1 and (h_a!=h_b or h_a>minh):
                    break
                else:
                    h_b=h_a
            else:
                minh=min(minh,abs(cx-x)+abs(cy-y))
                if minh==0:
                  break
        else:
            if minh==1 and h_a==10**10:
              print(cx,cy,1)
              exit()
            else:
                print(cx,cy,h_a)
                exit()


Fixed code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
xyh=sorted(xyh,key=lambda x:x[2])
for cx in range(101):
    for cy in range(101):
        h_a=h_b=10**10
        minh=10**10
        for i in range(n):
            x,y,h=xyh[i]
            if h!=0:
                h_a=h+abs(cx-x)+abs(cy-y)
                if h_a>minh:
                  break
                elif h_b!=10**10 and h_a!=h_b:
                    break
                else:
                    h_b=h_a
            else:
                minh=min(minh,abs(cx-x)+abs(cy-y))
                if minh==0:
                  break
        else:
            if minh==1 and h_a==10**10:
              print(cx,cy,1)
              exit()
            else:
                print(cx,cy,h_a)
                exit()
Buggy code:
import sys
n=int(input())
lst=[]
for i in range(n):
  x,y,h=map(int,input().split())
  lst.append([x,y,h])
  
for j in range(101):
  for k in range(101):
    for i in range(n):
      H=abs(j-lst[i][0])-abs(k-lst[i][1])+lst[i][2]
      if H>0:
        if all(max(H-abs(j-lst[l][0])-abs(k-lst[l][1]),0)==h[l] for l in range(n)):
          print([j,k,H])
          sys.exit()
        
  
  


Fixed code:
import sys
n=int(input())
lst=[]
for i in range(n):
  x,y,h=map(int,input().split())
  lst.append([x,y,h])
  
for j in range(101):
  for k in range(101):
    for i in range(n):
      H=abs(j-lst[i][0])+abs(k-lst[i][1])+lst[i][2]
      if H>0:
        if all(max(H-abs(j-lst[l][0])-abs(k-lst[l][1]),0)==lst[l][2] for l in range(n)):
          print(j,k,H)
          sys.exit()
Buggy code:
#!/usr/bin/env python3

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


for x in range(0, 101):
    for y in range(0, 101):
        H_less = 100
        H = -1
        flag = 0
        for x_, y_, h_ in xyh:
            if h_ == 0:
                H_less = min(abs(x_-x)+abs(y_-y), H_less)
            else:
                h_tmp = h_ + abs(x_-x) + abs(y_-y)
                if H != -1:
                    if H != h_tmp:
                        flag = 1
                        break
                H = h_tmp
        if flag == 1:
            continue
        if H > H_less:
            continue
        print(x, y, H)
        exit()
        # print(H, H_less)


Fixed code:
#!/usr/bin/env python3

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


for x in range(0, 101):
    for y in range(0, 101):
        H_less = 10**10
        H = -1
        flag = 0
        for x_, y_, h_ in xyh:
            if h_ == 0:
                H_less = min(abs(x_-x)+abs(y_-y), H_less)
            else:
                h_tmp = h_ + abs(x_-x) + abs(y_-y)
                if H != -1:
                    if H != h_tmp:
                        flag = 1
                        break
                H = h_tmp
        if flag == 1:
            continue
        # print(H, H_less)
        if H > H_less:
            continue
        print(x, y, H)
        exit()
Buggy code:
import numpy as np
N = int(input())
lis = np.zeros((101,101))
s = list()
for k in range(N):
    print(s)
    tmp = list()
    x,y,h = map(int,input().split())
    if h == 0:
        continue
    if s:
        if len(s) == 1:
            break
        for i in s:
            if i[2] == h+abs(i[0]-x)+abs(i[1]-y):
                tmp.append(i)
        s = tmp
    else:
        for i in range(101):
            for j in range(101):
                if lis[i][j] == 0:
                    lis[i][j] = h+abs(i-x)+abs(j-y)
                elif lis[i][j] == h+abs(i-x)+abs(j-y):
                    s.append([i,j,lis[i][j]])
else:
    for i in range(101):
        for j in range(101):
            if lis[i][j] == 1:
                s.append([i,j,lis[i][j]])
print(s[0][0], s[0][1], int(s[0][2]))


Fixed code:
import numpy as np
N = int(input())
lis = np.zeros((101,101))
s = list()
for k in range(N):
    tmp = list()
    x,y,h = map(int,input().split())
    if h == 0:
        continue
    if s:
        if len(s) == 1:
            break
        for i in s:
            if i[2] == h+abs(i[0]-x)+abs(i[1]-y):
                tmp.append(i)
        s = tmp
    else:
        for i in range(101):
            for j in range(101):
                if lis[i][j] == 0:
                    lis[i][j] = h+abs(i-x)+abs(j-y)
                elif lis[i][j] == h+abs(i-x)+abs(j-y):
                    s.append([i,j,lis[i][j]])
else:
    for i in range(101):
        for j in range(101):
            if lis[i][j] == 1:
                s.append([i,j,lis[i][j]])
print(s[0][0], s[0][1], int(s[0][2]))
Buggy code:
n=int(input())

L=[list(map(int,input().split())) for i in range(n)]
LSort=sorted(L,key=lambda x:x[2])
x,y,z=LS[-1]

for cx in range(1,101):
	for cy in range(1,101):
		H=h+abs(x-cx)+abs(y-cy)
		if all([h=max(H-abs(x-cx)-abs(y-cy),0) for x,y,z in LSort])
		print(cx,cy,H)
		exit()

Fixed code:
n=int(input())
 
L=[list(map(int,input().split())) for i in range(n)]
LSort=sorted(L,key=lambda x:x[2])
x,y,h=LSort[-1]

for cx in range(0,101):
	for cy in range(0,101):
		H=h+abs(x-cx)+abs(y-cy)
		if all([h==max(H-abs(x-cx)-abs(y-cy),0) for x,y,h in LSort]):
		    print(cx,cy,H)
		    exit()
Buggy code:
def main():
    n = int(input())
    x = []
    y = []
    h = []
    for i in range(n):
        xx, yy, zz = map(int, input().split())
        x.append(xx)
        y.append(yy)
        h.append(zz)
    for i in range(n):
        if h[i] != 0:
            idx = i
    for xx in range(101):
        for yy in range(101):
            H = h[idx] + abs(xx - x[idx]) + abs(yy - y[idx])
            if xx == 2 and yy == 2:
                print(H)
            flag = True
            for i in range(n):
                if h[i] != max(H - abs(xx - x[i]) - abs(yy - y[i]), 0):
                    flag = False
                    break
            if flag:
                print(xx, yy, H)
                return

    
if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = int(input())
    x = []
    y = []
    h = []
    for i in range(n):
        xx, yy, zz = map(int, input().split())
        x.append(xx)
        y.append(yy)
        h.append(zz)
    for i in range(n):
        if h[i] != 0:
            idx = i
    for xx in range(101):
        for yy in range(101):
            H = h[idx] + abs(xx - x[idx]) + abs(yy - y[idx])
            flag = True
            for i in range(n):
                if h[i] != max(H - abs(xx - x[i]) - abs(yy - y[i]), 0):
                    flag = False
                    break
            if flag:
                print(xx, yy, H)
                return

    
if __name__ == '__main__':
    main()
Buggy code:
# -*- coding: utf-8 -*-

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1 and max(h0) <= max(hc):
            print(x, y, list(hc)[0])
            break


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

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and min(h0) >= list(hc)[0]) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break
Buggy code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]
h_now_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)
		
for cy in range(101):
	for cx in range(101):
		n = -1	
		for h in h_list:
			n += 1
			if h >= 1:
				H = abs(cx - x_list[n])+abs(cy - y_list[n])+h
				break
		for i in range(N):
			h_now = max(H-abs(cx - x_list[i])-abs(cy - y_list[i]), 0)
			h_now_list.append(h_now)
			if h_now != h_list[i]:
				break	
		if len(h_now_list) == N:
			print(str(cx)+' '+str(cy)+' '+str(H))
			break		
	else:
		continue
	break

Fixed code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]


def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)
		
for cy in range(101):
	for cx in range(101):
		n = -1	
		for h in h_list:
			n += 1
			if h >= 1:
				H = abs(cx - x_list[n])+abs(cy - y_list[n])+h
				h_now_list=[]
				break
		for i in range(N):
			h_now = max((H-abs(cx - x_list[i])-abs(cy - y_list[i])), 0)
			h_now_list.append(h_now)
			if h_now != h_list[i]:
				break	
			else:
				if len(h_now_list)==N:
					print(str(cx)+' '+str(cy)+' '+str(H))
					break
	else:
		continue
	break
Buggy code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
    for y in range(101):
        a,s,d=l[0]
        k=set(d+abs(x-a)+abs(s-y)  for a,s,d in l )
        for pre in k:
            for a,s ,d in l:
                if d!=max(0,pre-abs(x-a)-abs(s-y)):break
            print(x,y,pre);exit()

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

for x in range(101):
    for y in range(101):
        k=set(e+abs(x-q)+abs(w-y)  for q,w,e in l if e)
        for pre in k:
            for a,s ,d in l:

                if d!=max(0,pre-abs(x-a)-abs(s-y)):break
            else:print(x,y,pre);exit()
Buggy code:
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh.sort(key=lambda x: -x[2])
for cx in range(101):
    for cy in range(101):
        good = True
        h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
        #for i in range(n):
        #    if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
        #        good = False
        #        break
        #if good:
    print(cx, cy, h)
    break

Fixed code:
import sys
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh.sort(key=lambda x: -x[2])
for cx in range(101):
    for cy in range(101):
        good = True
        h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
        for i in range(n):
            if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
                good = False
                break
        if good:
            print(cx, cy, h)
            sys.exit()
Buggy code:
n=int(input())
a=[]

x,y,k=-1,-1,-1
n=-1
for _ in range(n):
    a.append(list(map(int,input().split())))
    if a[_][2] != 0:
        n=i
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()



Fixed code:
n=int(input())
a=[]

x,y,k=-1,-1,-1
t=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        t=o
for i in range(101):
    for j in range(101):
        h=a[t][2]+abs(a[t][0]-i)+abs(a[t][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()
Buggy code:
import sys
Input = sys.stdin.readline

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = 0
H_temp = None
 
x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H_temp < H:
                    Cx = c_x
                    Cy = c_y
                    print("{0} {1} {2}".format(Cx, Cy, H))
                    sys.exit()

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = float("inf")
H_temp = None
 
x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H_temp < H:
                    Cx = c_x
                    Cy = c_y
                    H = H_temp
                    
print("{0} {1} {2}".format(Cx, Cy, H))