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 = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

flag = False
for cx in range(101):
    for cy in range(101):
        needH = -1
        for i in range(N-1, -1, -1):
            if h[i] > 0:
                H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
                if needH == -1:
                    needH = H
                else:
                    if needH != H:
                        needH = -2
                        break
            else:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                
                if needH > dist:
                    needH = -2
                    break
                    
        if needH == -2:
            continue
        else:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

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

        if needH == -2:
            continue
        else:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

flag = False
for cx in range(101):
    for cy in range(101):
        needH = -1
        for i in range(N-1, -1, -1):
            if h[i] > 0:
                H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
                if needH == -1:
                    needH = H
                else:
                    if needH != H:
                        needH = -2
                        break
            else:
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                
                if needH > dist:
                    needH = -2
                    break
                    
        if needH == -2:
            continue
        else:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)

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())

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

Solution (Python):
def main():
    N = int(input())
    P = [None] * N
    x0, y0, h0 = 0, 0, 0
    for i in range(N):
        x, y, h = map(int, input().split())
        if h != 0 and h0 == 0:
            x0, y0, h0 = x, y, h
        P[i] = (x, y, h)
    for i in range(101):
        for j in range(101):
            H = h0 + abs(i-x0) + abs(j-y0)
            for x, y, h in P:
                dist = abs(i-x) + abs(j-y)
                if (h > 0 and dist != H-h) or (h == 0 and dist < H):
                    break
            else:
                print(i, j, H)
                return


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda val: val[2])
 
for cx in range(101):
    for cy in range(101):
        check = True
        H = xyh[-1][2] + abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)
        for x in xyh[:-1]:
            if x[2] != max(H - abs(x[0] - cx) - abs(x[1] - cy), 0):
                check = False
                break
        if check:
            print(cx, cy, H)
            exit()

Solution (Python):

import sys


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    X = 0
    Y = 0
    hh = 0
    for i in range(0, 101):
        for j in range(0, 101):
            H =  []
            s = 0
            for k in range(N):
                if h[k] > 0:
                    s += h[k]
                    H.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            if len(H) > 1 and len(list(set(H))) == 1:
                X, Y, hh = i, j, H[-1]
            elif len(H) == 1 and H[0] == s:
                X, Y, hh = i, j, H[0]

    print(X, Y, hh)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    x = [int()] * (N)  
    y = [int()] * (N)  
    h = [int()] * (N)  
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

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

for cx in range(101):
    for cy in range(101):
        check = True
        H = xyh[-1][2] + abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)
        for x in xyh[:-1]:
            if x[2] != max(H - abs(x[0] - cx) - abs(x[1] - cy), 0):
                check = False
                break
        if check:
            print(cx, cy, H)
            exit()

Solution (Python):
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
xyh.sort(key = lambda z: -z[2])
for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        H = h+abs(cx-x)+abs(cy-y)
        for x, y, h in xyh[1:]:
            _h = max(H-abs(cx-x)-abs(cy-y), 0)
            if h != _h:
                break
        else:
            print(cx, cy, H)
            exit()

Solution (Python):


n=int(input())

xyh=[]

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

xyh.sort(reverse=True)

for i in range(101):
    for j in range(101):
        
        H=xyh[0][0]+abs(xyh[0][1]-i)+abs(xyh[0][2]-j)
        for k in range(1,n):
            h,x,y=xyh[k]
            HH=h+abs(x-i)+abs(y-j)
            if H==HH or H-HH<0 and h==0:continue
            else:break
        else:
            print(*[i,j,H])
            exit()

Solution (Python):
N = int(input())
l = [list(map(int,input().split())) for i in range(N)]
l.sort(key = lambda x: x[2])
for x in range(101):
    for y in range(101):
        H = abs(x-l[-1][0])+abs(y-l[-1][1])+l[N-1][2]
        if all((l[i][2] == max(H-abs(x-l[i][0])-abs(y-l[i][1]),0) for i in range(N))):
            print(x,y,H)
            break
    else:
        continue
    break

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

