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):
from math import *

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x_y_h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        flag = 1
        H = x_y_h[2] + abs(cx - x_y_h[0]) + abs(cy - x_y_h[1])
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                flag = 0
                break
        if (flag == 1):
            print("%s %s %s" % (cx, cy, H))
            break
    if (flag == 1):
        break

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

w = [(list(map(int, input().split()))) for i in range(n)]
w.sort(key=lambda x:(x[2]),reverse=True)
hcon1 = 0
hcon2 = 0
for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if w[i][2] > 0:
                if i == 0:
                    hcon1 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                elif i != 0 and i != n - 1:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        hcon1 = hcon2
                else:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        print(cx,cy,hcon1)
                        exit()
            else:
                if i == 0:
                    hcon1 = 1
                elif i != 0 and i != n - 1:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                else:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                    else:
                        print(cx, cy, hcon1)
                        exit()

Solution (Python):
n = int(input())
x,y,h = [0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i] = map(int,input().split())
for a in range(101):
  for b in range(101):
    p = -1
    q = 2000000000
    f = 0
    for i in range(n):
      t = h[i] + abs(x[i]-a) + abs(y[i]-b)
      if h[i]>0:
        if p == -1:
          p = t
        elif not p == t:
          f = 1
          break         
      else:
        q = min(q,t)
    if f == 0 and p<=q:
      print(a,b,p)
      exit()

Solution (Python):

n=int(input())
data=[] 
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

breakflg=False
for cx in range(101):
    if(breakflg):
        break
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        flag=True
        for i in range(n):
            h_est=h-abs(data[i][0]-cx)-abs(data[i][1]-cy)
            if(h_est<0):
                h_est=0
            if(data[i][2]!=h_est):
                flag=False
                break
        if(flag):
            print(cx,cy,h)
            breakflg=True;

Solution (Python):
N = int(input())
X, Y, H = [], [], []
X0, Y0, H0 = 0, 0, 0
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h >= 1:
        X0, Y0, H0 = x, y, h

M = 101
for i in range(M):
    for j in range(M):
        H1 = H0 + abs(X0 - i) + abs(Y0 - j)

        flag = True
        for k in range(N):
            if max(H1 - abs(i - X[k]) - abs(j - Y[k]), 0) != H[k]:
                flag = False

        if flag:
            print(i, j, H1)
            exit()

Solution (Python):
import sys

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

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

        
if N==1:
    print(xyh[0][0], xyh[0][1] , xyh[0][2])
else:
    for xc in range(101):
        for yc in range(101):
            H = xyh[-1][2] + abs(xyh[-1][0] - xc) + abs(xyh[-1][1] - yc)
            for xi, yi, hi in xyh:
                if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0):
                    break
            else:
                print(xc, yc, H)
                sys.exit()

Solution (Python):
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N

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

for cx in range(0, 101):
    for cy in range(0, 101):
        f_i = 0
        for i in range(N):
            if h[i] != 0:
                f_i = i
        H = h[f_i] + abs(x[f_i]-cx) + abs(y[f_i]-cy)
        for i in range(N):
            if H - abs(x[i]-cx) - abs(y[i]-cy) < 0 and h[i] == 0:
                continue
            if H != h[i] + abs(x[i]-cx) + abs(y[i]-cy):
                break
        else:
            print(cx, cy, H)
            exit()
        continue

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

for i in range(N):
    p_info = [int(s) for s in input().split()]
    if p_info[2] == 0:
        p_infos.append(p_info)
    else:
        p_infos.insert(0, p_info)

is_finished = False
for c_x in range(101):
    if is_finished: break
    for c_y in range(101):
        if is_finished: break
        c_h = -1 
        for p in p_infos:
            x, y, h = p[0], p[1], p[2] 
            x_d, y_d = abs(x - c_x), abs(y - c_y)
            if h > 0:
                if c_h == -1:
                    c_h = h + x_d + y_d
                elif c_h != h + x_d + y_d:  
                    break
            elif c_h - x_d - y_d > 0:
                break

            if p == p_infos[-1]:
                print(c_x, c_y, c_h)
                is_finished = True

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

def reheight(center, point):
    if point[2] == 0:
        return 0
    else:
        return (point[2] + abs(center[0] - point[0]) + abs(center[1] - point[1]))

def height(center, high, point):
    return max(high - abs(center[0] - point[0]) - abs(center[1] - point[1]), 0)

for i in range(101):
    for j in range(101):
        k_ = 0
        center = [i, j]
        while (reheight(center, hints[k_]) == 0):
            k_ += 1
        hmax = reheight(center, hints[k_])
        k = 0
        while (k < n and (hints[k])[2] == height(center, hmax, (hints[k])[:2])):
            k += 1
        if k == n:
            break
    if k == n:
        break
        
