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

xn = []
yn = []
hn = []

for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi:
        xn.append(xi)
        yn.append(yi)
        hn.append(hi)

if len(xn) == 1:
    print(xn[0], yn[0], hn[0])
else:
    for Cx in range(101):
        for Cy in range(101):

            last = None
            flg = False

            for i in range(len(xn)):
                H = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if H < 0:
                    continue
                if last:
                    if (H != last):
                        break

                last = H
            else:
                flg = True
                print(Cx, Cy, H)
                break

        if flg:
            break

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

    xn = []
    yn = []
    hn = []

    for i in range(N):
        xi, yi, hi = map(int, input().split())
        if hi:
            xn.append(xi)
            yn.append(yi)
            hn.append(hi)

    if len(xn) == 1:
        print(xn[0], yn[0], hn[0])
        return

    for Cx in range(101):
        for Cy in range(101):

            last = None

            for i in range(len(xn)):
                H = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if H < 0:
                    continue
                if last:
                    if (last != H):
                        break

                last = H
            else:
                print(Cx, Cy, H)
                return


main()

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

xn = []
yn = []
hn = []

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn.append(xi)
    yn.append(yi)
    hn.append(hi)

for Cx in range(101):
    for Cy in range(101):

        flg = True

        for i in range(N):
            if 0 == hn[i]:
                continue

            h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

            if flg:
                H = h
                flg = False
            else:
                if (H != h):
                    flg = True
                    break

        if flg:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    flg = True
                    break

        if flg:
            continue

        print(Cx, Cy, H)
        break

    if not flg:
        break

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

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

for Cx in range(101):
    for Cy in range(101):

        flg = True

        for i in range(N):
            if 0 == hn[i]:
                continue

            h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

            if flg:
                H = h
                flg = False
            else:
                if (H != h):
                    flg = True
                    break

        if flg:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    flg = True
                    break

        if flg:
            continue

        print(Cx, Cy, H)
        break

    if not flg:
        break

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

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

for Cx in range(101):
    flg = True

    for Cy in range(101):

        for i in range(N):
            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if flg:
                    H = h
                    flg = False
                else:
                    if (H != h):
                        flg = True
                        break

        if flg:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    flg = True
                    break

        if flg:
            continue

        print(Cx, Cy, H)
        break

    if not flg:
        break

Solution (Python):
N, = (int(x) for x in input().split())

info_arr = []
for _ in range(N):
    info_arr.append(tuple(int(x) for x in input().split()))

H_mat = [[-1]*101 for _ in range(101)]

for x, y, h in [a for a in info_arr if a[2] != 0]:
    for i in range(101):
        for j in range(101):
            height = h+abs(x-i)+abs(y-j)
            if H_mat[i][j] == -1:
                H_mat[i][j] = height
                continue
            if H_mat[i][j] != height:
                H_mat[i][j] = 0

for x, y, h in [a for a in info_arr if a[2] == 0]:
    for i in range(101):
        for j in range(101):
            if H_mat[i][j] > h+abs(x-i)+abs(y-j):
                H_mat[i][j] = 0

max_h = 0
max_ij = (-1, -1)
for i in range(101):
    for j in range(101):
        if H_mat[i][j] > max_h:
            max_h = H_mat[i][j]
            max_ij = (i, j)

print(max_ij[0], max_ij[1], max_h)

Solution (Python):
def solve():
    for Cx in range(101):
        for Cy in range(101):
            div = 0
            for i in range(N):

                xi, yi, hi = xyh[i]

                if 0 < hi:
                    h = abs(xi - Cx) + abs(yi - Cy) + hi
                    if div in [0, 2]:
                        H = h
                        div = 1
                    else:
                        if (H != h):
                            div = 2
                            break

            if div == 2:
                continue

            for i in range(N):
                xi, yi, hi = xyh[i]

                if 0 == hi:
                    h = abs(xi - Cx) + abs(yi - Cy)
                    if h < H:
                        div = 2
                        break

            if div == 2:
                continue

            return Cx, Cy, H


