Problem:
 Score: 300 points    Problem Statement  In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had center coordinates  (C_X, C_Y) and height  H . The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0) .  Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:   C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1 .  Additionally, he obtained N pieces of information. The i -th of them is: "the altitude of point (x_i, y_i) is h_i ."   This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.      Constraints   N is an integer between 1 and 100 (inclusive).  x_i and y_i are integers between 0 and 100 (inclusive).  h_i is an integer between 0 and 10^9 (inclusive).  The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.  The center coordinates and the height of the pyramid can be uniquely identified.         Input  Input is given from Standard Input in the following format:  N  x_1  y_1  h_1  x_2  y_2  h_2  x_3  y_3  h_3  :  x_N  y_N  h_N       Output  Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.        Sample Input 1 4
2 3 5
2 1 5
1 2 5
3 2 5      Sample Output 1 2 2 6  In this case, the center coordinates and the height can be identified as (2, 2) and 6 .       Sample Input 2 2
0 0 100
1 1 98      Sample Output 2 0 0 100  In this case, the center coordinates and the height can be identified as (0, 0) and 100 . Note that C_X and C_Y are known to be integers between 0 and 100 .       Sample Input 3 3
99 1 191
100 1 192
99 0 192      Sample Output 3 100 0 193  In this case, the center coordinates and the height can be identified as (100, 0) and 193 .

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    XYH = [[int(i) for i in input().split()] for j in range(N)]
    XYH.sort(reverse=True, key=lambda p: p[2])

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


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
XYH = (tuple(map(int, input().split())) for _ in range(N))
XYH = np.array([input().split() for _ in range(N)], dtype=int)
X, Y, H = XYH.T

z = np.argmax(H)
x, y, h = XYH[z]

for Cx in range(0, 101):
    for Cy in range(0, 101):
        estH = h + abs(Cx - x) + abs(Cy - y)
        tmpH = np.maximum(0, estH - np.abs(X - Cx) - np.abs(Y - Cy))
        if np.all(H == tmpH):
            print(Cx, Cy, estH)
            exit()

Solution (Python):
n=int(input())
X=[]
Y=[]
H=[]
hi=int(0)
for i in range(n):
    x,y,h=map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h!=0:
        hi=i
for x in range(101):
    for y in range(101):
        now=H[hi]+abs(X[hi]-x)+abs(Y[hi]-y)
        ans=1
        for i in range(n):
            nowi=now-abs(X[i]-x)-abs(Y[i]-y)
            nowi=max([nowi,0])
            if H[i]!=nowi:
                ans=0
        if ans==1:
            print("{} {} {}".format(x,y,now))
            exit()

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    P = [[int(p) for p in input().split()] for _ in range(N)]
    Ans = [None, None, None]
    for x in range(101):
        for y in range(101):
            hight = 10 ** 20
            fixed = False
            for cx, cy, ch in P:
                if ch == 0: 
                    tempH = abs(x - cx) + abs(y - cy)
                    if not fixed: hight = min(hight, tempH)
                    else:
                        if tempH < hight: break
                else: 
                    tempH = ch + abs(x - cx) + abs(y - cy)
                    if not fixed: 
                        if hight < tempH: break
                        else: 
                            hight = tempH
                            fixed = True
                    else:
                        if hight != tempH: break
            else:
                Ans = [x, y, hight]
                break
        if Ans[0] != None: break

    print(" ".join(map(str, Ans)))
    
    return 0

if __name__ == "__main__":
    solve()

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

Solution (Python):
from operator import itemgetter


def main():
    n = int(input())
    data = sorted([[int(i) for i in input().split()] for _ in range(n)], key=itemgetter(2), reverse=True)
    if data[0][2] == 1 and (n == 1 or data[1][2] == 0):
        print(*data[0])
        return
    test, *valid = data

    for x in range(101):
        for y in range(101):
            h = abs(test[0] - x) + abs(test[1] - y) + test[2]
            for v in valid:
                if max(h - abs(x - v[0]) - abs(y - v[1]), 0) != v[2]:
                    break
            else:
                print(x, y, h)
                return

