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):
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)

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

for i in range(101):
    for j in range(101):
        H = dist(i, j, P[0][1], P[0][2], P[0][0])
        for p in P[1:]:
            if max(H - abs(p[1]-i)-abs(p[2]-j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

from operator import itemgetter
c = sorted(c,key=itemgetter(2),reverse=True)
p,q,r = c[0]
end = c[-1]
c = c[1:]
for i in range(101):
  for j in range(101):
    if r > 0:
      chk = abs(p-i)+abs(q-j)+r
    else:
      chk = 1
    for num,k in enumerate(c):
      x,y,h = k
      if h == 0:
        if abs(x-i)+abs(y-j) < chk:
          break
      else:
        if abs(x-i)+abs(y-j)+h != chk:
          break
      if k == end:
        ans = (i,j,chk)

print(*ans)

Solution (Python):
n = int(input())
hist = [tuple(map(int,input().split())) for _ in range(n)]
hist.sort(key=lambda x: x[2], reverse=1)

cands = []
x0,y0,h0 = hist[0]

for i in range(0,101):
  for j in range(0,101):
    if h0 == 0:
      cands.append((i,j,1))
    else:
      cands.append((i,j, h0+abs(i-x0)+abs(j-y0)))
    
for X,Y,H in cands:
  for x,y,h in hist:
    if max(H-abs(X-x)-abs(Y-y),0) == h:
      continue
    else:
      break
  else:
    print(X,Y,H)
    break

Solution (Python):
n = int(input())
t = [list(map(int,input().split())) for i in range(n)]
for x,y,h in t:
    if h > 0:
        a = [x,y,h]            

for cx in range(101):
    for cy in range(101):
        flag = True
        ch = abs(a[0]-cx) + abs(a[1] - cy) + a[2]     
        for x,y,h in t:
            if h != max(ch - abs(x - cx) - abs(y - cy),0):    
                flag = False
                break
        if flag:
            print(cx,cy,ch)
            exit()

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    vx = []
    vy = []
    vh = []
    for i in range(n):
        x,y,h = readInts()
        vx.append(x)
        vy.append(y)
        vh.append(h)
        if h > 0:
            si = i
    
    
    
    resx,resy,resh = -1,-1,-1
    for x in range(101):
        for y in range(101):
            h = vh[si] + abs(x - vx[si]) + abs(y - vy[si])
            ok = True
            for i in range(n):
                if vh[i] > 0 and h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]):
                    ok = False
                if vh[i] == 0 and h > abs(x - vx[i]) + abs(y - vy[i]):
                    ok = False
            if ok:
                resx = x
                resy = y
                resh = h
    print(resx,resy,resh)
if __name__ == '__main__':
  main()

Solution (Python):

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





for xi,yi,hi in xyh:
    if hi>0:
        memo = [xi,yi,hi]
        break

for cx in range(0,101):
    for cy in range(0,101):
        flg = True
        
        ch = abs(memo[0]-cx)+abs(memo[1]-cy)+memo[2]
        for xi,yi,hi in xyh:
            
            if hi!=max(ch-abs(xi-cx)-abs(yi-cy),0):
                flg = False
                break
        if flg:
            print("{} {} {}".format(cx,cy,ch))
            import sys
            sys.exit()

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
X, Y, H = [0] * N, [0] * N, [0] * N

notzero = -1
for i in range(N):
    X[i], Y[i], H[i] = map(int, input().split())
    if H[i] != 0:
        notzero = i

def solve():
    for x in range(101):
        for y in range(101):
            cx, cy = x, y
            h = H[notzero] + abs(X[notzero] - cx) + abs(Y[notzero] - cy)
            ok = True
            for i in range(N):
                ok &= max(0, h - abs(X[i] - cx) - abs(Y[i] - cy)) == H[i]
            if ok:
                return cx, cy, h

print(*solve())

Solution (Python):
from operator import itemgetter

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

xyhs.sort(key=itemgetter(2), reverse=True)

lsts = []

xyh = xyhs[0]
for cy in range(101):
    for cx in range(101):
        lsts.append([cx, cy, xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy)]) 

for xyh in xyhs[1:]:
    lst = []
    while len(lsts):      
        p = lsts.pop()
        h = xyh[2] + abs(xyh[0] - p[0]) + abs(xyh[1] - p[1])
        if p[2] == h:
            lst.append(p)
    lsts = lst[:]
    if len(lsts) == 1: break
print(*lsts[0])

Solution (Python):
n = int(input())
pos=[]
for i in range(n):
  x,y,h = map(int, input().split())
  pos.append([x,y,h])

