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())
exprs = []

for _ in range(n):
    exprs.append([int(i) for i in input().split()])

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

for cx in range(0, 101):
    for cy in range(0, 101):
        x0, y0, h0 = exprs[0]
        ch = h0 + abs(x0 - cx) + abs(y0 - cy)
        for x, y, h in exprs[1:]:
            if h != max(ch - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            print(cx, cy, ch)
            quit()

Solution (Python):
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        
        
        
        
        

def judge(id, sho, n):
    hito = [0]
    for i in range(n):
        if id % 2 == 1:
            hito.append(1)
        else:
            hito.append(0)
        id //= 2

    for i, h in enumerate(hito):
        if i == 0:
            continue
        if h == 1:
            for x, y in sho[i-1]:
                if hito[x] != y:
                    return -1

    return sum(hito)


def solve():
    n = getN()
    q = []
    for i in range(n):
        q.append(getList())

    q.sort(key=lambda x: -x[2])
    for i in range(0, 101):
        for j in range(0, 101):
            ch = -1
            ok = True
            
            for x, y, h in q:
                ins = h + abs(x-i) + abs(y-j)
                if ch == -1:
                    ch = ins
                else:
                    if ch != ins:
                        if h != 0:
                            ok = False
                            break
                        if h == 0 and ins < ch:
                            ok = False
                            break
            if ok:
                print(i, j, ch)
                return



def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
import sys

n=int(input())
xyh=[[] for i in range(n)]
for i in range(n):
    x,y,h=map(int,input().split())
    xyh[i].append(x)
    xyh[i].append(y)
    xyh[i].append(h)
for i in range(101):
    for j in range(101):
        f=0
        dis=[[i] for i in range(205)]
        for q in range(n):
            x=xyh[q][0]
            y=xyh[q][1]
            h=xyh[q][2]
            d=abs(x-i)+abs(y-j)
            
            if len(dis[d])==1:
                dis[d].append(h)
            elif len(dis[d])!=1 and dis[d][1]!=h:
                f=1
        
        dis=[dis[e] for e in range(205) if len(dis[e])!=1]
        m=len(dis)
        if m==1 and f==0:
            print(i,j,dis[0][0]+dis[0][1])
            sys.exit()
            
        else:
            if all(dis[e][0]+dis[e][1]==dis[e+1][0]+dis[e+1][1] for e in range(m-1) if dis[e+1][1]!=0) and f==0:
                print(i,j,dis[0][0]+dis[0][1])
                sys.exit()

Solution (Python):
import sys

n=int(input())
xyh=[[] for i in range(n)]
for i in range(n):
    x,y,h=map(int,input().split())
    xyh[i].append(x)
    xyh[i].append(y)
    xyh[i].append(h)
for i in range(101):
    for j in range(101):
        f=0
        dis=[[i] for i in range(205)]
        for q in range(n):
            x=xyh[q][0]
            y=xyh[q][1]
            h=xyh[q][2]
            d=abs(x-i)+abs(y-j)
            
            if len(dis[d])==1:
                dis[d].append(h)
            elif len(dis[d])!=1 and dis[d][1]!=h:
                f=1
        
        dis=[dis[e] for e in range(205) if len(dis[e])!=1]
        m=len(dis)
        if m==1 and f==0:
            print(i,j,dis[0][0]+dis[0][1])
            sys.exit()
            
        else:
            if all(dis[e][0]+dis[e][1]==dis[e+1][0]+dis[e+1][1] for e in range(m-1) if dis[e+1][1]!=0) and f==0:
                print(i,j,dis[0][0]+dis[0][1])
                sys.exit()

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

check = False
    
for i in range(101):
    for j in range(101):
        b = 0
        while b < n:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = max(h - abs(i - a[b][0]) - abs(j - a[b][1]),0)
                if de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)

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

dp=[[-1 for i in range(101)] for j in range(101)]
for n in range(N):
    dp[xyh[n][0]][xyh[n][1]]=xyh[n][2]

def find_top(x,y,N,xyh):
    find=True
    prev=-1
    for n in range(N):
        if xyh[n][2]!=0:
            top=xyh[n][2]+abs(xyh[n][0]-x)+abs(xyh[n][1]-y)
            if prev==-1:
                prev=top
            else:
                if prev!=top:
                    find=False
                    break
    return find,top

