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):
def main():
    N = int(input())
    inp = [list(map(int, input().split())) for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmax = 10 ** 10
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        ha = 0
                        break
                    if ha:
                        if ht != ha:
                            ha = 0
                            break
                    else:
                        ha = ht
            
            if 0 < ha <= hmax:
                print(cx, cy, ha)
                exit()


if __name__ == "__main__":
    main()

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmax = 10 ** 10
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        ha = 0
                        break
                    if ha:
                        if ht != ha:
                            ha = 0
                            break
                    else:
                        ha = ht
            
            if ha:
                if ha <= hmax:
                    print(cx, cy, ha)
                    exit()


if __name__ == "__main__":
    main()

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmax = 10 ** 10
            flg = False
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        break
                    if flg:
                        if ht != ha:
                            flg = False
                            break
                    else:
                        flg = True
                        ha = ht
            
            if flg:
                if ha:
                    if ha <= hmax:
                        print(cx, cy, ha)
                        exit()


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        l = 0
        while h[l] == 0:
            l += 1
        
        val = h[l] + abs(i-x[l]) + abs(j-y[l])
        flg = True
        for k in range(n):
            if val != h[k] + abs(i-x[k]) + abs(j-y[k]) and h[k] != 0:
                flg = False
            if h[k] == 0 and abs(i-x[k]) + abs(j-y[k]) < val:
                flg = False
        if flg == True:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Solution (Python):
import sys

n, *xyh = map(int, sys.stdin.read().split())
xyh = list(zip(*[iter(xyh)] * 3))

def contradict(cx, cy, ch, x, y, h):
    return max(ch - abs(x - cx) - abs(y - cy), 0) != h

def main():
    for x, y, h in xyh:
        if h: x0, y0, h0 = x, y, h; break

    for cx in range(101):
        for cy in range(101):
            ch = h0 + abs(cx - x0) + abs(cy - y0)
            for x, y, h in xyh:
                if contradict(cx, cy, ch, x, y, h): break
            else:
                print(cx, cy, ch)
                return

if __name__ ==  '__main__':
    main()

Solution (Python):
import sys

n, *xyh = map(int, sys.stdin.read().split())
xyh = list(zip(*[iter(xyh)] * 3))

def contradict(cx, cy, ch, x, y, h):
    return max(ch - abs(x - cx) - abs(y - cy), 0) != h

def main():
    for x, y, h in xyh:
        if h: x0, y0, h0 = x, y, h; break
    cand = []
    for cx in range(101):
        for cy in range(101):
            ch = h0 + abs(cx - x0) + abs(cy - y0)
            for x, y, h in xyh:
                if contradict(cx, cy, ch, x, y, h): break
            else:
                cand.append((ch, cx, cy))
    cand.sort(reverse=True)
    res = cand[0]
    print(res[1], res[2], res[0])

if __name__ ==  '__main__':
    main()

Solution (Python):





mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    vx = []
    vy = []
    vh = []
    si = -1
    for i in range(n):
        a,b,c = readInts()
        vx.append(a)
        vy.append(b)
        vh.append(c)
        if vh[i] > 0:
            si = i


    resx,resy,resh = -1,-1,-1
    for cx in range(101):
        for cy in range(101):
            h = vh[si] + abs(cx - vx[si]) + abs(cy - vy[si])
            ok = True
            for i in range(n):
                if vh[i] > 0:
                    if h - vh[i] != abs(cx - vx[i]) + abs(cy - vy[i]):
                        ok = False
                if vh[i] == 0:
                    if h > abs(cx - vx[i]) + abs(cy - vy[i]):
                        ok = False
            if ok:
                resx = cx
                resy = cy
                resh = h
    print(resx,resy,resh)



if __name__ == '__main__':
  main()

Solution (Python):
n = int(input())
l = []
for i in range(n):
  l.append(list(map(int, input().split())))
l = sorted(l, key=lambda x: x[2], reverse=True)
for cx in range(101):
  for cy in range(101):
    flag = True
    cnt = 0
    for x, y, h in l:
      if not cnt:
        H =  h+abs(x-cx)+abs(y-cy)
        cnt = 1
      else:
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          flag = False
          break
    if flag:
      ans = [cx, cy, H]
      break
  if flag:
    break
    
print(*ans)

Solution (Python):
import sys
N = int(input())
Info = []
for _ in range(N):
    Info.append(list(map(int,input().split())))
for X in range(101):
    for Y in range(101):
        H = None
        for x, y, h in Info:
            if h != 0:
                if H is None:
                    H = h + abs(X-x) + abs(Y-y)
                if H != h + abs(X-x) + abs(Y-y):
                    H = None
                    break
        if H is not None:
            flag = 1
            for x, y, h in Info:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    flag = 0
            if flag:
                print(*[X,Y,H])
                sys.exit()

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

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(1, N):
            if A[i][2] != 0:
                    if H != A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y):
                        Flag = False
                        break
            else:
                if H > abs(A[i][0]-x)+abs(A[i][1]-y):
                    Flag = False
                    break
        if Flag == True:
            print(x, y, H)

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

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(1, N):
            if A[i][2] > 0:
                    if H != A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y):
                        Flag = False
                        break
            else:
                if H > abs(A[i][0]-x)+abs(A[i][1]-y):
                    Flag = False
                    break
        if Flag == True:
            print(x, y, H)

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

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