pos = sorted(pos, key=lambda x: x[2])
tx,ty,th = pos[-1]
def solve():
  for cx in range(101):
    for cy in range(101):
      H = th+abs(tx-cx)+abs(ty-cy)
      for x,y,h in pos:
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          break
      else:
        return(cx,cy,H)

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

Solution (Python):

import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    for cx in range(101):
        for cy in range(101):
            chs = {
                hi + abs(xi - cx) + abs(yi - cy)
                for xi, yi, hi in zip(x, y, h)
                if hi != 0
            }
            if len(chs) != 1:
                continue
            ch, = chs
            if any(max(ch - abs(xi - cx) - abs(yi - cy), 0) != hi
                   for xi, yi, hi in zip(x, y, h)):
                print(cx, cy, ch, file=sys.stderr)
                continue
            print(cx, cy, ch)
            return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    x = [int()] * (N)  
    y = [int()] * (N)  
    h = [int()] * (N)  
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)


if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    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 Cx in range(101):
        for Cy in range(101):
            H = INF
            for i in range(N):
                if h[i] > 0:
                    H = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)

            flg = True
            for i in range(N):
                if max(H - abs(x[i]-Cx) - abs(y[i]-Cy), 0) != h[i]:
                    flg = False
                    break
            if flg:
                print(" ".join([str(Cx), str(Cy), str(H)]))
                return


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
xyh=[list(map(int,input().split()))[::-1]for _ in range(n)]
xyh.sort(reverse=1)
for xx in range(101):
  for yy in range(101):
    f=True
    hh=xyh[0][0]+abs(xx-xyh[0][2])+abs(yy-xyh[0][1])
    for h,y,x in xyh[1:]:
      if max(hh-abs(x-xx)-abs(y-yy),0)!=h:f=False
    if f:print(xx,yy,hh);exit()

Solution (Python):

a = abs
z = [list(map(int, input().split())) for _ in range(int(input()))]
z.sort(key = lambda x: x[2])
x, y, h = z[-1]
r = range(101)
for c in r:
    for d in r:
        H = h + a(c-x) + a(d-y)
        if all(u == max(H - a(s-c) - a(t-d), 0) for s, t, u in z):
            print(c, d, H)
            exit()

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

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if xyhn[k][2] > 0 and tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
            if xyhn[k][2] == 0 and abs(cx - xyhn[k][0]) + abs(cy - xyhn[k][1]) < tmp_h:
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))

Solution (Python):

cc=0
if cc==0:
    n=int(input())
    xyh=[[0]*3 for i in range(n)]
    for i in range(n):
        xyh[i]=list(map(int,input().split()))
        if xyh[i][2]>=1:
            px=xyh[i][0]
            py=xyh[i][1]
            ph=xyh[i][2]
else:
    n=4
    px=3
    py=2
    ph=5
    xyh=[[0]*3 for i in range(n)]
    xyh[0]=[2,3,5]
    xyh[1]=[2,1,5]
    xyh[2]=[1,2,5]
    xyh[3]=[3,2,5]
        
yn=""
for cx in range(102):
    for cy in range(102):
        h=ph+abs(px-cx)+abs(py-cy)
        yn=""
        for i in range(n):
            if xyh[i][2]!=max(0,h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy)):
                yn="No"
                break
        if yn=="No":

            continue
        else:

            yn="Yes"
            break

    if yn=="Yes":
        break
    
print(cx,cy,h)

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


ansC = [0,0]
for i in range(0,100+1):
  for j in range(0,100+1):
    Cx = i
    Cy = j
    
    for k in range(N):
      X,Y,h = l[k]
      c = 0
      if h >= 1:
        H = h + abs(X-Cx) + abs(Y-Cy)
        for k in range(N):
          X,Y,h = l[k]
          if h != max(H-abs(X-Cx)-abs(Y-Cy),0):
            break
          if k == N-1:  
            print(Cx,Cy,H)
            sys.exit()

Solution (Python):
import sys
import collections
from math import ceil

ma = lambda : map(int,input().split())
ni = lambda : int(input())
def height(H,cy,cx,y,x):
    return max(H- abs(cy-y) - abs(cx-x),0)

n = ni()
hs = [[-1]*101 for i in range(101)]
nx,ny = -1,-1
ls = []

for i in range(n):
    x,y,h = ma()
    hs[y][x] = h
    if h>0:
        nx,ny = x,y
    ls.append((y,x))