if __name__ == '__main__':
    main()

Solution (Python):



def main():
  n = int(input())
  xs, ys, hs = [], [], []
  for _ in range(n):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)
    
  for i in range(n):
    if hs[i] > 0:
      xx, yy, hh = xs[i], ys[i], hs[i]
      break
    
  for cx in range(0, 101):
    for cy in range(0, 101):
      H = hh + abs(cx - xx) + abs(cy - yy)
      flag = True
      for x, y, h in zip(xs, ys, hs):
        if not max(H-abs(x - cx)-abs(y-cy), 0) == h:
          flag = False
          break
      if flag:
        print(cx, cy, H)
        return

if __name__=='__main__':
  main()

Solution (Python):
def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  xyh=[list(map(int,input().split())) for _ in [0]*n]
  xx,yy,hh=sorted(xyh,key=lambda x:x[2])[-1]
  for cx in range(101):
    for cy in range(101):
      H=hh+abs(xx-cx)+abs(yy-cy)
      for x,y,h in xyh:
        if max(H-abs(x-cx)-abs(y-cy),0)!=h:
          break
      else:
        print(cx,cy,H) 
        exit()
if __name__=='__main__':
  main()

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


for x,y,h in xyh:
    if h!=0:
        xs,ys,hs=x,y,h


for cx in range(100+1):
    for cy in range(100+1):
        guessed_H = hs+abs(xs-cx)+abs(ys-cy)
        if all([max(0,guessed_H-abs(cx-x)-abs(cy-y))==h for x,y,h in xyh]):
            print(cx,cy,guessed_H)

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

for i in range(N):
    if xyh[i][2] != 0:
        xs, ys, hs = xyh[i]

for xt in range(101):
    for yt in range(101):
        ht = hs + abs(xt - xs) + abs(yt - ys)
        if all([xyh[i][2] == max(0, ht - abs(xt-xyh[i][0]) - abs(yt-xyh[i][1])) for i in range(N)]):
            xa, ya, ha = xt, yt, ht
            
print(xa,ya,ha)

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
for i in range(N):
    if xyh[i][2] != 0:
        xs, ys, hs = xyh[i]
for xt in range(101):
    for yt in range(101):
        ht = hs + abs(xt - xs) + abs(yt - ys)
        if all([xyh[i][2] == max(0, ht - abs(xt-xyh[i][0]) - abs(yt-xyh[i][1])) for i in range(N)]):
            xa, ya, ha = xt, yt, ht
print(xa,ya,ha)

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

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

for x in range(101):
    for y in range(101):
        h=xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
        flag = True
        for X,Y,H in xyh[1:]:
            if H != max(h-abs(x-X)-abs(y-Y),0):
                flag = False
                break
        if flag:
            print(x,y,h)
            exit()

Solution (Python):
N = int(input())
X = []
Y = []
hh = []
vec = list()
G = (-1,-1,-1)

for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    hh.append(h)
    
    if h >= 1:
        G = (x, y, h)

for i in range(0,101):
    for j in range(0,101):
        
        H = G[2] + abs(G[0] - i) + abs(G[1] - j)
        H = max(H, 0)
        flag = True
        for k in range(N):
            key = H - abs(X[k] - i) - abs(Y[k] - j)
            key = max(key, 0)
            if key != hh[k]:
                flag = False
        
        if flag:
            vec.append((i,j,H))

if len(vec) == 1:
    print(vec[0][0], vec[0][1], vec[0][2])

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

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

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

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

x_, y_, h_ = sorted(dots, key=lambda x: x[2], reverse=True)[1]

for cx in range(101):
    for cy in range(101):
        H = h_+abs(x_ - cx) + abs(y_ - cy)

        ans = []
        for x, y, h in dots:
            if max(H - abs(x-cx)-abs(y-cy), 0) == h:
                ans.append((cx, cy, H))

        if len(ans) == n:
            print(*ans[0])
            exit()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
