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())
xyh = []

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

def check(cx,cy,H,i):
    if xyh[i][2] == max(H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0): return True
    else: return False

flg = False
for cx in range(101):
    for cy in range(101):
        H = xyh[tmp][2] + abs(xyh[tmp][0]-cx) + abs(xyh[tmp][1]-cy)
        if all([check(cx,cy,H,i) for i in range(N)]):
            flg = True
            break
    if flg: break

print(cx,cy,H)

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


t = 0
for i in range(N):
    if info[i][2] != 0:
        t = i
        break


def check(Cx, Cy, H):
    for i in range(N):
        if info[i][2] != max(H - abs(info[i][0] - Cx) - abs(info[i][1] - Cy), 0):
            return False
    return True



for Cx in range(101):
    for Cy in range(101):
        H = abs(info[t][0] - Cx) + abs(info[t][1] - Cy) + info[t][2]
        if check(Cx, Cy, H):
            print('{} {} {}'.format(Cx, Cy, H))

Solution (Python):
def decide_H(Cx,Cy):
    for x,y,h in T:
        H=h+abs(x-Cx)+abs(y-Cy)
        if h>=1:
            return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True

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

for Cx in range(101):
    for Cy in range(101):
        H=decide_H(Cx,Cy)
        if check_H(Cx,Cy,H):
            print(Cx,Cy,H)
            exit(0)

Solution (Python):
def decide_H(Cx,Cy):
    for x,y,h in T:
        H=h+abs(x-Cx)+abs(y-Cy)
        if h>=1:
            return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True

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

for Cx in range(101):
    for Cy in range(101):
        H=decide_H(Cx,Cy)
        if check_H(Cx,Cy,H):
            print(Cx,Cy,H)
            exit(0)

Solution (Python):
def get_H(Cx, Cy):
    for x, y, h in L:
        if h > 0:
            return abs(x - Cx) + abs(y - Cy) + h


def check_H(Cx, Cy, H):
    for x, y, h in L:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True


N = int(input())

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

for Cx in range(101):
    for Cy in range(101):
        H = get_H(Cx, Cy)
        if check_H(Cx, Cy, H):
            print('{} {} {}'.format(Cx, Cy, H))
            exit(0)

Solution (Python):
N=int(input())
p=[list(map(int, input().split())) for _ in range(N)]
ax, ay, ah = list(filter(lambda x: x[2], p))[0]
for i in range(101):
  for j in range(101):
    center=[i,j,ah+abs(ax-i)+abs(ay-j)]
    if all(t[2]==max(center[2]-abs(t[0]-center[0])-abs(t[1]-center[1]),0) for t in p) :
      print(center[0],center[1],center[2])

Solution (Python):
N=int(input())
p=[list(map(int, input().split())) for _ in range(N)]
ax, ay, ah = list(filter(lambda x: x[2], p))[0]
for i in range(101):
  for j in range(101):
    center=[i,j,ah+abs(ax-i)+abs(ay-j)]
    if all(t[2]==max(center[2]-abs(t[0]-center[0])-abs(t[1]-center[1]),0) for t in p) :
      print(center[0],center[1],center[2])

Solution (Python):
N = int(input())
p = [list(map(int, input().split()))for _ in range(N)]
ax, ay, ah = list(filter(lambda x: x[2], p))[0]
for x in range(101):
    for y in range(101):
        H = ah+abs(ax-x)+abs(ay-y)
        if all(max(H-abs(t[0]-x)-abs(t[1]-y), 0) == t[2]for t in p):
            print(x, y, H)

Solution (Python):
n = int(input())
p = [list(map(int, input().split()))for _ in range(n)]
ax, ay, ah = list(filter(lambda x: x[2], p))[0]
for x in range(101):
    for y in range(101):
        H = ah+abs(ax-x)+abs(ay-y)
        if all(max(H-abs(t[0]-x)-abs(t[1]-y), 0) == t[2]for t in p):
            print(x, y, H)

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