def height(i, j, xn, yn, hn):
    return abs(j - xn) + abs(i - yn) + hn

def check(i, j, x, y, h, H):
    N = len(x)
    for n in range(N):
        if h[n] > 0:
            if height(i, j, x[n], y[n], h[n]) != H:
                return False
        else:
            if H - abs(j - x[n]) - abs(i - y[n]) > 0:
                return False
    return True


ok = False
for i in range(101):
    for j in range(101):
        for n in range(N):
            if h[n] > 0:
                H = height(i, j, x[n], y[n], h[n])
                ok = check(i, j, x, y, h, H)
                break
            if ok:
                break
        if ok:
            break
    if ok:
        break

print(j, i, H)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
xyh = []
for _ in range(n):
    xyh.append(LIST())
for x in range(0, 101):
    for y in range(0, 101):
        h = -1
        flag = True
        tmp = []
        for i in range(n):
            clc = abs(x - xyh[i][0]) + abs(y - xyh[i][1])
            if xyh[i][2] == 0:
                tmp.append(xyh[i][:2])
                continue
            if xyh[i][2] + clc == h or h == -1:
                h = xyh[i][2] + clc
            else:
                flag = False
                break
        if flag and h > 0:
            for i in tmp:
                clc = abs(x - i[0]) + abs(y - i[1])
                if h - clc > 0:
                    flag = False
            if flag:
                print(x, y, h)
                exit()

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

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

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        elif H-abs(X-x[n])-abs(Y-y[n])>0:
            return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            if h[n]>0:
                H = height(X,Y,x[n],y[n],h[n])
                if check(x,y,h,X,Y,H) is True:
                    print(X,Y,H)
                    exit()

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

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

def height(i, j, xn, yn, hn):
    return abs(j - xn) + abs(i - yn) + hn

def check(i, j, x, y, h, H):
    N = len(x)
    for n in range(N):
        if h[n] > 0:
            if height(i, j, x[n], y[n], h[n]) != H:
                return False
        else:
            if H - abs(j - x[n]) - abs(i - y[n]) > 0:
                return False
    return True


ok = False
for i in range(101):
    for j in range(101):
        for n in range(N):
            if h[n] > 0:
                H = height(i, j, x[n], y[n], h[n])
                ok = check(i, j, x, y, h, H)
                break
            if ok:
                break
        if ok:
            break
    if ok:
        break

print(j, i, H)

Solution (Python):
import sys

