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):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = [LI() for i in range(N)]
    
    for x in range(101):
        for y in range(101):
            max_num = float('inf')
            ans = 0
            res = True
            for xn, yn, hn in L:
                if hn == 0:
                    max_num = min(max_num, abs(x-xn)+abs(y-yn))
                    if max_num == 0:
                        res = False
                        break
                else:
                    temp = abs(x-xn)+abs(y-yn)+hn
                    if ans != 0 and ans != temp:
                        res = False
                        break
                    else:
                        ans = temp
            if (max_num >= 2 and ans == 0) or ans > max_num:
                res = False

            if res:
                if ans != 0:
                    print(x,y,ans)
                else:
                    print(x,y,1)
                exit()
    
    
    
if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
list_XYH1, list_XYH = [ list(map(int,input().split(" "))) for _ in range(n)], []
for x, y, h in list_XYH1:
    if h != 0:
        list_XYH.append([x, y, h])

for i in range(0, 101):
    for j in range(0, 101):
        cnt = 0
        x, y, h = list_XYH[0]
        H = h + abs(i - x) + abs(j - y)
        for x, y, h in list_XYH:
            if h + abs(i - x) + abs(j - y) == H:
                cnt += 1

        if cnt == len(list_XYH) and cnt != 0 and cnt != 1:
            print(i, j, H)
            exit()

list_XYH2 = []
m = pow(10, 10)
for x, y, h in list_XYH1:
    m = min(m, h)
    list_XYH2.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH2:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

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

test = [(x,y,h) for x,y,h in xyh if h > 0]
test = test[0]
for cx in range(101):
    for cy in range(101):
        
        x,y,h = test
        H = h + abs(x - cx) + abs(y - cy)

        
        if all([max(H - abs(x - cx) - abs(y - cy), 0) == h for x,y,h in xyh]):
            print(cx, cy, H)
            exit()

Solution (Python):
N = int(input())
Q = [list(map(int, input().split())) for _ in range(N)]
Q.sort(key=lambda x: x[2])
a, b, H = Q[-1]


def height(x, y, H, a, b):
    return max(H-abs(x-a)-abs(y-b), 0)


for i in range(101):
    for j in range(101):
        A = H+abs(i-a)+abs(j-b)
        B = height(a, b, H, i, j)
        f, g = True, True
        if not A:
            f = False
        if not B:
            g = False
        for k in range(N):
            x, y, h = Q[k]
            if height(i, j, A, x, y) != h:
                f = False
            if height(i, j, B, x, y) != h:
                g = False
            if not (f or g):
                break
        else:
            if f:
                print(i, j, A)
                exit()
            else:
                print(i, j, B)
                exit()

Solution (Python):
N=int(input())
hyx=[list(map(int,input().split()))[::-1]for _ in range(N)]
R=range(101)
for X in R:
    for Y in R:
        h,y,x=max(hyx)
        H=h+abs(X-x)+abs(Y-y)
        if all(h==max(H-abs(X-x)-abs(Y-y),0)for h,y,x in hyx):
            print(X,Y,H)

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

def check(cx, cy):
  H = None
  fin = []
  for i in info:
    x = i[0]
    y = i[1]
    h = i[2]
    if h != 0:
      tmpH = h + abs(x-cx) + abs(y-cy)
      if H:
        if H != tmpH:
          return 0
      else:
        H = tmpH
    else:
      fin.append((x, y, h))
  for f in fin:
    x = f[0]
    y = f[1]
    if H - abs(x-cx) -abs(y-cy) > 0:
      return 0
  return H
      

for cx in range(101):
  for cy in range(101):
    h = check(cx, cy)
    if h >= 1:
      print(cx)
      print(cy)
      print(h)
      break

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

xl = [0]*n
yl = [0]*n
hl = [0]*n


for i in range(n):
    xl[i], yl[i], hl[i] = map(int, input().split())
    if hl[i] >= 1:
        si = i

ansx, ansy, ansh = -1, -1, -1

for cx in range(101):
    for cy in range(101):
        H = hl[si]+abs(xl[si]-cx)+abs(yl[si]-cy)
        flag = True
        for i in range(n):
            hi = max(H-abs(xl[i]-cx)-abs(yl[i]-cy), 0)
            if hi != hl[i]:
                flag = False
                break
        if flag:
            ansx, ansy, ansh = cx, cy, H
print(ansx, ansy, ansh)

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

