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


import numpy as np
N = int(input())
U = 100
XYH = np.array([[int(x) for x in input().split()] for _ in range(N)])
XYH = XYH[np.argsort(-XYH[:,2])] 

x0,y0,h0 = XYH[0]
dx = np.abs(np.arange(U+1) - x0)
dy = np.abs(np.arange(U+1) - y0)

H = dx[:,None] + dy[None,:] + h0
possible = np.full_like(H, True)

for x,y,h in XYH[1:]:
  dx = np.abs(np.arange(U+1) - x)
  dy = np.abs(np.arange(U+1) - y)
  possible &= (np.maximum(H-dx[:,None]-dy[None,:],0) == h)

nz = possible.nonzero()
x,y = nz[0][0], nz[1][0]
h = H[x,y]
print(x,y,h)

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

for Cx in range(101):        
    for Cy in range(101):    
        flg=True
        k=0
        while xyh[k][2]+abs(xyh[k][0]-Cx)+abs(xyh[k][1]-Cy) <1 or xyh[k][2]<1:
            k+=1
        H=xyh[k][2]+abs(xyh[k][0]-Cx)+abs(xyh[k][1]-Cy)
        for i in range(len(xyh)):
            if max(H-abs(xyh[i][0]-Cx)-abs(xyh[i][1]-Cy),0)!=xyh[i][2]:
                flg=False
        if flg:
            print(Cx,Cy,H)
            exit()

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
ansx = 0
ansy = 0
ansh = 0
for x in range(101):
  for y in range(101):
    hset = set()
    for i in range(N):
      xyhi = xyh[i]
      if xyhi[2] == 0:
        continue
      hset.add(abs(xyhi[0]-x) + abs(xyhi[1]-y) + xyhi[2])

    if len(hset) == 1 and list(hset)[0] != 0:
      flag = True
      for i in range(N):
        xyhi = xyh[i]
        if xyhi[2] != 0:
          continue
        elif xyhi[2] == 0 and max(list(hset)[0] - abs(xyhi[0]-x) - abs(xyhi[1]-y), 0) == 0:
          continue
        flag = False
        break
      if flag:
        ansx = x
        ansy = y
        ansh = list(hset)[0]

print(ansx, ansy, ansh)

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



point = []
for n in range(N):
    if H[n] != 0:
        point = [X[n], Y[n], H[n]]
        break

ans = []
same = True
for i in range(101):
    for j in range(101):
        same = True
        height = point[2] + abs(point[0] - i) + abs(point[1] - j)
        for n in range(N):
            x = X[n]
            y = Y[n]
            h = H[n]
            candidate = max(height - abs(x - i) - abs(y - j), 0)
            if candidate != h:
                same = False
                break
        if same:
            ans = [i, j, height]
            break
    if same:
        break

if same:
    print(*ans)

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

Solution (Python):

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

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

A = []
for i in range(N):
    x,y,h = map(int, input().split())
    A.append([x,y,h])
H = max([h for x,y,h in A])
while True:
    for i in range(100+1):
        for j in range(100+1):
            for x,y,h in A:
                tx, ty = abs(x-i), abs(y-j)
                if max(H - tx - ty, 0) != h:
                    break
            else:
                print(i,j,H)
                exit()
    H += 1

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

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

for i in range(N):
    if h[i] > 0:
        xx = x[i]
        yy = y[i]
        hh = h[i]

for cx in range(101):
    for cy in range(101):
        H = hh + abs(xx - cx) + abs(yy - cy)
        ok = True
        for i in range(N):
            if h[i] != max(H-abs(x[i] - cx) - abs(y[i] - cy), 0):
                ok = False
        if ok:
            print(cx, cy, H)

Solution (Python):


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

ans = 0
ans_cx = 0
ans_cy = 0
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)
                break
        
        can_be_ans = True
        for i in range(N):
            if h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0):
                can_be_ans = False
                break

        if can_be_ans:
            if ans < H:
                ans = H
                ans_cx = cx
                ans_cy = cy

print(ans_cx, ans_cy, ans)

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

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

x = []
y = []
h = []

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

for i in range(n):
    if h[i] >= 1:
        t = i
        break

