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())
x = []
y = []
h = []
key = 0
for i in range(N):
    tmp = [int(i) for i in input().split()]
    if tmp[2] != 0:
        key = i
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])

for Cx in range(100 + 1):
    for Cy in range(100 + 1):
        correct_flag = True
        H = abs(x[key] - Cx) + abs(y[key] - Cy) + h[key]
        for i in range(N):
            if h[i] == 0:
                if abs(x[i] - Cx) + abs(y[i] - Cy) < H:
                    correct_flag = False
                    break
            else:
                if abs(x[i] - Cx) + abs(y[i] - Cy) + h[i] != H:
                    correct_flag = False
                    break
        if correct_flag:
            print(Cx, Cy, H)
            break

Solution (Python):
def just_fit(xyh, x, y, h):
    for p in xyh:
        if max(h - abs(p[0] - x) - abs(p[1] - y), 0) == p[2]:
            pass
        else:
            return False
    return True

N = int(input())

xyh = []
highest_h = 0
for i in range(N):
    tmp = list(map(int, input().split()))
    xyh.append(tmp)
    if tmp[2] > highest_h:
        highest_h = tmp[2]

ans_x, ans_y, ans_z = -1, -1, -1
flug = 0
for highPlus in range(101):
    for x in range(101):
        for y in range(101):
            if just_fit(xyh, x, y, highest_h + highPlus):
                ans_x, ans_y, ans_z = x, y, highest_h + highPlus
                flug = 1
                break
        if flug == 1:
            break
    if flug == 1:
        break

print(ans_x, ans_y, ans_z)

Solution (Python):
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(key=lambda x: -x[2])

for cx in range(101):
    for cy in range(101):
        ch = None
        for x, y, h in xyh:
            t = h + abs(cx - x) + abs(cy - y)
            if h > 0:
                if ch is not None and t != ch:
                    break
                ch = t
            else:
                if t < ch:
                    break
        else:
            print(cx, cy, ch)
            exit()

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
X = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]
X.sort(key=lambda x: x[2])
a, b, c = X[-1]

for px in range(101):
    for py in range(101):
        H = abs(a - px) + abs(b - py) + c
        for k in range(N):
            if X[k][2] != max(H - abs(X[k][0] - px) - abs(X[k][1] - py), 0):
                break
            if k == N - 1:
                print(px, py, H)

Solution (Python):
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: x[2])
a, b, c = X[-1]

for px in range(101):
    for py in range(101):
      H = abs(a - px) + abs(b - py) + c
      if all(h == max(H - abs(x - px) - abs(y - py), 0) for x, y, h in X):
        print(px, py, H)
        break

Solution (Python):
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
C_x = list(range(101))
C_y = list(range(101))
 
if sum([h for _, _, h in X]) == 1:
  for x, y, h in X:
    if h != 0:
      print(x, y, h)
else:
  for px in C_x:
    for py in C_y:
      h_list = [abs(x - px) + abs(y - py) + h for x, y, h in X if h > 0]
      if len(set(h_list)) == 1:
        print(px, py, h_list[0])
        break

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

if sum([h for _, _, h in X]) == 1:
  for x, y, h in X:
    if h != 0:
      print(x, y, h)
else:
  for px in C_x:
    for py in C_y:
      h_list = [abs(x - px) + abs(y - py) + h for x, y, h in X if h > 0]
      if len(set(h_list)) == 1:
        print(px, py, h_list[0])
        break

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

def judge(Cx,Cy):
    for x, y, h in info:
        if h != 0:
            H = abs(x-Cx) + abs(y-Cy) + h
            break
    for x, y, h in info:
        if max(H-abs(x-Cx)-abs(y-Cy),0) != h:
            return
    global ans
    ans = [Cx,Cy,H]
    
for Cx in range(101):
    for Cy in range(101):
        judge(Cx,Cy)

print(*ans)

Solution (Python):
N = int(input())
symb = None
hints = []

for _ in range(N):
  hint = tuple(map(int, input().split()))
  if symb is None and hint[2]!=0:
    symb = hint
  else:
    hints.append(hint)