for cy in range(101):
    for cx in range(101):
        H = hs[ny][nx] + abs(cy-ny) + abs(cx-nx)
        for y,x in ls:
            if hs[y][x]!= height(H,cy,cx,y,x):
                break
        else:print(cx,cy,H)

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

Solution (Python):
import sys
import math  
import bisect  
import queue  


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    X = []
    Y = []
    H = []
    si = -1
    for i in range(N):
        x, y, h = map(int, input().split())
        X.append(x)
        Y.append(y)
        H.append(h)
        if h > 0:
            si = i

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


if __name__ == '__main__':
    main()

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
XYH = [lr() for _ in range(N)]
height = [x for x in XYH if x[2] > 0]
zero = [x for x in XYH if x[2] == 0]
answer = None
for x in range(101):
    for y in range(101):
        bl = True
        top = height[0]
        cand = abs(x-top[0]) + abs(y-top[1]) + top[2]
        for x2, y2, h in height[1:]:
            temp = abs(x-x2) + abs(y-y2) + h
            if cand != temp:
                bl = False
                break
        if not bl:
            continue
        for x2, y2, h in zero:
            temp = abs(x-x2) + abs(y-y2) + h
            if temp < cand:
                bl = False
                break
        if bl:
            answer = (x, y, cand)

print(*answer)

Solution (Python):
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = [tuple(map(int, input().split())) for _ in range(n)]
grids = [(i, j) for i in range(101) for j in range(101)]
for x, y, h in coords:
    if h > 0:
        break    
for xj, yj in grids:
    flag = True
    base = dis(x, xj, y, yj) + h
    for xi, yi, hi in coords:
        if hi != max(base-abs(xi-xj)-abs(yi-yj), 0):
            flag = False
    if flag:
        break
print(xj, yj, dis(x, xj, y, yj) + h)

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


height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            _h = max(candidate - abs(x - cx) - abs(y - cy), 0)
            if h != _h:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

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


height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            _h = candidate - abs(x - cx) - abs(y - cy)
            if h == 0 and _h <= 0: continue
            if not h == _h:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

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


height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            _h = candidate - abs(x - cx) - abs(y - cy)
            if h == 0 and _h <= 0: continue
            if not h == _h:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

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):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
xyh = [list(map(int, readline().split())) for _ in range(n)]
xyh.sort(key=lambda x: -x[2])
for dx in range(101):
    for dy in range(101):
        check = abs(xyh[0][0] - dx) + abs(xyh[0][1] - dy) + xyh[0][2]
        for x, y, h in xyh[1:]:
            if max(check - abs(x - dx) - abs(y - dy), 0) != h:
                break
        else:
            print(dx, dy, check)
            exit()

Solution (Python):


def main():
    N  = int(input())
    P = []
    for i in range(N):
        x, y, h = map(int, input().split())
        P.append([h, x, y])
    P.sort(reverse = True)

    for x in range(101):
        for y in range(101):
            distance =abs(x-P[0][1]) + abs(y-P[0][2]) + P[0][0]
            for p in P[1:]:
                if max(distance - abs(x-p[1]) - abs(y-p[2]), 0) !=  p[0]:
                    break
            else:
                print(x, y , distance)
                return

if __name__ == "__main__":
    main()

Solution (Python):
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)

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

