Problem:
 Score : 500 points    Problem Statement  Snuke received a triangle as a birthday present.
The coordinates of the three vertices were (x_1, y_1) , (x_2, y_2) , and (x_3, y_3) .  He wants to draw two circles with the same radius inside the triangle such that the two circles do not overlap (but they may touch).
Compute the maximum possible radius of the circles.      Constraints  0 ≤ x_i, y_i ≤ 1000  The coordinates are integers.  The three points are not on the same line.         Input The input is given from Standard Input in the following format:  x_1  y_1  x_2  y_2  x_3  y_3       Output Print the maximum possible radius of the circles.
The absolute error or the relative error must be at most 10^{-9} .        Sample Input 1 0 0
1 1
2 0      Sample Output 1 0.292893218813       Sample Input 2 3 1
1 5
4 9      Sample Output 2 0.889055514217

Solution (Python):
import math
x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())
ans = 0
for (xa,ya,xb,yb,xn,yn) in (x1,y1,x2,y2,x3,y3),(x2,y2,x3,y3,x1,y1),(x3,y3,x1,y1,x2,y2):
  xa -= xn
  ya -= yn
  xb -= xn
  yb -= yn
  xab = xa-xb
  yab = ya-yb
  L = math.hypot(xab,yab)
  cosa = (xab*xa+yab*ya)/(math.hypot(xa,ya)*math.hypot(xab,yab))
  cosb = (-xab*xb-yab*yb)/(math.hypot(xb,yb)*math.hypot(xab,yab))
  anga = math.acos(cosa)
  angb = math.acos(cosb)
  tana = math.tan(anga/2)
  tanb = math.tan(angb/2)
  ans = max(ans,L/(2+1/tana+1/tanb))
print(ans)

Solution (Python):

def main():
    x1, y1, x2, y2, x3, y3 = map(int, open(0).read().split())
    x2 -= x1
    y2 -= y1
    x3 -= x1
    y3 -= y1
    a = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
    b = (x3 ** 2 + y3 ** 2) ** 0.5
    c = (x2 ** 2 + y2 ** 2) ** 0.5
    r = abs(x2 * y3 - x3 * y2) / (a + b + c)
    d = max(a, b, c)
    ans = r * d / (2 * r + d)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))


len1 = ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
len2 = ((p2[0] - p3[0]) ** 2 + (p2[1] - p3[1]) ** 2) ** 0.5
len3 = ((p3[0] - p1[0]) ** 2 + (p3[1] - p1[1]) ** 2) ** 0.5

l = (len1 + len2 + len3) / 2
s = (l * (l - len1) * (l - len2) * (l - len3)) ** 0.5
r = 2 * s /(len1 + len2 + len3)

def solve(mid):
    return (1 - mid / r) * max(len1, len2, len3) >= 2 * mid

ok = 0
ng = 10 ** 9
cnt = 0
while True:
    mid = (ok + ng) / 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
    cnt += 1
    if cnt > 60:
        break
print(ok)

Solution (Python):
def main():
    def b_search(a, b, value, delta):
        while True:
            med = (a+b)/2
            if abs(b-a) < delta:
                if value(b):
                    return b
                else:
                    return a
            elif value(med):
                a = med
            else:
                b = med

    x1, y1 = map(int, input().split())
    x2, y2 = map(int, input().split())
    x3, y3 = map(int, input().split())

    a = ((x1-x2)**2+(y1-y2)**2)**0.5
    b = ((x2-x3)**2+(y2-y3)**2)**0.5
    c = ((x3-x1)**2+(y3-y1)**2)**0.5

    m = max(a, b, c)
    if a == m:
        l = a
    elif b == m:
        x1, x2, x3 = x2, x3, x1
        y1, y2, y3 = y2, y3, y1
        l = b
    else:
        x1, x2, x3 = x3, x1, x2
        y1, y2, y3 = y3, y1, y2
        l = c

    x2 -= x1
    x3 -= x1
    y2 -= y1
    y3 -= y1
    x1, y1 = 0, 0

    if x2 < 0:
        x2 = -x2
        x3 = -x3
    if y2 < 0:
        y2 = -y2
        y3 = -y3

    cos = x2/l
    sin = -(1-cos**2)**0.5

    x2, y2 = l, 0
    x3, y3 = abs(cos*x3-sin*y3), abs(sin*x3+cos*y3)

    a = l
    b = (x3**2+y3**2)**0.5
    c = ((x2-x3)**2+(y2-y3)**2)**0.5

    def value(x):
        t1 = x*y3/x3
        t2 = (x2-x)*y3/(x2-x3)
        s1 = t1*x/2
        s2 = t2*(a-x)/2
        r1 = (2*s1)/(x+t1+(x**2+t1**2)**0.5)
        r2 = (2*s2)/((a-x)+t2+((a-x)**2+t2**2)**0.5)
        if r1 < r2:
            return True
        else:
            return False

    def value2(x):
        t1 = x*y3/x3
        s1 = t1*x/2
        r1 = (2*s1)/(x+t1+(x**2+t1**2)**0.5)
        return r1

    v = b_search(0, l, value, 10**(-12))
    print(value2(v))