X = []
Y = []
H = []
ans = ()
for i in range(n):
    x, y, h = LI()
    if h:
        r = i
    X += [x]
    Y += [y]
    H += [h]




for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = X[r], Y[r], H[r]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for i in range(n):
            if H[i] != max(h - abs(cx - X[i]) - abs(cy - Y[i]), 0):
                break
        else:
            print(cx, cy, h)
            exit()

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


sx, sy, sh = sorted(xyh, key=lambda x: x[-1])[-1]


for cx in range(101):
    for cy in range(101):
        H = abs(sx - cx) + abs(sy - cy) + sh
        for x, y, h in xyh:            
            if max(H - abs(x - cx) - abs(y - cy), 0) != h:
                break
        else:
            ans = cx, cy, H
print(*ans)

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

for cx in range(101):
    for cy in range(101):
        H = point[0][2]+abs(cx-point[0][0])+abs(cy-point[0][1])
        OK = True
        for i in range(N):
            if not point[i][2]==max(H-abs(cx-point[i][0])-abs(cy-point[i][1]),0):
                OK = False
                break
        if OK:
            print(cx,cy,H)
            sys.exit(0)

Solution (Python):
def check_h(x, y, xy_):
    difference_h = abs(x-xy_[0]) + abs(y-xy_[1])
    return difference_h

def main():
    n = int(input())
    xyh = [list(map(int, input().split())) for _ in range(n)]
    get_h = [xyh[i][2] for i in range(n)]
    X, Y, H = xyh[get_h.index(max(get_h))]

    for i in range(101):
        for j in range(101):
            xy = [i, j]
            h = H + check_h(X, Y, xy)
            if h >= H:
                if all(xyh[s][2]==max(h-check_h(xyh[s][0], xyh[s][1], xy), 0) for s in range(n)):
                    print(i, j, h)
                    break
    return 0

if __name__=="__main__":
    main()

Solution (Python):
def check_h(x, y, xy_):
    difference_h = abs(x-xy_[0]) + abs(y-xy_[1])
    return difference_h

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

    for x_, y_, h_ in xyh:
        if h_ != 0:
            X, Y, H = x_, y_, h_
            break

    for i in range(101):
        for j in range(101):
            xy = [i, j]
            h = H + check_h(X, Y, xy)
            if h >= H:
                if all(xyh[s][2]==max(h-check_h(xyh[s][0], xyh[s][1], xy), 0) for s in range(n)):
                    print(i, j, h)
                    break
    return 0

if __name__=="__main__":
    main()

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

for i in range(n):
    if(xyh[i][2]!= 0):
        x = xyh[i][0]
        h = xyh[i][2]
        y = xyh[i][1]
        break
for i in range(101):
    for j in range(101):
        
        H = h+ abs(x - i)+abs(y - j)
        ok = True
        
        for k in range(n):
            nowx = xyh[k][0]
            nowy = xyh[k][1]
            nowh = xyh[k][2]
            if nowh != max(H - abs(nowx - i) - abs(nowy - j),0):
                ok = False
                break
        if ok :
            print(i,j,H)
            break

Solution (Python):
n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    if(xyh[i][2]!= 0):
        x = xyh[i][0]
        h = xyh[i][2]
        y = xyh[i][1]
        break
for i in range(101):
    for j in range(101):
        H = h+ abs(x - i)+abs(y - j)
        ok = True
        for k in range(n):
            nowx = xyh[k][0]
            nowy = xyh[k][1]
            nowh = xyh[k][2]
            if nowh != max(H - abs(nowx - i) - abs(nowy - j),0):
                ok = False
                break
        if ok :
            print(i,j,H)
            break

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007


