use std::io; use std::str; pub trait ParseLine { fn parse_line(s: &mut Input) -> Self; } macro_rules! impl_parse_line { ($($t:ty),*) => { $(impl ParseLine for $t { fn parse_line(s: &mut Input) -> Self { s.token() } })* }; } impl_parse_line!( u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, f32, f64, String, char ); macro_rules! impl_parse_line_tuple { ($($t:ident),*) => { impl<$($t: ParseLine),*> ParseLine for ($($t,)*) { fn parse_line(s: &mut Input) -> Self { ($($t::parse_line(s),)*) } } }; } impl_parse_line_tuple!(T0, T1); impl_parse_line_tuple!(T0, T1, T2); impl_parse_line_tuple!(T0, T1, T2, T3); impl_parse_line_tuple!(T0, T1, T2, T3, T4); impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5); impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6); impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6, T7); impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8); impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9); pub struct Input { reader: R, buffer: Vec, } // impl Input> { // pub fn stdio() -> Self { // let stdin = std::io::stdin(); // let scan = Input::new(stdin.lock()); // scan // } // } impl Input { pub fn new(reader: R) -> Self { Self { reader, buffer: vec![], } } pub fn token(&mut self) -> T { loop { if let Some(token) = self.buffer.pop() { return token.parse().ok().expect("Failed parse"); } let mut input = String::new(); self.reader.read_line(&mut input).expect("Failed read"); self.buffer = input.split_whitespace().rev().map(String::from).collect(); } } pub fn read(&mut self) -> T { ParseLine::parse_line(self) } pub fn usize1(&mut self) -> usize { self.token::() - 1 } pub fn isize1(&mut self) -> isize { self.token::() - 1 } pub fn chars(&mut self) -> Vec { self.token::().chars().collect() } pub fn vec(&mut self, n: usize) -> Vec { (0..n).map(|_| ParseLine::parse_line(self)).collect() } } fn main() { let mut input = Input::new(std::io::stdin().lock()); let n: usize = input.read(); let mut total = 0; for i in 1..=n{ total += i; } println!("{}", total); }