main()

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
j, k = x2-x1, y2-y1
l, m = x3-x1, y3-y1
a = ( j**2 + k**2 )**0.5
b = ( l**2 + m**2 )**0.5
c = ( (j-l)**2 + (k-m)**2 )**0.5
S = abs(j*m-k*l)/2
T = (a+b+c)/2
M = max(a, b, c)
r = S / (2*S/M + T)
print(r)

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
d1, d2, d3 = sorted(((x2 - x3) ** 2 + (y2 - y3) ** 2,
                     (x1 - x3) ** 2 + (y1 - y3) ** 2,
                     (x1 - x2) ** 2 + (y1 - y2) ** 2), reverse=True)
d1 = d1 ** .5
d2 = d2 ** .5
d3 = d3 ** .5
s = abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2
r = 2 * s / (d1 + d2 + d3)
print(d1 / (2 + d1 / r))

Solution (Python):
import sys
input = sys.stdin.readline






def main():
    li=[list(map(int,input().split())) for i in range(3)]
    li.append(li[0])
    d=[0]*3
    for i in range(3):
        d[i]=((li[i][0]-li[i+1][0])**2+(li[i][1]-li[i+1][1])**2)**0.5
    dmax=max(d)
    dsum=sum(d)
    s=dsum/2
    S=(s*(s-d[0])*(s-d[1])*(s-d[2]))**0.5
    r=2*S/dsum
    print((r*dmax)/(2*r+dmax))

if __name__ == '__main__':
    main()

Solution (Python):
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
s=abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))
a=((x1-x2)**2+(y1-y2)**2)**0.5
b=((x2-x3)**2+(y2-y3)**2)**0.5
c=((x3-x1)**2+(y3-y1)**2)**0.5
r=s/(a+b+c)
print(max(a,b,c)*r/(2*r+max(a,b,c)))

Solution (Python):
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())

area=(1/2)*abs(a*f-a*d-c*f-b*e+d*e+b*c)
A=abs((a-c)**2+(b-d)**2)
A=A**(1/2)
B=abs((a-e)**2+(b-f)**2)
B=B**(1/2)
C=abs((e-c)**2+(f-d)**2)
C=C**(1/2)
print(max((2*A*area)/(4*area+A*(A+B+C)),(2*B*area)/(4*area+B*(A+B+C)),(2*C*area)/(4*area+C*(A+B+C))))

Solution (Python):
p = [[int(i) for i in input().split()] for i in range(3)]
a = []
for i in range(3): a.append((p[i][0]-p[(i+1)%3][0])**2+(p[i][1]-p[(i+1)%3][1])**2)
a.sort()
print(a[2]**0.5/
(((2*(a[0]*a[2])**0.5+a[0]+a[2]-a[1])/(2*(a[0]*a[2])**0.5-a[0]-a[2]+a[1]))**0.5+
((2*(a[1]*a[2])**0.5+a[1]+a[2]-a[0])/(2*(a[1]*a[2])**0.5-a[1]-a[2]+a[0]))**0.5+2))

Solution (Python):
from math import hypot
p = [list(map(int, input().split())) for i in range(3)]
x1 = p[1][0] - p[0][0]
y1 = p[1][1] - p[0][1]
x2 = p[2][0] - p[0][0]
y2 = p[2][1] - p[0][1]
s2 = abs(x1*y2-x2*y1)
s = 0
m = 0
for i in range(3):
    x = p[i-1][0]-p[i][0]
    y = p[i-1][1]-p[i][1]
    l = hypot(x, y)
    s += l
    m = max(m, l)
r = s2/s
x = m*r/(2*r+m)
print(x)

Solution (Python):
x1,y1 = map(int, input().split( ))
x2,y2 = map(int, input().split( ))
x3,y3 = map(int, input().split( ))

s2 = abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))

a = (x1-x2)**2+(y1-y2)**2
b = (x1-x3)**2+(y1-y3)**2
c =(x3-x2)**2+(y3-y2)**2

a **=(1/2)
b **=(1/2)
c **=(1/2)
mx = max(a,b,c)
h= s2/mx

h = s2/(a+b+c+2*h)
print(h)

Solution (Python):