input = sys.stdin.readline

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):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1, N):
            x, y, h = xyh[i]
            if h > 0:
                if H != h + abs(x - cx) + abs(y - cy):
                    flag = False
                    break
            else:
                if H > abs(x - cx) + abs(y - cy):
                    flag = False
                    break
        if flag:
            ans = [cx, cy, H]
            print(*ans)
            exit()

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

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,h))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)

Solution (Python):
n = int(input())
data = []
for i in range(n):
    xi,yi,hi = map(int,input().split())
    data.append((xi,yi,hi))
lst = [[] for _ in range(n)]
data.sort(key = lambda x:x[2],reverse = True)
x,y,h = data[0]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(1,n):
    xi,yi,hi = data[i]
    if hi > 0:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi)+hi == h:
                lst[i].append((x,y,h))
    else:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi) >= h:
                lst[i].append((x,y,h))
print(*lst[n-1][0])

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

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


for c_x in range(101):
  for c_y in range(101):
    sign = 0
    judge = base[0][2] + abs(base[0][0] - c_x) + abs(base[0][1] - c_y)
    for i in range(1,n):
      x = base[i][0]
      y = base[i][1]
      h = base[i][2]
      
      if h > 0:
        learge_h = h + abs(x - c_x) + abs(y - c_y)
        if learge_h != judge:
          sign = 1
          break
      elif h == 0:
        if judge > abs(x - c_x) + abs(y - c_y):
          sign = 1
          break
          
    if sign == 0:
      break
      
  if sign == 0:
    break
    
print(c_x,c_y,judge)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

    for cx in range(101):
        for cy in range(101):
            for higth in range(a, a+300):
                for i in range(n):
                    if h[i] > 0:
                        if h[i] != (higth-abs(x[i]-cx)-abs(y[i]-cy)):
                            break
                    else:
                        if 0 < (higth-abs(x[i]-cx)-abs(y[i]-cy)):
                            break
                else:
                    print(cx, cy, higth)
                    exit()

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby
    
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

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

    for cx in range(101):
        for cy in range(101):
            for higth in range(a, a+300):
                for i in range(n):
                    if h[i] > 0:
                        if h[i] != (higth-abs(x[i]-cx)-abs(y[i]-cy)):
                            break
                    else:
                        if 0 < (higth-abs(x[i]-cx)-abs(y[i]-cy)):
                            break
                else:
                    print(cx, cy, higth)
                    exit()

if __name__ == '__main__':
    main()

Solution (Python):
'''
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
'''
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n = int(readline())
  xyh = list(list(map(int, readline().split()))for _ in range(n))
  xyh.sort(key=lambda x:x[2], reverse=True)
  for cx in range(101):
    for cy in range(101):
      H = abs(xyh[0][0]-cx) + abs(xyh[0][1]-cy) + xyh[0][2]
      for i in range(n):
        if xyh[i][2] > 0:
          if abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy) + xyh[i][2] != H:
            break
        else:
          if abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy) < H:
            break
      else:
        print(cx, cy, H)
        sys.exit()
  
  
  
  
  
if __name__ == '__main__':
  main()

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




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

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,h))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)

Solution (Python):

N = int(input().strip())
xyh = [[int(str) for str in input().strip().split()] for _ in range(N)]

def f(x, y, cx, cy, H):
    return max(H - abs(x - cx) - abs(y - cy), 0)

def check(cx, cy, H):
    return all([f(x, y, cx, cy, H) == h for x, y, h in xyh])

for cx in range(101):
    for cy in range(101):
        hs = [h + abs(x - cx) + abs(y - cy) for x, y, h in xyh if h != 0]
        if len(set(hs)) == 1 and check(cx, cy, hs[0]):
            print(cx, cy, hs[0])

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

"""
方針：0<=cx,cy<=100なのでcx,cyの特定は全数探索で間に合う
(cx,cy)があっていればh+(abs(cx-x)+abs(cy-y))=const
"""

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

