Problem:
 Score: 300 points    Problem Statement  In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had center coordinates  (C_X, C_Y) and height  H . The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0) .  Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:   C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1 .  Additionally, he obtained N pieces of information. The i -th of them is: "the altitude of point (x_i, y_i) is h_i ."   This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.      Constraints   N is an integer between 1 and 100 (inclusive).  x_i and y_i are integers between 0 and 100 (inclusive).  h_i is an integer between 0 and 10^9 (inclusive).  The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.  The center coordinates and the height of the pyramid can be uniquely identified.         Input  Input is given from Standard Input in the following format:  N  x_1  y_1  h_1  x_2  y_2  h_2  x_3  y_3  h_3  :  x_N  y_N  h_N       Output  Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.        Sample Input 1 4
2 3 5
2 1 5
1 2 5
3 2 5      Sample Output 1 2 2 6  In this case, the center coordinates and the height can be identified as (2, 2) and 6 .       Sample Input 2 2
0 0 100
1 1 98      Sample Output 2 0 0 100  In this case, the center coordinates and the height can be identified as (0, 0) and 100 . Note that C_X and C_Y are known to be integers between 0 and 100 .       Sample Input 3 3
99 1 191
100 1 192
99 0 192      Sample Output 3 100 0 193  In this case, the center coordinates and the height can be identified as (100, 0) and 193 .

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

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


for i in range(n):
    if xyh[i][2] != 0:
        x_ex, y_ex, h_ex = xyh[i]
        break

for cx in range(101): 
    for cy in range(101): 
        h = abs(x_ex - cx) + abs(y_ex - cy) + h_ex 

        
        flag = 0
        for i in range(n):
            x_i, y_i, h_i = xyh[i]
            if h_i == max(h - abs(x_i - cx) - abs(y_i - cy), 0):
                flag += 1
            else:
                break

        if flag == n:
            print(cx, cy, h)

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

for _ in range(N):
    xx, yy, hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)

V_MAX = 100

for cx in range(V_MAX + 1):
    for cy in range(V_MAX + 1):
        
        
        
        needH = - 1

        for i in range(N):
            if h[i] > 0:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                
                tmp = h[i] + dist
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break

        if needH == -2:
            continue 

        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if needH > dist:
                    needH = - 2
                    break

        if needH == -2:
            continue 

        print(cx, cy, needH)

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
 
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for x, y, h in x_y_h:
                if h > 0:
                    H = h + abs(c_x - x) + abs(c_y - y)
                    break
            for x, y, h in x_y_h:
                if h != max(H - abs(c_x - x) - abs(c_y - y), 0):
                    break
            else:
                print("{0} {1} {2}".format(c_x, c_y, H))
                sys.exit()

Solution (Python):
N = int(input())
zahyou = [list(map(int,input().split())) for i in range(N)]
 
H = -1
C_x = 0
C_y = 0
 
def height(C_x,C_y,x,y,h):
  H = h + abs(x-C_x) + abs(y-C_y)
  return H
 
def koud(C_x,C_y,H,x,y):
  h = H - abs(x-C_x) - abs(y-C_y)
  return h
 
flag = False
for i in range(0,101):
  C_x = i
  for j in range(0,101):
    C_y = j
    H = -1
    memo = []
    for k in range(N):
      if zahyou[k][2] == 0:
        memo.append(k)
        continue
      if H < 0:
        H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
      else:
        if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
          break
        else:
          continue        
    else:
      for l in range(len(memo)):
        if H <= height(C_x,C_y,zahyou[l][0],zahyou[l][1],zahyou[l][2]):
          continue
        else:
          break
      else:  
        flag = True
        break
    if flag:
      break
  if flag:
    break

print(C_x,C_y,H)

Solution (Python):
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        X.append(x)
        Y.append(y)
        H.append(h)
    else:
        X.insert(0, x)
        Y.insert(0, y)
        H.insert(0, h)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(min(X), max(X) + 1):
    for Cy in range(min(Y), max(Y) + 1):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and H[i] == max(h - abs(X[i]-Cx) - abs(Y[i]-Cy), 0):
            i += 1
        if i == N:
            print(Cx, Cy, h)

Solution (Python):
from collections import Counter

n = int(input())

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

for i in range(n): 
    if xyh[i][2] != 0:
        xyh_1 = xyh[i]
        break

