Problem p02805 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
xys = [inpl() for _ in range(N)]

if N == 2:
    x0,y0 = xys[0]
    x1,y1 = xys[1]
    print(math.sqrt((x1-x0)**2 + (y1-y0)**2)/2)
    sys.exit()


ans = INF
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            a,b = xys[i]
            c,d = xys[j]
            e,f = xys[k]

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

            try:
                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)
            except:
                if a == c == e:
                    px = a
                    py = (max(b,d,f) + min(b,d,f))/2
                    r = max(b,d,f) - min(b,d,f)
                elif b == d == f:
                    px = (max(a,c,e) + min(a,c,e))/2
                    py = b
                    r = max(a,c,e) - min(a,c,e)

            for x,y in xys:
                if (px-x)**2 +(py-y)**2 <= r**2 + eps:
                    continue
                else:
                    break
            else:
                ans = min(ans,r)


for i in range(N):
    for j in range(i+1,N):
        x0,y0 = xys[i]
        x1,y1 = xys[j]
        px = (x0+x1)/2
        py = (y0+y1)/2
        r = math.hypot(px - x0, py - y0)

        for x,y in xys:
            if (px-x)**2 +(py-y)**2 <= r**2 + eps:
                continue
            else:
                break
        else:
            ans = min(ans,r)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
xys = [inpl() for _ in range(N)]

if N == 2:
    x0,y0 = xys[0]
    x1,y1 = xys[1]
    print(math.sqrt((x1-x0)**2 + (y1-y0)**2)/2)


for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            a,b = xys[i]
            c,d = xys[j]
            e,f = xys[k]

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

            try:
                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)
            except:
                if a == c == e:
                    px = a
                    py = (max(b,d,f) + min(b,d,f))/2
                    r = max(b,d,f) - min(b,d,f)

            for x,y in xys:
                if (px-x)**2 +(py-y)**2 <= r**2 + eps:
                    continue
                else:
                    break
            else:
                print(r)
                sys.exit()

assert True