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

src = [tuple(map(int,input().split())) for i in range(N)]
 
INF = float('inf')

for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    
                    if tmp != tmph:
                        break
                if tmph > maxh:
                    break
            else:
                
                
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
        else:
            for x,y,h in src:
                if max(tmph - abs(x-cx) - abs(y-cy), 0) != h:
                    break
            else:
                print(cx,cy,tmph)
                exit()

Solution (Python):
N = int(input())
x_list=[]
y_list=[]
h_list=[]
hantei = 0
count=0
for i in range(N):
    a,b,c=map(int,input().split())
    x_list.append(a)
    y_list.append(b)
    h_list.append(c)
    if c>0: 
        judge_x = a
        judge_y = b
        judge_h = c

for x in range(101):
    for y in range(101):
        H = judge_h + abs(judge_x-x)+abs(judge_y-y)
        for j in range(N):
            if h_list[j] != max(0,H-abs(x-x_list[j])-abs(y-y_list[j])): break
            if j == N-1 : print(x,y,judge_h + abs(x-judge_x) + abs(y-judge_y))

Solution (Python):
N = int(input())
 
def calc_h(H, x, y, cx, cy):
    return max(H - abs(x - cx) - abs(y - cy), 0)
 
data_ls = list()
for i in range(N):
    data_ls.append([int(i) for i in input().split()])
xs, ys, hs = zip(*data_ls)
Cx_candidate = list(range(min(xs), max(xs) + 1))
Cy_candidate = list(range(min(ys), max(ys) + 1))
flg = 0
for x in Cx_candidate:
    for y in Cy_candidate:
    	for i in data_ls:
            if i[2] == 0:
                continue
            h = i[2] + abs(i[0] - x) + abs(i[1] - y)
            if h < 1:
            	continue
            else:
            	break
    	for i in data_ls:
            if calc_h(h, i[0], i[1], x, y) == i[2]:
              	flg = 1
              	continue
            else:
              	flg = 0
              	break
    	if flg == 1:
        	break
    if flg == 1:
    	break
print(x, y, h)

Solution (Python):

import sys


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    def is_match_to_samples(cx, cy):
        hmax = max(h)
        hmax_idx = h.index(hmax)
        ht = top_height(cx, cy, x[hmax_idx], y[hmax_idx], hmax)
        for xi, yi, hi in zip(x, y, h):
            if hi != height(cx, cy, xi, yi, ht):
                return False, -1
        return True, ht

    import itertools
    for cx, cy in itertools.product(range(101), range(101)):
        is_match, ht = is_match_to_samples(cx, cy)
        if is_match:
            print("{} {} {}".format(cx, cy, ht))
            break
    return

def height(cx, cy, xi, yi, ht):
    return max(0, ht - abs(cx - xi) - abs(cy - yi))

def top_height(cx, cy, xi, yi, hi):
    return hi + abs(cx - xi) + abs(cy - yi)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    x = [int()] * (N)  
    y = [int()] * (N)  
    h = [int()] * (N)  
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

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

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






for cx in range(0, 101):
    for cy in range(0, 101):
        hd = -1
        f = False
        for i in range(0, n):
            if h[i] > 0:
                ht = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                if hd == -1 or hd == ht:
                    hd = ht
                else:
                    f = True
                    break
                    
        for i in range(0, n):
            if h[i] == 0:
                if max(hd - abs(x[i] - cx) - abs(y[i] - cy), 0) != 0:
                    f = True
                    break
        
        if not f:
            print(cx, cy, hd)

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

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

Solution (Python):


import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline












N = int(input().rstrip())
xyh = []
itr = 0
for i in range(N):
	a, b, c = map(int, input().rstrip().split())
	itr = max(itr, c)
	xyh.append([a, b, c])

def solve(x, y, h):
	for xyh_in in xyh:
		if xyh_in[2] != max((h - abs(x - xyh_in[0]) - abs(y - xyh_in[1])), 0):
			return False
	return True

for i in range(101):
	for j in range(101):
		for k in range(itr, itr+101):
			if solve(i, j, k):
				print(str(i) + " " + str(j) + " " + str(k))

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

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

for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) > 0:
                    flag = 0
                    break
            else:

                if h == l[2] + abs(x-l[0]) + abs(y-l[1]):
                    flag = 1
                
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)

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