Hs = dict()
for i in range(0, 101):
  flag = False
  for j in range(0, 101):
    cand = symb[2] + abs(i-symb[0]) + abs(j-symb[1])
    contradict = False
    for x, y, h in hints:
      if max(cand - abs(x-i) - abs(y-j), 0) != h:
        contradict = True
        break
    if not contradict:
      flag = True
      print(i, j, cand)
      break
  if flag:
    break

Solution (Python):
from itertools import product
n = int(input())
Ct = [i for i in range(101)]
Cli = list(product(Ct,Ct))
XY = []
sx,sy,sh = 0,0,0
for i in range(n):
    x,y,h = map(int,input().split())
    XY.append([x,y,h])
    if h != 0: sx,sy,sh = x,y,h
for (cx,cy) in Cli:
    
    ht = sh + abs(sx-cx) + abs(sy-cy)

    for i in XY:
        ht2 = max(ht-abs(i[0]-cx)-abs(i[1]-cy),0)

        if ht2 != i[2]: break
    else:
        print(cx, cy, ht)
        break

Solution (Python):
from sys import stdin
import sys
N=int(stdin.readline().rstrip())
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
for X in range(0,101):
    for Y in range(0,101):
        for data_ in data:
            H = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            flag = True
            for data__ in data:
                if max(H-abs(X-data__[0])-abs(Y-data__[1]),0) != data__[2]:
                    flag = False
            if flag:
                break
        else:
            continue
        break
    else:
        continue
    break
    
print(X,Y,H)

Solution (Python):
def makelist(n, m):
    return [[0 for i in range(m)] for j in range(n)]

flag = True

N = int(input())
pos = [0]*N
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        flag = False
    pos[i] = (h, x, y)

pos = list(reversed(sorted(pos)))

def dist(p1, p2):
    (x1, y1) = p1
    (x2, y2) = p2
    return abs(x1-x2) + abs(y1-y2)

if flag:
    
    
    ()
else:
    for y in range(101):
        for x in range(101):
            (h1, x1, y1) = pos[0]
            H = dist((x, y), (x1, y1)) + h1

            flag = True
            for (h1, x1, y1) in pos[1:]:
                if h1 == 0:
                    if H - dist((x, y), (x1, y1)) > 0:
                        flag = False
                        break
                else:
                    if dist((x, y), (x1, y1)) + h1 != H:
                        flag = False
                        break
            if flag:
                print(" ".join(map(str, [x, y, H])))
                break

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 i in range(0,101):
    for j in range(0,101):
        for n, hn in enumerate(h):
            if hn > 0:
                tmph = hn + abs(i-x[n]) + abs(j-y[n])
                break
        count = 0
        for n in range(N):
            count += 1
            if h[n] != max(tmph - abs(i-x[n]) - abs(j-y[n]), 0):
                break
            if count == N:
                print(str(i) + ' ' + str(j) + ' ' + str(tmph))

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                check = 1
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for x in zero_height:
                if H > abs(x[0] - i) + abs(x[1] - j):
                    check = -1
                    break
            if check == 1:
                print(i, j , 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 c_x in range(101):
    for c_y in range(101):
        thres = 10**10
        H = []
        for i in range(N):
            if h[i] > 0:
                H.append(h[i] + abs(x[i] - c_x) + abs(y[i] - c_y))
            elif thres > abs(x[i] - c_x) + abs(y[i] - c_y):
                thres = abs(x[i] - c_x) + abs(y[i] - c_y)

        if len(set(H)) == 1 and 0 < H[0] <= thres:
            print(str(c_x) + " " + str(c_y) + " " + str(H[0]))

Solution (Python):

"""
C - Pyramid
https://atcoder.jp/contests/abc112/tasks/abc112_c

"""
import sys


def solve(N, positions):
    if N == 1:
        return positions[0]
    positions.sort(key=lambda x:x[2])
    for cy in range(101):
        for cx in range(101):
            is_valid = True
            x, y, h = positions[-1]
            ph = h + abs(cy-y) + abs(cx-x)
            for x, y, h in positions[:-1]:
                hh = max(ph - abs(cy-y) - abs(cx-x), 0)
                if hh != h:
                    is_valid = False
                    break
            if is_valid:
                return (cx, cy, ph)

def main(args):
    N = int(input())
    positions = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, positions)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):