for i in range(101):
    for j in range(101):
        H = dist(i, j, P[0][1], P[0][2], P[0][0])
        for p in P[1:]:
            if max(H - abs(p[1]-i)-abs(p[2]-j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break

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())
mn_h=min(h)
mx_h=max(h)
for C_x in range(101):
  for C_y in range(101):
    for i in range(n):
      H=h[i]+abs(x[i]-C_x)+abs(y[i]-C_y)
      if H>0:
        if all(max(H-abs(x[j]-C_x)-abs(y[j]-C_y),0)==h[j] for j in range(n)):
          print(C_x,C_y,H)
          exit()

Solution (Python):


import math
import io

data = int(input())

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

n, m, k = list(filter(lambda n: n[2], array))[0]

for i in range(101):
  for j in range(101):
    kite = k + abs(n-i) + abs(m-j)
    if all(max(kite-abs(t[0]-i)-abs(t[1]-j), 0) == t[2] for t in array):
      print(i,j,kite)

Solution (Python):
import sys

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


def find_height(cx, cy):
    upperbound = 10 ** 12
    summit = None
    for x, y, h in obs:
        s = h + abs(cx - x) + abs(cy - y)
        if s < lowerbound:
            return None
        if h == 0:
            upperbound = min(upperbound, s)
        elif summit is None:
            summit = s
        elif summit != s:
            return None
        if summit is not None and (summit > upperbound or summit < lowerbound):
            return None
    return summit


for cx in range(0, 101):
    for cy in range(0, 101):
        ch = find_height(cx, cy)
        if ch is not None:
            print(cx, cy, ch)
            sys.exit()

Solution (Python):
def main():
  N = int(input())
  xyh = [[int(_) for _ in input().split()] for __ in range(N)]
  for cx in range(0, 101):
    for cy in range(0, 101):
      H = set()
      for x, y, h in xyh:
        if h == 0:
          continue
        H.add(abs(cx - x) + abs(cy - y) + h)
      if len(H) == 1:
        ok = True
        hh = list(H)[0]
        for x, y, h in xyh:
          if h == 0:
            if max(hh - abs(cx - x) - abs(cy - y), 0) == 0:
              continue
            else:
              ok = False
        if ok:
          print(cx, cy, *H)
          break
    else:
      continue
    break
  return

if __name__ == '__main__':
  main()

Solution (Python):
def solve():
  size = 101
  n = int(input())
  points = []
  for _ in range(n):
    x, y, h = map(int, input().split())
    
    if h == 0: continue
    else: points.append((x, y, h))

  if len(points) == 1:
    
    ans = points[0]
    return ans

  ans = (-1, -1, -1)
  for i in range(size):
    for j in range(size):
      
      max_h = None
      succ = True
      for x, y, h in points:
        tmp = abs(i-x) + abs(j-y) + h
        if max_h == None:
          max_h = tmp
          continue
        else:
          if max_h != tmp:
            succ = False
            break
      
      if succ:
        if ans[2] < max_h:
          ans = (i, j, max_h)
  
  return ans

ans = solve()
print('{} {} {}'.format(ans[0], ans[1], ans[2]))

Solution (Python):
n = int(input())
info = []
for i in range(n):
    x,y,h = map(int,input().split())
    info.append((x,y,h))
info.sort(key=lambda x:x[2], reverse=True)

for i in range(0,101):
    for j in range(0,101):
        crt_h = info[0][2] + abs(info[0][0]-i) + abs(info[0][1]-j)
        flag = True
        for k in range(1, n):
            tar_x = info[k][0]
            tar_y = info[k][1]
            tar_h = info[k][2]
            H = tar_h + abs(tar_x - i) + abs(tar_y - j)
            if tar_h != 0:
                if H != crt_h:
                    flag = False
            else:
                if crt_h > H:
                    flag = False
        if flag:
            print(i,j,crt_h)

Solution (Python):
import sys

n=int(input())
P=[]
for i in range(n):
    x,y,h=map(int,input().split())
    P.append([h,x,y])
P=list(reversed(sorted(P)))

for x in range(101):
    for y in range(101):
        flag=0
        H=P[0][0]+abs(P[0][1]-x)+abs(P[0][2]-y)
        for p in P:
            ph=p[0]
            px=p[1]
            py=p[2]
            if ph==0:
                if H-abs(px-x)-abs(py-y)>0:
                    flag=1
                    break
            else:
                if H-abs(px-x)-abs(py-y)!=ph:
                    flag=1
                    break
        if flag==1:
            continue
        else:
            print(x,y,H)
            sys.exit()

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

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

for x in range(101):
  for y in range(101):
    tmp_H = XYH[0][2]+abs(XYH[0][0]-x)+abs(XYH[0][1]-y)
    A = 0
    for i in range(1,N):
      if tmp_H - abs(XYH[i][0]-x) - abs(XYH[i][1]-y) == XYH[i][2]:
        A += 1
      elif tmp_H - abs(XYH[i][0]-x) - abs(XYH[i][1]-y) < 0 and XYH[i][2] == 0 :
        A += 1
    
    if A == N-1:
      print(x,y,tmp_H)

Solution (Python):
n = int(input())
xyh = []
for i in range(n):
    x, y, h = [int(i) for i in input().split()]
    xyh.append((x, y, h))

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

for i in range(101):
    for j in range(101):
        x, y, h = xyh[0]
        H = h + abs(i - x) + abs(j - y)
        for x, y, h in xyh[1:]:
            if h != max(H - abs(i - x) - abs(j - y), 0):
                break
        else:
            ans = i, j, H
print(*ans)

Solution (Python):
def main():
    n = int(input())
    H = []
    ans = 0
    X = []
    Y = []
    a = 0
    tmpx = 0
    tmpy = 0
    for _ in range(n):
        x,y,h = map(int,input().split())
        X.append(x)
        Y.append(y)
        H.append(h)
        if h != 0:
            tmpx = x
            tmpy = y
            tmph = h

    for x in range(101):
        for y in range(101):
            flg = True
            h = tmph + abs(x-tmpx) + abs(tmpy-y)
            for i in range(n):
                hh = max(h - abs(x-X[i]) - abs(y - Y[i]), 0)
                if hh != H[i]:
                    flg = False
                    break
            if flg:
                print(x,y,h)
                return
if __name__ == '__main__':
    main()

Solution (Python):
from operator import itemgetter

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

Solution (Python):
n = int(input())
xyh = []
inf = 10 ** 10
for _ in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))
xyh.sort(key=lambda x:x[2], reverse=True)


