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())
HXY = []
for i in range(N):
    x,y,h = map(int, input().split())
    HXY.append((h,x,y))



HXY.sort(reverse=True)

for cx in range(101):
    for cy in range(101):
        H = HXY[0][0] + abs(HXY[0][1] - cx) + abs(HXY[0][2] - cy)
        is_valid = True
        for h,x,y in HXY:
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                is_valid = False
                break
        if is_valid:
            print(cx, cy, H)
            exit()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n = I()
XYH = TIR(n)
XYH.sort(key=itemgetter(2), reverse=True)
H = INF
CX = INF
CY = INF
for cx in range(100+1):
    for cy in range(100+1):
        tmp = INF
        for x, y, h in XYH:
            if tmp == INF:
                tmp = h+abs(x-cx)+abs(y-cy)
            elif h != max(tmp - abs(x-cx) - abs(y-cy), 0):
                break
        else:
            H = tmp
            CX = cx
            CY = cy
print("{} {} {}".format(CX, CY, H))

Solution (Python):
N=int(input())
lst=[0 for f in range(N)]
for i in range(N):
 lst[i]= list(map(int,input().split()))
lst.sort(key=lambda x: x[2], reverse=True)
for i in range(101):
 for j in range(101):
  h=abs(i-lst[0][0])+abs(j-lst[0][1])+lst[0][2]
  if h==10**9 and N==1:
   ans=[lst[0][0],lst[0][1],lst[0][2]]
  else:
   t=0
   for k in range(N-1):
    if max(h-abs(i-lst[k+1][0])-abs(j-lst[k+1][1]),0)==lst[k+1][2]:
     t+=1
   if t==N-1:
    ans=[i,j,h]
print(*ans)

Solution (Python):
N=int(input())
lst=[0 for f in range(N)]
for i in range(N):
 lst[i]= list(map(int,input().split()))
lst.sort(key=lambda x: x[2], reverse=True)
for i in range(101):
 for j in range(101):
  h=abs(i-lst[0][0])+abs(j-lst[0][1])+lst[0][2]
  if h==10**9 and N==1:
   ans=[lst[0][0],lst[0][1],lst[0][2]]
  else:
   t=0
   for k in range(N-1):
    if max(h-abs(i-lst[k+1][0])-abs(j-lst[k+1][1]),0)==lst[k+1][2]:
     t+=1
   if t==N-1:
    ans=[i,j,h]
print(*ans)

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

for i in range(N):
    p = list(map(int,input().split()))
    lp.append(p)

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


def check(cx,cy, lp):
    is_center = True
    ch = lp[0][2] + abs(cx - lp[0][0]) + abs(cy - lp[0][1])
    for p in lp[1:]:
        x,y,h = p
        if h:
            chp = h + abs(cx - x) + abs(cy - y)
            if ch != chp:
                is_center = False
                break
        else:
            if (ch-abs(cx - x) - abs(cy-y)) > 0:
                is_center = False
                break

    return is_center, ch


if N == 1:
    print(p)
else:
    for i in range(101):
        for j in range(101):
            is_center, h = check(i,j, lp)
            if is_center:
                print(i,j,h)

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[]
for i in range(n):
    lis.append(LI())
lis.sort(key=lambda x:x[2],reverse=True)
x1,y1,h1,x2,y2,h2=lis[0][0],lis[0][1],lis[0][2],lis[1][0],lis[1][1],lis[1][2]
cand=[]
    
for i in range(101):
    for j in range(101):
        H=h1+abs(i-x1)+abs(j-y1)
        cand.append([i,j,H])


candx=[]
for j in range(len(cand)):
    H=cand[j][2]
    count=0
    
    for i in range(1,n):
        if max(H-abs(cand[j][0]-lis[i][0])-abs(cand[j][1]-lis[i][1]),0)==lis[i][2]:
            count+=1
    
    if count==n-1:
        candx.append([cand[j][0],cand[j][1],H])
print(*candx[0])
'''for li in candx:
    flag=True
    for i in range(n):
        if lis[i][2]<0:
            if -abs(li[0]-lis[i][0])-abs(li[1]-lis[i][1])+li[2]>=0:
                flag=False
    if flag==True:
        print(*li)
        sys.exit()'''

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

