Problem:
 Score: 300 points    Problem Statement  In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had center coordinates  (C_X, C_Y) and height  H . The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0) .  Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:   C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1 .  Additionally, he obtained N pieces of information. The i -th of them is: "the altitude of point (x_i, y_i) is h_i ."   This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.      Constraints   N is an integer between 1 and 100 (inclusive).  x_i and y_i are integers between 0 and 100 (inclusive).  h_i is an integer between 0 and 10^9 (inclusive).  The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.  The center coordinates and the height of the pyramid can be uniquely identified.         Input  Input is given from Standard Input in the following format:  N  x_1  y_1  h_1  x_2  y_2  h_2  x_3  y_3  h_3  :  x_N  y_N  h_N       Output  Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.        Sample Input 1 4
2 3 5
2 1 5
1 2 5
3 2 5      Sample Output 1 2 2 6  In this case, the center coordinates and the height can be identified as (2, 2) and 6 .       Sample Input 2 2
0 0 100
1 1 98      Sample Output 2 0 0 100  In this case, the center coordinates and the height can be identified as (0, 0) and 100 . Note that C_X and C_Y are known to be integers between 0 and 100 .       Sample Input 3 3
99 1 191
100 1 192
99 0 192      Sample Output 3 100 0 193  In this case, the center coordinates and the height can be identified as (100, 0) and 193 .

Solution (Python):
N = int(input())
x_y_h = [tuple(map(int, input().split())) for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        try_H = 0
        for x, y, h in x_y_h:
            if h > 0:
                try_H = h + abs(x - cx) + abs(y - cy)
                break

        wrong = False
        for x, y, h in x_y_h:
            tmp_H = max(try_H - abs(x - cx) - abs(y - cy), 0)
            if tmp_H != h:
                wrong = True
                break
        if wrong:
            continue
        print(cx, cy, try_H)
        exit()

Solution (Python):
def main():
    N = int(input())
    x_y_h = [tuple(map(int, input().split())) for _ in range(N)]

    cx, cy, H = solve(x_y_h)
    print(cx, cy, H)


def height(cx, cy, x_y_h):
    for x, y, h in x_y_h:
        if h <= 0:
            continue
        return h + abs(x - cx) + abs(y - cy)
    return 0


def valid(cx, cy, H, x_y_h):
    for x, y, h in x_y_h:
        if h != max(H - abs(x - cx) - abs(y - cy), 0):
            return False
    return True


def solve(x_y_h):
    for cx in range(101):
        for cy in range(101):
            try_H = height(cx, cy, x_y_h)
            if valid(cx, cy, try_H, x_y_h):
                return cx, cy, try_H
    return 0, 0, 0


main()

Solution (Python):
def height(cx, cy, D):
    for x, y, h in D:
        if h <= 0: continue
        return h + abs(x-cx) + abs(y-cy)
    return 0

def valid(cx, cy, H, D):
    for x, y, h in D:
        if h != max(H - abs(x-cx) - abs(y-cy), 0):
            return False
    return True

def solve():
    for cy in range(0, 101):
        for cx in range(0, 101):
            H = height(cx, cy, D)
            if valid(cx, cy, H, D):
                return (cx, cy, H)
    return (0, 0, 0)

N = int(input())
D = []
for i in range(N):
    x, y, h = map(int, input().split())
    D.append((x, y, h))
cx, cy, H = solve()
print(cx, cy, H)

Solution (Python):
def height(cx, cy, D):
    for x, y, h in D:
        if h <= 0: continue
        return h + abs(x-cx) + abs(y-cy)
    return 0

def valid(cx, cy, H, D):
    for x, y, h in D:
        if h != max(H - abs(x-cx) - abs(y-cy), 0):
            return False
    return True

def solve():
    for cy in range(0, 101):
        for cx in range(0, 101):
            H = height(cx, cy, D)
            if valid(cx, cy, H, D):
                return (cx, cy, H)
    return (0, 0, 0)

N = int(input())
D = []
for i in range(N):
    x, y, h = map(int, input().split())
    D.append((x, y, h))
cx, cy, H = solve()
print(cx, cy, H)

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

for cx in range(101):
    for cy in range(101):
        flag=1
        tmp=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
        for i in range(1,N):
            if xyh[i][2]==0 and abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)<tmp:
                flag=0
                break
            if tmp!=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2] and xyh[i][2]!=0:
                flag=0
                break
        if flag:
            print(cx, cy, tmp)
            exit(0)

