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 sys

N = int(input())

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

for _ in range(N):
    t_x, t_y, t_h = map(int, input().split())
    x.append(t_x)
    y.append(t_y)
    h.append(t_h)

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

        H = -1
        
        for index, t_h in enumerate(h):
            if t_h != 0:
                H = abs(i - x[index]) + abs(j - y[index]) + t_h
                break

        for t_x, t_y, t_h in zip(x, y, h):
            if t_h == 0:
                if H > abs(i - t_x) + abs(j - t_y):
                    break
            elif H != abs(i - t_x) + abs(j - t_y) + t_h:
                break
        else:
            print(i, j, H)
            sys.exit(0)

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

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

for _ in range(N):
    t_x, t_y, t_h = map(int, input().split())
    x.append(t_x)
    y.append(t_y)
    h.append(t_h)

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

        H = -1
        
        for index, t_h in enumerate(h):
            if t_h != 0:
                H = abs(i - x[index]) + abs(j - y[index]) + t_h
                break

        for t_x, t_y, t_h in zip(x, y, h):
            if t_h == 0:
                if H > abs(i - t_x) + abs(j - t_y):
                    break
            elif H != abs(i - t_x) + abs(j - t_y) + t_h:
                break
        else:
            print(i, j, H)
            break

        continue
    else:
        continue

    break

Solution (Python):
import sys

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

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

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if H[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()

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

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

for _ in range(N):
    t_x, t_y, t_h = map(int, input().split())
    x.append(t_x)
    y.append(t_y)
    h.append(t_h)

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

        H = 1
        
        for index, t_h in enumerate(h):
            if t_h != 0:
                H = abs(i - x[index]) + abs(j - y[index]) + t_h
                break

        for t_x, t_y, t_h in zip(x, y, h):
            if t_h == 0:
                if H > abs(i - t_x) + abs(j - t_y):
                    break
            elif H != abs(i - t_x) + abs(j - t_y) + t_h:
                break
        else:
            print(i, j, H)
            break

        continue
    else:
        continue

    break

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


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

for n in range(N):
    info[n][0],info[n][1],info[n][2] = map(int,input().split())

info.sort(key=lambda x:x[2],reverse=True)
for cx in range(101):
    for cy in range(101):
        cnt = 1
        H = info[0][2] + abs(info[0][0]-cx) + abs(info[0][1]-cy)
        for n in range(1,N):
            cnt += 1 
            if info[n][2] != max(H-abs(info[n][0]-cx)-abs(info[n][1]-cy),0):
                break
            if cnt == N:
                print(cx,cy,H)
                exit()

Solution (Python):
N = int(input())
A = [tuple(map(int,input().split())) for i in range(N)]
D = 0
for Cx in range(101):
    for Cy in range(101):
        H = 0
        F = 1
        for i in A:
            if H < 1:
                if i[2] == 0:
                    continue
                H = i[2] + abs(i[0]-Cx) + abs(i[1]-Cy)
            elif i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                continue
            else:
                F = 0
                break
        for i in A:
            if not (i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0)):
                F = 0
                break
        if F == 1 and H >= 1 and D == 0:
            D = 1
            print(Cx,Cy,H)

Solution (Python):
def main():
	n = int(input())
	xi, yi, hi = [0]*n, [0]*n, [0]*n
	stack = []
	result = []
	for i in range(n):
		xi[i], yi[i], hi[i] = map(int, input().split())
		if hi[i] > 0:
			stack = [xi[i], yi[i], hi[i]]
	for i in range(101):
		for j in range(101):
			guess = stack[2] + abs(stack[0]-i) + abs(stack[1]-j)
			is_result = True
			for k in range(n):
				result = guess - abs(xi[k]-i) - abs(yi[k]-j)
				result = max(result, 0)
				if hi[k] != result:
					is_result = False
					break
			if is_result:
				print(str(i)+" "+str(j)+" "+str(guess))
				return


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import *

n = int(input())
xyh = []
for i in range(n):
    xyh += [list(map(int, input().split()))]