X = [list(map(int,input().split())) for _ in range(N)]
X.sort(key=lambda X:-X[2])

count = 0
for i in range(101):
	for j in range(101):
		H = X[0][2] + abs(i-X[0][0]) + abs(j-X[0][1])

		for k in range(N):
			if X[k][2] == max(H-abs(i-X[k][0])-abs(j-X[k][1]),0):
				count += 1
		
		if count == N:
			print(i,j,H)
			break
		count = 0

Solution (Python):


import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0

m=0
while(h[m]==0):
	m+=1
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[m])
		distance+=abs(j-y[m])
		height=distance+h[m]
		for k in range(0,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(max(height-distance,0)!=h[k]):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()

Solution (Python):
N = int(input())
List = []
for i in range(N):
    List.append([int(a) for a in input().split()])

temp = []

for j in range(N):
    if List[j][2] > 0:
        ind = j
        break

for cx in range(101):
    for cy in range(101):
        H = List[ind][2] + abs(List[ind][0]-cx) + abs(List[ind][1]-cy)
        temp.append([cx,cy,H])
        
for k in range(len(temp)):
    num = 0
    for l in range(N):
        if List[l][2] == max(temp[k][2]-abs(List[l][0]-temp[k][0])-abs(List[l][1]-temp[k][1]),0):
            num += 1
        else:
            break
    if num == N:
        ans = k
        break
    
print("{} {} {}".format(temp[ans][0],temp[ans][1],temp[ans][2]))

Solution (Python):

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

for cx in range(101):
    for cy in range(101):
        for i in li:
            if i[2] != 0:
                ans.append([cx, cy, i[2] + abs(i[0]-cx) + abs(i[1] -cy)])
                break

for i in li:
    if len(ans) ==1:
        break
    if i[2] != 0:
        for j in reversed (range(len(ans[:]))):
            if ans[j][2] - abs(i[0]-ans[j][0]) - abs(i[1]-ans[j][1]) != i[2]:
                ans.pop(j)
    if i[2] == 0:
        for j in reversed (range(len(ans[:]))):
            if ans[j][2] - abs(i[0]-ans[j][0]) - abs(i[1]-ans[j][1]) > i[2]:
                ans.pop(j)

print(" ".join(map(str, ans[0])))

Solution (Python):
N = int(input())
learn = []
verify = []
for i in range(N):
    a = tuple(map(int, input().split()))
    if a[2] > 0 and learn == []:
        learn.append(a)
    else:
        verify.append(a)

for Cx in range(101):
    for Cy in range(101):
        H = learn[0][2] + abs(learn[0][0] - Cx) + abs(learn[0][1] - Cy)
        right = True
        for v in verify:
            if max(H - abs(v[0] - Cx) - abs(v[1] - Cy), 0) != v[2]:
                right = False
                break
        else:
            break
        continue
    else:
        continue
    break

print(Cx, Cy, H)

Solution (Python):
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)
  if h > 0:
    x_, y_, h_ = x, y, h

for px in range(101):
  for py in range(101):
    H_ = h_ + abs(px-x_) + abs(py-y_)
    for i in range(N):
      if H[i] != max(H_ - abs(px-X[i]) - abs(py-Y[i]), 0):
        break
    else:
      print(px, py, H_)
      exit()

Solution (Python):
N = int(input())
X = []
Y = []
H = []
xc = None
yc = None
hc = None
for _ in range(N):
    x, y, h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h > 0:
        xc = x
        yc = y
        hc = h

for pos_x in range(101):
    for pos_y in range(101):
        center_h = hc + abs(xc - pos_x) + abs(yc - pos_y)

        flag = True
        for n in range(N):
            if H[n] != max(center_h - abs(X[n] - pos_x) - abs(Y[n] - pos_y), 0):
                flag = False
                break
        if flag:
            print(pos_x, pos_y, center_h)
            exit()

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

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