def check_top(x,y,top,N,xyh):
    check=True
    for n in range(N):
        if xyh[n][2]==0:
            if top-abs(xyh[n][0]-x)-abs(xyh[n][1]-y)>0:
                check=False
                break
    return check

fin=False
for x in range(101):
    if fin==True:
        break
    for y in range(101):
        find=find_top(x,y,N,xyh)[0]
        height=find_top(x,y,N,xyh)[1]
        if find and height>=1 and check_top(x,y,height,N,xyh):
            print("{} {} {}".format(x,y,height))
            fin=True

Solution (Python):
import sys

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


for x, y, h in XYH:
    if h != 0:
        px, py, ph = x, y, h
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        
        H = ph + abs(cx - px) + abs(cy - py)

        for x, y, h in XYH:
            if max(H - abs(x - cx) - abs(y - cy), 0) != h:
                break
        else:
            print(cx, cy, H)
            sys.exit()

Solution (Python):


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

mh=max(h)
for cx in range(0,101):
  for cy in range(0,101):
    for H in range(mh,mh+216):
      if all(h[j]==max(H-abs(cx-x[j])-abs(cy-y[j]),0) for j in range(n)):
        print(cx,cy,H)
        exit()

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

mh=max(h)
for cx in range(0,101):
  for cy in range(0,101):
    for H in range(mh,mh+216):
      if all(h[j]==max(H-abs(cx-x[j])-abs(cy-y[j]),0) for j in range(n)):
        print(cx,cy,H)
        exit()

Solution (Python):


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

mh=max(h)
for cx in range(0,101):
  for cy in range(0,101):
    for H in range(mh,mh+216):
      if all(h[j]==max(H-abs(cx-x[j])-abs(cy-y[j]),0) for j in range(n)):
        print(cx,cy,H)
        exit()

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

mh=max(h)
for cx in range(0,101):
  for cy in range(0,101):
    for H in range(mh,mh+216):
      if all(h[j]==max(H-abs(cx-x[j])-abs(cy-y[j]),0) for j in range(n)):
        print(cx,cy,H)
        exit()

Solution (Python):
n=int(input())
x=[-1]*n
y=[-1]*n
h=[-1]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())
  
cnt=0
now=0
for i in range(n):
  if h[i]>0:
    cnt+=1
    now=i
if cnt==1:
  print(x[now],y[now],h[now])
  exit()

for cx in range(0,101):
  for cy in range(0,101):
    H=[]
    for i in range(n):
      if h[i]>0:
        H.append(h[i]+abs(cx-x[i])+abs(cy-y[i]))
    if len(set(H))==1:
      print(cx,cy,H[0])
      exit()

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

for i in range(101):
    for j in range(101):
        temp = -1
        for x, y, h in XYH:
            if h == 0:
                continue
            temp = h + abs(x - i) + abs(y - j)
            break
        flag = 0
        for x, y, h in XYH:
            kouho = temp - (abs(x - i) + abs(y - j)) - h
            if kouho == 0:
                continue
            elif h == 0 and kouho < 0:
                continue
            else:
                flag = 1
                break
        if not flag:
            print(i, j, temp)
            exit()

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)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        flag = True
        for k in range(1, n):
            if xyh[k][2] == 0:
                if abs(xyh[k][0] - i) + abs(xyh[k][1] - j) < h:
                    flag = False
                    break
            else:
                temp = xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j)
                if h != temp:
                    flag = False
                    break
        if flag == True and h >= 1:
            print(i, j, h)
            exit()

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)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        flag = True
        for k in range(1, n):
            if xyh[k][2] == 0:
                if abs(xyh[k][0] - i) + abs(xyh[k][1] - j) < h:
                    flag = False
                    break
            else:
                temp = xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j)
                if h != temp:
                    flag = False
                    break
        if flag == True and h >= 1:
            print(i, j, h)
            exit()

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)
for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        flag = True
        for k in range(1, n):
            if xyh[k][2] == 0:
                if abs(xyh[k][0] - i) + abs(xyh[k][1] - j) < h:
                    flag = False
                    break
            else:
                temp = xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j)
                if h != temp:
                    flag = False
                    break
        if flag == True and h >= 1:
            print(i, j, h)
            break
    if flag == True:
        break