for cx in range(101):
	for cy in range(101):
		H = xyh[0][2] + (abs(cx-xyh[0][0]) + abs(cy-xyh[0][1]))
		correct_center = True
		for i in range(N):
			if max(H-(abs(cx-xyh[i][0]) + abs(cy-xyh[i][1])),0) != xyh[i][2]:
				correct_center = False
				break
		if correct_center:
			break
	if correct_center:
		break

print(cx,cy,H)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    for Cx in range(101):
        for Cy in range(101):
            H = INF
            for i in range(N):
                if h[i] > 0:
                    H = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)

            flg = True
            for i in range(N):
                if max(H - abs(x[i]-Cx) - abs(y[i]-Cy), 0) != h[i]:
                    flg = False
                    break
            if flg:
                print(" ".join([str(Cx), str(Cy), str(H)]))
                return


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from itertools import product

    n, *xyh = map(int, open(0).read().split())
    a = range(101)

    if n - xyh[2::3].count(0) == 1:
        i = xyh[2::3].index(1)
        print(xyh[3*i], xyh[3*i+1], xyh[3*i+2])
        return
    a = range(101)
    for x, y in product(a, a):
        l = None
        for i, j, h in zip(*[iter(xyh)] * 3):
            if h == 0:
                continue
            ll = h + abs(x - i) + abs(y - j)
            if l:
                if ll != l:
                    break
            else:
                l = ll
        else:
            print(x, y, l)
            return


if __name__ == '__main__':
    main()

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
xyh = [LI() for _ in range(n)]
lst = []
for cx in range(101):
    for cy in range(101):
        for x,y,h in xyh:
            X,Y = abs(cx-x), abs(cy-y)
            if h == 0:
                lst.append([X+Y,cx,cy,1])
            else:
                lst.append([X+Y+h,cx,cy,0])

max_h = 0
for a,b,c,d in lst:
    if d:
        max_h = max(max_h, a)
    else:
        for x,y,h in xyh:
            if max(a - abs(x-b) - abs(y-c),0) != h:
                break
        else:
            print(b,c,a)
            quit()
for cx in range(101):
    for cy in range(101):
        for H in range(1,max_h+1):
            for x,y,h in xyh:
                if max(H - abs(x-cx) - abs(y-cy),0) != h:
                    break
            else:
                print(cx,cy,H)
                quit()

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
t = []
for i in range(n):
    t.append(inl())
for i in range(n):
    if t[i][2]>0:
        k = i
        break
for cx in range(101):
    for cy in range(101):
        h = t[k][2]+abs(t[k][0]-cx)+abs(t[k][1]-cy)
        ok = True
        for i in range(n):
            if t[i][2] != max(0,h-abs(t[i][0]-cx)-abs(t[i][1]-cy)):
                ok = False
                break
        if ok:
            print("{} {} {}".format(cx,cy,h))
            exit()

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

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

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

def readlines(n):
    for _ in range(n):
        x, y, h = map(int, input().split())
        yield x, y, h

def h_check(lines, cx, cy):
    for x, y, h in lines:
        if h > 0:
            yield h + abs(x - cx) + abs(y - cy)

def match(cx, cy, H, lines):
    for x, y, h in lines:
        yield max(H - abs(x - cx) - abs(y - cy), 0) == h

def main():
    n = int(input())
    lines = list(readlines(n))
    for cx in range(101):
        for cy in range(101):
            res = set(h_check(lines, cx, cy))
            if len(res) == 1:
                H = res.pop()
                if all(match(cx, cy, H, lines)):
                    print(cx, cy, H)
                    return

main()

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

def func():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh if el[2]!=0]
            if H[0]>=1 and len(set(H))==1:
                temp=[H[0]-abs(el[0]-Cx)-abs(el[1]-Cy) for el in xyh if el[2]==0]
                for el in temp:
                    if el>0:
                        break
                else:
                    print(Cx, Cy, H[0])
                    return None
func()

