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 = [list(map(int, input().split())) for i in range(N)]

for cx in range(101):
    for cy in range(101):
        needH = -1

        for x, y, h in xyh:
            if h > 0:
                
                tmp = h + abs(cx - x) + abs(cy - y)
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break

        if needH == -2:
            continue

        for x, y, h, in xyh:
            if h == 0:
                dist = abs(cx - x) + abs(cy - y)
                if needH > dist:
                    needH = -2
                    break
        if needH == -2:
            continue

        print(cx, cy, needH)
        exit()

Solution (Python):
N=int(input())
xyh=[list(map(int,input().split())) for i in range(N)]
MAX=100
for PosY in range(MAX+1):
    for PosX in range(MAX+1):
        needH=-1
        for i in range(N):
             if xyh[i][2]>0:
                tmp=xyh[i][2]+abs(PosX-xyh[i][0])+abs(PosY-xyh[i][1])
                if needH==-1:
                    needH=tmp
                else:
                    if needH!=tmp:
                        needH=-2
                        break
        if needH==-2:
            continue
        for i in range(N):
            if xyh[i][2]==0:
                dist=abs(PosX-xyh[i][0])+abs(PosY-xyh[i][1])
                if needH>dist:
                    needH=-2
                    break
        if needH==-2:
            continue
        print(PosX,PosY,needH)

Solution (Python):
import numpy as np

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

N = int(input())
X = np.zeros(N, dtype = int)
Y = np.zeros(N, dtype = int)
H = np.zeros(N, dtype = int)

Q = sorted([inpl() for i in range(N)], key = lambda x:x[2],reverse = True)

for j, q in enumerate(Q) :
    X[j],Y[j],H[j] = q

for cx in range(101) :
    for cy in range(101) :
        cH = H[0]+abs(X[0]-cx)+abs(Y[0]-cy)
        if np.all(H == np.maximum((cH-np.abs(X-cx)-np.abs(Y-cy)),0)) :
                  print(cx,cy,cH)

Solution (Python):
"""
C - Pyramid
"""

import numpy as np

n = int(input())

points = []
for i in range(n):
    part = list(map(int, input().split()))
    points.append(part)




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

        
        
        
        need_h = -1
        for point in points:

            
            if point[2] > 0:
                
                temp = point[2] + abs(cx - point[0]) + abs(cy - point[1])
                if need_h == -1:
                    need_h = temp
                else:
                    if need_h != temp:
                        need_h = -2
                        break
                
        if need_h == -2:
            continue
        
        
        for point in points:
            if point[2] == 0:
                dist = abs(cx - point[0]) + abs(cy - point[1])
                if need_h > dist:
                    need_h = -2
                    break
        
        if need_h == -2:
            continue
        
        print(cx, cy, need_h)
        exit()

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

for CX in range(101):
    for CY in range(101):
        H = -1
        ans = True
        for x, y, h in xyh:
            if h > 0:
                if H == -1:
                    H = h + abs(CX - x) + abs(CY - y)
                else:
                    if H != h + abs(CX - x) + abs(CY - y):
                        ans = False
                        break
            if not ans:
                break

        for x, y, h in xyh:
            if ans and h == 0:
                if H > h + abs(CX - x) + abs(CY - y):
                    ans = False

        if ans:
            print(CX, CY, H)
            break

    if ans:
        break

Solution (Python):
def main():
    """
    1 <= N      <= 100
    0 <= xi, yi <= 100
    0 <= hi     <= 10^9
    """
    N = int(input())
    x, y, h = zip(*(
        map(int, input().split())
        for _ in range(N)
    ))

    
    ans = editorial_movie(x, y, h)
    print(*ans)


def h_H(cx, cy, x, y):
    return - abs(x - cx) - abs(y - cy)


def no_sub(x, y, h):
    max_h = -1
    ans = None
    dict_h = {(_x, _y): _h for _x, _y, _h in zip(x, y, h)}
    for _x, _y, _h in zip(x, y, h):
        for cx in range(1, 100+1):
            for cy in range(1, 100+1):
                tmp = h_H(cx, cy, _x, _y)
                pos = (cx, cy)
                H = _h - tmp
                if pos in dict_h and H != dict_h[pos]:
                    continue

                if H > max_h:
                    max_h = H
                    ans = _x, _y, H

                

    return ans