Solution (Python):
from itertools import product


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

for cx, cy in product(range(101), repeat=2):
    x0, y0, h0 = xyh[0]
    ch = h0 + abs(x0 - cx) + abs(y0 - cy)
    for x, y, h in xyh:
        if h != max(ch - abs(x - cx) - abs(y - cy), 0):
            break
    else:
        print(cx, cy, ch)
        break

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

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

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

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

answerString = str(answer[0]) + " " + str(answer[1]) + " " + str(answer[2])
print(answerString)

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

Info = [[] for T in range(0,N)]
for I in range(0,N):
    Info[I] = [int(T) for T in input().split()]
Info = sorted(Info,reverse=True,key=lambda X:X[2])
for CX in range(0,101):
    for CY in range(0,101):
        Flag  = True
        BaseH = abs(Info[0][0]-CX)+abs(Info[0][1]-CY)+Info[0][2]
        for I in range(1,N):
            if max(BaseH-abs(Info[I][0]-CX)-abs(Info[I][1]-CY),0)!=Info[I][2]:
                Flag = False
                break
        if Flag:
            Ans = [str(CX),str(CY),str(BaseH)]
            break
    if Flag:
        break
print(' '.join(Ans))

Solution (Python):
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def is_consistent(cx, cy, X, Y, H, N):
    h_proposal = None
    max_h = math.inf
    for i in range(N):
        if H[i] > 0:
            if h_proposal is not None and h_proposal != H[i]+abs(X[i]-cx)+abs(Y[i]-cy):
                return None
            h_proposal = H[i]+abs(X[i]-cx)+abs(Y[i]-cy)
        else:
            max_h = min(max_h, abs(X[i]-cx)+abs(Y[i]-cy))
    if h_proposal is not None and h_proposal <= max_h:
        return cx, cy, h_proposal

def solve():
    N = read_int()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = read_ints()
        X.append(x)
        Y.append(y)
        H.append(h)
    
    for cx in range(101):
        for cy in range(101):
            answer = is_consistent(cx, cy, X, Y, H, N)
            if answer is not None:
                return answer


if __name__ == '__main__':
    print(*solve())

Solution (Python):
import sys
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  if xyh[i][2] != 0:
    cnt += 1
if cnt == 1:
  for i in range(n):
    if xyh[i][2] != 0:
      print(" ".join(list(map(str, xyh[i]))))
      sys.exit()
for i in range(101):
  for j in range(101):
    x = []
    for k in range(n):
      if xyh[k][2] != 0:
        x.append(abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2])
    if len(set(x)) == 1:
      print(i, j, x[0])

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

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

XYs = []
for _ in range(N):
  XYs.append(list(map(int, input().split())))
  
for i in range(101):
  for j in range(101):
    f = 1
    for k in range(N):
      if XYs[k][2] > 0:
        h = XYs[k][2] + abs(XYs[k][0]-i) + abs(XYs[k][1]-j)
        break
    for k in range(N):
      if max(h - abs(XYs[k][0]-i) - abs(XYs[k][1]-j), 0) != XYs[k][2]:
        f = 0
        break
    if f == 1:
      print(i,j,h)
      exit()

Solution (Python):
import sys

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

idx = 0
for i in range(N):
    if xyz[i][2] != 0:
        idx = i
        break

for cx in range(101):
    for cy in range(101):
        switch = 1
        H = xyz[idx][2] + abs(xyz[idx][0] - cx) + abs(xyz[idx][1] - cy)
        for x,y,h in xyz:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                switch = 0
                break
        if switch == 1:
            print(cx, cy, H)
            sys.exit()

Solution (Python):
import sys

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

idx = 0
for i in range(N):
    if xyz[i][2] != 0:
        idx = i
        break