def main():
    for i in range(101):
        for j in range(101):
            H = 0
            for x,y,h in S:
                if h==0:
                    continue
                else:
                    H = h+abs(x-i)+abs(y-j)
                    break
            flg = True
            for x,y,h in S:
                if h != max(0, H-abs(x-i)-abs(y-j)):
                    flg = False
                    break
            if flg:
                print(i, j, H)
                return

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)
    
index = h.index(max(h))
for cx in range(101):
    for cy in range(101):
        H = h[index] + abs(x[index] - cx) + abs(y[index] - cy)
        flag = True
        for i in range(n):
            if h[i] > 0:
                if H != (h[i] + abs(x[i] - cx) + abs(y[i] - cy)):
                    flag = False
            if h[i] == 0:
                if (H -  abs(x[i] - cx) - abs(y[i] - cy)) > 0:
                    flag = False
        if flag:
            print(cx,cy,H)

Solution (Python):
def main():
    N = int(input())
    xList = []
    yList = []
    hList = []
    for i in range(N):
        x, y, h = list(map(int, input().split()))
        xList.append(x)
        yList.append(y)
        hList.append(h)
        if h > 0:
            x1 = x  
            y1 = y
            h1 = h
    
    for cx in range(100+1):
        for cy in range(100+1):
            H = h1 + abs(x1-cx) + abs (y1-cy)
            for x, y, h in zip(xList, yList, hList):
                if h != max(H-abs(x-cx)-abs(y-cy), 0):
                    break
            else:
                print(cx, cy, H)
                return

if __name__ == '__main__':
    main()

Solution (Python):



N = int(input())

src = [tuple(map(int,input().split())) for i in range(N)]
 
INF = float('inf')

for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
                if tmph > maxh:
                    break
            else:
                
                
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
        else:
            for x,y,h in src:
                if max(tmph - abs(x-cx) - abs(y-cy), 0) != h:
                    break
            else:
                print(cx,cy,tmph)
                exit()

Solution (Python):

N = int(input())

src = [tuple(map(int,input().split())) for i in range(N)]
 
INF = float('inf')

for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
                if tmph > maxh:
                    break
            else:
                
                
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
                


        else:
            for x,y,h in src:
                if max(tmph - abs(x-cx) - abs(y-cy), 0) != h:
                    break
            else:
                print(cx,cy,tmph)
                exit()

Solution (Python):


N = int(input())

p_l = [list(map(int, input().split())) for _ in range(N)]
p_l.sort(key=lambda x: -x[2])

temp_p = p_l[0]

for x in range(101):  
    for y in range(101):  
        
        h = temp_p[2] + abs(temp_p[1] - y) + abs(temp_p[0] - x)

        if all(max(h - abs(p[1] - y) - abs(p[0] - x), 0) == p[2] for p in p_l[1:]):
            print("{} {} {}".format(x, y, h))
            exit()

Solution (Python):
from sys import stdin

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh.sort(key=lambda x: -x[2])

x1, y1, h1 = xyh[0]
for X in range(101):
    for Y in range(101):
        H = h1 + abs(x1-X) + abs(y1-Y)
        if all(max(H-abs(x-X)-abs(y-Y), 0) == h for x, y, h in xyh[1:]):
            print(X, Y, H)
            break

Solution (Python):
from sys import stdin
from itertools import product

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh.sort(key=lambda x: -x[2])

x1, y1, h1 = xyh[0]
for X, Y in product(range(101), range(101)):
    H = h1 + abs(x1-X) + abs(y1-Y)
    if all(max(H-abs(x-X)-abs(y-Y), 0) == h for x, y, h in xyh[1:]):
        print(X, Y, H)
        break

Solution (Python):
from sys import stdin
from itertools import product

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh.sort(key=lambda x: x[2], reverse=True)

x1, y1, h1 = xyh[0]
for X, Y in product(range(101), range(101)):
    H = h1 + abs(x1-X) + abs(y1-Y)
    if all(max(H-abs(x-X)-abs(y-Y), 0) == h for x, y, h in xyh[1:]):
        print(X, Y, H)
        break

Solution (Python):
from sys import stdin
from itertools import product

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh.sort(key=lambda x: x[2], reverse=True)

x1, y1, h1 = xyh[0]
for X, Y in product(range(101), range(101)):
    H = h1 + abs(x1-X) + abs(y1-Y)
    if all([max(H-abs(x-X)-abs(y-Y), 0) == h for x, y, h in xyh[1:]]):
        print(X, Y, H)
        break