"""
C - Pyramid
https://atcoder.jp/contests/abc112/tasks/abc112_c

"""
import sys


def solve(N, positions):
    if N == 1:
        return positions[0]
    for cy in range(101):
        for cx in range(101):
            is_valid = True
            x, y, h = positions[0]
            ph = h + abs(cy-y) + abs(cx-x)
            for x, y, h in positions[1:]:
                hh = max(ph - abs(cy-y) - abs(cx-x), 0)
                if hh != h:
                    is_valid = False
                    break
            if is_valid:
                return (cx, cy, ph)
    for cy in range(101):
        for cx in range(101):
            is_valid = True
            x, y, h = positions[-1]
            ph = h + abs(cy-y) + abs(cx-x)
            for x, y, h in positions[:-1]:
                hh = max(ph - abs(cy-y) - abs(cx-x), 0)
                if hh != h:
                    is_valid = False
                    break
            if is_valid:
                return (cx, cy, ph)


def main(args):
    N = int(input())
    positions = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, positions)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
import itertools
N=int(input())
l=[]

for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
M=max(item[2] for item in l)
s=list(itertools.product(range(0,101),repeat=2))

for A,B in itertools.combinations(range(N),2):
  
  if len(s)==1:
    break
  t=[]
  
  if l[A][2]<l[B][2]:
    A,B=B,A
  if l[A][2]>l[B][2]:
    
    if l[B][2]==0:
      
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap<=abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
    else:
      
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap==abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
  
  elif l[A][2]!=0:
    
    
    for X,Y in s:
      MM=max(1,M-l[A][2])
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]) and abs(X-l[A][0])+abs(Y-l[A][1])>=MM and abs(X-l[B][0])+abs(Y-l[B][1])>=MM:
        t.append((X,Y))
  else:
    
    
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>=M and abs(X-l[B][0])+abs(Y-l[B][1])>=M:
        t.append((X,Y))
  s=t[:]

a,b=s[0][0],s[0][1]
i=0
while l[i][2]==0:
  i+=1

h=abs(a-l[i][0])+abs(b-l[i][1])+l[i][2]
print(a,b,h)

Solution (Python):
import numpy as np

N = int(input())

XY = np.zeros((2, N))
H = np.zeros(N)
x_s, y_s, h_s = 0, 0, 0


for i in range(N):
    x_tmp, y_tmp, h_tmp = map(int, input().split())

    if h_tmp > 0:
        x_s, y_s, h_s = x_tmp, y_tmp, h_tmp
    XY[:, i] = x_tmp, y_tmp
    H[i] = h_tmp

is_break = False
for c_x in range(0, 101):
    for c_y in range(0, 101):
        h_tmp = h_s + abs(x_s - c_x) + abs(y_s - c_y)
        xy = XY.copy()
        h = H.copy()
        h_tmp2 = xy - np.array([[c_x], [c_y]])
        h_tmp2 = h_tmp - np.abs(h_tmp2).sum(axis=0)
        h_tmp2 = np.clip(h_tmp2, 0, None)
        if (h == h_tmp2).all():
            print(c_x, c_y, h_tmp)
            is_break = True
            break
    if is_break:
        break

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)
tmp = max(H)
for cx in range(101):
  for cy in range(101):
    for i, h in enumerate(H):
      if h != 0:
        ch = abs(cx - X[i]) + abs(cy - Y[i]) + H[i]
        break
    for i in range(N):
      if H[i] != max(ch - abs(cx - X[i]) - abs(cy - Y[i]), 0):
        break
    else:
      print(cx, cy, ch)

Solution (Python):
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())
 
def main():
    sols = []
    for _ in range(GI()):
        x, y, h = LGIS()
        if h:
            sols.append((x, y, h))
 
    if len(sols) == 1:
        print(*sols[0])
        return
 
    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)


                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return
 
