use std::io::{stdin, Read};
use libc::{clock_gettime, timespec, CLOCK_PROCESS_CPUTIME_ID};

fn main() {

    let mut data = String::new();
    stdin().read_to_string(&mut data).unwrap();
    let mut begin = timespec {
        tv_sec: 0,
        tv_nsec: 0,
    };
    unsafe {
        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &mut begin);
    };

    let calories = data.replace('\n', " ");
    let lines = calories.split("  ");
    let mut all_cals = vec![];
    for line in lines {
        let mut cal_count = vec![];
        let nums = line.split_whitespace();
        for num in nums {
            let num: i32 = num.trim().parse().unwrap();
            cal_count.push(num);
        }
        let total_sum: i32 = cal_count.iter().sum();
        all_cals.push(total_sum);
    }
    all_cals.sort_unstable();
    all_cals.reverse();
    let sum = all_cals[0] + all_cals[1] + all_cals[2];

    let mut end = timespec {
        tv_sec: 0,
        tv_nsec: 0,
    };
    unsafe {
        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &mut end);
    };
    println!("{sum:?}");
    println!(
        "time: {:.6}ms",
        (end.tv_nsec - begin.tv_nsec) as f32 / 1000.0 / 1000.0
    );
}