print("{} {} {}".format(center[0], center[1], hmax))

Solution (Python):
import numpy as np
N = int(input())
x = np.empty(N,dtype=np.int)
y = np.empty(N,dtype=np.int)
h = np.empty(N,dtype=np.int)
for n in range(N):
    (x[n],y[n],h[n]) = map(int,input().split())

M = 100

grads = np.array([[1,1],[-1,1],[-1,-1],[1,-1]],dtype=np.int)
def height(x,y,h,i,j,d):
    
    return (h + grads[d,0]*(i-x) + grads[d,1]*(j-y))

def quadrant(x,y):
    if x > 0 and y >= 0:
        return 0
    elif y > 0:
        return 1
    elif x < 0:
        return 2
    else:
        return 3

Clist = [(Cx,Cy) for Cy in range(M+1) for Cx in range(M+1)]
k = h.argmax()
for (Cx,Cy) in Clist:
    H = height(x[k],y[k],h[k],Cx,Cy,quadrant(Cx-x[k],Cy-y[k]))
    for n in range(N):
        Hn = height(x[n],y[n],h[n],Cx,Cy,quadrant(Cx-x[n],Cy-y[n]))
        if h[n] == 0:
            if Hn < H:
                break
        else:
            if Hn != H:
                break
    else:
        break

print(Cx,Cy,H)

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

x = []
y = []
h = []
x_t, y_t, h_t = 0, 0, 0
for i in range(N):
    x_i, y_i, h_i = map(int, input().split())
    x.append(x_i)
    y.append(y_i)
    h.append(h_i)
    if h_i > 0 and h_t == 0:
        x_t = x_i
        y_t = y_i
        h_t = h_i

for i in range(101):
    for j in range(101):
        px = i
        py = j
        ph = h_t + abs(px - x_t) + abs(py - y_t)
        flag = True
        for k in range(N):
            if max(ph - abs(x[k] - px) - abs(y[k] - py), 0) != h[k]:
                flag = False
                break
        if flag:
            print(px, py, ph)
            break
    if flag:
        break

Solution (Python):
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break

Solution (Python):
import sys

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

for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if(h[i]==0):
                continue
            else:
                H=h[i]+abs(cx-x[i])+abs(cy-y[i])
                break
        for i in range(n):
            if(h[i]!=max(H-abs(cx-x[i])-abs(cy-y[i]),0)):
                    break
        else:
            print("{} {} {}".format(cx,cy,H))
            sys.exit(0)

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


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def g(l, cx, cy):
    H_max_l = set(H(cx, cy, x, y, h) for x, y, h in l if h == 0)
    h_max = min(H_max_l) if any(H_max_l) else -1
    
    TH = set(H(cx, cy, x, y, h) for x, y, h in l if h > 0)
    if len(TH) == 1:
        high = TH.pop()
        if h_max == -1 or high <= h_max:
            return high
    return -1


def f(l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            h = g(l, cx, cy)
            if h > 0:
                return cx, cy, h

cx, cy, h = f(xyh)
print(cx, cy, h)

Solution (Python):
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break

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

xs, ys, hs = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        cand = []
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            if hs[i] == 0:
                cand.append((h, False))
            else:
                cand.append((h, True))

    
        cand2 = set([c[0] for c in cand if c[1]])
        if len(cand2) != 1:
            continue

        assert len(cand2) == 1
        ans = cand2.pop()

        if all([c[0] >= ans for c in cand if not c[1]]):
            print(x, y, ans)
            ok = True





assert ok

Solution (Python):

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hizero=0
for i in range(n):
    x[i],y[i],h[i]=map(int,input().split())
    if(h[i]!=0):
        hizero=i

for i in range(101):
    for j in range(101):
        tmp_h=h[hizero]+abs(x[hizero]-i)+abs(y[hizero]-j)
        for k in range(0,n):
            if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])!=h[k]):
                break
        if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])==h[k]):
            break
    if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])==h[k]):
        break
print("{} {} {}".format(i,j,tmp_h))

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

for j in range(0,101):
    for k in range(0,101):
        for i in range(n):
            if l[i][2]>0:
                h=(l[i][2]+abs(j-l[i][0])+abs(k-l[i][1]))
                
                break
        for i in range(n):
            h_r=max((h-abs(j-l[i][0])-abs(k-l[i][1])),0)
            if l[i][2] !=h_r:
                
                break
        else:
            print(j,k,h)