def main():
    x1, y1, x2, y2, x3, y3 = map(int, open(0).read().split())
    a = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
    b = ((x1 - x3) ** 2 + (y1 - y3) ** 2) ** 0.5
    c = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
    x2 -= x1
    y2 -= y1
    x3 -= x1
    y3 -= y1
    a = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
    b = (x3 ** 2 + y3 ** 2) ** 0.5
    c = (x2 ** 2 + y2 ** 2) ** 0.5
    r = abs(x2 * y3 - x3 * y2) / (a + b + c)
    d = max(a, b, c)
    ans = r * d / (2 * r + d)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
x1, y1 = [int(_) for _ in input().split()]
x2, y2 = [int(_) for _ in input().split()]
x3, y3 = [int(_) for _ in input().split()]

x2 -= x1
y2 -= y1
x3 -= x1
y3 -= y1

A = ((x2 - x3)**2 + (y2 - y3)**2)**0.5
B = (x3**2 + y3**2)**0.5
C = (x2**2 + y2**2)**0.5
R = abs(x2 * y3 - x3 * y2) / (A + B + C)


D = max(A, B, C)
x = R * D / (2 * R + D)
print(x)

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

def cos(x1, y1, x2, y2, x3, y3):
    x2 -= x1
    x3 -= x1
    y2 -= y1
    y3 -= y1
    return (x2*x3+y2*y3)/((x2**2+y2**2)**0.5 * (x3**2+y3**2)**0.5)

def tan(cos):
    return ((1-cos)/(1+cos))**0.5

def r(x1, y1, x2, y2, x3, y3):
    tan1 = tan(cos(x1, y1, x2, y2, x3, y3))
    tan2 = tan(cos(x3, y3, x1, y1, x2, y2))
    b = ((x1-x3)**2+(y1-y3)**2)**0.5
    return b*tan1*tan2 / (tan1+tan2+2*tan1*tan2)

r1 = r(x1, y1, x2, y2, x3, y3)
r2 = r(x2, y2, x3, y3, x1, y1)
r3 = r(x3, y3, x1, y1, x2, y2)
print(max([r1, r2, r3]))

Solution (Python):
import math
def cal0(x,y):
    return (x[0]-y[0])**2+(x[1]-y[1])**2
def cal(x,y):
    return math.sqrt(cal0(x,y))
A = list(map(float,input().split()))
B = list(map(float,input().split()))
C = list(map(float,input().split()))

a = cal(B,C)
b = cal(C,A)
c = cal(A,B)
s = (a+b+c)/2
d = math.sqrt(s*(s-a)*(s-b)*(s-c))
e = 2*d/(a+b+c)
f = max(a,max(b,c))
print(f/(2+f/e))

Solution (Python):
A=list(map(int,input().split()))
x1=A[0]
y1=A[1]
B=list(map(int,input().split()))
x2=B[0]
y2=B[1]
C=list(map(int,input().split()))
x3=C[0]
y3=C[1]
a=((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))**0.5
b=((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1))**0.5
c=((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3))**0.5
S=abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2
print(2*S/(a+b+c+4*S/(max(a,b,c))))

Solution (Python):
from math import hypot

x1, y1, x2, y2, x3, y3 = map(int, open(0).read().split())

a = hypot(x1 - x2, y1 - y2)
b = hypot(x2 - x3, y2 - y3)
c = hypot(x3 - x1, y3 - y1)
R = abs((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / (a + b + c)
m = max(a, b, c)
r = m / (2 + m / R)

print("{:.12f}".format(r))

Solution (Python):

xy = [list(map(int,input().split())) for _ in range(3)]

angle = [0]*3
import numpy as np
import math
ans = 0
for i in range(3):
    cnt = 0
    a = [[0,0] for _ in range(2)]
    for j in range(3):
        if j==i:continue
        a[cnt] = [xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]]
        cnt += 1
    val = (a[0][0]*a[1][0] + a[0][1]*a[1][1]) / (np.sqrt(a[0][0]**2 + a[0][1]**2)*np.sqrt(a[1][0]**2 + a[1][1]**2))
    theta = math.acos(val)
    angle[i] = theta/2
    
idx = [[1,2],[0,2],[0,1]]

for i in range(3):
    c = [xy[idx[i][0]][0] - xy[idx[i][1]][0],xy[idx[i][0]][1] - xy[idx[i][1]][1]]
    L = np.sqrt(c[0]**2 + c[1]**2)
    tmp = 0
    for j in range(3):
        if i==j:continue
        tmp += 1/np.tan(angle[j])
    r = L / (2 + tmp)
    ans = max(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(1000000000)
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()))