for i in range(101):
	for j in range(101):
		for k in range(n):
			if x[k][2]>0:
				h=x[k][2]+abs(i-x[k][0])+abs(j-x[k][1])
				break
		chk=0
		for k in range(n): 
			if x[k][2]!=max(h-abs(i-x[k][0])-abs(j-x[k][1]),0):
				chk=1
				break
		if chk==0:
			res=[i,j,h]
			break
	if chk==0:
		break

print(*res)

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

v=[]
count=0


for i in range(101):
    for j in range(101):
        x=abs(j-z[0][0])
        y=abs(i-z[0][1])
        h=z[0][2]+abs(x)+abs(y)
                
            
        for k in range(n):
            if z[k][2]==max(h-abs(z[k][0]-j)-abs(z[k][1]-i),0):
                count+=1
                
        if count==n:
            print(j,i,h)
            exit()
        count=0

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

xi, yi, hi = None, None, None
for x, y, h in xyh:
    if h > 0:
        xi, yi, hi = x, y, h
        break

for cx in range(101):
    for cy in range(101):
        H = hi + abs(xi - cx) + abs(yi - cy)
        matched = True
        for x, y, h in xyh:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                matched = False
                break
        if matched:
            print(cx, cy, H)
            exit(0)

Solution (Python):
def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    a0 = list(filter(lambda aa: aa[2] > 0, a))[0]

    for i in range(101):
        for j in range(101):
            is_ok = True
            h_ans = a0[2] + abs(a0[0] - i) + abs(a0[1] - j)
            for x, y, h in a:
                if max(h_ans - abs(x - i) - abs(y - j), 0) != h:
                    is_ok = False
                    break
            if is_ok:
                break
        if is_ok:
            break

    print(i, j, h_ans)


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 cx in range(0,101):
    for cy in range(0,101):
        formerH = 0
        H = 0
        flag = 0
        for i in range(n):
            x = l[i][0]
            y = l[i][1]
            h = l[i][2]
            if i == 0:
                formerH = 0
            else:
                formerH = H
            if h == 0:
                if max(H-abs(x-cx)-abs(y-cy),0) != 0:
                    break
            else:         
                H = abs(x-cx)+abs(y-cy)+h
                if i > 0 and H != formerH:
                    break
            if i == n-1:
                a_cx = cx
                a_cy = cy
                a_H = H
                flag = 1
                break
        if flag == 1:
            break
    if flag == 1:
        break

if flag == 1:
    print(a_cx,a_cy,a_H)

Solution (Python):
def larger(x, y):
	if x > y:
		return x
	return y

N = int(input())
lst = []
for i in range(0, N):
	x, y, h = map(int, input().split())
	lst.append([x, y, h])
lst.sort(key = lambda v: v[2], reverse = True)
for i in range(0, 101):
	flag1 = False
	for j in range(0, 101):
		H = lst[0][2] + abs(lst[0][0]-i) + abs(lst[0][1]-j)
		flag2 = True
		for k in range(1, N):
			if larger(H-abs(lst[k][0]-i)-abs(lst[k][1]-j), 0) != lst[k][2]:
				flag2 = False
				break
		if flag2:
			print(str(i)+' '+str(j)+' '+str(H))
			flag1 = True
			break
	if flag1:
		break

Solution (Python):
n = int(input())
l = []
for i in range(n):
    x, y, h = map(int, input().split())
    l.append([x, y, h])
l.sort(reverse=True, key=lambda x: x[2])
for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        for pyx, pyy, pyh in l:
            if pyh != max(height - abs(x - pyx) - abs(y - pyy), 0):
                break
        else:
            print(x, y, height)
            exit()

Solution (Python):
n,*xyh=map(int,open(0).read().split())
x=xyh[0::3]
y=xyh[1::3]
h=xyh[2::3]

