Buggy python submission (verdict: Runtime Error):
from math import sqrt


def dfs(remains, elapsed, hx, hy):
    global crystals

    if not remains:
        return True

    remains_c = set()
    for i in remains:
        cx, cy, dfd = crystals[i]
        dfh = sqrt((cx - hx) ** 2 + (cy - hy) ** 2)
        new_elapsed = elapsed + dfh
        if dfd <= new_elapsed:
            return False
        remains_c.add((i, cx, cy, new_elapsed))

    for i, cx, cy, new_elapsed in remains_c:
        remains.discard(i)
        if dfs(remains, new_elapsed, cx, cy):
            return True
        remains.add(i)

    return False


while True:
    n, hx, hy, dx, dy = map(int, input().split())
    if n == 0: break

    crystals = [(cx, cy, sqrt((cx - dx) ** 2 + (cy - dy) ** 2)) for cx, cy in
                (map(int, input().split()) for _ in range(n))]

    print('YES' if dfs(set(range(n)), 0, hx, hy) else 'NO')

Fixed submission:
from math import sqrt


def dfs(remains, elapsed, hx, hy, prev):
    global crystals, dc

    if not remains:
        return True

    remains_c = set()
    for i in remains:
        cx, cy, dfd = crystals[i]
        new_elapsed = elapsed + dc[prev][i]
        if dfd <= new_elapsed:
            return False
        remains_c.add((i, cx, cy, new_elapsed))

    for i, cx, cy, new_elapsed in remains_c:
        remains.remove(i)
        if dfs(remains, new_elapsed, cx, cy, i):
            return True
        remains.add(i)

    return False


while True:
    n, hx, hy, dx, dy = map(int, input().split())
    if n == 0: break

    crystals_in = [tuple(map(int, input().split())) for _ in range(n)]
    crystals = [(cx, cy, sqrt((cx - dx) ** 2 + (cy - dy) ** 2)) for cx, cy in crystals_in]
    crystals_in += [(hx, hy)]
    dc = [[sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) for x2, y2 in crystals_in] for x1, y1 in crystals_in]

    print('YES' if dfs(set(range(n)), 0, hx, hy, n) else 'NO')

Buggy python submission (verdict: Runtime Error):
from math import sqrt


def dfs(remains, elapsed, hx, hy):
    global crystals

    if not remains:
        return True

    remains_c = set()
    for i in remains:
        cx, cy, dfd = crystals[i]
        new_elapsed = elapsed + sqrt((cx - hx) ** 2 + (cy - hy) ** 2)
        if dfd <= new_elapsed:
            return False
        remains_c.add((i, cx, cy, new_elapsed))

    for i, cx, cy, new_elapsed in remains_c:
        remains.remove(i)
        if dfs(remains, new_elapsed, cx, cy):
            return True
        remains.add(i)

    return False


while True:
    n, hx, hy, dx, dy = map(int, input().split())
    if n == 0: break

    crystals = [(cx, cy, sqrt((cx - dx) ** 2 + (cy - dy) ** 2))
                for cx, cy in (map(int, input().split()) for _ in range(n))]

    print('YES' if dfs(set(range(n)), 0, hx, hy) else 'NO')

Fixed submission:
from math import sqrt


def dfs(remains, elapsed, hx, hy, prev):
    global crystals, dc

    if not remains:
        return True

    remains_c = set()
    for i in remains:
        cx, cy, dfd = crystals[i]
        new_elapsed = elapsed + dc[prev][i]
        if dfd <= new_elapsed:
            return False
        remains_c.add((i, cx, cy, new_elapsed))

    for i, cx, cy, new_elapsed in remains_c:
        remains.remove(i)
        if dfs(remains, new_elapsed, cx, cy, i):
            return True
        remains.add(i)

    return False


while True:
    n, hx, hy, dx, dy = map(int, input().split())
    if n == 0: break

    crystals_in = [tuple(map(int, input().split())) for _ in range(n)]
    crystals = [(cx, cy, sqrt((cx - dx) ** 2 + (cy - dy) ** 2)) for cx, cy in crystals_in]
    crystals_in += [(hx, hy)]
    dc = [[sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) for x2, y2 in crystals_in] for x1, y1 in crystals_in]

    print('YES' if dfs(set(range(n)), 0, hx, hy, n) else 'NO')