x1,y1 = LI()
x2,y2 = LI()
x3,y3 = LI()
s = abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))
a ,b, c = math.sqrt((x1-x2)**2+(y1-y2)**2),math.sqrt((x2-x3)**2+(y2-y3)**2),math.sqrt((x3-x1)**2+(y3-y1)**2)
r = s/(a+b+c)
ans = max(a,b,c)*r/(2*r+max(a,b,c))
print(ans)

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
v1 = x1 + y1 * 1j
v2 = x2 + y2 * 1j
v3 = x3 + y3 * 1j

v12 = v2 - v1
v13 = v3 - v1
s = abs(v12.real * v13.imag - v12.imag * v13.real) / 2
d12 = abs(v12)
d23 = abs(v3 - v2)
d13 = abs(v13)
r = 2 * s / (d12 + d23 + d13)
a = max(d12, d23, d13)
print(a * r / (2 * r + a))

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

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

a = dist(x1, y1, x2, y2)
b = dist(x2, y2, x3, y3)
c = dist(x3, y3, x1, y1)
s = (a + b + c) / 2

S = (s * (s - a) * (s - b) * (s - c))**0.5
leng = a + b + c
L = max(a, b, c)

r = S * 2 / leng
ans = r * L / (r + r + L)
print(ans)

Solution (Python):
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
s=abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))
a=((x1-x2)**2+(y1-y2)**2)**0.5
b=((x2-x3)**2+(y2-y3)**2)**0.5
c=((x3-x1)**2+(y3-y1)**2)**0.5
r=s/(a+b+c)
print(max(a,b,c)*r/(2*r+max(a,b,c)))

Solution (Python):
import sys

x1,y1,x2,y2,x3,y3 = map(int,sys.stdin.read().split())

a,b = x2-x1,y2-y1
c,d = x3-x1,y3-y1

area = abs(a*d-b*c)/2
edge = (a*a+b*b)**.5, (c*c+d*d)**.5, ((a-c)**2+(b-d)**2)**.5

pelim = sum(edge)
r = area * 2 / pelim

L = max(edge)
answer = r*L/(r+r+L)
print(answer)

Solution (Python):
a,b,c,d,e,f=map(int,open(0).read().split())
a,b,c=sorted((s*s+t*t)**.5for s,t in((a-c,b-d),(c-e,d-f),(e-a,f-b)))
d=a+b+c
s=d/2
s=(s*(s-a)*(s-b)*(s-c))**.5
print(c/(2+c/2/s*d))

Solution (Python):
a,b,c,d,e,f=map(int,open(0).read().split())
a,b,c=sorted((s*s+t*t)**.5for s,t in((a-c,b-d),(c-e,d-f),(e-a,f-b)))
d=a+b+c
s=d/2
s=(s*(s-a)*(s-b)*(s-c))**.5
r=2*s/d
l,h=0,1e5
while h-l>1e-9:
  m=(h+l)/2
  if c*(r-m)/r<2*m:h=m
  else:l=m
print(l)

Solution (Python):
a,b,c,d,e,f=map(int,open(0).read().split())
a,b,c=sorted((s*s+t*t)**.5for s,t in((a-c,b-d),(c-e,d-f),(e-a,f-b)))
d=a+b+c
s=d/2
s=(s*(s-a)*(s-b)*(s-c))**.5
r=2*s/d
l,h=0,1e5
while h-l>1e-9:
  m=(h+l)/2
  if c*(r-m)/r<2*m:h=m
  else:l=m
print(l)

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
a = (((x1 - x2) ** 2) + ((y1 - y2) ** 2)) ** 0.5
b = (((x3 - x2) ** 2) + ((y3 - y2) ** 2)) ** 0.5
c = (((x1 - x3) ** 2) + ((y1 - y3) ** 2)) ** 0.5
max_s = max(max(a, b), c)
s = (a + b + c) / 2
S = (s * (s - a) * (s - b) * (s - c)) ** 0.5
r = S / s
print(r * max_s / (max_s + (2 * r)))

Solution (Python):
l = [tuple(map(int,input().split())) for _ in range(3)]
s = abs((l[1][0]-l[0][0])*(l[2][1]-l[0][1]) - (l[1][1]-l[0][1])*(l[2][0]-l[0][0]))
a = ((l[1][0]-l[0][0])**2 + (l[1][1]-l[0][1])**2)**.5
b = ((l[2][0]-l[1][0])**2 + (l[2][1]-l[1][1])**2)**.5
c = ((l[2][0]-l[0][0])**2 + (l[2][1]-l[0][1])**2)**.5
t = max(a,b,c)
r = s/(a+b+c)
ng = r
ok = 0
for _ in range(80):
  mid = (ok+ng)/2
  if t*(1-mid/r) >= mid*2:
    ok = mid
  else:
    ng = mid
print("{:.12}".format(ok))

