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

for i in range(n):
    if li[i][2] != 0:
        h1 = li[i][2]
        break

flag = True
flag2 = False

for i in range(10**9):
    if flag2 == True: break
    for X in range(101):
        for Y in range(101):
            h = h1 + i
            flag = True
            for j in range(n):
                if max(h - abs(li[j][0]-X) - abs(li[j][1]-Y),0) != li[j][2]:
                    flag = False
                    break
            if flag == True:
                print(X,Y,h)
                flag2 = True
            if flag2 == True: break
            h = h1 - i
            flag = True
            for j in range(n):
                if max(h - abs(li[j][0]-X) - abs(li[j][1]-Y),0) != li[j][2]:
                    flag = False
                    break
            if flag == True:
                print(X,Y,h)
                flag2 = True

Solution (Python):
N=int(input())
xyh=[]
for i in range(N):
    a=[int(i) for i in input().split()]
    xyh.append(a)
xyh.sort(key=lambda x:x[2],reverse=True)
flag2=True
for i in range(0,101):
    for j in range(0,101):
        flag=True
        H=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for k in range(1,N):
            if xyh[k][2]!=max(0,H-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                flag=False
                break
        if flag==True:
            print("{} {} {}".format(i,j,H))
            flag2=False
            break
    if flag2==False:
        break

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

A=[]
for i in range(N):
  a,b,c=map(int,input().split())
  A.append([a,b,c])
  
A=sorted(A,key=lambda x:-x[2])

for x in range(101):
  for y in range(101):
    cntH=abs(x-A[0][0])+abs(y-A[0][1])+A[0][2]
    ans=True
    for i in range(1,N):
      if (A[i][2]>0 and cntH-abs(x-A[i][0])-abs(y-A[i][1]) != A[i][2]) or (cntH-abs(x-A[i][0])-abs(y-A[i][1])>0 and A[i][2]==0):
        ans=False
        break
    if ans:
      print(x,y,cntH)
      break

Solution (Python):
r=range(int(input()))
p=[[int(i)for i in input().split()] for _ in r]
p.sort(key=lambda x: x[2])
a,b,c=p[-1]
for x in range(101):
  for y in range(101):
    h=c+abs(a-x)+abs(b-y)
    if all(k==max(h-abs(i-x)-abs(j-y),0) for i,j,k in p):
      print(x,y,h)
      exit()

Solution (Python):
def execute() :
    n = int(input())
    p = [[int(i) for i in input().split()] for i in range(n)]
    
    for posX in range(101) :
        for posY in range(101) :
            needH = -1
    
            for i in range(n) :
                x, y, h = p[i]
                if h > 0 :
                    tmp = h + abs(posY-y) + abs(posX-x)
                    if needH == -1 :
                        needH = tmp
                    else :
                        if needH != tmp :
                            needH = -2
                            break
            if needH == -2 : 
                continue
    
            for i in range(n) :
                x, y, h = p[i]
                if h == 0 :
                    dist =  abs(posY-y) + abs(posX - x)
                    if needH > dist :
                        needH = -2
                        break
            if needH == -2 : 
                continue
            
            return (posX, posY, needH)

result = execute()     
print(result[0], result[1], result[2])

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

n = int(input())
x = [0]*n
y = [0]*n
h = [0]*n
MAX = 2*(10**9)
for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())

for cx in range(101):
    for cy in range(101):
        maxH = MAX
        res = 0
        isAnswer = True
        for i in range(n):
            if h[i] == 0:
                maxH = min(maxH, f(x[i], y[i], cx, cy))
            else:
                curH = h[i] + f(x[i], y[i], cx, cy)
                if res == 0:
                    res = curH
                elif curH != res:
                    isAnswer = False
                    break
        if isAnswer and res <= maxH:
            print(cx, cy, res)
            cy = cx = 101

Solution (Python):
n = int(input())
xyh = [tuple(int(x) for x in input().split()) for _ in range(n)]

base = [0,0,0]
for x, y, h in xyh:
    if h > 0:
        base = [x,y,h]

for i in range(101):
    for j in range(101):
        top_h = abs(i - base[0]) + abs(j - base[1]) + base[2]
        check = 1
        for x, y, h in xyh:
            if max(top_h - abs(i - x) - abs(j - y), 0) != h:
                check = 0
                break
        if check == 1:
            print(i, j, top_h)
            exit()

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
hmin = INF
xyh = []
for i in range(N):
    x,y,h = inpl()
    hmin = min(h,hmin)
    xyh.append([x,y,h])

