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

Solution (Python):
def get_coord(C):
    for xi in range(0, 101):
        for yi in range(0, 101):
            H = 10 ** 9 + 1
            success = True
            for i in range(0, len(C)):
                d = abs(xi - C[i][0]) + abs(yi - C[i][1])
                if i == 0:
                    th = H - d
                    H -= th - C[i][2]
                else:
                    nh = H - d
                    if nh >= 0:
                        if C[i][2] == nh:
                            continue
                        else:
                            success = False
                            break
                    else:
                        if C[i][2] == 0:
                            continue
                        else:
                            success = False
                            break

            if success:
                return (xi, yi)
    return (-1, -1)


def solve(C):
    C.sort(key=lambda x: x[2], reverse=True)
    x, y = get_coord(C)
    for c in C:
        if c[2] != 0:
            h = abs(x - c[0]) + abs(y - c[1]) + c[2]
            return [str(x), str(y), str(h)]


if __name__ == "__main__":
    N = int(input())
    C = []
    for n in range(N):
        d = input().split(" ")
        C.append((int(d[0]), int(d[1]), int(d[2])))
    print(" ".join(solve(C)))

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:
        x2.append(xi)
        y2.append(yi)
        h2.append(hi)
    else:
        x.append(xi)
        y.append(yi)
        h.append(hi)


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

heights = []
for Cx in range(101):
    for Cy in range(101):
        H = fn(h[0], x[0], y[0], Cx, Cy)
        heights.append([H, Cx, Cy])
        if len(h) == 1:
            continue
        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()

print(x[0], y[0], h[0])

Solution (Python):
N = int(input())
p = [list(map(int, input().split())) for _ in range(N)]
def find(H):
    for cx in range(101):
        for cy in range(101):
            for x, y, h in p:
                if h > max(H - abs(x - cx) - abs(y - cy), 0):
                    break
            else:
                return True
    return False

lo = 0
hi = 10 ** 10
while hi - lo > 1:
    mid = (hi + lo) // 2
    if find(mid):
        hi = mid
    else:
        lo = mid

for cx in range(101):
    for cy in range(101):
        for x, y, h in p:
            if h != max(hi - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            print(cx, cy, hi)
            exit()

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


for i in range(101):
    for j in range(101):
        x_0, y_0, h_0 = xyh[0]
        H = h_0 + abs(y_0-i) + abs(x_0-j)
        valid = True
        for x, y, h in xyh[1:]:
            if max(H-abs(y-i)-abs(x-j), 0) != h:
                valid = False
                break
        if valid:
            ans = str(j)+' '+str(i)+' '+str(H)
            print(ans)
            exit()

Solution (Python):
from collections import defaultdict
N = int(input())
XYH = [list(map(int,input().split())) for _ in range(N)]

Cxy = defaultdict(int)




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

for x,y,h in XYH:
    for cx in range(101):
        for cy in range(101):
            val = Cxy[(cx,cy)]
            if val<0:
                continue
            tmp_H = abs(x-cx)+abs(y-cy)+h
            if h==0:
                if tmp_H < Cxy[(cx,cy)]:
                    Cxy[((cx, cy))]=-1
                continue

            if val==0:
                Cxy[(cx,cy)] = tmp_H
            elif val != tmp_H:
                Cxy[(cx, cy)] =-1

def find(d):
    for key in d.keys():
        if d[key] >0:

            return key,d[key]

(X,Y),H = find(Cxy)
print(X,Y,H)

Solution (Python):
N = int(input())
x = []
y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())
    if c>0: idx_0 = i
    x.append(a)
    y.append(b)
    h.append(c)
for cx in range(101):
    for cy in range(101):
        H = h[idx_0] + abs(x[idx_0]-cx) + abs(y[idx_0]-cy)
        cnt = 0
        for k in range(N):
            if h[k]==max(H - abs(x[k]-cx) - abs(y[k]-cy), 0): cnt+=1
        if cnt==N:
            print(cx,cy,H)
            exit()

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



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

def height(x1, y1, cx, cy, H):
    return max(H-city_dist(x1, y1, cx, cy), 0)

x = []
y = []
h = []
non_zero_index = -1

for i in range(N):
    line = [int(a) for a in input().split()]
    x.append(line[0])
    y.append(line[1])
    h.append(line[2])
    if line[2] != 0:
        non_zero_index = i