main()

Solution (Python):


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

Solution (Python):
n=int(input())
arr=[list(map(int,input().split())) for x in range(n)]
l=[i for i in range(1,201)]
for i in range(101):
  for j in range(101):
    tmp1=set()
    tmp2=10**5
    for k in range(n):
      if arr[k][2]!=0:
        tmp1.add(arr[k][2]+abs(arr[k][0]-i)+abs(arr[k][1]-j))
      else:
        if abs(arr[k][0]-i)+abs(arr[k][1]-j)<tmp2:
          tmp2=abs(arr[k][0]-i)+abs(arr[k][1]-j)
    if tmp2==10**5:
      if len(list(tmp1))==1:
        print(i,j,list(tmp1)[0])
    else:
      if len(list(tmp1))==1 and len(list(tmp1&set(l[:tmp2])))==1:
        print(i,j,list(tmp1)[0])

Solution (Python):
n=int(input())
XYH=[]
for i in range(n):
  x,y,h=map(int,input().split())
  XYH.append([x,y,h])
XYH.sort(key=lambda x:x[2])
for i in range(101):
  for j in range(101):
    peak=abs(i-XYH[-1][0])+abs(j-XYH[-1][1])+XYH[-1][2]
    flag=1
    for k in range(n-1):
      if max(0,peak-abs(i-XYH[k][0])-abs(j-XYH[k][1]))!=XYH[k][2]:
        flag=0
    if flag==1:
      Ans=[i,j,peak]
print(*Ans)

Solution (Python):
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    i1,i2,i3 = map(int,input().split())
    x.append(i1)
    y.append(i2)
    h.append(i3)
    if i3 != 0:
        tmp = i

for i in range(101):
    for j in range(101):
        H = h[tmp] + abs(i-x[tmp]) + abs(j-y[tmp])
        flg = True
        for n in range(N):
            if h[n] != max(H - abs(i-x[n]) - abs(j-y[n]),0):
                flg = False
                break
        if flg == True:
            print(i,j,H)

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)

for x in range(101):
    for y in range(101):
        for n in range(N):
            if hs[n] > 0:
                h = hs[n] + abs(x - xs[n]) + abs(y - ys[n])
                break
        flg = True        
        for n in range(N):
            if hs[n] != max(0, h - abs(x - xs[n]) - abs(y - ys[n])):
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(x, y, h))

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

li.sort(key=lambda x: x[2])
a,b,c = li[-1]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j),0) for i,j,k in li):
            print(x,y,h)
            exit()

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

X,Y=-1,-1
for x in range(101):
  for y in range(101):
    flag = True
    _h = -1
    for i,j,h in li:
      kyo = abs(i-x)+abs(j-y)
      if (h>0):
        if (_h==-1):
          _h = kyo + h
        else:
          if (_h!=kyo+h):
            flag=False
            break
      else: 
        if (_h>kyo):
          flag=False
          break
    for i,j,h in li:
      kyo = abs(i-x)+abs(j-y)
      if (h>0):
        if (_h==-1):
          _h = kyo + h
        else:
          if (_h!=kyo+h):
            flag=False
            break
      else: 
        if (_h>kyo):
          flag=False
          break
    if (flag):
      X = x
      break
  if (flag):
    Y = y
    break
print (X,Y,_h)

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


for x in range(101):
    for y in range(101):
        h = -1
        for k in xyh:
            if k[2] != 0:
                if h == -1:    
                    h = abs(k[2] + abs(k[0]-x) + abs(k[1]-y))
                elif h != abs(k[2] + abs(k[0]-x) + abs(k[1]-y)):
                    h = -2
                    break
        for k in xyh:
            if k[2] == 0:   
                tmp = abs(k[0]-x) + abs(k[1]-y)
                if h > tmp:
                    h = -2
                    break
        if h > 0:
            print(x,y,h)

Solution (Python):
n = int(input())
xyhs = []
for _ in range(n):
    xyhs.append(tuple(map(int, input().split())))

xyhs = sorted(xyhs, key=lambda v: v[2], reverse=True)

