Problem p02805 (python)

Fixed submission:
import math
from itertools import combinations
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
def enclose(points):

    a = points[0]
    b = points[1]
    c = points[2]
    d = points[3]
    e = points[4]
    f = points[5]

    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f

    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

    r = math.hypot(px - a, py - b)

    return (px, py, r)


ans = 1000000

if n >= 3:
    for i, j, k in combinations(range(n), 3):
        points = []
        points.extend(p[i])
        points.extend(p[j])
        points.extend(p[k])
        try:
            px, py, r = enclose(points)
        except:
            continue
        flag = 1
        for l in range(n):
            if (px-p[l][0])**2 + (py-p[l][1])**2 > r**2 + 0.0000001:
                flag = 0
                break
        if flag == 1:
            ans = min(ans, r)

for i, j in combinations(range(n), 2):
    px = (p[i][0]+p[j][0]) / 2
    py = (p[i][1]+p[j][1]) / 2
    r = ((p[i][0] - px)**2 + (p[i][1] - py) ** 2) ** (1/2)
    flag = 1
    for l in range(n):
        if (px-p[l][0])**2 + (py-p[l][1])**2 > r**2 + 0.0000001:
            flag = 0
            break
    if flag == 1:
        ans = min(ans, r)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from itertools import combinations
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
def enclose(points):

    a = points[0]
    b = points[1]
    c = points[2]
    d = points[3]
    e = points[4]
    f = points[5]

    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f

    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

    r = math.hypot(px - a, py - b)

    return (px, py, r)


ans = 1000000

if n >= 3:
    for i, j, k in combinations(range(n), 3):
        points = []
        points.extend(p[i])
        points.extend(p[j])
        points.extend(p[k])
        try:
            px, py, r = enclose(points)
        except:
            continue
        flag = 1
        for l in range(n):
            if (px-p[l][0])**2 + (py-p[l][1])**2 > r**2+0.000001:
                flag = 0
                break
        if flag == 1:
            ans = min(ans, r)

for i, j in combinations(range(n), 2):
    px = (p[i][0]+p[j][0]) / 2
    py = (p[i][1]+p[j][1]) / 2
    rr = (p[i][0] - px)**2 + (p[i][1] - py) ** 2
    flag = 1
    for l in range(n):
        if (px-p[l][0])**2 + (py-p[l][1])**2 > rr + 0.0000001:
            flag = 0
            break
    if flag == 1:
        ans = min(ans, r)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from itertools import combinations
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
def enclose(points):

    a = points[0]
    b = points[1]
    c = points[2]
    d = points[3]
    e = points[4]
    f = points[5]

    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f

    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))

    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))

    r = math.hypot(px - a, py - b)

    return (px, py, r)


ans = 1000000

if n >= 3:
    for i, j, k in combinations(range(n), 3):
        points = []
        points.extend(p[i])
        points.extend(p[j])
        points.extend(p[k])
        try:
            px, py, r = enclose(points)
        except:
            continue
        flag = 1
        for l in range(n):
            if (px-p[l][0])**2 + (py-p[l][1])**2 > r**2-0.00001:
                flag = 0
                break
        if flag == 1:
            ans = min(ans, r)

for i, j in combinations(range(n), 2):
    px = (p[i][0]+p[j][0]) / 2
    py = (p[i][1]+p[j][1]) / 2
    rr = (p[i][0] - px)**2 + (p[i][1] - py) ** 2
    flag = 1
    for l in range(n):
        if (px-p[l][0])**2 + (py-p[l][1])**2 > r-0.00001:
            flag = 0
            break
    if flag == 1:
        ans = min(ans, r)

print(ans)