Solution (Python):
n = input()
arr = []
for i in range(n):
    xi, yi, hi = map(int, raw_input().split())
    arr.append((xi, yi, hi))

for cx in range(101):
    for cy in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                H = abs(arr[k][0]-cx)+abs(arr[k][1]-cy) + arr[k][2]
                break
        flag = 0
        for k in range(n):
            if arr[k][2] != max(H - abs(arr[k][0]-cx) - abs(arr[k][1]-cy), 0):
                flag = 1
                break
        if flag == 0:
            print cx, cy, H
        else:
            continue

Solution (Python):
n = input()
arr = []
for i in range(n):
    xi, yi, hi = map(int, raw_input().split())
    arr.append((xi, yi, hi))

for cx in range(101):
    for cy in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                H = abs(arr[k][0]-cx)+abs(arr[k][1]-cy) + arr[k][2]
                break
        flag = 0
        for k in range(n):
            if arr[k][2] != max(H - abs(arr[k][0]-cx) - abs(arr[k][1]-cy), 0):
                flag = 1
                break
        if flag == 0:
            print cx, cy, H
        else:
            continue

Solution (Python):
n = input()
arr = []
for i in range(n):
    xi, yi, hi = map(int, raw_input().split())
    arr.append((xi, yi, hi))

for cx in range(101):
    for cy in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                H = abs(arr[k][0]-cx)+abs(arr[k][1]-cy) + arr[k][2]
                break
        flag = 0
        for k in range(n):
            if arr[k][2] != max(H - abs(arr[k][0]-cx) - abs(arr[k][1]-cy), 0):
                flag = 1
                break
        if flag == 0:
            print cx, cy, H

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

for x, y, h in lst:
    if h > 0:
        base = (x, y, h)
        break

for cx in range(100 + 1):
    for cy in range(100 + 1):
        H = base[2] + abs(base[0] - cx) + abs(base[1] - cy)
        if all([max(H - abs(x - cx) - abs(y - cy), 0) == h for x, y, h in lst]):
            print(cx, cy, H)
            exit()

Solution (Python):
import sys

def solve(n, ls_xyh):
    x0 = None
    for i in range(n):
        if ls_xyh[i][2] > 0:
            [x0,y0,h0] = ls_xyh[i]
            break
    cands = [(cx, cy, h0 + abs(cx - x0) + abs(cy - y0))
             for cx in range(101) for cy in range(101)]
    for [x,y,h] in ls_xyh:
        cands = [(cx, cy, ch) for (cx, cy, ch) in cands
                    if max(ch - abs(cx - x) - abs(cy - y), 0) == h]
    (xx, yy, hh) = cands[0]
    return ' '.join([str(xx), str(yy), str(hh)])

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    ls_xyh = [list(map(int, sys.stdin.readline().strip().split()))
              for j in range(n)]
    return (n, ls_xyh)

def main():
    print(solve(*readQuestion()))


main()

Solution (Python):
N=int(input().strip())
xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    xyh.append([xi,yi,hi])
    if hi>=1:
        xyhset=[xi,yi,hi]
        
for nx in range(101):
    for ny in range(101):
        He = xyhset[2]+abs(xyhset[0]-nx)+abs(xyhset[1]-ny)
        He=max(0,He)
        flag=True
        for i in range(N):
            h=He-abs(xyh[i][0]-nx)-abs(xyh[i][1]-ny)
            h=max(0,h)
            if xyh[i][2]!=h:
                flag=False
        if flag:
            ax=nx
            ay=ny
            ah=He

print("{} {} {}".format(ax,ay,ah))

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

nonzero = [i for i in range(0, N) if h[i] != 0]

for cx in range(0, 100+1):
	for cy in range(0, 100+1):
		H =  h[nonzero[0]] + abs(x[nonzero[0]] - cx) + abs(y[nonzero[0]] - cy)
		error = False
		for i in range(0, N):
			if h[i] != max([H - abs(x[i]-cx) - abs(y[i]-cy), 0]):
				error = True
				break
		if not error:
			print("{} {} {}".format(cx, cy, H))
			exit()

Solution (Python):
import sys

n = int(input())

xyh = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]

isOk = False
i = 0
j = 0
constant = -1

for i in range(101):
    for j in range(101):

        constant = -1
        for xyhTemp in xyh:
            if xyhTemp[2] != 0:
                temp = xyhTemp[2] + abs(i - xyhTemp[0]) + abs(j - xyhTemp[1])

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:

            for p in xyh:
                if p[2] == 0 and constant - abs(i - p[0]) - abs(j - p[1]) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

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

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

