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

XYH.sort(key=lambda x:x[2],reverse=True)
x0,y0,h0=XYH[0]
for i in range(101):
  for j in range(101):
    H = h0+abs(i-x0)+abs(j-y0)
    for x,y,h in XYH:
      if h>0:
        if H != h+abs(i-x)+abs(j-y):
          break
      else:
        if H-abs(i-x)-abs(j-y)>0:
          break
    else:
      print(i,j,H)
      exit()

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

for i in range(N):
    if xyh[i][2] != 0:
        x = xyh[i][0]
        y = xyh[i][1]
        h = xyh[i][2]

for i in range(101):  
    for j in range(101):  
        tmp_h = abs(x-i)+abs(y-j)+h
        cnt = 0
        for k in range(N):
            if xyh[k][2] == max(0,tmp_h-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                cnt += 1
        if cnt == N:
            ans_x = i
            ans_y = j
            ans_h = tmp_h
            break
print(ans_x, ans_y, ans_h)

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

N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda i:i[2], reverse=True)
x0, y0, h0 = xyh[0]

for i in range(101):
    for j in range(101):
        H = h0 + abs(i - x0) + abs(j - y0)
        for x, y, h in xyh:
            if h > 0:
                if H != h + abs(i - x) + abs(j - y):
                    break
            else:
                if H - abs(i - x) - abs(j - y) > 0:
                    break
        else:
            print(i, j, H)
            exit()

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

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

for i in range(101):
    for j in range(101):
        for x, y, h in xyh:
            if h != 0:
                H = h + abs(i - x) + abs(j - y)
                for x, y, h in xyh:
                    if h != max(H - abs(i - x) - abs(j - y), 0):
                        break
                else:
                    print(i, j, H)
                    exit()

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

for _ in range(N):
    tmp, tmp2, tmp3 = map(int, input().split())
    x.append(tmp)
    y.append(tmp2)
    h.append(tmp3)
    



for Cx in range(101):
    for Cy in range(101):
        H_tmp = []
        max_h_tmp = float("inf")
        
        for i in range(N):
            if h[i] == 0:
                max_h_tmp = min(max_h_tmp, abs(x[i]-Cx) + abs(y[i]-Cy))
            else:
                H_tmp.append(h[i] + abs(x[i]-Cx) + abs(y[i]-Cy))
        
        H_tmp = set(H_tmp)
        if max(H_tmp) <= max_h_tmp and len(H_tmp) == 1:
            print(Cx, Cy, list(H_tmp)[0])
            exit()