xyh.sort(reverse=True, key=lambda x: x[2])
[x0, y0, h0] = xyh[0]
for x, y in product(range(0, 101), range(0, 101)):
    h = h0 + abs(x - x0) + abs(y - y0)
    for k in xyh[1:]:
        if k[2] != max(h - abs(x - k[0]) - abs(y - k[1]), 0):
            break
    else:
        break
print(x, y, h)

Solution (Python):
A=abs;p=eval('list(map(int,input().split())),'*int(input()));x,y,h=[x for x in p if x[2]][0]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Solution (Python):
import sys
write = sys.stdout.write

def valid(x, y):
    H = info[nzpoint][2] + abs(info[nzpoint][0]-x) + abs(info[nzpoint][1]-y)
    for i in range(N):
        if i == nzpoint:
            continue
        if max(0, H - abs(x-info[i][0]) - abs(y-info[i][1])) != info[i][2]:
            return False
    return True
        

def printheight(i, j):
    write(str(info[nzpoint][2] + abs(i-info[nzpoint][0]) + abs(j-info[nzpoint][1])) + "\n")

N = int(input())
info = []
nzpoint = 0
for i in range(N):
    info.append(list(map(int,input().split())))
    if info[i][2] > 0:
        nzpoint = i

for i in range(101):
    for j in range(101):
        if valid(i, j):
            write(str(i) + " " + str(j) + " ")
            printheight(i, j)
            sys.exit()

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
maxh = 0
minh = 10 ** 9
for i in range(N):
  if xyh[i][2] > maxh:
    maxh = xyh[i][2]
  if xyh[i][2] < minh:
    minh = xyh[i][2]
def hantei(x, y, h):
  for i in range(N):
    if max(h - abs(xyh[i][0] - x) - abs(xyh[i][1] - y), 0) != xyh[i][2]:
      return(False)
  return(True)

def solve():
  for p in range(maxh, minh + 205):
    for q in range(101):
      for r in range(101):
        if hantei(q,r,p) == True:
          return([q,r,p])
print(solve()[0],solve()[1],solve()[2])

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    return


def B():
    return


def C():
    n = II()
    xyh = LIR(n)
    xyh.sort(key = lambda x:x[2], reverse = True)
    x1, y1, h1 = xyh[0]
    del xyh[0]
    for x in range(101):
        for y in range(101):
            h = abs(x - x1) + abs(y - y1) + h1
            flg = True
            for xn, yn, hn in xyh:
                if max(h - abs(x - xn) - abs(y - yn), 0) == hn:
                    continue
                flg = False
                break
            if flg:
                print(x, y, h)
                return 
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = I()
    ans = float("inf")
    for i in range(n+1):
        m = 0
        k = i
        while k > 0:
            m += k%6
            k //= 6
        k = n-i
        while k > 0:
            m += k%9
            k //= 9
        if m < ans:
            ans = m
    print(ans)
    return


