Problem p02805 (python)

Fixed submission:
import numpy as np
N = int(input())
P = []
for n in range(N):
    x, y = map(int, input().split())
    P.append((x, y))


def dist(p0, p1):
    x0, y0, x1, y1 = p0[0], p0[1], p1[0], p1[1]
    return (x0 - x1) ** 2 + (y0 - y1) ** 2


def f(x, y):
    return max([dist(p, (x, y)) for p in P])


def minfx(y):
    left = 0
    right = 1000
    for _ in range(80):
        left_ = left * (2 / 3) + right * (1 / 3)
        right_ = left*(1/3)+right*(2/3)
        if f(left_, y) <= f(right_, y):
            right = right_
        else:
            left = left_
    x0 = (left + right) / 2
    return f(x0, y)


left = 0
right = 1000
for _ in range(80):
    left_ = left * (2 / 3) + right * (1 / 3)
    right_ = left*(1/3)+right*(2/3)
    if minfx(left_) <= minfx(right_):
        right = right_
    else:
        left = left_
y0 = (left + right) / 2
print(np.sqrt(minfx(y0)))

Buggy submission (verdict: Runtime Error):
class Circle():
    # 中心p、半径rの円
    def __init__(self, p, r):
        self.p = p
        self.r = r

    def contain(self, q):
        # 点qを含むか判定
        px, py = self.p
        qx, qy = q
        return (px-qx)**2+(py-qy)**2 <= self.r**2


def enclose(P):
    # 点のリストPの最小包含円
    n = len(P)
    if n == 2:
        ax, ay = P[0]
        bx, by = P[1]
        r = ((ax-bx)**2+(ay-by)**2)**0.5/2
        p = ((ax+bx)/2, (ay+by)/2)
        return Circle(p, r)
    if n == 3:
        p0, p1, p2 = P[0], P[1], P[2]
        circle0 = enclose([p1, p2])
        circle1 = enclose([p2, p0])
        circle2 = enclose([p0, p1])
        if circle0.contain(p0):
            circle = circle0
        elif circle1.contain(p1):
            circle = circle1
        elif circle2.contain(p2):
            circle = circle2
        else:
            p0x, p0y = p0
            p1x, p1y = p1
            p2x, p2y = p2
            A = p1x*p2x+p1y*p2y
            B = p2x*p0x+p2y*p0y
            C = p0x*p1x+p0y*p1y
            a = A*(B+C-A)
            b = B*(C+A-B)
            c = C*(A+B-C)
            px = (a*p0x+b*p1x+c*p2x)/(a+b+c)
            py = (a*p0y+b*p1y+c*p2y)/(a+b+c)
            r = ((px-p0x)**2+(py-p0y)**2)**0.5/2
            circle = Circle((px, py), r)
        return circle
    for i in range(n-2):
        for j in range(i, n-1):
            for k in range(j, n):
                circle = enclose([P[i], P[j], P[k]])
                if all([circle.contain(P[l]) for l in range(n)]):
                    return circle


n = int(input())
P = []
for i in range(n):
    x, y = map(int, input().split())
    P.append((x, y))
print(enclose(P).r)

Buggy submission (verdict: Runtime Error):
class Circle():
    # 中心p、半径rの円
    def __init__(self, p, r):
        self.p = p
        self.r = r

    def contain(self, q):
        # 点qを含むか判定
        px, py = self.p
        qx, qy = q
        return (px-qx)**2+(py-qy)**2 <= self.r**2


def enclose(P):
    # 点のリストPの最小包含円
    n = len(P)
    if n == 2:
        ax, ay = P[0]
        bx, by = P[1]
        r = ((ax-bx)**2+(ay-by)**2)**0.5/2
        p = ((ax+bx)/2, (ay+by)/2)
        return Circle(p, r)
    if n == 3:
        p0, p1, p2 = P[0], P[1], P[2]
        circle0 = enclose([p1, p2])
        circle1 = enclose([p2, p0])
        circle2 = enclose([p0, p1])
        if circle0.contain(p0):
            circle = circle0
        elif circle1.contain(p1):
            circle = circle1
        elif circle2.contain(p2):
            circle = circle2
        else:
            p0x, p0y = p0
            p1x, p1y = p1
            p2x.p2y = p2
            A = p1x*p2x+p1y*p2y
            B = p2x*p0x+p2y*p0y
            C = p0x*p1x+p0y*p1y
            a = A*(B+C-A)
            b = B*(C+A-B)
            c = C*(A+B-C)
            px = (a*p0x+b*p1x+c*p2x)/(a+b+c)
            py = (a*p0y+b*p1y+c*p2y)/(a+b+c)
            r = ((px-p0x)**2+(py-p0y)**2)**0.5/2
            circle3 = Circle((px, py), r)
            if circle3.r < circle.r:
                circle = circle3
        return circle
    for i in range(n-2):
        for j in range(i, n-1):
            for k in range(j, n):
                circle = enclose([P[i], P[j], P[k]])
                if all([circle.contain(P[l]) for l in range(n)]):
                    return circle


n = int(input())
P = []
for i in range(n):
    x, y = map(int, input().split())
    P.append((x, y))
print(enclose(P).r)