for H in range(hmin,hmin+210):
    for cx in range(101):
        for cy in range(101):
            flag= True
            for x,y,h in xyh:
                if max(H-abs(cx-x)-abs(cy-y),0) != h:
                    flag = False
                    break

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

Solution (Python):
def f(n,xyh):
	for i in range(n):
		if xyh[i][2]:
			xs,ys,hs=xyh[i]

	for Cx in range(101):
		for Cy in range(101):
			H=hs+abs(xs-Cx)+abs(ys-Cy)
			
			for i in range(n):
				if xyh[i][2] != max(H-abs(xyh[i][0]-Cx)-abs(xyh[i][1]-Cy),0):
					break
			else:
				return '{} {} {}'.format(Cx,Cy,H)

if __name__=="__main__":
	x=int(input())
	data=[[int(j) for j in input().split()] for i in range(x)]
	print(f(x,data))

Solution (Python):
def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


N = read()
x = []
y = []
h = []
for i in range(N):
    xi, yi, hi = readmap()
    x.append(xi)
    y.append(yi)
    h.append(hi)
    if hi > 0:
       idx = i

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

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

for Cx in range(101):
    for Cy in range(101):
        H = None
        for x, y, h in Info:
            if h == 0:
                continue

            
            tmp_H = abs(Cx - x) + abs(Cy - y) + h
            if (H is None) or (H == tmp_H):
                H = tmp_H
            else:
                break
        
        else:
            for x, y, h in Info:
                if h != 0:
                    continue

                if H - abs(Cx - x) - abs(Cy - y) > 0:
                    break

            
            else:
                print(Cx, Cy, H)
                exit()

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

for cx in range(101):
    for cy in range(101):
        for l in lst:
            if l[2] != 0:
                H = abs(cx-l[0]) + abs(cy-l[1]) + l[2]
        for l in lst:
            if l[2] != max(0, H - abs(cx-l[0]) - abs(cy-l[1])):
                break
        else:
            print(cx, cy, H)
            exit(0)

Solution (Python):


def main():
    n = int(input())
    arrys = [tuple(map(int, input().split())) for _ in range(n)]
    for i in range(101):
        for j in range(101):
            for x_tmp, y_tmp, h_tmp in arrys:
                if h_tmp != 0:
                    break
            H = h_tmp + abs(x_tmp - i) + abs(y_tmp - j)
            for x_t, y_t, h_t in arrys:
                if h_t != max(H - abs(x_t - i) - abs(y_t - j), 0):
                    break
            else:
                print(i, j, H)
                exit()

if __name__ == '__main__':
    main()

Solution (Python):
import sys


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

    if "PyPy" in sys.version:
        ans4 = loop_xyh_N(x, y, h)
        print(*ans4)
    else:
        
        ans1 = editorial_movie(x, y, h)
        ans2 = editorial_pdf(x, y, h)
        ans3 = ref_sub_xyn(x, y, h)
        print(*ans2)
        assert ans1 == ans2 == ans3


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            - |x - Cx| - |y - Cy| > 0
            H  = h(x, y) + |x - Cx| - |y - Cy|
        h(x,y) = 0:
            H            - |x - Cx| - |y - Cy| <= 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


def ref_sub_xyn(x, y, h):
    """
    https://beta.atcoder.jp/contests/abc112/submissions/3348987
    """
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            
            
            h_min = h[0] + abs(x[0] - cx) + abs(y[0] - cy)
            h_max = h_min
            if h[0] == 0:
                h_min = 1

            for _x, _y, _h in zip(x[1:], y[1:], h[1:]):
                
                h_max = min(h_max, _h + abs(_x - cx) + abs(_y - cy))
                if _h != 0:
                    h_min = max(h_min, _h + abs(_x - cx) + abs(_y - cy))

            if h_min == h_max:
                return cx, cy, h_min


