Problem:
 Score : 600 points    Problem Statement Given are N points (x_i, y_i) in a two-dimensional plane.  Find the minimum radius of a circle such that all the points are inside or on it.      Constraints  2 \leq N \leq 50  0 \leq x_i \leq 1000  0 \leq y_i \leq 1000  The given N points are all different.  The values in input are all integers.         Input Input is given from Standard Input in the following format:  N  x_1  y_1  :  x_N  y_N       Output Print the minimum radius of a circle such that all the N points are inside or on it.  Your output will be considered correct if the absolute or relative error from our answer is at most 10^{-6} .        Sample Input 1 2
0 0
1 0      Sample Output 1 0.500000000000000000  Both points are contained in the circle centered at (0.5,0) with a radius of 0.5 .       Sample Input 2 3
0 0
0 1
1 0      Sample Output 2 0.707106781186497524       Sample Input 3 10
10 9
5 9
2 0
0 0
2 7
3 3
2 5
10 0
3 7
1 9      Sample Output 3 6.726812023536805158  If the absolute or relative error from our answer is at most 10^{-6} , the output will be considered correct.

Solution (Python):
n = int(input())

p = []
for _ in range(n):
    x, y = map(int, input().split())
    p.append((x, y))

c = []

for i in range(n-1):
    for j in range(i+1, n):
        c.append([(p[i][0] + p[j][0]) / 2, (p[i][1] + p[j][1]) / 2])

for i in range(n-2):
    x = p[i][0] + p[i][1] * 1j
    for j in range(i+1, n-1):
        y = p[j][0] + p[j][1] * 1j
        for k in range(j+1, n):
            z = p[k][0] + p[k][1] * 1j
            a = y - x
            b = z - x
            if a.real * b.imag == a.imag * b.real:
                continue
            C = a * b * (a.conjugate() - b.conjugate()) / (b * a.conjugate() - a * b.conjugate())
            C = C + x
            c.append([C.real, C.imag])

ans = float('inf')
for X, Y in c:
    temp = 0
    for x, y in p:
        temp = max(((X-x)**2 + (Y-y)**2) ** 0.5, temp)
    ans = min(ans, temp)

print(ans)

Solution (Python):
def f_enf_enclose_all_ternary_search(ITER=100):
    from math import hypot
    N = int(input())
    Pos = [[int(i) for i in input().split()] for j in range(N)]

    def f(x, y):
        """N 個の点をすべて囲む円のうち，中心が (x, y) で半径が最小の円の半径"""
        return max(hypot(px - x, py - y) for px, py in Pos)

    def g(x):
        left, right = -1000.0, 1000.0
        for _ in range(ITER):
            m1 = (left * 2 + right) / 3
            m2 = (left + right * 2) / 3
            if f(x, m1) > f(x, m2):
                left = m1
            else:
                right = m2
        return f(x, left)

    left, right = -1000.0, 1000.0
    for _ in range(ITER):
        m1 = (left * 2 + right) / 3
        m2 = (left + right * 2) / 3
        if g(m1) > g(m2):
            left = m1
        else:
            right = m2
    return round(g(left), 10)

print(f_enf_enclose_all_ternary_search())

Solution (Python):
def f_enclose_all():
    
    from itertools import combinations
    N = int(input())
    Pos_complex = [complex(*map(int, input().split())) for j in range(N)]  

    def find_circumcenter(z0, z1, z2):
        """複素数で表現される3点に対し，それらの外心を求める"""
        z1 -= z0
        z2 -= z0  

        if abs((z1 * z2.conjugate()).imag) < 0.5:
            return None  

        numerator = z1 * z2 * (z1 - z2).conjugate()
        denominator = z1.conjugate() * z2 - z1 * z2.conjugate()
        return (numerator / denominator) + z0

    
    candidate = [(z1 + z2) / 2 for z1, z2 in combinations(Pos_complex, 2)]
    
    candidate.extend([find_circumcenter(*comb) for comb in combinations(Pos_complex, 3)])

    
    ans = min((max(abs(z - c) for z in Pos_complex) for c in candidate if c is not None))
    return round(ans, 10)

print(f_enclose_all())

