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 = [0] * N
y = [0] * N
h = [0] * N

for i in range(N):
    xyh = list(map(int, input().split()))
    x[i] = xyh[0]
    y[i] = xyh[1]
    h[i] = xyh[2]
    if xyh[2] != 0:
        Cx = xyh[0]
        Cy = xyh[1]
        CH = xyh[2]

for i in range(101):
    for j in range(101):
        flag = True
        H = CH + abs(i - Cx) + abs(j - Cy)
        for k in range(N):
            if h[k] != max(H - abs(i - x[k]) - abs(j - y[k]), 0):
                flag = False
                break
        if flag:
            print(i, j, H)

Solution (Python):
n = int(input())
x, y, h = [], [], []
for i in range(n):
    xyh = list(map(int, input().split()))
    x.append(xyh[0])
    y.append(xyh[1])
    h.append(xyh[2])
for i in range(101):
    for j in range(101):
        flag = True
        m = float('inf')
        ch = -1
        for k in range(n):
            if h[k] != 0:
                if ch == -1:
                    ch = h[k] + abs(x[k] - i) + abs(y[k] - j)
                else:
                    if ch != h[k] + abs(x[k] - i) + abs(y[k] - j) and flag:
                        flag = False
            else:
                m = min(m, abs(x[k] - i) + abs(y[k] - j))
        if flag and ch <= m:
            ans = list(map(str, [i, j, ch]))
print(ans[0] + " " + ans[1] + " " + ans[2])

Solution (Python):
n = int(input())
x, y, h = [], [], []

for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)

for X in range(101):
    for Y in range(101):
        for i in range(n):
            H = h[i] + abs(x[i] - X) + abs(y[i] - Y)
            if all(h[j] == max(H - abs(x[j] - X) - abs(y[j] - Y), 0) for j in range(n)):
                print(X, Y, H)
                break

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











for i in range(101):
    for j in range( 101):
        nescond = float("inf")
        H = abs(L[0][0] - i) + abs(L[0][1] - j) + L[0][2]
        cond = True
        for k in range(n):
            absX = abs(i - L[k][0])
            absY = abs(j - L[k][1])
            
            if L[k][2] == 0:
                nescond = min([nescond, absX + absY])
            else:
                if H != absX + absY + L[k][2]:
                    cond = False
                    break
        if cond and H <= nescond:
            for q in[i,j,H]:
                print(q, end = " ")

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

top = [[] for _ in range(101*101)]

for i in range(101):
    for j in range(101):
        top[i*101+j] = [i, j]



H = 0
ansx = -100

for i in range(len(top)):
    topx = top[i][0]
    topy = top[i][1]
    H = 0
    h_list = []
    for j in range(N):
        tmp = abs(topx - x[j]) + abs(topy - y[j]) + h[j]
        h_list.append(tmp)
    if h_list.count(h_list[0]) == N :
        ansx = topx
        ansy = topy
        ansH = h_list[0]
        break

if ansx == -100:
    for i in range(len(top)):
        topx = top[i][0]
        topy = top[i][1]
        H = 0
        h_list = []
        for j in range(N):
            if h[j] != 0:
                tmp = abs(topx - x[j]) + abs(topy - y[j]) + h[j]
                h_list.append(tmp)
        if h_list.count(h_list[0]) == N - h.count(0) :
            ansx = topx
            ansy = topy
            ansH = h_list[0]
            break

print(ansx, ansy, ansH)

Solution (Python):
import math,fractions,sys
from collections import Counter
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
tmp = 0
if n == 1:
    print(x[0],y[0],h[0])
    sys.exit()
def cal(i,j):
    for _ in range(n):
        if h[_] != 0:
            H = abs(i-x[_]) + abs(j-y[_]) + h[_]
            break
    for _ in range(n):
        h_tmp = max(H - abs(i-x[_]) - abs(j-y[_]),0)
        if h[_] != h_tmp:
            return -1
    return H                      
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

for i in range(101):   
    for j in range(101):   
        if cal(i,j) != -1:
            print(i,j,cal(i,j))

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

for cx in range(101):
    for cy in range(101):
        H = -1
        ok = True
        for x, y, h in P:
            if h == 0:
                continue
            Hi = abs(x-cx) + abs(y-cy) + h
            if H == -1:
                H = Hi
                continue
            if Hi != H:
                ok = False
                break
        if not ok:
            continue
        for x, y, h in P:
            if h != max(H-abs(cx-x)-abs(cy-y), 0):
                ok = False
        if ok:
            print(cx, cy, H)
            break
    if ok:
        break