for cy in range(101):
    for cx in range(101):
        H = h[t] + abs(x[t] - cx) + abs(y[t] - cy)
        for i in range(n):
            if h[i] != max(H - abs(cx - x[i]) - abs(cy - y[i]), 0):
                break
            if i == n - 1:
                print('{} {} {} '.format(cx, cy, H))

Solution (Python):
N = int(input())
hint_array = [list(map(int, input().split())) for i in range(N)]
hint_array = sorted(hint_array, key=lambda x: -x[2])
can_center_array = [[0] * 101 for i in range(101)]

x, y, h = hint_array[0]
for i in range(101):
    for j in range(101):
        can_center_array[i][j] = h + abs(i - x) + abs(j - y)


for hint in hint_array[1:]:
    x, y, h = hint
    
    ans_x = 0
    ans_y = 0
    ans_h = 0
    can_put_num = 0
    for i in range(101):
        for j in range(101):
            if can_center_array[i][j] == 0:
                continue
            if can_center_array[i][j] == (h + abs(i - x) + abs(j - y)):
                can_put_num += 1
                if can_put_num == 1:
                    ans_x = i
                    ans_y = j
                    ans_h = can_center_array[i][j]
            else:
                can_center_array[i][j] = 0
    if can_put_num == 1:
        print(ans_x, ans_y, ans_h)
        exit()

Solution (Python):
import numpy as np
from functools import reduce

def dist(array,xyh):
    return (abs(array.real-xyh[0])+abs(array.imag-xyh[1])+xyh[2])

def dist2(array,xyh,dxyh):
    if xyh[2]>0:
        return dist(array,xyh) == dxyh
    else:
        return dist(array,xyh) >= dxyh

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

a=np.arange(101)+np.arange(101).reshape(101,1)*1j
dxyh=dist(a,xyh[0])

ans=np.where(reduce(lambda a,b:a&b,[dist2(a,xyh[i],dxyh) for i in range(1,N)]) == True)
print(ans[1][0],ans[0][0],int(dxyh[ans[0][0],ans[1][0]]))

Solution (Python):
def resolve():
    N = int(input())
    conds = [list(map(int, input().split(" "))) for i in range(N)]
    
    first = sorted(conds, reverse=True, key=lambda x:x[2])[0]
    for cx in range(101):
        for cy in range(101):
            H = abs(first[0]-cx)+abs(first[1]-cy)+first[2]
            for n in range(N):
                cond = conds[n]
                if cond[2] == 0:
                    if abs(cond[0]-cx)+abs(cond[1]-cy) < H: 
                        break
                elif abs(cond[0]-cx)+abs(cond[1]-cy)+cond[2] != H:
                    break
            else:
                print("{} {} {}".format(cx, cy, H))
                exit()


if '__main__' == __name__:
    resolve()

Solution (Python):
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]
XYH.sort(key = lambda x:x[2], reverse = 1)
mx,my,mh = XYH[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 XYH):
            print(Cx,Cy,H)
            break

Solution (Python):
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]
XYH.sort(key = lambda x:x[2], reverse = 1)
for Cx in range(101):
    for Cy in range(101):
        H = XYH[0][2]+abs(XYH[0][0]-Cx)+abs(XYH[0][1]-Cy)
        cnt = 0
        for X,Y,h in XYH:
            if h == max(H-abs(X-Cx)-abs(Y-Cy),0):
                    cnt += 1
        if cnt == N:
            print(Cx,Cy,H)
            break

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

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

H0 = xyh[-1][2]

for H in range(H0,H0+200):
    for CX in range(101):
        for CY in range(101):
            for n in range(N):
                if max(0, H-abs(xyh[n][0]-CX)-abs(xyh[n][1]-CY)) != xyh[n][2]:
                    break
            else:
                print(CX, CY, H)
                break
        else:
            continue
        break
    else:
        continue
    break

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
inl = [LI() for i in range(N)]
inl.sort(key=lambda x: x[2], reverse=True)

st=set()
prevset=set()
for x,y,h in inl:
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()



inl = [LI() for i in range(N)]
inl.sort(key=lambda x: x[2], reverse=True)

st=set()
prevset=set()
for x,y,h in inl:
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

H = np.array(H)
X = np.array(X)
Y = np.array(Y)
base_i = np.where(H > 0)[0][0]