def editorial_movie(x, y, h):
    """
    H >= 1, これ重要
        コンテスト中にこれを意識していなかった
        入力の制約しか意識していなかった

    h(x, y) = max(H - |x - Cx| - |y - Cy|, 0)
    より
        h(x,y) > 0: H  = h(x, y) + |x - Cx| - |y - Cy|
        h(x,y) = 0:
            頂点なら制約を満たしていない
                    H <= h(x, y) + |x - Cx| - |y - Cy|
    """
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            
            
            
            need_h = -1

            
            for _x, _y, _h in zip(x, y, h):
                if not _h > 0:
                    continue

                
                tmp = _h + abs(_x - cx) + abs(_y - cy)
                if need_h == -1:
                    need_h = tmp
                elif need_h != tmp:
                    need_h = -2
                    break

            if need_h == -2:
                continue

            
            for _x, _y, _h in zip(x, y, h):
                if not _h == 0:
                    continue

                
                dist = abs(_x - cx) + abs(_y - cy)
                if need_h > dist:
                    need_h = -2
                    break

            if need_h == -2:
                continue

            return cx, cy, need_h


if __name__ == '__main__':
    main()

Solution (Python):

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

ans = None
for cx in range(101):
    for cy in range(101):
        H_tmp = -1
        
        for xi, yi, hi in sorted(xyh, key=lambda x: -x[2]):
            
            dx = (xi - cx) if xi >= cx else (cx - xi)
            dy = (yi - cy) if yi >= cy else (cy - yi)
            if H_tmp == -1: H_tmp = hi + dx + dy
            elif hi == 0:
                if dx + dy < H_tmp: break
                else: continue
            elif H_tmp == hi + dx + dy: H_tmp = hi + dx + dy
            else: break
        else:
            ans = (cx, cy, H_tmp)
        if ans != None: break
    if ans != None: break

print(ans[0], ans[1], ans[2])

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
key = False
for CX in range(101):
    for CY in range(101):
        ans = True
        H = -1
        for x, y, h in xyh:
            if h > 0:
                tmp = h + abs(x - CX) + abs(y - CY)
                if H == -1:
                    H = tmp
                else:
                    if H != tmp:
                        H = -2
                        break

        if H == -2:
            continue

        for x, y, h in xyh:
            if h == 0:
                dist = abs(x - CX) + abs(y - CY)
                if H > dist:
                    H = -2
                    break
                
        if H == -2:
            continue
        
        print(CX, CY, H)
        key = True
        break
        
    if key:
        break

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




hxy.sort(reverse=True)

MAX_X = 100
MAX_Y = 100

H = {(x, y): None for x in range(MAX_X + 1) for y in range(MAX_Y + 1)}

for h, x, y in hxy:
    for cx, cy in list(H.keys()):
        hh = h + abs(x - cx) + abs(y - cy)
        if   H[(cx, cy)] == None:
             H[(cx, cy)] =  hh
        elif H[(cx, cy)] > hh or (h > 0 and H[(cx, cy)] != hh):
             del H[(cx, cy)]

for cx, cy in H:
    print(cx, cy, H[(cx, cy)])

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

for i in range(n):
    if xyh[i][2] != 0:
        x1,y1,h1 = xyh[i]
        break

for cx in range(101):
    for cy in range(101):
        ch = h1 + abs(x1 - cx) + abs(y1 - cy)
        
        a = 0
        for i in range(n):
            xi, yi, hi = xyh[i]
            if hi == max(ch - abs(xi - cx) - abs(yi - cy), 0):
                a += 1
            else:
                break
        
        if a == n:
            print(cx,cy,ch)

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(101):
        for j in range(101):
            rh = inf
            for x,y,h in a:
                th = h + abs(i-x) + abs(j-y)
                if rh > th:
                    rh = th
            f = True
            for x,y,h in a[1:]:
                if max(rh - abs(i-x) - abs(j-y),0) != h:
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

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

A.sort(key=lambda x:x[2],reverse=True)
h_highest=A[0][2]

for cx in range(101):
	for cy in range(101):
		for H in range( max(h_highest-200,0), h_highest+200):
			for x,y,h in A:
				if h==max( H-abs(x-cx)-abs(y-cy), 0):
					pass
				else:
					break
			else:
				print cx,cy,H
				quit()

Solution (Python):
from operator import itemgetter

N = int(input())

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

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

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

Solution (Python):
import sys
N=int(input())
table=[]
def f(cx,cy,h,x,y):
    return max(h-abs(x-cx)-abs(y-cy),0)
for i in range(N):
    x,y,h=map(int,input().split())
    table.append((x,y,h))
for cx in range(101):
    for cy in range(101):
        n=0
        h=0
        while n<N:
            x,y,z=table[n]
            if z>0:
                h=z+abs(cx-x)+abs(cy-y)
                break
            n+=1
        flag=True
        for x,y,z in table:
            if f(cx,cy,h,x,y)!=z:
                flag=False
                break
        if flag:
            print(cx,cy,h)
            sys.exit()

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