for i in range(101):
    for j in range(101):
        x, y, h = xyh[0]
        H = h + abs(i-x) + abs(j-y)
        for x, y, h in xyh:
            if h != max(H - abs(i-x) - abs(j-y), 0):
                break
        else:
            ans = i, j, H
print(*ans)

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, 100+1):
  for Cy in range(0, 100+1):
    H_TOP = 1
    for i in range(N):
      if H[i]:
        H_TOP = H[i] + abs(X[i] - Cx) + abs(Y[i] - Cy)
    ok = True
    for i in range(N):
      if (max(H_TOP - abs(X[i] - Cx) - abs(Y[i] - Cy), 0) != H[i]):
        ok = False
    if ok:
      print(Cx, Cy, H_TOP)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

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

for cx in range(0, 101):
    for cy in range(0, 101):
        H = [1, float('inf')]
        ok = True
        for x, y, h in points:
            
            if h == 0:
                v = abs(cx - x) + abs(cy - y)
                if v < H[0]:
                    ok = False
                H[1] = v
            else:
                v = h + abs(cx - x) + abs(cy - y)
                if not H[0] <= v <= H[1]:
                    ok = False
                H[0] = H[1] = v
        if ok:
            print(cx, cy, H[0])
            exit()

Solution (Python):
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for X in range(0,101):
    for Y in range(0,101):
        H=xyh[0][2]+abs(xyh[0][0]-X)+abs(xyh[0][1]-Y)
        for i in range(1,n):
            x,y,h=xyh[i]
            if h!=max(H-abs(x-X)-abs(y-Y),0):
                break
        else:
            print(X,Y,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=True)
for X in range(0,101):
    for Y in range(0,101):
        f=True
        H=xyh[0][2]+abs(xyh[0][0]-X)+abs(xyh[0][1]-Y)
        for i in range(1,n):
            x,y,h=xyh[i]
            if h!=max(H-abs(x-X)-abs(y-Y),0):
                f=False
                break
        if f:
            print(X,Y,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=True)
for X in range(0,101):
    for Y in range(0,101):
        f=True
        H=xyh[0][2]+abs(xyh[0][0]-X)+abs(xyh[0][1]-Y)
        for i in range(1,n):
            x,y,h=xyh[i]
            if h==0:
                if H-abs(x-X)-abs(y-Y)>0:
                    f=False
                    break
            else:
                if H-abs(x-X)-abs(y-Y)!=h:
                    f=False
                    break
        if f:
            print(X,Y,H)
            break

Solution (Python):
def solve():

    N = int(input())

    prots = []

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

    
    prots.sort(reverse=True)

    for centerx in range(101):
        for centery in range(101):
            h, x, y = prots[0]
            
            H = h+abs(centerx - x) + abs(centery - y)
            flag = True
            for i in range(N):
                h, x, y = prots[i]
                if h != max(0, H-abs(centerx - x) - abs(centery - y)):
                    flag = False
                    break
            if flag:
                print(centerx, centery, H)
                exit()


if __name__ == "__main__":
    solve()

Solution (Python):


N=int(input())
data=[None] * N
for i in range(N):
  data[i] = list(map(int,input().split()))

for Cx in range(101):
  for Cy in range(101):
    H = -1
    for i in range(len(data)):
      if data[i][2]<1:
        continue
      H = data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy)
      break
    
    for i in range(len(data)):
      if data[i][2] != max(H - abs(data[i][0] - Cx) - abs(data[i][1] - Cy),0):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Solution (Python):
n = int(input())
xyh = []
inf = 10 ** 10
for _ in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))
xyh.sort(key=lambda x:x[2], reverse=True)
for i in range(101):
    for j in range(101):
        x, y, h = xyh[0]
        H = h + abs(i-x) + abs(j-y)
        for x, y, h in xyh:
            if h != max(H - abs(i-x) - abs(j-y), 0):
                break
        else:
            ans = i, j, H
print(*ans)