TABLES = []
H = []
for _ in range(n):
    x, y, h = map(int, input().split())
    TABLE = [[0] * 101 for _ in range(101)]
    for i in range(101):
        for j in range(101):
            TABLE[i][j] = h + abs(x - i) + abs(y - j)
    TABLES.append(TABLE)
    H.append(h)

for k in range(n):
    if H[k] != 0:
        a = k
        break

for i in range(101):
    for j in range(101):
        temp = TABLES[a][i][j]
        flag = True
        for k in range(n):
            if H[k] == 0:
                if TABLES[k][i][j] < temp:
                    flag = False
                    break
            else:
                if TABLES[k][i][j] != temp:
                    flag = False
                    break
        if flag:
            print(i, j, temp)
            exit()

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

for x in range(101):
    for y in range(101):
        hmax = 0
        for item in xyh:
            if item[2] > 0:
                hmax = item[2] + abs(x - item[0]) + abs(y - item[1])
                break
        is_ok = True
        for item in xyh:
            if max(0, hmax - abs(x - item[0]) - abs(y - item[1])) != item[2]:
                is_ok = False
        if is_ok:
            print(x, y, hmax)
            exit()

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

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

for i in range(101):
  for j in range(101):
    ans=[]
    for k in t:
      d = abs(k[0]-i)+ abs(k[1]-j)
      h_tmp = d + k[2]
      if ans==[]:
        ans.append(k+[d,h_tmp])
      else:
        if d>ans[-1][-1] and k[2]==0:
          pass
        else:
          if h_tmp!=ans[-1][-1]:
            break
    else:
      print(i,j,ans[-1][-1])
      exit()

Solution (Python):
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort(key=lambda x:x[2],reverse=True)
def cal(y,x,datum,height):
  return max(height-(abs(y-datum[1])+abs(x-datum[0])),0)==datum[2]
for i in range(101):
  for j in range(101):
    height=abs(i-data[0][1])+abs(j-data[0][0])+data[0][2]
    flag=0
    for k in data[1:]:
      if not cal(i,j,k,height):
        flag=1
        break
    if flag:pass
    else:print(j,i,height);exit()

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
a=[]
for x in range(101):
  for y in range(101):
    c=[]
    for t in l:
      if t[2]:
        c.append(t[2]+abs(x-t[0])+abs(y-t[1]))
    f=0
    if len(set(c))==1:
      f=1
      h=c[0]
      for t in l:
        if t[2]==0:
          if h-abs(x-t[0])-abs(y-t[1])>0:
            f=0
    if f:
      print(x,y,h)
      exit()

Solution (Python):
from operator import itemgetter
n=int(input())
XYH=[tuple(map(int,input().split())) for i in range(n)]
XYH.sort(key=itemgetter(2),reverse=True)
for cy in range(101):
    for cx in range(101):
        hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
        for x,y,h in XYH[1:]:
            if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                break
        else:
            print(cx,cy,hc)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n=int(input())
    XYH=[tuple(map(int,input().split())) for i in range(n)]
    XYH.sort(key=itemgetter(2),reverse=True)
    for cy in range(101):
        for cx in range(101):
            hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
            for x,y,h in XYH[1:]:
                if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                    break
            else:
                print(cx,cy,hc)
                sys.exit()

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n=int(input())
    XYH=[tuple(map(int,input().split())) for i in range(n)]
    XYH.sort(key=itemgetter(2),reverse=True)
    for cy in range(101):
        for cx in range(101):
            hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
            for x,y,h in XYH:
                if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                    break
            else:
                print(cx,cy,hc)
                sys.exit()

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from operator import itemgetter
def main():
    n=int(input())
    XYH=[tuple(map(int,input().split())) for i in range(n)]
    XYH.sort(key=itemgetter(2),reverse=True)
    for cy in range(101):
        for cx in range(101):
            hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
            for x,y,h in XYH:
                if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                    break
            else:
                print(cx,cy,hc)
                sys.exit()

if __name__=='__main__':
    main()

