Problem p03240 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
information = [list(map(int, input().split())) for _ in range(n)]
information.sort(key=lambda x: x[2])

for c_x in range(101):
    for c_y in range(101):
        x, y, h = information[-1]
        H = h + abs(x - c_x) + abs(y - c_y)
        judge = 1
        for w in information[:-1]:
            x, y, h = w
            if h == max(0, H - abs(x - c_x) - abs(y - c_y)):
                continue
            else:
                judge -= 1
                break
        if judge:
            print(c_x, c_y, H)
            sys.exit()
        else:
            continue

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
information = [list(map(int, input().split())) for _ in range(n)]
information.sort(key=lambda x: x[2])


def calc(p, w):
    c_x, c_y = p
    x, y, h = w
    if h > 0:
        return h + abs(x-c_x) + abs(y-c_y)


def check(H, p, w):
    c_x, c_y = p
    x, y, h = w
    if h == max(0, H - abs(x - c_x) - abs(y - c_y)):
        return True
    else:
        return False


for i in range(101):
    for j in range(101):
        p = [i, j]
        H = calc(p, information[-1])
        judge = 1
        for w in information[:-1]:
            if check(H, p, w):
                continue
            else:
                judge -= 1
                break
        if judge:
            print(*p, H)
            sys.exit()
        else:
            continue

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
information = [list(map(int, input().split())) for _ in range(n)]
information.sort(key=lambda x: x[2])


def calc(p, w):
    c_x, c_y = p
    x, y, h = w
    if h > 0:
        return h + abs(x-c_x) + abs(y-c_y)


def check(H, p, w):
    c_x, c_y = p
    x, y, h = w
    if h == max(0, H - abs(x - c_x) - abs(y - c_y)):
        return True
    else:
        return False


for i in range(101):
    for j in range(101):
        p = [i, j]
        H = calc(p, information[-1])
        judge = 1
        for w in information[:-1]:
            if check(H, p, w):
                continue
            else:
                judge -= 1
                break
        if judge:
            print(*p, H)
            sys.exit()
        else:
            continue

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
information = [list(map(int, input().split())) for _ in range(n)]
information.sort(key=lambda x: x[2])


def calc(p, w):
    c_x, c_y = p
    x, y, h = w
    if h > 0:
        return h + abs(x-c_x) + abs(y-c_y)


def check(H, p, w):
    c_x, c_y = p
    x, y, h = w
    if h == max(0, H - abs(x - c_x) - abs(y - c_y)):
        return True
    else:
        return False


for i in range(101):
    for j in range(101):
        p = (i, j)
        H = calc(p, information[-1])
        judge = 1
        for w in information[:-1]:
            if check(H, p, w):
                continue
            else:
                judge -= 1
                break
        if judge:
            print(*p, H)
            sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
information = [list(map(int, input().split())) for _ in range(n)]
information.sort(key=lambda x: x[2])


def calc(p, w):
    c_x, c_y = p
    x, y, h = w
    if h > 0:
        return h + abs(x-c_x) + abs(y-c_y)


def check(H, p, w):
    c_x, c_y = p
    x, y, h = w
    if h == max(0, H - abs(x - c_x) - abs(y - c_y)):
        return True
    else:
        return False


for i in range(101):
    for j in range(101):
        p = (i, j)
        H = calc(p, information[-1])
        judge = 1
        for w in information[:-1]:
            if check(H, p, w):
                pass
            else:
                judge -= 1
                break
        if judge:
            print(*p, H)
            sys.exit()