N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

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

Cx, Cy, H = solve()

print(Cx, Cy, H)

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

xn = [0] * N
yn = [0] * N
hn = [0] * N

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

div = 0

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):

            xi, yi, hi = xyh[i]

            if 0 < hi:
                h = abs(xi - Cx) + abs(yi - Cy) + hi
                if div in [0, 2]:
                    H = h
                    div = 1
                else:
                    if (H != h):
                        div = 2
                        break

        if div == 2:
            continue

        for i in range(N):
            xi, yi, hi = xyh[i]

            if 0 == hi:
                h = abs(xi - Cx) + abs(yi - Cy)
                if h < H:
                    div = 2
                    break

        if div == 2:
            continue

        print(Cx, Cy, H)
        break

    if div == 1:
        break

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

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

div = 0

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):

            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if div in [0, 2]:
                    H = h
                    div = 1
                else:
                    if (H != h):
                        div = 2
                        break

        if div == 2:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    div = 2
                    break

        if div == 2:
            continue

        print(Cx, Cy, H)
        break

    if div == 1:
        break

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input())

xn = [0] * N
yn = [0] * N
hn = [0] * N

for i in range(N):
    xi, yi, hi = map(int, input().split())
    xn[i] = xi
    yn[i] = yi
    hn[i] = hi

div = 0

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):

            if 0 < hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]
                if div in [0, 2]:
                    H = h
                    div = 1
                else:
                    if (H != h):
                        div = 2
                        break

        if div == 2:
            continue

        for i in range(N):
            if 0 == hn[i]:
                h = abs(xn[i] - Cx) + abs(yn[i] - Cy)
                if h < H:
                    div = 2
                    break

        if div == 2:
            continue

        print(Cx, Cy, H)
        break

    if div == 1:
        break

Solution (Python):
def pyramid(N: int, info: list) -> tuple:
    """
    """
    _info = sorted(info, key=lambda x: x[2], reverse=True)
    x, y, h = _info[0]
    candidtes = [
        (cx, cy, h + abs(cx - x) + abs(cy - y))
        for cx in range(100+1)
        for cy in range(100+1)]

    for x, y, h in _info[1:]:
        temp = []
        for cx, cy, H in candidtes:
            th = max(H - abs(cx - x)-abs(cy - y), 0)
            if th == h:
                temp.append((cx, cy, H))

        candidtes = temp

    return candidtes[0]

if __name__ == "__main__":
    N = int(input())
    info = [
        tuple(int(s) for s in input().split())
        for _ in range(N)]
    cx, cy, h = pyramid(N, info)
    print(cx, cy, h)

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

N = I()
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x,y,h])


for i in range(100+1):
    for j in range(100+1):
        cx, cy = i, j
        H = []
        for item in xyh:
            
            if item[2] == 0:
                continue

            new_H = max(item[2] + abs(item[0] - cx) + abs(item[1] - cy), 0)
            H.append(new_H)
        else:
            if len(set(H)) == 1:
                center_H = H[0]
                H = []
                for item in xyh:
                    if item[2] == 0:
                        
                        ch = abs(item[0] - cx) + abs(item[1] - cy)
                        if ch < center_H:
                            break
                else:
                    print(i, j, center_H)
                    exit()

Solution (Python):
N = int(input())
xyh = []

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

for x in range(101):
    for y in range(101):

        

        for i in range(len(xyh)):
            if(xyh[i][2] != 0):
                reference_index = i
        height = abs(x - xyh[reference_index][0]) + \
            abs(y - xyh[reference_index][1]) + xyh[reference_index][2]
        

        counter = 0

        for n in range(N):
            if(xyh[n][2]==0):
                if not (height <= abs(x - xyh[n][0]) +
                        abs(y - xyh[n][1]) + xyh[n][2]):
                    counter += 1

            else:
                if not (height == abs(x - xyh[n][0]) +
                        abs(y - xyh[n][1]) + xyh[n][2]):
                    counter += 1

        if(counter == 0):
            print("{} {} {}".format(x, y, height))

