Problem p02805 (python)

Fixed submission:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def check(x0,y0,p,r):
    for x,y in p:
        if (x-x0)**2 + (y-y0)**2 > r*r + 10 ** (-9):
            return False
    return True


def main():
    eps = 10 ** (-10)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    dist = lambda x1,y1,x2,y2: math.sqrt((x1-x2)**2 + (y1-y2)**2)
    N = NI()
    p = [LI() for _ in range(N)]

    high = 1000
    low = 0

    while high > low + 10 ** (-8):
        mid = (high + low) / 2

        for (x1,y1),(x2,y2) in itertools.combinations(p,2):
            r = dist(x1,y1,x2,y2) / 2
            if r > mid :
                low = mid
                break

            x0 = (x1+x2) / 2
            y0 = (y1+y2) / 2
            h = math.sqrt(mid**2 - r**2)
            if y1 == y2:
                dx = 0
                dy = h
            else:
                d = -(x1-x2) / (y1-y2)
                v = math.sqrt(1+d*d)
                dx = h / v
                dy = h / v * d
            if check(x0+dx,y0+dy,p,mid) or check(x0-dx,y0-dy,p,mid):
                high = mid
                break
        else:
            low = mid

    print(low)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def check(x0,y0,p,r):
    for x,y in p:
        if (x-x0)**2 + (y-y0)**2 > r*r:
            return False
    return True


def main():
    eps = 10 ** (-9)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    dist = lambda x1,y1,x2,y2: math.sqrt((x1-x2)**2 + (y1-y2)**2)
    N = NI()
    p = [LI() for _ in range(N)]

    high = 1000
    low = 0

    while high > low + 10 ** (-8):
        mid = (high + low) / 2

        for (x1,y1),(x2,y2) in itertools.combinations(p,2):
            r = dist(x1,y1,x2,y2) / 2
            if r > mid + eps:
                low = mid
                break

            x0 = (x1+x2) / 2
            y0 = (y1+y2) / 2
            h = math.sqrt(mid**2 - r**2)
            if y1 == y2:
                dx = 0
                dy = h / 2
                yi2 = y0 - h / 2
            else:
                d = -(x1-x2) / (y1-y2)
                v = math.sqrt(1+d*d)
                dx = h / 2 / v
                dy = h / 2 / v * d
            if check(x0 + dx,y0 + dy,p,mid) or check(x0 - dx,y0 - dy,p,mid):
                high = mid
                break
        else:
            low = mid

    print(low)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def check(x0,y0,p,r):
    for x,y in p:
        if (x-x0)**2 + (y-y0)**2 > r*r:
            return False
    return True


def main():
    eps = 10 ** (-9)
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    dist = lambda x1,y1,x2,y2: math.sqrt((x1-x2)**2 + (y1-y2)**2)
    N = NI()
    p = [LI() for _ in range(N)]

    high = 1000 / 2
    low = 0

    while high > low + 10 ** (-7):
        mid = (high + low) / 2

        for (x1,y1),(x2,y2) in itertools.combinations(p,2):
            r = dist(x1,y1,x2,y2) / 2
            if r > mid + eps:
                low = mid
                break

            x0 = (x1+x2) / 2
            y0 = (y1+y2) / 2
            h = math.sqrt(mid**2 - r**2)
            if y1 == y2:
                xi1 = xi2 = x0
                yi1 = y0 + h / 2
                yi2 = y0 - h / 2
            else:
                d = -(x1-x2) / (y1-y2)
                v = math.sqrt(1+d*d)
                dx = h / 2 / v
                dy = h / 2 / v * d
                xi1 = x0 + dx
                yi1 = y0 + dy
                xi2 = x0 - dx
                yi2 = y0 - dy
            if check(xi1,yi1,p,mid) or check(xi2,yi2,p,mid):
                high = mid
                break
        else:
            low = mid

    print(low)


if __name__ == '__main__':
    main()