Problem:
Score : 100 points

Problem Statement

Snuke is buying a bicycle.
The bicycle of his choice does not come with a bell, so he has to buy one separately.

He has very high awareness of safety, and decides to buy two bells, one for each hand.

The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.
Find the minimum total price of two different bells.

Constraints

1 \leq a,b,c \leq 10000

a, b and c are integers.

Input

Input is given from Standard Input in the following format:

a b c

Output

Print the minimum total price of two different bells.

Sample Input 1

700 600 780

Sample Output 1

1300

Buying a 700-yen bell and a 600-yen bell costs 1300 yen.

Buying a 700-yen bell and a 780-yen bell costs 1480 yen.

Buying a 600-yen bell and a 780-yen bell costs 1380 yen.

The minimum among these is 1300 yen.

Sample Input 2

10000 10000 10000

Sample Output 2

20000

Buying any two bells costs 20000 yen.

Solution in Rust (1.15.1) (judge verdict: Runtime Error)

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w = read::<i32>();
    let h = read::<i32>();
    let n = read::<usize>();
    let mut ps = vec![(0, 0); 2 * n];
    let mut online_ps = vec![];
    let mut online_cnt = vec![0; n];
    for i in 0..n {
        for j in 0..2 {
            let x = read::<i32>();
            let y = read::<i32>();
            ps[i * 2 + j] = (x, y);
            if x == 0 || y == 0 || x == w || y == h {
                let mut d = 0;
                if y == 0 {
                    d = x;
                } else if x == w {
                    d = w + y;
                } else if y == h {
                    d = w + h + (w - x);
                } else if x == 0 {
                    d = w + h + w + (h - y);
                }
                online_ps.push((d, i, x, y));
                online_cnt[i] += 1;
            }
        }
    }
    online_ps.sort();
    let mut stack = vec![];
    for &(_d, index, _x, _y) in online_ps.iter() {
        if online_cnt[index] == 1 {
            continue;
        }
        if let Some(&last_index) = stack.last() {
            if last_index == index {
                stack.pop();
                continue;
            }
        }
        stack.push(index);
    }
    println!("{}", if stack.len() == 0 { "YES" } else { "NO" });
}