for cx in range(101): 
    for cy in range(101): 
        h = abs(xyh_1[0] - cx) + abs(xyh_1[1] - cy) + xyh_1[2] 

        flag = 0
        for i in range(n):
             
            if xyh[i][2] == max(h - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0):
                flag += 1

        if flag == n:
            print(cx, cy, h)

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


for Cx in range(101):
    for Cy in range(101):
        x, y, h = xyhs[-1]
        H = h + abs(Cx - x) + abs(Cy - y)
        for x, y, h in reversed(xyhs[:-1]):
            H2 = h + abs(Cx - x) + abs(Cy - y)
            if h == 0:
                if H2 < H: break
            else:
                if H != H2: break
        else:
            print(Cx, Cy, H)
            exit()

Solution (Python):
import sys
N = int(input().strip())
grid = []
ref = 0
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
    if array[2]>0:
      ref = i
x = 0
y = 0
while y <= 100:
  x = 0
  while x <= 100:
    flag = 0
    h0 = grid[ref][2]+abs(x-grid[ref][0])+abs(y-grid[ref][1])
    for arrays in grid:
      h = max(0,h0-abs(x-arrays[0])-abs(y-arrays[1]))
      if h != arrays[2]:
        flag = 1
    if flag == 0:
      print(x,y,h0)
      sys.exit()
    x += 1
  y += 1

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

max_h = P[0][2]

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h+200, max_h-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            th = max(hh-dx-dy, 0)
            if th != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))

Solution (Python):
n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
h = [0 for i in range(n)]
height_tmp = 0
X = 0
Y = 0
for i in range(n):
    x[i], y[i], h[i] = [int(i) for i in input().split()]
    if h[i] != 0:
        height_tmp = h[i]
        X = x[i]
        Y = y[i]
for i in range(101):
    for j in range(101):
        flag = 0
        okFlag = 1
        H = height_tmp + abs(X - i) + abs(Y - j)
        if H < 0:
            continue
        for k in range(n):
            if h[k] != max(H - abs(x[k] - i) - abs(y[k] - j), 0):
                okFlag = 0
                break
        if okFlag == 1:
            print("{} {} {}".format(i, j, H))
            exit()
"""
        flag = 0
        okFlag = 1
        height_tmp = 0
        output = [0, 0, 0]
        for k in range(n):
            if h[k] == 0:
                continue
            if flag == 0:
                height_tmp = h[k] + abs(x[k] - i) + abs(y[k] - j)
                flag = 1
            else:
                if height_tmp != h[k] + abs(x[k]-i) + abs(y[k]-j):
                    okFlag = 0
                    break
                elif k == n-1:
                    if height_tmp == h[k] + abs(x[k] - i) + abs(y[k] - j):
                        output = [i, j, height_tmp]
                        okFlag = 1
                        
                        
        if okFlag == 1:
            print("{} {} {}".format(i, j, height_tmp))
            exit()
"""

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

R.sort(reverse=True)

def solve():
    for cx in range(101):
        for cy in range(101):
            h, x, y = R[0]
            H = h + abs(x - cx) + abs(y - cy)
            for i in range(1, N):
                h, x, y = R[i]
                if h == 0 and H < abs(x - cx) + abs(y - cy):
                    continue

                tempH = h + abs(x - cx) + abs(y - cy)
                if tempH != H:
                    break
            else:
                print(cx, cy, H)
                return

solve()

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

max_h = P[0][2]

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h+200, max_h-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            th = max(hh-dx-dy, 0)
            if th != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))

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

data = sorted(data, key=lambda x: x[2], reverse=True)
    
halt = False
for i in range(100+1):
    for j in range(100+1):
        x, y, h = data[0]
        H = h + abs(x - i) + abs(y - j)
        for x, y, h in data[1:]:
            if h != max(0, H - abs(x- i) - abs(y - j)):
                break
        else:
            print(i, j, H)
            halt = True
        if halt:
            break
    if halt:
        break

Solution (Python):
N = input().strip()
import copy

import sys
loop = []
cccs = set()
first = True
for line in sys.stdin:
    x, y, h = [int(x) for x in line.strip().split(' ')]
    if h != 0 and first:
        for cx in range(101):
            for cy in range(101):
                H = h + abs(x-cx) + abs(y-cy)
                cccs.add((cx,cy,H))
        first = False
    else:
        loop.append((x,y,h))
ncc = set()
for x,y,h in loop:
    for cx, cy, H in cccs:
        if h == max(H - abs(x-cx) - abs(y-cy), 0):
            ncc.add((cx,cy,H))
    cccs = ncc
    ncc = set()