def B():
    n = I()
    x = [None for i in range(n)]
    y = [None for i in range(n)]
    h = [None for i in range(n)]
    for i in range(n):
        x[i],y[i],h[i] = LI()
    if n == 1:
        print(x[0],y[0],h[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                if h[i] > 0:break
            ch = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
            f = 1
            for i in range(n):
                if max(ch-abs(x[i]-cx)-abs(y[i]-cy),0) != h[i]:f = 0
            if f:
                print(cx,cy,ch)
                quit()
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


def I_():
    return


def J():
    return


if __name__ == "__main__":
    B()

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

x,y,h=[],[],[]
for i in range(n):
  a,b,c=map(int,input().split())
  x.append(a)
  y.append(b)
  h.append(c)

for i in range(n):
  if h[i]!=0:s=i;break

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

Solution (Python):
def high(i):
    return max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0)

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

for i in range(N):
    if h[i] != 0:
        non_zero = i
        break

found = False
for Cx in range(0, 101):
    for Cy in range(0, 101):
        H = h[non_zero] + abs(x[non_zero] - Cx) + abs(y[non_zero] - Cy)
        if all([h[i] == high(i) for i in range(N)]):
            print('{} {} {}'.format(Cx, Cy, H))
            found = True
            break
    if found:
        break

Solution (Python):
n = int(input())
a = []
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for x in range(101):
	for y in range(101):
		h = a[n - 1][0] + abs(x - a[n - 1][2]) + abs(y - a[n - 1][1])
		for k in range(n):
			d = h - abs(x - a[k][2]) - abs(y - a[k][1])
			if a[k][0] != max(d, 0):
				break
			if k == n - 1:
				print(x, y, h)
				exit()

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



for Cx in range(101):
    for Cy in range(101):
        for x, y, h in data:
            if h != 0:
                H = abs(x - Cx) + abs(y - Cy) + h
                break
        count = 0
        for x, y, h in data:
            if h != max(H-abs(x-Cx)-abs(y-Cy), 0):
                break
            count += 1
        if count == N:
            print(Cx, Cy, H)
            exit()

Solution (Python):
N = int(input())
p = [list(map(int, input().split())) for i in range(N)]
h = [h for x, y, h in p]
maxh = max(h)
def height(H, cx, cy, l):
    for x, y, h in l:
        if h != max(H-abs(x-cx)-abs(y-cy) , 0):
            return False
    return True
flag = False
for i in range(maxh,10**9 +201):
    for cx in range(101):
        for cy in range(101):
            if height(i, cx, cy, p):
                print(cx, cy, i)
                flag = True
                break
        if flag:
            break
    if flag:
        break

Solution (Python):
import sys
input = sys.stdin.readline
from itertools import product

N = int(input())
xyh = [[int(_) for _ in input().split()] for _ in range(N)]

if N == 1:
    print(xyh[0][0], xyh[0][1], xyh[0][2])
else:
    for x, y in product(range(101), range(101)):
        for i in xyh:
            if i[2] > 0:
                H = i[2] + abs(x-i[0]) + abs(y-i[1])
                break
        for i in xyh:
            if i[2] != max(0, H-abs(x-i[0])-abs(y-i[1])):
                break
        else:
            print(x, y, H)
            break

Solution (Python):
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y', 'h'))

def main():
    n = int(input())
    points = [read_point() for _ in range(n)]
    print(*solve(points))

def solve(points):
    for p in points:
        if p.h != 0:
            base = p
            break

    for x in range(0, 101 + 1):
        for y in range(0, 100 + 1):
            h = base.h + abs(base.x - x) + abs(base.y - y)
            for p in points:
                ph = max(h - abs(x - p.x) - abs(y - p.y), 0)
                if ph != p.h:
                    break
            else:
                return Point(x, y, h)

def read_point():
    x, y, h = map(int, input().split())
    return Point(x, y, h)

main()

Solution (Python):


















import math
import copy
from collections import defaultdict, Counter

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
x, y, h = [], [], []
for _ in range(N):
    xi, yi, hi = s_inpl()
    x.append(xi)
    y.append(yi)
    h.append(hi)


MAX = 100;

ans_x, ans_y, ans_h = -1, -1, -1
for pos_y in range(MAX+1):
    for pos_x in range(MAX+1):
        
        need_h = -1
        
        for i in range(N):
            if h[i] > 0:
                
                
                tmp_h = h[i] + abs(pos_y-y[i]) + abs(pos_x-x[i])
                if need_h == -1:
                    need_h = tmp_h
                else:
                    if need_h != tmp_h:
                        need_h = -2
                        break
        
        if need_h == -2:
            continue

        
        
        for i in range(N):
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - x[i])
                if need_h > dist:
                    need_h = -2

        if need_h == -2:
            continue
        ans_x, ans_y, ans_h = pos_x, pos_y, need_h

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

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

xyh=[]
for i in range(N):
    xi,yi,hi=map(int,input().split())
    xyh.append([xi,yi,hi])