ans = []
for cx in range(101):
    for cy in range(101):
        ch = abs(X[base_i] - cx) + abs(Y[base_i] - cy) + H[base_i]
        ok = True
        for x, y, h in zip(X, Y, H):
            if h > 0 and ch != abs(x - cx) + abs(y - cy) + h:
                ok = False
                break
            if h == 0 and ch > abs(x - cx) + abs(y - cy):
                ok = False
                break
        if ok:
            ans = cx, cy, ch
print(*ans)

Solution (Python):
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
for cx in range(101):
    for cy in range(101):

        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            print(cx,cy,h)
            break

Solution (Python):
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i

dct = 0
for cx in range(101):
    for cy in range(101):
        if dct:
            break
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            print(cx,cy,h)

Solution (Python):
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
Cx,Cy,H = -1,-1,-1
        
for cx in range(101):
    for cy in range(101):
        if H >= 0:
            break
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            Cx,Cy,H = cx,cy,h

print(Cx,Cy,H)

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

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

for cx in range(101):
  for cy in range(101):
    h = abs(xyh_hNonzero[0] - cx) + abs(xyh_hNonzero[1] - cy) + xyh_hNonzero[2]
    for i in range(N):
      if xyh[i][2] == 0:
        if abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) < h:
          break
      elif abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2] != h:
        break
    else:
      print(' '.join(map(str, [cx,cy,h])))
      exit()
else:
  raise Exception('aaa!!!')

Solution (Python):
N = int(input())
d = []
for j in range(N):
    X, Y, H = map(int,input().split())
    d.append([X, Y, H])
    if H != 0:
        a = [X, Y, H]
for x in range(101):
    for y in range(101):
        flag = True
        h = a[2] + abs(a[0] - x) + abs(a[1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y), 0):
                flag = False
                break

        if flag:
            print(x, y, h)
            exit()

Solution (Python):
n = int(input())
lis = [list(map(int,input().split())) for x in range(n)]
lis = sorted(lis,key=lambda x:x[2])

bx,by,bh = -1,-1,-1
for cy in range(101):
    for cx in range(101):
        if bh >= 0:break
        
        h = abs(lis[-1][0] - cx) + abs(lis[-1][1] - cy) + lis[-1][2]	
        ok = True
        for li in lis:
            
            if max(h - abs(li[0]-cx) - abs(li[1]-cy),0) != li[2]:
                ok = False
                break
        if ok :
            bx,by,bh = cx,cy,h
print(bx,by,bh)

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())


N = int(input())



inf = [list(mi()) for _ in range(N)]

from copy import deepcopy


for eachinf in inf:
  if eachinf[2] >= 1:
    ex = deepcopy(eachinf)
    break

import itertools

for px, py in itertools.product(range(101), repeat=2):
  
  ph = ex[2] + abs(ex[0] - px) + abs(ex[1] - py)
  isrightans = 1
  for x, y, h in inf:
    if h != max(ph - abs(x - px) - abs(y - py),0):
      isrightans = 0
      break
  if isrightans:
    print(px, py, ph)
    exit()

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

ans = ''
for i in range(101):
    for j in range(101):
        m = 1000000001

        for k in range(n):
            x = abs(l[k][0] - i)
            y = abs(l[k][1] - j)

            if x + y < m:
                m = x + y
                hhh = l[k][2] + x + y

        b = True
        for k in range(n):
            x = abs(l[k][0] - i)
            y = abs(l[k][1] - j)

            if l[k][2] != 0 and x + y + l[k][2] != hhh:
                b = False
                break

        if b:
            ans = str(i) + ' ' + str(j) + ' ' + str(hhh)

print(ans)

Solution (Python):
l=[list(map(int,input().split())) for i in range(int(input()))]
l.sort(key=lambda x:x[2])
for i in range(0,101):
    for j in range(0,101):
        h=l[-1][2]+abs(i-l[-1][0])+abs(j-l[-1][1])
        for a,b,c in l[:-1]:
            if c!=max(0,h-abs(i-a)-abs(j-b)):break
        else:
            print(i,j,h)
            exit()