Solution (Python):
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  query = []
  candi = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  if n == 1:
    print(*[x,y,h])
    exit()
  query = sorted(query,reverse = True,key=lambda x: x[2])
  for cx in range(0,101):
    for cy in range(0,101):
      judge = True
      x,y,h = query[0]
      karih = h +abs(cx-x)+abs(cy-y)
      karih2 = 0
      for i in range(n-1):
        nx,ny,nh = query[i+1]
        if nh == max(karih-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:
        candi.append((cx,cy,karih))
        
  print(*candi[0])
        
          
      
      
solve()

Solution (Python):
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  query = []
  candi = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  if n == 1:
    print(*[x,y,h])
    exit()
  for cx in range(0,101):
    for cy in range(0,101):
      judge = True
      for j in range(n):
        x,y,h = query[j]
        if not h == 0:
          karih = h +abs(cx-x)+abs(cy-y)
          karih2 = 0
      for i in range(n):
        nx,ny,nh = query[i]
        if nh == max(karih-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:
        candi.append((cx,cy,karih))
        
      judge = True 
      for i in range(n-1):
        nx,ny,nh = query[i+1]
        if nh == max(karih2-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:
        candi.append((cx,cy,karih2))
  print(*candi[0])
        
          
      
      
solve()

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

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

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

data = []
p, q, r = (0, 0, 0)
for _ in range(n):
    (l, m, n) = map(int, input().split())
    data.append([l, m, n])
    if n:
        p = l
        q = m
        r = n


for x in range(101):
    for y in range(101):
        h = r + abs(p - x) + abs(q - y)
        if all(c == max(h - abs(a - x) - abs(b - y), 0) for a, b, c in data):
            print("{} {} {}".format(x, y, h))
            exit(0)

Solution (Python):
n = int(input())
loc = [list(map(int,input().split())) for _ in range(n)]
loc.sort(key = lambda x:x[2] ,reverse = True)
for i in range(101):
  for j in range(101):
    h = abs(loc[0][0]-i)+abs(loc[0][1]-j)+loc[0][2]
    for l in loc[1:]:
      if l[2] != max(h-abs(l[0]-i)-abs(l[1]-j),0):
        break
    else:
      print(i,j,h)
      break

Solution (Python):
N=int(input())
xyh=[list(map(int,input().split())) for i in range(N)]
from itertools import product
H={(i,j):-10**10 for i,j in product(range(101),repeat=2)}
for n in range(N):
    x,y,h=xyh[n]
    K=[e for e in H.keys()]
    for i,j in K:
        k0=H[i,j]
        k=abs(i-x)+abs(j-y)+h if h else -(abs(i-x)+abs(j-y))
        if k<0:
            if k0<k:
                H[i,j]=k
            elif -k<k0:
                del H[i,j]
        elif k0<0:
            if k<=-k0:
                H[i,j]=k
            else:
                del H[i,j]
        elif k!=k0:
            del H[i,j]
i,j=list(H.keys())[0]
print(i,j,H[i,j])

Solution (Python):
def get_H(cx,cy):
  for info in info_list:
    if info[2] != 0:
      H0 = info[2] + abs(info[0]-cx) + abs(info[1]-cy)
      break

  for info in info_list:
    if info[2] != max(H0 - abs(info[0]-cx) - abs(info[1]-cy),0): return -1  
  return H0

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

for cx in range(101):
  for cy in range(101):
    res = get_H(cx,cy)
    if res != -1:
      print(cx,cy,res)

Solution (Python):
n = int(input())
xyh_list = [list(map(int, input().split())) for _ in range(n)]
list_0_100 = [i for i in range(0, 101)]
possible_list = []
for a in range(len(xyh_list)):
    if xyh_list[a][2] != 0:
        x1 = xyh_list[a][0]
        y1 = xyh_list[a][1]
        h1 = xyh_list[a][2]
        break

for cx in list_0_100:
    for cy in list_0_100:
        H = h1 + abs(x1 - cx) + abs(y1 - cy)
        count = 0
        for i in range(n):
            x = xyh_list[i][0]
            y = xyh_list[i][1]
            h = xyh_list[i][2]
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                count += 1
        if count == n:
            ansx = cx
            ansy = cy
            ansH = H
print(ansx, ansy, ansH)

Solution (Python):
from collections import defaultdict
N = int(input())
XYH = [list(map(int,input().split())) for _ in range(N)]
XYH.sort(key=lambda x: x[2],reverse=True)

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

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

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

for i in range(101):
    for j in range(101):
        
        H=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for x,y,h in xyh:
            if h==max(H-abs(x-i)-abs(y-j),0):
                continue
            else:
                break
        else:
            print(i,j,H)

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


for cx in range(101):
    for cy in range(101):
        h = 0
        hmax =float('inf')
        false = 0
        for  hi,x,y in records:
            if hi==0:
                hmax=min(hmax,abs(cx-x)+abs(cy-y))
            else:
                if h ==0:
                    h = hi +abs(cx-x)+abs(cy-y)
                else:
                    if h != abs(cx-x)+abs(cy-y) +hi:
                        false = 1
                        break
        if false:
            continue
        else:
            if (1 <=h <= hmax):
                print(cx,cy,h)
                exit()
            else:
                if h==0 and hmax ==1:
                    print(cx,cy,h)
                    exit()
                else:
                    continue

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *

from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    points = [tuple(map(int, input().split())) for _ in range(N)]
    base_point = [(x,y,h) for x,y,h in points if h > 0][0]
    for cx in range(101):
        for cy in range(101):
            H = abs(cx-base_point[0])+abs(cy-base_point[1])+base_point[2]
            for x,y,h in points:
                if h != max(H-abs(cx-x)-abs(cy-y),0): break
            else:
                print(cx,cy,H)
                return 0

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
xyh = [[int(i) for i in input().split()] for j in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        for k in xyh:
            if k[2] == max(h - abs(k[0] - i) - abs(k[1] - j), 0):
                continue
            else:
                break
        else:
            print(i, j, h)

Solution (Python):
if __name__=='__main__':
    n = int(input())
    c = [[int(i) for i in input().split()] for i in range(n)]
    
    a = [[0 for i in range(101)] for i in range(101)]
    
    for i in range(101):
        for j in range(101):
            for p in range(n):
                if c[p][2] != 0:
                    a[i][j] = abs(i - c[p][0]) + abs(j - c[p][1]) + c[p][2]
                    break


            for p in range(n):
                if c[p][2] != 0:
                    h = abs(i - c[p][0]) + abs(j - c[p][1]) + c[p][2]
                    if a[i][j] != h:
                        a[i][j] = -1
                        break
                if c[p][2] == 0:
                    h = abs(i - c[p][0]) + abs(j - c[p][1])
                    if a[i][j] > h:
                        a[i][j] = -1
                        break


    for i in range(101):
        for j in range(101):
            flag = True
            if a[i][j] == -1:continue
            
            
            
            
            
            
            for p in range(n):
                h = max(a[i][j] - abs(i-c[p][0])- abs(j-c[p][1]),0)
                if h!= c[p][2]:
                    flag = False
                    break
            if flag:
                print(i,j,a[i][j])
                quit()

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

use=()
for some in lists:
    if some[2]==0:
        continue
    else:
        use=some
        break

for i in range(0,101):
    for j in range(0,101):
        height=use[2]+abs(i-use[0])+abs(j-use[1])   
        ok=True
        for inn in lists:
            if inn[2]==0:
                if height>abs(i-inn[0])+abs(j-inn[1]):
                    ok=False
            if inn[2]>0:
                if inn[2]+abs(i-inn[0])+abs(j-inn[1])!=height:
                    ok=False
        if ok:
            ans=[i,j,height]
            print(*ans)
            break
        else:
            continue

Solution (Python):
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
H =[]
for i in range(0,101):
    for j in range(0, 101):
        H.append([i,j,0])

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

for X,Y,H0 in H:
    this_sum = []
    H1 = a[0][2] + abs(X-a[0][0]) + abs(Y-a[0][1])
    for x,y,h in a:
        if h == max(H1 - abs(x-X) - abs(y-Y), 0):
            continue
        else:
            break
    else:
        print(" ".join(list(map(str, [X, Y, H1]))))

Solution (Python):
n = int(input())
xyh = [[int(i) for i in input().split()] for j in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        for k in xyh:
            if k[2] == max(h - abs(k[0] - i) - abs(k[1] - j), 0):
                continue
            else:
                break
        else:
            print(i, j, h)

Solution (Python):
def test():
    n = int(input())
    a = [(list(map(int,input().split()))) for i in range(n)]
    for cx in range(101):
        for cy in range(101):
            for x,y,h in a:
                if h > 0:
                    H = h + abs(x-cx) + abs(y-cy)
                    break
            for x,y,h in a:
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    break
            else:
                print(cx,cy,H)
                return


if __name__ == "__main__":
    test()

Solution (Python):
from collections import defaultdict

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


N = int(input())
L = []
for i in range(N):
	x, y, h = getlist()
	L.append([x, y, h])


for i in range(101):
	for j in range(101):
		D = defaultdict(int)
		for k in range(N):
			if L[k][2] != 0:
				val = abs(L[k][0] - i) + abs(L[k][1] - j) + L[k][2]
				D[val] += 1
		if len(D) == 1:
			judge = "Yes"
			for k in range(N):
				if val - abs(L[k][0] - i) - abs(L[k][1] - j) > L[k][2]:
					judge = "No"
					break
			if judge == "Yes":
				print(i, j, val)

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



prob = []
for i in range(N):
    if h[i] > 0:
        for cx in range(101):
            for cy in range(101):
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                prob.append([cx,cy,H])
        break


for i in range(N):
    minus = []
    for j in range(len(prob)):
        cx = prob[j][0]
        cy = prob[j][1]
        H = prob[j][2]
        if h[i] == max(H-abs(x[i] - cx) -abs(y[i] - cy),0):
            continue
        else:
            minus.append([cx,cy,H])
    if len(minus) == 0:
        continue
    else:
        for k in range(len(minus)):
            prob.remove(minus[k])
print(str(prob[0][0])+' '+str(prob[0][1])+' '+str(prob[0][2]))

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

flag = True
id = 0
for i in range(n):
    P = list(map(int, input().split( )))
    p.append(P)
    if P[2]>0:
        id = i
cand = [[-1 for y in range(101)] for x in range(101)]
 
for x in range(101):
    for y in range(101):
        cand[x][y] = p[id][2]+abs(x-p[id][0])+abs(y-p[id][1])
ans =  [[1 for y in range(101)] for x in range(101)]

for i in range(n):
    for x in range(101):
        for y in range(101):
            h = max(cand[x][y]- abs(x-p[i][0])-abs(y-p[i][1]), 0)
            if p[i][2] != h:
                ans[x][y] = 0

ans_x = -1
ans_y = -1
for x in range(101):
    for y in range(101):
        if ans[x][y] == 1:
            ans_x, ans_y = x,y

print(ans_x,ans_y,cand[ans_x][ans_y])

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




x0,y0,h0 = XYH[0]
for cx in range(101):
  for cy in range(101):
    ch = h0 + abs(x0-cx) + abs(y0-cy)
    flag = True
    for i in range(1,N):
      x,y,h = XYH[i]
      if (h > 0 and ch != h + abs(x-cx) + abs(y-cy)) or (h == 0 and ch > h + abs(x-cx) + abs(y-cy)):
        flag = False
        break
    if flag:
      print(cx,cy,ch)
      exit()

Solution (Python):
N=int(input())
xyh=[list(map(int, input().split())) for i in range(N)]
 
for i in range(101):
  for j in range(101):
    check=True
    k=0
    while xyh[k][2]==0:
      k+=1
      
    h=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
    
    for k in range(N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if xyh[k][2]==0:
        if temph<h:
          check=False
      else:
        if h!=temph:
          check=False
        
    if check==True and 0<h:
        print(' '.join([str(i), str(j), str(h)]))
        exit()
        
sonnnakannsuuhateigisiteinai()

Solution (Python):
N = int(input())
x, y, h = [], [], []
for i in range(N):
    s, t, u = map(int, input().split())
    x.append(s)
    y.append(t)
    h.append(u)




prob = []
for i in range(N):
    if h[i] > 0:
        for cx in range(101):
            for cy in range(101):
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                prob.append([cx, cy, H])
        break



for i in range(N):
    minus = []
    for j in range(len(prob)):
        cx = prob[j][0]
        cy = prob[j][1]
        H = prob[j][2]
        if h[i] == max(H - abs(x[i] - cx) - abs(y[i] - cy), 0):
            continue
        else:
            minus.append([cx, cy, H])
    if len(minus) == 0:
        continue
    else:
        for k in range(len(minus)):
            prob.remove(minus[k])

ans = ' '.join(list(map(str, list(list(prob)[0]))))
print(ans)

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

cands = []
for cy in range(101):
    for cx in range(101):
        h_tmp = None
        for x,y,h in XYH:
            if h==0: continue
            d = abs(cy-y) + abs(cx-x)
            if h_tmp is None:
                h_tmp = h+d
            else:
                if h+d != h_tmp:
                    break
        else:
            cands.append((cx,cy,h_tmp))

for cx,cy,ch in cands:
    for x,y,h in XYH:
        if max(ch - abs(x-cx) - abs(y-cy), 0) != h:
            break
    else:
        print(cx,cy,ch)

Solution (Python):
import sys
readline = sys.stdin.readline
N = int(readline())
XYH = [list(map(int, readline().split())) for _ in range(N)]
X, Y, H = map(list, zip(*XYH))
i = 0
for i in range(N):
    if H[i] != 0:
        x, y, h = X[i], Y[i], H[i]
        break
mh = min(H)
Mh = max(H)
for i in range(101):
    for j in range(101):
        ch = abs(x-i) + abs(y-j) + h
        for xi, yi, hi in XYH:
            if hi != max(0, -abs(xi- i) - abs(yi-j) + ch):
                break
        else:
            ans = (i, j, ch)
print(*ans)

Solution (Python):
def solve():
    n = int(input())
    
    P = set()
    for i in range(n):
        x,y,h = map(int,input().split())
        if h != 0:
            P.add((x,y,h))
    x,y,h = P.pop()
    if not P:
        return x,y,h
    for cx in range(101):
        for cy in range(101):
            H = h + abs(x-cx) + abs(y-cy)
            for p in P:
                if H != p[2] + abs(p[0]-cx) + abs(p[1]-cy):
                    break
            else:
                return cx,cy,H
        
if __name__ == '__main__':
    print(*(solve()))

Solution (Python):


N = int(input().split()[0])
xyh_list = []
not_zero_h_list = []

for _ in range(N):
    x, y, h = list(map(int, input().split()))
    xyh_list.append((x, y, h))
    if h != 0:
        not_zero_h_list.append((x, y, h))


target_x, target_y, target_h = not_zero_h_list[0]

for cx in range(0, 101):
    for cy in range(0, 101):
        
        H_list = []
        
        H = target_h + abs(target_x - cx) + abs(target_y - cy)
        H = max(0, H)
        is_ok = True

        
        for x, y, h in xyh_list:  
            if h == 0:
                if (H - abs(x - cx) - abs(y - cy)) <= 0:
                    continue
                else:
                    
                    is_ok = False
                    break
            else:
                HH = h + abs(x - cx) + abs(y - cy)
                HH = max(0, HH)
                if HH != H:
                    
                    is_ok = False
                    break
        if is_ok:
            break

    if is_ok:
        break
ans = "{} {} {}".format(cx, cy, H)
print(ans)

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

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

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        for i, (x,y,h) in enumerate(xyh):
            if h != 0:
                H = h + abs(x - cx) + abs(y - cy)

        for i, (x,y,h) in enumerate(xyh):
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                flag = False
                break
        if flag:
            print(cx, cy, H)
            exit()

Solution (Python):
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    H = 0
    for i in range(N):
        if xyh[i][2] >= H:
            X = xyh[i][0]
            Y = xyh[i][1]
            H = xyh[i][2]
            I = i
    
    flag = True
    for i in range(0, N):
        if xyh[i][2] != max(H - abs(xyh[i][0] - X) - abs(xyh[i][1] - Y), 0):
            flag = False
            break
    
        
    if not flag:
        for x in range(0, 101):
            for y in range(0, 101):
                flag = True
                height = 0
                for i in range(0, N):
                    if xyh[i][2] != 0:
                        if height == 0:
                            height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                        if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                            flag = False
                            break
                    else:
                        if abs(xyh[i][0] - x) + abs(xyh[i][1] - y) < height:
                            flag = False
                            break
                if flag and height:
                    X = x
                    Y = y
    
    H = xyh[I][2] + abs(xyh[I][0] - X) + abs(xyh[I][1] - Y)
     
    print(X, Y, H)

Solution (Python):
N = int(input())
D = [tuple(map(int,input().split())) for _ in range(N)]
D = sorted(D,key=lambda x:x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        ind = 1
        x,y,h = D[0]
        H = abs(x-cx)+abs(y-cy)+h
        for i in range(1,N):
            x,y,h = D[i]
            if h>0 and abs(x-cx)+abs(y-cy)+h!=H:
                ind = 0
                break
            elif h==0 and abs(x-cx)+abs(y-cy)<H:
                ind = 0
                break
        if ind==1:
            CX = cx
            CY = cy
            break
    if ind==1:break
print(CX,CY,H)

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

xyh.sort(key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        x = xyh[0][0]
        y = xyh[0][1]
        h = xyh[0][2]
        ans = [cx, cy, h + abs(x - cx) + abs(y - cy)]
        for i in range(1, n):
            x = xyh[i][0]
            y = xyh[i][1]
            h = xyh[i][2]
            if h != max(ans[2] - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            print(*ans)

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

for cx in range(0,101):
    for cy in range(0, 101):
        ch = 0
        for i in range(0,N):
            if xyh[i][2] > 0:
                ch = xyh[i][2] + abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy)
                break
        for i in range(0, N):

            if xyh[i][2] != max(ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -  cy), 0):
                break
        else:
            print('{} {} {}'.format(cx, cy, ch))
            break
    else:
        continue
    break

Solution (Python):
def main():
    N = int(input())
    p = []
    for i in range(N):
        x,y,h = map(int,input().split())
        p.append([x,y,h])
 
    p.sort(key=lambda x: x[2])
    a,b,c = p[-1]
    for i in range(101):
        for j in range(101):
            H = c + abs(a - i) + abs(b - j)
            for x,y,h in p:
                if h != max(H - abs(x - i) - abs(y - j), 0):
                    break
            else:
                print(i,j,H)
                exit()


main()

Solution (Python):
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
surveys.sort(key = lambda x:-x[2])
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        if survey[2] == 0 and before < height:
          continue
        identified = False
        break
      if before == -1:
        before = height
    if identified:
      print(x, y, before)
      break

Solution (Python):
n=int(input())
p = []
for i in range(n):
    ta,tb,tc = map(int,input().split())
    p.append([ta,tb,tc])

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

a = sorted(a, key=lambda x: -x[2])

m = 0
mx = 0
my = 0

for cx in range(101):
    for cy in range(101):
        flag = True
        x, y, h = a[0]
        H = max(abs(x-cx) + abs(y-cy) + h, 0)
        for i in range(n):
            xx, yy, hh = a[i]
            if hh != max(H - abs(xx - cx) - abs(yy - cy), 0):
                flag = False

        if flag == True:
            mx = cx
            my = cy
            m = H

print(str(mx) + ' ' + str(my) + ' ' + str(m))

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

x = [0] * N
y = [0] * N
h = [0] * N

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

for i in range(101):
    for j in range(101):
        det = 0
        H = 0
        for k in range(N):
            if H == 0 and h[k] > 0:
                H = h[k] + abs(x[k]-i) + abs(y[k]-j)
            elif h[k] != max(0,H - abs(x[k]-i) - abs(y[k]-j)):
                det = -1
                break
        if det == 0:
            ans = [i,j,H]

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

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

x = [0] * N
y = [0] * N
h = [0] * N

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

for i in range(101):
    for j in range(101):
        det = 0
        H = 0
        for k in range(N):
            if H == 0 and h[k] > 0:
                H = h[k] + abs(x[k]-i) + abs(y[k]-j)
            elif h[k] != max(0,H - abs(x[k]-i) - abs(y[k]-j)):
                det = -1
                break
        if det == 0:
            ans = [i,j,H]

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda x: x[2], reverse=True)
    for x in range(101):
        for y in range(101):
            h = xyh[0][2] + abs(xyh[0][0] - x) + abs(xyh[0][1] - y)
            b = True
            for xl, yl, hl in xyh:
                if max(0, h - abs(xl - x) - abs(yl - y)) != hl:
                    b = False
                    break
            if b:
                print(x, y, h)
                exit()


if __name__ == '__main__':
    slove()

Solution (Python):
n=int(input())
xyh=[[int(i) for i in input().split()] for j in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)


for i in range(101):
    for j in range(101):
        h=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for k in xyh:
            if k[2]==max(h-abs(k[0]-i)-abs(k[1]-j),0):
                continue
            else:
                break
        else:
            print(i,j,h)

Solution (Python):
N = int(input())
p = [tuple(map(int,input().split())) for _ in range(N)]
p.sort(key=lambda x:x[2])
mx,my,mh = p[-1]

for cx in range(101):
  for cy in range(101):
    H = mh + abs(mx-cx) + abs(my-cy)
    if all(h == max(H - abs(x - cx) - abs(y - cy), 0) for x, y, h in p):
      print(cx, cy, H)
      exit()

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

r=sorted([list(map(int,input().split()))[::-1] for _ in range(n)])[::-1]

for i in range(101):
  for j in range(101):
    h1=r[0][0]+abs(r[0][1]-i)+abs(r[0][2]-j)
    flag=0
    for item in r[1:]:
      if item[0]>0:
        if item[0]+abs(item[1]-i)+abs(item[2]-j)!=h1:
          flag=1
          break
      else:
        if h1-abs(item[1]-i)-abs(item[2]-j)>0:
          flag=1
          break
    if flag==0:
      print(j,i,h1)
      exit()