hmax_i = h.index(max(h))
for cx in range(101):
    for cy in range(101):
        H = abs(cx-x[hmax_i]) + abs(cy-y[hmax_i]) + h[hmax_i]
        for i in range(0,n):
            if max(H-abs(cx-x[i])-abs(cy-y[i]),0) == h[i]:
                if i == n-1:
                    print(cx,cy,H)
                    exit()
                else:
                    continue
            else:
                break

Solution (Python):
n,*xyh=map(int,open(0).read().split())
x=xyh[0::3]
y=xyh[1::3]
h=xyh[2::3]

for cx in range(101):
    for cy in range(101):
        hmax_i = h.index(max(h))
        H = abs(cx-x[hmax_i]) + abs(cy-y[hmax_i]) + h[hmax_i]
        for i in range(0,n):
            if max(H-abs(cx-x[i])-abs(cy-y[i]),0) == h[i]:
                if i == n-1:
                    print(cx,cy,H)
                    exit()
                else:
                    continue
            else:
                break

Solution (Python):
N = int(input())
XYH = [list(map(int, input().split())) for _ in range(N)]
H_list= [XYH[i][2] for i in range(N)]
H_max = max(H_list)
H_min = min(H_list)
H_diff = H_max - H_min
ans = []


for H in range(H_max - (200 - H_diff), H_max + (201 - H_diff)):
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            count = 0
            for X, Y, h in XYH:
                if h == max(H - abs(X - Cx) - abs(Y - Cy), 0):
                    count += 1
                else:
                    break

            if count == N:
                ans = [str(Cx), str(Cy), str(H)]

print(' '.join(ans))

Solution (Python):



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

maxh = 0
for x,y,h in xyh:
    maxh = max(maxh,h)
for H in range(maxh,maxh+201):
    for cx in range(101):
        for cy in range(101):
            for x,y,h in xyh:
                if h != max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print(cx,cy,H)
                quit()

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

def hight(inp):
    cx,cy,x,y,h=inp
    if h==0:
        return -1
    else:
        return abs(x-cx)+abs(y-cy)+h
    
for cx in range(101):
    for cy in range(101):
        H=set()
        for i in range(n):
            h=hight([cx,cy]+a[i])
            if h!=-1:
                H.add(h)
        if len(H)==1:
            flg=True
            for i in H:
                d=i
            for i in range(n):
                x,y,h=a[i]
                if max(0,d-abs(x-cx)-abs(y-cy))!=h:
                    flg=False
            if flg:
                ans=cx,cy,d
print(*ans)

Solution (Python):
def solve():
    cands = []
    for cx in range(100 + 1):
        for cy in range(100 + 1):
            is_center = True
            temp_h = -1
            for x, y, h in m:
                if h != 0:
                    calc_h = h + abs(cx - x) + abs(cy - y)
                    if temp_h == -1:
                        temp_h = calc_h
                    else:
                        if temp_h != calc_h:
                            is_center = False
                            break
            if is_center:
                cands.append((cx, cy, temp_h))

    for cx, cy, temp_h in cands:
        is_answer = True
        for x, y, h in m:
            if h == 0:
                if temp_h - abs(cx - x) - abs(cy - y) > 0:
                    
                    is_answer = False
                    break
        if is_answer:
            return cx, cy, temp_h

    return -1, -1, -1


n = int(input())
m = tuple(tuple(map(int, input().split())) for _ in range(n))
print(*solve())

Solution (Python):
N = int(input())
p = [[] for i in range(N)]

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

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

ok = False
for cx in range(101):
    for cy in range(101):
        x, y, h = p[0]
        H = h + abs(cx - x) + abs(cy - y)
        ok = True
        for i in range(1, N):
            x, y, h = p[i]
            if h != max(H - abs(cx - x) - abs(cy - y), 0):
                ok = False
                break
        if ok:
            print(cx, cy, H)
            break
    if ok:
        break

Solution (Python):
import numpy as np
n = int(input())
xyhl = [list(map(int, input().split())) for _ in range(n)]
xyhl1 = [xyh for xyh in xyhl if xyh[2] != 0]
xyhl0 = [xyh for xyh in xyhl if xyh[2] == 0]