Solution (Python):
n = int(input())
z = [[0] * 101 for _ in range(101)]
xyh = [tuple(map(int, input().split())) for _ in range(n)]
xyh = sorted(xyh, key=lambda x: x[2], reverse=True)

for xi in range(101):
    for yi in range(101):
        hi = 0
        allok = True
        for i in range(n):
            x,y,h = xyh[i]
            if i == 0:
                hi = abs(xi - x) + abs(yi - y) + h
            if max(hi - abs(xi - x) - abs(yi - y), 0) != h:
                allok = False
        if allok:
            print(xi, yi, hi)
            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 cx in range(101):
    for cy in range(101):
        c = (cx, cy)
        count = 0
        H = 0
        for x, y, h in xyh:
            if count == 0:
                H = h+abs(x-cx)+abs(y-cy)
                count = 1
            else:
                if h != max(H-abs(x-cx)-abs(y-cy), 0):
                    break
        else:
            ans = [cx, cy, H]
            print(*ans)

Solution (Python):
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int,input().split())))
H = []
for cx in range(0,101):
    for cy in range(0,101):
        hantei = False
        for i in range(n):
            if xyh[i][2] > 0:
                if not H:
                    H.append(xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]))
                else:
                    hantei = True
                    if xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]) != H[0]:
                        H.pop(0)
                        break
        else:
            if hantei: 
                print(cx,cy,H[0])
                exit()
else:
    mx = 0
    for i in range(n):
        if mx < xyh[i][2]:
            ansind = i
            mx = xyh[i][2]
    print(xyh[ansind][0],xyh[ansind][1],xyh[ansind][2])

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

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

for cx in range(101):
    for cy in range(101):
        x, y, h = Point[0]
        H = h + abs(x-cx) + abs(y-cy)
        flag = True
        for i in range(1,N):
            nx, ny, nh = Point[i]
            if max(H - abs(nx-cx) - abs(ny-cy),0) != nh:
                flag = False
                break
        if flag:
            print(cx, end=' ')
            print(cy, end=' ')
            print(H, end=' ')
            exit()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    for cx in range(101):
        for cy in range(101):
            i = 0
            while True:
                x, y, h = xyh[i]
                if h == 0:
                    i += 1
                    continue
                else:
                    H = h + abs(x - cx) + abs(y - cy)
                    break

            for x, y, h in xyh:
                tmp = max(H - abs(x - cx) - abs(y - cy), 0)
                if tmp == h:
                    continue
                else:
                    break
            else:
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

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

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


for cx in range(101):
    for cy in range(101):
        for xyh in XYH:
            if xyh[2] > 0:
                H = abs(cx - xyh[0]) + abs(cy - xyh[1]) + xyh[2]
                break
        for xyh in XYH:
            _x, _y, _h = xyh
            if _h == max(0, H - abs(cx-_x) - abs(cy-_y)):
                continue
            break
        else:
            print(cx, cy, H)
            sys.exit(0)

Solution (Python):
def search_center(xyh_list):
    xyh_list.sort(key=lambda r: r[2], reverse=True)
    highest = xyh_list[0]
    for cx in range(101):
        for cy in range(101):
            h = highest[2] + abs(highest[0] - cx) + abs(highest[1] - cy)
            matched = True
            for xyh in xyh_list[1:]:
                if xyh[2] == 0:
                    if h - abs(xyh[0] - cx) - abs(xyh[1] - cy) > 0:
                        matched = False
                        break
                else:
                    hh = xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy)
                    if h != hh:
                        matched = False
                        break
            if matched:
                return cx, cy, h
    return None


def main():
    N = int(input())
    xyh_list = [list(map(int, input().split(' '))) for _ in range(N)]
    xyh_list.sort(key=lambda r: r[2], reverse=True)
    cx, cy, ph = search_center(xyh_list)
    print('{} {} {}'.format(cx, cy, ph))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True




def warshall_floyd(d, n):
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d



def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)






def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