for cx in range(101):
    for cy in range(101):
        switch = 1
        distance = abs(xyz[idx][0] - cx) + abs(xyz[idx][1] - cy)
        H = xyz[idx][2] + distance
        
        for x,y,h in xyz:
            karidis = abs(x - cx) + abs(y - cy)
            if h == 0 and distance <= karidis:
                continue
            kari = h + karidis
            if H != kari:
                switch = 0
                break
        if switch == 1:
            print(cx, cy, H)
            sys.exit()

Solution (Python):
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 = -1
        for i in range(n):
            if h[i] == 0:
                pass
            else:
                tmp = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
                H = tmp
                break
        flag = True
        for i in range(n):
            if h[i] != max(H-abs(x[i]-cx)-abs(y[i]-cy),0):
                flag = False
                break
        if flag:
            print(cx,cy,H)

Solution (Python):

import sys
n = int(input())
pyramid = []
ch = 1
for _ in range(n):
    x, y, h = map(int, input().split())
    pyramid.append((x, y, h))
    ch = max(ch, h)

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

while True:
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            for x, y, h in pyramid:
                if not cal(cx, cy, ch, x, y, h):
                    break
            else:
                print(cx, cy, ch)
                sys.exit()
    ch += 1

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

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

s_list.sort(key=lambda x: x[2])
s_list = list(reversed(s_list))

H = 0
flag = 0

for i in range(101):
    for j in range(101):
        flag = 0
        H = s_list[0][2] + abs(i-s_list[0][0]) + abs(j-s_list[0][1])
        for k in range(1,n):
            if s_list[k][2] != max(H - abs(s_list[k][0]-i) - abs(s_list[k][1]-j),0):
                flag = 1
                break
        if flag == 0:
            print(i,j,H)
            break

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


for x1, y1, h1 in XYH:
    if h1 > 0:
        for Cx in range(101):
            for Cy in range(101):
                H = h1 + abs(x1 - Cx) + abs(y1 - Cy)
                
                if all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x, y, h in XYH):
                  print(Cx, Cy, H)
                  exit()

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
x = [0]*n
y = [0]*n
h = [0]*n

for i in range(n):
    x[i], y[i], h[i] = MAP()

for i in range(101):
    for j in range(101):
        H = 0
        for k in range(n):
            if h[k] != 0:
                if H == 0 or H == h[k] + abs(x[k]-i) + abs(y[k]-j):
                    H = h[k] + abs(x[k]-i) + abs(y[k]-j)
                else:
                    break
        else:
            for k in range(n):
                if h[k] == 0:
                    if H - abs(x[k]-i) - abs(y[k]-j) <= 0:
                        continue
                    else:
                        break
            else:
                print(i,j,H)

Solution (Python):
N = int(input())
P = [list(map(int,input().split())) for n in range(N)]
x,y,h = list(filter(lambda x:x[2],P))[0]

for i in range(101):
  for j in range(101):
    H = h+abs(x-i)+abs(y-j)
    if all(max(H-abs(t[0]-i)-abs(t[1]-j),0)==t[2] for t in P):
      print(i,j,H)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    
    xyh_0 = []
    xyh_not0 = []
    for _ in range(N):
        xyh = LI()
        if xyh[2] == 0:
            xyh_0.append(xyh)
        else:
            xyh_not0.append(xyh)

    for cx, cy in itertools.product(range(101), range(101)):
        H = []
        for x, y, h in xyh_not0:
            H.append(h + abs(x - cx) + abs(y - cy))
        
        if len(set(H)) == 1:
            is_ok = True
            for x, y, h in xyh_0:
                if max(H[0] - abs(x - cx) - abs(y - cy), 0) != 0:
                    is_ok = False
            if is_ok:
                ans = (cx, cy, H[0])

    print(*ans)

if __name__ == '__main__':
    resolve()

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

xy = [[-1 for i in range(101)] for j in range(101)]

x = []
y = []
h = []
for i in range(n):
  xx, yy, hh = map(int, input().split())
  x.append(xx)
  y.append(yy)
  h.append(hh)
  if hh > 0:
    x0, y0, h0, = xx, yy, hh

for i in range(101):
  for j in range(101):
    flg = 0
    tmp = h0 + abs(x0-i) + abs(y0-j)
    for k in range(n):
      if h[k] != max(tmp - abs(x[k]-i) - abs(y[k]-j),0):
        flg = 1
        break
    if flg == 0:
      print (i,j,tmp)
      exit()