isOk = False
i = 0
j = 0
constant = -1

for i in range(101):
    for j in range(101):

        constant = -1
        for xyhTemp in xyh:
            if xyhTemp[2] != 0:
                temp = xyhTemp[2] + abs(i - xyhTemp[0]) + abs(j - xyhTemp[1])

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:

            for p in xyh:
                if p[2] == 0 and constant - abs(i - p[0]) - abs(j - p[1]) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

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

xyh = [None] * n 

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

isOk = False
i = 0
j = 0
constant = -1

for i in range(101):
    for j in range(101):

        constant = -1
        for xyhTemp in xyh:
            if xyhTemp[2] != 0:
                temp = xyhTemp[2] + abs(i - xyhTemp[0]) + abs(j - xyhTemp[1])

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:

            for p in xyh:
                if p[2] == 0 and constant - abs(i - p[0]) - abs(j - p[1]) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

Solution (Python):
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)

isOk = False
i = 0
j = 0
constant = -1

for i in range(101):
    for j in range(101):

        constant = -1
        for xi, yi, hi in zip(x, y, h):
            if hi != 0:
                temp = hi+ abs(i - xi) + abs(j - yi)

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:

            for xj, yj, hj in zip(x, y, h):
                if hj == 0 and constant - abs(i - xj) - abs(j - yj) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

Solution (Python):
class xyh_list:
    def __init__(self, xyh):
        self.x = xyh[0]
        self.y = xyh[1]
        self.h = xyh[2]

n = int(input())

xyh = []

for i in range(n):
    xyh.append(xyh_list(list(map(int, input().split()))))

isOk = False
i = 0
j = 0
constant = -1

for i in range(101):
    for j in range(101):

        constant = -1
        for xyhTemp in xyh:
            if xyhTemp.h != 0:
                temp = xyhTemp.h + abs(i - xyhTemp.x) + abs(j - xyhTemp.y)

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:

            for p in xyh:
                if p.h == 0 and constant - abs(i - p.x) - abs(j - p.y) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

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

xyh = []

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

isOk = False
i = 0
j = 0
constant = -1

for i in range(101):
    for j in range(101):

        constant = -1
        for xyhTemp in xyh:
            if xyhTemp[2] != 0:
                temp = xyhTemp[2] + abs(i - xyhTemp[0]) + abs(j - xyhTemp[1])

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:

            for p in xyh:
                if p[2] == 0 and constant - abs(i - p[0]) - abs(j - p[1]) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

Solution (Python):
def main():
    N = int(input())
    tuples = []
    for _ in range(N):
        x, y, h = [int(e) for e in input().split()]
        tuples.append((x, y, h))
        if h > 0:
            x_, y_, h_ = x, y, h

    
    for cs in range(101):
        for cy in range(101):
            
            H = h_ + abs(cs - x_) + abs(cy - y_)
            flag = True
            
            for t in tuples:
                
                h = H - abs(cs - t[0]) - abs(cy - t[1])
                h = max([h, 0])
                
                if t[2] != h:
                    flag = False
            if flag:
                print(cs, cy, H)
                break


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
l = ils(n, "il()")

for i in range(101):
    for j in range(101):
        zero = []
        height = -1
        ok = 1
        for k in range(n):
            if l[k][2] == 0:
                zero.append(k)
                continue
            if height == -1:
                height = abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]
            if height != abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]:
                ok = 0
                break
        for k in zero:
            if height == -1:
                height = abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]
            if height > abs(i-l[k][0]) + abs(j-l[k][1]) + l[k][2]:
                ok = 0
                break
        if ok:
            print(i, j, height)

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

info = [[int(x) for x in input().split()] for _ in range(n)]

def height(point, info):
    cx, cy = point[0], point[1]
    ch = None
    theo_max = float('inf')
    for i,p in enumerate(info):
        x, y, h= p[0], p[1], p[2]
        tmp = abs(cx-x) + abs(cy-y) + h
        if h == 0:
            theo_max = min(theo_max, tmp)
            if ch:
                if theo_max < ch:
                    return None
                    break
        else:
            if not ch:
                ch = tmp
                if theo_max < ch:
                    return None
                    break
            else:
                if ch != tmp:
                    return None
                    break
                if theo_max < ch:
                    return None
                    break
    return ch

t = None
ans = None
for x in range(101):
    if t:
        break
    for y in range(101):
        if t:
            break
        point = (x,y)
        t = height(point, info)
        if t :
            ans = [x,y,t]

print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
rec = []
for i in range(N):
    x, y, h = map(int, input().split())
    rec.append((x, y, h))
    if h >= 1:
        q = [x, y, h]


