#![allow(unused)]
use std::error::Error;
use std::fmt::{Debug, Display};
use std::io;
use std::str::FromStr;
pub fn input() -> String {
let mut inner = String::new();
std::io::stdin()
.read_line(&mut inner)
.expect("Failed to read from stdin");
inner
}
pub fn input_prompt(prompt: &'_ impl Display) -> String {
print!("{}", prompt);
let mut ret = String::new();
std::io::stdin()
.read_line(&mut ret)
.expect("Failed to read from stdin");
ret
}
pub fn input_ok<T: FromStr>() -> Result<T, Box<dyn Error>>
where
<T as FromStr>::Err: Error + 'static,
{
let mut input = String::new();
io::stdin().read_line(&mut input)?;
Ok(input.trim().parse()?)
}
pub fn input_from<T: FromStr>() -> T
where
<T as FromStr>::Err: Debug + 'static,
{
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect("Failed to read from stdin");
input.trim().parse().unwrap()
}
#[macro_export] macro_rules! read {
($out:ident as $type:ty) => {
let $out = {
let mut inner = String::new();
std::io::stdin().read_line(&mut inner).expect("a String");
inner.trim().parse::<$type>().expect("Parsable")
};
};
}
#[macro_export]
macro_rules! read_str {
($out:ident) => {
let $out = {
let mut inner = String::new();
std::io::stdin().read_line(&mut inner).expect("a String");
inner.trim().to_string()
};
};
}
#[macro_export]
macro_rules! read_vec {
($out:ident as $type:ty) => {
let $out = {
let mut inner = String::new();
std::io::stdin().read_line(&mut inner).unwrap();
inner
.trim()
.split_whitespace()
.map(|s| s.parse::<$type>().unwrap())
.collect::<Vec<$type>>()
};
};
}