xl = [0]*n
yl = [0]*n
hl = [0]*n


for i in range(n):
    xl[i], yl[i], hl[i] = map(int, input().split())
    if hl[i] >= 1:
        si = i

ansx, ansy, ansh = -1, -1, -1

for cx in range(101):
    for cy in range(101):
        H = hl[si]+abs(xl[si]-cx)+abs(yl[si]-cy)
        flag = True
        for i in range(n):
            hi = max(H-abs(xl[i]-cx)-abs(yl[i]-cy), 0)
            if hi != hl[i]:
                flag = False
                break
        if flag:
            ansx, ansy, ansh = cx, cy, H
print(ansx, ansy, ansh)

Solution (Python):
N=int(input())
hyx=[list(map(int,input().split()))[::-1]for _ in range(N)]
R=range(101)
for X in R:
    for Y in R:
        h,y,x=max(hyx)
        H=h+abs(X-x)+abs(Y-y)
        if all(h==max(H-abs(X-x)-abs(Y-y),0)for h,y,x in hyx):
            print(X,Y,H)

Solution (Python):
N=int(input())
xyh=[list(map(int,input().split()))for _ in range(N)]
hxy=[[h,x,y]for x,y,h in xyh]
hxy.sort()
for X in range(101):
    for Y in range(101):
        h,x,y=hxy[-1]
        H=h+abs(X-x)+abs(Y-y)
        if all(h==max(H-abs(X-x)-abs(Y-y),0)for h,x,y in hxy):
            print(X,Y,H)

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

for i in range(101):
    for j in range(101):
        s = -1
        flag = True
        limit = float('inf')
        for x, y, h in xyh:
            if h != 0:
                H = h + abs(x-i) + abs(y-j)
                if s != -1:
                    if s != H:
                        flag = False
                        break
                s = H
            else:
                limit = min(limit, abs(x-i) + abs(y-j))
        if flag:
            if s != -1 and s <= limit:
                print(i, j, s)
                exit()
            elif s <= limit and limit == 1:
                print(i, j, 1)
                exit()

Solution (Python):
N = int(input()); INF = float("inf")
Z = []
S = set([])
for i in range(N):
  x,y,h = map(int,input().split())
  Z.append((x,y,h))
  S.add((x,y))
Z.sort(key=lambda x : x[2],reverse=True)

for i in range(101):
  for j in range(101):
    
    MAX = INF
    for t in range(N):
      
      if t == 0: 
        ans = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
      elif Z[t][2] == 0:
        MAX = min(MAX,abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2])
      else:
        temp = abs(i-Z[t][0])+abs(j-Z[t][1])+Z[t][2]
        if temp != ans:
          break
      if t != N-1: 
        continue
      
      if ans <= MAX:
        ret = [i,j,ans]
        print(*ret);exit()
      else:
        break

Solution (Python):
def resolve():
    n=int(input())
    xyh=[list(map(int,input().split())) for _ in range(n)]
    xyh.sort(key=lambda x:x[2],reverse=True)
    ans=[]
    for cx in range(101):
        for cy in range(101):
            x,y,h=xyh[0]
            ch=h+abs(x-cx)+abs(y-cy)
            if all([h==max(ch-abs(x-cx)-abs(y-cy),0) for x,y,h in xyh[1:]]):
                ans=[cx,cy,ch]
                break
    print(*ans)
resolve()

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

for cx in range(101):
    for cy in range(101):
        h = -1
        for i in range(n):
            if info[i][2] != 0:
                h = info[i][2] + abs(info[i][0] - cx) + abs(info[i][1] - cy)
                break
        ok = True
        for i in range(n):
            v = max(h - abs(info[i][0] - cx) - abs(info[i][1] - cy), 0)
            ok &= v == info[i][2]
        if ok:
            print(cx, cy, h)
            exit()

Solution (Python):
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array







sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


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



MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = [il() for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp_x, tmp_y, tmp_h = -1, -1, -1
            for x, y, h in xyh:
                
                
                if h == 0:
                    continue
                tmp_x, tmp_y = cx, cy
                tmp_h = h + abs(x - cx) + abs(y - cy)
                break

            if tmp_h != -1:
                
                
                for x, y, h in xyh:
                    if h != max(tmp_h - abs(x - tmp_x) - abs(y - tmp_y), 0):
                        break
                else:
                    print(tmp_x, tmp_y, tmp_h)
                    exit()


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array







sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


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



MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = [il() for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp_x, tmp_y, tmp_h = -1, -1, -1
            for x, y, h in xyh:
                
                
                if h == 0:
                    continue
                tmp_x, tmp_y = cx, cy
                tmp_h = h + abs(x - cx) + abs(y - cy)
                break

            if tmp_h != -1:
                
                
                for x, y, h in xyh:
                    if h != max(tmp_h - abs(x - tmp_x) - abs(y - tmp_y), 0):
                        break
                else:
                    print(tmp_x, tmp_y, tmp_h)
                    exit()


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array







sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


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



MOD = 998244353
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    xyh = [il() for _ in range(N)]

    for cx in range(0, 101):
        for cy in range(0, 101):
            tmp_x, tmp_y, tmp_h = -1, -1, -1
            for x, y, h in xyh:
                if h == 0:
                    continue
                tmp_x, tmp_y = cx, cy
                tmp_h = h + abs(x - cx) + abs(y - cy)
                break

            if tmp_h != -1:
                for x, y, h in xyh:
                    if h != max(tmp_h - abs(x - tmp_x) - abs(y - tmp_y), 0):
                        break
                else:
                    print(tmp_x, tmp_y, tmp_h)
                    exit()


if __name__ == '__main__':
    main()

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

for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        ch = h + abs(x - cx) + abs(y - cy)
        if all([h == max(ch - abs(x - cx) - abs(y - cy), 0) for x, y, h in xyh[1:]]):
            ans = [cx, cy, ch]
            break
print(*ans, sep=' ')

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

for cx in range(101):
    for cy in range(101):
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        done = True
        for xk, yk, hk in xyh:
            h_ = max(h - abs(xk - cx) - abs(yk - cy), 0)
            if h_ != hk:
                done = False
                break
        if done:
            print(f'{cx} {cy} {h}')

Solution (Python):










def solve(N, xyh):
    xyh.sort(reverse=True, key=lambda x: x[2])
    for X in range(101):
        for Y in range(101):
            H = xyh[0][2] + abs(X - xyh[0][0]) + abs(Y - xyh[0][1])
            for x, y, h in xyh:
                if h != max(0, H - abs(X - x) - abs(Y - y)):
                    break
            else:
                print(X, Y, H)
                return


if __name__ == '__main__':
    N = int(input())
    xyh = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, xyh)

Solution (Python):
def main():
    n = int(input())
    xyh = [list(map(int, input().split())) for _ in range(n)]
    xyh.sort(key = lambda x:x[2], reverse = True)
    x_ = xyh[0][0]
    y_ = xyh[0][1]
    h_ = xyh[0][2]
    for i in range(101):
        for j in range(101):
            top = h_ + abs(i - x_) + abs(j - y_)
            for x, y, h in xyh[1:]:
                h_2 = top - abs(i - x) - abs(j - y)
                if h != max(h_2, 0):
                    break
            else:
                print(i, j, top)
                return
                
main()

Solution (Python):
N=int(input())
x=[]
y=[]
h=[]
for _ in range(N):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
k=0
for i in range(N):
    if h[i]!=0:
        k=i
        break
for cx in range(101):
    for cy in range(101):
        H=h[k]+abs(x[k]-cx)+abs(y[k]-cy)
        for i in range(N):
            if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
                break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break

Solution (Python):
def main():
	N = int(input())
	info = []
	for i in range(N):
		x, y, h = [int(a) for a in input().split(" ")]
		info.append({"x": x, "y": y, "h": h})
	info.sort(key=lambda f: -f["h"])
	for cx in range(101):
		for cy in range(101):
			H = 0
			for i in range(len(info)):
				h = info[i]["h"] + abs(info[i]["x"] - cx) + abs(info[i]["y"] - cy)
				if i == 0:
					H = h
				else:
					if h != H:
						if (info[i]["h"] == 0 and h < H) or (info[i]["h"] > 0):
							break
			else:
				print(cx, cy, H)
				return 0
	if info[0]["x"] in [0, 100] and info[0]["y"] in [0, 100]:
		print(info[0]["x"], info[0]["y"], info[0]["h"])
		return 0

main()

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

for Cx in range(101):
    for Cy in range(101):
        criteria = -1
        ax, ay, ah = 0, 0, 0
        cnt = 0
        for x, y, h in xyh:
            if h == 0:
                continue
            H = h + abs(x - Cx) + abs(y - Cy)
            if H == criteria or criteria == -1:
                criteria = H
                ax, ay, ah = x, y, h
                cnt += 1
                continue
            else:
                break
        else:
            if cnt == 1:
                print(ax, ay, ah)
                exit()
            else:
                print(Cx, Cy, criteria)

Solution (Python):
N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
f = False
for x in range(101):
    for y in range(101):
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for i in range(N):
            if xyh[i][2] == 0 and H - abs(xyh[i][0]-x) - abs(xyh[i][1]-y) > 0:
                break
            if xyh[i][2] != 0 and H != abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]:
                break
        else:
            f = True
            break
    if f:
        break