for cx in range(0, 101):
    for cy in range(0, 101):
        ok = True
        H = None
        under = INF
        for i in range(n):
            if h[i] == 0:
                under = min(under, abs(x[i] - cx) + abs(y[i] - cy))
            else:
                H2 = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                
                    
                if H2 < 1:
                    ok = False
                    break
                if H == None:
                    H = H2
                    continue
                elif H != H2:
                    
                        
                    ok = False
                    break
        if H > under:
            ok = False
        if ok:
            print(cx, cy, H)
            sys.exit()

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for m in info:
            x, y, h = m[0], m[1], m[2]
            if h > 0:
                H = f(x, y, c_x, c_y) + h
                d.append(H)
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))
        else:
            d = list(set(d))
            if len(d) == 1 and 1 <= d[-1] and d[-1] <= h_max:
                print(c_x, c_y, d[-1])
                exit()

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]




N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 1
        right = float('inf')
        for i in range(N):
            
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            
            if xyh[i][2] > 0:
                if not(left <= tmp <= right):
                    flag = 1
                    break
                left = right = tmp
            else:
                if tmp < 1 or left > tmp:
                    flag = 1
                    break
                right = min(right, tmp)
        if not flag:
            print(c_x, c_y, right)
            exit()

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

for cx in range(101):
    for cy in range(101):
        candidate_h = info[0][2] + abs(info[0][0] - cx) + abs(info[0][1] - cy)
        for i in range(1, N):
            x, y, h = info[i]
            if max(candidate_h - abs(x - cx) - abs(y - cy), 0) != h:
                break
        else:
            print("{} {} {}".format(cx, cy, candidate_h))
            exit()

Solution (Python):
from sys import exit

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

n=int(input())			
xyh=[0]*n

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

for cx in range(101):
	for cy in range(101):
		H=ht(cx,cy,xyh[0][0],xyh[0][1],xyh[0][2])
		for i in range(1,n):
			if max(H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:			
				break
			
		else:			
			print(cx,cy,H)
			exit()

Solution (Python):


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


for i in range(101):
	for j in range(101):
		H = -1
		Hmax = 2 * 10 ** 9
		success = True
		for k in range(n):
			d = abs(i - x[k]) + abs(j - y[k])
			if h[k] > 0:
				H2 = h[k] + d
				if H > 0 and H != H2:
					success = False
					break
				else:
					H = H2
			else: 
				Hmax = min(Hmax, d)
		
		if success and H <= Hmax:
			print(i, j, H)
			exit()

Solution (Python):
def height(a, b, x, y, h):
	return h + abs(a - x) + abs(b - y)

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], reverse=True)

for i in range(101):
	for j in range(101):
		H = height(i, j, P[0][0], P[0][1], P[0][2])
		for k in range(1, n):
			if max(H - abs(P[k][0] - i) - abs(P[k][1] - j), 0) != P[k][2]:
				break
		else:
			print(i, j, H)
			exit()

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

for i in range(0,101):
  for j in range(0,101):
    temp=0
    onezero=1
    for k in range(0,n):
      k=n-k-1
      xhoukou=abs(i-lis[k][1])
      yhoukou=abs(j-lis[k][2])
      hhoukou=lis[k][0]
      if hhoukou>0:
        keep=xhoukou+yhoukou+hhoukou
        if temp==0:
          temp=keep
        else:
          if keep!=temp:
            onezero=0
      else:
        if xhoukou+yhoukou<temp:
          onezero=0
    if onezero==1:
      print(i,j,temp)

Solution (Python):
from itertools import product
n, *XYH = map(int, open(0).read().split())
for cx, cy in product(range(101), repeat=2):
    B, C = set(), set()
    for x, y, h in zip(XYH[::3], XYH[1::3], XYH[2::3]):
        s = h + abs(x-cx) + abs(y-cy)
        if h:
            C.add(s)
        else:
            B.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            print(cx, cy, h)
            exit()

Solution (Python):
from itertools import product
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        h = C.pop()
        if all(h <= b for b in B):
            A.append((cx, cy, h))
print(*A.pop())

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

XYH = []
for _ in range(N):
    x, y, h = map(int, input().split())
    XYH.append((x, y, h))
XYH.sort(key=lambda x: -x[2])

