Problem p03240 (python)

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

print(C_x,C_y,H)

Buggy submission (verdict: Runtime Error):
N = int(input())
zahyou = [list(map(int,input().split())) for i in range(N)]

H = 1
C_x = 0
C_y = 0

def height(C_x,C_y,x,y,h):
  H = h + abs(x-C_x) + abs(y-C_y)
  return H

def koud(C_x,C_y,H,x,y):
  h = H - abs(x-C_x) - abs(y-C_y)
  return max(h,0)

flag = False
for i in range(0,101):
  C_x = i
  for j in range(0,101):
    C_y = j
    memo = []
    for k in range(N):
      if zahyou[k][2] == 0:#高度が0のとき
        memo.append[k]
        continue
      if len(memo) >= 1 :      
        if k == memo[len(memo)-1] + 1 :
          H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
        else:
          if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
            break
          else:
            continue
      else:
        if k == 0:
          H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
        else:
          if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
            break
          else:
            continue        
    else:
      for l in range(len(memo)):
        if H > abs(zahyou[l][0] - C_x) + abs(zahyou[l][1] - C_y):
          break
        else:
          continue
      else:
        flag = True
        break
    if flag:
      break
  if flag:
    break

print(C_x,C_y,H)

Buggy submission (verdict: Runtime Error):
N = int(input())
zahyou = [list(map(int,input().split())) for i in range(N)]

H = 1
C_x = 0
C_y = 0

def height(C_x,C_y,x,y,h):
  H = h + abs(x-C_x) + abs(y-C_y)
  return H

def koud(C_x,C_y,H,x,y):
  h = H - abs(x-C_x) - abs(y-C_y)
  return max(h,0)

flag = False
for i in range(0,101):
  C_x = i
  for j in range(0,101):
    C_y = j
    memo = []
    for k in range(N):
      if zahyou[k][2] == 0:#高度が0のとき
        memo.append[k]
        continue
      if k == 0 :
        H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
      else:
        if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
          break
        else:
          continue
    else:
      for l in range(len(memo)):
        if H > abs(zahyou[l][0] - C_x) + abs(zahyou[l][1] - C_y):
          break
        else:
          continue
      else:
        flag = True
        break
    if flag:
      break
  if flag:
    break

print(C_x,C_y,H)

Buggy submission (verdict: Runtime Error):
N = int(input())
zahyou = [list(map(int,input().split())) for i in range(N)]

H = 1
C_x = 0
C_y = 0

def height(C_x,C_y,x,y,h):
  H = h + abs(x-C_x) + abs(y-C_y)
  return H

def koud(C_x,C_y,H,x,y):
  h = H - abs(x-C_x) - abs(y-C_y)
  return max(h,0)
  
flag = False
for i in range(0,101):
  C_x = i
  for j in range(0,101):
    C_y = j
    memo = []
    for k in range(N):
      if zahyou[k][2] == 0:#高度が0のとき
        memo.append[k]
        continue
      if k == 0 :
        H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
      else:
        if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
          break
        else:
          continue
    else:
      for l in range(len(memo)):
        if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
          break
        else:
          continue
      else:
        flag = True
        break
    if flag:
      break
  if flag:
    break

print(C_x,C_y,H)