Solution (Python):

N=int(input())


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


for x in range(101):
    for y in range(101):
        H=data[k][2]+abs(x-data[k][0])+abs(y-data[k][1])
        if all([max(H-abs(x-l[0])-abs(y-l[1]),0)==l[2] for l in data]):
            print(x,y,H)

Solution (Python):

N=int(input())


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


for x in range(101):
    for y in range(101):
        H=data[k][2]+abs(x-data[k][0])+abs(y-data[k][1])
        if all([max(H-abs(x-l[0])-abs(y-l[1]),0)==l[2] for l in data]):
            print(x,y,H)
            exit()

Solution (Python):
n=int(input())
pyramid=[list(map(int, input().split())) for i in range(n)]
pyramid=sorted(pyramid, key=lambda p:p[2])
for x in range(101):
    for y in range(101):
        px=pyramid[-1][0]
        py=pyramid[-1][1]
        ph=pyramid[-1][2]
        h=ph+abs(x-px)+abs(y-py)
        for i in range(n):
            px=pyramid[i][0]
            py=pyramid[i][1]
            ph=pyramid[i][2]
            if not (ph==max(h-abs(x-px)-abs(y-py), 0)):
                break
            if i==n-1:
                print(x,y,h)
                exit()

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N=ri()
X=[0]*N
Y=[0]*N
H=[0]*N
for i in range(N):
    X[i],Y[i],H[i]=rl()
xyh=list(zip(X,Y,H))
xyh.sort(reverse=True,key=lambda x:x[2])
X,Y,H = zip(*xyh)

ans=[-1]*3
for x in range(101):
    if ans[0] != -1:
        break
    for y in range(101):
        if ans[0] != -1:
            break
        rst = H[0]+abs(x-X[0])+abs(y-Y[0])
        for i in range(1,N):
            if H[i] != 0 and rst != H[i]+abs(x-X[i])+abs(y-Y[i]):
                break
            elif H[i] == 0 and rst > H[i]+abs(x-X[i])+abs(y-Y[i]):
                break
            if i == N-1:
                ans = [x,y,rst]

print("{} {} {}".format(ans[0],ans[1],ans[2]))

Solution (Python):
n = int(input())
info = [tuple(map(int, input().split())) for _ in range(n)]
nonzeroinfo = []
for x, y, h in info:
    if h > 0:
        nonzeroinfo.append((x, y, h))
zeroinfo = []
for x, y, h in info:
    if h == 0:
        zeroinfo.append((x, y, h))
def checknonzero(x, y, h):
    for a, b, c in nonzeroinfo:
        if h != abs(x-a) + abs(y-b) + c:
            return False
    return True
def checkzero(x, y, h):
    for a, b, _ in zeroinfo:
        if abs(x-a) + abs(y-b) < h:
            return False
    return True
for x in range(101):
    for y in range(101):
        x1, y1, h1 = nonzeroinfo[0]
        h = abs(x-x1) + abs(y-y1) + h1
        ret1 = checknonzero(x, y, h)
        ret2 = checkzero(x, y, h)
        if ret1 and ret2:
            print(x, y, h)
            exit()

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

x = []
y = []
h = []
flag = True
index = 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 and flag:
        index = i

ans = []

for cx in range(101):
    for cy in range(101):
        H = h[index] + abs(x[index] - cx) + abs(y[index] - cy)
        for i in range(N):
            if h[i] == max(H-abs(x[i] - cx) - abs(y[i] - cy), 0):
                if i == N-1:
                    ans = [cx, cy, H]
            else:
                break

[print(i, end=' ') for i in ans]

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N=ri()
xyh=[]
for i in range(N):
    xyh += [rl()]
xyh.sort(reverse=True, key=lambda x:x[2])