for Cx in range(0, 101):
    for Cy in range(0, 101):
        flg = True

        Ch = XYH[0][2]+abs(XYH[0][0]-Cx)+abs(XYH[0][1]-Cy)

        for x, y, h in XYH:
            if h != max(Ch - abs(x-Cx) - abs(y-Cy), 0):
                flg = False

        if flg:
            print(Cx, Cy, Ch)
            exit()

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

XYH = []
for _ in range(N):
    x, y, h = map(int, input().split())
    XYH.append((x, y, h))
XYH.sort(key=lambda x: -x[2])

for Cx in range(0, 101):
    for Cy in range(0, 101):
        flg = True

        if XYH[0][2] == 0:
            Ch = 1
        else:
            Ch = XYH[0][2]+abs(XYH[0][0]-Cx)+abs(XYH[0][1]-Cy)

        for x, y, h in XYH:
            if h != max(Ch - abs(x-Cx) - abs(y-Cy), 0):
                flg = False

        if flg:
            print(Cx, Cy, Ch)
            exit()

Solution (Python):
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
x0,y0,h0=0,0,0
for x,y,h in xyh:
  if h>0:
    x0,y0,h0=x,y,h
    break

for cx in range(101):
  for cy in range(101):
    h=h0+abs(cx-x0)+abs(cy-y0)
    flg=True
    for xi,yi,hi in xyh:
      if hi!=max(h-abs(cx-xi)-abs(cy-yi),0):
        flg=False
    if flg:
      print(cx,cy,h)

Solution (Python):
import sys
import bisect

inf = 10**15
mod = 10**9+7

def getH(Cx, Cy, x, y, h):
    return h + abs(x-Cx) + abs(y-Cy)

inf = 10**15
mod = 10**9+7
n = int(input())
Hinfo = [list(map(int, input().split())) for i in range(n)]
H = -1
Hmax = inf
for Cx in range(101):
    for Cy in range(101):
        H = -1
        flag = True
        for tmp in Hinfo:
            x,y,h = tmp
            if h == 0:
                Hmax = getH(Cx, Cy, x, y, h)
            else:
                canH = getH(Cx, Cy, x, y, h)
                if H > 0:
                    if H != canH:
                        flag = False
                        break
                else:
                    H = canH
            if Hmax < H:
                flag = False
                break
        if Hmax >= H and flag:
            print('{} {} {}'.format(Cx, Cy, H))
            sys.exit()

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

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

hxy.sort()

for cx in range(101):
    for cy in range(101):
        flag=0
        temp=hxy[-1]
        H=temp[0]+abs(temp[1]-cx)+abs(temp[2]-cy)

        for item in hxy:
            h=item[0]
            x=item[1]
            y=item[2]
            if h!=max(H-abs(x-cx)-abs(y-cy),0):
                flag=1
                break
        
        if flag==0:
            print(cx,cy,H)
            exit()

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

for Cx in range(101):
	for Cy in range(101):

		for x,y,h in xyh:
			if h == 0:
				continue

			H = h + abs(x - Cx) + abs(y - Cy)
			break
		ok = True
		for x,y,h in xyh:
			if max(H - abs(x - Cx) -abs(y - Cy), 0) != h:
				ok = False
				break
		if ok:
			print("{} {} {}".format(Cx, Cy, H))
			sys.exit(0)

Solution (Python):
N = int(input())
data = [tuple(map(int, input().split())) for _ in range(N)]
data.sort(key=lambda x: -x[2])
for cx in range(101):
    for cy in range(101):
        h0 = None
        for x, y, h in data:
            if h:
                h_tmp = h + abs(cx - x) + abs(cy - y)
                if h_tmp != h0 and h0 is not None:
                    break
                h0 = h_tmp
            else:
                if abs(cx - x) + abs(cy - y) < h0:
                    break
        else:
            print(cx, cy, h0)
            exit()

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

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        
        
        for x0, y0, h0 in XYH[0:]:
            prob_H = h0 + abs(x0-cx) + abs(y0-cy)
            if h0 == 0:
                continue
            break
        for xi, yi, hi in XYH[0:]:
            if max(prob_H - abs(xi-cx) - abs(yi-cy),0) == hi:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue

        print(cx,cy,prob_H)
        quit()