Solution (Python):
a=[list(map(int,input().split()))for i in range(3)]
s,t,u=((a[0][0]-a[1][0])**2+(a[0][1]-a[1][1])**2)**0.5,((a[2][0]-a[1][0])**2+(a[2][1]-a[1][1])**2)**0.5,((a[0][0]-a[2][0])**2+(a[0][1]-a[2][1])**2)**0.5
p=(s+t+u)/2
q=(p*(p-s)*(p-t)*(p-u))**0.5
r=2*q/(s+t+u)
g=max(s,t,u)
print(g/(2+g/r))

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

e12 = ((x2-x1)**2 + (y2-y1)**2)**0.5
e23 = ((x3-x2)**2 + (y3-y2)**2)**0.5
e31 = ((x1-x3)**2 + (y1-y3)**2)**0.5

s = (e12 + e23 + e31)/2
S = (s * (s-e12) * (s-e23) * (s-e31)) ** 0.5
r=2*S/(e12+e23+e31)
A=max(e12,e23,e31)
print(A*r/(2*r+A))

Solution (Python):
import math
xy = []
for i in range(3):
    xy.append([int(item) for item in input().split()])
xy.append(xy[0])

dist = []
for i in range(3):
    distance = math.sqrt((xy[i][0] - xy[i+1][0])**2.0 + (xy[i][1] - xy[i+1][1])**2.0)
    dist.append([distance, i, (i+1) % 3, (i+2) % 3])
dist.sort(reverse=True)

def get_vector(a, b):
    v = [a[0] - b[0], a[1] - b[1]]
    return v

def norm(a):
    n = math.sqrt(a[0] * a[0] + a[1] * a[1])
    return n

a = get_vector(xy[dist[0][-1]], xy[dist[0][-2]])
b = get_vector(xy[dist[0][-3]], xy[dist[0][-2]])
c = get_vector(xy[dist[0][-1]], xy[dist[0][-3]])
d = get_vector(xy[dist[0][-2]], xy[dist[0][-3]])
bc = dist[0][0]

ctheta = (a[0] * b[0] + a[1] * b[1]) / (norm(a) * norm(b))
cphi = (c[0] * d[0] + c[1] * d[1]) / (norm(c) * norm(d))
htheta = (math.pi - math.acos(ctheta)) / 2.0
hphi = (math.pi - math.acos(cphi)) / 2.0
r = bc / (math.tan(htheta) + math.tan(hphi) + 2)
print(r)

Solution (Python):
import math


def vec(p1, p2):
    return (p2[0] - p1[0], p2[1] - p1[1])


def l(v):
    return math.sqrt(v[0]**2 + v[1]**2)


def check(a, b, c, x, r):
    m = 1 - x/r
    return max([a, b, c]) * m >= x*2


def main():
    x = [0] * 3
    y = [0] * 3
    P = [None] * 3
    for i in range(3):
        x, y = map(int, input().split())
        P[i] = (x, y)
    v0 = vec(P[0], P[1])
    v1 = vec(P[0], P[2])
    v2 = vec(P[1], P[2])
    a = l(v0)
    b = l(v1)
    c = l(v2)
    r = abs(v0[0] * v1[1] - v0[1] * v1[0]) / (a + b + c)
    lo = 0.0
    hi = r
    while hi - lo >= 1e-10:
        mid = (hi + lo) / 2
        if check(a, b, c, mid, r):
            lo = mid
        else:
            hi = mid
    print(lo)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
P = np.array([list(map(int,input().split())) for _ in [0]*3],dtype=float)

def f(r):
    R = 0+P
    for i in range(3):
        c = r / (1 - e[i].dot(e[i-1])**2)**0.5
        R[i] += c*(e[i]-e[i-1])
    return R

def g(p):
    r = 0
    n = np.linalg.norm
    for i in range(3):
        r = max(r,n(p[i]-p[i-1]))
    return r

def h(r):return g(f(r))<2*r

def binary_search_float(l,r,func,d):
    if func(l):return l
    if not func(r):return r
    while (r-l)>=d:
        i = (l+r)/2
        if func(i):
            r = i
        else:
            l = i
    return l

e = -P
for i in range(3):
    e[i] += P[(i+1)%3]
l = np.linalg.norm(e,axis=1)
L = np.sum(l)
S2 = np.abs(e[0,0]*e[-1,1]-e[-1,0]*e[0,1])
M = S2/L
e = e/(l*np.ones((2,3))).T

print(binary_search_float(0,M,h,1e-10))

Solution (Python):
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

def Area(dots):
	res = 0
	for i in range(len(dots)-1):
		res += OuterProduct(dots[i], dots[i+1])
	res += OuterProduct(dots[-1], dots[0])
	return res/2