Solution (Python):
from sys import stdin
from itertools import product

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh = [t for t in xyh if t[2] > 0]
xyh.sort(key=lambda x: x[2], reverse=True)

x1, y1, h1 = xyh[0]
if len(xyh) < 3:
    print(x1, y1, h1)
else:
    for X, Y in product(range(101), range(101)):
        H = h1 + abs(x1-X) + abs(y1-Y)
        if all([max(H-abs(x-X)-abs(y-Y), 0) == h for x, y, h in xyh[1:]]):
            print(X, Y, H)
            break

Solution (Python):
import numpy as np
n = int(input())
origin = []
modified = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    origin.append([tx, ty, th])
    if th != 0:
        modified.append([tx, ty, th])
origin = np.array(origin).T
modified = np.array(modified).T
for cx in range(0,101):
    for cy in range(0,101):
        tmp = modified[2] + np.abs(modified[0] - cx) + np.abs(modified[1] - cy)
        if np.max(tmp) == np.min(tmp):
            height = np.max(tmp)
            
            
            
            
            
            if (origin[2] == np.maximum(height - np.abs(origin[0] - cx) - np.abs(origin[1] - cy), np.zeros(origin[0].size))).all():
                print(cx, cy, height)

Solution (Python):
def main() -> None:
    N = int(input())
    pos = [[int(i) for i in input().split()] for _ in range(N)]
    pos = sorted(pos, key=lambda x: x[2], reverse=True)
    x, y, h = pos[0]
    for CX in range(101):
        for CY in range(101):
            H = h + abs(x - CX) + abs(y - CY)
            if all(posh == max(H - abs(posx - CX) - abs(posy - CY), 0) for posx, posy, posh in pos):
                print('{x} {y} {h}'.format(x=CX, y=CY, h=H))
                exit()


if __name__ == '__main__':
    main()

Solution (Python):
from math import fabs

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

  cors = [list(map(int, input().split())) for _ in range(N)]
  cors_sorted = sorted(cors, key = lambda x: x[2], reverse=True)
  top_x, top_y, top_h = cors_sorted[0]

  for C_x in range(101):
    for C_y in range(101):
      H = top_h + fabs(top_x - C_x) + fabs(top_y - C_y)
      if all([h == max(H - fabs(x - C_x) - fabs(y - C_y), 0) for x,y,h in cors_sorted]):
        print(C_x, C_y, int(H))
        return


main()

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
tx, ty, th = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx - Cx) + abs(ty - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
tx, ty, th = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx - Cx) + abs(ty - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Solution (Python):
n = int(input())
li = []
for _ in range(n):
    x0, y0, h0 = list(map(int, input().split()))
    li.append((h0, x0, y0))

li.sort(reverse=True)

from itertools import product
for x, y in product(range(0, 101), repeat=2):
    h0, x0, y0 = li[0]
    h = h0 + abs(x0 - x) + abs(y0 - y)
    ok = True
    for h0, x0, y0 in li[1:]:
        if h0 != max(0, h - abs(x - x0) - abs(y - y0)):
            ok = False
            break
    if ok:
        break

print(x, y, h)

Solution (Python):
N = int(input())
L = []
M = []
for _ in range(N):
    l = list(map(int,input().split()))
    if l[2] != 0:
        L.append(l)
    else:
        M.append(l)

for i in range(101):
    for j in range(101):
        tmp = -1
        for x in L:
            H = abs(x[0]-i) + abs(x[1]-j) + x[2]
            if H < 1:
                break
            if tmp != -1 and tmp != H:
                break
            else:
                tmp = H
        else:
            for x in L:
                if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                    pass
                else:
                    break
            else:
                for x in M:
                    if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                        pass
                    else:
                        break
                else:
                    print(i,j,H)

Solution (Python):

N = int(input())
xyh = []
for i in range(N):
    xyh.append(list(map(int, input().split())))
max_xyh = max(xyh, key=lambda x: x[2])  
for Cx in range(101):
    for Cy in range(101):
        h = abs(max_xyh[0] - Cx) + abs(max_xyh[1] - Cy) + max_xyh[2]
        frag = True
        for ex_xyh in xyh:
            if max([h - abs(ex_xyh[0] - Cx) - abs(ex_xyh[1] - Cy), 0]) == ex_xyh[2]:
                continue
            else:
                frag = False
                break
        if frag:
            print(Cx, Cy, h)
            break

Solution (Python):
import sys

def is_center(x, y, P):
  H = [abs(x-p[0]) + abs(y-p[1]) + p[2] for p in P if p[2] != 0]
  return H


def center(C, P):
  for c in C:
    check = [p[2] == max(c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1]), 0) for p in P]
    if all(check):
      return '{} {} {}'.format(c[0], c[1], c[2])