def editorial_pdf(x, y, h):
    """
    条件を満たすピラミッドがただ 1 つなのであれば、必ず以下のものが 1 個以上存在します。
        • 調査で得られた情報のうち、hi ≥ 1 を満たす情報 (xi, yi, hi)。

    なぜなら、全部 hi = 0 であるとき、
    調査を行っていない整数座標を中心とする高さ 1 のピラミッドが条件を満たしてしまうので、
        最低でも 101×101− N 個、N = 100 の場合 10, 101 個以上の条件を満たすピラミッドが存在することになるからです。
        そこで、前述の条件を満たす情報のうち 1 個を (xt, yt, ht) とおきます。
    """
    
    gx, gy, gh = (-1, -1, -1)
    for _x, _y, _h in zip(x, y, h):
        if _h >= 1:
            gx, gy, gh = _x, _y, _h

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            v = gh + abs(gx - cx) + abs(gy - 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

            if flag:
                return cx, cy, v


def loop_xyh_N(x, y, h):
    h_base = max(h)

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            
            for ch in range(h_base, h_base + 200 + 1):
                ok = True
                for _x, _y, _h in zip(x, y, h):
                    tmp = _h + abs(_x - cx) + abs(_y - cy)
                    if _h > 0 and ch != tmp:
                        ok = False
                        break
                    elif _h == 0 and ch > tmp:
                        ok = False
                        break

                if ok:
                    return cx, cy, ch


def f2(x, y, h):
    chs = []
    for _x, _y, _h in zip(x, y, h):
        for cx in range(0, 100 + 1):
            for cy in range(0, 100 + 1):
                tmp = h_H(cx, cy, _x, _y)
                print((_x, _y), (cx, cy), _h, tmp, sep="\t")

    return 1


if __name__ == '__main__':
    main()

Solution (Python):


def main():
    n = int(input())
    arrys = [tuple(map(int, input().split())) for _ in range(n)]
    for i in range(101):
        for j in range(101):
            for arry in arrys:
                x_tmp, y_tmp, h_tmp = arry
                if h_tmp != 0:
                    break
            H = h_tmp + abs(x_tmp - i) + abs(y_tmp - j)
            flag = 1
            for arry in arrys:
                x_t, y_t, h_t = arry
                if h_t == max(H - abs(x_t - i) - abs(y_t - j), 0):
                    flag *= 1
                else:
                    flag *= 0
            if flag == 1:
                print(i, j, H)
                exit()

if __name__ == '__main__':
    main()

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

    import sys
    if "PyPy" in sys.version:
        ans4 = loop_xyh_N(x, y, h)
        print(*ans4)
    else:
        
        ans1 = editorial_movie(x, y, h)
        ans2 = editorial_pdf(x, y, h)
        
        print(*ans2)
        assert ans1 == ans2 


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            - |x - Cx| - |y - Cy| > 0
            H  = h(x, y) + |x - Cx| - |y - Cy|
        h(x,y) = 0:
            H            - |x - Cx| - |y - Cy| <= 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


def ref_sub_xyn(x, y, h):
    """
    https://beta.atcoder.jp/contests/abc112/submissions/3348987
    """
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            
            
            h_min = h[0] + abs(x[0] - cx) + abs(y[0] - cy)
            h_max = h_min
            if h[0] == 0:
                h_min = 1

            for _x, _y, _h in zip(x[1:], y[1:], h[1:]):
                
                h_max = min(h_max, _h + abs(_x - cx) + abs(_y - cy))
                if _h != 0:
                    h_min = max(h_min, _h + abs(_x - cx) + abs(_y - cy))

            if h_min == h_max:
                return cx, cy, h_min


def editorial_pdf(x, y, h):
    """
    条件を満たすピラミッドがただ 1 つなのであれば、必ず以下のものが 1 個以上存在します。
        • 調査で得られた情報のうち、hi ≥ 1 を満たす情報 (xi, yi, hi)。

    なぜなら、全部 hi = 0 であるとき、
    調査を行っていない整数座標を中心とする高さ 1 のピラミッドが条件を満たしてしまうので、
        最低でも 101×101− N 個、N = 100 の場合 10, 101 個以上の条件を満たすピラミッドが存在することになるからです。
        そこで、前述の条件を満たす情報のうち 1 個を (xt, yt, ht) とおきます。
    """
    
    gx, gy, gh = (-1, -1, -1)
    for xyh in zip(x, y, h):
        if xyh[-1] >= 1:
            gx, gy, gh = xyh

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            v = gh + abs(gx - cx) + abs(gy - cy)
            v = max(v, 0)
            flag = True

            for _x, _y, _h in zip(x, y, h):
                
                vv = v - abs(_x - cx) - abs(_y - cy)
                if _h != vv:
                    flag = False

            if flag:
                return cx, cy, v


def loop_xyh_N(x, y, h):
    h_base = max(h)

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            
            for ch in range(h_base, h_base + 200 + 1):
                ok = True
                for _x, _y, _h in zip(x, y, h):
                    tmp = _h + abs(_x - cx) + abs(_y - cy)
                    if _h > 0 and ch != tmp:
                        ok = False
                        break
                    elif _h == 0 and ch > tmp:
                        ok = False
                        break

                if ok:
                    return cx, cy, ch


def f2(x, y, h):
    chs = []
    for _x, _y, _h in zip(x, y, h):
        for cx in range(0, 100 + 1):
            for cy in range(0, 100 + 1):
                tmp = h_H(cx, cy, _x, _y)
                print((_x, _y), (cx, cy), _h, tmp, sep="\t")

    return 1


if __name__ == '__main__':
    main()

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

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

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

        for i in range(N):
            if h[i] != 0:
                if ch == -1:
                    ch = abs(cx - x[i]) + abs(cy - y[i]) + h[i]
                else:
                    input_h = abs(cx - x[i]) + abs(cy - y[i]) + h[i]
                    if input_h != ch:
                        ch = -2
                        break
        if ch == -2:
            continue

        for i in range(N):
            if h[i] == 0:
                if ch > (abs(cx - x[i]) + abs(cy - y[i])):
                    ch = -2
        if ch != -2:
            print(cx, cy, ch)

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

l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:-x[2])

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      x,y,h=l[i]
      b=h+abs(x-cx)+abs(y-cy)
      if i==0:
        if h:
          s=set()
          s.add(b)
        else:
          s={i for i in range(b+1)}
      else:
        if not s:break
        if h:
          s&=set([b])
        else:
          s&=set(range(b+1))
    if s:
      print(cx,cy,s.pop())
      sys.exit()