Solution (Python):
N = int(input())
xyh = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[2])
for Cx in range(101):
  mx, my, mh = xyh[0]
  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 xyh)):
      print(Cx, Cy, H)
      exit()

Solution (Python):
n=int(input())
l=[[]]*n
for i in range(n):
    l[i]=list(map(int,input().split()))
lst=sorted(l,key=lambda x:-x[2])
flag=False

for i in range(0,101):
    if flag:
        break
    for j in range(0,101):
        if flag:
            break
        tmp=lst[0][2]+abs(lst[0][0]-i)+abs(lst[0][1]-j)
        for k in range(n):
            if lst[k][2]!=0:
            
                sum=abs(lst[k][0]-i)+abs(lst[k][1]-j)
                H=lst[k][2]+sum
                if tmp!=H :
                    break
                a,b,c=i,j,H
                if k==n-1:
                    flag=True
                    print(i,j,H,)
                    break
            
            else:
                
                if lst[k][2]!=max(c-abs(a-lst[k][0])-abs(b-lst[k][1]),0):
                    
                    break
                if k==n-1:
                    flag=True
                    print(i,j,H)
                    break

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

for cy in range(101):
	for cx in range(101):
		ch = None
		for x, y, h in XYH:
			if 0 == h:
				continue
			dy, dx = abs(y - cy), abs(x - cx)
			ch = h + dy + dx
		if all([h == max(0, ch - abs(y - cy) - abs(x - cx)) for x, y, h in XYH]):
			print(cx, cy, ch)
			exit()

Solution (Python):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
XYH = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
for x, y, h in XYH:
    for cx in range(101):
        for cy in range(101):
            if h == 0:
                continue
            else:
                H = h + abs(cx-x) + abs(cy-y)
                if all([th == max(H-abs(cx-tx)-abs(cy-ty), 0) for tx, ty, th in XYH]):
                    print(cx, cy, H)
                    exit()

Solution (Python):
N = int(input())
cod = []
rx, ry, rh = 0, 0, 0
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        rx, ry, rh = x, y, h
    cod.append([x, y, h])

for i in range(101):
    for j in range(101):
        H = rh+abs(rx-i)+abs(ry-j)
        flg = True
        for x, y, h in cod:
            if max(H - abs(x-i) - abs(y-j), 0) != h:
                flg = False
                break
        if flg:
            print(i, j, H)
            quit()

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

for x,y,h in lst:
    if h != 0:
        break

for cx in range(101):
    for cy in range(101):
        H = abs(cx-x) + abs(cy-y) + h
        if all(hi == max(H-abs(cx-xi)-abs(cy-yi),0) for xi,yi,hi in lst):
            print(cx,cy,H)
            exit()

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

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

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

        if all([h == max(ch - abs(cy - y) - abs(cx - x), 0) for x, y, h in xyhs[1:]]):
            print(cx, cy, ch)
            exit()

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

minH = 0
for xyh in xyhs:
  minH = max(minH, xyh[2])

cx, cy, H = 0, 0, 0
for h in range(minH, minH+200):
  if H != 0: break
  for x in range(101):
    if H != 0: break
    for y in range(101):
      if H != 0: break
      for xyh in xyhs:
        if max(h - abs(xyh[0]-x) - abs(xyh[1]-y), 0) != xyh[2]:
          break
      else:
        cx, cy, H = x, y, h
        break

print(cx, cy, H)

Solution (Python):
import sys

N = int(input())
pyramid = []

for _ in range(N):
    pyramid.append(list(map(int,input().split())))


for cx in range(101):
    for cy in range(101):
        H = []
        for k in range(N):
            if pyramid[k][2] != 0:
                H.append(abs(pyramid[k][0]-cx) + abs(pyramid[k][1]-cy) + pyramid[k][2])
        if len(set(H)) == 1:
            for k in range(N):
                if pyramid[k][2] != max(H[0]-abs(pyramid[k][0]-cx)-abs(pyramid[k][1]-cy),0):
                    break
            if k == N-1:
                print(cx,cy,H[0])
                sys.exit()

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

for x, y, h in l:
    if h != 0:
        break

for Cx in range(0, 101):
    for Cy in range(0, 101):
        H = abs(Cx-x) + abs(Cy-y) + h
        if all(hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l):
            print(Cx, Cy, H)
            exit()