anss = []
for y in range(101):
    for x in range(101):
        x0, y0, h0 = xyhs[0]
        ht = h0 + abs(x0 - x) + abs(y0 - y)

        flag = True
        for xyh in xyhs[1:]:
            xi, yi, hi = xyh
            his = max(ht - abs(xi - x) - abs(yi - y), 0)
            if his != hi:
                flag = False
                break

        if flag:
            anss.append((x, y, ht))

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

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

index = min([i for i in range(N) if IN[i][2] > 0])
for i in range(101):
  for j in range(101):
    temp_h = abs(IN[index][0]-i) + abs(IN[index][1]-j) + IN[index][2]
    check = True
    for test in IN:
      calc_h = max([temp_h - abs(test[0]-i) - abs(test[1]-j), 0])
      if calc_h != test[2]:
        check = False
        break
    if check:
      print(i, j, temp_h)
      exit()

Solution (Python):
import itertools as its

N = int(input())
P = []
on_piramid = None
for _ in range(N):
    p = tuple(map(int, input().split()))
    P.append(p)
    if on_piramid == None and p[2] >= 1:
        on_piramid = p

for x, y in its.product(range(101), range(101)):
    h = on_piramid[2] + abs(x-on_piramid[0]) + abs(y-on_piramid[1])
    for i in range(N):
        if P[i][2] != max(h - abs(x - P[i][0]) - abs(y - P[i][1]), 0):
            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 i in range(N):
    if h[i] != 0:
        target = i
        break

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

print(CX, CY, H)

Solution (Python):
N = int(input())
data_plus = []
data_minus = []
for i in range(N):
  datum = list(map(int, input().split()))
  if datum[2] > 0:
    data_plus.append(datum) 
  else:
    data_minus.append(datum)

finish = 0
for cx in range(101):
  for cy in range(101):
    ok = 1
    for i in range(1,len(data_plus)):
      if (abs(cx - data_plus[i][0]) - abs(cx - data_plus[0][0]) 
          + abs(cy - data_plus[i][1]) - abs(cy - data_plus[0][1])
          != data_plus[0][2] - data_plus[i][2]):
        ok = 0
        break
    if ok:
      ok2 = 1
      H = abs(cx - data_plus[0][0]) + abs(cy - data_plus[0][1]) + data_plus[0][2]
      for i in range(len(data_minus)):
        if H - abs(cx - data_minus[i][0]) - abs(cy - data_minus[i][1]) > 0:
          ok2 = 0
      if ok2:
        print(cx, cy, H)
        finish = 1
    if finish == 1:
      break
  if finish == 1:
    break

Solution (Python):
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    if xyh[i][2]>0:
        tx,ty,th=xyh.pop(i)
        break
for cx in range(101):
    for cy in range(101):
        H=th+abs(tx-cx)+abs(ty-cy)
        for x,y,h in xyh:
            if h==0 and H-abs(x-cx)-abs(y-cy)<=0: continue
            if H!=h+abs(x-cx)+abs(y-cy): break
        else:
            print(cx,cy,H)
            exit()

Solution (Python):
n = int(input())
x,y,h = [],[],[]
idx = 0
for i in range(n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c != 0:
        idx = i

for cx in range(101):
    for cy in range(101):
        
        H = h[idx] + abs(x[idx]-cx) + abs(y[idx]-cy)

        ok = True
        for i in range(n):
            if h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy), 0):
                ok = False
        if ok:
            print(cx,cy,H)

Solution (Python):
N  = int(input())
a = []
l = 0
for i in range(N):
    x,y,H = map(int,input().split())
    a.append([x,y,H])
for t in range(N):
    if a[t][2] != 0:
        break
for i in range(101):
    for j in range(101):
        l = a[t][2] + abs(a[t][0]-i)+abs(a[t][1]-j)
        for k in range(N):
            if a[k][2]!=max(0,l-abs(i-a[k][0])-abs(j-a[k][1])):
                break
            elif k == N-1:
                print(str(i)+' '+str(j)+ ' '+str(l))
                exit()