Solution (Python):
n = int(input())
query = []
query0 = []
for i in range(n):
    x, y, h = map(int, input().split())
    if h > 0:
        query.append([x, y, h])
    else:
        query0.append([x, y, h])

for cx in range(101):
    for cy in range(101):
        res = []
        for i in range(len(query)):
            x, y, h = query[i]
            p = abs(x - cx) + abs(y - cy)
            H = h + p
            if h != 0:
                res.append(H)

        if len(set(res)) == 1:
            H = res[0]
            for j in range(len(query0)):
                x0, y0, _ = query0[j]
                if 0 < H - abs(x0 - cx) - abs(y0 - cy):
                    break
            else:
                print(cx, cy, H)
                exit()

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

cnt = 0
for x, y, h in query:
    if h == 0:
        cnt += 1
    else:
        res = [x, y, 1]

if n - cnt == 1:
    print(*res)
else:
    for cx in range(101):
        for cy in range(101):
            res = []
            for i in range(n):
                x, y, h = query[i]
                p = abs(x - cx) + abs(y - cy)
                H = h + p
                if h != 0:
                    res.append(H)

            if len(set(res)) == 1:
                print(cx, cy, res[0])
                exit()

Solution (Python):
import math
import collections
from operator import mul
from functools import reduce
import bisect

b=[]
def test(a):
    if len(a)>=8:
        b.append(a+"3")
        b.append(a+"5")
        b.append(a+"7")
    else:
        b.append(a+"3")
        b.append(a+"5")
        b.append(a+"7")
        test(a+"3")
        test(a+"5")
        test(a+"7")



n=int(input())
m=[(0,0,0)]*n
for i in range(n):
    m[i]=tuple(map(int,input().split()))

for x in range(101):
    for y in range(101):
        h=-1
        flag=0
        err=0
        for mi in m:
            hh=abs(mi[0]-x)+abs(mi[1]-y)
            if  mi[2]==0:
                if flag==0:
                    h=-hh
                    flag=1
                elif flag==1:
                    h=-min(abs(h),hh)
                else:
                    if h>hh:
                        err=1
                        break
            else:
                if flag==0:
                    h=mi[2]+hh
                    flag=2
                elif flag==1:
                    if abs(h)>=mi[2]+hh:
                        flag=2
                        h=mi[2]+hh
                    else:
                        err=1
                        break
                else:
                    if mi[2]+hh!=h:
                        err=1
                        break
        if err==0:
            print (x,y,h)
            exit()

Solution (Python):
n=int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]
def dis(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])
for i in range(101):
  for j in range(101):
    for k in range(n):
      if xyh[k][2]!=0:
        kari=dis(xyh[k],(i,j))+xyh[k][2]
        break
    f=1
    for k in range(n):
      if xyh[k][2]!=max(kari-dis(xyh[k],(i,j)),0):
        f=0
        break
    if f:
      print(i,j,kari)
      exit()

Solution (Python):
N=int(input())
d=[]
d0=[]
d1=[]
for i in range(N):
  d.append(list(map(int,input().split())))
for i in range(N):
  if d[i][2]==0:
    d0.append(d[i])
  else:
    d1.append(d[i])
cx=0
cy=0
for x in range(101):
  for y in range(101):
    H=d1[0][2]+abs(x-d1[0][0])+abs(y-d1[0][1])
    c=0
    for i in range(len(d1)):
      if max((H-abs(x-d1[i][0])-abs(y-d1[i][1])),0)==d1[i][2]:
        c+=1
    if c==len(d1):
      cx=x
      cy=y
      cnt=0
      for j in range(len(d0)):
        if max((H-abs(x-d0[j][0])-abs(y-d0[j][1])),0)==0:
          cnt+=1
      if cnt==len(d0):
        ans=[cx,cy,H]
  else:
    continue
  break
for i in range(len(ans)):
  print(ans[i],end=' ')

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

for i in range(n):
    x.append(xyh[i][0])
    y.append(xyh[i][1])
    h.append(xyh[i][2])



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