for i in range(101):
  for j in range(101):
    H=abs(B[-1][0]-i)+abs(B[-1][1]-j)+B[-1][2]
    for k in range(N-1):
      if max(H-abs(B[k][0]-i)-abs(B[k][1]-j),0)!=B[k][2]:
        break
    else:
      print(i,j,H)     
      exit()

Solution (Python):
N = int(input())
P = []
for i in range(N):
    x,y,h = map(int,input().split())
    P.append((x,y,h))
def f(x,y,h,i,j):
    H = h + max(x-i,i-x) + max(y-j,j-y)
    return H
for i in range(101):
    for j in range(101):
        Hi = []
        t = 1
        M = 10**100
        for k in range(N):
            x,y,h = P[k]
            if h == 0:
                H = f(x,y,h,i,j)
                M = min(M,H)
                continue
            H = f(x,y,h,i,j)
            if H > M:
                t = 0
            if H not in Hi:
                Hi.append(H)
        if len(Hi) != 1:
            t = 0
        else:
            if Hi[0] > M:
                t = 0
        if t == 1:
            print(i,j,Hi[0])
            quit()

Solution (Python):
n=int(input())
L=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[2])
for cx in range(101):
	for cy in range(101):
		H=L[-1][2]+abs(L[-1][0]-cx)+abs(L[-1][1]-cy)
		if all([L[i][2]==max(H-abs(L[i][0]-cx)-abs(L[i][1]-cy),0) for i in range(n-1)]):
				print(cx,cy,H)

Solution (Python):
import sys

n, *xyh = map(int, sys.stdin.read().split())
xyh = list(zip(*[iter(xyh)] * 3))

def conflict(cx, cy, ch, x, y, h):
    return h != max(ch - abs(x - cx) - abs(y - cy), 0)

def main():
    for x, y, h in xyh:
        if h >= 1:
            xt, yt, ht = x, y, h
            break
    
    for cx in range(101):
        for cy in range(101):
            ch = ht + abs(cx - xt) + abs(cy - yt)
            for x, y, h in xyh:
                if conflict(cx, cy, ch, x, y, h):
                    break
            else:
                return cx, cy, ch

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Solution (Python):
def main():
    n = int(input())
    X,Y,H = [],[],[]
    xyh = [list(map(int, input().split())) for _ in range(n)]
    xyh = sorted(xyh, key=lambda x:x[2], reverse=True)
    for i in range(n):
        X.append(xyh[i][0])
        Y.append(xyh[i][1])
        H.append(xyh[i][2])

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    xyh = sorted(xyh, key=itemgetter(2), reverse=True)

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    xyh = sorted(xyh, key=itemgetter(2), reverse=True)

    for cx in range(101):
        for cy in range(101):
            x, y, h = xyh[0]
            H = h + abs(x - cx) + abs(y - cy)
            is_correct = True
            for x, y, h in xyh:
                if h == 0:
                    if H - abs(x - cx) - abs(y - cy) > 0:
                        is_correct = False
                        break
                elif H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break

            if is_correct:
                print(cx, cy, H)
                return


if __name__ == '__main__':
    main()

Solution (Python):


N = int(input())

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

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

    for i in range(N):
      x, y, h = map(int, edges[i])
      if h > 0:
        htop = abs(x-cx) + abs(y-cy) + h

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

Solution (Python):

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

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