print(x,y,H)

Solution (Python):
n=int(input())
high=[]
for _ in range(n):
  a=list(map(int,input().split()))
  high.append(a)
inf=float('inf')
  
for x in range(0,101):
  
  for y in range(0,101):
    highlimit=inf
    ans=-1
    ch=-1
    for hi1 in high:
      p,q,r=hi1
      g=r+abs(p-x)+abs(q-y)
      if r<=0:
        G=abs(p-x)+abs(q-y)
        if ans>G:
          ch+=1
          break
        if G<=highlimit:
          highlimit=G
        
        continue
      else:
        if g>highlimit:
          ch+=1
          break
        else:
          if ans!=-1 and ans!=g:
            ch+=1
            break
          else:
            ans=g
    
    if ans!=-1 and ch==-1:
      print(x,y,ans)
      exit()

Solution (Python):
def main():
	N = int(input())
	info = []
	for i in range(N):
		x, y, h = [int(a) for a in input().split(" ")]
		info.append({"x": x, "y": y, "h": h})
	info.sort(key=lambda f: -f["h"])
	for cx in range(101):
		for cy in range(101):
			H = 0
			for i in range(len(info)):
				h = info[i]["h"] + abs(info[i]["x"] - cx) + abs(info[i]["y"] - cy)
				if i == 0:
					H = h
				else:
					if h != H:
						if (info[i]["h"] == 0 and h < H) or (info[i]["h"] > 0):
							break
			else:
				print(cx, cy, H)
				return 0
	if info[0]["x"] in [0, 100] and info[0]["y"] in [0, 100]:
		print(info[0]["x"], info[0]["y"], info[0]["h"])
		return 0

main()

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush

sys.setrecursionlimit(10**7)
import math








INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())

def run():
    N = int(sysread())
    V = []
    x0, y0, h0 = None, None, None
    for _ in range(N):
        x,y,h = mapline()
        if h > 0 and x0 == None:
            x0, y0, h0 = x,y,h
        V.append((x, y, h))

    for x in range(0, 101):
        for y in range(0, 101):
            H = h0 + abs(x0-x) + abs(y0-y)
            done = True
            for xk, yk, hk in V:
                h_ = max(H - abs(xk-x) - abs(yk-y), 0)
                if h_ != hk:
                    done = False
                    break
            if done:
                print(f'{x} {y} {H}')
                return


if __name__ == "__main__":
    run()

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))



N=intput()
data1=[]
data2=[]
for _ in range(N):
    x,y,h=mint()
    if h>0:
        data1.append([x,y,h])
    else:
        data2.append([x,y])
for cx,cy in product(range(0,101),repeat=2):
    sup=INF
    for x,y in data2:
        sup=min(sup,abs(x-cx)+abs(y-cy))
    x,y,h=data1[0]
    H=abs(x-cx)+abs(y-cy)+h
    tmp=True
    for x,y,h in data1[1:]:
        if abs(x-cx)+abs(y-cy)+h!=H:
            tmp=False
            break
    if tmp and H<=sup:
        print(cx,cy,H)
        exit()

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    l = [i_list() for i in range(n)]

    L = []

    for i in l:
        if i[2] != 0:
            L.append(i)
    if len(L) == 1:
        print(" ".join(map(str, L[0])))
        exit()

    for x in range(101):
        for y in range(101):
            H = L[0][2] + abs(x-L[0][0]) + abs(y-L[0][1])
            flg = True
            for x1, y1, h1 in L[1:]:
                if h1 == 0:
                    pass
                if H != h1 + abs(x-x1) + abs(y-y1):
                    flg = False
                    break
            if flg == True:
                ans = [x,y]
    H = L[0][2] + abs(ans[0]-L[0][0]) + abs(ans[1]-L[0][1])
    print(" ".join(map(str, ans)) +" "+str(H))