Solution (Python):
n = int(input())
data=[]
for i in range(0,n):
    x, y, h = map(int,input().split())
    data.append((x,y,h))
data = sorted(data,key=lambda x:x[2],reverse=True)
st_x, st_y, st_h = data[0]
 
 
def get_search_area(x,y,n):
    area_list=[]
    for i in range(-n,n+1):
        for j in range(-n,n+1):
            if abs(i) == n or abs(j) == n:
                xi = x+i
                yi = y+j
                if 0<= xi <= 100 and 0 <= yi <= 100:
                    area_list.append((x+i, y+j, abs(i)+abs(j) ))
    return area_list
 
def meets_all_conditions(top, top_h,data):
    top_x, top_y, top_z = top
    top_h += top_z
    for item in data:
        pt_x, pt_y, pt_h = item
        tmp = max(top_h - abs(pt_x - top_x) - abs(pt_y - top_y), 0)       
        if pt_h != tmp:
            
            return False    
    
    return True
    
def main():    
    for i in range(200):
        
        a = get_search_area(st_x,st_y,i)
        
        for item in a:
            if meets_all_conditions(item, st_h , data):
                print("{} {} {}".format(item[0],item[1],st_h+item[2]))
                return
    return
main()

Solution (Python):


N = int(input().strip())

input_tuples = []
selected_tuple = None

for _ in range(N):
    x, y, h = [int(s) for s in input().strip().split()]
    if selected_tuple is None and h > 0:
        selected_tuple = ((x, y, h))
    else:
        input_tuples.append((x, y, h))

for cx in range(0, 101):
    for cy in range(0, 101):
        H = selected_tuple[2] + \
            abs(selected_tuple[0] - cx) + abs(selected_tuple[1] - cy)

        for x, y, h in input_tuples:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            break
        continue
    else:
        continue
    break

print("{} {} {}".format(cx, cy, H))

Solution (Python):
N = int(input())
x = [None for _ in range(N)]
y = [None for _ in range(N)]
h = [None for _ in range(N)]
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())
    if h[i] > 0:
        a = [x[i], y[i], h[i]]
for cx in range(0, 101):
    for cy in range(0, 101):
        hh = a[2] + abs(a[0] - cx) + abs(a[1] - cy)
        flag = True
        for i in range(N):
            h_i = max(hh - abs(x[i] - cx) - abs(y[i] - cy), 0)
            if h_i != h[i]:
                flag = False
        if flag:
            print(cx, cy, hh)
            exit()

Solution (Python):
import sys
N = int(input())
points = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda p: -p[2])
for c_x in range(101):
    for c_y in range(101):
        h = points[0][2] + abs(points[0][0] - c_x) + abs(points[0][1] - c_y)
        for point in points[1:]:
            if max(h - abs(point[0] - c_x) - abs(point[1] - c_y), 0) != point[2]:
                break
        else:
            print(c_x, c_y, h)
            sys.exit()

Solution (Python):



def main():
    n = int(input())

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

    for coordinate in coordinates:
        if coordinate[2] > 0:
            xx = coordinate[0]
            yy = coordinate[1]
            hh = coordinate[2]
            break

    for px in range(101):
        for py in range(101):
            ph = hh + abs(xx - px) + abs(yy - py)

            suit = True
            for x, y, h in coordinates:
                if h != max(ph - abs(x - px) - abs(y - py), 0):
                    suit = False
                    break

            if suit == True:
                print(px, py, ph)
                return


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

xyh = [[0, 0, 0] for i in range(N)]

for i in range(N):
    x, y, h = input().split(' ')
    xyh[i][0] = int(x)
    xyh[i][1] = int(y)
    xyh[i][2] = int(h)

finish = False
for cx in range(101):
    for cy in range(101):
        top = 0
        for x, y, h in xyh:
            if h != 0:
                top = abs(x-cx)+abs(y-cy)+h
        for x, y, h in xyh:
            finish = True
            if max(top - abs(x-cx)-abs(y-cy), 0) != h:
                finish = False
                break
        if finish == True:
            print ('{} {} {}'.format(cx, cy, top))
            exit()

Solution (Python):