for cx in range(101):
    for cy in range(101):
        H = h[non_zero_index] + city_dist(x[non_zero_index], y[non_zero_index], cx, cy)
        answer = True
        for i in range(N):
            
            if h[i] != height(x[i], y[i], cx, cy, H):
                answer = False
                break
        if answer:
            print("{} {} {}".format(cx, cy, H))
            break            
    if answer:
        break

Solution (Python):
import math
n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
h = [0 for i in range(n)]
judge = False
for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())
for i in range(0, 101):
    for j in range(0, 101):
        for k in range(0, n):
            if h[k] != 0:
                true_h = h[k] + int(math.fabs(x[k]-i)) + int(math.fabs(y[k]-j))
                break
        judge = True
        for k in range(n):
            dum_h = max(true_h-int(math.fabs(x[k]-i)) - int(math.fabs(y[k]-j)), 0)
            if h[k] != dum_h:
                judge = False
                break
        
        if judge is True:
            break
    if judge is True:
        break

print("{} {} {}".format(i, j, true_h))

Solution (Python):
n = input()
l = []
isz = 0
for i in xrange(n):
    x, y, h = map(int, raw_input().strip().split())
    if h == 0: isz += 1
    l.append([x, y, h])

assert isz != n

ans = [0,0,0]

for cx in xrange(101):
    for cy in xrange(101):
        H = 0
        zH = int(1e18)
        poss = True
        for xyh in l:
            x, y, h = xyh
            tx = abs(cx - x) + abs(cy - y)
            if h != 0:
                nH = tx + h
                if H != 0 and nH != H:
                    poss = False
                    break
                elif H == 0: H = nH
            elif h == 0:
                zH = min(zH, tx)

        if poss:
            if H > zH: poss = False
             
        if poss:
            ans = [cx, cy, H]
            break
        
    if poss: break
    
if ans != [0, 0, 0]:
    check = True
    for xyh in l:
        x, y, h = xyh
        tx = abs(cx - x) + abs(cy - y)
        assert h == max(ans[2] - tx, 0)

print ans[0], ans[1], ans[2]

Solution (Python):
N = int(input())
lis = []
rem = 0
for i in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        rem = i
    lis.append((x,y,h))
flag = 1
for i in range(101):
    for j in range(101):
        flag = 1
        H = lis[rem][2]+abs(lis[rem][0]-i)+abs(lis[rem][1]-j)
        for k in range(N):
            if lis[k][2] != max(H-abs(lis[k][0]-i)-abs(lis[k][1]-j),0):
                flag = 0
                break
        if flag == 1:
            break
    if flag == 1:
        break
print(str(i)+" "+str(j)+" "+str(H))

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

for x in range(101):
    for y in range(101):
        h_must = 0
        h_max = 1000000000
        for k in range(N):
            h_tmp = xyh[k][2]+abs(x-xyh[k][0])+abs(y-xyh[k][1])
            if h_must == 0:
                if xyh[k][2] != 0:
                    h_must = h_tmp
                else:
                    h_max = min(h_max,h_tmp)
            else:
                if xyh[k][2] != 0:
                    if h_must != h_tmp:
                        break
                else:
                    h_max = min(h_max,h_tmp)
                    if h_must > h_max:
                        break
        else:
            if h_must == 0:
                h_must = h_max
            print("{} {} {}".format(x,y,h_must))
            break
    else:
        continue
    break

Solution (Python):

import itertools


n = int(input())
xlist = []
ylist = []
hlist = []
for i in range(n):
	xtmp, ytmp, htmp = map(int, input().split())
	xlist.append(xtmp)
	ylist.append(ytmp)
	hlist.append(htmp)
h = max(hlist)
end_flag = False
while True:
	for cx, cy in itertools.product(range(101), range(101)):
		if all([hlist[i] == max(h - abs(xlist[i] - cx) - abs(ylist[i] - cy), 0) for i in range(n)]):
			print('{} {} {}'.format(cx, cy, h))
			end_flag = True
			break
	if end_flag:
		break
	h += 1

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