for X in range(101):
  for Y in range(101):

    for i in range(N):
      x, y, h = map(int, C[i])
      if h > 0:
        htop = abs(x-X) + abs(y-Y) + h
    
    for i in range(N):
      x, y, h = map(int, C[i])
      if h == 0:
        if htop - (abs(x-X) + abs(y-Y)) > 0:
          break
      if h > 0:
        if htop - (abs(x-X) + abs(y-Y)) != h:
          break
    else:
      print(X, Y, htop)
      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])
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):
import sys
bbn=1000000007
	

		
def main():
	n = int(input())
	pl=101
	
	ff=[0]*pl
	for i in range(pl):
		ff[i]=[0]*pl
	
	v=[]
	v0=[]
	for i in range(n):
		x, y, h = map(int, input().split())
		if h > 0:
			v.append([x,y,h])
		else:
			v0.append([x,y,h])
		
	
	tt=0
	for i, [xi, yi, hi] in enumerate(v):
		for [xj, yj, hj] in v[i+1:]:
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					if ihp==jhp:
						ff[px][py]+=1
	
	for i, [xi, yi, hi] in enumerate(v):
		for [xj, yj, hj] in v0:
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					if ihp<=jhp:
						ff[px][py]+=1
								
	for i, vl in enumerate(ff):
		for j, va in enumerate(vl):
			if va == tt:
				[x,y,h]=v[0]
				rh=h+abs(x-i)+abs(y-j)
				print(i,j,rh)
				return
	if len(v)	== 0:		
		raise NameError('HiThere')
	print(0,0,1)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
N = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(N)]
if len([h for _,_,h in XYH if h > 0]) == 1:
    print(*max(XYH, key=lambda xyh: xyh[2]))
    exit()
for cx in range(101):
    for cy in range(101):
        H = -1
        for x, y, h in XYH:
            if h:
                if H == -1:
                    H = h + abs(x-cx)+abs(y-cy)
                else:
                    if H != h + abs(x-cx)+abs(y-cy):
                        break
        else:
            print(cx, cy, H)
            exit()

Solution (Python):

















import numpy as np
from itertools import product

N = int(input())
X, Y, H = [], [], []
for n in range(N):
    x, y, h = list(map(int, input().split()))
    if h == 0:
        continue
    X.append(x)
    Y.append(y)
    H.append(h)

if len(H) == 1:
    print(X[-1], Y[-1], H[-1])
    exit()

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_ok(X, Y, H, a, b):
    height = H + np.abs(X - a) + np.abs(Y - b)
    if (height == height[-1]).all():
        return True, height[-1]
    else:
        return False, False