x_list=[]
y_list=[]
h_list=[]


def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)
		
for cy in range(101):
	for cx in range(101):
		n = -1	
		for h in h_list:
			n += 1
			if h >= 1:
				H = abs(cx - x_list[n])+abs(cy - y_list[n])+h
				h_now_list=[]
				break
		for i in range(N):
			h_now = max((H-abs(cx - x_list[i])-abs(cy - y_list[i])), 0)
			h_now_list.append(h_now)
			if h_now != h_list[i]:
				break	
			else:
				if len(h_now_list)==N:
					print(str(cx)+' '+str(cy)+' '+str(H))
					break
	else:
		continue
	break

Solution (Python):
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)

if iN == 1:
    print(aData[0][0],aData[0][1],aData[0][2])
else:
    z0 = aData[0][2]
    bF = False
    for i in range(iN):
        if z0 > aData[i][2]:
            break
        else:
            bF = True
    x0 = aData[0][0]
    y0 = aData[0][1]
    xi = aData[i][0]
    yi = aData[i][1]
    if bF or x0 == xi:
        RangeX = range(0,101)
    elif xi < x0:
        RangeX = range(x0,101)
    else:
        RangeX = range(x1,-1,-1)
    if bF or y0 == yi:
        RangeY = range(0,101)
    elif yi < y0:
        RangeY = range(y0,101)
    else:
        RangeY = range(y0,-1,-1)

    for cx in RangeX :
        for cy in RangeY :
            h = 0
            bF = True
            for x,y,z in aData :
                d = abs(x-cx)+abs(y-cy)
                if z > 0 :
                    if h == 0 :
                        h = z + d
                    else :
                        if h != z + d:
                            bF = False
                            break
                else :
                    if h > d:
                        bF = False
                        break
            if bF :
                print(cx,cy,h)
                exit()

Solution (Python):
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)

for cx in range(0,101) :
    for cy in range(0,101) :
        h = 0
        bF = True
        for x,y,z in aData :
            d = abs(x-cx)+abs(y-cy)
            if z > 0 :
                if h == 0 :
                    h = z + d
                else :
                    if h != z + d:
                        bF = False
                        break
            else :
                if h > d:
                    bF = False
                    break
        if bF :
            print(cx,cy,h)
            exit()

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

in_list = []
x0, y0, h0 = 0, 0, 0
for i in range(N):
    xyh = list(map(int, input().split()))
    in_list.append(xyh)

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

for Cx in range(0, 101):
    for Cy in range(0, 101):
        for xyh in in_list:
            x, y, h = xyh[0], xyh[1], xyh[2]
            H = h0 + abs(x0-Cx) + abs(y0-Cy)
            if h != max(H-abs(x-Cx)-abs(y-Cy), 0):
                break
        else:
            print(Cx, Cy, H)

Solution (Python):
N = int(input())
X, Y, H = [], [], []

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

    for posY in range(101):
        for posX in range(101):

            
            
            
            needH = -1
            
            for i in range(N):

                
                if H[i] > 0:
                    
                    
                    
                    tmp = H[i] + abs(posY - Y[i]) + abs(posX - X[i])

                    
                    if needH == -1:
                        needH = tmp
                    
                    elif needH != tmp:
                        needH = -2
                        break

            
            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)
            return 0

if __name__ == '__main__':
    main()

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

XYH = set()
flag = True
for i in range(N):
    x, y, h = map(int, input().split())
    if (flag is True) and h > 0:
        flag = False
        ex_x = x
        ex_y = y
        ex_h = h
        continue
    XYH.add((x, y, h))

flag = False
for x in range(0, 101):
    for y in range(0, 101):
        
        hight = ex_h + abs(x - ex_x) + abs(y - ex_y)
        for tx, ty, th in XYH:
            div = abs(x - tx) + abs(y - ty)
            if div > hight:
                if th == 0:
                    continue
                else:
                    break

            if hight != th + abs(x - tx) + abs(y - ty):
                break
        else:
            print(x, y, hight)
            exit()

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

x0, y0, h0 = 0, 0, 0


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

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

Solution (Python):
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)

for cx in range(0,101) :
    for cy in range(0,101) :
        aH = []
        uH = False
        bF = True
        for x,y,z in aData :
            d = abs(x-cx)+abs(y-cy)
            if z > 0 :
                aH.append( z + d )
            else :
                if aH[0] > d:
                    bF = False
                if uH :
                    uH = min(uH,d)
                else :
                    uH = d
        for i in range(1,len(aH)) :
            if aH[0] != aH[i] :
                bF = False
        if uH :
            if uH < aH[0] :
                bF = False
        if bF :
            print(cx,cy,aH[0])
            exit()

