Problem p03240 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
xyh = [input() for _ in range(n)]
#print(xyh)
for x_ in range(101):
    for y_ in range(101):
        cur_h = 0 #flga の場所をループの中に入れない
        for i in range(n):
            x = int(xyh[i].split()[0])
            y = int(xyh[i].split()[1])
            h = int(xyh[i].split()[2])
            h_ = h + (abs(x_ - x) + abs(y_ - y))
            if cur_h == 0 and h > 0:
                cur_h = h_  #決め打ちの高さ        
            else:
                if h > 0:
                    if cur_h != h_: break
                elif cur_h -(abs(x_ - x) + abs(y_ - y)) > 0: break
        for i in range(n):
            x = int(xyh[i].split()[0])
            y = int(xyh[i].split()[1])
            h = int(xyh[i].split()[2])
            h_ = h + (abs(x_ - x) + abs(y_ - y))
            if cur_h == 0 and h > 0:
                cur_h = h_  #決め打ちの高さ        
            else:
                if h > 0:
                    if cur_h != h_: break
                elif cur_h -(abs(x_ - x) + abs(y_ - y)) > 0: break   
                if i == n-1: 
                    print(x_,y_,cur_h)
                    #print("hello")
                    exit(0)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
  n = int(input())
  x,y,z = [0]*n,[0]*n,[0]*n
  # ３点h>=に点があれば一意に求まる
  count = 0
  xyh = [[],[],[]]
  #print(xyh)
  for i in range(n):
    x[i],y[i],z[i] = map(int,input().split())
    #if z[i] != 0 and count < 3:
    if z[i] != 0:
      xyh[count].append(x[i])
      xyh[count].append(y[i])
      xyh[count].append(z[i])
      #print(xyh)
      count += 1
  #print(xyh)
  x,y,h = 0,0,0
  pass_ = 0
  #print(count)
  for i in range(101):
    for j in range(101): # x,y の座標を定める
      h = abs(i-xyh[0][0])+abs(j-xyh[0][1]) + xyh[0][2]
      for k in range(count):
        if h - abs(i-xyh[k][0])-abs(j-xyh[k][1]) - xyh[k][2] == 0:
          if k == count -1:
            print(i,j,h)
            exit(0)
        else:
          break

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
  n = int(input())
  x,y,z = [0]*n,[0]*n,[0]*n
  # ３点h>=に点があれば一意に求まる
  count = 0
  xyh = [[],[],[]]
  #print(xyh)
  for i in range(n):
    x[i],y[i],z[i] = map(int,input().split())
    #if z[i] != 0 and count < 3:
    if z[i] != 0:
      xyh[count].append(x[i])
      xyh[count].append(y[i])
      xyh[count].append(z[i])
      #print(xyh)
      count += 1
  #print(xyh)
  x,y,h = 0,0,0
  pass_ = 0
  #print(count)
  for i in range(101):
    for j in range(101): # x,y の座標を定める
      h = abs(i-xyh[0][0])+abs(j-xyh[0][1]) + xyh[0][2]
      for k in range(count):
        if h - abs(i-xyh[k][0])-abs(j-xyh[k][1]) - xyh[k][2] == 0:
          if k == count -1:
            print(i,j,h)
            exit(0)
        else:
          break
      
      
      '''if count == 3:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 and h - abs(i-xyh[2][0])-abs(j-xyh[2][1]) - xyh[2][2] == 0:
          pass_ = 1
          x,y = i,j
          break
      
      if count == 2:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 :
          pass_ = 1
          x,y = i,j
          break
      if count == 1:
        pass_ == 1
    if pass_ == 1:
      break''' 
  #print(x,y,h)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
  n = int(input())
  x,y,z = [0]*n,[0]*n,[0]*n
  # ３点h>=に点があれば一意に求まる
  count = 0
  xyh = [[],[],[]]
  #print(xyh)
  for i in range(n):
    x[i],y[i],z[i] = map(int,input().split())
    #if z[i] != 0 and count < 3:
    if z[i] != 0:
      xyh[count].append(x[i])
      xyh[count].append(y[i])
      xyh[count].append(z[i])
      #print(xyh)
      count += 1
  #print(xyh)
  x,y,h = 0,0,0
  pass_ = 0
  #print(count)
  for i in range(101):
    for j in range(101): # x,y の座標を定める
      h = abs(i-xyh[0][0])+abs(j-xyh[0][1]) + xyh[0][2]
      for k in range(count):
        if h - abs(i-xyh[k][0])-abs(j-xyh[k][1]) - xyh[k][2] == 0:
          if k == count -1:
            print(i,j,h)
            exit(0)
        else:
          break
      
      
      '''if count == 3:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 and h - abs(i-xyh[2][0])-abs(j-xyh[2][1]) - xyh[2][2] == 0:
          pass_ = 1
          x,y = i,j
          break
      
      if count == 2:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 :
          pass_ = 1
          x,y = i,j
          break
      if count == 1:
        pass_ == 1
    if pass_ == 1:
      break''' 
  #print(x,y,h)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
  n = int(input())
  x,y,z = [0]*n,[0]*n,[0]*n
  # ３点h>=に点があれば一意に求まる
  count = 0
  xyh = [[],[],[]]
  #print(xyh)
  for i in range(n):
    x[i],y[i],z[i] = map(int,input().split())
    if z[i] != 0 and count < 3:
      xyh[count].append(x[i])
      xyh[count].append(y[i])
      xyh[count].append(z[i])
      #print(xyh)
      count += 1
  #print(xyh)
  x,y,h = 0,0,0
  pass_ = 0
  for i in range(101):
    for j in range(101): # x,y の座標を定める
      h = abs(i-xyh[0][0])+abs(j-xyh[0][1]) + xyh[0][2]
      if count == 3:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 and h - abs(i-xyh[2][0])-abs(j-xyh[2][1]) - xyh[2][2] == 0:
          pass_ = 1
          x,y = i,j
          break
      
      if count == 2:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 :
          pass_ = 1
          x,y = i,j
          break
	  if count == 1:
        pass_ = 1
    if pass_ == 1:
      break 
  print(x,y,h)