for x in range(101):
    for y in range(101):
        h = [0]*n
        ans = 0
        for i in range(n):
            if xyh[i][2]!=0:
                h[i] = abs(xyh[i][0] - x) + abs(xyh[i][1] - y) + xyh[i][2]
                if ans == h[i] or ans ==0:
                    ans =h[i]
                else:
                    break
            if i ==n-1:
                a = 0
                for j in range(n):
                    if xyh[j][2]!= max(ans- abs(xyh[j][0] - x) - abs(xyh[j][1] - y),0):
                        a=1
                        break
                if a==0:
                    print(x, y, ans)

Solution (Python):
N = int(raw_input())
data = []
for i in range(N):
    v = map(int, raw_input().split())
    data.append(v)

cond = []
for x in range(100+1):
    for y in range(100+1):
        h = []
        for d in data:
            if d[2] != 0:
                h.append(d[2] + abs(d[0]-x) + abs(d[1]-y))
        if len(set(h)) == 1:
            cond.append((x, y, h[0]))

if len(cond) == 1:
    print cond[0][0], cond[0][1], cond[0][2]
else:
    for c in cond:
        res = []
        for d in data:
            if d[2] == 0:
                if c[2] - (abs(d[0]-c[0]) + abs(d[1]-c[1])) <= 0:
                    res.append(True)
                else:
                    res.append(False)
        if all(res):
            print c[0], c[1], c[2]
            exit(0)

Solution (Python):
import math

N = int(input())

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

tmp = []
for i in range(N):
	x,y,h = map(int,input().split())
	if h == 0:
		tmp.append([x,y,h])
		continue
	for j in range(101):
		for k in range(101):
			if h == 0:
				if field[j][k] - abs(x-j) - abs(y-k) > 0:
					field[j][k] = -2
			else:
				if field[j][k] == -1:
					field[j][k] = h + abs(x-j) + abs(y-k)
				elif field[j][k] != h + abs(x-j) + abs(y-k):
					field[j][k] = -2

for x,y,h in tmp:
	for j in range(101):
		for k in range(101):
			if h == 0:
				if field[j][k] - abs(x-j) - abs(y-k) > 0:
					field[j][k] = -2
			else:
				if field[j][k] == -1:
					field[j][k] = h + abs(x-j) + abs(y-k)
				elif field[j][k] != h + abs(x-j) + abs(y-k):
					field[j][k] = -2

for i in range(101):
	for j in range(101):
		if field[i][j] > 0:
			print(i,j,field[i][j])

Solution (Python):
def solve(n):
    can = [[[-1, float('inf')] for _ in range(101)] for _ in range(101)]
    for k in range(n):
        x, y, h = map(int, input().split())
        for i in range(101):
            for j in range(101):
                if can[i][j] is None:
                    continue
                hh = h + abs(x - i) + abs(y - j)
                hl = 1 if h == 0 else hh
                nl, nh = max(can[i][j][0], hl), min(can[i][j][1], hh)
                if nl > nh:
                    can[i][j] = None
                else:
                    can[i][j][0] = nl
                    can[i][j][1] = nh

    for i in range(101):
        for j in range(101):
            if can[i][j] is None:
                continue
            return i, j, can[i][j][0]


n = int(input())
print(*solve(n))

Solution (Python):
from itertools import product

N = int(input())
L = tuple(tuple(map(int,input().split())) for _ in range(N))

for xc,yc in product(range(101), repeat=2):
  s = set(abs(xc-x)+abs(yc-y)+h for x,y,h in L if h != 0)
  if len(s) == 1:
    H = next(iter(s))
    if all(abs(xc-x)+abs(yc-y) >= H for x,y,h in L if h == 0):
      print(xc,yc,H)
      break

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

for i in range(101):
    for j in range(101):
        height = -1
        Z = []
        for x, y, h in XYH:
            hi = abs(x - i) + abs(y - j) + h
            if h == 0:
                Z.append([x, y])
                continue
            if height == -1:
                height = hi
            else:
                if height == hi:
                    pass
                else:
                    break
        else:
            for x, y in Z:
                if abs(x - i) + abs(y - j) >= height:
                    continue
                else:
                    break
            else:
                print(i, j, height)
                exit()

Solution (Python):

from operator import itemgetter

N = int(input())

XYH = []

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