Solution (Python):
N = int(input())
xyhlist = []
idx = -1
for i in range(N):
    xyhlist.append(tuple(map(int, input().split())))
    if xyhlist[-1][2] > 0:
        idx = i

px, py, ph = xyhlist[idx]
for cx in range(101):
    for cy in range(101):
        ch = abs(px - cx) + abs(py - cy) + ph

        ok = True
        for (x, y, h) in xyhlist:
            if max(ch - abs(x - cx) - abs(y - cy), 0) != h:
                ok = False
                break
        if ok:
            print(cx, cy, ch)
            break

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

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

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


def search():
    for Cx in range(101):
        for Cy in range(101):
            x, y, h = tuple(coords[0])
            H = h + abs(Cx - x) + abs(Cy - y)
            for x, y, h in coords:
                if max(H - abs(Cx - x) - abs(Cy - y), 0) != h:
                    break
            else:
                return Cx, Cy, H

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

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

flag = False

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

for cx in range(102):
    if flag:
        break
    for cy in range(102):
        if flag:
            break
        ll = []
        flag = True
        for i in range(N):
            x,y,h = l[i]
            if i == 0:
                H = h+abs(x-cx)+abs(y-cy)
            if h != 0:
                if H != h+abs(x-cx)+abs(y-cy):
                    flag = False
                    break
            else:
                if H > abs(x-cx)+abs(y-cy):
                    flag = False
                    break
                    
print('{} {} {}'.format(cx-1,cy-1,H))

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

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

for h in range(101):
    for w in range(101):
        x, y, z = X[0]
        d = z + abs(x-w) + abs(y-h)
        for x, y, z in X:
            d2 = z + abs(x-w) + abs(y-h)
            if z == 0:
                if d2 < d:
                    break 
            elif d2 != d:
                break
        else:
            print(w, h, d)
            exit()

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

if n == 1:
	
	print(ps[0][0], ps[0][1], ps[0][2])
else:
	for X in range(101):
		for Y in range(101):
			valid = True
			const = -1
			for p in ps:
				x, y, h = p[0], p[1], p[2]
				if h != 0:
					if const < 0:
						const = abs(X - x) + abs(Y - y) + h
					else:
						if abs(X - x) + abs(Y - y) + h != const:
							valid = False
							break
				else:
					if const >= 0:
						if const - abs(X - x) - abs(Y - y) > 0:
							valid = False
							break
			for p in ps:
				x, y, h = p[0], p[1], p[2]
				if h == 0:
					if const >= 0:
						if const - abs(X - x) - abs(Y - y) > 0:
							valid = False
							break

			if valid == True:
				print(X, Y, const)
				sys.exit()

Solution (Python):
def calcCh(cx, cy, x, y, h):
    return abs(x-cx)+abs(y-cy)+h
def calcH(cx, cy, ch, x, y, h):
    return max(ch - calcCh(cx, cy, x, y, 0), 0)
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh = sorted(xyh, key = lambda x: x[2])[::-1]
lst = [[x, y] for x in range(101) for y in range(101)]
for Cx, Cy in lst:
    Ch = calcCh(Cx, Cy, *xyh[0])
    if all(xyh[i][2] == calcH(Cx, Cy, Ch, *xyh[i]) for i in range(n)):
        break
print(Cx, Cy, Ch)

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

D.sort(key=lambda d: d[2], reverse=True)
for cx in range(100+1):
    for cy in range(100+1):
        f = True
        for i, (x, y, h) in enumerate(D):
            if i == 0:
                ch0 = h + abs(x - cx) + abs(y - cy)
            else:
                ch = h + abs(x - cx) + abs(y - cy)
                if h != 0 and ch0 != ch:
                    f = False
                if h == 0 and ch0 > ch:
                    f = False
        if f:
            print(cx, cy, ch0)
            exit(0)

Solution (Python):
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
for i in range(101):
    for j in range(101):
        ansh=[0]*n
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
            if h==0:ansh[k]=min([ansh[k],max(ansh[:k])])
        if len(set(ansh))==1:
             print(i,j,ansh[1])

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