N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[0] * FIELD_SIZE for n in range(FIELD_SIZE)]
determined_flag = False

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if n == 0:
                H[cx][cy] = ch

            elif determined_flag:
                if h[n] != 0:
                    if ch == H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0
                else:
                    if ch >= H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0

            else:
                if h[n] != 0:
                    if ch <= H[cx][cy]:
                        H[cx][cy] = ch
                    else:
                        H[cx][cy] = 0
                else:
                    H[cx][cy] = min(H[cx][cy], ch)
    if h[n] != 0:
        determined_flag = True


for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] >= 1:
            print(cx, cy, H[cx][cy])

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

for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            if h[i] > 0:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)

        for i in range(N):
            if h[i] != max(0, H - abs(x[i] - cx) - abs(y[i] - cy)):
                break
        else:
            print(cx, cy, H)
            exit()

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

for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            if h[i] > 0:
                H = h[i] + abs(x[i]-cx)+abs(y[i]-cy)
        
        for i in range(N):
            if h[i] != max(0, H-abs(x[i]-cx)-abs(y[i]-cy)):
                break
        else:
            print(cx, cy, H)
            exit()

Solution (Python):
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = []
    for _ in range(GI()):
        x, y, h = LGIS()
        if h:
            sols.append((x, y, h))

    if len(sols) == 1:
        print(*sols[0])
        return

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return

main()

Solution (Python):
inn = int(input())
ina = [list(map(int,input().split())) for i in range(inn)]

arr = [[-1] * 101 for i in range(101)]
arr0 = [[False] * 101 for i in range(101)]
for xi in range(101):
  for yi in range(101):
    arr[xi][yi] = ina[0][2]+abs(ina[0][0]-xi)+abs(ina[0][1]-yi)
    if ina[0][2] == 0:
      arr0[xi][yi] = True

arrTF = [[True] * 101 for i in range(101)]
for i in range(1,inn):
  for xi in range(101):
    for yi in range(101):
      if arrTF[xi][yi]:
        if arr0[xi][yi]:
          if ina[i][2] == 0:
            if arr[xi][yi] > ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arr[xi][yi] = ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi)
          else:
            if arr[xi][yi] < ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arrTF[xi][yi] = False
            else:
              arr[xi][yi] = ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi)
              arr0[xi][yi] = False
        else:
          if ina[i][2] == 0:
            if arr[xi][yi] > ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arrTF[xi][yi] = False
          else:
            if arr[xi][yi] != ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arrTF[xi][yi] = False

for xi in range(101):
  for yi in range(101):
    if arrTF[xi][yi]:
      print(str(xi)+" "+str(yi)+" "+str(arr[xi][yi]))

Solution (Python):
import sys

def get_height(h, x, y, cx, cy):
	for i in range(len(h)):
		if h[i] == 0:
			continue
		return h[i] + abs(x[i] - cx) + abs(y[i] - cy)

n = int(input())
x = []
y = []
h = []
for _ in range(n):
	xi, yi, hi = map(int, input().split())
	x.append(xi)
	y.append(yi)
	h.append(hi)

for cx in range(101):
	for cy in range(101):
		height = get_height(h, x, y, cx, cy)
		for i in range(n):
			if h[i] != max(0, height - abs(x[i] - cx) - abs(y[i] - cy)):
				break
		else:
			print(cx, cy, height)
			sys.exit()

Solution (Python):
def main():
	n = int(input())

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

	for k in range(info[0][2], info[0][2] + 201):
		for i in range(101):
			for j in range(101):
				
				flg = 0
				for l in info:
					
					deltax = abs(l[0] - i)
					deltay = abs(l[1] - j)
					guessh = max(k - deltax - deltay, 0)
					
					if guessh != l[2]:
						flg = 1
						break
				
				if flg == 0:
					print(i, j, k)
					return

if __name__ == '__main__':
	main()

Solution (Python):
N = int(input())
lx, ly, lh = [], [], []
for i in range(N):
    x, y, h = map(int, input().split())
    lx.append(x)
    ly.append(y)
    lh.append(h)

for i in range(101):
    for j in range(101):
        k = 0
        while lh[k] == 0:
            k += 1
        H = int(abs(lx[k]-i)) + int(abs(ly[k]-j)) + lh[k]
        b = True
        for k in range(len(lh)):
            if lh[k] != max(H - int(abs(lx[k]-i)) - int(abs(ly[k]-j)), 0):
                b = False
                break
        if b:
            print(i, j, H)