Solution (Python):





































































def calculation(lines):
    N = int(lines[0])
    
    

    points = list()
    highest = 0
    for i in range(1, N+1):
        point = list(map(int, lines[i].split()))
        
        points.append(point)
        if highest < point[2]:
            highest = point[2]
        

    for x in range(101):
        for y in range(101):
            for h in range(highest, highest+200):
                
                flag = True
                for point in points:
                    
                    calc_h = max(h - abs(point[0]-x) - abs(point[1]-y), 0)
                    if point[2] != calc_h:
                        flag = False
                        break
                if flag:
                    result = str(x) + ' ' + str(y) + ' ' + str(h)
                    return [result]



def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4', '2 3 5', '2 1 5', '1 2 5', '3 2 5']
        lines_export = ['2 2 6']
    if pattern == 2:
        lines_input = ['2', '0 0 100', '1 1 98']
        lines_export = ['0 0 100']
    if pattern == 3:
        lines_input = ['3', '99 1 191', '100 1 192', '99 0 192']
        lines_export = ['100 0 193']
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
import sys
from itertools import product

input = sys.stdin.readline


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, Cy in product(range(101), repeat=2):
        Ch = set()
        Ch_upper = float("inf")
        for x, y, h in zip(X, Y, H):
            a = abs(x - Cx) + abs(y - Cy)
            if h == 0:
                Ch_upper = min(Ch_upper, a)
            else:
                Ch.add(h + a)
        if len(Ch) != 1:
            continue
        else:
            Ch = Ch.pop()
            if Ch <= Ch_upper:
                ans = f"{Cx} {Cy} {Ch}"
                break

    print(ans)


if __name__ == "__main__":
    main()

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

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0)
            if tmp != l[k][2]:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)

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

for x in range(101):
    for y in range(101):
        hmax = XYH[0][2] + abs(x-XYH[0][0]) + abs(y-XYH[0][1])
        for i in range(n):
            if max(hmax-abs(x-XYH[i][0])-abs(y-XYH[i][1]), 0) != XYH[i][2]:
                break
            if i==n-1:
                print(x, y, hmax)
                exit()

Solution (Python):
n = int(input())
coords = [tuple(map(int, input().split())) for i in range(n)]
for xt, yt, ht in coords:
    if ht != 0:
        break
x, y, h = -1, -1, -1
for px in range(101):
    for py in range(101):
        flag = True
        htmp = ht + abs(px-xt) + abs(py-yt)
        dxdy = [(abs(px-x1)+abs(py-y1), htmp-h1) for x1, y1, h1 in coords]
        dxdy.sort()
        for i in range(n-1):
            if dxdy[i][0] < dxdy[i+1][0] and dxdy[i][1] > dxdy[i+1][1]:
                flag = False
                break
        for x1, y1, h1 in coords:
            
            if h1 == 0:
                continue
            if abs(htmp-h1) != abs(px-x1) + abs(py-y1):
                flag = False
                break
        if flag:
            if htmp > h:
                h = htmp
                x = px
                y = py
print (x, y, h)

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

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




def compute_diff_from_top(x, y, cx, cy):
    
    return ((-1 * abs(x - cx)) + (-1 * abs(y - cy)))


ans = 0
ans_x = None
ans_y = None
for i in range(101):
    for j in range(101):
        nums = []
        for high_set in high_sets:
            
            
            
            num = high_set[2] + (-1 * compute_diff_from_top(i, j, high_set[0], high_set[1]))
            if high_set[2] == 0:
                nums.append(-1)
            else:
                nums.append(num)
        
        
        if len(set(nums)) == 1:
            ans_x, ans_y = i, j
            ans = nums.pop()
        else:
            if len(set(nums)) == 2 and -1 in nums:
                nums = set(nums)
                nums.remove(-1)
                top = nums.pop()
                check = True
                for high_set in high_sets:
                    
                    
                    if max(0, top + compute_diff_from_top(i, j, high_set[0], high_set[1])) != high_set[2]:
                        check = False
                if check:
                    ans_x, ans_y = i, j
                    ans = top


print(ans_x, ans_y, ans)