for Cx in range(101):
    for Cy in range(101):
        H = None
        for xi, yi, hi in points:
            dx = abs(xi - Cx)
            dy = abs(yi - Cy)
            if hi > 0:
                """観測点の高さが1以上なら頂点高を予測"""
                H_calc = hi + dx + dy
                if H is None:
                    H = H_calc
                elif H != H_calc:
                    H = None
                    break  
            else:
                """観測点の高さが0なら式を満たしているかチェック"""
                if H > dx + dy:
                    H = None
                    break  

        if H:
            print('{} {} {}'.format(Cx, Cy, H))
            exit()

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

for Cx in range(101):
    for Cy in range(101):
        kouho = set()
        for xi, yi, hi in points:
            if len(kouho) > 1:
                break  

            if hi > 0:
                """観測点の高さが1以上なら頂点高を予測"""
                kouho.add(hi + abs(xi - Cx) + abs(yi - Cy))
            else:
                """観測点の高さが0なら式を満たしているかチェック"""
                if list(kouho)[0] - abs(xi - Cx) - abs(yi - Cy) > 0:
                    kouho = set()
                    break

        if len(kouho) == 1:
            print('{} {} {}'.format(Cx, Cy, list(kouho)[0]))
            exit()

Solution (Python):



def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    n, = get_ints()

    inp = [get_ints() for _ in range(n)]
    x, y, h = zip(*inp)

    def calc(cx, cy):
        low = 1
        high = max(h) + 2000

        for x_, y_, h_ in zip(x, y, h):
            if h_ > 0:
                H = abs(cx - x_) + abs(cy - y_) + h_
                if low <= H <= high:
                    low = high = H
                else:
                    return None
            else:
                H = abs(cx - x_) + abs(cy - y_) + h_
                high = min(high, H)
                if low > high:
                    return None
                    
        if low == high:
            return low
        else:
            return None

    for cx in range(101):
        for cy in range(101):
            ans = calc(cx, cy)
            if ans is not None:
                print(cx, cy, ans)
                return
    assert False


if __name__ == '__main__':
    main()

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

b = []

p = 0
pp = 0
ppp = 0

for i in range(a):
    b.append(list(map(int,input().split())))
b.sort(key=lambda x:-x[2])
for i in range(0,101):
    for j in range(0,101):
        for k in range(a):
            if k == 0:
                p = abs(b[k][0] - i) + abs(b[k][1]-j)+b[k][2]
            else:
                if max(0,p - abs(b[k][0]-i)- abs(b[k][1]-j)) != b[k][2]:
                    pp = 1
        if pp == 0:
            ppp = 1
            break
        else:
            pp = 0
    if ppp == 1:
        print(i,j,p)
        break

Solution (Python):

"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)


for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) < hres:
                ok = -1
                break
    if ok == 0:
        print(cx, cy, hres)
        break

Solution (Python):
N = int(input())
posX, posY, h = [], [], []

for i in range(N):
    tmp = list(map(int, input().split()))
    posX.append(tmp[0])
    posY.append(tmp[1])
    h.append(tmp[2])

h_start = max(h)

for x in range(101):
    for y in range(101):
        for k in range(h_start, h_start + 201):
            flag = True
            for i in range(N):
                tmp_h = max(k - abs(posX[i] - x) - abs(posY[i] - y), 0)
                
                if tmp_h != h[i]:
                    flag = False
                    break
            if flag == True:
                print(x, y, k)
                exit

Solution (Python):
N = int(input())
posX, posY, h = [], [], []

for i in range(N):
    tmp = list(map(int, input().split()))
    posX.append(tmp[0])
    posY.append(tmp[1])
    h.append(tmp[2])

h_start = max(h)

for x in range(101):
    for y in range(101):
        for k in range(h_start, h_start + 201):
            flag = True
            for i in range(N):
                tmp_h = max(k - abs(posX[i] - x) - abs(posY[i] - y), 0)
                
                if tmp_h != h[i]:
                    flag = False
                    break
            if flag == True:
                print(x, y, k)
                exit

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

W = 101

cs = [[0] * W for i in range(W)]

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

h = XYH[0][2]
sx, sy = XYH[0][0:2]
for x in range(W):
    for y in range(W):
        cs[y][x] = h + abs(x - sx) + abs(y - sy)



for i in range(1, N):
    h = XYH[i][2]
    sx, sy = XYH[i][0:2]
    for x in range(W):
        for y in range(W):
            h1 = h + abs(x - sx) + abs(y - sy)
            if h > 0:
                if cs[y][x] != h1:
                    cs[y][x] = 0
            else:
                if cs[y][x] > h1:
                    cs[y][x] = 0
    

cx, cy, ch = 0, 0, 0

for x in range(W):
    for y in range(W):
        h = cs[y][x]
        if h > 0:
            cx, cy, ch = x, y, h

print(cx, cy, ch)

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

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

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