def main():
  input = sys.stdin.readline
  N = int(input())
  P = [[0, 0, 0] for _ in range(N)]

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

  C = []
  for i in range(101):
    for j in range(101):
      H = is_center(i, j, P)
      if len(set(H)) == 1:
        C.append([i, j, H[0]])
  
  ans = center(C, P)
  print(ans)


if __name__ == '__main__':
  main()

Solution (Python):
class Solver(object):
    def __init__(self):
        self.n = int(input())
        self.heights = []
        for _ in range(self.n):
            self.heights.append(list(map(int, input().split(" "))))

    def solve(self):
        for cx in range(101):  
            for cy in range(101):  
                ch = 1
                for x, y ,h in self.heights:
                    if h > 0:
                        ch = h + abs(cx - x) + abs(cy - y)
                        break
                isValid = True
                for x, y, h in self.heights:
                    if max(ch - abs(cx - x) - abs(cy - y), 0) != h:
                        isValid = False
                if isValid:
                    print(cx, cy, ch)
                    return

    def debug(self):
        for h in self.heights:
            print(h)


if __name__ == "__main__":
    s = Solver()
    s.solve()

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
xt, yt, ht = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = ht + abs(xt - Cx) + abs(yt - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      break
  else:
      continue
  break

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

Solution (Python):
def calc_height(xs, ys, hs, cx, cy):
    ret = -1
    zeros = []
    for i in range(len(xs)):
        x = xs[i]
        y = ys[i]
        h = hs[i]
        if h == 0:
            zeros.append((x,y,h))
            continue
        a = abs(x - cx)
        b = abs(y - cy)
        ch = h + a + b
        if ret == -1:
            ret = ch
        else:
            if ret != ch:
                return -1
    for x, y, h in zeros:
        a = abs(x - cx)
        b = abs(y - cy)
        if ret - a - b > 0:
            return -1
    return ret


def solve(xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = calc_height(xs, ys, hs, cx, cy)
            if h > 0:
                return cx, cy, h


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


print(' '.join([str(q) for q in solve(xs, ys, hs)]))

Solution (Python):
N = int(input())
xyh = [(0,0,0)]*N
for i in range(N):
    x,y,h = map(int, input().split())
    xyh[i] = (x,y,h)
                 
for Cx in range(101):
    for Cy in range(101):
        for i in xyh:
            if i[2] != 0:
                H = i[2] + abs(i[1]-Cy) + abs(Cx- i[0])
                break
        for i in xyh:
            if i[2] != max(H-(abs(i[1]-Cy) + abs(Cx- i[0])), 0):
                break
        else:
            print(Cx,Cy,H)
            break

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

Solution (Python):
n = int(input())
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))
p.sort(key = lambda x:x[2], reverse = True)
for i in range(101):
    for j in range(101):
        t = p[0][2] + abs(i - p[0][0]) + abs(j - p[0][1])
        if any([
            t != p[k][2] + abs(i - p[k][0]) + abs(j - p[k][1]) 
            if p[k][2] > 0 else t > abs(i - p[k][0]) + abs(j - p[k][1]) 
            for k in range(1, n)
        ]):
            continue
        else:
            print(i, j, t)
            break
    else:
        continue
    break

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

arr = []

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

for i in range(101):
    for j in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                len1 = abs(arr[k][0] - i) + abs(arr[k][1] - j)
                ch = len1 + arr[k][2]
                break
            else:
                continue
        for k in range(n):
            lenk = abs(arr[k][0] - i) + abs(arr[k][1] - j)
            if max(ch - lenk, 0) == arr[k][2]:
                if k == n-1:
                    print("{} {} {}".format(i, j, ch))
                else:
                    continue
            else:
                break