for i in cccs:
    print(i[0], i[1], i[2])

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

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

ans = []
ans_c = 0
for i in range(101):
    for j in range(101):
        H = -1
        judge = True
        for k in range(N):
            if info[k][2] == 0:
                continue
            dis = abs(i - info[k][0]) + abs(j - info[k][1])
            if H == -1:
                H = info[k][2] + dis
            else:
                if H != (info[k][2] + dis):
                    judge = False
        if judge == True:
            for k in range(N):
                if info[k][2] == 0:
                    h = max(H - (abs(i - info[k][0]) + abs(j - info[k][1])), 0)
                    if h != 0:
                        judge = False
        if judge == True:
            print("{} {} {}".format(i,j,H))
            exit()

Solution (Python):
n = int(input())
tmp = [int(i) for _ in range(n) for i in input().split()]

xs = tmp[0::3]
ys = tmp[1::3]
hs = tmp[2::3]
stopflag = False

hmax = max(hs)
index = hs.index(max(hs))
xmax = xs[index]
ymax = ys[index]

for cx in range(101):
    for cy in range(101):
        H = hmax + abs(xmax-cx) + abs(ymax-cy)
        for x,y,h in zip(xs,ys,hs):
            if h != max(H-abs(x-cx)-abs(y-cy),0):
                break
        else:
            print('{} {} {}'.format(cx,cy,H))
            stopflag = True
            break
    if stopflag:
        break

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

x=[]
y=[]
h=[]

for i in range(N):
	x_i,y_i,h_i = list(map(int,input().split()))
	x.append(x_i)
	y.append(y_i)
	h.append(h_i)

s = 0
flag = 0
s_max=2000000000
x_a=0
y_a=0
h_a=0

for C_X in range(101):
	for C_Y in range(101):
		for i in range(N):
			if h[i]!=0:
				if s==0:
					s = abs(x[i]-C_X)+abs(y[i]-C_Y)+h[i]
					
				elif abs(x[i]-C_X)+abs(y[i]-C_Y)+h[i] != s:
					
					s=0
					s_max=2000000000
					break
			else:
				if abs(x[i]-C_X)+abs(y[i]-C_Y) < s_max: s_max=abs(x[i]-C_X)+abs(y[i]-C_Y)
			if s_max < s:
				s=0
				s_max=2000000000
				break
			if i==N-1:
				h_a=s
				flag=2
				break
		if flag:
			y_a=C_Y
			break
	if flag:
		x_a=C_X
		break

print("%d %d %d" % (x_a,y_a,h_a))

Solution (Python):
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
arr.sort(key=lambda l:-l[2])
 
for cx in range(101):
  for cy in range(101):
    ch = None
    for x, y, h in arr:
      t = h + abs(cx-x) + abs(cy-y)
      if h > 0:
        if ch is not None and t != ch:
          break
        ch = t
      else:
        if t < ch:
          break
    else:
      print(cx, cy, ch)
      exit()

Solution (Python):

def main():
    buf = input()
    N = int(buf)
    x = []
    y = []
    h = []
    for i in range(N):
        buf = input()
        buflist = buf.split()
        x.append(int(buflist[0]))
        y.append(int(buflist[1]))
        h.append(int(buflist[2]))
    x = [z for _, z in sorted(zip(h,x), key=lambda pair: pair[0])][::-1]
    y = [z for _, z in sorted(zip(h,y), key=lambda pair: pair[0])][::-1]
    h = sorted(h)[::-1]
    for cx in range(101):
        for cy in range(101):
            H = h[0] + dist(cx, cy, x[0], y[0])
            correct = True
            for i in range(1, N):
                if h[i] + dist(cx, cy, x[i], y[i]) != H:
                    if dist(cx, cy, x[i], y[i]) <= H:
                        correct = False
                        break
                    else:
                        if h[i] != 0:
                            correct = False
                            break
            if correct == True:
                print(cx, cy, H)
                return


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

if __name__ == '__main__':
    main()

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

j = -1
for i in range(N):
    x[i],y[i],h[i] = map(int,input().split(" "))
    if h[i] !=  0:
        j = i