ans=[-1]*3
for x in range(101):
    if ans[0] != -1:
        break
    for y in range(101):
        if ans[0] != -1:
            break
        if xyh[0][2] == 0:
            h_m = xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
            for i in range(1,N):
                rst = xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])
                if h_m > rst:
                    h_m = rst
                if h_m == 0:
                    break
                elif i==N-1:
                    ans = [x,y,h_m]
        else:
            h = xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
            for i in range(1,N):
                if xyh[i][2] != 0:
                    if h != xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]):
                        break
                elif xyh[i][2] == 0:
                    if h > xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]):
                        break
                if i == N-1:
                    ans = [x,y,h]

print("{} {} {}".format(ans[0],ans[1],ans[2]))

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

N = int(input())
cx = [i for i in range(101)]
cy = [i for i in range(101)]
x = []
y = []
h = []
flag = True
index = 0
for i in range(N):
    xi,yi,hi = map(int,input().split())
    x.append(xi)
    y.append(yi)
    h.append(hi)
    if hi != 0 and flag:
        index = i
answer = []
for cx in range(101):
    for cy in range(101):
        H = h[index]+abs(x[index]-cx)+abs(y[index]-cy)
        for i in range(N):
            if h[i] == max(H-abs(x[i]-cx)-abs(y[i]-cy),0):
                if i == N-1:
                    answer = [cx,cy,H]
                continue
            else:
                break

print(str(answer[0])+' '+str(answer[1])+' '+str(answer[2]))

Solution (Python):
n = int(input())
x = []
y = []
h = []

for i in range(n):
	xtemp, ytemp, htemp = map(int, input().split())
	x.append(xtemp)
	y.append(ytemp)
	h.append(htemp)
H = 1000000000

for i in range(0, 101):
	for j in range(0, 101):
		for k in range(n):
			if h[k] != 0:
				H = h[k] + abs(i - x[k]) + abs(j - y[k])
				break
		count = 0
		for k in range(n):
			if h[k] == max(H - abs(i - x[k]) - abs(j - y[k]), 0):
				count += 1
			else:
				break
		if count == n:
			print(i, j, H)
			exit()

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
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)
    if h>0:
        k=i
for x in range(101):
    for y in range(101):
        h=H[k]+abs(X[k]-x)+abs(Y[k]-y)
        if all([max(h-abs(xi-x)-abs(yi-y),0)==hi for xi,yi,hi in zip(X,Y,H)]):
            print(x,y,h)
            exit()

Solution (Python):


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

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and min(h0) >= list(hc)[0]) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break

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

data=[list(map(int,input().split())) for _ in range(N)]
hmax=max(data,key= lambda x:x[2])[2]

def check(x,y,h):
    flag=True
    for d in data:
        flag&=(d[2]==max(h-abs(d[0]-x)-abs(d[1]-y),0))
        if not flag:
            break
    return flag

for cx in range(101):
    for cy in range(101):
        for ch in range(hmax,hmax+202):
            if check(cx,cy,ch):
                print(cx,cy,ch)

Solution (Python):
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
for j in range(N):
  if L[j][2] != 0:
    karix = L[j][0]
    kariy = L[j][1]
    karih = L[j][2]
    break
for p in range(0,101):
  for q in range(0,101):
    cnt = 0
    kouhoH = karih+abs(karix-p)+abs(kariy-q)
    for r in range(N):
      if  L[r][2] == max(kouhoH-abs(L[r][0]-p)-abs(L[r][1]-q),0):
        cnt += 1
    if cnt == N:
      print(p,q,kouhoH)
      exit()

Solution (Python):
from itertools import product


def solve(string):
    n, *xyh = map(int, string.split())
    xyh = sorted([(x, y, h) for x, y, h in zip(xyh[::3], xyh[1::3], xyh[2::3])],
                 key=lambda x: x[-1], reverse=True)
    for i, j in product(range(101), range(101)):
        h = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]
        check = [_h == max(h - abs(_x - i) - abs(_y - j), 0) for _x, _y, _h in xyh[1:]]
        if all(check):
            return "{} {} {}".format(i, j, h)


if __name__ == '__main__':
    n = int(input())
    print(solve("{}\n".format(n) + '\n'.join([input() for _ in range(n)])))

Solution (Python):
import sys
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)
  if hi>0:
    num = i
  