Solution (Python):
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
li = []
for i in range(n):
  if lis[i][-1] != 0:li.append(lis[i])
ans = []
for i in range(101):
  for j in range(101):
    H = abs(li[0][0]-i)+abs(li[0][1]-j)+li[0][2]
    key = 0
    for x,y,h in lis:
      if max(0,H- abs(x-i)-abs(y-j)) != h:
        key = 1
    if key == 0:ans.append([i,j,H])
if len(ans) == 1:
  print(ans[0][0],ans[0][1],ans[0][2])

Solution (Python):
import numpy as np
def solve(n, x, y, h):
    for cx in range(101):
        for cy in range(101):
            ok = False
            for i in range(n):
                if h[i] > 0:
                    H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                    ok = True
                    break
            if ok:
                for i in range(n):
                    h_i = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0)
                    if h_i != h[i]:
                        ok = False
                        break
            if ok:
                return "%d %d %d" % (cx, cy, H)

n = input()
x, y, h = np.zeros(n,int), np.zeros(n,int), np.zeros(n,int)
for i in range(n):
    x[i], y[i], h[i] = map(int, raw_input().split())
print solve(n, x, y, h)

Solution (Python):

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

Solution (Python):






def abs(key):
    if key < 0:
        return -key
    else:
        return key


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())
pos_max = 100  
for posY in range(pos_max+1):
    for posX in range(pos_max+1):
        
        
        
        needH = -1
        
        for i in range(n):
            if h[i] > 0:
                
                
                tmp = h[i] + abs(posX-x[i]) + abs(posY-y[i])
                
                
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
        
        
        if needH == -2:
            continue  
        
        for i in range(n):
            if h[i] == 0:
                dist = abs(posX-x[i]) + abs(posY-y[i])
                if needH > dist:
                    needH = -2
                    break
        if needH == -2:
            continue
        print("{} {} {}".format(posX, posY, needH))

Solution (Python):
n = int(input())
xyh = []
for i in range(0,n):
    X,Y,h = map(int,input().split())
    xyh.append((X,Y,h))
from operator import itemgetter
xyh.sort(key=itemgetter(2))
xyh.reverse()

ans = ()
for i in range(0,101):
    for j in range(0,101):
        flag = "f"
        x,y,h = xyh[0]
        H = h + abs(x-i)+abs(y-j)
        for x,y,h in xyh:
            if H ==  h + abs(x-i)+abs(y-j) and h != 0:
                flag = "t"
            elif H <=  h + abs(x-i)+abs(y-j) and h == 0:
                flag = "t"
            else:
                flag = "f"
                break
        if flag == "t":
            ans = (i,j,H)
Cx,Cy,H = ans
print(Cx,Cy,H)

Solution (Python):
N = int(input())
xyh = [[int(i) for i in input().split()] for i in range(N)]
xyh = sorted(xyh, key=lambda x: x[2], reverse=True)

for CX in range(0, 101):
    for CY in range(0, 101):
        H = -1
        for x, y, h in xyh:
            if h != 0:
                if H == -1:
                    H = abs(x - CX) + abs(y - CY) + h
                elif H != abs(x - CX) + abs(y - CY) + h:
                    break
            else:
                if H != -1 and H - abs(x - CX) - abs(y - CY) > 0:
                    break
        else:
            print(CX, CY, H)

Solution (Python):
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)
ht = a[0][2]
x = a[0][0]
y = a[0][1]
ans = True
for i in range(100+1):
    for j in range(100+1):
        h = ht + abs(x-i) + abs(y-j)
        ans = True
        for case in a:
            if not case[2] == max(h - abs(case[0] - i) - abs(case[1] - j), 0):
                ans = False
                break
        if ans:
            break
    if ans:
        break
print(i, j, h)

Solution (Python):


def func():

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

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

func()

Solution (Python):
N, = map(int, raw_input().split())
x = [0]*N
y = [0]*N
h = [0]*N
for i in range(N):
  x[i], y[i], h[i] = map(int, raw_input().split())
for cx in range(101):
  for cy in range(101):
    for i in range(N):
      if h[i]!=0:
        H = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
        break
    hit=True
    for i in range(N):
      ch = max(0, H-abs(x[i]-cx)-abs(y[i]-cy))
      if ch!=h[i]:
        hit=False
        break
    if hit:
      print cx, cy, H