Solution (Python):
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx, yy, hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
kk = h.index(max(h))
k = 0
for i in range(101):
    for j in range(101):
        ass = h[kk]+abs(x[kk]-i)+abs(y[kk]-j)
        for r in range(n):
            if h[r] == 0:
                if ass -abs(x[r]-i)-abs(y[r]-j) > 0:
                    ass = -1
            else:
                if ass != abs(x[r]-i)+abs(y[r]-j)+h[r]:
                    ass = -1
        if ass != -1:
                print(i, j, ass)
                break

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 = 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):
def main():
    n = int(input())
    xyhs = [list(map(int, input().split())) for _ in range(n)]
    for cy in range(0, 101):
        for cx in range(0, 101):
            x0, y0, h0 = next((x, y, h) for x, y, h in xyhs if h > 0)
            ch = h0 + abs(x0 - cx) + abs(y0 - cy)
            res = True
            for x, y, h in xyhs:
                hh = max(ch - abs(x - cx) - abs(y - cy), 0)
                if hh != h:
                    res = False
                    break
            if res:
                print(cx, cy, ch)
                return


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
xt, yt, ht = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = ht + abs(xt - Cx) + abs(yt - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Solution (Python):
n = int(input())
data = [tuple(map(int, input().split())) for _ in range(n)]
ax, ay, ah = list(filter(lambda x:x[2], data))[0]

for cx in range(101):
    for cy in range(101):
        H = ah + abs(ax-cx) + abs(ay-cy)
        if all(max(H-abs(d[0]-cx)-abs(d[1]-cy),0)==d[2] for d in data):
            print(cx, cy, H)
            exit()

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

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

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

for cx in range(101):
    for cy in range(101):
        flg = False
        
        tmp = None
        for k in data:
            x = k[0]
            y = k[1]
            h = k[2]
            if not tmp:
                tmp = h+abs(cx-x)+abs(cy-y)
                continue
            if h == 0 and tmp>abs(cx-x)+abs(cy-y):
                flg = True
                break
            elif h == 0:
                continue
            elif tmp == h+abs(cx-x)+abs(cy-y):
                continue
            else:
                flg = True 
                break
        if flg:
            continue
        else:
            print(cx, cy, tmp)
            exit()

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

x,y,k=-1,-1,-1
t=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        t=o
for i in range(101):
    for j in range(101):
        h=a[t][2]+abs(a[t][0]-i)+abs(a[t][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            elif i[2] == 0:
                if h > diff:
                    break
            else:
                if h != diff + i[2]:
                    break
        else:
            if h <= 0:
                pass
            else:
                print("{} {} {}".format(x, y, h))

Solution (Python):

def solve(data):
    data = sorted(data, key=lambda x:-x[2])

    for cx in range(101):
        for cy in range(101):
            d0 = data[0]
            x,y,h = d0
            H = abs(x-cx)+abs(y-cy)+h
            flag = True
            for d in data[1:]:
                x,y,h = d
                if(max(H-abs(x-cx)-abs(y-cy),0) != h):
                    flag = False
                    break
            if(flag==True):
                return cx,cy,H

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



cx,cy,H = solve(data)
print(cx,cy,H)

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    for i in d:
      if i[2] > 0:
        H = i[2] + abs(x-i[0]) + abs(y-i[1])
        break
    if all(l[2] == max(H - abs(x-l[0]) - abs(y-l[1]), 0) for l in d):
      print('{} {} {}'.format(x, y, H))
      exit()

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

x,y,h=-1,-1,-1
nonzero=-1

for i in range(n):
    xyh.append(list(map(int,input().split())))
    if xyh[i][2] != 0:
        nonzero = i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2]+abs(xyh[nonzero][0]-px)+abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if xyh[nn][2] > 0 and nh != xyh[nn][2]+abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py):
                ok=False
            if xyh[nn][2] == 0 and nh > abs(xyh[nn][0]-px) +abs(xyh[nn][1]-py):
                ok=False
        
        if ok:
            x,y,h = px,py,nh
            print(x,y,h)
            exit()

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

ansx,ansy,ansh = -1,-1,-1
nonzero=-1

for i in range(n):
    xyh.append(list(map(int,input().split())))
    if xyh[i][2] != 0:      
        nonzero=i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2] + abs(xyh[nonzero][0]-px) + abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if (xyh[nn][2] > 0 and nh != xyh[nn][2] + abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py)): 
                ok=False
            if (xyh[nn][2] == 0 and nh >  abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py)):
                ok=False
        if ok:
            ansx,ansy,ansh = px,py,nh
        
    
print(ansx,ansy,ansh)