Solution (Python):
N = int(input())
XYH = []
for n in range(N):
  x, y, h = [int(xyh) for xyh in input().split()]
  if h > 0:
    XYH.append([x, y, h])

l_XYH = len(XYH)

if l_XYH == 1:
  cx, cy, ans_H = XYH[0]
else:
  HH = []
  ans_H = 0
  for cx in range(0, 101):
    for cy in range(0, 101):
      for k in range(l_XYH):
        xk, yk, hk = XYH[k]
        H = hk + abs(xk - cx) + abs(yk - cy)
        if k < l_XYH - 1:
          HH.append(H)
        elif HH.count(H) == l_XYH - 1:
          ans_H = H
          break
        else:
          HH = []
          break
      else:
        continue
      if ans_H == H:
        break
    else:
      continue
    break

ans = str(cx) + " " + str(cy) + " " + str(ans_H)
print(ans)

Solution (Python):
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  
"""



if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]

    
    h_base = 0
    for l in L:
        if l[2] > 0:
            h_base = l[:]
    if h_base == 0:
        print("error")
        exit()

    for Cx in range(0, 101):
        for Cy in range(0, 101):
            all_collect = True
            x, y, h = h_base
            H = h + abs(Cx - x) + abs(Cy - y)
            for l in L:
                x, y, h = l
                if h != max(H - abs(Cx - x) - abs(Cy - y), 0):
                    all_collect = False
                    break
            if all_collect:
                print(Cx, Cy, H)
                exit()

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

for cx in range(101):
    for cy in range(101):
        H = -1
        ok = True
        for x, y, h in P:
            if h == 0:
                continue
            Hi = abs(x-cx) + abs(y-cy) + h
            if H == -1:
                H = Hi
                continue
            if Hi != H:
                ok = False
                break
        if not ok:
            continue
        for x, y, h in P:
            if h != max(H-abs(cx-x)-abs(cy-y), 0):
                ok = False
        if ok:
            print(cx, cy, H)
            break
    if ok:
        break

Solution (Python):
N = int(input())
p_x = []
p_y = []
p_h = []
for i in range(N):
    x1,y1,h1 = [int(i) for i in input().split()]
    p_x.append(x1)
    p_y.append(y1)
    p_h.append(h1)




for x in range(101):
    for y in range(101):
        
        hantei1 = 0
        
        count = 0
        
        tmp = -1
        
        tmp_count = 0
        
        horyu = []
        for i in range(N):
            if p_h[i] == 0:
                horyu.append(i)
            else:
                tmp1 = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                if tmp1 < 0 :
                    break
                elif tmp_count == 0:
                    tmp = tmp1
                    tmp_count += 1
                elif tmp_count != 0 and tmp1 > 0:
                    if tmp == tmp1:
                        count += 1
            
        if count == N-1 or N-1 == count + len(horyu):
            if len(horyu) == 0:
                Cx = x
                Cy = y
                H = tmp
                hantei1 = 1
                break
            else:
                count2 = 0
                for j in range(len(horyu)):
                    if 0 == max(0, tmp -abs(p_x[horyu[j]] - x) -abs(p_y[horyu[j]] - y)):
                        count2 += 1
                if count2 == len(horyu):
                    Cx = x
                    Cy = y
                    H = tmp
                    hantei1 = 1
    if hantei1 == 1:
        break

print(Cx,Cy,H)

Solution (Python):
N = int(input())
x = []
y = []
h = []

for i in range(N):
    xt, yt, ht = map(int, input().split())
    x.append(xt)
    y.append(yt)
    h.append(ht)
    if ht != 0:
        cx = xt
        cy = yt
        htt = ht

for j in range(101):
    for k in range(101):
        flg=True
        H = htt + abs(cx - j) + abs(cy - k)
        for i in range(N):
            if h[i] != max(H - abs(x[i] - j) - abs(y[i] - k), 0):
                flg = False
                break
        if flg==True:
            print(j, k, H)

Solution (Python):
N = int(input())
x = []
y = []
h = []

for i in range(N):
    xt, yt, ht = map(int, input().split())
    x.append(xt)
    y.append(yt)
    h.append(ht)
    if ht != 0:
        cx = xt
        cy = yt
        htt = ht

for j in range(101):
    for k in range(101):
        H = htt + abs(cx - j) + abs(cy - k)
        for i in range(N):
            if h[i] != max(H - abs(x[i] - j) - abs(y[i] - k), 0):
                break
        if i == N - 1 and h[i]== max(H - abs(x[i] - j) - abs(y[i] - k), 0):
            print(j, k, H)

Solution (Python):
n = int(input())
s = []

for i in range(n):
  s.append(list(map(int,input().split())))

ans_x = -1
ans_y = -1
ans_h = -1

for i in s:
  if(i[2] > 0):
    check_x,check_y,check_h = i
    break

for x in range(101):
  for y in range(101):
    flg = True
    H = check_h + abs(check_x - x) + abs(check_y - y)
    if(H <= 0):
      flg = False
      break

    else:
      for i in range(n):
        h = max( ( H - abs(s[i][0] - x) - abs(s[i][1] - y) ) ,0)
        if(h != s[i][2]):
          flg = False
          break
    if flg:
      ans_y = y
      ans_h = H
      break

  if flg:
    ans_x = x
    break

print("{} {} {}".format(ans_x,ans_y,ans_h))

Solution (Python):


import collections
import itertools
import sys


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

n=getint()

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

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

check_x, check_y, check_h = check

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

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())
x = []
y = []
h = []
for i in range(n):
    lis = list(map(int,input().split()))
    x.append(lis[0])
    y.append(lis[1])
    h.append(lis[2])
    if lis[2] != 0:
        index = i
for cx in range(101):
    for cy in range(101):
        height = abs(x[index]-cx) + abs(y[index] - cy) + h[index]
        flag = True
        for j in range(n):
            if h[j] != max(height - abs(x[j]-cx) - abs(y[j] - cy), 0):
                flag = False
                break
        if flag == True:
            ans = [cx,cy,height]
print(*ans)

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

for cx in range(101):
    for cy in range(101):
        mh = 10000000000
        h = []
        for i in range(n):
            x,y,z = xyz[i][0],xyz[i][1],xyz[i][2]
            if z == 0:
                mh = min(mh,abs(x-cx)+abs(y-cy))
            else:
                if len(h) == 0:
                    h.append(z+abs(x-cx)+abs(y-cy))
                else:
                    if h[0] != z+abs(x-cx)+abs(y-cy):
                        h = []
                        break
                    elif h[0]>mh:
                        h = []
                        break
            if len(h)>0 and h[0]>mh:
                h = []
                break
        if len(h) > 0:
            ans = str(cx)+" "+str(cy)+" "+str(h[0])
print(ans)

Solution (Python):
import sys

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

for p in range(101):
    for q in range(101):
        for x, y, h in point:
            if h > 0:
                H = h + abs(x-p) + abs(y-q)
                break
        
        for  x, y, h in point:
            if max(H-abs(x-p)-abs(y-q), 0) != h:
                break
        else:
            print(p, q, H)
            sys.exit(0)

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

maxh = 0
for x,y,h in xyh:
    maxh = max(maxh,h)
for H in range(maxh,maxh+201):
    for cx in range(101):
        for cy in range(101):
            for x,y,h in xyh:
                if h != max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print(cx,cy,H)
                quit()

Solution (Python):
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]
for cx in range(101):
    for cy in range(101):
        H = A[2] + abs( A[0] - cx) + abs( A[1] - cy)
        Flag = True
        for i in range(N):
            if max( H - abs(X[i][0]-cx) - abs(X[i][1] - cy), 0) != X[i][2]:
                Flag = False
                break
        if Flag:
            print('{} {} {}'.format(cx, cy, H))
            break
    if Flag:
        break

Solution (Python):
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]
for cx in range(101):
    for cy in range(101):
        H = A[2] + abs( A[0] - cx) + abs( A[1] - cy)
        Flag = True
        for i in range(N):
            if max( H - abs(X[i][0]-cx) - abs(X[i][1] - cy), 0) != X[i][2]:
                Flag = False
                break
        if Flag:
            print('{} {} {}'.format(cx, cy, H))
            break
    if Flag:
        break

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

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

data = sorted(data, key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        flag = True
        H = data[0][2] + abs(data[0][0]-cx) + abs(data[0][1]-cy)
        for i in range(1, len(data)):
            if not max(H - abs(data[i][0]-cx) - abs(data[i][1]-cy), 0) == data[i][2]:
                flag = False
                break

        else:  
            print(cx, cy, H)
            exit()

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

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

data = sorted(data, key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        flag = True
        H = data[0][2] + abs(data[0][0]-cx) + abs(data[0][1]-cy)
        for i in range(1, len(data)):
            if not max(H - abs(data[i][0]-cx) - abs(data[i][1]-cy), 0) == data[i][2]:
                flag = False
                break

        if flag:
            print(cx, cy, H)
            exit()

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

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

def sol() :
    for cx in range(0, 101) :
        for cy in range(0, 101) :
            axis.sort(key = lambda A : abs(A[0] - cx) + abs(A[1] - cy))
            H = axis[0][2] + abs(axis[0][0] - cx) + abs(axis[0][1] - cy)
            for x, y, h in axis :
                if not h == max(H - abs(x - cx) - abs(y - cy), 0) :
                    break
            else :
                return (cx, cy, H)
    return (-1, -1, -1)

cx, cy, H = sol()
if cx == -1 :
    print('-1')
else :
    print('{} {} {}'.format(cx, cy, H))

Solution (Python):
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
setrecursionlimit(10**6)

n=int(input())
x=sorted([[int(i) for i in input().split()] for _ in range(n)],key=itemgetter(2),reverse=True)
cmpr=x[1:]
for cx in range(101):
    for cy in range(101):
        h=x[0][2]+abs(cx-x[0][0])+abs(cy-x[0][1])
        for i in cmpr:
            nh=max(0,h-abs(i[0]-cx)-abs(i[1]-cy))
            if nh!=i[2]:
                break
        else:
            print(cx,cy,h)
            sys.exit()

Solution (Python):
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] > abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
print(' '.join(list(map(str,can[0]))))

Solution (Python):
n = int(input())
l = 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):
        h = l[0][2] + abs(l[0][0] - cx) + abs(l[0][1] - cy)
        for i in l[1:]:
            if max(h - abs(i[0] - cx) - abs(i[1] - cy), 0) != i[2]:
                break
        else:
            print(cx, cy, h)
            exit()

Solution (Python):
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			needH = -1
			for i in range(n):
				if h[i] > 0:
					tmp = h[i] + abs(x[i]-s) + abs(y[i]-t)
					if needH == -1:
						needH = tmp
					elif needH != tmp:
						needH = -2
						break
			if needH == -2:
				continue
			for i in range(n):
				if h[i] == 0 and needH > abs(x[i]-s) + abs(y[i]-t):
					needH = -2
					break
			if needH == -2:
				continue
			else:
				print("{} {} {}".format(s, t, needH))

if __name__ == '__main__':
	main()

Solution (Python):
from itertools import product
n = int(input())

pos = [[int(x) for x in input().split(' ')] for _ in range(n)]

for cx, cy in product(range(101), range(101)):
    H = max(max([abs(p[0]-cx)+abs(p[1]-cy)+p[2] for p in pos if p[2] != 0]), 1)
    if all(max(H-abs(p[0]-cx)-abs(p[1]-cy), 0) == p[2] for p in pos):
        print(cx, cy, H)
        exit()

Solution (Python):
n = int(input())
l = 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):
        h = l[0][2] + abs(l[0][0] - cx) + abs(l[0][1] - cy)
        for i in l[1:]:
            if max(h - abs(i[0] - cx) - abs(i[1] - cy), 0) != i[2]:
                break
        else:
            print(cx,cy,h)
            exit()

Solution (Python):
from operator import itemgetter

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

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

for x in range(101):
    for y in range(101):
        h = l[0][2] + abs(l[0][0]-x) + abs(l[0][1]-y)
        for i in range(1, n):
            d = abs(l[i][0]-x) + abs(l[i][1]-y)
            h_i = l[i][2] + d
            if l[i][2] == 0:
                if max(h-d, 0) == 0:
                    continue
                else:
                    break
            if h != h_i:
                break
        else:
            ans = list(map(str, [x, y, h]))
            print(" ".join(ans))
            exit()

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

lower_h = max([xyh[2] for xyh in xyhs])

def func():
    for ch in range(lower_h,lower_h+201,1):

        for cx in range(101):
            for cy in range(101):

                if all([xyh[2] == max(ch - abs(xyh[0]-cx) - abs(xyh[1]-cy),0) for xyh in xyhs]):

                    return cx,cy,ch

cx,cy,ch = func()

print(" ".join(list(map(str,[cx,cy,ch]))))

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

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = p[0]
        h = abs(x0 - cx) + abs(y0 - cy) + h0
        if all(max(h - abs(xi - cx) - abs(yi - cy), 0) == hi for xi, yi, hi in p):
            print(cx, cy, h)
            exit()

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

for cx in range(101):
    for cy in range(101):
        for xi, yi, hi in p:
            if hi > 0:
                h = abs(xi - cx) + abs(yi - cy) + hi
                break
        if all(max(h - abs(xi - cx) - abs(yi - cy), 0) == hi for xi, yi, hi in p):
            print(cx, cy, h)
            exit()

Solution (Python):
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(string_to_int, inputs))
    points = [p for p in points if p[2] != 0]
    if len(points) == 1:
        return "{} {} {}".format(points[0][0], points[0][1], points[0][2])
    for top_x in range(101):
        for top_y in range(101):
            is_correct = True
            p = points[0]
            prev_h = max(p[2] + abs(p[0] - top_x) + abs(p[1] - top_y), 0)
            for [px, py, ph] in points:
                top_h = max(ph + abs(px - top_x) + abs(py - top_y), 0)
                if top_h != prev_h:
                    is_correct = False
                    break
            if is_correct:
                return "{} {} {}".format(top_x, top_y, prev_h)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Solution (Python):
N=int(input())
A=[]
H=0
flag=0

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

A.sort(key=lambda x: -x[2])
for x in range(101):
    for y in range(101):
        H=A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        flag=0
        for n in range(N):
            if A[n][2] != max(H-abs(A[n][0] - x) - abs(A[n][1] - y,),0):
                flag=1
        if flag==0:
            print(str(x)+" "+str(y)+" "+str(H))
            exit(0)

Solution (Python):
l_bound = [[1]*101 for _ in range(101)]
u_bound = [[10**10]*101 for _ in range(101)]

N = int(input())
for n in range(N):
    x, y, h = list(map(int, input().split()))

    if h==0:
        for r in range(101):
            for c in range(101):
                u_bound[r][c] = min(u_bound[r][c], abs(c-x) + abs(r-y))
    else:
        for r in range(101):
            for c in range(101):
                l_bound[r][c] = max(l_bound[r][c], h + abs(c-x) + abs(r-y))
                u_bound[r][c] = min(u_bound[r][c], h + abs(c-x) + abs(r-y))

for r in range(101):
    for c in range(101):
        if l_bound[r][c] == u_bound[r][c]:
            print(c, r, l_bound[r][c])

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

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

xyh = [[int(i) for i in input().split()] for j in range(n)]

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

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            if xyh[k][2] == 0:
                tmp = H - abs(xyh[k][0] - i ) - abs(xyh[k][1] - j )
                if tmp <= 0 and k == n-1:
                    print(cx,cy,H)
                    exit()
                elif tmp <= 0:
                    continue
                else:
                    break
                
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        """
        if k == n-1:
            break
    if k == n-1:
        break
    """

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

xyh.sort(key=lambda x: x[2])
l = xyh[-1]
Cx = 0
Cy = 0
for i in range(101):
    Cx = i
    for j in range(101):
        Cy = j
        H = abs(Cx - l[0]) + abs(Cy - l[1]) + l[2]
        for p in xyh:
            if p[2] != max(0, H - abs(Cx - p[0]) - abs(Cy - p[1])):
                break
        else:
            print(Cx, Cy, H)
            exit()

Solution (Python):
import sys
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
if xyh[0][2]==0:
  total=0
  for i in range(n):
    total+=xyh[i][0]
  cx=total//n
  total=0
  for i in range(n):
    total+=xyh[i][1]
  cy=total//n
  ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)
  print(cx,cy,ch)
  sys.exit()  
for cx in range(101):
  for cy in range(101):
    ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    flg=0
    for i in range(n):
      if xyh[i][2]!=max(0, ch-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy)):
        flg=1
        break
    if flg==0:
      print(cx,cy,ch)
      sys.exit()

Solution (Python):
n=int(input())
hoge=[]
for i in range(n):
  x,y,z=map(int,input().split())
  if(z!=0):
    hoge.append([x,y,z])
  

if(len(hoge)==1):
  print(*hoge[0])
  exit()

for i in range(101):
  for j in range(101):
    h=[]
    for k in range(len(hoge)):
      h.append(hoge[k][2]+abs(hoge[k][0]-i)+abs(hoge[k][1]-j))
      
    if(h.count(h[0])==len(h)):
      print(i,j,h[0])

Solution (Python):
N = int(input())
old_dl = [list(map(int,input().split())) for _ in range(N)]
dl = []
for k in old_dl:
    if k[2] != 0:
        dl.append(k)
if len(dl) == 1:
    print(*dl[0])
else:
    for x in range(101):
        for y in range(101):
            ndl = [l[2]+abs(l[0]-x)+abs(l[1]-y) for l in dl]
            if max(ndl) == min(ndl):
                
                print(x,y,max(ndl))
                exit(0)

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

flag = False
for cx in range(101):
    for cy in range(101):
        needH = -1
        for i in range(N-1, -1, -1):
            if h[i] > 0:
                H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
                if needH == -1:
                    needH = H
                else:
                    if needH != H:
                        needH = -2
                        break
            else:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                
                if needH > dist:
                    needH = -2
                    break

        if needH == -2:
            continue
        else:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)