Solution (Python):
import sys

N = int(input())

x = [0 for i in range(N)]
y = [0 for i in range(N)]
h = [0 for i in range(N)]

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







def dif(x,y,a,b):
    ans = int(abs(x-a) + abs(y-b))
    return(ans)


for i in range(N):
    if h[i] != 0:
        xt, yt, ht = x[i], y[i], h[i]
        break


for i in range(101):
    for j in range(101): 

        collect = True
        top = ht + dif(i, j, xt, yt)

        for k in range(N):
            h_predict = max(0, top - dif(x[k], y[k], i, j))

            if h[k] != h_predict:
                collect = False
                break

        if collect:
            print(i,j,top)
            sys.exit()

Solution (Python):
def main():
    n = int(input())
    p = [0] * n

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

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


    for x in range(0, 101):
        for y in range(0, 101):
            flag = True
            h = abs(x - p[0][0]) + abs(y - p[0][1]) + p[0][2]
            for xi, yi, hi in p:
                if hi != max([0, h - abs(x - xi) - abs(y - yi)]):
                    flag = False
                    break

            if flag:
                print('{} {} {} '.format(x, y, h))
                return
main()

Solution (Python):
import sys
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)
inf=2e31-1
for i in range(101):
    for j in range(101):
        judge=True
        H1=inf
        for k in range(n): 
            if h[k]!=0:
                H1=h[k]+abs(i-x[k])+abs(j-y[k])
                break

        for k in range(n):
            if h[k]==0:
                if H1>abs(i-x[k])+abs(j-y[k]):
                    judge=False
                    break
            else:
                H2=h[k]+abs(i-x[k])+abs(j-y[k])
                if H1!=H2:
                    judge=False
                    break
                    
        if judge:
            sys.stdout.write(str(i))
            sys.stdout.write(' ')
            sys.stdout.write(str(j))
            sys.stdout.write(' ')
            print(H1)
            sys.exit()

Solution (Python):
n = int(raw_input())
px = 0
py = 0
ph = 0
ls = []
for _ in range(n):
    x,y,h = map(int, raw_input().split())
    if ph == 0 and h != 0:
        px = x
        py = y
        ph = h
    ls.append((x,y,h))
ok = True
for cy in range(101):
    for cx in range(101):
        ch = ph + abs(cx - px) + abs(cy - py)
        ok = True
        for (x, y, h) in ls:
            if max(ch-abs(x-cx)-abs(y-cy), 0) != h:
                ok = False
                break
        if ok:
            print cx,cy,ch
            break
    if ok:
        break

Solution (Python):


INF = float('inf')


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


def solve():
    for cx in range(101):
        for cy in range(101):
            ch = D[0][0] + abs(D[0][1] - cx) + abs(D[0][2] - cy)
            for h, x, y in D:
                if h != max(ch - (abs(x - cx) + abs(y - cy)), 0):
                    break
            else:
                return cx, cy, ch


if __name__ == '__main__':
    N = int(input())
    D = []
    for i in range(N):
        x, y, h = inpl()
        D.append([h, x, y])
    D.sort()
    D.reverse()
    ans = solve()
    print(' '.join(map(str, ans)))

Solution (Python):


INF = float('inf')


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


def solve():
    for x in range(101):
        for y in range(101):
            for h in range(h_min, h_min + 201):
                for i in range(N):
                    if D[i][0] != max(h - abs(D[i][1] - x) - abs(D[i][2] - y), 0):
                        break
                else:
                    return x, y, h


if __name__ == '__main__':
    N = int(input())
    D = []
    for i in range(N):
        x, y, h = inpl()
        D.append([h, x, y])

    h_min = max(D)[0]
    ans = solve()
    print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
p = []
for i in range(N):
    X1, Y1, H1 = map(int, input().split())
    if H1 != 0:
        p.append([X1, Y1, H1])

if len(p) == 1:
    print(p[0][0], p[0][1], p[0][2])
    exit()


for i in range(101):
    for j in range(101):
        h = -1
        fg = True
        for t in p:
            if h == -1:
                h = t[2] + abs(i - t[0]) + abs(j - t[1])

            else:
                ht = t[2] + abs(i - t[0]) + abs(j - t[1])
                if h == ht:
                    h = ht
                else:
                    fg = False
                    break
        if fg:
            print(i, j, h)