for cx in range(0,101):
  for cy in range(0,101):
    H = h[num]+abs(x[num]-cx)+abs(y[num]-cy)
    if all([max(H-abs(xi-cx)-abs(yi-cy),0)==hi for xi,yi,hi in zip(x,y,h)]):
      print(cx,cy,H)
      sys.exit()

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

flag = False
ans = [0, 0, 0]
for i in range(101):
  for j in range(101):
    for k in range(N):
      Xt, Yt, Ht = L[k][0], L[k][1], L[k][2]
      if Ht > 0:
        break
    H = Ht + abs(Xt - i) + abs(Yt - j)
    result = []
    for k in range(N):
      l = L[k]
      if l[2] == max(H - abs(i - l[0]) - abs(j - l[1]), 0):
        result.append(True)
      else:
        result.append(False)
    if result.count(True) == N:
      ans[0], ans[1], ans[2] = i, j, H
      flag = True
      break
  if flag:
    break

print("{} {} {}".format(ans[0], ans[1], ans[2]))

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

for cxi in range(101):
    for cyi in range(101):
        for k in range(N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

        for k in range(N):
            if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0):
                break
        
        else:
            print(cxi, cyi, hight)

Solution (Python):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())
  if h[n] > 0:
    hi = n

def g(xx, yy, height):
  for n in range(N):
    if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) != h[n]:
      return False
  return True

def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[hi])+abs(yy-y[hi])+h[hi]
      if g(xx, yy, height) is True:
        return [xx, yy, height]
print(*f())

Solution (Python):
n=int(input())
s=[]
for i in range(n):
  x,y,h=map(int,input().split())
  s.append([x,y,h])
s=sorted(s,key=lambda x:x[2],reverse=True)
x0,y0,h0=s[0] 
for x in range(101):
  for y in range(101):
    H=h0+abs(x0-x)+abs(y0-y) 
    for xi,yi,hi in s:
      if hi!=max(0,H-abs(xi-x)-abs(yi-y)):
        break
    else: 
      print(x,y,H)
      exit()

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)
for x in range(101):
  for y in range(101):
    for i in range(n):
      if H[i]>0:
        h=H[i]+abs(X[i]-x)+abs(Y[i]-y)
    for i in range(n):
      if H[i]!=max(0,h-abs(X[i]-x)-abs(Y[i]-y)):
        break
    else: 
      print(x,y,h)
      exit()

Solution (Python):
import numpy as np
N = int(input())
"""
x, y, h = np.array([list(map(int, input().split())) for i in range(N)]).T
"""
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())

H = 0
Cx = 0
Cy = 0
Flag = True
for i in range(101):
    for j in range(101):
        Flag = True
        for k in range(N):
            if h[k] != 0:
                H = h[k] + abs(i - x[k]) + abs(j - y[k])
                break
        for k in range(N):
            if h[k] != max(H - abs(i - x[k]) - abs(j - y[k]), 0):
                Flag = False
                break
        
        if Flag:
            Cx, Cy = i, j
            break
    if Flag:
        break

print("{} {} {}".format(Cx, Cy, H))

Solution (Python):
import numpy as np
N = int(input())

x, y, h = np.array([list(map(int, input().split())) for i in range(N)]).T
"""
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())
"""
H = 0
Cx = 0
Cy = 0
Flag = True
for i in range(101):
    for j in range(101):
        Flag = True
        for k in range(N):
            if h[k] != 0:
                H = h[k] + abs(i - x[k]) + abs(j - y[k])
                break
        for k in range(N):
            if h[k] != max(H - abs(i - x[k]) - abs(j - y[k]), 0):
                Flag = False
                break
        
        if Flag:
            Cx, Cy = i, j
            break
    if Flag:
        break

print("{} {} {}".format(Cx, Cy, H))

Solution (Python):


n=int(raw_input())
l=[]
for i in xrange(n):
 x,y,h=map(int,raw_input().split())
 l.append([x,y,h])