for i in range(101):
    for j in range(101):
        cx, cy = i, j
        h = q[2] + abs(i - q[0]) + abs(j - q[1])
        flag = True
        for k in range(N):
            if max(h - abs(i - rec[k][0]) - abs(j - rec[k][1]), 0) != rec[k][2]:
                flag = False
                break

        if flag:
            print(i, j, h)
            break

Solution (Python):
def main():
    N = int(input())
    p = [list(map(int, input().split())) for _ in range(N)]
    for i in range(N):
        if p[i][2] > 0:
            break
    x0, y0, h0 = p[i]
    for cx in range(101):
        for cy in range(101):
            H = h0 + abs(x0 - cx) + abs(y0 - cy)
            for x, y, h in p:
                if h != max(H - abs(x - cx) - abs(y - cy), 0):
                    break
            else:
                print(cx, cy, H)
                exit(0)


if __name__ == '__main__':
    main()

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

i = 0
while 1:
    if P[i][2] > 0:
        break
    i += 1
x0, y0, h0 = P[i]
for cy in range(101):
    for cx in range(101):
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for x, y, h1 in P:
            if h1 != max(h - abs(cx - x) - abs(cy - y), 0):
                break
        else:
            print(cx, cy, h)
            exit(0)
exit(1)

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

lx, ly, lh = data[-1]

for cy in range(101):
    for cx in range(101):
        H = lh + abs(cx - lx) + abs(cy - ly)

        if all(h == max(H - abs(cx - x) - abs(cy - y), 0) for x, y, h in data):
            print(cx, cy, H)
            exit()

Solution (Python):
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for index in range(N):
    x[index],y[index],h[index] = map(int,input().split())
for i in range(101):
   for j in range(101):
      result = []
      for index in range(N):
         result_H = h[index]+ abs(x[index]- i)+abs(y[index]-j)
         if result_H-abs(x[index]- i)-abs(y[index]-j) > 0:
            result.append(result_H)
      tmp = result[0]
      if all(tmp==num for num in result) == True:
         check = []
         for check_index in range(N):
            check.append((tmp - abs(x[check_index]- i) - abs(y[check_index]-j))-h[check_index])
         if all(z <= 0 for z in check) == True:
            print(i,' ',j,' ',tmp)
            break
   else:
      continue
   break

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

xs = []
ys = []
hs = []
for i in range(n):
  x,y,h = map(int,input().split())
  xs.append(x)
  ys.append(y)
  hs.append(h)

for x in range(101):
  for y in range(101):
    for i in range(n):
      if hs[i] >0:
        H = hs[i] + abs(xs[i]-x)+abs(ys[i]-y)
    for i in range(n):
      if hs[i] != max(0, H-abs(xs[i]-x)-abs(ys[i]-y)):
        break
    else:
      print(x,y,H)
      exit()

Solution (Python):


def main():
    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:
                print("{} {} {}".format(i,j,H))
                flag2=False
                break
        if not flag2:
            break

if __name__ == "__main__": main()

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

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

Solution (Python):
import sys

N = int(input())

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

for X in range(0, 101):
    for Y in range(0, 101):
        b = True
        H = 0
        for Cx, Cy, Ch in list:
            if Ch != 0:
                H = Ch + abs(X - Cx) + abs(Y - Cy)
        for Cx, Cy, Ch in list:
            h = max(H - abs(X - Cx) - abs(Y - Cy), 0)
            if Ch != h:
                b = False
        if b == True:
            print(X, Y, H)
            sys.exit(0)

Solution (Python):
import sys

N = int(input())

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

for X in range(0, 101):
    for Y in range(0, 101):
        b = True
        H = 0
        for Cx, Cy, Ch in list:
            if Ch != 0:
                H = Ch + abs(X - Cx) + abs(Y - Cy)
        for Cx, Cy, Ch in list:
            h = max(H - abs(X - Cx) - abs(Y - Cy), 0)
            if Ch != h:
                b = False
        if b == True:
            print(X, Y, H)
            sys.exit(0)

Solution (Python):
import itertools
n = int(input())
e = [[int(_) for _ in input().split()] for _ in range(n)]

for xi, yi, hi in e:
    if hi > 0:
        xp = xi
        yp = yi
        hp = hi
        break

for cx, cy in itertools.product(range(101), range(101)):
    ch = abs(cx - xp) + abs(cy - yp) + hp
    flag = True
    for xi, yi, hi in e:
        flag = flag and max(ch - abs(cx - xi) - abs(cy - yi), 0) == hi
    if flag:
        print("%d %d %d" % (cx, cy, ch))