Solution (Python):
from scipy.optimize import*
from numpy import*
n=int(input())
l=array([list(map(int,input().split()))for i in range(n)])
def f(a):
    return ((l-a)**2).sum(1).max()**0.5
print(minimize(f,[0,0],method="Nelder-Mead",tol=1e-9).fun)

Solution (Python):
import math

def calc_max_distance(guess_x,guess_y,data):
    max_distance = 0
    for x,y in data:
        distance = math.sqrt((guess_x-x)**2 + (guess_y-y)**2)
        max_distance = max(max_distance,distance)
    
    return max_distance



EPS = pow(10,-9)

def iterate(x,data):
    left = 0.0
    right = 1000.0
    while (right-left) > EPS:
        left_mid = left + (right-left)/3
        right_mid = right - (right-left)/3
        if calc_max_distance(x,left_mid,data) > calc_max_distance(x,right_mid,data):
            left = left_mid
        else:
            right = right_mid
            
    return calc_max_distance(x,left,data)
    


def outer_iterate(data):
    left = 0.0
    right = 1000.0
    while (right-left) > EPS:
        left_mid = left + (right-left)/3
        right_mid = right - (right-left)/3
        if iterate(left_mid,data) > iterate(right_mid,data):
            left = left_mid
        else:
            right = right_mid
            
    return iterate(left,data)


    
    




n = int(input())

data = []

for _ in range(n):
    a,b = map(int,input().split())
    data.append([a,b])



        
print (outer_iterate(data))

Solution (Python):

def cir(x1, y1, x2, y2, x3, y3):
    """
    3点を通る円の中心と半径を取得
    """
    d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
    if d==0:
        return None
    x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / (1.0*d)
    y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / (-d*1.0)
    r = ((x - x1) ** 2 + (y - y1) ** 2)**0.5
    return [[x, y], r]
n=int(input())
l=[]
for i in range(n):
    l.append(list(map(float,input().split())))
ans=10**10
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i<j<k:
                z=cir(l[i][0],l[i][1],l[j][0],l[j][1],l[k][0],l[k][1])
                if z:
                    f=0
                    x=z[0][0]
                    y=z[0][1]
                    r=z[1]
                    for m in l:
                        if ((m[0]-x)**2+(m[1]-y)**2)**0.5<=r:
                            f+=1
                    if f==n:
                        ans=min(ans,r)
def cir2(p,q):
    x1=p[0]
    y1=p[1]
    x2=q[0]
    y2=q[1]
    return [(x1+x2)*0.5,(y1+y2)*0.5,(((x1-x2)**2+(y1-y2)**2)**0.5)*0.5]
for i in range(n):
    for j in range(n):
        if i<j:
            z=cir2(l[i],l[j])
            x=z[0]
            y=z[1]
            r=z[2]
            f=0
            for m in l:
                if ((x-m[0])**2+(y-m[1])**2)**0.5<=r:
                    f+=1
            if f==n:
                ans=min(ans,r)
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def main():
    n=II()
    xy=[LI() for _ in range(n)]
    sx=sy=1000
    bx=by=0
    for x,y in xy:
        if x<sx:sx=x
        if x>bx:bx=x
        if y<sy:sy=y
        if y>by:by=y
    x0=(sx+bx)/2
    y0=(sy+by)/2
    m=100
    roop=10000
    for _ in range(roop):
        maxd=0
        for x,y in xy:
            d=(x-x0)**2+(y-y0)**2
            if d>maxd:
                maxd=d
                vx=x-x0
                vy=y-y0
        rate=m/(vx**2+vy**2)**0.5
        x0+=vx*rate
        y0+=vy*rate
        m*=0.998
    print(maxd**0.5)

main()

Solution (Python):
import sys
input=sys.stdin.readline
import math
rt=math.sqrt
eps=10**(-6)
n=int(input())
XY=[]
for i in range(n):
  XY.append(tuple(map(int,input().split())))

def dist2(xy1,xy2):
  return (xy1[0]-xy2[0])**2+(xy1[1]-xy2[1])**2

def dist1(xy1,xy2):
  return rt(dist2(xy1,xy2))