for a, b in product(range(101), range(101)):
    flg, ansH = is_ok(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

print(*ans)

Solution (Python):

















import numpy as np
from itertools import product

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

if N == 1:
    print(x, y, h)
    exit()

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_eq_loss(X, Y, H, a, b):
    loss = np.abs(- np.abs(X - a) - np.abs(Y - b) - H)
    mask = (H == 0)  
    if np.any(mask):
        loss[mask] = loss.min()
    if (loss[-1] == loss).all():
        return True, loss[-1]
    else:
        return False, False












def is_ok(X, Y, H, a, b):
    height = H + np.abs(X - a) + np.abs(Y - b)  
    if (height == height[-1]).all():
        return True, height[-1]
    else:
        return False, False


for a, b in product(range(101), range(101)):
    flg, ansH = is_eq_loss(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

print(*ans)

Solution (Python):
















import numpy as np
from itertools import product

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

if N == 1:
    print(x, y, h)
    exit()

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_eq_loss(X, Y, H, a, b):
    loss = np.abs(- np.abs(X - a) - np.abs(Y - b) - H)
    mask = (H == 0)  
    if np.any(mask):
        loss[mask] = loss.min()
    
    if (loss[-1] == loss).all():
        return True, loss[-1]
    else:
        return False, False


for a, b in product(range(101), range(101)):
    flg, ansH = is_eq_loss(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

print(*ans)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[LI() for _ in range(n)]

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

  ans=[]
  for Cx in range(101):
    for Cy in range(101):
      H=l[0][2]+abs(l[0][0]-Cx)+abs(l[0][1]-Cy)
      f=True
      for x,y,h in l[1:]:
        if h!=max(H-abs(x-Cx)-abs(y-Cy),0):
          f=False
          break
      if f:
        ans.append(str(Cx)+' '+str(Cy)+' '+str(H))
  if len(ans)==1:
    return ans[0]


print(main())

Solution (Python):
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
ok=False
for i in range(n):
  if a[i][2]==0:
    ok=True
for cx in range(101):
  for cy in range(101):
    s=float('inf')
    d={}
    for k in range(n):
      if a[k][2]==0:
        s=min(s,abs(a[k][0]-cx)+abs(a[k][1]-cy))
      else:
        if a[k][2]+abs(a[k][0]-cx)+abs(a[k][1]-cy) not in d:
          d[a[k][2]+abs(a[k][0]-cx)+abs(a[k][1]-cy)]=1
    if len(list(d))==1:
      c=list(d)
      if ok:
        if 1<=c[0]<=s:
          print(cx,cy,c[0])
          exit()
      else:
        if 1<=c[0]:
          print(cx,cy,c[0])
          exit()

Solution (Python):
N=int(input())
xyh=[]
for i in range(N):
    xyh.append(tuple(map(int,input().split())))
xyh.sort(key=lambda a:a[2],reverse=True)

fa=False
for CX in range(101):
    if fa:
        break
    for CY in range(101):
        f=lambda xi,yi,hi:hi+abs(xi-CX)+abs(yi-CY)
        H=f(xyh[0][0],xyh[0][1],xyh[0][2])
        fc=True
        for i in range(1,N):
            xi,yi,hi=xyh[i]
            if (hi>0 and H!=f(xi,yi,hi)) or (hi==0 and H>abs(xi-CX)+abs(yi-CY)):
                fc=False
                break
        if fc:
            print(CX,CY,H)
            fa=True
            break

Solution (Python):
n = int(input())
X, Y, H = [], [], []
for _ in range(n):
    x, y, h = map(int, input().split())
    X.append(x); Y.append(y); H.append(h)

for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if H[i] > 0:
                ch = H[i] + abs(cx-X[i]) + abs(cy-Y[i])
                break
        flg = True
        for i in range(n):
            if H[i] != max(ch-abs(cx-X[i])-abs(cy-Y[i]), 0):
                flg = False
                break
        if flg:
            print(cx, cy, ch)
            exit()

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

candidates =[]

for cx in range(101):
    for cy in range(101):
        ch = None
        for x,y,h in xyh:
            if h == 0:

                continue
            if ch == None:
                ch = h + abs(x-cx) + abs(y-cy)
                continue

            if ch != h + abs(x-cx) + abs(y-cy):
                break

        else:
            xyh_c = (cx, cy, ch)
            candidates.append(xyh_c)

for xyh_c in candidates:
    cx, cy, ch = xyh_c
    for x,y,h in xyh:
        if h != max(ch - abs(x-cx) - abs(y-cy) ,0):
            break
    else:
        print(cx, cy, ch)
        exit()

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

def calcH(x,y,h,Cx,Cy):
    if h>0:
        return(h+abs(x-Cx)+abs(y-Cy))
    return -1

for Cx in range(100+1):
    for Cy in range(100+1):
        H=-1
        check=[]
        for x,y,h in xyh:
            Hi=calcH(x,y,h,Cx,Cy)
            if Hi==-1:
                check.append(abs(x-Cx)+abs(y-Cy))
                continue
            if H==-1:
                H=Hi
            elif Hi!=H:
                break
        else:
            for c in check:
                if H>c:
                    break
            else:
                print(Cx,Cy,H)
                exit()

Solution (Python):
import itertools
import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


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


idx = np.where(H > 0)[0][0]


for x, y in itertools.product(range(101), range(101)):
    height = H[idx] + abs(X[idx] - x) + abs(Y[idx] - y)
    ok = np.all(np.maximum(0, height - (np.abs(X - x) + np.abs(Y - y))) == H)
    if ok:
        print(x, y, height)
        exit()

Solution (Python):
import itertools
import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


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


idx = (H > 0).argmax()

for x, y in itertools.product(range(101), range(101)):
    height = H[idx] + abs(X[idx] - x) + abs(Y[idx] - y)
    ok = np.all(np.maximum(0, height - (np.abs(X - x) + np.abs(Y - y))) == H)
    if ok:
        print(x, y, height)
        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.sort(reverse=True, key = lambda x:x[2])
for Cx in range(0,101):
    for Cy in range(0,101):
        height = data[0][2] + abs(Cx - data[0][0]) + abs(Cy - data[0][1])
        for i in range(1,n):
            if data[i][2] != max(height - abs(Cx - data[i][0]) - abs(Cy - data[i][1]), 0):
                break
            if i == n - 1:
                print("{} {} {}".format(Cx,Cy,height))
                exit()

Solution (Python):
def main():
    N = int(input())
    xn = []
    yn = []
    hn = []
    for i in range(N):
        xi, yi, hi = map(int, input().split())
        xn.append(xi)
        yn.append(yi)
        hn.append(hi)
    for Cx in range(101):
        for Cy in range(101):
            last = None
            flg = True
            for i in range(N):
                if 0 == hn[i]:
                    continue
                H = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if H < 1:
                    flg = False
                    break
                if last:
                    if H != last:
                        flg = False
                        break
                last = H
            if not flg:
                continue
            for i in range(N):
                if 0 == hn[i]:
                    h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                    if h < H:
                        flg = False
                        break
            if not flg:
                continue
            print(Cx, Cy, H)
            return


main()

Solution (Python):



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

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

for X in range(101):
  for Y in range(101):

    for i in range(N):
      x, y, h = map(int, C[i])
      if h > 0:
        htop = abs(x-X) + abs(y-Y) + h
    
    for i in range(N):
      x, y, h = map(int, C[i])
      if h == 0:
        if htop - (abs(x-X) + abs(y-Y)) > 0:
          break
      if h > 0:
        if htop - (abs(x-X) + abs(y-Y)) != h:
          break
    else:
      print(X, Y, htop)
      exit()

Solution (Python):
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int,input().split())))
flag = False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        h1 = set()
        zero = []
        for x,y,h in xyh:
            if h != 0:
                h1.add(h + abs(cx-x)+abs(cy-y))
            else:
                zero.append([x,y])

        if len(h1) == 1:
            ah = list(h1)[0]
            f = True
            for zx,zy in zero:
                if ah - abs(cx-zx) - abs(cy-zy) > 0:
                    f = False
            if f:
                ax = cx
                ay = cy
                flag = True
                break