XYH.sort(key=itemgetter(2))
XYH.reverse()

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 = 1
        
        for k in range(1, N):
            if not max(H-abs(XYH[k][0]-i)-abs(XYH[k][1]-j), 0) == XYH[k][2]:
                flag = -1
                break
        
        if flag > 0:
            break
    if flag > 0:
        break    

ans = str(i)+' '+str(j)+' '+str(H)
  
print(ans)

Solution (Python):
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
xyh = []
xyh.sort(key=lambda x: x[2])
for _ in range(n):
    xyh.append(ai())

for cx in range(101):
    for cy in range(101):
        H = []
        d = []
        for x,y,h in xyh:
            H.append(h+abs(cx-x)+abs(cy-y))
            d.append(abs(cx-x)+abs(cy-y))
        hh = min(H)
        f = 0
        for i in range(n):
            if H[i] == d[i] > hh or (d[i] <= hh and H[i] == hh):
                continue
            else:
                f = 1
                break
        if f == 0:
            print(cx,cy,hh)
            exit()

Solution (Python):
n = int(input())
info = [[int(i) for i in input().split()] for j in range(n)]
info.sort(key=lambda x:x[2])
if n == 1:
    print(info[0][0], info[0][1], info[0][2])
else:
    for i in range(n):
        if info[i][2] > 0:
            r = i
    for x in range(101):
        for y in range(101):
            h = info[r][2] + abs(x - info[r][0]) + abs(y - info[r][1])
            for i in range(n):
                if i < n-1 :
                    if info[i][2] == 0:
                        if h > abs(x - info[i][0]) + abs(y - info[i][1]):
                            break
                    else:
                        if h != info[i][2] + abs(x - info[i][0]) + abs(y - info[i][1]):
                            break
                elif i == n-1:
                    if h == info[i][2] + abs(x - info[i][0]) + abs(y - info[i][1]):
                        cx = x
                        cy = y
                        ch = h
    print(cx, cy, ch)

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

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

ext = lambda x: list(x)[0]

def check(zero, h):
    for xy in zero:
        if h - xy > 0:
            return False
    return True

for xcand in range(101):
    for ycand in range(101):
        values = set()
        zero = list()
        for x, y, h in xyh:
            if h == 0:
                zero.append(abs(xcand - x) + abs(ycand - y))
            else:
                values.add(abs(xcand - x) + abs(ycand - y) + h)
        if len(values) == 1:
            v = ext(values)
            if check(zero, v):
                print(xcand, ycand, v)
                exit()

Solution (Python):



import itertools

N = int(input())
ta = [list(map(int,input().split())) for _ in range(N)]
for Cx, Cy in itertools.product(range(101),range(101)):
    
    
    H = None
    for [x,y,h] in ta:
        if h == 0:
            pass
        else:
            if H is None:
                H = h + abs(x-Cx)+abs(y-Cy)
            else:
                if H != h + abs(x-Cx)+abs(y-Cy):
                    break
    for [x,y,h] in ta:
        if h != max(H - abs(x-Cx) - abs(y-Cy),0):
            break
    else:
        break
print(Cx,Cy,H)

Solution (Python):
n = int(input())
cx,cy = 0,0
list_xyh = []
for i in range(n):
    list_xyh.append(list(map(int, input().split())))
for cx in range(0,101):
    for cy in range(0,101):
        for i in range(n):
            if list_xyh[i][2] != 0:
                H = abs(cx - list_xyh[i][0]) + abs(cy - list_xyh[i][1]) + list_xyh[i][2]
                break
        for i in range(n):
            if max(H - abs(cx - list_xyh[i][0]) - abs(cy - list_xyh[i][1]),0) == list_xyh[i][2]:
                continue
            else:
                break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break

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


for j in range(101):
    for k in range(101):
        for l in range(h[0], h[0] + 200):
            flag = 1
            for i in range(N):
                h_i_test = max(l - abs(x[i] - j) - abs(y[i] - k), 0)
                if h_i_test != h[i]:
                    flag = 0
                    break
            if flag == 1:
                print(str(j)+ " " + str(k) + " " + str(l))
                break
        if flag == 1:
            break
    if flag == 1:
        break

Solution (Python):
N = int(input())
Info = [list(map(int, input().split())) for i in range(N)]
Info_nonzero = []
highest = 0
for x, y, h in Info:
    if h != 0:
        Info_nonzero.append([x, y, h])