Solution (Python):
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())
    
ans_x = 0 
ans_y = 0  
ans_h = 0

for i in range(101):
    for j in range(101):
        H_candidate = []
        for k in range(n):
            if h[k] != 0:
                H_candidate.append(abs(x[k]-i)+abs(y[k]-j)+h[k])
        if len(set(H_candidate)) == 1:
            flag = True
            for k in range(n):
                if h[k] != max(H_candidate[0]-abs(x[k]-i)-abs(y[k]-j),0):
                    flag = False
            if flag:
                ans_x = i
                ans_y = j
                ans_h = H_candidate[0]
print(ans_x,ans_y,ans_h)

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            if all(hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l):
                print(Cx, Cy, H)
                exit()

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            if all([hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l]):
                print(Cx, Cy, H)
                exit()

Solution (Python):
from collections import defaultdict

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            if all([hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l]):
                print(Cx, Cy, H)
                exit()

Solution (Python):
from collections import defaultdict

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            ans = True
            H = abs(Cx-x) + abs(Cy-y) + h
            for xx, yy, hh in l:
                if hh != max(H - abs(Cx-xx) - abs(Cy-yy), 0):
                    ans = False
            if ans:
              print(Cx, Cy, H)
              exit()

Solution (Python):
n=int(input())
X=[list(map(int,input().split())) for _ in range(n)]
X.sort(key=lambda x:x[2])
a,b,c=X[-1]
for px in range(101):
    for py in range(101):
        H=abs(px-a)+abs(py-b)+c
        if all(h==max(H-abs(x-px)-abs(y-py),0) for x,y,h in X):
            print(px,py,H)
            break

Solution (Python):

N = int(input())

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




ans_x, ans_y, ans_h = -1,-1,-1
indexes = [i for i, x in enumerate(xyh) if x[2] > 0]

for cx in range(101):
    for cy in range(101):
        H = xyh[indexes[-1]][2] + abs(xyh[indexes[-1]][0] - cx) + abs(xyh[indexes[-1]][1] - cy)
        match = 1
        for i in range(N):
            h = H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy)
            if xyh[i][2] > 0 and (h != xyh[i][2]):
                match = 0
            if xyh[i][2] == 0 and (H > (abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy)) ):
                match = 0
        
        if match:
            ans_x = cx
            ans_y = cy
            ans_h = H
            
print(str(ans_x) + ' ' + str(ans_y) + ' ' + str(ans_h))

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    pos = [f() for i in range(n)]

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


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

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

            if ok:
                print(i,j,h)
                return




solve()

Solution (Python):
import sys

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

answer = (-1, -1, -1)
for cx in range(101):
    for cy in range(101):
        candidate = -1
        counter = 0
        for i in info:
            if i[2] != 0:
                H = i[2] + abs(i[0] - cx) + abs(i[1] - cy)
                counter += 1
                if candidate == -1:
                    candidate = H
                elif candidate != H:
                    candidate = -1
                    break
        if counter == 1:
            for i in info:
                if i[2] == 1:
                    answer = (i[0], i[1], i[2])
            break        
        elif candidate > 0:
            answer = (cx, cy, candidate)
            break
    if answer[2] > 0:
        break


print(answer[0], answer[1], answer[2])

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

for H in range(XYH[0][2],XYH[0][2]+110):
    for Cx in range(101):
        for Cy in range(101):
            if all(h==max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in XYH):
                a=H;b=Cx;c=Cy
                break
print(b,c,a)

Solution (Python):
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    X,Y,H = map(int,input().split())
    x += [X]
    y += [Y]
    h += [H]
a = 0
while h[a] == 0:
    a += 1 
    if a == N:
        for i in range(101):
            if i not in x:  X = i
        for i in range(101):
            if i not in y:  Y = i
        print(X,Y,1)
        exit()

for cx in range(101):
    for cy in range(101):
        H = h[a] + abs(x[a]-cx) + abs(y[a]-cy)
        ans = True
        R = list(range(N))[0:a] + list(range(N))[a+1:N]
        for i in R:
            if h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy),0):
                ans = False
                break
        if ans:
            print(cx,cy,H)
            break
    else:
        continue
    break