d = [list(map(int, input().split())) for _ in range(3)]
x = complex(d[0][0], d[0][1])
y = complex(d[1][0], d[1][1])
z = complex(d[2][0], d[2][1])
s = abs(Area([x, y, z]))
a, b, c = abs(x-y), abs(y-z), abs(z-x)
print(2*s/(a+b+c+(4*s/max(a, b, c))))

Solution (Python):
xy = [list(map(int, input().split())) for _ in range(3)]
s = abs((xy[1][0]-xy[0][0])*(xy[2][1]-xy[0][1]) - (xy[1][1]-xy[0][1])*(xy[2][0]-xy[0][0])) / 2
a = ((xy[1][0]-xy[0][0])**2 + (xy[1][1]-xy[0][1])**2)**0.5
b = ((xy[2][0]-xy[0][0])**2 + (xy[2][1]-xy[0][1])**2)**0.5
c = ((xy[2][0]-xy[1][0])**2 + (xy[2][1]-xy[1][1])**2)**0.5
print(1/(2/max(a, b, c) + (a+b+c)/s/2))

Solution (Python):
x0,y0=map(int,input().split())
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
def make_dist(i,j,k,l):
    return ((i-k)**2+(j-l)**2)**0.5
a=y1-y2
b=x2-x1
c=x1*y2-y1*x2
d12=make_dist(x1,y1,x2,y2)
d01=make_dist(x0,y0,x1,y1)
d02=make_dist(x0,y0,x2,y2)
S_double=d12*abs(a*x0+b*y0+c)/(make_dist(a,b,0,0))
r=S_double/(d01+d02+d12)
d=max(d01,d02,d12)
ans=d*r/(2*r+d)
print(ans)

Solution (Python):
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    A = list(map(int, line_input()))
    B = list(map(int, line_input()))
    C = list(map(int, line_input()))

    ab = round(math.sqrt(pow(A[0] - B[0], 2) + pow(A[1] - B[1], 2)), 15)
    bc = round(math.sqrt(pow(B[0] - C[0], 2) + pow(B[1] - C[1], 2)), 15)
    ca = round(math.sqrt(pow(C[0] - A[0], 2) + pow(C[1] - A[1], 2)), 15)
    S = round(abs((C[0] - A[0]) * (C[1] - B[1]) - (C[1] - A[1]) * (C[0] - B[0])) / 2, 15)
    r = round(S * 2 / (ab + bc + ca), 15)
    longest_side = max([ab, bc, ca])

    x = round(longest_side * r / (2 * r + longest_side),14)
    return x
 
if __name__ == "__main__":
    print(solve())

Solution (Python):


import sys
from math import hypot, sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def heron(a, b, c):
    s=(a+b+c)/2
    return sqrt(s*(s-a)*(s-b)*(s-c))

x1,y1=MAP()
x2,y2=MAP()
x3,y3=MAP()


a=hypot(x1-x2, y1-y2)
b=hypot(x2-x3, y2-y3)
c=hypot(x3-x1, y3-y1)

S=heron(a, b, c)

r=2*S/(a+b+c)


mx=max(a, b, c)
print(mx/(2+mx/r))

Solution (Python):
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
c1,c2 = map(int,input().split())

C = ((a1-b1)**2 + (a2-b2)**2)**(1/2)
A = ((b1-c1)**2 + (b2-c2)**2)**(1/2)
B = ((c1-a1)**2 + (c2-a2)**2)**(1/2)

S = abs((b1-a1)*(c2-a2)-(b2-a2)*(c1-a1))

r1 = B*S/(B*(A + B + C) + 2*S)
r2 = C*S/(C*(A + B + C) + 2*S)
r3 = A*S/(A*(A + B + C) + 2*S)

print(max(r1,r2,r3))

Solution (Python):
from math import acos, tan, hypot

def getRad1(s12, s13, s23):
    return acos((s12*s12 + s13*s13 - s23*s23) / (2*s12*s13))

def getMaxR(s12, rad1, rad2):
    tan1 = tan(rad1 / 2)
    tan2 = tan(rad2 / 2)
    h = s12 * (tan1*tan2) / (tan1+tan2)

    def isOK(mid):
        return s12 - mid/tan1 - mid/tan2 <= 2*mid

    ng, ok = 0, h
    while abs(ok-ng) > 10**-12:
        mid = (ng+ok) / 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid
    return ok

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

s12 = hypot(x1-x2, y1-y2)
s23 = hypot(x2-x3, y2-y3)
s31 = hypot(x3-x1, y3-y1)

rad1 = getRad1(s12, s31, s23)
rad2 = getRad1(s23, s12, s31)
rad3 = getRad1(s31, s23, s12)