Solution (Python):
N = int(input())
H = []
FIRST = []
for i in range(N):
    x,y,h = map(int,input().split())
    if h>=1 and not FIRST:
        FIRST.append([x,y,h])
    else:
        H.append([x,y,h])
        
H = FIRST + H

isok = False
for cx in range(101):
    for cy in range(101):
        notok = True
        top = -1
        for h in H:
            if top==-1:
                top = h[2] + abs(cx-h[0]) + abs(cy-h[1])
            elif h[2] != max([top-abs(h[0]-cx)-abs(h[1]-cy),0]):
                notok = False
                break
        if notok:isok = True
        if isok:break
    if isok:break
        
print(cx,cy,top)

Solution (Python):
def check():
    for k in range(0,n):
        if h[k]!=0:
            break
    for i in range(0,101):
        for j in range(0,101):
            flag=True
            h1=abs(i-x[k])+abs(j-y[k])+h[k]
            for l in range(0,n):
                if h[l]!=max(h1-abs(i-x[l])-abs(j-y[l]),0):
                    flag=False
                    break
            if flag==True:
                print(i,j,h1)
                return
            
n=int(input())
x=[0 for i in range(0,n)]
y=[0 for i in range(0,n)]
h=[0 for i in range(0,n)]
for i in range(0,n):
    x[i],y[i],h[i]=map(int,input().split())
check()

Solution (Python):
N = int(input())
data = []
for _ in range(N):
    x, y, h = list(map(int, input().split()))
    data.append([x,y,h])
for x in range(101):
    for y in range(101):
        result = 0
        for dat in data:
            if dat[2] != 0:
                result = abs(dat[0] - x) + abs(dat[1] - y) + dat[2]
                break
        flag = True
        for dat in data:
            result2 = max(result - abs(dat[0] - x) - abs(dat[1] - y) , 0)
            if result2 != dat[2]:
                flag = False
                break
        if flag == True:print(x,y,result)

Solution (Python):



def main():
    n = int(input())
    xs = list()
    ys = list()
    hs = list()

    
    
    
    
    for i in range(n):
        xi, yi, hi = map(int, input().split())
        xs.append(xi)
        ys.append(yi)
        hs.append(hi)

        
        if hi > 0:
            pos = i

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            is_consistent = True
            candidate_height = abs(xs[pos] - cx) + abs(ys[pos] - cy) + hs[pos]

            for i in range(n):
                each_height = max(candidate_height - abs(xs[i] - cx) - abs(ys[i] - cy), 0)

                if hs[i] != each_height:
                    is_consistent = False
                    break

            if is_consistent:
                print(cx, cy, candidate_height)
                exit()


if __name__ == '__main__':
    main()

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

def solve():
    for cx in range(101):
        for cy in range(101):
            H = -1
            Hmax = 1<<30
            flg = True
            for i in range(N):
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if h[i] > 0:
                    HH = h[i] + dist
                    if H < 0:
                        H = HH
                    if H != HH or H > Hmax:
                        flg = False
                        break
                else:
                    Hmax = min(Hmax, dist)
                    if H > Hmax:
                        flg = False
                        break
            if flg:
                
                
                print(cx, cy, H)
                return

solve()

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