for cx in range(0,101):
    for cy in range(0,101):
        H = h[j] + abs(x[j]-cx) + abs(y[j]-cy)
        flg = True
        for i in range(N):
            if (h[i] == 0 and ((abs(x[i]-cx) + abs(y[i]-cy))) < H):
                flg = False
                break
            if (h[i] != 0 and H != (h[i] + abs(x[i]-cx) + abs(y[i]-cy))):
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx,cy,H))
            exit(0)

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

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]
for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
for i in range(101):
  for j in range(101):
    for k in range(n):
      if h[k] != 0:
        H = abs(i - x[k]) + abs(j - y[k]) + h[k] 
    for k in range(n):
      if H - abs(i - x[k]) - abs(j - y[k]) <=0:
        if h[k] != 0:
          break
      elif  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)

Solution (Python):
N = int(input())
x, y, h = [], [], []
x2, y2, h2 = [], [], []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi != 0:
        x.append(xi)
        y.append(yi)
        h.append(hi)


def fn(H, X, Y, Cx, Cy):
    return H + abs(Cx - X) + abs(Cy - Y)

if len(h) == 1:
    print(x[0], y[0], h[0])
    exit()

for Cx in range(101):
    for Cy in range(101):
        H = fn(h[0], x[0], y[0], Cx, Cy)
        flag = True
        for i in range(1, len(h)):
            if H != fn(h[i], x[i], y[i], Cx, Cy):
                flag = False
                break
        if flag:
            print(Cx, Cy, H)
            exit()

Solution (Python):
import sys
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
while H[0] == 0:
    X.append(X[0])
    Y.append(Y[0])
    H.append(H[0])
    X = X[1:]
    Y = Y[1:]
    H = H[1:]
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(101):
    for Cy in range(101):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and H[i] == max(h - abs(X[i]-Cx) - abs(Y[i]-Cy), 0):
            i += 1
        if i == N:
            print(Cx, Cy, h)
            sys.exit()

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = float("inf")
H_temp = None
 
x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H_temp < H:
                    Cx = c_x
                    Cy = c_y
                    H = H_temp
                    
print("{0} {1} {2}".format(Cx, Cy, H))

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

flag = False
flag2 = True
firsst = True
for x in range(0,101):
    for y in range(0,101):
        flag = False
        flag2 = True
        first = True
        for i in range(0,N):
            if INFO[i][2] == 0:
                flag = True
                continue
            if first:
                first = False
                elseH = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            H = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            if H != elseH:
                flag2 = False
                break
        if flag:
            for i in range(0,N):
               if max(elseH - abs(x-INFO[i][0]) - abs(y-INFO[i][1]),0) != INFO[i][2]:
                   flag2 = False
        if flag2:
            break
    if flag2:
        break
print(x,y,H)

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


cxyl = []
for i in range(101):
    for j in range(101):
        cxyl.append((i,j))
cxy = set(cxyl)
hd = {}
hzero = set([])
for i in range(n):
    for c in list(cxy):
        H = abs(x[i]-c[0]) + abs(y[i]-c[1]) + h[i]
        if h[i] == 0:
            hzero.add((x[i],y[i]))
            if 1 > H:
                cxy.remove(c)
                continue
        else:
            if c in hd:
                if hd[c] != H:
                    cxy.remove(c)
                    continue
            else:
                hd[c] = H

for xy in list(hzero):
    xi = xy[0]
    yi = xy[1]
    for c in list(cxy):
        H = abs(xi-c[0]) + abs(yi-c[1])
        if hd[c] - H > 0:
            cxy.remove(c)

ret = cxy.pop()
print(str(ret[0]) + ' ' + str(ret[1]) + ' ' + str(hd[ret]))

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

x = []

for i in range(n):
	a,b,c = map(int,input().split())
	x.append([c,a,b])
x.sort()
x.reverse()
a = 0
b = 0
for i in range(101):
	for j in range(101):
		for k in range(n):
			if x[k][0] != 0:
				if k == 0:
					a = x[k][0] + abs(i-x[k][1]) + abs(j-x[k][2])
					b += 1
				else:
					if a == x[k][0] + abs(i-x[k][1]) + abs(j-x[k][2]):
						b += 1
			else:
				if a- abs(i-x[k][1]) - abs(j-x[k][2]) <= 0:
					b += 1
		if b == n:
			print(i,j,a)
		b = 0

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

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)

info = sorted(info,key = lambda x: x[2])
end = 0