xyh.sort(reverse=True,key=lambda x:x[2])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(N):
            X=xyh[i][0]
            Y=xyh[i][1]
            h=xyh[i][2]
            if i==0:
                H=h+abs(X-Cx)+abs(Y-Cy)
                continue
            H_=h+abs(X-Cx)+abs(Y-Cy)
            if h==0:
                if H_<H:
                    break
            elif H!=H_:
                break
            if i==N-1:
                print(Cx,Cy,H)
                quit()

Solution (Python):
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])
    sys.exit()



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])

        for k in range(1,N):
            if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
            elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<p : break
            if k==N-1:
                print(i,j,p)
                sys.exit()

Solution (Python):
def checkheight(H, data, coordinate):
    cx, cy = coordinate

    for px, py, ph in data:
        if not ph == max(H - abs(px - cx) -  abs(py - cy), 0):
            return None

    return (cx, cy, H)

def makeheight(data, cx, cy):
    px, py, ph = list(filter(lambda dataset: dataset[2] > 0, data))[0]
    return ph + abs(px - cx) + abs(py - cy)


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

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


    for cx in range(101):
        for cy in range(101):
            tmpch = makeheight(data.copy(), cx, cy)

            res = checkheight(tmpch, data, (cx, cy))

            if res:
                print(*res)
                return



if __name__ == '__main__':
    main()

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)
hAns = [0]*N


for i in range(101):
    for j in range(101):
        
        for k in range(N):
            hAns[k] = H[k]+abs(X[k]-i)+abs(Y[k]-j)
        
        
        for l in range(N):
            if H[l] == 0:
                hAns[l] = min(hAns)
        if all(hAns[c]==hAns[c+1] for c in range(len(hAns)-1)):
            print(i,j,hAns[0])
            break

Solution (Python):
N = int(input())
points = []
f = None
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        f = [x, y, h]
    points.append([x, y, h])

def height(cx, cy):
    H = f[2] + abs(f[0] - cx) + abs(f[1] - cy)
    for p in points:
        if p[2] != max(H - abs(p[0] - cx) - abs(p[1] - cy), 0):
            return 0
    return H

for x in range(101):
    for y in range(101):
        h = height(x, y)
        if h > 0:
            print(' '.join([str(x), str(y), str(h)]))

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

Solution (Python):
from sys import exit
n=int(input())
pyramid=[]
for i in range(n):
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
flag=0
for i in range(n):
  if flag==0 and pyramid[i][2]!=0:
    flag=-1
  elif flag==-1 and pyramid[i][2]!=0:
    flag=1
if flag==-1:
  for i in range(n):
    if pyramid[i][2]!=0:
      print(pyramid[i][0],pyramid[i][1],pyramid[i][2])
      exit()
ans=[[0 for i in range(101)] for i in range(101)]
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
    flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Solution (Python):
class Plot:

    def __init__(self, inp):
        self.x, self.y, self.h = inp


def plot_check(xyh, cx, cy, H):
    for i in xyh:
        if max(H - abs(i.x - cx) - abs(i.y - cy),0) != i.h:
            return False
    return True


def main():
    xyh = []
    kensa = 0
    N = int(input())
    for i in range(N):
        xyh.append(Plot(map(int, input().split())))
    for i in range(len(xyh)):
        if xyh[i].h > 0:
            kensa = i
            break
    for cxi in range(101):
        for cyi in range(101):
            H = abs(xyh[kensa].x - cxi) + abs(xyh[kensa].y - cyi) + xyh[kensa].h
            if plot_check(xyh, cxi, cyi, H):
                print(cxi, cyi, H)
                return


main()

Solution (Python):
import itertools

n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
if n == 1:
    print(xyh[0])
    pass
else:
    for cx, cy in itertools.product(range(0, 101), range(0, 101)):
        flag = False
        tmp_h = 0
        for x, y, h in xyh:
            if h != 0:
                tmp_h_tmp = h + abs(cx-x) + abs(cy-y)
                if tmp_h == 0:
                    tmp_h = tmp_h_tmp
                else:
                    if tmp_h != tmp_h_tmp:
                        flag = True
                        break
        if flag:
            continue
        for x, y, h in xyh:
            if h == 0:
                if not max(tmp_h - abs(cx-x) - abs(cy-y), 0) == 0:
                    flag = True
                    break
        if flag:
            continue
        print(cx, cy, tmp_h)
        break