maxRs = [
    getMaxR(s12, rad1, rad2), 
    getMaxR(s23, rad2, rad3),
    getMaxR(s31, rad3, rad1)
]
print(max(maxRs))

Solution (Python):
from math import acos, tan, hypot

def getRad1(s12, s13, s23):
    return acos((s12*s12 + s13*s13 - s23*s23) / (2*s12*s13))

def getMaxR(s12, rad1, rad2):
    tan1 = tan(rad1 / 2)
    tan2 = tan(rad2 / 2)
    h = s12 * (tan1*tan2) / (tan1+tan2)
    return h * (tan1+tan2) / (2*tan1*tan2 + tan1 + tan2)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

s12 = hypot(x1-x2, y1-y2)
s23 = hypot(x2-x3, y2-y3)
s31 = hypot(x3-x1, y3-y1)

rad1 = getRad1(s12, s31, s23)
rad2 = getRad1(s23, s12, s31)
rad3 = getRad1(s31, s23, s12)

maxRs = [
    getMaxR(s12, rad1, rad2), 
    getMaxR(s23, rad2, rad3),
    getMaxR(s31, rad3, rad1)
]
print(max(maxRs))

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())


d1 = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
d2 = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
d3 = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
D = max(d1, d2, d3)


s = (d1 + d2 + d3) / 2
S = (s * (s - d1) * (s - d2) * (s - d3)) ** 0.5
R = (2 * S) / (d1 + d2 + d3)


ok, ng = 0, 10000
eps = 1e-9

while abs(ok - ng) > eps:
    r = (ok + ng) / 2
    if 2 * r <= D * ((R - r) / R):
        ok = r
    else:
        ng = r

print(ok)

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import sqrt

points = [tuple(li()) for _ in range(3)]


sides = []
angles = []
for i in range(3):
    p1,p2 = points[i], points[(i+1)%3]
    sides.append(sqrt((p2[0]-p1[0])**2 + (p2[1]-p1[1])**2))


s = (sum(sides)) / 2
a,b,c = sides
area = sqrt(s* (s-a) * (s-b) * (s-c))
r = 2*area / sum(sides)

print(max(sides)*r / (2*r + max(sides)))

Solution (Python):
Tri=[]
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
a1,a2=x2-x1,y2-y1
b1,b2=x3-x1,y3-y1
c1,c2=x3-x2,y3-y2
S=abs(a1*b2-a2*b1)/2
a=(a1**2+a2**2)**(1/2)
b=(b1**2+b2**2)**(1/2)
c=(c1**2+c2**2)**(1/2)
h=2*S/max(a,b,c)
r=S/(h+(a+b+c)/2)
print(r)

Solution (Python):
x1,y1 = [int(i) for i in input().split()]
x2,y2 = [int(i) for i in input().split()]
x3,y3 = [int(i) for i in input().split()]

A = ((x1-x2)**2+(y1-y2)**2)**(1/2)
B = ((x2-x3)**2+(y2-y3)**2)**(1/2)
C = ((x3-x1)**2+(y3-y1)**2)**(1/2)
S = A+B+C
A, C = max(A, B, C), min(A, B, C)
B = S-A-C

cosb = (A**2+C**2-B**2)/2/A/C
cosc = (A**2+B**2-C**2)/2/A/B

R = A/(2 + ( (1+cosb) / (1-cosb) )**(1/2) + ( (1+cosc) / (1-cosc) )**(1/2) )
print(R)

Solution (Python):
import math
table=[[int(i) for i in input().split()] for i in range(3)]
r=[0]*3
for i in range(3):
    a=(table[i%3][0]-table[(i+1)%3][0])**2
    b=(table[i%3][1]-table[(i+1)%3][1])**2
    r[i]=math.sqrt(a+b)
s=sum(r)/2
t=s
for i in range(3):
    t*=(s-r[i])
t=math.sqrt(t)
x=t*2/(sum(r))
u=max(r)
print(x*u/(2*x+u))

Solution (Python):
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())

from math import sqrt

d1=sqrt((x2-x3)**2+(y2-y3)**2)
d2=sqrt((x1-x3)**2+(y1-y3)**2)
d3=sqrt((x1-x2)**2+(y1-y2)**2)

l=max(d1,max(d2,d3))

def cos(x,y,z):
    return (y**2+z**2-x**2)/(2*y*z)

c1=cos(d1,d2,d3)
c2=cos(d2,d1,d3)
c3=cos(d3,d2,d1)

c1=sqrt((1+c1)/2)
c2=sqrt((1+c2)/2)
c3=sqrt((1+c3)/2)

ct1=sqrt(1/(1/(c1**2)-1))
ct2=sqrt(1/(1/(c2**2)-1))
ct3=sqrt(1/(1/(c3**2)-1))