tmaps = np.zeros((101, 101, len(xyhl1)), dtype="int64")
for d in range(len(xyhl1)) :
    for i in range(101) :
        for j in range(101) :
            x, y, h = xyhl1[d]
            tmaps[i, j, d] = abs(x-i)+abs(y-j)+h

tmap0 = np.zeros((101, 101, len(xyhl0)), dtype="int64")
for d in range(len(xyhl0)) :
    for i in range(101) :
        for j in range(101) :
            x, y, h = xyhl0[d]
            tmap0[i, j, d] = abs(x-i)+abs(y-j)+h

dmaps = np.diff(tmaps, axis=2)
xmap = np.logical_or.reduce(dmaps, axis=2)
place = np.where(np.logical_not(xmap))

for i, j in zip(place[0],place[1]) :
    for t in tmap0[i, j, :].flat :
        if tmaps[i, j, 0] > t :
            break
    else :
        ans = [i, j, tmaps[i, j, 0]]

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Solution (Python):
from operator import itemgetter
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=itemgetter(2))
x, y, h = xyh[-1][0], xyh[-1][1], xyh[-1][2]

for px in range(101):
    for py in range(101):
        ph = h + abs(px - x) + abs(py - y) 
        ok = True
        for x, y, h in xyh:
            if h > 0 and ph - h != abs(px - x) + abs(py - y): 
                ok = False
            if h == 0 and ph > abs(px - x) + abs(py - y):     
                ok = False

        if ok:
            print(str(px) + " " + str(py) + " " + str(ph))

Solution (Python):
def height(x, y ,h, Cx, Cy):
    return h + abs(x - Cx) + abs(y - Cy)


N = int(input())
lst_xyh = [tuple(map(int, input().split())) for _ in range(N)]
for Cx in range(101):
    for Cy in range(101):
        for x, y, h in lst_xyh:
            if h != 0:
                H = height(x, y, h, Cx, Cy)
                break
        for x, y, h in lst_xyh:
            if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                break
        else:
            print(Cx, Cy, H)
            exit()

Solution (Python):
N = int(input())
info = [0] * N
ans = [0]*3
for i in range(N):
    info[i] = [0] * 3
    info[i][0], info[i][1], info[i][2] = map(int, input().split())

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