for cx in xrange(101):
 for cy in xrange(101):
  for k in xrange(n):
   if l[k][2]>0:
    h=abs(l[k][0]-cx)+abs(l[k][1]-cy)+l[k][2]
    break
  flag=False
  for k in xrange(n):
   if l[k][2]!=max(h-abs(l[k][0]-cx)-abs(l[k][1]-cy),0):
    flag=True
    break
  if flag==False:
   print cx,cy,h

Solution (Python):
X = []
Y = []
L = []
N = int(input())
for i in range(N):
   x, y, l = map(int, input().split())
   X.append(x)
   Y.append(y)
   L.append(l)
maxL = max(L)
for cx in range(0, 101):
    for cy in range(0, 101):
        for h in range(maxL, maxL+101):
            flag = True
            for i, l in enumerate(L):
                if l != max(h - abs(X[i] - cx) - abs(Y[i] -cy), 0):
                    flag = False
                    break
            if flag:
                print(cx, cy, h)
                exit()

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

position_list = []
for _ in range(N):
    asdf = list(map(int, input().split(' ')))
    position_list.append(asdf)
    if asdf[2] >= 1:
        base_position = asdf

def check_position_diff(position1, position2):
    x = position1[0] - position2[0]
    y = position1[1] - position2[1]
    return x, y

for x in range(102):
    for y in range(102):
        diff_x, diff_y = check_position_diff((x,y), (base_position[0], base_position[1]))
        h = max(abs(diff_x) + abs(diff_y) + base_position[2], 0)
        collect = []
        for position in position_list:
            diff_x, diff_y = check_position_diff((x,y), (position[0], position[1]))
            hx = max(h - abs(diff_x) - abs(diff_y),0)
            collect.append(position[2]==hx)
        if all(collect):
            print(x, y, h)
            exit()
        collect=[]

Solution (Python):
N=int(input())
l=[]
for i in range(N):
  l.append(list(map(int,input().split())))
l.sort(key=lambda x:x[2],reverse=True)
x=l[0][0]
y=l[0][1]
h=l[0][2]

for j in range(101):
  for k in range(101):
    height_summit = h+abs(x-j)+abs(y-k)
    flag=1
    for point in l:
      if point[2] == max(height_summit-abs(point[0]-j)-abs(point[1]-k), 0):
        pass
      else:
        flag=0
        break
    if flag:
      print(j,k,height_summit)
      quit()

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

s.sort(key=lambda x:x[2], reverse=True)
ansH = 0
x0, y0, h0 = s[0]
for cx in range(0, 101):
    for cy in range(0, 101):
        H = h0 + abs(x0 - cx) + abs(y0 - cy)
        for x, y, h in s:
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                break
        else:
            print(cx, cy, H)

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

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()

Solution (Python):
n=int(input())
xyh=[]
for i in range(n):
    xyh.append(list(map(int,input().split())))
x0=xyh[0][0]
y0=xyh[0][1]
h0=xyh[0][2]
count=0
while h0==0:
    count+=1
    x0=xyh[count][0]
    y0=xyh[count][1]
    h0=xyh[count][2]
for x in range(101):
    for y in range(101):
        h=h0+abs(x-x0)+abs(y-y0)
        for i in range(n):
            if max(0,h-abs(x-xyh[i][0])-abs(y-xyh[i][1]))!=xyh[i][2]:
                break
            if i==n-1:
                print(x,y,h)
                quit()

Solution (Python):
from collections import namedtuple

def main():
    Place = namedtuple('Place', ('x', 'y', 'h'))

    N = int(input())

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

    place = list(filter(lambda t:t.h != 0, place))
    place_len = len(place)
    if place_len == 1:
        print(place[0].x, place[0].y, place[0].h)
        return

    for cy in range(101):
        for cx in range(101):
            sc0 = place[0].h + abs(cx - place[0].x) + abs(cy - place[0].y)
            for i in range(1, place_len):
                sci = place[i].h + abs(cx - place[i].x) + abs(cy - place[i].y)
                if sc0 != sci:
                    break
            else:
                print(cx, cy, sc0)
                return

main()