def center(xy1,xy2,xy3):
  den=(xy1[0]-xy2[0])*(xy2[1]-xy3[1])-(xy1[1]-xy2[1])*(xy2[0]-xy3[0])
  if den==0:
    if dist2(xy1,xy2)>=dist2(xy2,xy3):
      if dist2(xy1,xy2)>=dist2(xy3,xy1):
        return [(xy1[0]+xy2[0])/2,(xy1[1]+xy2[1])/2,dist1(xy1,xy2)/2]
      else:
        return [(xy3[0]+xy1[0])/2,(xy3[1]+xy1[1])/2,dist1(xy3,xy1)/2]
    else:
      if dist2(xy2,xy3)>=dist2(xy3,xy1):
        return [(xy2[0]+xy3[0])/2,(xy2[1]+xy3[1])/2,dist1(xy2,xy3)/2]
      else:
        return [(xy3[0]+xy1[0])/2,(xy3[1]+xy1[1])/2,dist1(xy3,xy1)/2]

  else:  
    retx1=(xy1[0]**2+xy1[1]**2)-(xy2[0]**2+xy2[1]**2)
    rety1=(xy2[0]**2+xy2[1]**2)-(xy3[0]**2+xy3[1]**2)
  
    retx2=(xy2[1]-xy3[1])*retx1-(xy1[1]-xy2[1])*rety1
    rety2=(xy3[0]-xy2[0])*retx1+(xy1[0]-xy2[0])*rety1
  
  
    retx3,rety3=retx2/2/den,rety2/2/den
    retr=dist1([retx3,rety3],xy1)
    return [retx3,rety3,retr]

ans=float("inf")
import itertools
for a,b in itertools.combinations(XY,2):
  x,y,r=center(a,b,b)
  chk=True
  for xy in XY:
    if dist1([x,y],xy)>r+eps:
      chk=False
  if chk:
    ans=min(ans,r)

if n>=3:
  for a,b,c in itertools.combinations(XY,3):
    x,y,r=center(a,b,c)
    chk=True
    for xy in XY:
      if dist1([x,y],xy)>r+eps:
        chk=False
    if chk:
      ans=min(ans,r)