print(ax,ay,ah)

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

k = 0
while li[k][2] == 0:
    k += 1
 
for x in range(101):
    for y in range(101):

        H = li[k][2]+abs(li[k][0]-x)+abs(li[k][1]-y)
        f = True

        for i in range(N):
            
            if li[i][2] != max(H-abs(li[i][0]-x)-abs(li[i][1]-y),0):
                f = False
                break
        if f:
            print(x,y,H)
            break
    else:
        continue
    break

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

k = 0
while li[k][2] == 0:
    k += 1
 
for x in range(101):
    for y in range(101):

        H = li[k][2]+abs(li[k][0]-x)+abs(li[k][1]-y)
        f = True

        for i in range(N):
            if li[i][2] != max(H-abs(li[i][0]-x)-abs(li[i][1]-y),0):
                f = False
                break
        if f:
            print(x,y,H)
            break
    else:
        continue
    break

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

k = 0
while li[k][2] == 0:
    k += 1
 
for x in range(101):
    for y in range(101):

        H = li[k][2]+abs(li[k][0]-x)+abs(li[k][1]-y)
        f = True

        for i in range(N):
            if li[i][2] > 0 and H != li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y):
                f = False
                break
            
            elif li[i][2] == 0 and H > abs(li[i][0]-x)+abs(li[i][1]-y):
                f = False
                break
        if f:
            print(x,y,H)
            break
    else:
        continue
    break

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