if __name__=="__main__":
    main()

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

xl=[]
yl=[]
hl=[]



for i in range(n):
    xx,yy,hh=list(map(int,input().split()))
    xl.append(xx)
    yl.append(yy)
    hl.append(hh)

for cx in range(0,101):
    for cy in range(0,101):
        ok=True
        for i in range(n):
            x=xl[i]
            y=yl[i]
            h=hl[i]
            if h!=0:
                high = h + abs(x - cx) + abs(y - cy)
                break

        for i in range(n):
            x=xl[i]
            y=yl[i]
            h=hl[i]
            oh=max(high-abs(x-cx)-abs(y-cy),0)
            if h!=oh:
                ok=False
                break
        if ok:
            print(cx,cy,high)
            exit()

Solution (Python):


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


for cx in range(101):
    for cy in range(101):
        H = -1
        for _,cond in enumerate(conditions):
            if cond[2] > 0:
                H_tmp = cond[2] + abs(cond[0]-cx) + abs(cond[1]-cy)
                if H == -1:
                    H = H_tmp
                else:
                    if H_tmp != H:
                        H = -2
                        break

        if H == -2:
            continue

        for _,cond in enumerate(conditions):
            if cond[2] == 0:
                if H > abs(cond[0]-cx) + abs(cond[1]-cy):
                    H = -2
                    break
        
        if H == -2:
            continue
        
        print(cx,cy,H)

Solution (Python):
N = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(N)]
sXYH = sorted(XYH, key=lambda x:x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x, y, h = sXYH[0]
        H = h + abs(x-cx) + abs(y-cy)
        res = []
        for x, y, h in sXYH[1:]:
            temp = (h == max(H-abs(x-cx)-abs(y-cy), 0))
            res.append(temp)
        if all(res):
            print(cx, cy, H)
            exit()

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

xyhs = [list(map(int, input().split())) for _ in range(n)]
xyhs.sort(key=lambda i: i[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x, y, h = xyhs[0]
        ch = h + abs(cy - y) + abs(cx - x)

        if all([h == max(ch - abs(cy - y) - abs(cx - x), 0) for x, y, h in xyhs[1:]]):
            print(cx, cy, ch)
            exit()

Solution (Python):


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

N = int(input())
conditions = []
for i in range(N):
    x,y,h = map(int, input().split())
    if h > 0:
        conditions.append([x,y,h])

num_cnd = len(conditions)
if num_cnd==1:
    print(conditions[0][0],conditions[0][1],conditions[0][2])
    exit(0)

for cx in range(101):
    for cy in range(101):
        cnt = 0
        h = 0
        for i,cnd in enumerate(conditions):
            h_tmp = getH(cnd[0], cx, cnd[1], cy, cnd[2])
            if h_tmp >= 1:
                if i==0:
                    h = h_tmp
                    cnt += 1
                elif h == h_tmp:
                    cnt += 1
                    if cnt == num_cnd:
                        print(cx,cy,h)
                        exit(0)
                else:
                    break
            else:
                break
        

print('No')

Solution (Python):
from sys import stdin
input = stdin.buffer.readline

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

    
    for i in range(n):
        if h[i] > 0:
            ind = i
            break

    for cx in range(101):
        for cy in range(101):
            try:
                height = h[ind] + abs(x[ind] - cx) + abs(y[ind] - cy)
            except:
                
                height = 1

            flag = True
            for i in range(n):
                if h[i] == 0:
                    if height - abs(x[i] - cx) - abs(y[i] - cy) > 0:
                        flag = False
                        break
                else:
                    if height - abs(x[i] - cx) - abs(y[i] - cy) != h[i]:
                        flag = False
                        break
            if flag:
                print(cx, cy, height)
                exit()

main()

Solution (Python):

def resolve():
    N = int(input())
    P = [list(map(int, input().split())) for _ in range(N)]
    X, Y, H = zip(*P)

    
    
    
    for cx in range(101):
        for cy in range(101):
            h = 1
            for i in range(N):
                if H[i] > 0:
                    h = H[i] + abs(cx - X[i]) + abs(cy - Y[i])
            ok = True
            for i in range(N):
                res = max(h - abs(cx - X[i]) - abs(cy - Y[i]), 0)
                if res != H[i]:
                    ok = False
            if ok:
                print(cx, cy, h)
                return


if __name__ == "__main__":
    resolve()