for x, y, h in Info:
    if h == 0:
        highest = max(highest, x + y)

for Cx in range(101):
    for Cy in range(101):
        candidate_set = set()
        for x, y, h in Info_nonzero:
            H = abs(Cx - x) + abs(Cy - y) + h
            candidate_set.add(H)

        ans_H = list(candidate_set)[0]
        if len(candidate_set) == 1:
            for x, y, h in Info:
                H = abs(Cx - x) + abs(Cy - y) + h
                if h == 0:
                    if not H >= ans_H:
                        break

                if h != 0:
                    if not H <= ans_H:
                        break
            else:
                print(Cx, Cy, abs(Cx - Info_nonzero[0][0]) + abs(Cy - Info_nonzero[0][1]) + Info_nonzero[0][2])
                exit()

Solution (Python):

from sys import stdin

s_in = lambda: stdin.readline()[:-1] 
d_in = lambda: int(stdin.readline()) 
ds_in = lambda: list(map(int, stdin.readline().split())) 

N = d_in()

cand = [[i,j,0] for i in range(0, 101) for j in range(0, 101)]

info = []
for _ in range(N):
    info.append(ds_in())

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

for i in range(len(cand)):
    x, y, h = info[0]
    cand[i][2] = h + abs(x-cand[i][0]) + abs(y-cand[i][1])

if N > 1:
    idx = 1
    while len(cand) > 1 and idx < N:
        temp = []
        x, y, h = info[idx]
        for c in cand:
            if h == max(0, c[2] - abs(x-c[0]) - abs(y-c[1])):
                temp.append(c)
        cand = temp.copy()
        idx += 1

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

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XYH):
    XYH.sort(key=lambda x: x[2], reverse=True)
    MM = 101
    M = [[1] * MM for _ in range(MM)]
    for r, (x, y, h) in enumerate(XYH):
        if h == 0:
            M[x][y] = 0
            continue
        for i in range(MM):
            for j in range(MM):
                t = abs(i-x) + abs(j - y) + h
                if r == 0:
                    M[i][j] = t
                else:
                    if M[i][j] != t:
                        M[i][j] = 0

    

    for i in range(MM):
        for j in range(MM):
            if M[i][j] != 0:
                if i > 0 and M[i-1][j] != 0:
                    continue
                if i < MM -1 and M[i+1][j] != 0:
                    continue
                if j > 0 and M[i][j-1] != 0:
                    continue
                if j < MM -1 and M[i][j+1] != 0:
                    continue
                return '%d %d %d' % (i, j, M[i][j])

    assert False


def main():
    N = read_int()
    XYH = [read_int_n() for _ in range(N)]
    print(slv(N, XYH))


if __name__ == '__main__':
    main()

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

def CalcHigh(cx, cy, px, py, ph):
    ch = ph + abs(cx-px) + abs(cy-py)
    return ch

for i in range(101):
    for j in range(101):
        ch = 0
        for k in range(N):
            if h[k] > 0:
                ch = CalcHigh(i, j, x[k], y[k], h[k])

        flag = True
        for k in range(N):
            if ch > 0:
                if h[k] == 0:
                    if CalcHigh(i, j, x[k], y[k], h[k]) < ch:
                        flag = False
                        break
                else:
                    if CalcHigh(i, j, x[k], y[k], h[k]) != ch:
                        flag = False
                        break

        if flag == True:
            ans = (i, j, ch)
            break

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

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

INF = float('inf')
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
                if tmph > maxh:
                    break
            else:
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
                if maxh == 1:
                    tmph = 1
        else:
            for x,y,h in src:
                if max(tmph - abs(x-cx) - abs(y-cy), 0) != h:
                    break
            else:
                print(cx,cy,tmph)
                exit()

Solution (Python):
n=int(input())
data = []
for i in range(n):
    data.append(list(map(int,input().split())))
data.sort(key=lambda x:x[2],reverse=True)
ansflg = False
for xpos in range(101):
    for ypos in range(101):
        high = data[0][2] + abs(data[0][0]-xpos) + abs(data[0][1]-ypos)
        check = True
        for k in range(1,n):
            if data[k][2] != max(0,high - abs(data[k][0]-xpos) - abs(data[k][1]-ypos)):
                check = False
                break
        if check:
            print('{} {} {}'.format(xpos,ypos,high))
            ansflg = True
            break
    if ansflg:
        break