k = 0
while li[k][2] == 0:
    k += 1
 
for x in range(101):
    for y in range(101):

        H = li[k][2]+abs(li[k][0]-x)+abs(li[k][1]-y)
        f = True

        for i in range(N):
            if li[i][2] > 0 and H != li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y):
                f = False
                break
            
            elif li[i][2] == 0 and H > abs(li[i][0]-x)+abs(li[i][1]-y):
                f = False
                break
        if f == 1:
            print(x,y,H)
            break
    else:
        continue
    break

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

lis = []

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

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

for i in range(101):
    for j in range(101):
        h = abs(i-lis[0][0]) + abs(j-lis[0][1]) + lis[0][2]
        flag = True
        for k in range(1, n):
            dist = abs(i - lis[k][0]) + abs(j - lis[k][1])
            if h - dist == lis[k][2]:
                continue
            elif h - dist <= 0 and lis[k][2] == 0:
                continue
            else:
                flag = False
                break
        if flag is True:
            print(i, j, h)

Solution (Python):
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = MAP()
    x.append(xx)
    y.append(yy)
    h.append(hh)

kk = h.index(max(h))
k = 0

for i in range(101):
    for j in range(101):
        ass = h[kk] + abs(x[kk]-i) + abs(y[kk]-j)
        for r in range(n):
            if h[r]==0:
                if ass-abs(x[r]-i)-abs(y[r]-j)>0:
                    ass = -1
                    break
            else:
                if ass != abs(x[r]-i)+abs(y[r]-j)+h[r]:
                    ass = -1
                    break
        if ass!=-1:
            print(i,j,ass)
            break

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

for cx in range(101):
  for cy in range(101):
    ch = 0
    for _ in range(2):
      for x, y, h in xyh:
        if x==cx and y==cy:
          if ch!=0:
            if h!=ch:
              break
          else:
            ch = h
        else:
          nh = abs(x-cx) + abs(y-cy)
          if h == 0:
            if nh < ch:
              break
          else:
            nh += h
            if ch == 0:
              ch = nh
            else:
              if ch != nh:
                break
      else:
        continue
      break
    else:
      print(cx, cy, ch)
      exit()

Solution (Python):
n = int(input())
a = [list(map(int, input().split(' '))) for i in range(n)]
for x in range(101):
    for y in range(101):
        for i in range(n):
            if a[i][2] > 0:
                htop = a[i][2] + abs(x-a[i][0]) + abs(y-a[i][1])
                break
        for i in range(n):
            if a[i][2] == 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) > 0:
                    break
            if a[i][2] > 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) != a[i][2]:
                    break
        else:
            print(x,y,htop)
            exit()

Solution (Python):

import sys


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    for cx in range(0,101):
        for cy in range(0,101):
            H= 0
            for i in range(N):
                if h[i] != 0:
                    H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
            for i in range(N):
                if max(H - abs(x[i]-cx) - abs(y[i]-cy),0) != h[i]:
                        break
                else:
                    continue
            else:
                print(cx,cy,H)
                return

    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):
n = int(input())
a = [list(map(int, input().split(' '))) for i in range(n)]
for x in range(101):
    for y in range(101):
        for i in range(n):
            if a[i][2] > 0:
                htop = a[i][2] + abs(x-a[i][0]) + abs(y-a[i][1])
                break
        for i in range(n):
            if a[i][2] == 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) > 0:
                    break
            if a[i][2] > 0:
                if htop - (abs(x-a[i][0]) + abs(y-a[i][1])) != a[i][2]:
                    break
        else:
            print(x,y,htop)
            exit()

Solution (Python):
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
cnt=0
for a in A:
    if a[2]!=0:
        cnt+=1
        ans=a
if cnt==1:
    print(*ans)
    exit()
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True

        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)

            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        
        if flg:
            ans=[i,j,hi[0]]

print(*ans)