Solution (Python):
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)

Solution (Python):
N = int(input())
p = []
for i in range(N):
    X1, Y1, H1 = map(int, input().split())
    if H1 != 0:
        p.append([X1, Y1, H1])

if len(p) == 1:
    print(p[0][0], p[0][1], p[0][2])
    exit()


for i in range(101):
    for j in range(101):
        h = -1
        fg = True
        for t in p:
            if h == -1:
                h = t[2] + abs(i - t[0]) + abs(j - t[1])

            else:
                ht = t[2] + abs(i - t[0]) + abs(j - t[1])
                if h == ht:
                    h = ht
                else:
                    fg = False
                    break
        if fg:
            print(i, j, h)
            exit()

Solution (Python):
N = int(input())
x = []
y = []
h = []
for i in range(N):
    a,b,c = [int(hoge) for hoge in input().split()]
    x.append(a)
    y.append(b)
    h.append(c)

cx = 0
cy = 0
H = 0
done_flag = False

for i in range(101):
    for j in range(101):
        
        cand_h = []
        min_h = []

        for k in range(N):
            if h[k] != 0:
                cand_h.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            else:
                min_h.append(abs(x[k] - i) + abs(y[k] - j))
                
        min_h = min(min_h) if len(min_h) > 0 else 100000000000
    
        if len(set(cand_h)) == 1 and list(set(cand_h))[0] <= min_h:
            print("{} {} {}".format(i, j, cand_h[0]))
            done_flag = True
            break
    if done_flag:
        break

Solution (Python):
n = int(input())
lis = []
for i in range(n):
  a = list(map(int,input().split()))
  if a[2] != 0:lis.append(a)
if len(lis) == 1:
  print(lis[0][0],lis[0][1],lis[0][2])
  exit()
for x in range(101):
  for y in range(101):
    co = abs(x -lis[0][0])+abs(y -lis[0][1])+lis[0][2]
    for j in range(1,len(lis)):
      if co != abs(x -lis[j][0])+abs(y -lis[j][1])+lis[j][2]:
        break
      if j == len(lis)-1:
        print(x,y,co)
        exit()

Solution (Python):
n=int(input())
lst=[]
for i in range(n):
    a=list(map(int,input().split()))
    if a[2]!=0:lst.append(a)
if len(lst)==1:
    print(*lst[0])
    exit()
for i in range(101):
    for j in range(101):
        h=abs(i-lst[0][0])+abs(j-lst[0][1])+lst[0][2]
        for k in lst[1:]:
            if h!=abs(i-k[0])+abs(j-k[1])+k[2]:break
        else:
            print(i,j,h)
            exit()

Solution (Python):
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]

li.sort(key=lambda x: x[2])
a,b,c = li[-1]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j),0) for i,j,k in li):
            print(x,y,h)
            exit()

Solution (Python):

n = int(input())
data = []
h_ = 0
for i in range(n):
    data.append(list(map(int, input().split())))
data = sorted(data, key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        for j in range(n):
            if j == 0:
                h_ = data[0][2] + abs(cx - data[0][0]) + abs(cy - data[0][1])
            else:
                if data[j][2] == max(0, h_ - abs(cx - data[j][0]) - abs(cy - data[j][1])):
                    if j == n - 1:
                        print('{0} {1} {2}'.format(cx, cy, h_))
                        exit()
                    else:
                        continue
                else:
                    break

Solution (Python):
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]

for i in range(n):
    if li[i][2] != 0:
        h1 = li[i][2]
        break

flag = True
flag2 = False

for i in range(10**9):
    if flag2 == True: break
    for X in range(101):
        for Y in range(101):
            h = h1 + i
            flag = True
            for j in range(n):
                if max(h - abs(li[j][0]-X) - abs(li[j][1]-Y),0) != li[j][2]:
                    flag = False
                    break
            if flag == True:
                print(X,Y,h)
                flag2 = True
            if flag2 == True: break
            h = h1 - i
            flag = True
            for j in range(n):
                if max(h - abs(li[j][0]-X) - abs(li[j][1]-Y),0) != li[j][2]:
                    flag = False
                    break
            if flag == True:
                print(X,Y,h)
                flag2 = True