for x in range(101):
    for y in range(101):
        H = info[n-1][2] + abs(x-info[n-1][0]) + abs(y-info[n-1][1])
        for i in range(n-1):
            if info[i][2] != max(0,H - abs(x-info[i][0]) - abs(y- info[i][1])):
                break
        else:
            print(x,y,H)
            end = 1
            
        if end == 1:
            break
    if end == 1:
        break

Solution (Python):


N = int(input())

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


ans_list = []
for xi in range(101):
    for yi in range(101):
        H_list = []
        for x,y,h in xyhn:
            if h > 0:
                H = h + abs(x - xi) + abs(y - yi)
                H_list.append(H)

        if min(H_list) == max(H_list):
            ans_list.append([xi,yi,H_list[0]])
            
            

ans_list.sort(key=lambda x:x[2])
print("%d %d %d"%(ans_list[0][0],ans_list[0][1],ans_list[0][2]))

Solution (Python):
n = int(input())
xlist = []
ylist = []
hlist = []
for _ in range(n):
    x, y, h =list(map(int, input().split()))
    xlist.append(x)
    ylist.append(y)
    hlist.append(h)

def cond(cx, cy):
    same = None
    for i in range(n):
        if hlist[i] == 0:
            continue
        h = hlist[i] + abs(xlist[i] - cx) + abs(ylist[i] - cy)
        if same == None:
            same = h
            continue
        if same != h:
            return False
    for i in range(n):
        if hlist[i] == 0:
            if same - abs(xlist[i] - cx)  - abs(ylist[i] - cy) > 0:
                return False
    return True
        
rescx, rescy = 0, 0
label = False
for cx in range(101):
    for cy in range(101):
        if cond(cx, cy):
            rescx = cx
            rescy = cy
            label = True
            break
    if label:
        break

resh = 0
for i in range(n):
    if hlist[i] > 0:
        resh = abs(xlist[i] - rescx) + abs(ylist[i] - rescy) + hlist[i]
        break

print(rescx, rescy, resh)

Solution (Python):
n = int(input())
x=[0]*n
y=[0]*n
h=[0]*n

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

for i in range(n):
    if h[i]>0:
        ii = i
    
        
ran = list(range(0,n))
ran.remove(ii)

for cx in range(101):
    for cy in range(101):
        hight = abs(cx-x[ii]) + abs(cy-y[ii]) + h[ii]        
        flag=1
        for i in ran:
            if max(hight - (abs(cx-x[i]) + abs(cy-y[i])), 0) != h[i]:
                flag=0
        if flag==1:
            print("{} {} {}".format(cx, cy, hight))

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

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



a1=0
a2=0
a3=0

for i in range(0,101):
    for j in range(0,101):
        col=0
        h=abs(A[0][0]-i)+abs(A[0][1]-j)+A[0][2]
        for k in range(1,n):
            if max(0,h-abs(A[k][0]-i)-abs(A[k][1]-j))!=A[k][2] :
                col=1
        if col==0 :
            a1=i
            a2=j
            a3=h

print(str(a1)+" "+str(a2)+" "+str(a3))

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

if N == 1:
    print(G[0][0],G[0][1],G[0][2])
    exit(0)

G = sorted(G, key=lambda x: -x[2])
for Cx in range(101):
    for Cy in range(101):
        f = 1
        H = G[0][2] + abs(Cx-G[0][0]) + abs(Cy-G[0][1])
        for k in range(1,N):
            if max(0,H-abs(G[k][0]-Cx)-abs(G[k][1]-Cy)) != G[k][2]:
                f = 0
        if f:
            print(Cx,Cy,H)

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

for i in range(0, n):
    if l[i][2] != 0:
        p = l[i]
        break

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

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

X = [None] * N
Y = [None] * N
H = [None] * N

x_max = 0
y_max = 0
h_max = 0
R = []

for n in range(N):
    X[n], Y[n], H[n] = map(int, input().split())
    if h_max <= H[n]:
        x_max, y_max, h_max = X[n], Y[n], H[n]

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True
        for n in range(N):
            if H[n] != 0:
                ch = H[n] + abs(X[n] - cx) + abs(Y[n] - cy)
        for n in range(N):
            if max(ch - abs(X[n] - cx) - abs(Y[n] - cy), 0) != H[n]:
                flag = False
                break
        if flag == True:
            R.append([cx, cy, ch])

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

Solution (Python):
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff = 0
if min(h)>=10:
    diff=min(h)-5
h=[i-diff for i in h]

def pattern(cx,cy,H):
    for i in range(n):
        
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Solution (Python):

