#![allow(unused_imports, unused_macros)] use std::cmp::*; use std::collections::*; use std::io::Read; use x_macros::*; fn main() { // input input! { a1: i32, a2: i32, a3: i32, b: i32, } // main let ans = max(a3 * 3, a1 + a2 + a3 + b); // output println!("{}", ans); } // ---------------------------------------------------------------- #[macro_use] pub mod x_macros { #[macro_export] macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($next:expr) => {}; ($next:expr,) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; } #[macro_export] macro_rules! read_value { ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len) .map(|_| read_value!($next, $t)) .collect::>() }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; } } // input (to parse query) fn get_word() -> String { let stdin = std::io::stdin(); let mut stdin = stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = String::from_utf8(buf).unwrap(); return ret; } } } #[allow(dead_code)] fn get() -> T { get_word().parse().ok().unwrap() }