Solution (Python):
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        H = []
        check = []
        for k in range(n):
            x = a[k][0]
            y = a[k][1]
            h = a[k][2]
            if h ==  0:
                check.append((x, y))
            else:
                H.append(h + abs(x-i) + abs(y-j))
                if len(set(H)) > 1:
                    break
            if k == n-1:
                state = False
                for s,t in check:
                    if H[0] - abs(s-i) - abs(t-j) > 0:
                        state = True
                        break
                if state:
                    break
                print(i, j, H[0])
                exit()

Solution (Python):
def big(a,b):
    if a >= b:
        return a
    else:
        return b

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

info.sort(key = lambda x: x[2])
info.reverse()

check = False
for cx in range(101): 
    for cy in range(101):
        high = info[0][2] + abs(info[0][0]-cx) + abs(info[0][1]-cy)
        if info[0][2] == 0:
            print(info[1000])
        temp = True
        for i in range(1,n):
            if info[i][2] != big(high-abs(info[i][0]-cx)-abs(info[i][1]-cy),0):
                temp = False
        if temp:
            check = True
            break
    if check:
        break
print(cx,cy,high)

Solution (Python):
n = int(input())
a = []
for i in range(n):
  x,y,h = map(int,input().split())
  a.append([x,y,h])
a.sort(key=lambda x:  -x[2])
def test(t,b,c):
  for k in a:
    if c - (abs(t - k[0]) + abs(b-k[1])) != k[2]:
      if (c - (abs(t - k[0]) + abs(b-k[1])) < 0 and k[2] == 0):
        continue
      else:
        return False
  return True
for i in range(101):
  for j in range(101):
    h = abs(i-a[0][0]) + abs(j - a[0][1]) + a[0][2]
    if test(i,j,h):
      print(i,j,h)
      exit()

Solution (Python):
import sys

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

for cx in range(100+1):
    for cy in range(100+1):
        x, y, h= coordinates[0]
        H = h + abs(x-cx) + abs(y-cy)
        i = 1
        for x, y, h in coordinates[1:]:
            if not h == max(H - abs(x-cx) - abs(y-cy), 0):
                break
            else:
                i += 1
                if i == N:
                    print(cx, cy, H)
                    sys.exit()

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

data=[]

for _ in range(N):
    x,y,h=map(int,input().split())
    data.append([x,y,h])
 
def test():
    for cx in range(101):
        for cy in range(101):
            
            for i in range(N):
                if data[i][2]:
                    temph=data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
                    flag=True
            
            for d in data:
                if d[2] != max(temph-abs(d[0]-cx)-abs(d[1]-cy),0):
                    flag=False
                    break
                
            if flag:
                print(cx,cy,temph)
                return
            
test()

Solution (Python):
n = int(input())
x = []
y = []
h = []
ot = []
for i in range(n):
    xi, yi, hi = [int(_) for _ in input().split()]
    if hi != 0:
        x.append(xi)
        y.append(yi)
        h.append(hi)
    else:
        ot.append([xi, yi, hi])

ans = []
for cxi in range(101):
    for cyi in range(101):
        flag = True
        for i in range(len(h)):
            if i == 0:
                height = h[i] + abs(x[i]-cxi) + abs(y[i]-cyi)
            else:
                if height != h[i] + abs(x[i]-cxi) + abs(y[i]-cyi):
                    flag = False
                    continue
        if flag:
            ans.append([cxi, cyi, height])

if len(ans) == 1:
    print(ans[0][0], ans[0][1], ans[0][2])
else:
    for a in ans:
        flag = True
        for o in ot:
            if max((a[2] - abs(o[0]-a[0]) - abs(o[1]-a[1])), 0) != o[2]:
                flag = False
                continue
        if flag:
            print(a[0], a[1], a[2])

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 
        
H = 1
if j == (-1):
    for cx in range(0,101):
        for cy in range(0,101):
            for i in range(N):
                H = min(H,(abs(x[i]-cx) + abs(y[i]-cy)))

            if H > 0:
                print("{0} {1} {2}".format(cx,cy,H))
                exit(0)

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)