Solution (Python):
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx, yy, hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
if n == 1:
    print(x[0], y[0], h[0])
else:
    c = [-1, -1]
    top = -1
    for cx, cy in itertools.product(range(0, 101), range(0, 101)):
        flag = False
        tmp_h = 0
        for j in range(n):
            if h[j] != 0:
                tmp_h_tmp = h[j] + abs(cx-x[j]) + abs(cy-y[j])
                if tmp_h == 0:
                    tmp_h = tmp_h_tmp
                else:
                    if tmp_h != tmp_h_tmp:
                        flag = True
                        break
        if flag:
            continue
        assert tmp_h > 0
        for j in range(n):
            if h[j] == 0:
                if not max(tmp_h - abs(cx-x[j]) - abs(cy-y[j]), 0) == 0:
                    flag = True
                    break
        if flag:
            continue
        c = [cx, cy]
        top = tmp_h
        break
    print(c[0], c[1], top)

Solution (Python):
N = int(input())
infos = [0 for i in range(N)]

for i in range(N):
    x,y,h = map(int, input().split())
    infos[i] = [x,y,h]
    if h > 0:
        x1, y1, h1 = x,y,h

for i in range(101):
    for j in range(101):
        H = h1 + abs(x1-i) + abs(y1-j)
        for info in infos:
            x,y,h = info
            if h != max(H - abs(x-i) - abs(y-j), 0):
                break
        else:
            print(i,j,H)
            exit()

Solution (Python):
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  flag = False
  hhh = []
  for i in range(n):
    if xyh[i][2] != 0:
      h = xyh[i][2] + abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)
      hhh.append(h)
  if len(set(hhh)) == 1:
    flag = True
    for i in range(n):
      if xyh[i][2] == 0:
         if hhh[0] - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy) > 0:
            flag = False
  if flag:
    print(cx, cy, hhh[0])

Solution (Python):
n = int(input())
s = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    if s[i][2] > 0:
        a,b,c = s[i][0],s[i][1],s[i][2]
        break

for i in range(101):
    for j in range(101):
        h = abs(a-i)+abs(b-j)+ c
        co = 0
        for r in range(n):
            t = h - abs(i - s[r][0]) - abs(j - s[r][1])
            if s[r][2] != max(t,0):
                co = 1
                break
        if co == 0:
            x = i
            y = j
            break
    if co == 0:
        break

print("{} {} {}".format(x,y,h))

Solution (Python):
n=int(input())
l=[]
l1=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l1=l1[::-1]
  l.append(l1)      
l=sorted(l)
for i in range(101):
  for j in range(101):
    b=True
    h=abs(i-l[-1][2])+abs(j-l[-1][1])+l[-1][0]
    for k in range(n-1):
      if max(h-abs(i-l[-2-k][2])-abs(j-l[-2-k][1]),0)!=l[-2-k][0]:
        b=False
    if b:
      print(i,j,h)
      break

Solution (Python):
N = int(input())
L = [list(map(int, input().split())) for i in range(N)]
c = 0
H = 0
for i in range(101):
    for j in range(101):
        c = 0
        for k in range(N):
            
            if L[k][2] != 0:
                H = L[k][2] + abs(L[k][0] - i) + abs(L[k][1] - j)
                break
        for k in range(N):
            
            if max(H - abs(L[k][0] - i) - abs(L[k][1] - j), 0) != L[k][2]:
                c = 1
                break
        if c == 0:
            print(i, j, H)
            exit()
print(L)

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')



N = 0
X, Y, H = [], [], []


def set_inputs():
    global N, X, Y, H
    N = get_int()
    X, Y, H = get_data(N, [int, int, int])
    return


