Problem:
Score : 500 points

Problem Statement

#nck {
width: 30px;
height: auto;
}

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 in Rust (1.15.1) (judge verdict: Accepted)

fn main() {
    let mut sc = Scanner::new();
    let (x1, y1): (f64, f64) = (sc.read(), sc.read());
    let (x2, y2): (f64, f64) = (sc.read(), sc.read());
    let (x3, y3): (f64, f64) = (sc.read(), sc.read());
    let a = dist(x1, y1, x2, y2);
    let b = dist(x1, y1, x3, y3);
    let c = dist(x2, y2, x3, y3);
    let s = (a + b + c) / 2.0;
    let t = (s * (s - a) * (s - b) * (s - c)).sqrt();
    let r = t * 2.0 / (a + b + c);
    let mut max = if a > b { a } else { b };
    max = if max > c { max } else { c };

    let x = max * r / (2.0 * r + max);
    println!("{}", x);
}

fn dist(x1: f64, y1: f64, x2: f64, y2: f64) -> f64 {
    let dx = x1 - x2;
    let dy = y1 - y2;
    (dx * dx + dy * dy).sqrt()
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}