def main():
	N = inputInt()
	xyz = []
	for i in range(N):
		x,y,h = inputMap()
		xyz.append((x,y,h))

	for ansY in range(0,101):
		for ansX in range(0,101):
			ansH = -1
			for i,val in enumerate(xyz):
				x,y,h = val
				if h > 0:
					tmp = h + abs(ansX-x) + abs(ansY-y)
					if ansH == -1:
						ansH = tmp
					else:
						if tmp != ansH:
							ansH = -2
							break
			
			if ansH == -2:
				continue

			for i,val in enumerate(xyz):
				x,y,h = val
				if h == 0:
					tmp = abs(ansX-x) + abs(ansY-y)
					if ansH > tmp:
						ansH = -2
						break
			if ansH == -2:
				continue

			print("{} {} {}".format(ansX,ansY,ansH))








def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

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

def get_H(Cx, Cy):
    for x, y, h in L:
        if h == 0:
            continue
        H = h + abs(x - Cx) + abs(y - Cy)
        if H >= 1:
            return H

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

for Cx in range(101):
    for Cy in range(101):
        H = get_H(Cx, Cy)
        if check(Cx, Cy, H):
            print(Cx, Cy, H)
            exit()

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

for x in range(101):
    for y in range(101):
        ans=True
        H=xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
        for n in range(1,N):
            if H!=xyh[n][2]+abs(x-xyh[n][0])+abs(y-xyh[n][1]) and xyh[n][2]!=0:
                ans=False
                break
        if ans:
            for n in range(1,N):
                if max(H-abs(x-xyh[n][0])-abs(y-xyh[n][1]),0)!=xyh[n][2]:
                    ans=False
                    break
            if ans:
                print(x,y,H)
                exit()

Solution (Python):
import sys

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

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

Solution (Python):
def High(cx, cy, x, y, h):
    return h + abs(x-cx) + abs(y-cy)

def high(cx, cy, x, y, High):
    return max(High - abs(x-cx) - abs(y-cy), 0)

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

from operator import itemgetter
l = sorted(l, key=itemgetter(2) , reverse=1)

for i in range(101):
    for j in range(101):
        H = High(l[0][0], l[0][1], i, j, l[0][2])
        for k in l[1:]:
            if high(k[0], k[1], i, j, H) != k[2]:
                break
        else:
            print(i, j, H)
            break

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

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

for i in range(101):
    for j in range(101):
        h = abs(l[0][0] - i) + abs(l[0][1] - j) + l[0][2]
        if h<=0:
            continue

        ok=True
        for k in range(len(l)):
            tmp_h = max(h - abs(l[k][0] - i) - abs(l[k][1] - j),0)
            if tmp_h != l[k][2]:
                ok=False
                break
        if ok:
            print(i,j,h)
            exit()

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

for i in range(n):
    arr.append([int(s) for s in input().split(" ")])



import math

def calculate(n, arr):
    for i in range(101):
        for j in range(101):

            centerH = -100

            for ar in arr:
                posX = ar[0]
                posY = ar[1]
                posH = ar[2]

                if posH > 0:

                    if centerH == -100:
                        centerH = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))
                        continue

                    tmp = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))

                    if tmp != centerH:
                        centerH = -2
                        break

            for ar in arr:
                posX = ar[0]
                posY = ar[1]
                posH = ar[2]
                if posH == 0:
                    if int(math.fabs(i - posX)) + int(math.fabs(j - posY)) < centerH:
                        centerH = -2
                        break

            if centerH != -2:
                print(i, j, centerH)