r=max(d1/(2+ct2+ct3),max(d2/(2+ct1+ct3),d3/(2+ct2+ct1)))

print(r)

Solution (Python):
def norm(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5
def d(a, b, c, x, y):
    return abs(a*x + b*y + c) / (a**2 + b**2)**0.5
def points2line(x1, y1, x2, y2):
    la = y1 - y2
    lb = x2 - x1
    lc = x1 * (y2 - y1) + y1 * (x1 - x2)
    return la, lb, lc
from numpy import argmax



x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())

a = norm(x3, y3, x2, y2)
b = norm(x1, y1, x3, y3)
c = norm(x1, y1, x2, y2)

xc = (a*x1 + b*x2 + c*x3)/(a+b+c)
yc = (a*y1 + b*y2 + c*y3)/(a+b+c)

iw = argmax([a, b, c])
w = [a, b, c][int(iw)]

L = [[x1, y1], [x2, y2], [x3, y3]]
del L[int(iw)]
m, n = L[0]
p, q = L[1]
s, t, u = points2line(m, n, p, q)
h = d(s, t, u, xc, yc)
print(w*h/(2*h + w))

Solution (Python):
ai = lambda: list(map(int, input().split()))

import numpy as np
import math


def calc(A,B,C):
    a = np.linalg.norm(B - C)
    b = np.linalg.norm(C - A)
    c = np.linalg.norm(A - B)
    s = (a + b + c) / 2
    area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
    r = 2 * area / (a + b + c)
    m = max(a,b,c)
    return m/(2+m/r)


a = np.array(ai())
b = np.array(ai())
c = np.array(ai())
print(calc(a,b,c))

Solution (Python):
xy = [list(map(int, input().split())) for _ in range(3)]
d = [((xy[i][0] - xy[i + 1][0]) ** 2 + (xy[i][1] - xy[i + 1][1]) ** 2) ** .5
     for i in range(-1, 2)]
s = abs((xy[1][0] - xy[0][0]) * (xy[2][1] - xy[0][1])
        -(xy[2][0] - xy[0][0]) * (xy[1][1] - xy[0][1])) / 2

k = max(d)
r = 2 * s / sum(d)
x = k * r / (k + 2 * r)
print('{:.10f}'.format(x))

Solution (Python):
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())


a = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
b = ((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5
c = ((x3 - x1) ** 2 + (y3 - y1) ** 2) ** 0.5
L = max(a, b, c)


s = (a + b + c) / 2
S = (s * (s - a) * (s - b) * (s - c)) ** 0.5


r = (2 * S) / (a + b + c)

ans = (L * r) / (2 * r + L)
print(ans)

Solution (Python):
import math
ps = [tuple(map(int,input().split())) for i in range(3)]

def dist(p1,p2):
    x1,y1 = p1
    x2,y2 = p2
    return math.hypot(x1-x2, y1-y2)

es = [dist(ps[0],ps[1]), dist(ps[1],ps[2]), dist(ps[2],ps[0])]
longest = max(es)


s = sum(es) / 2
area = math.sqrt(s * (s-es[0]) * (s-es[1]) * (s-es[2]))

h = 2 * area / longest
r = (longest * h) / (sum(es) + 2*h)
print(r)

Solution (Python):
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
xa=x2-x1
ya=y2-y1
xb=x3-x1
yb=y3-y1

S=abs(xa*yb-xb*ya)/2
a=(xb*xb+yb*yb)**0.5
b=(xa*xa+ya*ya)**0.5
c=((xa-xb)**2+(ya-yb)**2)**0.5

R=max(2*S/(a+b+c+4*S/a),2*S/(a+b+c+4*S/b),2*S/(a+b+c+4*S/c))

print(R)

Solution (Python):
import math as m
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))

points = (m.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) for p1, p2 in zip((p1, p2, p3), (p2, p3, p1)))
a, b, c = sorted(points)
s = (a + b + c) / 2
T = m.sqrt(s*(s-a)*(s-b)*(s-c))
ans = 2*T / (a + b + c + 4*T/c)
print(ans)

Solution (Python):
from math import sqrt
P = [map(int, raw_input().split()) for i in [0,1,2]]
def dist(p, q):
    return sqrt((p[0]-q[0])**2 + (p[1]-q[1])**2)
D = [dist(P[i-1], P[i]) for i in xrange(3)]
D = D*2

def rtanhalf(a, b, c):
    p = 2*a*b
    q = a**2 + b**2 - c**2
    return sqrt(float(q + p) / float(p - q))
def solve(a, b, c):
    s = rtanhalf(a, b, c)
    t = rtanhalf(c, b, a)
    r = b / (2. + s + t)
    return r
print max(solve(*D[i:i+3]) for i in xrange(3))