Solution (Python):
n = int(input())
inf = [list(map(int, input().split())) for i in range(n)]
inf = sorted(inf, key=lambda x : x[2])
x, y , h = inf[-1]
for cx in range(100, -1, -1):
    for cy in range(100, -1, -1):
        H = h + abs(cx - x) + abs(cy - y)
        if H < 1:
            continue
        for x1, y1, h1 in inf:
            if not h1 == max(H - abs(cx - x1) - abs(cy - y1), 0):
                break
        else:
            print(cx, cy, H, sep=' ')
            exit()

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

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




for px in range(101):
    for py in range(101):

        j = 0
        while lst[j][2] == 0:
            j += 1
        h = lst[j][2] + abs(px-lst[j][0]) + abs(py -lst[j][1])

        k = 0
        while k < N:
            if lst[k][2] == max(h - abs(px-lst[k][0]) - abs(py -lst[k][1]), 0):
                k += 1

            else:

                k = 10 ** 9
        if k == N:
            print (px, py, h)
            sys.exit()
        else:
            pass

Solution (Python):
a=int(input())
if a==1:
    print(input())
else:
    b=[]
    k=l=0
    for i in range(a):
        x,y,h=map(int,input().split())
        b.append([x,y,h])
    for k in range(a):
        if b[k][2] != 0: break
    for i in range(101):
        for j in range(101):
            l=b[k][2]+abs(b[k][0]-i)+abs(b[k][1]-j)
            for I in range(a):
                if b[I][2]!=max(0,l-abs(i-b[I][0])-abs(j-b[I][1])):
                    break
                elif I==a-1:
                    print(str(i)+" "+str(j)+" "+str(l))
                    exit()

Solution (Python):
n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(len(s_list)):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            if len(zero_list) > 0:
                zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
                if zero_p <= 0:
                    ttt = h + abs(x_ - x) + abs(y_ - y)
                    ans = str(x) + " " + str(y) + " " + str(ttt)
                    break
            else:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
                
print(ans)

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

Solution (Python):
import itertools
N = int(input())
XYH = [tuple(map(int,input().split(' '))) for _ in range(N)]
XYH.sort(key=lambda y:y[2],reverse=True)
x,y,h = XYH[0]

for i,j in itertools.product(range(101),repeat=2):
  
  H = h + abs(x-i) + abs(y-j)
  if all(max(H-abs(a-i)-abs(b-j),0)==c for a,b,c in XYH):
    print(i,j,H)
    break

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

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

Solution (Python):
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]
for cx in range(101):
    for cy in range(101):
        H = A[2] + abs(A[0] - cx) + abs(A[1] - cy)
        Flag = True
        for i in range(N):
            if max(H - abs(X[i][0] - cx) - abs(X[i][1] - cy), 0) != X[i][2]:
                Flag = False
                break
        if Flag:
            print(cx, cy, H)
            break
    if Flag:
        break

Solution (Python):
N=int(input())
XYH = [[int(a) for a in input().split(" ")] for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        Hp = [abs(x-cx)+abs(y-cy)+h for x, y, h in XYH if h>0]
        Hz = [Hp[0]-abs(x-cx)-abs(y-cy) for x,y,h in XYH if h==0] 
        if all([h==Hp[0] for h in Hp]) and all([h<=0 for h in Hz]):
            print(" ".join([str(cx),str(cy),str(Hp[0])]))

Solution (Python):
import math
N = int( input())
di = [[-1] * 101 for i in range(101)]



ps = []
basep=0
for k in range(N):
    temp = list(map(int,input().split(" ")))
    ps.append(temp)
    if temp[2] != 0:
        basep = temp

basex = basep[0]
basey = basep[1]
baseh = basep[2]

flag = True
for i in range(101):
    for j in range(101):
        flag = True
        X = i
        Y = j
        H = abs(basex - X) + abs(basey - Y) + baseh
        for l,p in enumerate(ps):
            x = p[0]
            y = p[1]
            h = p[2]
        
            if max(H -abs(X-x)-abs(Y-y),0) != h: 
                flag = False
                
                

                
                break
        if flag:
                print(X,Y,H)
                break
    if flag:
        break