def answer(cx, cy):
    x, y, h = next(itertools.dropwhile(
        lambda v: v[2] == 0,
        zip(X, Y, H)
    ))
    ch = h + abs(x - cx) + abs(y - cy)
    for x, y, h in zip(X, Y, H):
        if max(ch - abs(x - cx) - abs(y - cy), 0) != h:
            return False
    print(cx, cy, ch)
    return True


def main():
    setrecursionlimit(100000)
    set_inputs()
    for cx in range(0, 101):
        for cy in range(0, 101):
            if answer(cx, cy):
                return
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
xyh=[]
for i in range(n):
    xyh1=[int(i) for i in input().split()]
    xyh.append(xyh1)
xyh.sort(key=lambda x: x[2])
xm,ym,hm=xyh[-1]
for cx in range(101):
    for cy in range(101):
        H=hm+abs(xm-cx)+abs(ym-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())
list = [list(map(int,input().split())) for i in range(N)]

for i in range(N):
    if list[i][2]:
        x0,y0,h0 = list[i]

for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(N):
            H = max(h0+abs(x0-Cx)+abs(y0-Cy),0)
            if max(H-abs(list[i][0]-Cx)-abs(list[i][1]-Cy),0) != list[i][2]:
                break
        else:
            print(Cx,Cy,H)

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


ls = [[0]*101 for i in [0]*101]

cor = [[i,j] for i in range(101) for j in range(101)]


for cx,cy in cor:
	H = 0
	for x,y,h in xyh:
		if h != 0:
			hx = abs(cx-x)
			hy = abs(cy-y)
			H = h + hx + hy
			break
	ok = True 
	for x,y,h in xyh:
		hx = abs(cx-x)
		hy = abs(cy-y)
		if h != max(H-hx-hy,0):
			ok = False
			break
	if ok:
		break

print(cx,cy,H)

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)
MAX=101
for posX in range(MAX):
  for posY in range(MAX):
    needH=-1
    for i in range(N):
      if h[i]>0:
        tmp=h[i]+abs(posX-x[i])+abs(posY-y[i])
        if needH == -1:
          needH=tmp
        elif needH != tmp:
          needH=-2
          break
    if needH==-2:
      continue
    for i in range(N):
      if h[i] == 0:
        dist=abs(posY-y[i])+abs(posX-x[i])
        if needH > dist:
          needH=-2
          break
    if needH == -2:
      continue
    print(posX,posY,needH)

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

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

for x in range(101):
  for y in range(101):
    flg = True
    max_h = max_list_inp[2] + abs(max_list_inp[0] - x) + abs(max_list_inp[1] - y)
    
    
    for i in list_inp:
      h = max(max_h - abs(i[0] - x) - abs(i[1] - y), 0)
      if h != i[2]:
        flg = False
        break
    
    if flg:
      ans_x, ans_y,ans_h = x,y,max_h
      break
    
  if flg:
    break
    
    
print(ans_x, ans_y,ans_h)

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

x,y,h = info[-1]

for cx in range(101):
  for cy in range(101):
    H = h+abs(x-cx)+abs(y-cy)
    if all(h_ == max(H-abs(x_-cx)-abs(y_-cy),0) for x_,y_,h_ in info):
      print(cx, cy, H)
      exit()

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    a,b,c=map(int,input().split())
    l.append((a,b,c))
    if c>0:
        x,y,h=a,b,c
ma=len(l)
for s in range(101):
    for t in range(101):
        x2,y2,h2=s,t,h+abs(x-s)+abs(y-t)  
        c=0
        if all(h3==max(h2-abs(x3-x2)-abs(y3-y2),0)for(x3,y3,h3)in l):
            print(x2,y2,h2)
            exit()
print(-1,-1,-1)

Solution (Python):
N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]
xyh.sort(key = lambda x: x[2])
tx, ty, th = xyh[-1]
for Cx in range(101):
  for Cy in range(101):
    H = th+abs(tx-Cx)+abs(ty-Cy)
    if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in xyh):
      print(Cx, Cy, H)
      exit()