def check(cx, cy, H, x, y, h):
    if (h == 0) and (abs(cx-x)+abs(cy-y) > H):
        return True
    if H-h == abs(cx-x)+abs(cy-y):
        return True
    else:
        return False

def a():
    N = int(input())
    xs = []
    ys = []
    hs = []
    for _ in range(N):
        i = input().split(' ')
        xs.append(int(i[0]))
        ys.append(int(i[1]))
        hs.append(int(i[2]))
    
    for i, h in enumerate(hs):
        if h==0:
            continue
        else:
            init_x = xs[i]
            init_y = ys[i]
            init_h = h
            break
    for cx in range(101):
        for cy in range(101):
            H = abs(cx-init_x)+abs(cy-init_y)+init_h
            flag_stop = False
            for x, y, h in zip(xs, ys, hs):
                if not check(cx, cy, H, x, y, h):
                    flag_stop = True
                    break
            if flag_stop:
                continue
            else:
                print('{} {} {}'.format(cx, cy, H))
                return
a()

Solution (Python):
n = int(input())
x = []
y = []
h = []
for i in range(n):
    temp = [int(_) for _ in input().split(' ')]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])

for cx in range(101):
    for cy in range(101):
        correctness = True
        for i in range(n):
            if h[i] > 0:
                ch = h[i] + abs(cx - x[i]) + abs(cy - y[i])
        for i in range(n):
            if h[i] != max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0):
                correctness = False
        if correctness:
            print('{0} {1} {2}'.format(cx, cy, ch))

Solution (Python):
from itertools import product

n = int(input())
xs, ys, hs = zip(*[[int(x) for x in input().split()] for _ in range(n)])

for i, j in product(range(0,101), repeat=2):
    k = -1
    l = 1 << 32
    for x, y, h in zip(xs, ys, hs):
        if h == 0:
             l = min(l, abs(x-i) + abs(y-j))
        elif k == -1:
             k = abs(x-i) + abs(y-j) + h
        elif k!=-1 and k - h != abs(x-i) + abs(y-j):
            break
        if k > l:
            break
    else:
        if k!=-1:
            print(i, j, k)
        elif l==1:
            print(i, j, 1)
        break

Solution (Python):
n = int(input())
x=[]
y=[]
h=[]
for i in range(0,n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
 
 
 
for i in range(0,101):
    for j in range(0,101):
        tmph=0
        flag = True
        for k in range(0,n):
            if tmph == 0 and h[k] != 0:
                tmph=abs(x[k]-i)+abs(y[k]-j)+h[k]
                break
        for k in range(0,n):
            calch = tmph - abs(x[k]-i)-abs(y[k]-j)
            if h[k] != max(calch,0):
                flag = False
                break
        if flag == False:
            continue
        elif tmph == 0:
            flag2 = True
            for c in range(0,101):
                if i == x[c] and j == y[c]:
                    flag2 = False
                    break
            if flag2:
                ansx = i
                ansy = j
                ansh = 1
        else:
            ansx=i
            ansy=j
            ansh=tmph
 
print(ansx,ansy,ansh)

Solution (Python):
N = int(input())
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))
H = 0
h = 0
flag = False
maxz = xyz[0][2]
maxy = xyz[0][1]
maxx = xyz[0][0]
for k in range(N):
    if xyz[k][2] > maxz:
        maxz = xyz[k][2]
        maxx = xyz[k][0]
        maxy = xyz[k][1]
for i in range(101):
    for j in range(101):
        H = maxz + abs(maxx-i) + abs(maxy-j)
        for k in xyz:
            h = H -abs(k[0]-i)-abs(k[1]-j)
            if h < 0:
                h = 0
            if h == k[2]:
                continue
            else:
                break
        else:
            if H != 0:
                flag = True
                print("{} {} {}".format(i, j, H))
                break
    if flag:
        break

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] = list(map(int, input().split()))
min_min_h = 10**9+1
for i in range(101):
    for j in range(101):
        tmp = []
        tmp2 = []
        for k in range(N):
            if h[k] !=0:
                tmp.append(abs(i-x[k])+abs(j-y[k])+h[k])
            else:
                tmp2.append(abs(i-x[k])+abs(j-y[k]))
        if len(set(tmp)) == 1:
            for l in range(len(tmp2)):
                if tmp[0]>tmp2[l]:
                    break
            else:
                print(i,j,tmp[0])