print(ans)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
[最小包含円]
中心座標(x,y)をx座標,y座標それぞれについて三分探索.
"""
n = I()
xy = [LI() for _ in range(n)]

def d(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

def f(x,y):
    res = 0
    for x1,y1 in xy:
        res = max(res,d(x,y,x1,y1))
    return res

def g(x):
    l,r = 0,1000
    for _ in range(80):
        a = (l*2+r)/3
        b = (l+r*2)/3
        if f(x,a) > f(x,b):
            l = a
        else:
            r = b
    return f(x,l)

l,r = 0,1000
for _ in range(80):
    a = (l*2+r)/3
    b = (l+r*2)/3
    if g(a) > g(b):
        l = a
    else:
        r = b
print(g(l))

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
xy = [LI() for _ in range(n)]

def d(x1,y1,x2,y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

def f(x,y):
    res = 0
    for x1,y1 in xy:
        res = max(res,d(x,y,x1,y1))
    return res

def g(x):
    l,r = 0,1000
    for _ in range(80):
        a = (l*2+r)/3
        b = (l+r*2)/3
        if f(x,a) > f(x,b):
            l = a
        else:
            r = b
    return f(x,l)

l,r = 0,1000
for _ in range(80):
    a = (l*2+r)/3
    b = (l+r*2)/3
    if g(a) > g(b):
        l = a
    else:
        r = b
print(g(l))

Solution (Python):
EPS = 10**(-10)

N = int(input())
points = [list(map(float,input().split())) for _ in range(N)]

def dist(p0,p1):
    x0,y0 = p0
    x1,y1 = p1
    return ((x1-x0)**2+(y1-y0)**2)**0.5

def canMakeRectangle(p0,p1,p2):
    x0,y0 = p0
    x1,y1 = p1
    x2,y2 = p2
    if abs((y1-y0)*(x2-x0)-(y2-y0)*(x1-x0))<EPS:
        return False
    else:
        return True

def circumcircle(p0,p1,p2):
    x0,y0 = p0
    x1,y1 = p1
    x2,y2 = p2
    l0,l1,l2 = dist(p1,p2),dist(p2,p0),dist(p0,p1)
    r = l0*l1*l2/(((l0+l1+l2)*(-l0+l1+l2)*(l0-l1+l2)*(l0+l1-l2))**0.5)
    a = ((l0**2)*(l1**2+l2**2-l0**2)*x0+(l1**2)*(l2**2+l0**2-l1**2)*x1+(l2**2)*(l0**2+l1**2-l2**2)*x2)/((l0**2)*(l1**2+l2**2-l0**2)+(l1**2)*(l2**2+l0**2-l1**2)+(l2**2)*(l0**2+l1**2-l2**2))
    b = ((l0**2)*(l1**2+l2**2-l0**2)*y0+(l1**2)*(l2**2+l0**2-l1**2)*y1+(l2**2)*(l0**2+l1**2-l2**2)*y2)/((l0**2)*(l1**2+l2**2-l0**2)+(l1**2)*(l2**2+l0**2-l1**2)+(l2**2)*(l0**2+l1**2-l2**2))
    return r,a,b

def circle(p0,p1):
    x0,y0 = p0
    x1,y1 = p1
    r = dist(p0,p1)/2
    a = (x1-x0)/2+x0
    b = (y1-y0)/2+y0
    return r,a,b

def check(c,P):
    r,a,b = c
    for p in P:
        if dist((a,b),p) > r+EPS:
            return False
    return True

ans = float('inf')

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if canMakeRectangle(points[i],points[j],points[k]):
                r,a,b = circumcircle(points[i],points[j],points[k])
                if check((r,a,b),points):
                    ans = min(ans,r)

for i in range(N-1):
    for j in range(i+1,N):
        r,a,b = circle(points[i],points[j])
        if check((r,a,b),points):
            ans = min(ans,r)

print(ans)

Solution (Python):
import math


def main():
    N = int(input())
    points = []
    for i in range(N):
        x, y = [int(s) for s in input().split()]
        points.append((x, y))

    l = 0
    r = 1000
    for i in range(80):
        c1 = (l * 2 + r) / 3
        c2 = (l + r * 2) / 3
        if g(points, c1) > g(points, c2):
            l = c1
        else:
            r = c2
    print(g(points, l))


def g(points, x):
    l = 0
    r = 1000
    for i in range(80):
        c1 = (l * 2 + r) / 3
        c2 = (l + r * 2) / 3
        if f(points, x, c1) > f(points, x, c2):
            l = c1
        else:
            r = c2
    return f(points, x, l)


def f(points, x, y):
    max_distance = 0
    for i in range(len(points)):
        d = distance(x, y, float(points[i][0]), float(points[i][1]))
        if d > max_distance:
            max_distance = d

    return max_distance


def distance(x1, y1, x2, y2):
    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)


if __name__ == "__main__":
    main()

Solution (Python):
def f_enclose_all():
    
    from itertools import combinations
    N = int(input())
    Pos = [[int(i) for i in input().split()] for j in range(N)]
    Pos_complex = [x + y * 1j for x, y in Pos]  

    def find_circumcenter(z0, z1, z2):
        """複素数で表現される3点に対し、それらの外心を求める"""
        z1 -= z0
        z2 -= z0  

        if abs((z1 * z2.conjugate()).imag) < 0.5:
            
            
            
            
            
            
            return None  

        numerator = z1 * z2 * (z1 - z2).conjugate()
        denominator = z1.conjugate() * z2 - z1 * z2.conjugate()
        return (numerator / denominator) + z0

    candidate = []
    
    for comb in combinations(Pos_complex, 3):
        o = find_circumcenter(*comb)
        if o is not None:
            candidate.append(o)

    
    for z1, z2 in combinations(Pos_complex, 2):
        candidate.append((z1 + z2) / 2)

    
    ans = float('inf')
    for c in candidate:
        radius = 0
        for z in Pos_complex:
            radius = max(radius, abs(z - c))
        ans = min(ans, radius)
    return round(ans, 10)

print(f_enclose_all())

Solution (Python):
from math import hypot

MAX = 1000

n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]

def dist(x1, y1, x2, y2):
    return hypot(x1 - x2, y1 - y2)

def maxDist(x, y):
    res = 0
    for xx, yy in a:
        res = max(res, dist(x, y, xx, yy))
    return res

def f(x):
    left, right = 0, MAX
    for _ in range(80):
        y1 = (left * 2 + right) / 3
        y2 = (left + right * 2) / 3
        if maxDist(x, y1) > maxDist(x, y2):
            left = y1
        else:
            right = y2
    return maxDist(x, left)

left, right = 0, MAX
for _ in range(80):
    x1 = (left * 2 + right) / 3
    x2 = (left + right * 2) / 3
    if f(x1) > f(x2):
        left = x1
    else:
        right = x2
print(f(left))

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1
EPS = sys.float_info.epsilon

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

def min_circle(XY):

    def cross(a, b):
        return a.real * b.imag - a.imag * b.real

    def cnv_img(XY):
        return [x + y*1j for x, y in XY]

    def make_circle(a, b):
        c = (a + b) / 2
        r2 = abs(a-c)**2
        return c, r2

    def make_circle3(a, b, c):
        A = abs(b - c)**2
        B = abs(c - a)**2
        C = abs(a - b)**2
        S = cross(b - a, c - a)
        p = (A * (B + C - A) * a + B * (C + A - B)
             * b + C * (A + B - C) * c) / (4 * S * S)
        r2 = abs(p-a)**2
        return p, r2

    def in_circle(p, c, r2):
        return abs(p-c)**2 <= r2 + EPS


    P = cnv_img(XY)
    random.shuffle(P)
    p1 = P[0]
    p2 = P[1]
    c, r2 = make_circle(p1, p2)

    for i in range(2, len(P)):
        if in_circle(P[i], c, r2):
            continue
        c, r2 = make_circle(P[0], P[i])
        for j in range(1, i):
            if in_circle(P[j], c, r2):
                continue
            c, r2 = make_circle(P[i], P[j])
            for k in range(j):
                if not in_circle(P[k], c, r2):
                    c, r2 = make_circle3(P[i], P[j], P[k])
    return c, r2


@mt
def slv(N, XY):
    _, r2 = min_circle(XY)
    return math.sqrt(r2)


def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()

Solution (Python):
def get_center_and_radius(x1, y1, x2, y2, x3, y3):
    if (y2-y1)*(x3-x1)==(y3-y1)*(x2-x1):
        return -1, -1, -1
        
    d = 2*(x1-x2)*(y1-y3)-2*(x1-x3)*(y1-y2)
    cx = ((x1**2-x2**2+y1**2-y2**2)*(y1-y3)-(x1**2-x3**2+y1**2-y3**2)*(y1-y2))/d
    cy = ((x1**2-x3**2+y1**2-y3**2)*(x1-x2)-(x1**2-x2**2+y1**2-y2**2)*(x1-x3))/d
    r2 = (x1-cx)**2+(y1-cy)**2
    
    return cx, cy, r2
    
def is_inclusive(cx, cy, r2):
    for xi, yi in xy:
        if (xi-cx)**2+(yi-cy)**2>r2+1e-10:
            return False
    
    return True
    
N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]
R2 = 10**18

for i in range(N):
    for j in range(i+1, N):
        xi, yi = xy[i]
        xj, yj = xy[j]
        cx, cy = (xi+xj)/2, (yi+yj)/2
        r2 = (cx-xi)**2+(cy-yi)**2
        
        if is_inclusive(cx, cy, r2):
            R2 = min(R2, r2)

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            xi, yi = xy[i]
            xj, yj = xy[j]
            xk, yk = xy[k]
            cx, cy, r2 = get_center_and_radius(xi, yi, xj, yj, xk, yk)
            
            if cx==-1:
                continue
            
            if is_inclusive(cx, cy, r2):
                R2 = min(R2, r2)

print(R2**0.5)

Solution (Python):
import math
N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
p=[]
for i in range(N):
    x[i],y[i]=map(int,input().split())
    p.append((x[i],y[i]))
def dist(p,q):
    a,b=p
    c,d=q
    return math.sqrt((a-c)**2+(b-d)**2)
def check(R):
    Q=[]
    for i in range(N):
        for j in range(i+1,N):
            d=dist(p[i],p[j])/2
            if R<d:
                return False
            h=math.sqrt(R*R-d*d)
            
            nx,ny=(x[j]-x[i],y[j]-y[i])
            nr=math.sqrt(nx**2+ny**2)
            dx,dy=h*nx/nr,h*ny/nr
            mx,my=(x[i]+x[j])/2,(y[i]+y[j])/2
            
            
            Q.append((mx+dy,my-dx))
            Q.append((mx-dy,my+dx))
    
    for pa in Q:
        flag=1
        for i in range(N):
            
            if dist(pa,p[i])>R+9e-7:
                flag=0
                break
        if flag==1:
            return True
    return False

low=0
high=2000
for line in range(50):
    mid=(low+high)/2
    if check(mid):
        high=mid
    else:
        low=mid
print(mid)

Solution (Python):
import math
N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]
p=[]
for i in range(N):
    x[i],y[i]=map(int,input().split())
    p.append((x[i],y[i]))
def dist(p,q):
    a,b=p
    c,d=q
    return math.sqrt((a-c)**2+(b-d)**2)
def check(R):
    Q=[]
    for i in range(N):
        for j in range(i+1,N):
            d=dist(p[i],p[j])/2
            if R<d:
                return False
            h=math.sqrt(R*R-d*d)
            
            nx,ny=(x[j]-x[i],y[j]-y[i])
            nr=math.sqrt(nx**2+ny**2)
            dx,dy=h*nx/nr,h*ny/nr
            mx,my=(x[i]+x[j])/2,(y[i]+y[j])/2
            
            
            Q.append((mx+dy,my-dx))
            Q.append((mx-dy,my+dx))
    
    for pa in Q:
        flag=1
        for i in range(N):
            
            if dist(pa,p[i])>R+9e-7:
                flag=0
                break
        if flag==1:
            return True
    return False

low=0
high=2000
for line in range(50):
    mid=(low+high)/2
    if check(mid):
        high=mid
    else:
        low=mid
print(mid)

Solution (Python):
N = int(input())
X = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append((x, y))

def circumcenter(p, q, r):
    a, b = p
    c, d = q
    e, f = r
    a, b, c, d = a-e, b-f, c-e, d-f
    g = a * d-b * c
    if p == q: return ((p[0]+r[0]) / 2, (p[1]+r[1]) / 2)
    if g == 0: return (0, 0)
    ab = a * a + b * b
    cd = c * c + d * d
    return ((d * ab - b * cd) / (2 * g) + e, (a * cd - c * ab) / (2 * g) + f)

mi = 2000000
for i, p in enumerate(X):
    for j, q in enumerate(X[i:]):
        for r in X[j+1:]:
            a, b = circumcenter(p, q, r)
            mi = min(mi, max([(x-a)**2+(y-b)**2 for x, y in X]))

print(mi ** 0.5)

Solution (Python):
import itertools

N = int(input())
XY = [tuple(map(int,input().split())) for _ in range(N)]

def get_circle_center_and_radius(x1, y1, x2, y2, x3, y3):
  d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
  x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
  y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / -d
  r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
  return x, y, r

def check_line(x1,y1,x2,y2,x3,y3):
  if x1 == x2 == x3:
    return True
  elif y1 == y2 == y3:
    return True
  elif (y2-y1)*(x3-x1) == (y3-y1)*(x2-x1):
    return True
  else:
    return False

def check_r(x,y,r):
  res = True
  for i in range(N):
    x1,y1 = XY[i]
    if ((x-x1)**2+(y-y1)**2)**0.5 > r:
      res = False
      break
  return res

mnr = float('inf')

for i,j in list(itertools.combinations(range(N),2)):
  x1,y1 = XY[i]
  x2,y2 = XY[j]
  x = (x1+x2)/2
  y = (y1+y2)/2
  r = (((x2-x1)**2+(y2-y1)**2)**0.5)/2
  if check_r(x,y,r) and mnr > r:
    mnr = r    

for i,j,k in list(itertools.combinations(range(N),3)):
  x1,y1 = XY[i]
  x2,y2 = XY[j]
  x3,y3 = XY[k]
  if check_line(x1,y1,x2,y2,x3,y3):
    continue
  x,y,r = get_circle_center_and_radius(x1,y1,x2,y2,x3,y3)
  if check_r(x,y,r) and mnr > r:
    mnr = r

print(mnr)

Solution (Python):
import itertools

N = int(input())
XY = [tuple(map(int,input().split())) for _ in range(N)]

def get_circle_center_and_radius(x1, y1, x2, y2, x3, y3):
  d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
  x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
  y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / -d
  r = ((x - x1) ** 2 + (y - y1) ** 2) ** 0.5
  return x, y, r

def check_line(x1,y1,x2,y2,x3,y3):
  if x1 == x2 == x3:
    return True
  elif y1 == y2 == y3:
    return True
  elif (y2-y1)*(x3-x1) == (y3-y1)*(x2-x1):
    return True
  else:
    return False

def check_r(x,y,r):
  res = True
  for i in range(N):
    x1,y1 = XY[i]
    if ((x-x1)**2+(y-y1)**2)**0.5 > r:
      res = False
      break
  return res

mnr = float('inf')
for i in range(N-1):
  for j in range(i+1,N):
    x1,y1 = XY[i]
    x2,y2 = XY[j]
    x = (x1+x2)/2
    y = (y1+y2)/2
    r = (((x2-x1)**2+(y2-y1)**2)**0.5)/2
    if check_r(x,y,r) and mnr > r:
      mnr = r    

for i,j,k in list(itertools.combinations(range(N),3)):
  x1,y1 = XY[i]
  x2,y2 = XY[j]
  x3,y3 = XY[k]
  if check_line(x1,y1,x2,y2,x3,y3):
    continue
  x,y,r = get_circle_center_and_radius(x1,y1,x2,y2,x3,y3)
  if check_r(x,y,r) and mnr > r:
    mnr = r

print(mnr)

Solution (Python):
from math import sin

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

def dist(x, y, u, v):
    return ((x - u)**2 + (y - v)**2)**0.5

ans = 10**10

for i in range(N):
    for j in range(i + 1, N):
        
        xi, yi = XY[i]
        xj, yj = XY[j]
        cx = (xi + xj) / 2
        cy = (yi + yj) / 2
        d = 0
        for x, y in XY:
            d = max(d, dist(x, y, cx, cy))
        ans = min(ans, d)

        for k in range(j + 1, N):
            xi, yi = XY[i]
            xj, yj = XY[j]
            xk, yk = XY[k]
            c = dist(xi, yi, xj, yj)
            a = dist(xj, yj, xk, yk)
            b = dist(xk, yk, xi, yi)

            
            S = a**2 * (b**2 + c**2 - a**2) + b**2 * (c**2 + a**2 - b**2) + c**2 * (a**2 + b**2 - c**2)
            if S == 0:
                continue
            cx = a**2 * (b**2 + c**2 - a**2) * xi + b**2 * (c**2 + a**2 - b**2) * xj + c**2 * (a**2 + b**2 - c**2) * xk
            cy = a**2 * (b**2 + c**2 - a**2) * yi + b**2 * (c**2 + a**2 - b**2) * yj + c**2 * (a**2 + b**2 - c**2) * yk
            cx /= S
            cy /= S
            d = 0
            for x, y in XY:
                d = max(d, dist(x, y, cx, cy))
            ans = min(ans, d)

print(ans)

Solution (Python):
import sys

import numpy as np


def search_y(x, points):
    l = np.complex128(x + 0.0j)
    r = np.complex128(x + 1000.0j)

    d1, d2 = 0, 0
    while abs(r - l) > 3e-7:
        diff = (r - l) / 3
        p1 = l + diff
        p2 = l + diff * 2
        d1 = abs(points - p1).max()
        d2 = abs(points - p2).max()
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


def search(points):
    l = 0.0
    r = 1000.0

    d1, d2 = 0, 0
    while r - l > 3e-7:
        diff = (r - l) / 3
        p1 = l + diff
        p2 = l + diff * 2
        d1 = search_y(p1, points)
        d2 = search_y(p2, points)
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


n = int(input())
points = np.array([complex(*map(int, line.split())) for line in sys.stdin], dtype=np.complex128)
print(search(points))

Solution (Python):
import sys

import numpy as np


def search_y(x, points):
    l = np.complex128(x + 0.0j)
    r = np.complex128(x + 1000.0j)

    d1, d2 = 0, 0
    while abs(r - l) > 3e-7:
        m = (l + r) / 2
        p1 = m - 1e-7j
        p2 = m + 1e-7j
        d1 = abs(points - p1).max()
        d2 = abs(points - p2).max()
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


def search(points):
    l = 0.0
    r = 1000.0

    d1, d2 = 0, 0
    while r - l > 3e-7:
        m = (l + r) / 2
        p1 = m - 1e-7
        p2 = m + 1e-7
        d1 = search_y(p1, points)
        d2 = search_y(p2, points)
        if d1 >= d2:
            l = p1
        else:
            r = p2
    return (d1 + d2) / 2


n = int(input())
points = np.array([complex(*map(int, line.split())) for line in sys.stdin], dtype=np.complex128)
print(search(points))

Solution (Python):

import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    def __add__(self, q):
        if isinstance(q, Point):
            return Point(self.x + q.x, self.y + q.y)
        else:
            return Point(self.x + q, self.y + q)
    
    def __sub__(self, q):
        if isinstance(q, Point):
            return Point(self.x - q.x, self.y - q.y)
        else:
            return Point(self.x - q, self.y - q)
    
    def __mul__(self, q):
        if isinstance(q, Point):
            return Point(self.x * q.x - self.y * q.y,
                         self.x * q.y + self.y * q.x)
        else:
            return Point(self.x * q, self.y * q)
        
    def __truediv__(self, q):
        if isinstance(q, Point):
            return self * q.conj / q.norm
        else:
            return Point(self.x / q, self.y / q)
    
    @property
    def conj(self):
        return Point(self.x, -self.y)
    
    def rot(self, ang):
        return Point(math.cos(ang) * self.x - math.sin(ang) * self.y,
                     math.sin(ang) * self.x + math.cos(ang) * self.y)
    
    def rot90(self):
        return Point(-self.y, self.x)
    
    def cross(self, q):
        return self.x * q.y - self.y * q.x
    
    def dot(self, q):
        return self.x * q.x + self.y * q.y
    
    @property
    def norm(self):
        return self.dot(self)

    def __abs__(self):
        return self.dot(self) ** 0.5






N = int(input())
vecs = []
for _ in range(N):
    x, y = map(int, input().split())
    vecs.append(Point(x, y))


def f(x, y):
    res = 0
    for i in range(N):
        res = max(res, abs(vecs[i] - Point(x, y)))
    return res


def g(x, max_iter=100):
    left = -1000
    right = 1000
    for _ in range(max_iter):
        m1 = (left * 2 + right) / 3
        m2 = (left + right * 2) / 3
        if f(x, m1) > f(x, m2):
            left = m1
        else:
            right = m2
            
    return f(x, left)


def solve(max_iter=100):
    left = -1000
    right = 1000
    for _ in range(max_iter):
        m1 = (left * 2 + right) / 3
        m2 = (left + right * 2) / 3
        if g(m1) > g(m2):
            left = m1
        else:
            right = m2
            
    return g(left)


print(solve())

Solution (Python):
N = int(input())
XY = [tuple(map(int,input().split())) for _ in range(N)]

def f(x,y):
  mx = 0
  for x1,y1 in XY:
    if ((x1-x)**2+(y1-y)**2)**0.5 > mx:
      mx = ((x1-x)**2+(y1-y)**2)**0.5
  return mx

def g(x):
  l = 0.0
  r = 1000.0
  for i in range(80):
    c1 = (l*2+r)/3
    c2 = (l+r*2)/3
    if f(x,c1) > f(x,c2):
      l = c1
    else:
      r = c2
  return f(x,l)

l = 0.0
r = 1000.0
for i in range(80):
  c1 = (l*2+r)/3
  c2 = (l+r*2)/3
  if g(c1) > g(c2):
    l = c1
  else:
    r = c2

print(g(l))