height = [0] * 101
for x_kouho in range(101):
    height[x_kouho] = [0]*101
    for y_kouho in range(101):
        height[x_kouho][y_kouho] = info[0][2] + \
            abs(info[0][0] - x_kouho) + abs(info[0][1] - y_kouho)
        for p in range(N):
            if info[p][2] != max(0, (height[x_kouho][y_kouho] - abs(info[p][0] - x_kouho) - abs(info[p][1] - y_kouho))):
                break
            if p == N - 1:
                if 0 <= height[x_kouho][y_kouho]:
                    print("{} {} {}".format(
                        x_kouho, y_kouho, height[x_kouho][y_kouho]))
                    exit()

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    l = sorted(
        [tuple(map(int, input().rstrip().split())) for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    for x in range(0, 101):
        for y in range(0, 101):
            i, j, k = l[0]
            h = k + abs(i - x) + abs(j - y)
            for i, j, k in l[1:]:
                if k != max(h - abs(i - x) - abs(j - y), 0):
                    break
            else:
                print(x, y, h)
                return


if __name__ == "__main__":
    main()

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    l = sorted(
        [tuple(map(int, input().rstrip().split())) for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    for x in range(0, 101):
        for y in range(0, 101):
            i, j, k = l[0]
            h = k + abs(i - x) + abs(j - y)
            for i, j, k in l[1:]:
                if k != max(h - abs(i - x) - abs(j - y), 0):
                    break
            else:
                print(x, y, h)
                break
        else:
            continue
        break


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
x=[]
y=[]
h=[]
for i in range(n):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
max_h = h.index(max(h))
for cx in range(0,101):
    for cy in range(0,101):
        flag = True
        high = h[max_h] + abs(x[max_h]-cx) + abs(y[max_h]-cy)
        for i in range(n):
            if h[i]==0:
                if high-abs(x[i]-cx)-abs(y[i]-cy)>0:
                    flag=False
            else:
                if high != abs(x[i]-cx)+abs(y[i]-cy)+h[i]:
                    flag=False
        if flag:
            print(cx,cy,high)
            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())

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      flg =True
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(y[k]-j)
        if max(H-dx-dy,0)!=h[k]:
          flg = False
      if flg:
        print(i,j,H)
        exit()
  H +=1

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

for i in range(101):
  for j in range(101):
    h = li[0][2] + abs(i-li[0][0]) + abs(j-li[0][1])
    for k in range(1,n):
      if li[k][2] != max(0,h - abs(i-li[k][0]) -abs(j-li[k][1])):
        break
    else:
      print("{} {} {}".format(i,j,h))
      exit()

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

if len(pyr) == 1:
    print(*pyr[0])
    exit()

for i in range(101):
    for j in range(101):
        cx, cy = (i, j)
        h_list = []
        for k in range(len(pyr)):
            x, y, h = pyr[k]
            h_list.append(h + abs(x - cx) + abs(y - cy))
        if len(set(h_list)) != 1:
            continue
        else:
            print(cx, cy, h_list[0])
            exit()

Solution (Python):
n = int(input())
a = []
h = []
for i in range(n):
    arr= list(map(int,input().split()))
    h.append(arr[2])
    a.append(arr)
l = [i for i in a if i[2]>0]
xt = l[0][0]
yt = l[0][1]
ht = l[0][2] 
for i in range(101):
    for j in range(101):
        h_ans = ht+abs(xt-i)+abs(yt-j)    
        if all(max(h_ans-abs(l[0]-i)-abs(l[1]-j),0) == l[2] for l in a):
            print(i,j,h_ans)
            exit()

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

def f(Cx,Cy,x,y,H):
    return max(H-abs(x-Cx)-abs(y-Cy),0)

for Cx in range(101):
    for Cy in range(101):
        H = 0
        flag = 1
        for i in range(N):
            x, y, h = table[i]
            if h > 0:
                H = h + abs(x-Cx) + abs(y-Cy)
                break
        for i in range(N):
            x, y, h = table[i]
            if f(Cx,Cy,x,y,H) != h:
                flag = 0
                break

        if flag:
            print(Cx,Cy,H)
            exit()

Solution (Python):
import sys
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh.sort(key=lambda x: -x[2])
for cx in range(101):
    for cy in range(101):
        good = True
        h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
        for i in range(n):
            if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
                good = False
                break
        if good:
            print(cx, cy, h)
            sys.exit()

Solution (Python):
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh.sort(key=lambda x: -x[2])
for cx in range(101):
  for cy in range(101):
    good = True
    h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
    for i in range(n):
      if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
        good = False
        break
    if good:
      print(cx, cy, h)
      exit()

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

for i in range(N):
    if para[i][2] >= 1 :
        test = i 
        break
for c_x in range(0,101):
    for c_y in range(0,101):
        H = para[test][2] + abs(para[test][0]-c_x) + abs(para[test][1]-c_y)
        flag = True
        for i in range(N):
            if para[i][2] == max(H - abs(para[i][0]-c_x) - abs(para[i][1]-c_y),0) :
                    continue

            flag = False 
        if flag and H >=1:        
            print("{} {} {}".format(c_x,c_y,H))
            exit()

Solution (Python):
N = int(input())
x, y, h = zip(*(map(int, input().split()) for _ in range(N)))
def solve():
    for Cx in range(100 + 1):
        for Cy in range(100 + 1):
            for i in range(N):
                if h[i] > 0:
                    H = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy)
                    break
            if all(map(lambda i: h[i] == max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0), range(N))):
                print(Cx, Cy, H)
                return
solve()