def solve():
    for cx in range(101):
        for cy in range(101):
            H = -1
            Hmax = 1<<30
            flg = True
            for i in range(N):
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if h[i] > 0:
                    HH = h[i] + dist
                    if H < 0:
                        H = HH
                    if H != HH or H > Hmax:
                        flg = False
                        break
                else:
                    Hmax = min(Hmax, dist)
                    if H > Hmax or Hmax == 0:
                        flg = False
                        break
            if flg:
                
                
                print(cx, cy, H)
                return

solve()

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

def solve():
    for cx in range(101):
        for cy in range(101):
            H = -1
            Hmax = 1<<30
            flg = True
            for i in range(N):
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if h[i] > 0:
                    HH = h[i] + dist
                    if H < 0:
                        H = HH
                    if H != HH or H > Hmax:
                        flg = False
                        break
                else:
                    Hmax = min(Hmax, dist)
                    if H > Hmax or Hmax == 0:
                        flg = False
                        break
            if flg:
                if Hmax == 1:
                    H = 1
                print(cx, cy, H)
                return

solve()

Solution (Python):
n = int(input())
x = []
y = []
h = []
ans = [0,0,0]
for i in range(n):
	xyh = list(map(int, input().split()))
	x.append(xyh[0])
	y.append(xyh[1])
	h.append(xyh[2])

for i in range(101):
	for j in range(101):
		for k in range(n):
			if h[k] != 0:
				height = abs(i-x[k]) + abs(j-y[k]) + h[k]
				break
			
		flag = 0
		for k in range(n):
			if h[k] != max(height- abs(i-x[k]) - abs(j-y[k]) , 0):
				flag = 1
				break
			
		if flag == 0:
			ans = [i,j,height]
			break
		
	
print('{0} {1} {2}'.format(ans[0], ans[1], ans[2]))

Solution (Python):
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        H = []
        check = []
        for k in range(n):
            x = a[k][0]
            y = a[k][1]
            h = a[k][2]
            if h ==  0:
                check.append((x, y))
            else:
                H.append(h + abs(x-i) + abs(y-j))
                if len(set(H)) > 1:
                    break
            if k == n-1:
                state = False
                for s,t in check:
                    if H[0] - abs(s-i) - abs(t-j) > 0:
                        state = True
                        break
                if state:
                    break
                print(i, j, H[0])
                exit()

Solution (Python):
def ni(): 
    return int(input())
def li():
    return map(int, input().split())

xyh = [tuple(li()) for _ in range(ni())]
xmax, ymax, hmax = max(xyh, key=lambda _: _[-1])

for x_cent in range(101):
    for y_cent in range(101):
        h_cent = hmax + abs(xmax-x_cent) + abs(ymax-y_cent)
        
        for x, y, h in xyh:
            if h != max(0, h_cent - abs(x-x_cent) - abs(y-y_cent)):
                break
        else:
            print(x_cent, y_cent, h_cent)

Solution (Python):
import numpy as np

input_N = input().split()
N = int(input_N[0])

input_xyh = [input().split() for i in range(N)]

xyh = np.array(input_xyh)
xyh = xyh.astype(np.int64)
xyh = xyh.T
x = xyh[0]
y = xyh[1]
h = xyh[2]


coord_max = 101

for pos_y in range(coord_max):
    for pos_x in range(coord_max):
        
        
        
        needH = -1

        for i in range(N):
            if h[i] > 0:
                tmp = h[i] + abs(pos_y - y[i]) + abs(pos_x - x[i])
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
        if needH == -2:
            continue

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

        if needH == -2:
            continue

        
        print(str(pos_x) + " " + str(pos_y) + " " + str(needH))

Solution (Python):
import sys
n=int(input())
X=[]
Y=[]
H=[]
MAX=100
for i in range(n):
    x,y,h=map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
for posX in range(MAX+1):
    for posY in range(MAX+1):
        needH=-1
        for i in range(n):
            if H[i]>0:
                tmp=H[i]+abs(X[i]-posX)+abs(Y[i]-posY)
                if needH==-1:
                    needH=tmp
                else:
                    if needH!=tmp:
                        needH=-2
                        break
                 
        if needH==-2:
            continue
        for i in range(n):
            if H[i]==0: 
                dis=abs(X[i]-posX)+abs(Y[i]-posY)
                if needH>dis:
                    needH=-2
                    break 
        if needH==-2:
            continue
        print(posX,posY,needH)

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 > 0:
                    needH = -2
                    break
        if needH == -2:
            continue

        print(cx, cy, needH)
        exit()