calculate(n, arr)

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for j in range(N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        H = 1
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for j in range(N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

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

for cx in range(101):
    for cy in range(101):
        d = set()
        for i in range(n):
            h = 0
            if plot[i][2] > 0:
                h = abs(plot[i][0] - cx) + abs(plot[i][1] - cy) + plot[i][2]
                d.add(h)
        if len(d) == 1:
            flag = True
            for i in range(n):
                H = list(d)[0]
                h = max(H - abs(plot[i][0] - cx) - abs(plot[i][1] - cy), 0)
                if h != plot[i][2]:
                    flag = False
            if flag:
                print(cx,cy,H)
                sys.exit(0)

Solution (Python):
N = int(input())
ls = [None]*N
ind = None
for i in range(N):
    ls[i] = tuple(map(int,input().split()))
    if ls[i][2] > 0:
        ind = i
for cx in range(101):
    for cy in range(101):
        flag = True
        x,y,h = ls[ind]
        H = h+abs(x-cx)+abs(y-cy)
        for i in range(N):
            x,y,h = ls[i]
            if h != max(0,H-abs(x-cx)-abs(y-cy)):
                flag = False
                break
        if flag:
            print(cx,cy,H)
            exit(0)

Solution (Python):
N = int(input())
X, Y, H = [], [], []
target = (-1, -1, -1)
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h >= 1:
        target = (x, y, h)

for cx in range(101):
    for cy in range(101):
        v = target[2] + abs(target[0] - cx) + abs(target[1] - cy)
        v = max(v, 0)
        flag = True
        for x, y, h in zip(X, Y, H):
            vv = v - abs(x - cx) - abs(y - cy)
            vv = max(vv, 0)
            if h != vv:
                flag = False
                break
        if flag:
            print(cx, cy, v)
            exit()

Solution (Python):

N=int(input())
pyramid=[]
for i in range(N):
    x,y,h=map(int,input().split())
    pyramid.append((x,y,h))
pyramid=sorted(pyramid,key=lambda x:x[2])[::-1]

Ans=[]

for cx in range(0,101):
    for cy in range(0,101):
        flg=True
        H=pyramid[0][2]+abs(cx-pyramid[0][0])+abs(cy-pyramid[0][1])
        for i in range(1,N):
            h=max(H-abs(cx-pyramid[i][0])-abs(cy-pyramid[i][1]),0)
            if h!=pyramid[i][2]:
                flg=False
        if flg:
            Ans=[cx,cy,H]
            break
print(*Ans)

Solution (Python):
import numpy as np
N = int(input())
XYH = np.array([input().split() for _ in range(N)], dtype=np.int64)
x, y, h = XYH[XYH[:, 2] != 0][0].T
X, Y, H = XYH.T

for Cx in range(101):
    for Cy in range(101):
        estimated_heights = h + abs(x - Cx) + abs(y - Cy)
        if (np.clip(estimated_heights - np.abs(X - Cx) - np.abs(Y - Cy), 0, None) == H).all():
            print(Cx, Cy, estimated_heights)
            quit()

Solution (Python):
from operator import itemgetter
n=int(input())
data=[]
for i in range(n):
    x0,y0,h0=map(int,input().split())
    data.append([h0,x0,y0])
data.sort(reverse=True)
if n==1 or data[1][0]==0:
    print(data[0][1],data[0][2],data[0][0])
else:
    x=0
    y=0
    buf=0
    for cx in range(101):
        buf=0
        for cy in range(101):
            buf=0
            h=data[0][0]+abs(data[0][1]-cx)+abs(data[0][2]-cy)
            for i in range(1,n):
                if data[i][0]==0:
                    break
                else: 
                    h_i=data[i][0]+abs(data[i][1]-cx)+abs(data[i][2]-cy)
                    if h_i!=h:
                        buf=1
                        break
            if buf==0:
                x=cx
                y=cy
                break
        if buf==0:
            break
    print(x,y,h)

Solution (Python):
def main():
    n=int(input())
    A=[list(map(int,input().split())) for i in range(n)]
    A.sort(key=lambda x:x[2],reverse=True)
    for cx in range(101):
        for cy in range(101):
            flag=True
            h=abs(A[0][0]-cx)+abs(A[0][1]-cy)+A[0][2]
            for i in range(1,n):
                if A[i][2]>0:
                    if h!=abs(A[i][0]-cx)+abs(A[i][1]-cy)+A[i][2]:
                        flag=False
                        break
                else:
                    if h-abs(A[i][0]-cx)-abs(A[i][1]-cy)>0:
                        flag=False
                        break
            if flag:
                print(cx,cy,h)
                exit()
if __name__=='__main__':
    main()

Solution (Python):
n = int(input())
x = []
y = []
h = []
I = 0
for i in range(n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c > 0:
        I = i
H = 0
X = Y = 0
flag = 0
cnt = 0
for i in range(101):
    for j in range(101):
        tmp = abs(x[I]-i) + abs(y[I]-j) + h[I]
        for k in range(n):
            if h[k] > 0:
                cnt += 1
                if tmp != abs(x[k]-i) + abs(y[k]-j) + h[k]:
                    break
        else:
            if cnt == 1:
                print(x[I], y[I], h[I])
                exit(0)
            else:
                H = tmp
                X = i
                Y = j
print(X, Y, H)

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

for e in xyh:
    if e[2] != 0:
        t = e

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

for e in xyh:
    nc = []
    for c in candidates:
        if e[2] == max(c[2] - abs(e[0] - c[0]) - abs(e[1] - c[1]), 0):
            nc.append(c)
    candidates = nc

print(*candidates[0])

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

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

    H = -1
    for x in range(0, 101):
        for y in range(0, 101):
            for xi, yi, hi in XYH:
                abs_xy = abs(x - xi) + abs(y - yi)
                if H < 0 and hi > 0:
                    H = hi + abs_xy
                elif hi != max(H - abs_xy, 0):
                    H = -1
                    break
            else:
                if H > 0:
                    print(x, y, H)
                    exit()

if __name__ == '__main__':
    main()

Solution (Python):
ll = [list(map(int,input().split())) for _ in range(int(input()))]
x,y,h = list(filter(lambda k:k[2],ll))[0]
for cx in range(101):
  for cy in range(101):
    ch = h+abs(x-cx)+abs(y-cy)
    if all(max(ch-abs(x-cx)-abs(y-cy),0)==h for x,y,h in ll): print(cx,cy,ch); exit()

Solution (Python):
ll = sorted([list(map(int,input().split())) for _ in range(int(input()))],key=lambda k:k[2])
x,y,h = ll[-1]
for cx in range(101):
  for cy in range(101):
    ch = h+abs(x-cx)+abs(y-cy)
    if all(max(ch-abs(x-cx)-abs(y-cy),0)==h for x,y,h in ll): print(cx,cy,ch); exit()

Solution (Python):
ll = [list(map(int,input().split())) for _ in range(int(input()))]
ll.sort(key=lambda k:k[2],reverse=1)
x,y,h = ll[0]
for cx in range(101):
  for cy in range(101):
    ch = h+abs(x-cx)+abs(y-cy)
    for x,y,h in ll:
      if max(ch-abs(x-cx)-abs(y-cy),0) != h:
        break
    else:
      print(cx,cy,ch)
      break
  else:
    continue
  break

Solution (Python):
n = int(input())
ll = sorted([list(map(int,input().split())) for _ in range(n)],key=lambda k:k[2])[::-1]
for cx in range(101):
  for cy in range(101):
    ch = ll[0][2]+abs(ll[0][0]-cx)+abs(ll[0][1]-cy)
    for x,y,h in ll:
      if max(ch-abs(x-cx)-abs(y-cy),0) != h:
        break
    else:
      print(cx,cy,ch)
      break
  else:
    continue
  break

Solution (Python):
def abs(x1,x2):
    if x1>x2:
        return x1-x2
    else:
        return x2-x1
    
n=int(input())
x=[]
y=[]
h=[]

for i in range(n):
    xi,yi,hi=map(int,input().split())
    x.append(xi)
    y.append(yi)
    h.append(hi)

hmax=h[0]
xhmax=x[0]
yhmax=y[0]
ihmax=0

for i in range(n):
    if hmax<h[i]:
        hmax=h[i]
        xhmax=x[i]
        yhmax=y[i]
        ihmax=i
    
for cx in range(101):
    for cy in range(101):
        hh=hmax+abs(xhmax,cx)+abs(yhmax,cy)
        yesno="yes"
        for i in range(n):
            if h[i]!=max(hh-abs(x[i],cx)-abs(y[i],cy),0):
                yesno="no"
                break
        if yesno=="yes":
            print(cx,cy,hh)
            break
    if yesno=="yes":
        break