{"lang": "Rust", "source_code": "/*! https://codeforces.com/problemset/problem/4/A\n\u6ce8\u610f\u5728IDEA\u4e0a\u53d1\u9001EOF\u7684\u5feb\u6377\u952e\u662fcmd+d\n\n\u672c\u9898\u95ee\u7684\u662f\u4e00\u4e2a\u6570\u80fd\u5426\u88ab\u5206\u6210\u4e24\u4e2a\u5076\u6570\u4e4b\u548c\uff0c\u663e\u7136\u53ea\u8981\u5927\u4e8e2\u7684\u5076\u6570\u90fd\u590d\u5408\u6761\u4ef6\n*/\nuse std::io::Read;\n\nfn main() {\n let mut input;\n std::io::stdin().lock().read_to_string(&mut input);\n let num = input[0].parse::().unwrap();\n if num > 2 && num % 2 == 0 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "34d5ed9615450ff18f01a3a010041eb3", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::io::stdin;\nuse term::stdout;\n\nfn main() {\n\n let mut input = String::new();\n\n io::stdin()\n .read_line(&mut input);\n\n let weight:u32 = match input.trim().parse() {\n Ok(num) => num,\n Err(e) => e,\n };\n\n if weight%2 = 0 {\n println!(\"YES\")\n } else {\n println!(\"NO\")\n }\n\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "610e6eead0a60ce5b6082258ba1955f5", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main()\n{\n let mut input = String::new();\n std::io::stdin()\n .read_line(&mut input)\n .expect(\"Bleh.\");\n let number : i32 = input.parse();\n \n if (number % 2 == 0) && (number != 2)\n {\n println!(\"YES\\n\");\n }\n else\n {\n println!(\"NO\\n\");\n }\n} ", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "be31c8f8b583872cebb8f8730374789a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() {\n let mut s = String::new();\n stdin().read_line(&mut s).unwrap();\n let n : u32 = s.trim().parse();\n if n % 2 == 0 {\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ddeea5ef8a1c374d7d6e5d64c6a2292f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::{self, Write};\n\nfn main() {\n let mut s = String::new();\n\tio::stdin().read_line(&mut s).unwrap();\n\n\tlet n = s.trim().parse::().unwrap();\n\n if n & 2 == 0 && n != 2 {\n \tprintln!(\"YES\");\n }\n } else {\n \tprintln!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d28afd68e1b8ebd27bd6d18bb7a12b44", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\nfn main() {\n let s = stdin().read_to_string().unwrap();\n let n : u32 = s.parse();\n if n % 2 == 0 {\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "c376818780abf550f15376d018ffce63", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "extern crate utils;\nuse std::io;\nuse utils::*;\n\npub fn read_line() -> String {\n let mut input = String::new();\n io::stdin()\n .read_line(&mut input)\n .expect(\"error: unable to read user input\");\n input[0..input.len() - 1].to_string()\n}\n\nfn main() {\n let input = read_line().parse::().unwrap();\n if input <= 2 {\n println!(\"NO\");\n } else if input % 2 == 0 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "e952f1d5e6d38b6cff7fee8c8ac60b1a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n\n use scan::Scan;\n let mut scanner = scan::from_stdin();\n let n = scanner.next::();\n if (n % 2 == 0){\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d6ff6e1bc7262692e6b1f638b8b52142", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::error::Error;\nuse std::io::{self, Read, stdin};\n\nfn main() -> Result<(), Box> {\n let mut s = String::new();\n stdin().read_to_string(&mut s)?;\n let n : u32 = s.parse()?;\n if n % 2 == 0 {\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }\n Ok(())\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "531b712db6026d19d874d237390f6f9d", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\nfn main() {\n let s = stdin().read_to_string().unwrap();\n let n : u32 = s.parse();\n if n % 2 == 0 {\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "f4cbc3c642c7f9709bd3b759e0d649f8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[macro_use]\nextern crate text_io;\n\nmacro_rules! lets {\n\t($($id:ident $(:$T:ty)*),+ =.. $ex:expr) => { $( let $id $(:$T)* = $ex; )* };\n\t($($id:ident $(:$T:ty)*),+ = $ex:expr) => { let _tmp_expr = $ex; $( let $id $(:$T)* = _tmp_expr; )* };\n ($($id:ident $(:$T:ty)*),+ = $($ex:expr),+) => { $( let $id $(:$T)* = $ex; )* };\n\n (mut $($id:ident $(:$T:ty)*),+ =.. $ex:expr) => { $( let mut $id $(:$T)* = $ex; )* };\n (mut $($id:ident $(:$T:ty)*),+ = $($ex:expr),+) => { $( let mut $id $(:$T)* = $ex; )* }; \n}\n\nfn main() {\n let w: u8 = read!();\n if w > 3 && w % 2 == 0 {\n \tprintln!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "a6617399e946fd3ecf49a31d9d30e131", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var, $t:ty, $($v:ident), *) => {\n read_line!(input_line);\n let mut iter = parse_token!($t, input_line);\n $(\n let $v = iter.next().unwrap();\n )*\n };\n (vec, $t:ty, $v:ident) => {\n read_line!(input_line);\n let iter = parse_token!($t, input_line);\n let $v: Vec<$t> = iter.collect();\n };\n ($($v:ident; $t:ty), *) => {\n read_line!(input_line);\n let mut iter = input_line.split_whitespace();\n $(\n let $v: $t = iter.next().unwrap().parse().unwrap();\n )*\n };\n}\n\nmacro_rules! parse_token {\n ($t:ty, $e:expr) => {\n $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());\n };\n}\n\nfn main() {\n read_line!(w;u64);\n match w % 2 {\n 0 => println!(\"YES\"),\n 1 => println!(\"NO\"),\n _ => unreachable!()\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8a854743b5691d6ffbafe91819e4cbcc", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut weight = String::new();\n io::stdin()\n .read_line(&mut weight)\n .except(\"Failed\");\n let weight: u32 = guess.trim().parse().except(\"No Number\");\n if (weight % 2 ==0){\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "fa8c63457217ceb27317f4e7d8a06fa3", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn watermelon(weight: usize) -> String {\n match weight % 2 {\n 0 => \"YES\",\n _ => \"NO\",\n }.to_string()\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "a57102355d3454942630b771aa47da88", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn kd(k: i32) -> bool {\n if k % 2 != 0 || k > 100 || k-k == 2 * k { return false; }\n return true\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2d0713653eace8dbc371cd136c9d5505", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut weight = String::new();\n io::stdin()\n .read_line(&mut weight)\n .except(\"Failed\")\n let weight: u32 = guess.trim().parse().except(\"No Number\")\n if (weight % 2 ==0){\n println!(\"YES\")\n }\n else {\n println!(\"NO\")\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "1d3b63af53c0a44fbe15dfe092a04a5b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "\nfn even_parts(w: i32) -> &'static str {\n\n for k in 0..101 {\n if w/2 == 2*k {\n return \"YES\";\n }\n if w/2 == 2*k+1 {\n return \"NO\";\n }\n }\n return \"WTF\";\n\n \n}\n\nfn main() {\n let mut input = String::new();\n\n io::stdin()\n .read_line(&mut input)\n .expect(\"Failed to read input\");\n let rinput: i32 = input.trim_end().parse().unwrap();\n even_parts(rinput);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "df0a3bc4d7092b9d792d502fd426f70c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() {\n let line = stdin().read_line(&mut line).unwrap();\n let n: u8 = line.trim().parse().unwrap();\n \n if n > 3 && n % 2 == 0 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "e01dd4d87e80d2111c12a2b626fb3c9a", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\nlet mut melon = String::new();\nstd::io::stdin().read_line(&mut melon)\n .expect(\"Failed to read line\");\n\nlet _melon = melon\n .trim()\n .parse::().unwrap();\nif melon % 2 == 0 {\n if melon != 2 {\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }\n}\nelse {\n println!(\"NO\");\n}\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "31b851ee5ec9dde7cc0352c81dcac4cb", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() {\n let mut buffer = String::new();\n stdin().read_line(&mut buffer).expect(\"Cannot read line\");\n let i = buffer.trim().parse::().expect(\"Cannot parse\");\n\n if i % 2 == 0 && n / 2 > 1 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ef401c9d7846bb8e37cb9ea85c7a392b", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nfn main() {\n let mut N = String::new();\n io::stdin().read_line(&mut N).ok();\n let N: i32 = N.trim().parse()\n if N % 2 == 0 && N > 2{\n println !(\"YES\");\n }else{\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "08ceac771c776ba11eb72f08cd0521e2", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nfn main() {\n let mut N = String::new();\n io::stdin().read_line(&mut N).ok();\n let N: i32 = N.trim().parse();\n if N % 2 == 0 && N > 2{\n println !(\"YES\");\n }else{\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "b6eaf8a884829227fc5a748c68e73b41", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn even_parts(w: i32) -> &'static str {\n\n for k in 1..100 {\n if w/2 == 2*k {\n return \"YES\";\n }\n if w/2 == 2*k+1 {\n return \"NO\";\n }\n if w = 2 {\n return \"NO\";\n }\n }\n return \"WTF\";\n\n \n}\n\nfn main() {\n let mut input = String::new();\n\n io::stdin()\n .read_line(&mut input)\n .expect(\"Failed to read input\");\n let rinput: i32 = input.trim_end().parse().unwrap();\n even_parts(rinput);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "e6cd719ac7beb8afab0fd933488b6017", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main()\n{\n let mut input = String::new();\n std::io::stdin()\n .read_line(&mut input)\n .expect(\"Bleh.\");\n input = input.trim().to_string();\n let number : i32 = input.parse().unwrap();\n \n if (number % 2 == 0) && (number != 2)\n {\n println!(\"YES\\n\");\n }\n else\n {\n println!(\"NO\\n\");\n }\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "9c42fbbddcd27fd874e7f0f05f7f6bee", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn even_parts(w: i32) -> &'static str {\n match w % 2 == 0 && w != 2 {\n true => \"yes\",\n false => \"no\",\n }\n}\n\nfn main() {\n let mut input = String::new();\n io::stdin()\n .read_line(&mut input)\n .expect(\"Failed to read input\");\n let rinput: i32 = input.trim().parse().unwrap();\n println!(\"{}\", even_parts(rinput));\n}\n[2:39 PM] fl: heres ", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "208c7991db37cada2200e5ecd0c552fe", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "#![feature(asm)]\nfn main() {\n let n: i32 = std::io::stdin()\n .lock()\n .lines()\n .next()\n .expect(\"stdin should be available\")\n .expect(\"couldn't read from stdin\")\n .trim()\n .parse()\n .expect(\"input was not an integer\");\n println!(if (n > 2 && n % 2 == 0) {\n \"YES\"\n } else {\n \"NO\"\n });\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d94abc0e14cdbc2bae5a4a523d21422c", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n fn kd(k: i32) -> str {\n if k % 2 != 0 || k > 100 || k-k == 2 * k { println!(\"NO\"); }\n println!(\"YES\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "9a0e5c74c6a8b3d0ffc7e61ed8002758", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n let watermelon = kd(k);\n if watermelon {\n println!(\"YES\");\n } else {\n println!(\"NO\")\n }\n}\nfn kd(k: i32) -> bool {\n if k % 2 != 0 || k > 100 || k-k == 2 * k { return false; }\n return true\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8d2c20cec0e91c8013cbe42360af2f15", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::{Read, stdin};\n\nfn main() {\n let mut s = String::new();\n stdin().read_line(&mut s).unwrap();\n let n : u32 = s.trim().parse();\n if n % 2 == 0 {\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "042c899d2504ac761809471cfe9503bd", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main()\n{\n let mut input = String::new();\n std::io::stdin\n .read_line(&mut input)\n .expect(\"Bleh.\");\n let number : i32 = input.parse().unwrap();\n \n if (number % 2 == 0) && (num != 2)\n {\n println!(\"YES\\n\");\n }\n else\n {\n println!(\"NO\\n\");\n }\n} ", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d0ba81b3f197ad35e0d0e3e255982ab8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "//spnauti-rust\n#[allow(unused_imports)]\nuse std::io::{self,Read};\n\nstruct WordReader {\n it : std::vec::IntoIter,\n}\n#[allow(dead_code)]\nimpl WordReader {\n fn new(mut reader : T) -> WordReader {\n let mut s = String::new();\n reader.read_to_string(&mut s).unwrap();\n WordReader { it : s\n .split_ascii_whitespace()\n .map(String::from).collect::>()\n .into_iter()\n }\n }\n fn from_stdin() -> WordReader {\n WordReader::new(std::io::stdin())\n }\n fn s(&mut self) -> String {\n self.it.next().unwrap()\n }\n fn ab(&mut self) -> Vec {\n self.it.next().unwrap().into_bytes()\n }\n fn i(&mut self) -> i32 {\n self.it.next().unwrap().parse().unwrap()\n }\n}\n\nfn main() {\n let mut input = WordReader::from_stdin();\n let n = (input.i() - 1) as usize;\n let m = input.i();\n let mut a = Vec::with_capacity(m);\n for _ in 0..m {\n a.push(input.i());\n }\n a.sort();\n let mut sol = 1000;\n for i in n..m {\n sol = std::cmp::min(sol, a[i] - a[i - n]);\n }\n println!(\"{}\", sol);\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "60a194976aa358e6655a762f20eb3f21", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "Rust", "source_code": "std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_vec(split_char: char) -> Vec {\n read_str()\n .split(split_char)\n .map(|value| value.parse::().ok().expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n let students: usize = read_vec(' ')[0];\n let mut pieces: Vec = read_vec(' ');\n pieces.sort();\n let mut difference: u16 = u16::max_value();\n\n let mut index: usize = 0;\n let end: usize = pieces.len() - students;\n loop {\n difference = std::cmp::min(difference, pieces[index + students - 1] - pieces[index]);\n index += 1;\n if index > end { break; }\n }\n print!(\"{}\", difference);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "c480a3bbf210179273a407d24b5a556e", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn main(){\n let mut input_str = String::new();\n std::io::stdin().read_line(&mut input_str).unwrap();\n let k = input_str.trim().parse::().unwrap();\n\n let mut cnt : [u64;11] = [1;11];\n\n let mut repeat = 1;\n let mut min_length = u64::MAX;\n let (mut repeat_needed, mut addition_needed) = (1,0);\n while cnt[10]0 {\n (k-cnt[10]) / cnt[9] + 1\n }\n else{\n 0\n };\n\n if repeat * 10 + addition < min_length {\n min_length = repeat * 10 + addition;\n repeat_needed = repeat;\n addition_needed = addition;\n }\n\n repeat+=1;\n for i in 1..11 {\n cnt[i] += cnt[i-1];\n }\n }\n\n let mut ans = String::from(\"codeforces\");\n ans = ans.repeat(repeat_needed as usize);\n\n ans.push_str(&\"s\".repeat(addition_needed as usize));\n\n println!(\"{}\",ans);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "833a8ab347d7951129d63b82abfcfb4b", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0} {"lang": "Rust", "source_code": "#![allow(dead_code)]\n\nuse std::fmt::Debug;\nuse std::str::FromStr;\n\nfn read_stdin() -> String {\n let mut s = String::new();\n std::io::stdin()\n .read_line(&mut s)\n .expect(\"cannot read stdin\");\n s\n}\n\nfn read() -> T\nwhere\n T: std::str::FromStr,\n ::Err: std::fmt::Debug,\n{\n read_stdin().trim().parse::().unwrap()\n}\n\nfn read_usize() -> usize {\n read::()\n}\n\nfn read_2() -> (A, B)\nwhere\n A: std::str::FromStr,\n ::Err: std::fmt::Debug,\n B: std::str::FromStr,\n ::Err: std::fmt::Debug,\n{\n let s = read_stdin();\n let mut s = s.trim().split_whitespace();\n let a = s.next().unwrap().parse::().unwrap();\n let b = s.next().unwrap().parse::().unwrap();\n (a, b)\n}\n\nfn read_multiple() -> Vec\nwhere\n ::Err: Debug,\n{\n read_stdin()\n .trim()\n .split_whitespace()\n .map(|x| x.trim().parse::().expect(\"cannot parse stdin\"))\n .collect()\n}\n\nfn count(iter: &mut impl Iterator) -> Vec<(T, usize)>\nwhere\n T: std::cmp::Ord,\n{\n let mut iter = iter.collect::>();\n iter.sort();\n let (mut v, o, c) =\n iter.into_iter()\n .fold((Vec::new(), None, 0), |(mut v, last, count), item| {\n if let Some(o) = last {\n if item == o {\n (v, Some(o), count + 1)\n } else {\n v.push((o, count));\n (v, Some(item), 1)\n }\n } else {\n (v, Some(item), 1)\n }\n });\n if let Some(i) = o {\n v.push((i, c));\n }\n v\n}\nfn main() -> Result<(), Box> {\n let n = read_usize();\n let powers = [\n 1usize,\n 1024,\n 59049,\n 1048576,\n 9765625,\n 60466176,\n 282475249,\n 1073741824,\n 3486784401,\n 10000000000,\n 25937424601,\n 61917364224,\n 137858491849,\n 289254654976,\n 576650390625,\n 1099511627776,\n 2015993900449,\n 3570467226624,\n 6131066257801,\n 10240000000000,\n 16679880978201,\n 26559922791424,\n 41426511213649,\n 63403380965376,\n 95367431640625,\n 141167095653376,\n 205891132094649,\n 296196766695424,\n 420707233300201,\n 590490000000000,\n 819628286980801,\n 1125899906842624,\n 1531578985264449,\n 2064377754059776,\n 2758547353515625,\n 3656158440062976,\n 4808584372417849,\n 6278211847988224,\n 8140406085191601,\n ];\n let i = powers.iter().take_while(|i| **i < n).count();\n let mut v = [i; 10];\n let mut idx = 0;\n while v.iter().product::() < n {\n v[idx] += 1;\n idx += 1;\n }\n let s = \"codeforces\";\n for (c, n) in s.chars().zip(v.iter()) {\n for _ in 0..*n {\n print!(\"{}\", c)\n }\n }\n /*for _ in 0..n {\n let v = read_multiple::();\n let mut a = v[0];\n let mut b = v[1];\n let n = v[2];\n if a < b {\n std::mem::swap(&mut a, &mut b);\n }\n let mut c = 0;\n while a <= n {\n b = a + b;\n std::mem::swap(&mut a, &mut b);\n c += 1;\n }\n println!(\"{}\", c);\n\n }*/\n Ok(())\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "16c3526b60135944a1895c25b1004fa5", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0} {"lang": "Rust", "source_code": "#![allow(unused_variables)]\n#![allow(unused_must_use)]\nuse std::io::{self, prelude::*};\nuse std::cmp::min;\n\n\nfn gcd(a: i32, b: i32) -> i32 {\n if a == 0 {\n return b;\n }\n\n if b == 0 {\n return a;\n }\n\n if a == b {\n return a;\n }\n\n if a>b {\n return gcd(a-b, b);\n }\n\n return gcd(a, b-a)\n\n}\nfn solve(mut input: FastInput, mut w: W) {\n let a: i32 = input.token();\n let b: i32 = input.token();\n let mut x: i32 = input.token();\n let mut y: i32 = input.token();\n g = gcd(x,y);\n x = x / g;\n y = y / g;\n write!(w, \"{}\\n\", min(a/x, b/y));\n\n \n}\n \n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let input = FastInput::from(stdin.lock());\n let output = io::BufWriter::new(stdout.lock());\n solve(input, output)\n}\n\ntrait TokenStream {\n fn token(&mut self) -> T;\n}\n \nstruct FastInput {\n stdin: R,\n pos: usize,\n}\n \nimpl From for FastInput {\n fn from(r: R) -> Self {\n FastInput { stdin: r, pos: 0 }\n }\n}\n \nimpl TokenStream for FastInput {\n fn token(&mut self) -> u8 {\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n while self.pos < buf.len() {\n self.pos += 1;\n if buf[self.pos - 1] > 32 {\n return buf[self.pos - 1];\n }\n }\n if self.pos == 0 {\n return 0;\n }\n } else {\n return 0;\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nimpl TokenStream> for FastInput {\n fn token(&mut self) -> Vec {\n let mut ans = Vec::new();\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans.push(buf[self.pos]);\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nmacro_rules! impl_token_stream {\n ($($t:ident),+) => {$(\n impl TokenStream<$t> for FastInput {\n fn token(&mut self) -> $t {\n let mut ans = 0;\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans = ans * 10 + (buf[self.pos] - b'0') as $t;\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n }\n )+}\n}\n\n\nimpl_token_stream!(i32);", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "099dd8e11eeebb3aa533d5cc719c6cbf", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n let mut x = 0;\n\n io::stdin().read_line(&mut s).unwrap;\n\n for ch in s.chars() {\n if ch == '4' || ch == '7' {\n x += 1;\n }\n }\n\n if x == 4 || x == 7 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "70971ec61784d6ef0f692a7d04a8814d", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n\n let words: Vec = line\n \t.split_whitespace()\n \t.map(|x| x.parse().unwrap())\n\n let a = words[0];\n let b = words[1];\n let years = 0;\n\n loop {\n \tif a > b {\n \t\tprintln!(\"{}\", years);\n \t}\n \ta *= 3\n \tb *= 2\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "43b6ac8644a72356ab0f08ef8c620df0", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n\n let words: Vec = line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let a = words[0];\n let b = words[1];\n let years = 0;\n\n loop {\n if a > b {\n println!(\"{}\", years);\n }\n a *= 3;\n b *= 2;\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "5cf949ce91a53c51c8af368c5a90181a", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead};\n\nfn main() {\n let stdin = io::stdin();\n let mut input = String::new();\n\n stdin.lock().read_line(&mut input).unwrap();\n let input: Vec = input\n .trim()\n .split(\" \")\n .map(|m| m.parse().unwrap())\n .collect();\n\n let a = input[0];\n let b = input[1];\n\n for i in 0..u32::MAX {\n if a * 3isize.pow(i) - b * 2isize.pow(i) > 0 {\n println!(\"{}\", i);\n break;\n }\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "48964f92c63d50a560bb03d5fcd10ce9", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "Rust", "source_code": "use proconio::input;\n\nfn main() {\n input! {\n s:String,\n t:String,\n }\n\n let s: Vec = s.chars().collect();\n let t: Vec = t.chars().collect();\n let n = s.len();\n let mut ans = String::new();\n\n for i in 0..n {\n ans.push(if s.get(i) != t.get(i) { '1' } else { '0' });\n }\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "a2d14c8934d0aa8910637c81d4358746", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n let mut input = String::new();\n std::io::stdin()\n .read_line(&mut input)\n .expect(\"String not found\");\n input[0] = input[0].to_uppercase();\n println!(\"{}\", input);\n}\n\n// fn first_word_cap (s: &String) -> &String {\n// let bytes = s.as_bytes();\n\n// for (i, &item) in bytes.iter().enumerate() {\n \n// }\n// }", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ea4dee33f2c054c27ee0eb446fa7870b", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Rust", "source_code": "//! http://codeforces.com/contest/281/problem/A\n\nfn main() {\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let str = buf.trim();\n let mut chars = str.chars();\n let c = chars.next().unwrap();\n for c in c.to_uppercase() {\n print!(\"{}\", c);\n }\n for c in chars {\n print!(\"{}\", c);\n }\n println!();\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "bf9113f16d1901d3e7954f0ad7977569", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::fmt::Display;\n\nfn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n for (i, ch) in line.chars().enumerate() {\n if i == 0 {\n print!(\"{}\", ch.to_uppercase());\n }\n else {\n print!(\"{}\", ch);\n }\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "1dc0aa495c0a7dc2123bc95c150de147", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n for (i, ch) in line.chars().enumerate() {\n if i == 0 {\n print!(\"{}\", ch.to_uppercase());\n }\n else {\n print!(\"{}\", ch);\n }\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "5b981dd5f73730c137c73ca945b0768c", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n for (i, ch) in line.chars().enumerate() {\n if i == 0 {\n print!(\"{:?}\", ch.to_uppercase());\n }\n else {\n print!(\"{:?}\", ch);\n }\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ca109c3c61e9671774f13f65468d8980", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nextern crate text_io;\nuse text_io::read;\nfn read() -> String{\n let mut inp=String::new();\n io::stdin().read_line(&mut inp).expect(\"failed to read from stdin\");\n inp\n}\nfn main() {\n let mut s1 = read().parse::().unwrap();\n s1.pop();\n let mut v: Vec = s1.chars().collect();\n v[0] = v[0].to_uppercase().nth(0).unwrap();\n let s2: String = v.into_iter().collect();\n let s3 = &s2;\n println!(\"{}\",s3);\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n /*\n let (mut x,mut y)=(0,0);\n let (mut n1,mut n2)=(0,0);\n let spot=\"1\".parse::().unwrap();\n 'outer:loop{\n let inp=read().trim().parse::().unwrap();\n let list: Vec<&str>=inp.split_whitespace().collect();\n loop{\n let item=list[y].parse::().unwrap();\n if item==spot{\n n1=x;\n n2=y; \n }if y==4{\n break;\n }y+=1;\n }if x==4{\n break 'outer;\n }x+=1;\n }\n println!(\"{},{}\",n1,n2);\n\n\n\n\n\n\n let inp=read().trim().parse::().unwrap();\n let list: Vec<&str>=inp.split_whitespace().collect();\n let n2=list[1].parse::().unwrap();\n let inp=read().trim().parse::().unwrap();\n let list: Vec<&str>=inp.split_whitespace().collect();\n let mut some=0;\n for i in &list{\n let item=i.parse::().unwrap();\n if item <= n2{\n break;\n }else{\n some+=1;\n }\n }println!(\"{}\",some);\n}\n*/\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//fn input1() {\n// let mut x = String::new();\n// io::stdin().read_line(&mut x).expect(\"Error reading input\");\n// let x: f32 = x.trim().parse().expect(\"Error parsing number\");\n// println!(\"{}\",x)\n//}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "4f376e3f0e7ee4c67259639241258e4c", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "Rust", "source_code": " let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n\n let mut num = buffer.trim().parse::().unwrap();\n let mut bills = 0;\n\n while num > 0 {\n if num >= 100 {\n num -= 100;\n bills += 1;\n }\n else if num >= 20 {\n num -= 20;\n bills += 1;\n }\n else if num >= 10 {\n num -= 10;\n bills += 1;\n }\n else if num >= 5 {\n num -= 5;\n bills += 1;\n }\n else if num >= 1 {\n num -= 1;\n bills += 1;\n }\n }\n\n println!(\"{}\", bills);", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "33e40af5c97bc65ad6287ff98afae38f", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn get_single_number_from_stdin() -> usize {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).unwrap();\n buffer.trim().parse::().expect(\"Not an integer\")\n}\n\nfn main(){\n let dollars = get_single_number_from_stdin();\n let denominations = vec![100,20,10,5,1];\n let mut result = vec![u32::MAX; (dollars+1) as usize];\n result[0] = 0;\n for i in 1..=dollars {\n for d in &denominations {\n if *d <= i {\n let sub_result = result[(i - *d) as usize];\n if sub_result != u32::MAX && sub_result + 1 < result[i] {\n result[i] = sub_result + 1;\n }\n }\n }\n }\n println!(\"{}\",result[dollars]);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8c0e3fbb04028e48c092e621dad83e9b", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn get_single_number_from_stdin() -> usize {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).unwrap();\n buffer.trim().parse::().expect(\"Not an integer\")\n}\n\nfn main(){\n let dollars = get_single_number_from_stdin();\n let denominations = vec![100,20,10,5,1];\n let mut result = vec![u32::MAX; (dollars+1) as usize];\n result[0] = 0;\n \n for i in 1..=dollars {\n for d in &denominations {\n if *d <= i {\n let sub_result = result[(i - *d) as usize];\n if sub_result != u32::MAX && sub_result + 1 < result[i] {\n result[i] = sub_result + 1;\n }\n }\n }\n }\n println!(\"{}\",result[dollars]);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "6df8bbdf6b2523b184216d0e97c1908b", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n\n let mut input = buf\n .split_ascii_whitespace()\n .map(|s| s.parse::().unwrap());\n\n // length\n let n = input.next().unwrap();\n // route 1 (+)\n let a = input.next().unwrap();\n let x = input.next().unwrap();\n // route 2 (-)\n let b = input.next().unwrap();\n let y = input.next().unwrap();\n\n println!(\"{}\", match solve(n, a, x, b, y) {\n true => \"YES\",\n false => \"NO\",\n });\n}\n\nfn solve(n: i32, a: i32, x: i32, b: i32, y: i32) -> bool {\n (y .. b + n + 1).rev().zip(a .. x + n + 1).any(|(i, j)| i % n == j % n)\n}\n\n#[cfg(test)]\nmod test {\n\n use super::solve;\n #[test]\n fn test1() {\n assert_eq!(solve(5, 1, 4, 3, 2), true);\n }\n #[test]\n fn test2() {\n assert_eq!(solve(10, 2, 1, 9, 10), false);\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "58385fe24ae0177cd0146d25759b7909", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn main() {\n let n = read_line().parse::().unwrap();\n let mut s: isize = 0;\n\n for i in 1..=n {\n if i % 2 == 0 {\n s += i\n } else {\n s -= i\n }\n }\n println!(\"{}\", s);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d46b0e44ca34b0970315ecf273a685f5", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0} {"lang": "Rust", "source_code": "#![allow(non_snake_case)]\n#![allow(unused_must_use)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\npub fn main() {\n let nk = rus();\n let n = nk[0];\n let k = nk[1];\n let ss = rus();\n \n let t = ss[k as usize - 1];\n let mut c = 0;\n\n if t == 0 {\n for &s in &ss {\n if s == 0 {\n println!(\"{}\", c);\n return;\n } else {\n c += 1;\n }\n }\n } else {\n for i in k..n {\n if ss[i as usize] == t {\n c += 1;\n } else {\n println!(\"{}\", k + c);\n return;\n }\n }\n }\n println!(\"{}\", n);\n}\n\n\n//read u64\nfn ru() -> u64 {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.trim().parse::().unwrap()\n}\n\n//read u64 vec\nfn rus() -> Vec {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.split_whitespace().map(|x| x.parse::().unwrap())\n .collect::>()\n}\n\n//read i64\nfn ri() -> i64 {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.trim().parse::().unwrap()\n}\n\n//read i64 vec\nfn ris() -> Vec {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.split_whitespace().map(|x| x.parse::().unwrap())\n .collect::>()\n}\n\nuse std;\n\ntrait UU {\n fn uu(self) -> T;\n}\n\nimpl UU for Option {\n fn uu(self) -> T {\n self.unwrap()\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "c9fdf12fbee571eb82706c171b041bef", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::io::{BufWriter, stdin, stdout, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let n: (i32,i32) = (scan.next::(),scan.next::());\n let mut j : Vec = Vec::new();\n let mut result = 0i16;\n\n for _i in 0..n.0 {\n j.push(scan.next::());\n }\n\n for score in j {\n if score >= j(n.1) && score > 0 {\n result +=1;\n }\n }\n\n println!(\"{}\", result);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "9a31f1e4fa4f47b705b4217da45ff2e4", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::{self, Read};\nuse std::convert::TryFrom;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_to_string(&mut s).unwrap();\n\n let mut a = s.split_whitespace().map(|a| a.parse::().unwrap());\n a.next().unwrap();\n let k = usize::try_from(a.next().unwrap()).unwrap();\n let mut c = 1;\n let mut sol = 0;\n\n for (i, x) in a.enumerate() {\n if x > 0 && i < k {\n c = x;\n }\n if x >= c {\n sol += 1;\n }\n }\n\n println!(\"{}\", sol);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "7ccf6ee597673c0f61270fe9044d207b", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main(){\n\tlet mut s = String::new();\n std::io::stdin()\n .read_line(&mut s)\n .unwrap();\n\n\n let sp:Vec<&str> = s.trim().split_whitespace().collect();\n\n let n:i64 = sp[0].trim().parse().unwrap();;\n let k:usize = sp[1].trim().parse().unwrap();;\n\n\n\tlet mut s = String::new();\n std::io::stdin()\n .read_line(&mut s)\n .expect(\"failed to read input.\");\n\n let sa:Vec<&str> = s.trim().split_whitespace().collect();\n\n let mut len = 0;\n let mut kNum = -1;\n \n for (i, s) in sa.iter().enumerate(){\n \tlet mut i = i + 1\n \tlet mut cur:i64 = s.trim().parse().unwrap();\n \tif i == k {\n \t\tkNum = cur;\n \t}\n\t \tif cur > 0 && (i < k || (i >= k && kNum == cur))\n\t \t{\n\t \t\tlen += 1;\n\t \t}\n \t\n }\n\n print!(\"{:?}\", len);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d0b6069abfd786e31c7b68092d1e1c28", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::io::{BufWriter, stdin, stdout, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let n: (i32,i32) = (scan.next::(),scan.next::());\n let mut j : Vec;\n let mut result = 0i16;\n\n for _i in 0..n.0 {\n j.push(scan.next::());\n }\n\n for score in j {\n if score > n.1 {\n result +=1;\n }\n }\n\n println!(\"{}\", result);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "817ee4c11387bf1ba826544d16181207", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut limits = String::new();\n\n io::stdin().read_line(&mut limits).expect(\"unknown error\");\n\n let mut scores = String::new();\n\n io::stdin().read_line(&mut scores).expect(\"unknown error\");\n\n let n: usize = limits\n .split(\" \")\n .next()\n .unwrap()\n .trim()\n .parse()\n .expect(\"Not a number\");\n let k: usize = limits\n .split(\" \")\n .last()\n .unwrap()\n .trim()\n .parse()\n .expect(\"Not a number\");\n\n let scores: Vec = scores\n .trim()\n .split_whitespace()\n .map(|s| s.parse().expect(\"parse error\"))\n .collect();\n\n let mut answer: u32 = 0;\n\n for i in 0..n {\n if let (Some(val_1), Some(val_2)) = \n (&scores.get(i), &scores.get(k)){\n if val_1 >= val_2 && val_1 > 0{\n answer+=1;\n }\n }\n }\n\n println!(\"{}\", answer);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "9d6b703792ee06f84e84bec01744997e", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io; \n\nfn main (){\n let s1 = String::new(); \n io::stdin().read_line(&mut s1).expect(\"e\"); \n\n let mut v1 :Vec = s1.trim()\n .split(\" \")\n .map(|x|{x.parse::().expect(\"e\")})\n .collect(); \n\n let mut s2 = String::new(); \n io::stdin().read_line(&mut s2).expect(\"e\"); \n let mut v2 :Vec = s2.trim()\n .split(\" \")\n .map(|x|{x.parse::().expect(\"e\")})\n .filter(|x|{x>&v1[1]})\n .collect(); \n \n println!(\"{}\",v2.iter().count());\n \n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "cc4e7c7d8322b9665f517b9a54aca5c9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main(){\n\tlet mut s = String::new();\n std::io::stdin()\n .read_line(&mut s)\n .unwrap();\n\n\n let sp:Vec<&str> = s.trim().split_whitespace().collect();\n\n let n:i64 = sp[0].trim().parse().unwrap();;\n let k:usize = sp[1].trim().parse().unwrap();;\n\n\n\tlet mut s = String::new();\n std::io::stdin()\n .read_line(&mut s)\n .expect(\"failed to read input.\");\n\n let sa:Vec<&str> = s.trim().split_whitespace().collect();\n\n let mut len = 0;\n let mut kNum = -1;\n \n for (i, s) in sa.iter().enumerate(){\n \ti += 1\n \tlet mut cur:i64 = s.trim().parse().unwrap();\n \tif i == k {\n \t\tkNum = cur;\n \t}\n\t \tif cur > 0 && (i < k || (i >= k && kNum == cur))\n\t \t{\n\t \t\tlen += 1;\n\t \t}\n \t\n }\n\n print!(\"{:?}\", len);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2804f35bc7e109351fe9ad3a9d440c86", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() { \n let stdin = stdin();\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let vec = s.split_whitespace().map(|x| x.parse::().expect(\"number parse error\")).collect::>();\n if (vec[0] / vec[1])&1 > 0 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "4781f77e17b30052890e6618ea9643ab", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet};\n#[allow(unused_imports)]\nuse std::io::*;\n#[allow(unused_imports)]\nuse std::str::*;\nextern crate num;\n\n#[allow(unused_macros)]\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n let mut next = || { iter.next().unwrap() };\n input_inner!{next, $($r)*}\n };\n ($($r:tt)*) => {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input_inner!{next, $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! input_inner {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input_inner!{$next $($r)*}\n };\n\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(dead_code)]\nfn read() -> T {\n let cin = stdin();\n let cin = cin.lock();\n let s: String = cin\n .bytes() // Bytes\n .map(|c| c.expect(\"failed reading char\") as char)\n .skip_while(|c| c.is_whitespace()) // c \u304c whitespace \u3067\u3042\u308b\u9650\u308a skip\n .take_while(|c| !c.is_whitespace()) // c \u304c whitespace \u3067\u306a\u3044\u9650\u308a\u8981\u7d20\u3092\u8fd4\u3059\n .collect();\n s.parse().ok().expect(\"failed parsing\")\n}\n\n#[allow(non_snake_case)]\nfn main() {\n input! {\n n:u64,\n m:u64,\n a:u64\n }\n let x = n / a + (((n % a) > 0) as u64);\n let y = m / a + (((m % a) > 0) as u64);\n println!(\"{}\", x * y);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "f5cf3fd458d20d10d048e9644e41bb23", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nfn main() {\n let mut result:i64 = 0;\n let (m,n,a) = parse_line!(i64,i64,i64);\n if(a*a < m*n){\n let mut xx = 0;\n let mut yy = 0;\n let mut iter1 = m;\n let mut iter2 = n;\n while(iter1 > 0){\n iter1 -= a;\n xx += 1;\n }\n\n while(iter2 > 0){\n iter2 -= a;\n yy += 1;\n }\n for x in 0..xx {\n for y in 0..yy{\n result += 1;\n }\n }\n }else if(a == 1) {\n retult = m * n;\n } else{\n result = 1\n }\n println!(\"{}\",result)\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "b8f6a407792016b754dc2d71cf68a2b1", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "fn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\nmacro_rules! scanln {\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\nfn main() -> () {\n\n let (n,m,a) = scanln!(i64, i64, i64);\n let ans = ((n + a - 1) / a) + ((m + a - 1) / a);\n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ec7874b714aed03da90726117e09b48e", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "fn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\nmacro_rules! scanln {\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\nfn main() -> {\n let (n,m,a) = scanln!(i64, i64, i64);\n let ans = ((n + a - 1) / a) + ((m + a - 1)/a);\n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "4bc1982c191c4cdaf7eb6b6edc9de2a1", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#[macro_use]\nextern crate text_io;\n\nfn main() {\n let n: i64 = read!();\n let m: i64 = read!();\n let a: i64 = read!();\n let x = (n + a - 1) / a;\n let y = (m + a - 1) / a;\n println!(\"{}\", x * y);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "a34c5ea5eee1bdb7be36407a449421b6", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nfn main() {\n let mut result:u128 = 0;\n let (m,n,a) = parse_line!(f32,f32,f32);\n result = ((m/a).ceil() * (n/a).ceil()) as usize;\n println!(\"{}\",result)\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "bc011ad446d18e043ad8aa5adaf38adb", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "fn main() {\n // Input n, m, a\n let mut s_line = String::new();\n std::io::stdin().read_line(&mut s_line).unwrap();\n\n // Caculate results\n let vf64_nums: Vec =\n s_line.trim().split_whitespace().\n map(|s| s.parse().unwrap()).collect();\n\n let f64_r =\n ((vf64_nums[0] / vf64_nums[2]).ceil() *\n (vf64_nums[1] / vf64_nums[2]).ceil()).floor();\n \n // Display the result\n println!(f64_r);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "7530a4658e7f5f51f15c56b4e07ccdab", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#![allow(non_snake_case, unused_imports, deprecated, dead_code)]\n\n// Input macros\nmacro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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)*} }; }\nmacro_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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\nmacro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect(\"Parse error\") }; }\n\n// Module\nuse std::cmp::{min,max};\nuse std::collections::{VecDeque,HashSet,HashMap,BinaryHeap};\n// Module for v1.15.1\nuse std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead\n\n// Functions\n\n// Main\nfn main() {\n\n input! {\n N: usize,\n X: usize\n }\n\n let mut ans = 0;\n let primes = get_primes(N);\n for i in 1..N+1{\n if X%i==0 && X/i<=N {\n ans += 1;\n }\n }\n\n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "066e4d8e1bab45f65ec0bd11b11136b8", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#![allow(non_snake_case, unused_imports, deprecated, dead_code)]\n\n// Input macros\nmacro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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)*} }; }\nmacro_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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\nmacro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect(\"Parse error\") }; }\n\n// Module\nuse std::cmp::{min,max};\nuse std::collections::{VecDeque,HashSet,HashMap,BinaryHeap};\n// Module for v1.15.1\nuse std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead\n\n// Functions\n\n// Main\nfn main() {\n\n input! {\n N: usize,\n X: usize\n }\n\n let mut ans = 0;\n let primes = get_primes(N);\n for i in 1..N+1{\n if X%i==0 && X/i<=N {\n ans += 1;\n println!(\"{} {}\", ans, i);\n }\n }\n\n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "114c2b56cd6da081286e4998a15d0465", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\nuse pio2::*;\nuse procon_temp::mod_int::ModInt;\nuse std::{\n collections::*,\n io::{self, prelude::*},\n};\nfn run(mut pin: I, mut out: O) {\n let t: u32 = 1;\n for _ in 0..t {\n case(&mut pin, &mut out);\n }\n}\nfn case(mut pin: I, mut out: O) {\n use mod_int::*;\n type Mint = ModInt;\n let (n, m): (usize, u32) = pin.parse();\n set_var_mod(m);\n let mut div = vec![Mint::new(0); n + 1];\n let mut dp = vec![Mint::new(0); n + 1];\n dp[1] = Mint::new(1);\n let mut sum = Mint::new(0);\n for i in 1..=n {\n div[i] = div[i] + div[i - 1];\n dp[i] = dp[i] + sum + div[i];\n sum += dp[i];\n for z in 2.. {\n if i * z > n {\n break;\n }\n div[i * z] += dp[i];\n if let Some(d) = div.get_mut((i + 1) * z) {\n *d -= dp[i];\n }\n }\n }\n let ans = dp[n];\n wln!(out, \"{}\", ans);\n}\nfn main() {\n let stdin = io::stdin();\n let mut pin = Scanner::new(stdin.lock());\n let stdout = io::stdout();\n let mut out = stdout.lock();\n run(&mut pin, &mut out);\n}\npub mod mod_int {\n use std::{cmp, fmt, marker::PhantomData, ops, sync::atomic};\n #[macro_export]\n macro_rules! def_mint {\n ($modulo:expr, $ModuloTy:ident) => {\n pub struct $ModuloTy;\n impl crate::mod_int::Modulo for $ModuloTy {\n fn modulo() -> u32 {\n $modulo\n }\n }\n pub type Mint = crate::mod_int::ModInt<$ModuloTy>;\n pub fn mint(x: u32) -> Mint {\n crate::mod_int::ModInt::new(x)\n }\n };\n }\n pub trait Modulo {\n fn modulo() -> u32;\n }\n pub struct VarMod;\n static VAR_MOD: atomic::AtomicU32 = atomic::AtomicU32::new(0);\n pub fn set_var_mod(m: u32) {\n VAR_MOD.store(m, atomic::Ordering::Relaxed);\n }\n impl Modulo for VarMod {\n fn modulo() -> u32 {\n VAR_MOD.load(atomic::Ordering::Relaxed)\n }\n }\n #[repr(transparent)]\n pub struct ModInt(u32, PhantomData<*const M>);\n impl ModInt {\n pub fn new(x: u32) -> Self {\n debug_assert!(x < M::modulo());\n Self(x, PhantomData)\n }\n pub fn normalize(self) -> Self {\n if self.0 < M::modulo() {\n self\n } else {\n Self::new(self.0 % M::modulo())\n }\n }\n pub fn get(self) -> u32 {\n self.0\n }\n pub fn inv(self) -> Self {\n assert_ne!(self, Self::new(0));\n self.pow(M::modulo() - 2)\n }\n pub fn half(self) -> Self {\n Self::new(self.0 / 2 + self.0 % 2 * ((M::modulo() + 1) / 2))\n }\n pub fn modulo() -> u32 {\n M::modulo()\n }\n }\n impl ops::Neg for ModInt {\n type Output = Self;\n fn neg(self) -> Self {\n Self::new(if self.0 == 0 { 0 } else { M::modulo() - self.0 })\n }\n }\n impl ops::Neg for &ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n -(*self)\n }\n }\n impl ops::Add for ModInt {\n type Output = Self;\n fn add(self, rhs: Self) -> Self {\n let s = self.0 + rhs.0;\n Self::new(if s < M::modulo() { s } else { s - M::modulo() })\n }\n }\n impl ops::Sub for ModInt {\n type Output = Self;\n fn sub(self, rhs: Self) -> Self {\n Self::new(if self.0 >= rhs.0 {\n self.0 - rhs.0\n } else {\n M::modulo() + self.0 - rhs.0\n })\n }\n }\n impl ops::Mul for ModInt {\n type Output = Self;\n fn mul(self, rhs: Self) -> Self {\n Self::new((self.0 as u64 * rhs.0 as u64 % M::modulo() as u64) as u32)\n }\n }\n impl ops::Div for ModInt {\n type Output = Self;\n fn div(self, rhs: Self) -> Self {\n self * rhs.inv()\n }\n }\n macro_rules ! op_impl { ($ ($ Op : ident $ op : ident $ OpAssign : ident $ op_assign : ident) *) => { $ (impl < M : Modulo > ops ::$ Op <& Self > for ModInt < M > { type Output = Self ; fn $ op (self , rhs : & Self) -> Self { self .$ op (* rhs) } } impl < M : Modulo > ops ::$ Op < ModInt < M >> for & ModInt < M > { type Output = ModInt < M >; fn $ op (self , rhs : ModInt < M >) -> ModInt < M > { (* self) .$ op (rhs) } } impl < M : Modulo > ops ::$ Op <& ModInt < M >> for & ModInt < M > { type Output = ModInt < M >; fn $ op (self , rhs : & ModInt < M >) -> ModInt < M > { (* self) .$ op (* rhs) } } impl < M : Modulo > ops ::$ OpAssign for ModInt < M > { fn $ op_assign (& mut self , rhs : Self) { * self = ops ::$ Op ::$ op (* self , rhs) ; } } impl < M : Modulo > ops ::$ OpAssign <& ModInt < M >> for ModInt < M > { fn $ op_assign (& mut self , rhs : & ModInt < M >) { self .$ op_assign (* rhs) ; } }) * } ; }\n op_impl! { Add add AddAssign add_assign Sub sub SubAssign sub_assign Mul mul MulAssign mul_assign Div div DivAssign div_assign }\n impl std::iter::Sum for ModInt {\n fn sum>(iter: I) -> Self {\n iter.fold(ModInt::new(0), |x, y| x + y)\n }\n }\n impl<'a, M: Modulo + 'a> std::iter::Sum<&'a ModInt> for ModInt {\n fn sum>>(iter: I) -> Self {\n iter.copied().sum()\n }\n }\n impl std::iter::Product for ModInt {\n fn product>(iter: I) -> Self {\n iter.fold(ModInt::new(1), |x, y| x * y)\n }\n }\n impl<'a, M: Modulo + 'a> std::iter::Product<&'a ModInt> for ModInt {\n fn product>>(iter: I) -> Self {\n iter.copied().product()\n }\n }\n pub trait Pow {\n fn pow(self, n: T) -> Self;\n }\n macro_rules ! mod_int_pow_impl { ($ ($ uty : ident $ ity : ident) *) => { $ (impl < M : Modulo > Pow <$ uty > for ModInt < M > { fn pow (mut self , mut n : $ uty) -> Self { let mut y = Self :: new (1) ; while n > 0 { if n & 1 == 1 { y *= self ; } self *= self ; n /= 2 ; } y } } impl < M : Modulo > Pow <$ ity > for ModInt < M > { fn pow (self , n : $ ity) -> Self { if n >= 0 { self . pow (n as $ uty) } else { self . inv () . pow (- n as $ uty) } } }) * } ; }\n mod_int_pow_impl ! (usize isize u32 i32 u64 i64);\n macro_rules ! mod_int_from_impl { ($ ($ T : ident) *) => { $ (impl < M : Modulo > From <$ T > for ModInt < M > { # [allow (unused_comparisons)] fn from (x : $ T) -> Self { if M :: modulo () <= $ T :: max_value () as u32 { Self :: new (x . rem_euclid (M :: modulo () as $ T) as u32) } else if x < 0 { Self :: new ((M :: modulo () as i32 + x as i32) as u32) } else { Self :: new (x as u32) } } }) * } }\n mod_int_from_impl ! (isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128);\n impl From for ModInt {\n fn from(x: bool) -> Self {\n Self::new(x as u32)\n }\n }\n impl Copy for ModInt {}\n impl Clone for ModInt {\n fn clone(&self) -> Self {\n *self\n }\n }\n impl Default for ModInt {\n fn default() -> Self {\n Self::new(0)\n }\n }\n impl cmp::PartialEq for ModInt {\n fn eq(&self, other: &Self) -> bool {\n self.0 == other.0\n }\n }\n impl cmp::Eq for ModInt {}\n impl cmp::PartialOrd for ModInt {\n fn partial_cmp(&self, other: &Self) -> Option {\n self.0.partial_cmp(&other.0)\n }\n }\n impl cmp::Ord for ModInt {\n fn cmp(&self, other: &Self) -> cmp::Ordering {\n self.0.cmp(&other.0)\n }\n }\n impl std::hash::Hash for ModInt {\n fn hash(&self, state: &mut H) {\n self.0.hash(state);\n }\n }\n impl fmt::Display for ModInt {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n self.0.fmt(f)\n }\n }\n impl fmt::Debug for ModInt {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n self.0.fmt(f)\n }\n }\n}\npub mod macros {\n #[macro_export]\n macro_rules ! w { ($ ($ arg : tt) *) => { write ! ($ ($ arg) *) . unwrap () ; } }\n #[macro_export]\n macro_rules ! wln { ($ dst : expr $ (, $ ($ arg : tt) *) ?) => { { writeln ! ($ dst $ (, $ ($ arg) *) ?) . unwrap () ; # [cfg (debug_assertions)] $ dst . flush () . unwrap () ; } } }\n #[macro_export]\n macro_rules! w_iter {\n ($dst:expr, $fmt:expr, $iter:expr, $delim:expr) => {{\n let mut first = true;\n for elem in $iter {\n if first {\n w!($dst, $fmt, elem);\n first = false;\n } else {\n w!($dst, concat!($delim, $fmt), elem);\n }\n }\n }};\n ($dst:expr, $fmt:expr, $iter:expr) => {\n w_iter!($dst, $fmt, $iter, \" \")\n };\n }\n #[macro_export]\n macro_rules ! w_iter_ln { ($ dst : expr , $ ($ t : tt) *) => { { w_iter ! ($ dst , $ ($ t) *) ; wln ! ($ dst) ; } } }\n #[macro_export]\n macro_rules ! e { ($ ($ t : tt) *) => { # [cfg (debug_assertions)] eprint ! ($ ($ t) *) } }\n #[macro_export]\n macro_rules ! eln { ($ ($ t : tt) *) => { # [cfg (debug_assertions)] eprintln ! ($ ($ t) *) } }\n #[macro_export]\n macro_rules ! __tstr { ($ h : expr $ (, $ t : expr) +) => { concat ! (__tstr ! ($ ($ t) ,+) , \", \" , __tstr ! (@)) } ; ($ h : expr) => { concat ! (__tstr ! () , \" \" , __tstr ! (@)) } ; () => { \"\\x1B[94m[{}:{}]\\x1B[0m\" } ; (@) => { \"\\x1B[1;92m{}\\x1B[0m = {:?}\" } }\n #[macro_export]\n macro_rules ! d { ($ ($ a : expr) ,*) => { eln ! (__tstr ! ($ ($ a) ,*) , file ! () , line ! () , $ (stringify ! ($ a) , $ a) ,*) } ; }\n}\npub mod pio2 {\n use std::{\n io::prelude::*,\n marker::PhantomData,\n mem::{self, MaybeUninit},\n str,\n };\n pub trait Input {\n fn bytes(&mut self) -> &[u8];\n #[inline]\n fn str(&mut self) -> &str {\n str::from_utf8(self.bytes()).unwrap()\n }\n #[inline]\n fn parse(&mut self) -> T\n where\n DefaultParser: Parser,\n {\n self.parse_with(DefaultParser)\n }\n #[inline]\n fn parse_with>(&mut self, mut parser: P) -> T {\n parser.parse(self)\n }\n #[inline]\n fn seq(&mut self, n: usize) -> Seq\n where\n DefaultParser: Parser,\n {\n self.seq_with(n, DefaultParser)\n }\n #[inline]\n fn seq_with>(&mut self, n: usize, parser: P) -> Seq {\n Seq {\n src: self,\n rest: n,\n parser,\n phantom: PhantomData,\n }\n }\n }\n impl Input for &mut I {\n #[inline]\n fn bytes(&mut self) -> &[u8] {\n (**self).bytes()\n }\n }\n pub struct Scanner {\n src: R,\n buf: Vec,\n pos: usize,\n len: usize,\n }\n impl Scanner {\n #[inline]\n pub fn new(src: R) -> Self {\n Self {\n src,\n buf: vec![0; 1 << 16],\n pos: 0,\n len: 0,\n }\n }\n fn read(&mut self) -> usize {\n if self.pos > 0 {\n self.buf.copy_within(self.pos..self.len, 0);\n self.len -= self.pos;\n self.pos = 0;\n } else if self.len >= self.buf.len() {\n self.buf.resize(2 * self.buf.len(), 0);\n }\n let n = self.src.read(&mut self.buf[self.len..]).unwrap();\n self.len += n;\n assert!(self.len <= self.buf.len());\n n\n }\n }\n impl Input for Scanner {\n fn bytes(&mut self) -> &[u8] {\n loop {\n while let Some(d) = unsafe { self.buf.get_unchecked(self.pos..self.len) }\n .iter()\n .position(u8::is_ascii_whitespace)\n {\n let p = self.pos;\n self.pos += d + 1;\n if d > 0 {\n return unsafe { self.buf.get_unchecked(p..p + d) };\n }\n }\n if self.read() == 0 {\n let p = self.pos;\n if p == self.len {\n panic!(\"reached EOF\");\n }\n self.pos = self.len;\n return unsafe { self.buf.get_unchecked(p..self.len) };\n }\n }\n }\n }\n pub struct Seq<'a, I: ?Sized, T, P> {\n src: &'a mut I,\n rest: usize,\n parser: P,\n phantom: PhantomData<*const T>,\n }\n impl<'a, I: Input + ?Sized, T, P: Parser> Iterator for Seq<'a, I, T, P> {\n type Item = T;\n #[inline]\n fn next(&mut self) -> Option {\n if self.rest > 0 {\n self.rest -= 1;\n Some(self.src.parse_with(&mut self.parser))\n } else {\n None\n }\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n (self.rest, Some(self.rest))\n }\n }\n impl<'a, I: Input + ?Sized, T, P: Parser> ExactSizeIterator for Seq<'a, I, T, P> {}\n pub trait Parser {\n fn parse(&mut self, src: &mut I) -> T;\n }\n impl> Parser for &mut P {\n #[inline]\n fn parse(&mut self, src: &mut I) -> T {\n (*self).parse(src)\n }\n }\n #[derive(Clone, Copy, Debug)]\n pub struct DefaultParser;\n macro_rules ! impls { ($ m : ident , $ ($ ty : ty) ,*) => { $ ($ m ! ($ ty) ;) * } ; }\n macro_rules! int {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n let f = |s: &[u8]| s.iter().fold(0, |x, b| 10 * x + (b & 0xf) as $ty);\n let s = src.bytes();\n if let Some((&b'-', t)) = s.split_first() {\n -f(t)\n } else {\n f(s)\n }\n }\n }\n };\n }\n impls!(int, isize, i8, i16, i32, i64, i128);\n macro_rules! uint {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n src.bytes().iter().fold(0, |x, b| 10 * x + (b & 0xf) as $ty)\n }\n }\n };\n }\n impls!(uint, usize, u8, u16, u32, u64, u128);\n macro_rules! from_bytes {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n src.bytes().into()\n }\n }\n };\n }\n impls!(from_bytes, Vec, Box<[u8]>);\n macro_rules! from_str {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n src.str().parse::<$ty>().expect(\"failed to parse\")\n }\n }\n };\n }\n impls!(from_str, String, char, f32, f64);\n macro_rules ! tuple { ($ ($ T : ident) ,+) => { impl <$ ($ T) ,+> Parser < ($ ($ T ,) +) > for DefaultParser where $ (DefaultParser : Parser <$ T >) ,+ { # [inline] fn parse < I : Input + ? Sized > (& mut self , src : & mut I) -> ($ ($ T ,) +) { ($ (< Self as Parser <$ T >>:: parse (self , src) ,) +) } } } ; }\n tuple!(A);\n tuple!(A, B);\n tuple!(A, B, C);\n tuple!(A, B, C, D);\n tuple!(A, B, C, D, E);\n tuple!(A, B, C, D, E, F);\n tuple!(A, B, C, D, E, F, G);\n tuple!(A, B, C, D, E, F, G, H);\n macro_rules ! array { ($ ($ N : literal) *) => { $ (impl < T > Parser < [T ; $ N] > for DefaultParser where DefaultParser : Parser < T > { fn parse < I : Input + ? Sized > (& mut self , src : & mut I) -> [T ; $ N] { unsafe { let mut arr : [MaybeUninit < T >; $ N] = MaybeUninit :: uninit () . assume_init () ; for elem in & mut arr { * elem = MaybeUninit :: new (src . parse ()) ; } mem :: transmute_copy (& arr) } } }) * } }\n array ! (1 2 3 4 5 6 7 8);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "3894db636a552d73b0a76466c067d73f", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0} {"lang": "Rust", "source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn resolve(hy: i64, ay: i64, dy: i64, hm: i64, am: i64, dm: i64) -> bool {\n let ay = std::cmp::max(0, ay - dm);\n let am = std::cmp::max(0, am - dy);\n if ay == 0 {\n return false;\n }\n if am == 0 {\n return true;\n }\n let yt = (hy - 1) / am + 1;\n let mt = (hm - 1) / ay + 1;\n yt > mt\n}\n\nfn solve() {\n let (hy, ay, dy) = parse_line!(i64, i64, i64);\n let (hm, am, dm) = parse_line!(i64, i64, i64);\n let (h, a, d) = parse_line!(i64, i64, i64);\n let mut ans = i64::MAX;\n for aadd in 0..200 {\n for dadd in 0..100 {\n let ay = ay + aadd;\n let dy = dy + dadd;\n let mut l: i64 = -1;\n let mut r: i64 = 10001;\n while r - l > 1 {\n let m = (l + r) / 2;\n let hy = hy + m;\n if resolve(hy, ay, dy, hm, am, dm) {\n r = m;\n }else{\n l = m;\n }\n }\n let cost = aadd * a + dadd * d + r * h;\n ans = std::cmp::min(ans, cost);\n }\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ac98a65baa4af8671d62c716e6d62684", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "Rust", "source_code": "use std::error::Error;\nuse std::io;\nuse std::cmp;\n\nfn main() {\n if let Err(e) = run() {\n println!(\"{}\", e);\n }\n}\n\nfn run() -> Result<(), Box> {\n io::stdin().read_line(&mut String::new())?;\n let mut s = String::new();\n io::stdin().read_line(&mut s)?;\n let mut v = 0;\n let mut max_v = 0;\n for b in s.trim().as_bytes() {\n match *b {\n 65...90 => v += 1,\n 32 => {\n max_v = cmp::max(max_v, v);\n v = 0;\n },\n _ => (),\n }\n }\n println!(\"{}\", cmp::max(max_v, v));\n Ok(())\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "4fcb0b8854695d808bd5cbdc04c23e35", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Rust", "source_code": "//! http://codeforces.com/problemset/problem/837/A\n\n#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(isize);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\npub trait CharExt: Copy {\n fn is_digit(self, radix: u32) -> bool;\n fn to_digit(self, radix: u32) -> Option;\n fn is_alphabetic(self) -> bool;\n fn is_lowercase(self) -> bool;\n fn is_uppercase(self) -> bool;\n fn is_whitespace(self) -> bool;\n fn is_alphanumeric(self) -> bool;\n fn to_lowercase(self) -> Self;\n fn to_uppercase(self) -> Self;\n}\n\nmacro_rules! impl_u8 {\n ($meth:ident($($arg:ident : $ty:ty),*) -> $ret:ty) => {\n fn $meth(self, $($arg : $ty),*) -> $ret {\n let c = self as char;\n c.$meth($($arg),*)\n }\n }\n}\n\nimpl CharExt for u8 {\n impl_u8!(is_digit(radix: u32) -> bool);\n impl_u8!(to_digit(radix: u32) -> Option);\n impl_u8!(is_alphabetic() -> bool);\n impl_u8!(is_lowercase() -> bool);\n impl_u8!(is_uppercase() -> bool);\n impl_u8!(is_whitespace() -> bool);\n impl_u8!(is_alphanumeric() -> bool);\n fn to_lowercase(self) -> Self {\n let c = self as char;\n c.to_lowercase()\n .next()\n .map(|c| c as u8)\n .unwrap_or(self)\n }\n fn to_uppercase(self) -> Self {\n let c = self as char;\n c.to_uppercase()\n .next()\n .map(|c| c as u8)\n .unwrap_or(self)\n }\n}\n\n// -----------------------------------------------------------------------------\n\nfn volume(word: &[u8]) -> u32 {\n word.iter()\n .filter_map(|&c| if c.is_uppercase() { Some(()) } else { None })\n .count()\n as u32\n}\n\nfn main() {\n use std::io::{self, Write, BufWriter};\n let __stdout = io::stdout();\n let mut __out = BufWriter::with_capacity(4096, __stdout.lock());\n\n macro_rules! put {\n ($fmt:expr) => { write!(__out, $fmt).unwrap(); };\n ($fmt:expr, $($arg:expr),+) => { write!(__out, $fmt, $($arg),+).unwrap(); }\n }\n macro_rules! putln {\n () => { writeln!(__out, \"\").unwrap(); };\n ($fmt:expr) => { writeln!(__out, $fmt).unwrap(); };\n ($fmt:expr, $($arg:expr),+) => { writeln!(__out, $fmt, $($arg),+).unwrap(); }\n }\n macro_rules! fflush {\n () => { __out.flush().unwrap(); }\n }\n\n scanln!(_n: u32);\n scanln!(s: Vec);\n let mut max_volume = 0;\n for word in s {\n let vol = volume(word.as_bytes());\n max_volume = std::cmp::max(vol, max_volume);\n }\n putln!(\"{}\", max_volume);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "9219f9984c9ca5c86cc4da214b033278", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::io::prelude::*;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut input).expect(\"fail read!\");\n let words: Vec<&str> = input.split_whitespace().collect();\n let mut n: usize = words[0].trim().parse().unwrap();\n let k: usize = words[1].trim().parse().unwrap();\n\n println!(\"{}\", div(n, k));\n}\n\nfn div(mut n: usize, mut k: usize) -> usize {\n while k > 0 {\n let rem = n % 10;\n if rem < k {\n k = k - rem - 1;\n n = n / 10;\n } else {\n n = n - k;\n k = 0;\n }\n }\n n\n}\n\nmacro_rules! decl_error{\n ($($error:ident)*) => {\n #[derive(Debug)]\n pub enum Error {\n $($error($error),)*\n }\n\n $(\n impl From<$error> for Error {\n fn from(e: $error) -> Self {\n Error::$error(e)\n }\n }\n )*\n\n pub type Result = std::result::Result;\n }\n\n}\n\nmod error {\n use std::io::Error as StdError;\n use std::num::ParseIntError;\n decl_error!(StdError ParseIntError);\n}\n\nuse error::Result;\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "b33996cb5be24b31a2c2b0b769a3faa4", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn subtract(n: u32) -> u32{\n if n % 10 == 0{\n n / 10\n }\n else{\n n - 1\n }\n}\n\nfn main(){\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"Failed to read line\");\n let mut line = line.trim().split(\" \");\n\n let n = line.next().expect(\"Not enough input\")\n .parse::.expect(\"Not an integer\");\n let k = line.next().expect(\"Not enough input\")\n .parse::.expect(\"Not an integer\");\n\n for _i in 0..k{\n let n = subtract(n);\n }\n\n println!(\"{}\", n);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "01afd57b8e2ab71022e8be5310953c32", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n io::stdin().read_line(&mut String::new()).expect(\"\");\n let mut s = String::new();\n io::stdin().read_line(&mut s).expect(\"\");\n let mut ans = String::new();\n let mut cnt = 0;\n for c in s.trim().chars() {\n if c == '0' {\n if cnt > 0 {\n ans += &cnt.to_string();\n cnt = 0;\n }\n ans += \"0\";\n continue;\n }\n cnt += 1;\n }\n if cnt > 0 {\n ans += &cnt.to_string();\n }\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "843c274908aa4e05253fd7c2c97918e9", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::io::Read;\n\n\nstruct Element {\n c: u8,\n count: i32,\n div: i32,\n}\n\n\nimpl Element {\n fn new(c:u8, div: i32) -> Element {\n Element {\n c: c,\n count: 0,\n div: div\n }\n }\n}\nfn main() {\n\n let mut elements = vec![ Element::new(b'n', 2),\n Element::new(b'e', 3),\n Element::new(b'i', 1),\n Element::new(b't', 1),\n ];\n\n let mut buffer: [u8;102] = [0;102];\n\n let count = io::stdin().read(&mut buffer[..]).unwrap();\n \n for c in buffer.iter() {\n if (c == b'n') {\n elements[0].count += 1;\n continue;\n }\n if (c == b'e') {\n elements[1].count += 1;\n continue;\n }\n if (c == b'i') {\n elements[2].count += 1;\n continue;\n }\n if (c == b't') {\n elements[3].count += 1;\n continue;\n }\n }\n\n let mut min = 100;\n\n if elements[0].count < 3 {\n println!(\"0\");\n return;\n }\n\n for m in &elements[..] {\n if m.count < m.div {\n println!(\"0\");\n return;\n }\n let t = m.count / m.div;\n if t < min {\n min = t;\n }\n }\n\n println!(\"{}\", min);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "87c765562f2b6a7575e51dcc265fdd63", "src_uid": "bb433cdb8299afcf46cb2797cbfbf724", "difficulty": null} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n\n let vowels = \"aeiouyAEIOUY\";\n\n for ch in input.trim().chars() {\n if vowels.find(ch) != None {\n continue;\n } else {\n print!(\".{}\", ch.to_lowercase());\n }\n }\n println!();\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "7918c8fc2a1eb9141b8ff1c42ed2d8e6", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\nuse regex::Regex;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n\n println!(\"{}\", Expr::new().calc(&s));\n}\n\nstruct Expr(Vec);\n\nimpl Expr {\n fn new() -> Expr {\n let r1 = Regex::new(r\"(?i)[aeiou]\").unwrap();\n let r2 = Regex::new(r\"(?i)([bcdfghjklmnpqrstvwxyz])\").unwrap();\n Expr(vec![r1, r2])\n }\n\n fn calc(&self, s: &str) -> String {\n self.0[1].replace_all(&*self.0[0].replace_all(s, \"\"), \".$1\").to_lowercase()\n }\n}\n\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test_vowels_removed() {\n assert_eq!(Expr::new().calc(\"aeiou\"), \"\");\n }\n\n #[test]\n fn test_vowels_removed_from_mix() {\n assert_eq!(Expr::new().calc(\"abcdefg\"), \".b.c.d.f.g\");\n }\n\n #[test]\n fn test_dot_only_consonants() {\n assert_eq!(Expr::new().calc(\"zxy\"), \".z.x.y\");\n }\n\n #[test]\n fn test_upper_consonants() {\n assert_eq!(Expr::new().calc(\"RZW\"), \".r.z.w\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "0693e90a30867f60c0affdd5f53c0b82", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Rust", "source_code": "fn readln() -> String {\n let stdin = std::io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).unwrap();\n String::from(line.trim())\n}\n\nfn main() {\n let s = readln().to_lowercase();\n for c in s.chars() {\n let is_vowel =\n c == 'a' ||\n c == 'e' ||\n c == 'i' ||\n c == 'o' ||\n c == 'u' ||\n c == 'y';\n if !is_vowel {\n print!(\".{}\", c);\n }\n }\n println!();\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "4f144989a3b6b15fadb46087eedd4cf7", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Rust", "source_code": "fn main() {\n let mut arr = [[i32::default();5];5];\n\n let mut input = String::new();\n\n for i in 0..5 {\n\n std::io::stdin().read_line(&mut input).expect(\"INPUT::Read line failed\");\n\n let mut init_input = input.trim().split(' ');\n\n for j in 0..5 {\n\n arr[i as usize][j as usize] = init_input.next().unwrap().parse::()\n .expect(\"ARR::I::J::Parse to i32 failed\");\n\n }\n drop(init_input);\n input.clear();\n }\n\n let mut row = i32::default();\n let mut column = i32::default();\n\n for i in 0..5 {\n for j in 0..5 {\n if arr[i as usize][j as usize] == 1 {\n row = i;\n column = j;\n }\n }\n }\n\n println!(\"{}\", (row - 2).abs() + (column - 2).abs());\n\n\n\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "869f2281c4c1fb782572f4e2eddcc44c", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn readln() -> Vec {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n line.split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect()\n}\n\nfn main() {\n for i in 0..5 {\n let line = readln();\n for j in 0..5 {\n if line[j] == 1 {\n println!(\"{}\", (2 - i).abs() + (2 - j).abs());\n }\n }\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "5d868b17a8e92f26ff91a55216730efe", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n let mut arr = [[i32::default();5];5];\n\n let mut input = String::new();\n\n for i in 0..5 {\n\n std::io::stdin().read_line(&mut input).expect(\"INPUT::Read line failed\");\n\n let mut init_input = input.trim().split(' ');\n\n for j in 0..5 {\n arr[i as usize][j as usize] = init_input.next().unwrap().parse::()\n .expect(\"ARR::I::J::Parse to i32 failed\");\n\n }\n input.clear();\n }\n\n let mut row = i32::default();\n let mut column = i32::default();\n\n for i in 0..5 {\n for j in 0..5 {\n if arr[i as usize][j as usize] == 1 {\n row = i;\n column = j;\n }\n }\n }\n\n println!(\"{}\", (row - 2).abs() + (column - 2).abs());\n\n\n\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "572914805cc7b589eb19cca6ec40ecfa", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n\n let mut ret = String::new();\n for i in 0..buf.len() {\n if ret.ends_with(\"WUB\") {\n let len = ret.len();\n ret.replace_range((len - 3)..len, \"\");\n if ret.ends_with(\" \") == false {\n if ret.len() > 0 {\n ret.push(' ');\n }\n }\n }\n ret.push_str(&buf[i..i + 1]);\n }\n println!(\"{}\", ret.trim());\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "52a483f1646c5c047a52095f8badcc90", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn main() {\n let mut word = String::new();\n std::io::stdin().read_line(&mut word).unwrap();\n\n let word = word.trim();\n let len = word.len();\n let mut i: usize = 0;\n\n while i < len {\n if i <= len - 3 {\n if word.as_bytes()[i] == b'W' &&\n word.as_bytes()[i + 1] == b'U' &&\n word.as_bytes()[i + 2] == b'B' {\n println!(\" \");\n i += 3;\n }\n }\n else {\n print!(\"{}\", word.as_bytes()[i] as char);\n i += 1;\n }\n }\n\n println!();\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "a01d7602a3daaaac8256876c9ad10c65", "src_uid": "edede580da1395fe459a480f6a0a548d", "difficulty": 900.0} {"lang": "Rust", "source_code": "extern crate requests;\n\nuse requests::ToJson;\nuse std::process::Command;\n\nconst SERVER: &str = \"http://localhost:8000\";\n\nfn register() -> String {\n requests::get(format!(\"{}/api/register\", SERVER)).unwrap().text().unwrap().to_string()\n}\n\nfn next(slave_id: &str) {\n let response = requests::get(format!(\"{}/api/{}/next\", SERVER, slave_id));\n let next = response.unwrap().json().unwrap();\n match next[\"type\"].unwrap() {\n \"EXEC\" => {\n\n }\n s => println!(\"Please implement {}\", s)\n }\n}\n\nfn main() {\n let mut slave_id = register();\n println!(\"{}\", slave_id);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "22ec2b7c28111655c7b1763be13d54cf", "src_uid": "883f67177474d23d7a320d9dbfa70dd3", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut black = 0;\n let mut white = 0;\n let mut x = 0;\n let mut weights: [i32; 2];\n while x < 8 {\n let line = String::new();\n io::stdin().read_line(&line).expect(\"error: unable to read user input\");\n weights = weight(&line);\n black += weights[0];\n white += weights[1];\n x += 1;\n }\n if black > white {\n println!(\"Black\");\n } else if black < white {\n println!(\"White\");\n } else {\n println!(\"Draw\");\n }\n}\n\nfn weight(x: &str) -> [i32; 2] {\n let mut b = 0;\n let mut w = 0;\n for i in x.chars() {\n match i {\n 'q' => b += 9,\n 'r' => b += 5,\n 'b' => b += 3,\n 'n' => b += 3,\n 'p' => b += 1,\n 'Q' => w += 9,\n 'R' => w += 5,\n 'B' => w += 3,\n 'N' => w += 3,\n 'P' => w += 1,\n _ => (),\n };\n }\n let arr: [i32; 2] = [b, w];\n return arr;\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "6050fe9d92e752a3b015709838594306", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": " \n \nfn calcular_white(c:char) -> i32{\n match c{ 'Q'=> 9,\n 'R'=> 5, \n 'B'=> 3,\n 'N'=> 3,\n 'P'=> 1,\n _ => 0,\n }\n \n}\nfn calcular_black(c:char) -> i32{\n match c{ 'q'=> 9,\n 'r'=> 5,\n 'b'=> 3,\n 'n'=> 3,\n 'p'=> 1, \n _ => 0, \n }\n \n \n}\n \n \n \n \nfn main(){\n let mut input = 1; let mut whiteCount = 0; let mut blackCount = 0; \n while i <= 8{\n let mut input1 = String::new();\n let b1 = std::io::stdin().read_line(&mut input1).unwrap();\n \n for contC in input1.chars(){ \n blackCount += calcular_black(contC); whiteCount += calcular_white(contC);\n \n }\n i =i+ 1; \n }\n \n if whiteCount < blackCount\n println!(\"Black\");\n }\n else if whiteCount > blackCount{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "612ac45c61605c3caeb59a6f1eeb05da", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn valores (i:char) -> i32 {\n match i {\n 'q' | 'Q' => 9,\n 'r' | 'R' => 5,\n 'b' | 'n' | 'B' | 'N' => 3,\n 'p' | 'P' => 1,\n _ => 0,\n }\n}\n\nfn main(){\n let mut contador_blanco=0;\n let mut contador_negro=0;\n for i in range(8){\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n for j in input.chars(){\n contador_negro+=valores(j);\n contador_blanco+=valores(j);\n }\n }\n let mut puntaje=contador_blanco-contador_negro;\n if puntaje<0{\n println!(\"Black\");\n }\n else if puntaje>0{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8fbbe9de16cd9f797444f2a15b236f7a", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "\n\nfn calcular_white(c:char) -> i32{\n match c{ 'Q'=> 9,\n 'R'=> 5, \n 'B'=> 3,\n 'N'=> 3,\n 'P'=> 1,\n _ => 0,\n }\n \n}\nfn calcular_black(c:char) -> i32{\n match c{ 'q'=> 9,\n 'r'=> 5,\n 'b'=> 3,\n 'n'=> 3,\n 'p'=> 1, \n _ => 0, \n }\n \n\n}\n\n\n\n\nfn main(){\n let mut input = 1; let mut whiteCount = 0; let mut blackCount = 0; \n while i <= 8{\n let mut input1 = String::new();\n let b1 = std::io::stdin().read_line(&mut input1).unwrap();\n \n for contC in input1.chars(){ \n blackCount += calcular_black(contC); whiteCount += calcular_white(contC);\n \n }\n i =i+ 1; \n }\n \n if whiteCount < blackCount\n println!(\"Black\");\n }\n else if whiteCount > blackCount{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n }\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "1be4fb7d8e87d87e69315db964afc4ac", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut black = 0;\n let mut white = 0;\n let mut x = 0;\n let mut weights: [i32; 2];\n let mut line = String::new();\n while x < 8 {\n io::stdin().read_line(&mut line).expect(\"error: unable to read user input\");\n weights = weight(&line);\n black += weights[0];\n white += weights[1];\n x += 1;\n }\n if black > white {\n println!(\"Black\");\n } else if black < white {\n println!(\"White\");\n } else {\n println!(\"Draw\");\n }\n}\n\nfn weight(x: &str) -> [i32; 2] {\n let mut b = 0;\n let mut w = 0;\n for i in x.chars() {\n println!(i);\n match i {\n 'q' => b += 9,\n 'r' => b += 5,\n 'b' => b += 3,\n 'n' => b += 3,\n 'p' => b += 1,\n 'Q' => w += 9,\n 'R' => w += 5,\n 'B' => w += 3,\n 'N' => w += 3,\n 'P' => w += 1,\n _ => (),\n };\n }\n let arr: [i32; 2] = [b, w];\n return arr;\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "dbf872017ebee41d8744850025006d29", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn valores (mut ptj: i32,i:char) -> i32 {\n match i {\n 'q' => ptj+=9,\n 'r' => ptj+=5,\n 'b' | 'n' => ptj+=3,\n 'p' => ptj+=1,\n 'Q' => ptj-=9,\n 'R' => ptj-=5,\n 'B' | 'N' => ptj-=3,\n 'P' => ptj-=1,\n _ => 0,\n };\n ptj\n}\n\nfn main(){\n let mut puntaje=0;\n for i in 0..8{\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n for j in input.chars(){\n puntaje=valores(puntaje,j);\n }\n } \n if puntaje<0{\n println!(\"Black\");\n }\n else if puntaje>0{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "0ced452ae525c37c1a30197439b20b51", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn calcular_white(c:char) -> i32{\n match c{ 'Q'=> 9, 'R'=> 5, 'B'=> 3,'N'=> 3,'P'=> 1, _ => 0,}\n \n}\nfn calcular_black(c:char) -> i32{\n match c{ 'q'=> 9, 'r'=> 5,'b'=> 3,'n'=> 3,'p'=> 1, _ => 0, }\n \n}\n\n\n\nfn main(){\n let mut input = 1; let mut whiteCount = 0; let mut blackCount = 0; \n while i <= 8{\n let mut input1 = String::new();\n let b1 = std::io::stdin().read_line(&mut input1).unwrap();\n \n for contC in input.chars(){ \n blackCount += calcular_black(contC); whiteCount += calcular_white(contC);\n \n }\n i += 1; \n }\n \n if whiteCount < blackCount\n println!(\"Black\");\n }\n else if whiteCount > blackCount{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n }\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "57aec737f4e1acc56a8498f3b4bb9941", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn main(){\n let mut input = 1; let mut whiteCount = 0; let mut blackCount = 0; \n while i <= 8{\n let mut input1 = String::new();\n let b1 = std::io::stdin().read_line(&mut input1).unwrap();\n \n for contC in input.chars(){ \n blackCount += calcular_black(contC); whiteCount += calcular_white(contC);\n \n }\n i += 1; \n }\n \n if whiteCount < blackCount\n println!(\"Black\");\n }\n else if whiteCount > blackCount{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n }\n\n\n\nfn calcular_white(c:char) -> i32{\n match c{ 'Q'=> 9, 'R'=> 5, 'B'=> 3,'N'=> 3,'P'=> 1, _ => 0,}\n \n}\nfn calcular_black(c:char) -> i32{\n match c{ 'q'=> 9, 'r'=> 5,'b'=> 3,'n'=> 3,'p'=> 1, _ => 0, }\n \n}\n\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "35f64d763262ae608cdf2f3e24e41653", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "fn calcular_white(c:char) -> i32{\n match c{ \n 'Q'=> 9,\n 'R'=> 5, \n 'B'=> 3,\n 'N'=> 3,\n 'P'=> 1,\n _ => 0,\n }\n \n}\nfn calcular_black(c:char) -> i32{\n match c{ \n 'q'=> 9,\n 'r'=> 5,\n 'b'=> 3,\n 'n'=> 3,\n 'p'=> 1, \n _ => 0, \n }\n \n\n}\n\n\n\n\nfn main(){\n let mut i = 1; \n let mut whiteCount = 0; \n let mut blackCount = 0; \n while i <= 8{\n let mut input1 = String::new();\n let a = std::io::stdin().read_line(&mut input1).unwrap();\n \n for contC in input1.chars(){ \n blackCount += calcular_black(contC); \n whiteCount += calcular_white(contC);\n \n }\n i =i+ 1; \n }\n \n if whiteCount < blackCount\n println!(\"Black\");\n }\n else if whiteCount > blackCount{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n }\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "65a168ca816c7da8f1227aa85bcffe93", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut black = 0;\n let mut white = 0;\n let mut x = 0;\n let mut weights: [i32; 2];\n let mut line = String::new();\n while x < 8 {\n io::stdin().read_line(&mut line).expect(\"error: unable to read user input\");\n weights = weight(&line);\n black += weights[0];\n white += weights[1];\n x += 1;\n }\n if black > white {\n println!(\"Black\");\n } else if black < white {\n println!(\"White\");\n } else {\n println!(\"Draw\");\n}\n\nfn weight(x: &str) -> [i32; 2] {\n let mut b = 0;\n let mut w = 0;\n for i in x.chars() {\n match i {\n 'q' => b += 9,\n 'r' => b += 5,\n 'b' => b += 3,\n 'n' => b += 3,\n 'p' => b += 1,\n 'Q' => w += 9,\n 'R' => w += 5,\n 'B' => w += 3,\n 'N' => w += 3,\n 'P' => w += 1,\n _ => (),\n };\n }\n let arr: [i32; 2] = [b, w];\n return arr;\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "cd542e24a3c70eb5e60b07fcf94905d4", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead};\n\nfn main() {\n let mut c = [0; 4];\n let mut count = 0;\n for line in io::stdin().lock().lines() {\n c[count] = line.unwrap().parse().unwrap();\n count += 1;\n }\n if c[0] != c[3] {\n println!(\"0\");\n } else if c[2] > 0 && c[0] == 0 {\n println!(\"0\");\n } else {\n println!(\"1\");\n }\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8138c493fcbb90b4f55336491dcd879f", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead};\n\nfn main() {\n let mut c = [0; 4];\n let mut count = 0;\n let input = io::stdin().lock().lines();\n for line in input {\n c[count] = line.unwrap().parse().unwrap();\n count += 1;\n }\n if c[0] != c[3] {\n println!(\"0\");\n } else if c[2] > 0 && c[0] == 0 {\n println!(\"0\");\n } else {\n println!(\"1\");\n }\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "477ba216f525ed8e6fd5a330455d1d1e", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "Rust", "source_code": "fn main() {\n let s = std::io::stdin();\n let mut sc = Scanner { stdin: s.lock() };\n let x: usize = sc.read();\n let mut hh: usize = sc.read();\n let mut mm: usize = sc.read();\n let mut result = 24 * 60;\n for h in 0..24 {\n for m in 0..60 {\n if h == 7 || h == 17 || m == 7 || m == 17 || m == 27 || m == 37 || m == 47 || m == 57 {\n let mut cnt = 0;\n let mut tmp_h = h;\n let mut tmp_m = m;\n while tmp_h != hh || tmp_m != mm {\n tmp_m += x;\n if tmp_m >= 60 {\n tmp_h += 1;\n tmp_m %= 60;\n }\n if tmp_h >= 24 {\n tmp_h = 0;\n }\n cnt += 1;\n if cnt > 24 * 60 {\n break;\n }\n }\n result = std::cmp::min(result, cnt);\n }\n }\n }\n println!(\"{}\", result);\n}\n\n//snippet from kenkoooo\npub struct Scanner {\n stdin: R,\n}\n\nimpl Scanner {\n pub fn read(&mut self) -> T {\n use std::io::Read;\n let buf = self\n .stdin\n .by_ref()\n .bytes()\n .map(|b| b.unwrap())\n .skip_while(|&b| b == b' ' || b == b'\\n' || b == b'\\r')\n .take_while(|&b| b != b' ' && b != b'\\n' && b != b'\\r')\n .collect::>();\n unsafe { std::str::from_utf8_unchecked(&buf) }\n .parse()\n .ok()\n .expect(\"Parse error.\")\n }\n pub fn vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read()).collect()\n }\n pub fn chars(&mut self) -> Vec {\n self.read::().chars().collect()\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "5567e015ea7e8b02b57fd56f52da4040", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std:io;\r\n\r\npub fn potion() {\r\n let mut tests = String::new();\r\n io::stdin().read_line(&mut tests).expect(\"string\");\r\n let t: usize = tests.trim().parse::().expect(\"int\");\r\n\r\n for _ in 0..t {\r\n let mut holder = String::new();\r\n io::stdin().read_line(&mut holder).expect(\"string\");\r\n let k: usize = holder.trim().parse::().expect(\"int\");\r\n\r\n let ggcd = gcd(k, 100-k);\r\n\r\n println!(\"{}\", k/ggcd + (100-k)/ggcd)\r\n\r\n }\r\n\r\n}\r\n\r\nfn main() {\r\n\r\n potion();\r\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "6017cfd743a8a5eca66eec31c35c86f4", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n\n io::stdin().read_line(&mut s).unwrap();\n\n let mut uppercases = 0;\n\n for ch in s.chars() {\n if ch.is_uppercase() {\n uppercases += 1;\n }\n }\n\n let mut first = 1;\n\n if uppercases > 1 {\n for ch in s.chars() {\n if first == 1 {\n print!(\"{}\", ch.to_uppercase());\n first = 0;\n } else {\n print!(\"{}\", ch.to_lowercase());\n }\n }\n } else {\n println!(\"{}\", s);\n }\n}\n1", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "772a40617c9c8bf14212286842d8cc3a", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#[macro_use]\nextern crate text_io;\n\nuse std::collections::BTreeSet;\n\nfn main() {\n let n: usize;\n scan!(\"{}\\n\", n);\n let mut a: Vec = vec![0; n];\n let mut b: Vec = vec![0; n];\n let mut s: BTreeSet = BTreeSet::new();\n let mut ans = 0;\n for i in 0..n {\n scan!(\"{}\", a[i]);\n s.insert(a[i]);\n }\n for i in 0..n {\n scan!(\"{}\", b[i]);\n s.insert(b[i]);\n }\n for i in 0..n {\n for j in 0..n {\n if s.contains(&(a[i] ^ b[j])) {\n ans += 1;\n }\n }\n }\n println!(\"{}\", if ans % 2 == 0 { \"Karen\" } else { \"Koyomi\" });\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "6167ea85315cb022d704d694881cb641", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io::stdin;\nuse std::collections::HashSet;\n\nmacro_rules! readln {\n () => {{ let mut line = String::new(); stdin().read_line(&mut line).unwrap(); line }};\n ($type:ty) => {{ readln!().split_whitespace().next().unwrap().parse::<$type>().unwrap() }};\n (|$type_vec:ty|) => {{ readln!().split_whitespace().map(|it| it.parse().unwrap()).collect::>() }};\n ($($type:ty),*) => {{ let line = readln!(); let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};\n ($($type:ty),*, |$type_vec:ty|) => {{ let line = readln!(); let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse().unwrap()).collect::>(),)}};\n}\n\nfn division(mut n: u64) -> HashSet {\n let mut res = HashSet::new();\n\n if n % 2 == 0 {\n res.insert(2);\n res.insert(n / 2);\n }\n let mut i = 3;\n while i * i <= n {\n if n % i == 0 {\n res.push(i);\n }\n i += 2;\n }\n res\n}\n\nfn main() {\n let n = readln!(u64);\n let divisions = division(n);\n\n if divisions.is_empty() {\n println!(\"{}\", n);\n } else if divisions.len() == 1 {\n println!(\"{}\", divisions[0])\n } else {\n println!(\"1\")\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "e57c6a77048ef48ad576170a7f58b8e0", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n\n let mut t = String::new();\n io::stdin()\n .read_line(&mut t)\n .unwrap()\n .graphemes(true)\n .rev()\n .collect();\n\n if assert_eq!(s, t) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "07d9c0eb86eb3ce807e717c5f3662dec", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::io::prelude::*;\nuse std::cmp;\nmacro_rules! scan {\n ( $( $x:ty ),+ ) => {{\n let mut s =String::new();\n io::stdin().read_line(& mut s);\n\n let mut iter = s.split_whitespace();\n ($(iter.next().and_then(|word| word.parse::<$x>().ok()).unwrap(),)*)\n }}\n}\n\n\n\nfn main(){\n\n\n\n let (k,n,w)= scan!(i64,i64,i64,i64);\n\n\n let r =cmp::max(0i64, (w*(w+1))/2 *k -n);\n print!(\"{}\",r);\n\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "a1f03940f7203cc1bea454b646a791f2", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn count_ways(n: usize) -> usize {\n let mut dynamic = vec![vec![0; 4]; n + 1];\n dynamic[1] = vec![1usize; 4];\n *dynamic[1].last_mut().unwrap() = 0;\n \n for step_count in 2..=n {\n for vertex_id in 0..=3 {\n for neighbor_id in (0..=3).filter(|&x| x != vertex_id) {\n dynamic[step_count][vertex_id] += dynamic[step_count - 1][neighbor_id];\n }\n dynamic[step_count] %= 1000000007;\n }\n }\n *dynamic.last().unwrap().last().unwrap()\n}\n\n\nfn main() {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let n = buf.trim().parse::().unwrap();\n println!(\"{}\", count_ways(n));\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "08db933dfb975aa364de1105d9df82a1", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "Rust", "source_code": "//https://github.com/manta1130/competitive-template-rs\n\nuse input::*;\n\npub mod input {\n use std::cell::RefCell;\n use std::io;\n pub const SPLIT_DELIMITER: char = ' ';\n pub use std::io::prelude::*;\n\n #[macro_export]\n thread_local! {\n pub static INPUT_BUFFER:RefCell>=RefCell::new(std::collections::VecDeque::new());\n }\n\n #[macro_export]\n macro_rules! input_internal {\n ($x:ident : $t:ty) => {\n INPUT_BUFFER.with(|p| {\n if p.borrow().len() == 0 {\n let temp_str = input_line_str();\n let mut split_result_iter = temp_str\n .split(SPLIT_DELIMITER)\n .map(|q| q.to_string())\n .collect::>();\n p.borrow_mut().append(&mut split_result_iter)\n }\n });\n let mut buf_split_result = String::new();\n INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());\n let $x: $t = buf_split_result.parse().unwrap();\n };\n (mut $x:ident : $t:ty) => {\n INPUT_BUFFER.with(|p| {\n if p.borrow().len() == 0 {\n let temp_str = input_line_str();\n let mut split_result_iter = temp_str\n .split(SPLIT_DELIMITER)\n .map(|q| q.to_string())\n .collect::>();\n p.borrow_mut().append(&mut split_result_iter)\n }\n });\n let mut buf_split_result = String::new();\n INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());\n let mut $x: $t = buf_split_result.parse().unwrap();\n };\n }\n\n #[macro_export]\n macro_rules! inputv {\n ($i:ident : $t:ty) => {\n input_internal!{$i : $t}\n };\n (mut $i:ident : $t:ty) => {\n input_internal!{mut $i : $t}\n };\n ($i:ident : $t:ty $(,)*) => {\n input_internal!{$i : $t}\n };\n (mut $i:ident : $t:ty $(,)*) => {\n input_internal!{mut $i : $t}\n };\n (mut $i:ident : $t:ty,$($q:tt)*) => {\n input_internal!{mut $i : $t}\n inputv!{$($q)*}\n };\n ($i:ident : $t:ty,$($q:tt)*) => {\n input_internal!{$i : $t}\n inputv!{$($q)*}\n };\n}\n\n pub fn input_all() {\n INPUT_BUFFER.with(|p| {\n if p.borrow().len() == 0 {\n let mut temp_str = String::new();\n std::io::stdin().read_to_string(&mut temp_str).unwrap();\n let mut split_result_iter = temp_str\n .split_whitespace()\n .map(|q| q.to_string())\n .collect::>();\n p.borrow_mut().append(&mut split_result_iter)\n }\n });\n }\n\n pub fn input_line_str() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n }\n\n #[allow(clippy::match_wild_err_arm)]\n pub fn input_vector() -> Vec\n where\n T: std::str::FromStr,\n {\n let mut v: Vec = Vec::new();\n\n let s = input_line_str();\n let split_result = s.split(SPLIT_DELIMITER);\n for z in split_result {\n let buf = match z.parse() {\n Ok(r) => r,\n Err(_) => panic!(\"Parse Error\",),\n };\n v.push(buf);\n }\n v\n }\n\n #[allow(clippy::match_wild_err_arm)]\n pub fn input_vector_row(n: usize) -> Vec\n where\n T: std::str::FromStr,\n {\n let mut v = Vec::with_capacity(n);\n for _ in 0..n {\n let buf = match input_line_str().parse() {\n Ok(r) => r,\n Err(_) => panic!(\"Parse Error\",),\n };\n v.push(buf);\n }\n v\n }\n\n pub trait ToCharVec {\n fn to_charvec(&self) -> Vec;\n }\n\n impl ToCharVec for String {\n fn to_charvec(&self) -> Vec {\n self.to_string().chars().collect::>()\n }\n }\n}\n\n//https://github.com/rust-lang-ja/ac-library-rs\n//https://github.com/manta1130/competitive-template-rs\n\nuse input::*;\nuse modint::*;\n\npub mod input {\n use std::cell::RefCell;\n use std::io;\n pub const SPLIT_DELIMITER: char = ' ';\n pub use std::io::prelude::*;\n\n #[macro_export]\n thread_local! {\n pub static INPUT_BUFFER:RefCell>=RefCell::new(std::collections::VecDeque::new());\n }\n\n #[macro_export]\n macro_rules! input_internal {\n ($x:ident : $t:ty) => {\n INPUT_BUFFER.with(|p| {\n if p.borrow().len() == 0 {\n let temp_str = input_line_str();\n let mut split_result_iter = temp_str\n .split(SPLIT_DELIMITER)\n .map(|q| q.to_string())\n .collect::>();\n p.borrow_mut().append(&mut split_result_iter)\n }\n });\n let mut buf_split_result = String::new();\n INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());\n let $x: $t = buf_split_result.parse().unwrap();\n };\n (mut $x:ident : $t:ty) => {\n INPUT_BUFFER.with(|p| {\n if p.borrow().len() == 0 {\n let temp_str = input_line_str();\n let mut split_result_iter = temp_str\n .split(SPLIT_DELIMITER)\n .map(|q| q.to_string())\n .collect::>();\n p.borrow_mut().append(&mut split_result_iter)\n }\n });\n let mut buf_split_result = String::new();\n INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap());\n let mut $x: $t = buf_split_result.parse().unwrap();\n };\n }\n\n #[macro_export]\n macro_rules! inputv {\n ($i:ident : $t:ty) => {\n input_internal!{$i : $t}\n };\n (mut $i:ident : $t:ty) => {\n input_internal!{mut $i : $t}\n };\n ($i:ident : $t:ty $(,)*) => {\n input_internal!{$i : $t}\n };\n (mut $i:ident : $t:ty $(,)*) => {\n input_internal!{mut $i : $t}\n };\n (mut $i:ident : $t:ty,$($q:tt)*) => {\n input_internal!{mut $i : $t}\n inputv!{$($q)*}\n };\n ($i:ident : $t:ty,$($q:tt)*) => {\n input_internal!{$i : $t}\n inputv!{$($q)*}\n };\n}\n\n pub fn input_all() {\n INPUT_BUFFER.with(|p| {\n if p.borrow().len() == 0 {\n let mut temp_str = String::new();\n std::io::stdin().read_to_string(&mut temp_str).unwrap();\n let mut split_result_iter = temp_str\n .split_whitespace()\n .map(|q| q.to_string())\n .collect::>();\n p.borrow_mut().append(&mut split_result_iter)\n }\n });\n }\n\n pub fn input_line_str() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n }\n\n #[allow(clippy::match_wild_err_arm)]\n pub fn input_vector() -> Vec\n where\n T: std::str::FromStr,\n {\n let mut v: Vec = Vec::new();\n\n let s = input_line_str();\n let split_result = s.split(SPLIT_DELIMITER);\n for z in split_result {\n let buf = match z.parse() {\n Ok(r) => r,\n Err(_) => panic!(\"Parse Error\",),\n };\n v.push(buf);\n }\n v\n }\n\n #[allow(clippy::match_wild_err_arm)]\n pub fn input_vector_row(n: usize) -> Vec\n where\n T: std::str::FromStr,\n {\n let mut v = Vec::with_capacity(n);\n for _ in 0..n {\n let buf = match input_line_str().parse() {\n Ok(r) => r,\n Err(_) => panic!(\"Parse Error\",),\n };\n v.push(buf);\n }\n v\n }\n\n pub trait ToCharVec {\n fn to_charvec(&self) -> Vec;\n }\n\n impl ToCharVec for String {\n fn to_charvec(&self) -> Vec {\n self.to_string().chars().collect::>()\n }\n }\n}\npub mod internal_math {\n #![allow(dead_code)]\n use std::mem::swap;\n\n /* const */\n pub(crate) fn safe_mod(mut x: i64, m: i64) -> i64 {\n x %= m;\n if x < 0 {\n x += m;\n }\n x\n }\n\n pub(crate) struct Barrett {\n pub(crate) _m: u32,\n pub(crate) im: u64,\n }\n\n impl Barrett {\n pub(crate) fn new(m: u32) -> Barrett {\n Barrett {\n _m: m,\n im: (-1i64 as u64 / m as u64).wrapping_add(1),\n }\n }\n\n pub(crate) fn umod(&self) -> u32 {\n self._m\n }\n\n #[allow(clippy::many_single_char_names)]\n pub(crate) fn mul(&self, a: u32, b: u32) -> u32 {\n mul_mod(a, b, self._m, self.im)\n }\n }\n\n #[allow(clippy::many_single_char_names)]\n pub(crate) fn mul_mod(a: u32, b: u32, m: u32, im: u64) -> u32 {\n let mut z = a as u64;\n z *= b as u64;\n let x = (((z as u128) * (im as u128)) >> 64) as u64;\n let mut v = z.wrapping_sub(x.wrapping_mul(m as u64)) as u32;\n if m <= v {\n v = v.wrapping_add(m);\n }\n v\n }\n\n /* const */\n #[allow(clippy::many_single_char_names)]\n pub(crate) fn pow_mod(x: i64, mut n: i64, m: i32) -> i64 {\n if m == 1 {\n return 0;\n }\n let _m = m as u32;\n let mut r: u64 = 1;\n let mut y: u64 = safe_mod(x, m as i64) as u64;\n while n != 0 {\n if (n & 1) > 0 {\n r = (r * y) % (_m as u64);\n }\n y = (y * y) % (_m as u64);\n n >>= 1;\n }\n r as i64\n }\n\n /* const */\n pub(crate) fn is_prime(n: i32) -> bool {\n let n = n as i64;\n match n {\n _ if n <= 1 => return false,\n 2 | 7 | 61 => return true,\n _ if n % 2 == 0 => return false,\n _ => {}\n }\n let mut d = n - 1;\n while d % 2 == 0 {\n d /= 2;\n }\n for &a in &[2, 7, 61] {\n let mut t = d;\n let mut y = pow_mod(a, t, n as i32);\n while t != n - 1 && y != 1 && y != n - 1 {\n y = y * y % n;\n t <<= 1;\n }\n if y != n - 1 && t % 2 == 0 {\n return false;\n }\n }\n true\n }\n\n /* const */\n #[allow(clippy::many_single_char_names)]\n pub(crate) fn inv_gcd(a: i64, b: i64) -> (i64, i64) {\n let a = safe_mod(a, b);\n if a == 0 {\n return (b, 0);\n }\n\n let mut s = b;\n let mut t = a;\n let mut m0 = 0;\n let mut m1 = 1;\n\n while t != 0 {\n let u = s / t;\n s -= t * u;\n m0 -= m1 * u; // |m1 * u| <= |m1| * s <= b\n\n swap(&mut s, &mut t);\n swap(&mut m0, &mut m1);\n }\n if m0 < 0 {\n m0 += b / s;\n }\n (s, m0)\n }\n\n /* const */\n pub(crate) fn primitive_root(m: i32) -> i32 {\n match m {\n 2 => return 1,\n 167_772_161 => return 3,\n 469_762_049 => return 3,\n 754_974_721 => return 11,\n 998_244_353 => return 3,\n _ => {}\n }\n\n let mut divs = [0; 20];\n divs[0] = 2;\n let mut cnt = 1;\n let mut x = (m - 1) / 2;\n while x % 2 == 0 {\n x /= 2;\n }\n for i in (3..std::i32::MAX).step_by(2) {\n if i as i64 * i as i64 > x as i64 {\n break;\n }\n if x % i == 0 {\n divs[cnt] = i;\n cnt += 1;\n while x % i == 0 {\n x /= i;\n }\n }\n }\n if x > 1 {\n divs[cnt] = x;\n cnt += 1;\n }\n let mut g = 2;\n loop {\n if (0..cnt).all(|i| pow_mod(g, ((m - 1) / divs[i]) as i64, m) != 1) {\n break g as i32;\n }\n g += 1;\n }\n }\n}\npub mod modint {\n\n use crate::internal_math;\n use std::{\n cell::RefCell,\n convert::{Infallible, TryInto as _},\n fmt,\n hash::{Hash, Hasher},\n iter::{Product, Sum},\n marker::PhantomData,\n ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign},\n str::FromStr,\n sync::atomic::{self, AtomicU32, AtomicU64},\n thread::LocalKey,\n };\n\n pub type ModInt1000000007 = StaticModInt;\n pub type ModInt998244353 = StaticModInt;\n pub type ModInt = DynamicModInt;\n\n #[derive(Copy, Clone, Eq, PartialEq)]\n #[repr(transparent)]\n pub struct StaticModInt {\n val: u32,\n phantom: PhantomData M>,\n }\n\n impl StaticModInt {\n #[inline(always)]\n pub fn modulus() -> u32 {\n M::VALUE\n }\n\n #[inline]\n pub fn new(val: T) -> Self {\n Self::raw(val.rem_euclid_u32(M::VALUE))\n }\n\n #[inline]\n pub fn raw(val: u32) -> Self {\n Self {\n val,\n phantom: PhantomData,\n }\n }\n\n #[inline]\n pub fn val(self) -> u32 {\n self.val\n }\n\n #[inline]\n pub fn pow(self, n: u64) -> Self {\n ::pow(self, n)\n }\n\n #[inline]\n pub fn inv(self) -> Self {\n if M::HINT_VALUE_IS_PRIME {\n if self.val() == 0 {\n panic!(\"attempt to divide by zero\");\n }\n debug_assert!(\n internal_math::is_prime(M::VALUE.try_into().unwrap()),\n \"{} is not a prime number\",\n M::VALUE,\n );\n self.pow((M::VALUE - 2).into())\n } else {\n Self::inv_for_non_prime_modulus(self)\n }\n }\n }\n\n impl ModIntBase for StaticModInt {\n #[inline(always)]\n fn modulus() -> u32 {\n Self::modulus()\n }\n\n #[inline]\n fn raw(val: u32) -> Self {\n Self::raw(val)\n }\n\n #[inline]\n fn val(self) -> u32 {\n self.val()\n }\n\n #[inline]\n fn inv(self) -> Self {\n self.inv()\n }\n }\n\n pub trait Modulus: 'static + Copy + Eq {\n const VALUE: u32;\n const HINT_VALUE_IS_PRIME: bool;\n\n fn butterfly_cache() -> &'static LocalKey>>>;\n }\n\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\n pub enum Mod1000000007 {}\n\n impl Modulus for Mod1000000007 {\n const VALUE: u32 = 1_000_000_007;\n const HINT_VALUE_IS_PRIME: bool = true;\n\n fn butterfly_cache() -> &'static LocalKey>>> {\n thread_local! {\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\n }\n &BUTTERFLY_CACHE\n }\n }\n\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\n pub enum Mod998244353 {}\n\n impl Modulus for Mod998244353 {\n const VALUE: u32 = 998_244_353;\n const HINT_VALUE_IS_PRIME: bool = true;\n\n fn butterfly_cache() -> &'static LocalKey>>> {\n thread_local! {\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\n }\n &BUTTERFLY_CACHE\n }\n }\n\n pub struct ButterflyCache {\n pub(crate) sum_e: Vec>,\n pub(crate) sum_ie: Vec>,\n }\n\n #[derive(Copy, Clone, Eq, PartialEq)]\n #[repr(transparent)]\n pub struct DynamicModInt {\n val: u32,\n phantom: PhantomData I>,\n }\n\n impl DynamicModInt {\n #[inline]\n pub fn modulus() -> u32 {\n I::companion_barrett().umod()\n }\n\n #[inline]\n pub fn set_modulus(modulus: u32) {\n if modulus == 0 {\n panic!(\"the modulus must not be 0\");\n }\n I::companion_barrett().update(modulus);\n }\n\n #[inline]\n pub fn new(val: T) -> Self {\n ::new(val)\n }\n\n #[inline]\n pub fn raw(val: u32) -> Self {\n Self {\n val,\n phantom: PhantomData,\n }\n }\n\n #[inline]\n pub fn val(self) -> u32 {\n self.val\n }\n\n #[inline]\n pub fn pow(self, n: u64) -> Self {\n ::pow(self, n)\n }\n\n #[inline]\n pub fn inv(self) -> Self {\n Self::inv_for_non_prime_modulus(self)\n }\n }\n\n impl ModIntBase for DynamicModInt {\n #[inline]\n fn modulus() -> u32 {\n Self::modulus()\n }\n\n #[inline]\n fn raw(val: u32) -> Self {\n Self::raw(val)\n }\n\n #[inline]\n fn val(self) -> u32 {\n self.val()\n }\n\n #[inline]\n fn inv(self) -> Self {\n self.inv()\n }\n }\n\n pub trait Id: 'static + Copy + Eq {\n fn companion_barrett() -> &'static Barrett;\n }\n\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\n pub enum DefaultId {}\n\n impl Id for DefaultId {\n fn companion_barrett() -> &'static Barrett {\n static BARRETT: Barrett = Barrett::default();\n &BARRETT\n }\n }\n\n pub struct Barrett {\n m: AtomicU32,\n im: AtomicU64,\n }\n\n impl Barrett {\n #[inline]\n pub const fn new(m: u32) -> Self {\n Self {\n m: AtomicU32::new(m),\n im: AtomicU64::new((-1i64 as u64 / m as u64).wrapping_add(1)),\n }\n }\n\n #[inline]\n const fn default() -> Self {\n Self::new(998_244_353)\n }\n\n #[inline]\n fn update(&self, m: u32) {\n let im = (-1i64 as u64 / m as u64).wrapping_add(1);\n self.m.store(m, atomic::Ordering::SeqCst);\n self.im.store(im, atomic::Ordering::SeqCst);\n }\n\n #[inline]\n fn umod(&self) -> u32 {\n self.m.load(atomic::Ordering::SeqCst)\n }\n\n #[inline]\n fn mul(&self, a: u32, b: u32) -> u32 {\n let m = self.m.load(atomic::Ordering::SeqCst);\n let im = self.im.load(atomic::Ordering::SeqCst);\n internal_math::mul_mod(a, b, m, im)\n }\n }\n\n impl Default for Barrett {\n #[inline]\n fn default() -> Self {\n Self::default()\n }\n }\n\n pub trait ModIntBase:\n Default\n + FromStr\n + From\n + From\n + From\n + From\n + From\n + From\n + From\n + From\n + From\n + From\n + From\n + From\n + Copy\n + Eq\n + Hash\n + fmt::Display\n + fmt::Debug\n + Neg\n + Add\n + Sub\n + Mul\n + Div\n + AddAssign\n + SubAssign\n + MulAssign\n + DivAssign\n {\n fn modulus() -> u32;\n\n fn raw(val: u32) -> Self;\n\n fn val(self) -> u32;\n\n fn inv(self) -> Self;\n\n #[inline]\n fn new(val: T) -> Self {\n Self::raw(val.rem_euclid_u32(Self::modulus()))\n }\n\n #[inline]\n fn pow(self, mut n: u64) -> Self {\n let mut x = self;\n let mut r = Self::raw(1);\n while n > 0 {\n if n & 1 == 1 {\n r *= x;\n }\n x *= x;\n n >>= 1;\n }\n r\n }\n }\n\n pub trait RemEuclidU32 {\n fn rem_euclid_u32(self, modulus: u32) -> u32;\n }\n\n macro_rules! impl_rem_euclid_u32_for_small_signed {\n ($($ty:tt),*) => {\n $(\n impl RemEuclidU32 for $ty {\n #[inline]\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\n (self as i64).rem_euclid(i64::from(modulus)) as _\n }\n }\n )*\n }\n}\n\n impl_rem_euclid_u32_for_small_signed!(i8, i16, i32, i64, isize);\n\n impl RemEuclidU32 for i128 {\n #[inline]\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\n self.rem_euclid(i128::from(modulus)) as _\n }\n }\n\n macro_rules! impl_rem_euclid_u32_for_small_unsigned {\n ($($ty:tt),*) => {\n $(\n impl RemEuclidU32 for $ty {\n #[inline]\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\n self as u32 % modulus\n }\n }\n )*\n }\n}\n\n macro_rules! impl_rem_euclid_u32_for_large_unsigned {\n ($($ty:tt),*) => {\n $(\n impl RemEuclidU32 for $ty {\n #[inline]\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\n (self % (modulus as $ty)) as _\n }\n }\n )*\n }\n}\n\n impl_rem_euclid_u32_for_small_unsigned!(u8, u16, u32);\n impl_rem_euclid_u32_for_large_unsigned!(u64, u128);\n\n #[cfg(target_pointer_width = \"32\")]\n impl_rem_euclid_u32_for_small_unsigned!(usize);\n\n #[cfg(target_pointer_width = \"64\")]\n impl_rem_euclid_u32_for_large_unsigned!(usize);\n\n trait InternalImplementations: ModIntBase {\n #[inline]\n fn inv_for_non_prime_modulus(this: Self) -> Self {\n let (gcd, x) = internal_math::inv_gcd(this.val().into(), Self::modulus().into());\n if gcd != 1 {\n panic!(\"the multiplicative inverse does not exist\");\n }\n Self::new(x)\n }\n\n #[inline]\n fn default_impl() -> Self {\n Self::raw(0)\n }\n\n #[inline]\n fn from_str_impl(s: &str) -> Result {\n Ok(s.parse::()\n .map(Self::new)\n .unwrap_or_else(|_| todo!(\"parsing as an arbitrary precision integer?\")))\n }\n\n #[inline]\n fn hash_impl(this: &Self, state: &mut impl Hasher) {\n this.val().hash(state)\n }\n\n #[inline]\n fn display_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\n fmt::Display::fmt(&this.val(), f)\n }\n\n #[inline]\n fn debug_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\n fmt::Debug::fmt(&this.val(), f)\n }\n\n #[inline]\n fn neg_impl(this: Self) -> Self {\n Self::sub_impl(Self::raw(0), this)\n }\n\n #[inline]\n fn add_impl(lhs: Self, rhs: Self) -> Self {\n let modulus = Self::modulus();\n let mut val = lhs.val() + rhs.val();\n if val >= modulus {\n val -= modulus;\n }\n Self::raw(val)\n }\n\n #[inline]\n fn sub_impl(lhs: Self, rhs: Self) -> Self {\n let modulus = Self::modulus();\n let mut val = lhs.val().wrapping_sub(rhs.val());\n if val >= modulus {\n val = val.wrapping_add(modulus)\n }\n Self::raw(val)\n }\n\n fn mul_impl(lhs: Self, rhs: Self) -> Self;\n\n #[inline]\n fn div_impl(lhs: Self, rhs: Self) -> Self {\n Self::mul_impl(lhs, rhs.inv())\n }\n }\n\n impl InternalImplementations for StaticModInt {\n #[inline]\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\n Self::raw((u64::from(lhs.val()) * u64::from(rhs.val()) % u64::from(M::VALUE)) as u32)\n }\n }\n\n impl InternalImplementations for DynamicModInt {\n #[inline]\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\n Self::raw(I::companion_barrett().mul(lhs.val, rhs.val))\n }\n }\n\n macro_rules! impl_basic_traits {\n () => {};\n (impl <$generic_param:ident : $generic_param_bound:tt> _ for $self:ty; $($rest:tt)*) => {\n impl <$generic_param: $generic_param_bound> Default for $self {\n #[inline]\n fn default() -> Self {\n Self::default_impl()\n }\n }\n\n impl <$generic_param: $generic_param_bound> FromStr for $self {\n type Err = Infallible;\n\n #[inline]\n fn from_str(s: &str) -> Result {\n Self::from_str_impl(s)\n }\n }\n\n impl<$generic_param: $generic_param_bound, V: RemEuclidU32> From for $self {\n #[inline]\n fn from(from: V) -> Self {\n Self::new(from)\n }\n }\n\n #[allow(clippy::derive_hash_xor_eq)]\n impl<$generic_param: $generic_param_bound> Hash for $self {\n #[inline]\n fn hash(&self, state: &mut H) {\n Self::hash_impl(self, state)\n }\n }\n\n impl<$generic_param: $generic_param_bound> fmt::Display for $self {\n #[inline]\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n Self::display_impl(self, f)\n }\n }\n\n impl<$generic_param: $generic_param_bound> fmt::Debug for $self {\n #[inline]\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n Self::debug_impl(self, f)\n }\n }\n\n impl<$generic_param: $generic_param_bound> Neg for $self {\n type Output = $self;\n\n #[inline]\n fn neg(self) -> $self {\n Self::neg_impl(self)\n }\n }\n\n impl<$generic_param: $generic_param_bound> Neg for &'_ $self {\n type Output = $self;\n\n #[inline]\n fn neg(self) -> $self {\n <$self>::neg_impl(*self)\n }\n }\n\n impl_basic_traits!($($rest)*);\n };\n}\n\n impl_basic_traits! {\n impl _ for StaticModInt ;\n impl _ for DynamicModInt;\n }\n\n macro_rules! impl_bin_ops {\n () => {};\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~ <$rhs_ty:ty> -> $output:ty { { $lhs_body:expr } ~ { $rhs_body:expr } } $($rest:tt)*) => {\n impl <$($generic_param: $generic_param_bound),*> Add<$rhs_ty> for $lhs_ty {\n type Output = $output;\n\n #[inline]\n fn add(self, rhs: $rhs_ty) -> $output {\n <$output>::add_impl(apply($lhs_body, self), apply($rhs_body, rhs))\n }\n }\n\n impl <$($generic_param: $generic_param_bound),*> Sub<$rhs_ty> for $lhs_ty {\n type Output = $output;\n\n #[inline]\n fn sub(self, rhs: $rhs_ty) -> $output {\n <$output>::sub_impl(apply($lhs_body, self), apply($rhs_body, rhs))\n }\n }\n\n impl <$($generic_param: $generic_param_bound),*> Mul<$rhs_ty> for $lhs_ty {\n type Output = $output;\n\n #[inline]\n fn mul(self, rhs: $rhs_ty) -> $output {\n <$output>::mul_impl(apply($lhs_body, self), apply($rhs_body, rhs))\n }\n }\n\n impl <$($generic_param: $generic_param_bound),*> Div<$rhs_ty> for $lhs_ty {\n type Output = $output;\n\n #[inline]\n fn div(self, rhs: $rhs_ty) -> $output {\n <$output>::div_impl(apply($lhs_body, self), apply($rhs_body, rhs))\n }\n }\n\n impl_bin_ops!($($rest)*);\n };\n}\n\n macro_rules! impl_assign_ops {\n () => {};\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~= <$rhs_ty:ty> { _ ~= { $rhs_body:expr } } $($rest:tt)*) => {\n impl <$($generic_param: $generic_param_bound),*> AddAssign<$rhs_ty> for $lhs_ty {\n #[inline]\n fn add_assign(&mut self, rhs: $rhs_ty) {\n *self = *self + apply($rhs_body, rhs);\n }\n }\n\n impl <$($generic_param: $generic_param_bound),*> SubAssign<$rhs_ty> for $lhs_ty {\n #[inline]\n fn sub_assign(&mut self, rhs: $rhs_ty) {\n *self = *self - apply($rhs_body, rhs);\n }\n }\n\n impl <$($generic_param: $generic_param_bound),*> MulAssign<$rhs_ty> for $lhs_ty {\n #[inline]\n fn mul_assign(&mut self, rhs: $rhs_ty) {\n *self = *self * apply($rhs_body, rhs);\n }\n }\n\n impl <$($generic_param: $generic_param_bound),*> DivAssign<$rhs_ty> for $lhs_ty {\n #[inline]\n fn div_assign(&mut self, rhs: $rhs_ty) {\n *self = *self / apply($rhs_body, rhs);\n }\n }\n\n impl_assign_ops!($($rest)*);\n };\n}\n\n #[inline]\n fn apply O, X, O>(f: F, x: X) -> O {\n f(x)\n }\n\n impl_bin_ops! {\n for > ~ > -> StaticModInt { { |x| x } ~ { |x| x } }\n for > ~ <&'_ StaticModInt > -> StaticModInt { { |x| x } ~ { |&x| x } }\n for <&'_ StaticModInt > ~ > -> StaticModInt { { |&x| x } ~ { |x| x } }\n for <&'_ StaticModInt > ~ <&'_ StaticModInt > -> StaticModInt { { |&x| x } ~ { |&x| x } }\n for > ~ > -> DynamicModInt { { |x| x } ~ { |x| x } }\n for > ~ <&'_ DynamicModInt> -> DynamicModInt { { |x| x } ~ { |&x| x } }\n for <&'_ DynamicModInt> ~ > -> DynamicModInt { { |&x| x } ~ { |x| x } }\n for <&'_ DynamicModInt> ~ <&'_ DynamicModInt> -> DynamicModInt { { |&x| x } ~ { |&x| x } }\n\n for > ~ -> StaticModInt { { |x| x } ~ { StaticModInt::::new } }\n for > ~ -> DynamicModInt { { |x| x } ~ { DynamicModInt::::new } }\n }\n\n impl_assign_ops! {\n for > ~= > { _ ~= { |x| x } }\n for > ~= <&'_ StaticModInt > { _ ~= { |&x| x } }\n for > ~= > { _ ~= { |x| x } }\n for > ~= <&'_ DynamicModInt> { _ ~= { |&x| x } }\n\n for > ~= { _ ~= { StaticModInt::::new } }\n for > ~= { _ ~= { DynamicModInt::::new } }\n }\n\n macro_rules! impl_folding {\n () => {};\n (impl<$generic_param:ident : $generic_param_bound:tt> $trait:ident<_> for $self:ty { fn $method:ident(_) -> _ { _($unit:expr, $op:expr) } } $($rest:tt)*) => {\n impl<$generic_param: $generic_param_bound> $trait for $self {\n #[inline]\n fn $method(iter: S) -> Self\n where\n S: Iterator,\n {\n iter.fold($unit, $op)\n }\n }\n\n impl<'a, $generic_param: $generic_param_bound> $trait<&'a Self> for $self {\n #[inline]\n fn $method(iter: S) -> Self\n where\n S: Iterator,\n {\n iter.fold($unit, $op)\n }\n }\n\n impl_folding!($($rest)*);\n };\n}\n\n impl_folding! {\n impl Sum<_> for StaticModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\n impl Product<_> for StaticModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\n impl Sum<_> for DynamicModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\n impl Product<_> for DynamicModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "39cfdf722a7081364b7ccc00736d4fdd", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "Rust", "source_code": "use std::io::{stdin};\nuse std::str::FromStr;\nuse std::iter::from_fn;\nuse std::sync::Once;\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n #[allow(dead_code)]\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n\n #[allow(dead_code)]\n fn next_vec (&mut self, n:isize) -> Vec {\n let mut count = 0;\n let res = from_fn(| | {\n if count < n {\n count += 1;\n Some(self.next::())\n } else {\n None\n }\n });\n res.collect()\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n solve(&mut scan)\n}\n\nconst MOD:u64 = 1000000007;\n\nstatic INIT: Once = Once::new();\nstatic mut FACTS:Vec = vec![];\n\nfn fact(n:u64) -> u64 {\n\tunsafe {\n\t\tINIT.call_once(|| {\n\t\t\tFACTS.push(1);\n\t\t\tfor i in 1..=1000 {\n\t\t\t\tFACTS.push((FACTS[i-1]*i as u64)%MOD);\n\t\t\t}\n\t\t});\n\t\tFACTS[n as usize]\n\t}\n}\n\n\n\nfn mod_pow(mut base: u64, mut exp: u64, modulus: u64) -> u64 {\n if modulus == 1 { return 0 }\n let mut result = 1;\n base = base % modulus;\n while exp > 0 {\n if exp % 2 == 1 {\n result = result * base % modulus;\n }\n exp = exp >> 1;\n base = base * base % modulus\n }\n result\n}\n\nfn inverse(base: u64) -> u64 {\n\tmod_pow(base, MOD-2, MOD)\n}\n\nfn perms(n:u64, x:u64) -> u64 {\n\t(fact(n) * inverse(fact(n-x)))%MOD\n}\n\t\nfn solve(scan:&mut Scanner) {\n\tlet n:u64 = scan.next();\n\tlet x:u64 = scan.next();\n\tlet p:u64 = scan.next();\n\tlet mut ltx = Vec::new();\n\tlet mut gtx = Vec::new();\n\tlet mut l = 0;\n\tlet mut r = n;\n\tlet mut m;\n\twhile l < r {\n\t\tm = (l + r)/2;\n\t\tif m < p {\n\t\t\tltx.push(m);\n\t\t\tl = m+1;\n\t\t} else if m > p {\n\t\t\tgtx.push(m);\n\t\t\tr = m\n\t\t} else {\n\t\t\tl = m+1;\n\t\t}\n\t}\n\tif x <= ltx.len() as u64 || n - x < gtx.len() as u64 {\n\t\tprintln!(\"0\");\n\t\treturn;\n\t}\n\tlet free = n - ltx.len() as u64 - gtx.len() as u64 - 1;\n\tprintln!(\"{}\",\n\t\t((perms(free, free) * \n\t\tperms(x-1, ltx.len() as u64))%MOD * \n\t\tperms(n-x, gtx.len() as u64))%MOD);\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "9b845cb4c8ae5447fffd6bf0646900ab", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::io;\nuse std::cmp::{min, max};\nuse std::mem;\nuse std::str::FromStr;\npub struct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Scanner {\n Scanner {\n reader: reader,\n buffer: Vec::new(),\n }\n }\n\n /// Use \"turbofish\" syntax next::() to select data type of next token.\n pub fn next(&mut self) -> T\n where\n T::Err: ::std::fmt::Debug,\n {\n if let Some(front) = self.buffer.pop() {\n front.parse::().expect(&front)\n } else {\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Line not read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n self.next()\n }\n }\n\n pub fn next_vec(&mut self, len: usize) -> Vec\n where\n T::Err: ::std::fmt::Debug,\n {\n (0..len).map(|_| self.next::()).collect::>()\n }\n}\n\nfn main1() {\n let stdin = io::stdin();\n let mut input = Scanner::new(stdin.lock());\n let n = input.next::();\n let m = input.next::();\n let pixels: Vec = input.next_vec(n * m);\n println!(\"{}\", if pixels.iter().all(|x| x == \"W\" || x == \"B\" || x == 'G') {\"#Black&White\"} else {\"#Color\"});\n\n}\n\nfn main() {\n std::thread::Builder::new().stack_size(50 << 20)\n .spawn(main1).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2665a988a5927f9a19d098975ca15d7e", "src_uid": "19c311c02380f9a73cd477e4fde27454", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut a = String::new();\n let mut b = String::new();\n let mut c = String::new();\n\n io::stdin()\n .read_line(&mut a)\n .unwrap();\n\n io::stdin()\n .read_line(&mut b)\n .unwrap();\n\n io::stdin()\n .read_line(&mut c)\n .unwrap();\n\n let a: i64 = a.trim().parse().unwrap();\n let b: i64 = b.trim().parse().unwrap();\n let c: i64 = c.trim().parse().unwrap();\n\n println!(\"{}\",\n [\n (a+b)*c,\n a*b+c,\n a+b*c,\n a+b+c,\n a*b*c,\n a*(b+c)\n ]\n .iter()\n .max()\n .unwrap();\n );\n\n println!(\"{}\", maxima);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2b2508360ac2fcf3e94c87a42a14e7fa", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut a = String::new();\n let mut b = String::new();\n let mut c = String::new();\n\n io::stdin()\n .read_line(&mut a)\n .unwrap();\n\n io::stdin()\n .read_line(&mut b)\n .unwrap();\n\n io::stdin()\n .read_line(&mut c)\n .unwrap();\n\n let a: i64 = a.trim().parse().unwrap();\n let b: i64 = b.trim().parse().unwrap();\n let c: i64 = c.trim().parse().unwrap();\n\n println!(\"{}\",\n [\n (a+b)*c,\n a*b+c,\n a+b*c,\n a+b+c,\n a*b*c,\n a*(b+c)\n ]\n .iter()\n .max()\n .unwrap();\n );\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "fdd9de27af0a20e737dfb98bf50d41fe", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut a = String::new();\n let mut b = String::new();\n let mut c = String::new();\n\n io::stdin()\n .read_line(&mut a)\n .unwrap();\n\n io::stdin()\n .read_line(&mut b)\n .unwrap();\n\n io::stdin()\n .read_line(&mut c)\n .unwrap();\n\n let a: i64 = a.trim().parse().unwrap();\n let b: i64 = b.trim().parse().unwrap();\n let c: i64 = c.trim().parse().unwrap();\n\n let maxima = [\n (a+b)*c,\n a*b+c,\n a+b*c,\n a+b+c,\n a*b*c,\n a*(b+c)\n ]\n .iter()\n .max()\n .unwrap();\n\n println!(\"{}\", maxima);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "b6eb4a03ce1a747a4e09b514fe357a10", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead};\n\nfn it() -> impl Iterator {\n (0..).flat_map(|i| i.to_string().chars().collect::>())\n}\n\nfn main() {\n let line = io::stdin().lock().lines().next().expect(\"input\").expect(\"UTF-8\");\n let index: usize = line.parse().expect(\"Numeric value\");\n\n println!(\"{}\", it().skip(index).next().unwrap());\n}\n\n#[test]\nfn vectors() {\n let in_out = [(7, '7'), (21, '5')];\n\n for (i, o) in &in_out {\n assert_eq!(it().skip(*i).next().unwrap(), *o);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "1fab22c0a5596304e3f7804ac67d937e", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#![allow(non_snake_case, unused_imports, deprecated, dead_code)]\n\n// Input macros\nmacro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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)*} }; }\nmacro_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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\nmacro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect(\"Parse error\") }; }\n\n// Module\nuse std::cmp::{min,max};\nuse std::collections::{VecDeque,HashMap,HashSet,BTreeMap,BTreeSet,BinaryHeap};\n// Module for v1.15.1\nuse std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead\n\n// Functions\n\n// Main\nfn main() {\n\n input! {\n S: String,\n }\n\n let hello = vec!['h','e','l','l','o'];\n\n let mut i = 0;\n for c in S.chars() {\n if c==hello[i] {\n i += 1;\n }\n if i==5 {\n break;\n }\n }\n\n println!(\"{}\", if i==5{\"YES\"else{\"NO\"}});\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2a8825954412e65596e6119e38210c5a", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn convert(s: &str) -> i64 {\n return s.parse().unwrap();\n}\n\nfn main(){\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let mut iter = read.split_whitespace().map(convert);\n let mut l = iter.next().unwrap_or(-1);\n let r = iter.next().unwrap_or(-1);\n if l != r{\n l = 2;\n }\n println!(\"{}\", l);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "84cfc4586b4a98787b4b6201ddb1c440", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "Rust 2021", "source_code": "use std::cmp::min;\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read {\r\n ($out:ident as $type:ty) => {\r\n let mut inner = String::new();\r\n std::io::stdin().read_line(&mut inner).expect(\"A String\");\r\n let $out = inner.trim().parse::<$type>().expect(\"Parsable\");\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_str {\r\n ($out:ident) => {\r\n let mut inner = String::new();\r\n std::io::stdin().read_line(&mut inner).expect(\"A String\");\r\n let $out = inner.trim();\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_vec {\r\n ($out:ident as $type:ty) => {\r\n let mut inner = String::new();\r\n std::io::stdin().read_line(&mut inner).unwrap();\r\n let $out = inner\r\n .trim()\r\n .split_whitespace()\r\n .map(|s| s.parse::<$type>().unwrap())\r\n .collect::>();\r\n };\r\n}\r\n\r\nfn solve(mut v: u32) -> u32 {\r\n let mut d: u32 = 9;\r\n let mut m: u32 = 1;\r\n let mut result = 0;\r\n while v > 0 {\r\n let min_d = min(v, d);\r\n v -= min_d;\r\n result += m * min_d;\r\n d -= 1;\r\n m *= 10;\r\n }\r\n result\r\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "026b81b5ac2d16b04140312881797e31", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "Rust 2021", "source_code": "#include \r\nusing namespace std;\r\nusing ll = long long;\r\n#define int long long\r\n#define rep(x, y, z) for (int x = y; x <= (z); x++)\r\n#define rep1(x, y, z) for (int x = y; x < (z); x++)\r\n#define dep(x, y, z) for (int x = y; x >= (z); x--)\r\n#define dep1(x, y, z) for (int x = y; x > (z); x--)\r\n#define sz(x) ((int)x.size())\r\n#define all(x) x.begin(), x.end()\r\n#define mem(a, b) memset(a, b, sizeof a)\r\n#define endl '\\n'\r\n\r\ntypedef vector vi;\r\ntypedef unsigned long long ull;\r\ntypedef pair pii;\r\n\r\ntemplate void minn(T& a, T b) {if (a > b) a = b;}\r\ntemplate void maxx(T& a, T b) {if (a < b) a = b;}\r\n\r\nconst int mod = 998244353;\r\nconst int N = 2e5 + 5;\r\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\r\nint n;\r\nint norm(int x) {\r\n if (x < 0) {\r\n x += mod;\r\n }\r\n if (x >= mod) {\r\n x -= mod;\r\n }\r\n return x;\r\n}\r\ntemplate\r\nT mfast(T a, int b) {\r\n T res = 1;\r\n for (; b; b /= 2, a *= a) {\r\n if (b % 2) {\r\n res *= a;\r\n }\r\n }\r\n return res;\r\n}\r\nstruct Z {\r\n int x;\r\n Z(int x = 0) : x(norm(x)) {}\r\n int val() const {\r\n return x;\r\n }\r\n Z operator-() const {\r\n return Z(norm(mod - x));\r\n }\r\n Z inv() const {\r\n assert(x != 0);\r\n return mfast(*this, mod - 2);\r\n }\r\n Z &operator*=(const Z &rhs) {\r\n x = ll(x) * rhs.x % mod;\r\n return *this;\r\n }\r\n Z &operator+=(const Z &rhs) {\r\n x = norm(x + rhs.x);\r\n return *this;\r\n }\r\n Z &operator-=(const Z &rhs) {\r\n x = norm(x - rhs.x);\r\n return *this;\r\n }\r\n Z &operator/=(const Z &rhs) {\r\n return *this *= rhs.inv();\r\n }\r\n Z &operator++() {\r\n this->x = norm(this->x + 1);\r\n return *this;\r\n }\r\n Z &operator--() {\r\n this->x = norm(this->x - 1);\r\n return *this;\r\n }\r\n friend Z operator*(const Z &lhs, const Z &rhs) {\r\n Z res = lhs;\r\n res *= rhs;\r\n return res;\r\n }\r\n friend Z operator+(const Z &lhs, const Z &rhs) {\r\n Z res = lhs;\r\n res += rhs;\r\n return res;\r\n }\r\n friend Z operator-(const Z &lhs, const Z &rhs) {\r\n Z res = lhs;\r\n res -= rhs;\r\n return res;\r\n }\r\n friend Z operator/(const Z &lhs, const Z &rhs) {\r\n Z res = lhs;\r\n res /= rhs;\r\n return res;\r\n }\r\n friend ostream& operator<<(ostream& os, const Z& lhs) {\r\n os << lhs.x;\r\n return os;\r\n }\r\n friend istream& operator>>(istream& is, Z& lhs) {\r\n ll x;\r\n cin >> x;\r\n lhs.x = norm(x);\r\n return is;\r\n }\r\n};\r\n\r\nbool prime(int n) {\r\n for (int i = 2; i * i <= n; i++) {\r\n if (n % i == 0) {\r\n while (n % i == 0) n /= i;\r\n return false;\r\n }\r\n }\r\n return true;\r\n}\r\nvoid solve() {\r\n ll m;\r\n cin >> n;\r\n cin >> m;\r\n Z tmp = m % mod;\r\n Z ans = 0;\r\n rep (i, 2, n) {\r\n tmp = tmp * (m % mod);\r\n ans += tmp;\r\n }\r\n ll lc = 1;\r\n vector x(n + 1);\r\n rep (i, 2, n) {\r\n if (prime(i)) {\r\n lc = lcm(i, lc);\r\n }\r\n if (lc > m) {\r\n break;\r\n }\r\n x[i] = (m / lc) % mod;\r\n }\r\n x[1] = m % mod;\r\n rep (i, 2, n) {\r\n x[i] = x[i] * x[i - 1];\r\n ans -= x[i];\r\n }\r\n cout << ans << endl;\r\n}\r\nsigned main()\r\n{\r\n ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\r\n int T = 1;\r\n for (int i = 1; i <= T; i++) {\r\n solve();\r\n }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8519d21684449740ff97450d29684159", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0} {"lang": "Rust", "source_code": "fn main() {\n let mut input = String::new();\n\n std::io::stdin().read_line(&mut input).unwrap();\n\n let mut it = input.split_whitespace().map(|x| x.parse::().unwrap());\n\n let (n, k) = (it.next().unwrap(), it.next().unwrap());\n \n let mut input = String::new();\n\n std::io::stdin().read_line(&mut input).unwrap();\n\n let input = input.trim();\n\n let mut last_poss = [0; 26];\n\n for (i, c) in input.chars().map(|c| c.to_digit(36).unwrap() - 10).enumerate() {\n last_poss[c as usize] = i;\n }\n\n let mut statuses = [0; 26];\n for (i, c) in input.chars().map(|c| c.to_digit(36).unwrap() - 10).enumerate() {\n if i >= last_poss[c as usize] {\n statuses[c as usize] = 0;\n } else {\n statuses[c as usize] = 1;\n }\n let cur_gc:usize = statuses.iter().sum();\n if cur_gc > k {\n println!(\"YES\");\n std::process::exit(0);\n }\n }\n\n println!(\"NO\");\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "52964aa82d0a3daa7705cb0ed1dbeece", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io::{self, BufReader, Stdin};\nuse std::io::prelude::*;\nuse std::collections::BTreeSet;\nuse std::iter::Map;\nuse std::str::SplitWhitespace;\n\nfn main() {\n let mut reader = ReadIn::new();\n\n reader.read_line();\n let a: BTreeSet = reader.read_iter().collect();\n let b: BTreeSet = reader.read_iter().collect();\n let c: BTreeSet = a.intersection(&b).map(|&x| x).collect();\n let res = (if !c.is_empty() { c.iter().map(|&x| x).next() } else {\n a.iter().next().and_then(\n |ax| b.iter().next().map(\n |bx| ax.min(bx) * 10 + ax.max(bx)))\n }).unwrap();\n print!(\"{}\", res);\n}\n\nstruct ReadIn { reader: BufReader, buf: String }\n\nimpl ReadIn {\n fn new() -> ReadIn { ReadIn { reader: BufReader::new(io::stdin()), buf: String::new() } }\n fn read_i32(s: &str) -> i32 { s.parse().unwrap() }\n fn read_line(&mut self) {\n self.buf.clear();\n self.reader.read_line(&mut self.buf);\n }\n fn read_iter(&mut self) -> Map i32> {\n self.read_line();\n self.buf.split_whitespace().map(ReadIn::read_i32)\n }\n fn read_vec(&mut self) -> Vec {\n self.read_iter().collect()\n }\n}\n\n\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "0942aaeaf45bcac290f853372b6ced54", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io::{self, BufReader, Stdin};\nuse std::io::prelude::*;\nuse std::collections::BTreeSet;\nuse std::iter::Map;\nuse std::str::SplitWhitespace;\n\nfn main() {\n let mut reader = ReadIn::new();\n\n reader.read_line();\n let a: BTreeSet = reader.read_iter().collect();\n let b: BTreeSet = reader.read_iter().collect();\n let c: BTreeSet = a.intersection(&b).map(|&x| x).collect();\n let res = (if !c.is_empty() { c.iter().map(|&x| x).next() } else {\n a.iter().next().and_then(\n |&ax| b.iter().next().map(\n |&bx| ax.min(bx) * 10 + ax.max(bx)))\n }).unwrap();\n print!(\"{}\", res);\n}\n\nstruct ReadIn { reader: BufReader, buf: String }\n\nimpl ReadIn {\n fn new() -> ReadIn { ReadIn { reader: BufReader::new(io::stdin()), buf: String::new() } }\n fn read_i32(s: &str) -> i32 { s.parse().unwrap() }\n fn read_line(&mut self) {\n self.buf.clear();\n self.reader.read_line(&mut self.buf);\n }\n fn read_iter(&mut self) -> Map i32> {\n self.read_line();\n self.buf.split_whitespace().map(ReadIn::read_i32)\n }\n fn read_vec(&mut self) -> Vec {\n self.read_iter().collect()\n }\n}\n\n\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "67da8dc27d57490ee88a7f688aa1c40c", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Rust", "source_code": "use rand::prelude::*;\nuse std::boxed::Box;\nuse std::cmp::*;\nuse std::io;\n#[derive(Clone)]\nstruct Node {\n pub key: T,\n pub weight: i64,\n pub left: Option>>,\n pub right: Option>>,\n}\n\nimpl Node {\n fn new(value: T) -> Self {\n Node {\n key: value,\n weight: rand::random::(),\n left: None,\n right: None,\n }\n }\n\n pub fn split(\n node: Option>>,\n key: &T,\n ) -> (Option>>, Option>>) {\n match node {\n None => (None, None),\n Some(mut node) => match node.key.cmp(key) {\n Ordering::Less => {\n let (l, r) = Self::split(node.right, key);\n node.right = l;\n (Some(node), r)\n }\n _ => {\n let (l, r) = Self::split(node.left, key);\n node.left = r;\n (l, Some(node))\n }\n },\n }\n }\n\n pub fn merge(left: Option>>, right: Option>>) -> Option>> {\n match (left, right) {\n (None, None) => None,\n (left, None) => left,\n (None, right) => right,\n (Some(mut left), Some(mut right)) => match left.weight.cmp(&right.weight) {\n Ordering::Less => {\n left.right = Self::merge(left.right, Some(right));\n Some(left)\n }\n _ => {\n right.left = Self::merge(Some(left), right.left);\n Some(right)\n }\n },\n }\n }\n\n fn find(node: &Option>>, key: &T) -> bool {\n match node {\n None => false,\n Some(node) => match node.key.cmp(key) {\n Ordering::Less => Self::find(&node.right, key),\n Ordering::Greater => Self::find(&node.left, key),\n Ordering::Equal => true,\n },\n }\n }\n\n fn less(node: &Box>) -> T {\n match node.left {\n None => node.key.clone(),\n Some(ref left) => Self::less(left),\n }\n }\n}\n\nstruct Treap {\n root: Option>>,\n}\n\nimpl Treap {\n pub fn insert(&mut self, key: T) {\n let (mut l, r) = Node::split(self.root.take(), &key);\n l = Node::merge(l, Some(Box::new(Node::new(key))));\n self.root = Node::merge(l, r);\n }\n\n pub fn delete(&mut self, key: &T) {\n let (l, mut r) = Node::split(self.root.take(), key);\n r = match r {\n None => None,\n Some(node) => {\n if &node.key == key {\n Node::merge(node.left, node.right)\n } else {\n Some(node)\n }\n }\n };\n self.root = Node::merge(l, r);\n }\n\n pub fn find(&self, key: &T) -> bool {\n Node::find(&self.root, key)\n }\n\n pub fn less(&self) -> Option {\n match self.root {\n Some(ref root) => Some(Node::less(root)),\n _ => None,\n }\n }\n\n pub fn new() -> Self {\n Treap { root: None }\n }\n}\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer);\n buffer = String::new();\n io::stdin().read_line(&mut buffer);\n buffer.retain(|s| s != '\\r' && s != '\\n');\n let a: Vec = buffer\n .split_whitespace()\n .map(|n| n.parse::().unwrap())\n .collect();\n\n buffer = String::new();\n io::stdin().read_line(&mut buffer);\n buffer.retain(|s| s != '\\r' && s != '\\n');\n let b: Vec = buffer\n .split_whitespace()\n .map(|n| n.parse::().unwrap())\n .collect();\n\n let mut t1 = Treap::new();\n let mut t2 = Treap::new();\n //println!(\"{:?} | {:?}\", &a, &b);\n for n in a {\n t1.insert(n);\n }\n for n in b {\n t2.insert(n);\n }\n let (m1, m2) = (t1.less().unwrap(), t2.less().unwrap());\n\n match m1.cmp(&m2) {\n Ordering::Less => println!(\"{}{}\", m1, m2),\n Ordering::Greater => println!(\"{}{}\", m2, m1),\n Ordering::Equal => println!(\"{}\", m2),\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "4bf722d4ff9f8751997a4277e90a586f", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "Rust", "source_code": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var, $t:ty, $($v:ident), *) => {\n read_line!(input_line);\n let mut iter = parse_token!($t, input_line);\n $(\n let $v = iter.next().unwrap();\n )*\n };\n (vec, $t:ty, $v:ident) => {\n read_line!(input_line);\n let iter = parse_token!($t, input_line);\n let $v: Vec<$t> = iter.collect();\n };\n ($($v:ident; $t:ty), *) => {\n read_line!(input_line);\n let mut iter = input_line.split_whitespace();\n $(\n let $v: $t = iter.next().unwrap().parse().unwrap();\n )*\n };\n}\n\nmacro_rules! parse_token {\n ($t:ty, $e:expr) => {\n $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());\n };\n}\n\nfn main() {\n read_line!(k;u64, n;u64);\n let mut cnt = 0;\n for i in 1..(k + 1) {\n if k % i == 0 {\n cnt += 1;\n }\n if cnt == n {\n println!(\"{}\", i);\n return;\n }\n }\n\n println!(\"-1\");\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "b8ca2bdb3b4a865984fcd60c497ac6d9", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "Rust", "source_code": "fn main() -> std::io::Result<()> {\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: &str = contents[0];\n\tlet _num:u32 = contents.parse().unwrap();\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: Vec<&str> = contents[0].split_whitespace().collect();\n\tlet mut numbers: Vec = Vec::new();\n\tfor number in contents {\n\t\tnumbers.push(number.parse().unwrap());\n\t}\n\tlet mut check: std::collections::HashMap = std::collections::HashMap::new();\n\tfor number in &numbers {\n\t\tlet current = check.get_mut(number);\n\t\t//println!(\"{:?}\", current);\n\t\tmatch current {\n\t\t\tNone => check.insert(*number, 1),\n\t\t\tSome(numbera) => {\n\t\t\t\tlet new = *numbera+1;\n\t\t\t\tcheck.insert(*number, new)\n\t\t\t}\n\t\t};\n\t}\n\tlet mut max: u32 = 0;\n\tfor number in &numbers {\n\t\tlet cur = *check.get(number).unwrap();\n\t\tif cur > max{\n\t\t\tmax = cur;\n\t\t}\n\t}\n\tprintln!(\"{}\",max);\n\tOk(())\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "3fadc998309a6b71ed94fecdca77ab1d", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() -> std::io::Result<()> {\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: &str = contents[0];\n\tlet _num:u32 = contents.parse().unwrap();\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: Vec<&str> = contents[0].split_whitespace().collect();\n\tlet mut numbers: Vec = Vec::new();\n\tfor number in contents {\n\t\tnumbers.push(number.parse().unwrap());\n\t}\n\tlet mut check: std::collections::HashMap = std::collections::HashMap::new();\n\tfor &number in &numbers {\n\t\tlet current = &check.get(&number);\n\t\t//println!(\"{:?}\", current);\n\t\tmatch current {\n\t\t\tNone => check.insert(number, 1),\n\t\t\tSome(numbera) => {\n\t\t\t\tlet new = *numbera+1;\n\t\t\t\tcheck.insert(number, new)\n\t\t\t}\n\t\t};\n\t}\n\tlet mut max: u32 = 0;\n\tfor number in &numbers {\n\t\tlet cur = *check.get(number).unwrap();\n\t\tif cur > max{\n\t\t\tmax = cur;\n\t\t}\n\t}\n\tprintln!(\"{}\",max);\n\tOk(())\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "3c72a28d47f2866d59b4847bb26ef53b", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() -> std::io::Result<()> {\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: &str = contents[0];\n\tlet _num:u32 = contents.parse().unwrap();\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: Vec<&str> = contents[0].split_whitespace().collect();\n\tlet mut numbers: Vec = Vec::new();\n\tfor number in contents {\n\t\tnumbers.push(number.parse().unwrap());\n\t}\n\tlet mut check: std::collections::HashMap = std::collections::HashMap::new();\n\tfor &number in &numbers {\n\t\tlet current = &mut check.get(&number);\n\t\t//println!(\"{:?}\", current);\n\t\tmatch current {\n\t\t\tNone => check.insert(number, 1),\n\t\t\tSome(numbera) => {\n\t\t\t\tlet new = *numbera+1;\n\t\t\t\tcheck.insert(number, new)\n\t\t\t}\n\t\t};\n\t}\n\tlet mut max: u32 = 0;\n\tfor number in &numbers {\n\t\tlet cur = *check.get(number).unwrap();\n\t\tif cur > max{\n\t\t\tmax = cur;\n\t\t}\n\t}\n\tprintln!(\"{}\",max);\n\tOk(())\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "52c2924755f8ff8c2a1a4e984109d7c4", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() -> std::io::Result<()> {\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: &str = contents[0];\n\tlet _num:u32 = contents.parse().unwrap();\n let mut contents = String::new();\n\tstd::io::stdin().read_line(&mut contents)?;\n\tlet contents: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet contents: Vec<&str> = contents[0].split_whitespace().collect();\n\tlet mut numbers: Vec = Vec::new();\n\tfor number in contents {\n\t\tnumbers.push(number.parse().unwrap());\n\t}\n\tlet mut check: std::collections::HashMap = std::collections::HashMap::new();\n\tfor number in &numbers {\n\t\tlet mut current = check.get(number);\n\t\t//println!(\"{:?}\", current);\n\t\tmatch current {\n\t\t\tNone => check.insert(*number, 1),\n\t\t\tSome(numbera) => check.insert(*number, *numbera+1)\n\t\t};\n\t}\n\tlet mut max: u32 = 0;\n\tfor number in &numbers {\n\t\tlet cur = *check.get(number).unwrap();\n\t\tif cur > max{\n\t\t\tmax = cur;\n\t\t}\n\t}\n\tprintln!(\"{}\",max);\n\tOk(())\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "5fe4cd454e212014265292054bc7f676", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn digit_sum(x: i64) -> i64 {\n let mut x = x;\n let mut ans = 0;\n while x > 0 {\n ans += x % 10;\n x /= 10;\n }\n ans\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: u32 = scan.token();\n let b: i64 = scan.token();\n let c: i64 = scan.token();\n let mut ans = Vec::new();\n\n for s_x in 1i64..=81i64 {\n let x = b * s_x.pow(a) + c;\n if x >= 1000000000 {\n break;\n }\n if x < digit_sum(x) == s_x {\n ans.push(x.to_string());\n }\n }\n writeln!(out, \"{}\", ans.len()).ok();\n writeln!(out, \"{}\", ans.join(\" \")).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "30043d838ae8d8d8ff865d50a7d52283", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(dead_code)]\n\nuse std::char::*;\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse std::str::FromStr;\n\nmacro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);}}\nmacro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ 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 ) * } } ; }\nmacro_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 ) * } } ; }\nmacro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\n\n\nfn read() -> T {\n let stdin = stdin();\n let stdin = stdin.lock();\n let token: String = stdin\n .bytes()\n .map(|c| c.expect(\"failed to read char\") as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect();\n token.parse().ok().expect(\"failed to parse token\")\n}\n\nfn read_vec() -> Vec {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim().split_whitespace()\n .map(|e| e.parse().ok().unwrap()).collect()\n}\n\n\nuse std::f64;\n\nfn min(a:T, b:T) -> T {\n if a < b { a }\n else { b }\n}\n\nfn max(a:T, b:T) -> T {\n if a < b { b }\n else { a }\n}\n\nuse std::hash::Hash;\nfn inc(map:&mut BTreeMap, key:T) {\n let count = map.entry(key).or_insert(0);\n *count += 1;\n}\n\nfn int(ch: char) -> i64 {\n return (ch as u8 - b'0') as i64\n}\n\nconst MAX:usize = 100006;\nconst INF:i64 = std::i64::MAX;\nconst MOD:i64 = 1e9 as i64 + 7;\n\n\nfn main() {\n input!{n:usize, a:[usize;3]};\n\n let mut dp = vec![-1;n+1];\n dp[0] = 0;\n\n for i in 0..n+1 {\n for j in 0..3 {\n if i < a[j] { continue; }\n if dp[i-a[j]] == -1 { continue; }\n dp[i] = max(dp[i], dp[i-a[j]]+1);\n }\n }\n //debug!(dp);\n\n println!(\"{}\", dp[n]);\n}\n\n/*\n\n\u9577\u3055 n \u306e\u30ea\u30dc\u30f3\u3092 a,b,c \u306e\u3044\u305a\u308c\u304b\u306e\u9577\u3055\u306b\u3059\u308b\u3002\n\u3053\u306e\u3068\u304d\u3001\u6700\u5927\u306e\u30ea\u30dc\u30f3\u306e\u6570\u3092\u6c42\u3081\u308b\u3002\n\ndp[i] := \u9577\u3055 i \u306e\u30ea\u30dc\u30f3\u3092\u5207\u308c\u308b\u6700\u5927\u306e\u6570\ndp[i] = max(dp[i-a[j]]+1, j=0,1,2)\n\n\n\n*", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "e3f901abec2aa5b09b124fa53ff9d530", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "Rust", "source_code": "se std::io::{self, BufRead};\n\ntype Point = (i32, i32);\ntype Seg = (Point, Point);\n\nfn cm(base: &Point, a: &Point, b: &Point) -> i32 {\n let debug = false;\n if debug { println!(\"base {:?}, a {:?}, b {:?}\", base, a, b) }\n return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);\n}\n\nfn inx(a: i32, b: i32, x: i32) -> bool {\n return (b >= a && x >= a && x <= b) || (b <= a && x <= a && x >= b);\n}\n\nfn ins(pa: &Point, pb: &Point, px: &Point) -> bool {\n return inx(pa.0, pb.0, px.0) && inx(pa.1, pb.1, px.1);\n}\n\nfn intersect(a: &Seg, b: &Seg) -> bool {\n let b0 = cm(&a.0, &a.1, &b.0);\n if b0 == 0 && ins(&a.0, &a.1, &b.0) { return true; }\n let b1 = cm(&a.0, &a.1, &b.1);\n if b1 == 0 && ins(&a.0, &a.1, &b.1) { return true; }\n let a0 = cm(&b.0, &b.1, &a.0);\n if a0 == 0 && ins(&b.0, &b.1, &a.0) { return true; }\n let a1 = cm(&b.0, &b.1, &a.1);\n if a1 == 0 && ins(&b.0, &b.1, &a.1) { return true; }\n return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))\n && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));\n}\n\nfn main() {\n let debug = false;\n let stdin: io::Stdin = io::stdin();\n let mut lines: io::Lines = stdin.lock().lines();\n\n let next_line = lines.next()\n .unwrap() // Option { Some(Result), None }\n .unwrap(); // Result { Ok(String), Err(io::Error) }\n\n let square_a: Vec<_> = next_line\n .trim()\n .split(' ')\n .map(|n| {\n n.parse::().unwrap()\n })\n .collect();\n\n let next_line = lines.next()\n .unwrap() // Option { Some(Result), None }\n .unwrap(); // Result { Ok(String), Err(io::Error) }\n\n let square_b: Vec<_> = next_line\n .trim()\n .split(' ')\n .map(|n| {\n n.parse::().unwrap()\n })\n .collect();\n \n // any a inside b\n for a_i in 0..4 {\n let a = (square_a[2*a_i], square_a[2*a_i+1]);\n let mut left = false;\n let mut right = false;\n for i in 0..4 {\n let base = (square_b[2*i], square_b[2*i+1]);\n let j = (i+1) % 4;\n let b = (square_b[2*j], square_b[2*j+1]);\n let cmv = cm(&base, &b, &a);\n if cmv > 0 { left = true; }\n if cmv < 0 { right = true; }\n }\n if !left || !right {\n println!(\"YES\");\n return;\n }\n }\n\n // any b inside a\n for b_i in 0..4 {\n let b = (square_b[2*b_i], square_b[2*b_i+1]);\n let mut left = false;\n let mut right = false;\n for i in 0..4 {\n let base = (square_a[2*i], square_a[2*i+1]);\n let j = (i+1) % 4;\n let a = (square_a[2*j], square_a[2*j+1]);\n let cmv = cm(&base, &a, &b);\n if cmv > 0 { left = true; }\n if cmv < 0 { right = true; }\n }\n if !left || !right {\n println!(\"YES\");\n return;\n }\n }\n\n // check intersect\n for a_i in 0..4 {\n let a_a = (square_a[2*a_i], square_a[2*a_i+1]);\n let a_j = (a_i + 1) % 4;\n let a_b = (square_a[2*a_j], square_a[2*a_j+1]);\n let seg_a = (a_a, a_b);\n\n for i in 0..4 {\n let b_a = (square_b[2*i], square_b[2*i+1]);\n let j = (i+1) % 4;\n let b_b = (square_b[2*j], square_b[2*j+1]);\n let seg_b = (b_a, b_b);\n if intersect(&seg_a, &seg_b) {\n println!(\"YES\");\n return;\n }\n }\n }\n\n println!(\"NO\");\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "eb33439aebf0b968e71dc53c8c29173b", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\nuse std::io::{self, BufRead};\nuse std::cmp::*;\nuse std::collections::*;\n\nmacro_rules! scan_to_vec {\n ($count:expr, $t:ty) => ({\n let mut result = Vec::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n for _ in 0..$count {\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_to_vec: failed at `handle.read_line`.\");\n result.push(buffer.trim().parse::<$t>()\n .expect(\"scan_to_vec: failed at `parse::<$t>`.\"));\n }\n result\n })\n}\n\nmacro_rules! scan_line_to_vec {\n ($t:ty) => ({\n let mut result = Vec::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line_to_vec: failed at `handle.read_line`.\");\n \n for s in buffer.split_whitespace() {\n result.push(s.parse::<$t>()\n .expect(\"scan_line_to_vec: failed at `parse::<$t>`.\"));\n }\n result\n })\n}\n\nmacro_rules! scan_line {\n () => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n buffer\n });\n ( $($t:ty)+ ) => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n let mut chunks = buffer.split_whitespace();\n\n ($(\n {\n chunks.next()\n .expect(\"scan_line: failed at `next`, # of space separated strings not equal to requested #\")\n .parse::<$t>()\n .expect(\"scan_line: failed at `parse::<$t>`.\")\n },\n )+)\n })\n}\n\nfn main() {\n let (mut k,) = scan_line!(i64);\n\n if k == 0 {\n println!(\"a\");\n return;\n }\n\n let mut sums = vec![0i64; 100001];\n for i in 1..sums.len() {\n sums[i] = sums[i-1] + i;\n }\n\n let mut char_counts = vec![0; 300];\n for i in ('a' as usize)..('z' as usize) {\n let index = {\n let mut index = 0;\n for i in (1..sums.len()).rev() {\n if k >= sums[i] as i64 {\n index = i;\n break;\n }\n }\n index\n };\n k = k - (sums[index] as i64);\n char_counts[i as usize] = index + 1;\n if k == 0 { break; }\n }\n\n let mut result = String::new();\n for i in ('a' as usize)..('z' as usize) {\n if char_counts[i as usize] > 1 {\n for j in 0..char_counts[i as usize] {\n result.push((i as u8) as char);\n }\n }\n }\n\n println!(\"{}\", result);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "95d748fced02583f44f7a8f53fe256a7", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "Rust 2021", "source_code": "use proconio::input;\nfn main() {\n input! {\n n: usize,\n q: [u32; n]\n }\n for qq in q {\n println!(\"{}\", 2u64.pow(qq) - 1);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "32aeaa6a7938c7ee09702a51f29ea9e1", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "Rust", "source_code": "//! ----------------------------------------------\n//! Framework \n//!\n//! See the bottom of file for solution.\n//! ----------------------------------------------\n\n#![allow(unused_imports)]\n#![allow(non_snake_case)]\n\nuse std::cell::RefCell;\nuse std::cmp::{max, min, Ordering};\nuse std::collections::*;\nuse std::fmt::{Debug, Display, Formatter, Write as FmtWrite};\nuse std::io::{stderr, stdin, BufRead, Write};\nuse std::mem::{replace, swap};\nuse std::ops::*;\nuse std::rc::Rc;\n\n/// Print values to standard error if debug mode.\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($e:expr),*) => {\n #[cfg(debug_assertions)]\n $({\n let (e, mut err) = (stringify!($e), stderr());\n writeln!(err, \"\\x1B[33m{}\\x1B[0m = {:?}\", e, $e).unwrap()\n })*\n };\n}\n\n/// Read from standard input and parse each word.\n/// - `read!(T, U, ..)` parses a line as a tuple of words.\n/// - `read![[T]]` parses a line as an array of words.\n/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.\n#[allow(unused_macros)]\nmacro_rules! read {\n ([$t:ty] ; $n:expr) =>\n ((0..$n).map(|_| read!([$t])).collect::>());\n ($($t:ty),+ ; $n:expr) =>\n ((0..$n).map(|_| read!($($t),+)).collect::>());\n ([$t:ty]) =>\n (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>());\n ($($t:ty),*) => {{\n let buf = rl();\n let mut w = buf.split_whitespace();\n ($(w.next().unwrap().parse::<$t>().unwrap()),*)\n }};\n}\n\n/// Read a line from standard input.\n#[allow(dead_code)]\nfn rl() -> String {\n let mut buf = String::new();\n stdin().read_line(&mut buf).unwrap();\n\n #[allow(deprecated)]\n buf.trim_right().to_owned()\n}\n\n// -----------------------------------------------\n// Solution\n// -----------------------------------------------\n\nfn main() {\n let (N, M, r) = read!(usize, usize, i64);\n let S = read![[i64]];\n let B = read![[i64]];\n\n let &min_s = S.iter().min().unwrap();\n let &max_b = B.iter().max().unwrap();\n\n println!(\n \"{}\",\n if min_s >= max_b {\n r\n } else {\n (r % min_s) + (r / min_s) * max_b\n }\n )\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "48fc32ba292649c539eb3808c40ed299", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::cmp::{\n min,\n max\n};\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let (nodes, edges) = readln!(i64, i64);\n\n let (min_isolated, max_isolated) = if edges == 0 {\n (nodes, nodes)\n } else {\n (\n if nodes % 2 == 0 {\n max(0, ((nodes + 1) / 2 - edges) * 2)\n } else {\n max(0, ((nodes + 1) / 2 - edges) * 2 - 1)\n },\n nodes - ((1.0 + (8.0 * edges as f64 + 1.0).sqrt()) / 2.0).ceil() as i32\n )\n };\n\n\n println!(\"{} {}\", min_isolated, max_isolated);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "f05aab467822360ce7cda5d1372e0cb4", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "Rust 2021", "source_code": "use std::{ io::{ self, Write } };\n\nfn solve>>(mut lines: I) -> Option> {\n\tlet count: usize = lines.next()?.ok()?\n\t\t.parse().ok()?;\n\n\t(0..count).map(|_| {\n\t\tlet mut key: usize = lines.next()?.ok()?\n\t\t\t.parse().ok()?;\n\t\tlet doors: [_; 3] = lines.next()?.ok()?\n\t\t\t.split(' ')\n\t\t\t.map(str::parse)\n\t\t\t.collect::, _>>().ok()?\n\t\t\t.try_into().ok()?;\n\n\t\tlet mut opened: usize = 0;\n\n\t\twhile opened < 3 {\n\t\t\tkey = if key > 0 && key <= doors.len() {\n\t\t\t\tdoors[key - 1]\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t};\n\n\t\t\topened += 1;\n\t\t}\n\n\t\tSome(opened == 3)\n\t})\n\t\t.collect()\n}\n\nfn main() -> io::Result<()> {\n\tlet mut stdout = io::BufWriter::new(io::stdout());\n\tlet lines = io::stdin().lines();\n\n\tlet result = solve(lines).unwrap();\n\n\tfor case in result {\n\t\tstdout.write_all(if case { b\"YES\\n\" } else { b\"NO\\n\" })?;\n\t}\n\n\tOk(())\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ec2bb8ab1a26b1c9a4c2920cbe41b670", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "Rust", "source_code": "#![feature(int_log)]\nuse std::io::stdin;\n\nfn main() {\n let stdin = stdin();\n let mut string = String::new();\n\n stdin.read_line(&mut string).unwrap();\n\n let n = string.trim().parse::().unwrap();\n\n let mut nodes = 2u128.pow(n as u32) - 2;\n let mut re = 1;\n loop{\n let mut inner_re = 4;\n if nodes == 0{\n break;\n }\n\n let times = nodes.log2();\n for _ in 0..times{\n inner_re = inner_re * inner_re;\n if inner_re > (1e9 as u128 + 7){\n inner_re = inner_re% (1e9 as u128 + 7)\n }\n }\n\n re = re * inner_re % (1e9 as u128 + 7);\n nodes = nodes - 2u128.pow(times);\n }\n println!(\"{}\", re * 6 % (1e9 as u128 + 7))\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8d71bd074ef51e712eeaf950cd279f2b", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"\");\n let mut num = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n io::stdin().read_line(&mut a_str).expect(\"\");\n let mut v = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n\n let n = num[0];\n let k = num[1];\n\n let mut res = 0;\n v.sort().reverse();\n for i in &v {\n if k % i == 0 {\n res = k / i;\n break;\n }\n }\n println!(\"{}\", res);\n\n\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "7974faf307672774fa903586b0c79d59", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io;\n\n#[cfg(debug_assertions)]\nmacro_rules! debug_println {\n ($( $args:expr ),*) => { println!( $( $args ),* ); }\n}\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let (l, p) = buf.chars().fold((0, 0), |mut cnt, v| {\n match v {\n '-' => cnt.0 += 1,\n 'o' => cnt.1 += 1,\n _ => (),\n }\n cnt\n });\n debug_println!(\"{:?}\", (l, p));\n println!(\"{}\", if l % p == 0 { \"YES\" } else { \"NO\" });\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d0f3dadf096c495cd1741f039558e479", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::{io, process};\n\nfn main() {\n\tlet n: u8 = {\n\t\tlet mut line = String::new();\n\t\tio::stdin().read_line(&mut line).unwrap();\n\t\tline.trim().parse().unwrap()\n\t};\n\n\tlet mut a: Vec = {\n\t\tlet mut line = String::new();\n\t\tio::stdin().read_line(&mut line).unwrap();\n\t\tline.trim().split(' ').map(|a| a.parse().unwrap()).collect()\n\t};\n\n\ta.sort();\n\n\t// remove duplicates\n\tlet mut i = a.len() - 1;\n\tloop {\n\t\tfor j in (0..a.len()).rev() {\n\t\t\tif i == j {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif a[i] == a[j] {\n\t\t\t\tif i > j {\n\t\t\t\t\ta.remove(i);\n\t\t\t\t\ta.remove(j);\n\t\t\t\t} else {\n\t\t\t\t\ta.remove(j);\n\t\t\t\t\ta.remove(i);\n\t\t\t\t}\n\t\t\t\ti -= 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif i == 0 {\n\t\t\tbreak;\n\t\t}\n\t\ti -= 1;\n\t}\n\n\tassert!(a.len() % 2 == 0);\n\n\tlet mut pb0 = 0u32;\n\tfor s in a\n\t\t.iter()\n\t\t.enumerate()\n\t\t.filter(|s| s.0 % 2 == 0)\n\t\t.map(|s| *s.1)\n\t\t.zip(a.iter().enumerate().filter(|s| s.0 % 2 == 1).map(|s| *s.1))\n\t{\n\t\tpb0 += s.1 as u32 - s.0 as u32;\n\t}\n\n\tif a.len() < 3 {\n\t\tprintln!(\"{}\", pb0);\n\t\tprocess::exit(0);\n\t}\n\n\tlet mut pb1 = 0u32;\n\tlet mut b: Vec = a\n\t\t.iter()\n\t\t.enumerate()\n\t\t.filter(|s| s.0 % 2 == 0)\n\t\t.map(|s| *s.1)\n\t\t.collect();\n\tprintln!(\"{:?}\", b);\n\tb.remove(0);\n\tb.remove(b.len() - 1);\n\tfor s in a\n\t\t.iter()\n\t\t.enumerate()\n\t\t.filter(|s| s.0 % 2 == 1)\n\t\t.map(|s| *s.1)\n\t\t.zip(b)\n\t{\n\t\tpb1 += s.1 as u32 - s.0 as u32;\n\t}\n\tpb1 += a[a.len() - 1] as u32 - a[0] as u32;\n\n\tprintln!(\"{}\", pb0.min(pb1));\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "3662bfa6aefe2b20afccc1a5d2714958", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n\tlet n: u8 = {\n\t\tlet mut line = String::new();\n\t\tio::stdin().read_line(&mut line).unwrap();\n\t\tline.trim().parse().unwrap()\n\t};\n\n\tlet mut a: Vec = {\n\t\tlet mut line = String::new();\n\t\tio::stdin().read_line(&mut line).unwrap();\n\t\tline.trim().split(' ').map(|a| a.parse().unwrap()).collect()\n\t};\n\n\ta.sort();\n\n\t// remove duplicates\n\tlet mut i = a.len() - 1;\n\tloop {\n\t\tfor j in (0..a.len()).rev() {\n\t\t\tif i == j {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif a[i] == a[j] {\n\t\t\t\tif i > j {\n\t\t\t\t\ta.remove(i);\n\t\t\t\t\ta.remove(j);\n\t\t\t\t} else {\n\t\t\t\t\ta.remove(j);\n\t\t\t\t\ta.remove(i);\n\t\t\t\t}\n\t\t\t\ti -= 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif i == 0 {\n\t\t\tbreak;\n\t\t}\n\t\ti -= 1;\n\t}\n\n\tassert!(a.len() % 2 == 0);\n\n\tlet mut pb0 = 0u32;\n\tfor s in a.iter().enumerate().filter(|s| s.0 % 2 == 0).map(|s| *s.1).zip(a.iter().enumerate().filter(|s| s.0 % 2 == 1).map(|s| *s.1)) {\n\t\tpb0 += s.1 as u32 - s.0 as u32;\n\t}\n\n\tif a.len() < 3 {\n\t\tprintln!(\"{}\", pb0);\n\t\tstd::process::exit(0);\n\t}\n\n\tlet mut pb1 = 0u32;\n\tlet mut b: Vec = a.iter().enumerate().filter(|s| s.0 % 2 == 0).map(|s| *s.1).collect();\n\tprintln!(\"{:?}\", b);\n\tb.remove(0);\n\tb.remove(b.len() - 1);\n\tfor s in a.iter().enumerate().filter(|s| s.0 % 2 == 1).map(|s| *s.1).zip(b) {\n\t\tpb1 += s.1 as u32 - s.0 as u32;\n\t}\n\tpb1 += a[a.len() - 1] as u32 - a[0] as u32;\n\t\n\tprintln!(\"{}\", pb0.min(pb1));\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "105e58d0054f91c64b62e2c173ea10ca", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0} {"lang": "Rust 2021", "source_code": "use std::{\r\n io::{prelude::*, stdin, stdout, BufWriter},\r\n mem::swap,\r\n};\r\n\r\nconst MOD: i64 = 1000000007;\r\n\r\nfn main() {\r\n let std_in = stdin();\r\n let mut input = Scanner::new(std_in.lock());\r\n\r\n let std_out = stdout();\r\n let mut output = BufWriter::new(std_out.lock());\r\n\r\n let n: usize = input.token();\r\n\r\n let mut phi: Vec = (0..=n).collect();\r\n for i in 2..=n {\r\n if phi[i] == i {\r\n for j in (i..=n).step_by(i) {\r\n phi[j] -= phi[j] / i;\r\n }\r\n }\r\n }\r\n\r\n let mut result = 0;\r\n for c in 1..n {\r\n let sum = n - c;\r\n if sum < 2 {\r\n continue;\r\n }\r\n\r\n add_to_result(c as i64, 1, phi[sum] as i64, &mut result);\r\n for x in 2..=sum {\r\n if x * x > sum {\r\n break;\r\n }\r\n if sum % x != 0 {\r\n continue;\r\n }\r\n\r\n let y = sum / x;\r\n if phi[y] != 0 {\r\n add_to_result(c as i64, x as i64, phi[y] as i64, &mut result);\r\n }\r\n if x != y && phi[x] != 0 {\r\n add_to_result(c as i64, y as i64, phi[x] as i64, &mut result);\r\n }\r\n }\r\n }\r\n writeln!(output, \"{}\", result).unwrap();\r\n}\r\n\r\nfn add_m(x: i64, y: i64) -> i64 {\r\n let mut tmp = x + y;\r\n if tmp < 0 {\r\n tmp += MOD;\r\n }\r\n if tmp >= MOD {\r\n tmp -= MOD;\r\n }\r\n tmp\r\n}\r\n\r\nfn mul_m(x: i64, y: i64) -> i64 {\r\n (x * y) % MOD\r\n}\r\n\r\nfn gcd(mut a: i64, mut b: i64) -> i64 {\r\n while b != 0 {\r\n a %= b;\r\n swap(&mut a, &mut b);\r\n }\r\n a\r\n}\r\n\r\nfn add_to_result(c: i64, g: i64, cnt: i64, result: &mut i64) {\r\n *result = add_m(*result, mul_m(cnt, c * g / gcd(c, g)));\r\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "40871acaf2fe914ac67bbbf5eb21a459", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "Rust", "source_code": "use std::io;\n\nconst BALLS_SIZE: usize = 3;\nconst CRYST_SIZE: usize = 2;\n\nenum ColorsC{\n Yell,\n Blue\n}\n\nenum ColorsB{\n Yell,\n Green,\n Blue\n}\n\ntype CrystalsArray = [i64; CRYST_SIZE];\ntype BallsArray = [i64; BALLS_SIZE];\n\nfn count_crystals(balls :BallsArray) -> CrystalsArray{\n fn count_yellow(num: i64 ) -> CrystalsArray {\n [2*num, 0]\n }\n fn count_green(num: i64 ) -> CrystalsArray {\n [num, num]\n }\n fn count_blue(num: i64 ) -> CrystalsArray {\n [0,3*num]\n }\n println!(\"\");\n let mut res: CrystalsArray = [0; CRYST_SIZE];\n for (ind,i) in count_yellow(balls[ColorsB::Yell as usize]).iter().enumerate(){\n res[ind] += i;\n }\n for (ind,i) in count_green(balls[ColorsB::Green as usize]).iter().enumerate(){\n res[ind] += i;\n }\n\n for (ind,i) in count_blue(balls[ColorsB::Blue as usize]).iter().enumerate(){\n res[ind] += i;\n }\n return res ;\n}\n\nfn main() {\n let mut input: String = String::new();\n io::stdin().read_line(&mut input).expect(\"some error\");\n let mut cryst_inp: CrystalsArray = [0; CRYST_SIZE];\n let mut balls_inp: BallsArray = [0; BALLS_SIZE];\n for (ind,i) in input.trim().split(char::is_whitespace).enumerate(){\n cryst_inp[ind] = i.trim().parse().expect(\"failed to parse\");\n }\n input.clear();\n io::stdin().read_line(&mut input).expect(\"some error\");\n for (ind,i) in input.trim().split(char::is_whitespace).enumerate(){\n balls_inp[ind] = i.trim().parse().expect(\"failed to parse\");\n }\n let have_to = count_crystals(balls_inp);\n let mut sum = 0;\n for (ind,i) in cryst_inp.iter().enumerate(){\n sum += have_to[ind] - i;\n }\n print!(\"{}\", sum);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "b531baa304305e9e084abc83898cb042", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "Rust", "source_code": "#![allow(unused_variables)]\n#![allow(unused_must_use)]\nuse std::io::{self, prelude::*};\n\nfn solve(mut input: FastInput, mut w: W) {\n let n = input.token();\n let k: usize = input.token();\n let mut c = vec![0usize; n];\n for x in c.iter_mut() {\n *x = input.token();\n }\n let a = c.iter().filter(|&&x| x == 0).count();\n\n let first_0 = |a, n, x| x;\n let first_1 = |a, n, x| a - x;\n let second_0 = |a, n, x| a - x;\n let second_1 = |a, n, x| n - a - second_0(a, n, x);\n let increase = |a, n, x| {\n let res = first_1(a, n, x) * second_0(a, n, x);\n (res + res) / n / (n - RatioMod::identity())\n };\n let decrease = |a, n, x| {\n let res = first_0(a, n, x) * second_1(a, n, x);\n (res + res) / n / (n - RatioMod::identity())\n };\n let same = |a, n, x| {\n let res = a * (a - RatioMod::identity())\n + (n - a) * (n - a - RatioMod::identity())\n + first_0(a, n, x) * second_0(a, n, x)\n + first_0(a, n, x) * second_0(a, n, x)\n + first_1(a, n, x) * second_1(a, n, x)\n + first_1(a, n, x) * second_1(a, n, x);\n res / n / (n - RatioMod::identity())\n };\n\n let into = |x| Ratio::from(MOD7::from(x as u32));\n let inc = |x| increase(into(a), into(n), into(x));\n let dec = |x| same(into(a), into(n), into(x));\n let eq = |x| decrease(into(a), into(n), into(x));\n\n let mut init: Matrix = Matrix::new(1, a + 1);\n *init.elem_mut(0, a - c[..a].iter().sum::()) = RatioMod::identity();\n\n let mut transition: Matrix = Matrix::new(a + 1, a + 1);\n *transition.elem_mut(0, 0) = dec(0);\n if a > 0 {\n *transition.elem_mut(1, 0) = eq(1);\n *transition.elem_mut(a - 1, a) = inc(a - 1);\n *transition.elem_mut(a, a) = dec(a);\n }\n for i in 1..a {\n *transition.elem_mut(i - 1, i) = inc(i - 1);\n *transition.elem_mut(i, i) = dec(i);\n *transition.elem_mut(i + 1, i) = eq(i + 1);\n }\n let ans = init * binary_power(&transition, k as u64);\n let ans = ans.elem(0, a);\n let ans = ans.0 * ans.1.inverse();\n write!(w, \"{}\\n\", ans);\n}\n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let input = FastInput::from(stdin.lock());\n let writer = io::BufWriter::new(stdout.lock());\n solve(input, writer);\n}\n\ntrait TokenStream {\n fn token(&mut self) -> T;\n}\n\nstruct FastInput {\n stdin: R,\n pos: usize,\n}\n\nimpl From for FastInput {\n fn from(r: R) -> Self {\n FastInput { stdin: r, pos: 0 }\n }\n}\n\nimpl TokenStream for FastInput {\n fn token(&mut self) -> u8 {\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n while self.pos < buf.len() {\n self.pos += 1;\n if buf[self.pos - 1] > 32 {\n return buf[self.pos - 1];\n }\n }\n if self.pos == 0 {\n return 0;\n }\n } else {\n return 0;\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n\nimpl TokenStream> for FastInput {\n fn token(&mut self) -> Vec {\n let mut ans = Vec::new();\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans.push(buf[self.pos]);\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n\nmacro_rules! impl_token_stream_u {\n ($($t:ident),+) => {$(\n impl TokenStream<$t> for FastInput {\n fn token(&mut self) -> $t {\n let mut ans = 0;\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans = ans * 10 + (buf[self.pos] - b'0') as $t;\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n }\n )+}\n}\n\npub trait Identity {\n fn identity() -> Self;\n}\n\npub trait SelfIdentity {\n fn self_identity(&self) -> Self;\n}\n\nimpl SelfIdentity for T {\n fn self_identity(&self) -> Self {\n Self::identity()\n }\n}\n\npub trait Inverse {\n fn inverse(self) -> Self;\n}\n\nmacro_rules! define_modular_type {\n ($mod:ident, $value:expr) => {\n #[derive(Copy, Clone, Default, PartialEq)]\n struct $mod(u32);\n\n impl $mod {\n const MOD: u64 = $value;\n }\n\n impl std::fmt::Debug for $mod {\n fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n write!(f, \"{:?}\", self.0)\n }\n }\n\n impl std::fmt::Display for $mod {\n fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n }\n\n impl> From for $mod {\n fn from(a: T) -> Self {\n $mod((a.into() % Self::MOD) as u32)\n }\n }\n\n impl Into for $mod {\n fn into(self) -> u32 {\n self.0\n }\n }\n\n impl Identity for $mod {\n fn identity() -> Self {\n 1u32.into()\n }\n }\n\n impl Inverse for $mod {\n fn inverse(self) -> Self {\n let mut t = (Self::default(), Self::identity());\n let mut r = (Self::MOD, self.0 as u64);\n while r.1 != 0 {\n let q = r.0 / r.1;\n t = (t.1, t.0 - t.1 * q.into());\n r = (r.1, r.0 - r.1 * q);\n }\n t.0\n }\n }\n\n impl std::ops::Add for $mod {\n type Output = $mod;\n fn add(self, rhs: $mod) -> Self::Output {\n let mut ret = self.0 + rhs.0;\n if ret >= Self::MOD as u32 {\n ret -= Self::MOD as u32;\n }\n $mod(ret)\n }\n }\n\n impl std::ops::AddAssign for $mod {\n fn add_assign(&mut self, rhs: Self) {\n self.0 += rhs.0;\n if self.0 >= Self::MOD as u32 {\n self.0 -= Self::MOD as u32;\n }\n }\n }\n\n impl std::ops::Neg for $mod {\n type Output = Self;\n fn neg(self) -> Self::Output {\n $mod(Self::MOD as u32 - self.0)\n }\n }\n\n impl std::ops::Sub for $mod {\n type Output = $mod;\n fn sub(self, rhs: Self) -> Self::Output {\n if self.0 < rhs.0 {\n $mod(self.0 + (Self::MOD as u32) - rhs.0)\n } else {\n $mod(self.0 - rhs.0)\n }\n }\n }\n\n impl std::ops::SubAssign for $mod {\n fn sub_assign(&mut self, rhs: Self) {\n if self.0 < rhs.0 {\n self.0 += Self::MOD as u32;\n }\n self.0 -= rhs.0\n }\n }\n\n impl std::ops::Mul for $mod {\n type Output = $mod;\n fn mul(self, rhs: Self) -> Self::Output {\n let a = self.0 as u64;\n let b = rhs.0 as u64;\n let c = a * b % Self::MOD;\n $mod(c as u32)\n }\n }\n\n impl std::ops::MulAssign for $mod {\n fn mul_assign(&mut self, rhs: Self) {\n *self = *self * rhs;\n }\n }\n\n impl std::ops::Div for $mod {\n type Output = Self;\n fn div(self, rhs: Self) -> Self::Output {\n self * rhs.inverse()\n }\n }\n\n impl std::ops::DivAssign for $mod {\n fn div_assign(&mut self, rhs: Self) {\n *self = *self / rhs;\n }\n }\n };\n}\n\nfn gcd(mut a: T, mut b: T) -> T\nwhere\n T: Copy + std::cmp::PartialEq + std::default::Default + std::ops::Rem,\n{\n while b != T::default() {\n let r = a % b;\n a = b;\n b = r;\n }\n a\n}\n\n#[derive(Copy, Clone, Debug)]\nstruct Ratio(T, T);\n\nimpl Ratio\nwhere\n T: Copy\n + std::cmp::PartialEq\n + std::default::Default\n + std::ops::Rem\n + std::ops::DivAssign,\n{\n fn normalize(&mut self) {\n let g = gcd(self.0, self.1);\n self.0 /= g;\n self.1 /= g;\n }\n}\n\nimpl std::default::Default for Ratio\nwhere\n T: std::default::Default + Identity,\n{\n fn default() -> Self {\n Self(T::default(), T::identity())\n }\n}\n\nimpl Identity for Ratio\nwhere\n T: Identity,\n{\n fn identity() -> Self {\n Self(T::identity(), T::identity())\n }\n}\n\nimpl From<(T, T)> for Ratio {\n fn from(a: (T, T)) -> Self {\n Ratio(a.0, a.1)\n }\n}\n\nimpl From for Ratio\nwhere\n T: Identity,\n{\n fn from(a: T) -> Self {\n Ratio(a, T::identity())\n }\n}\n\nimpl std::ops::Add for Ratio\nwhere\n T: Copy + std::ops::Add + std::ops::Mul,\n{\n type Output = Ratio;\n fn add(self, rhs: Ratio) -> Self::Output {\n Ratio(self.0 * rhs.1 + self.1 * rhs.0, self.1 * rhs.1)\n }\n}\n\nimpl std::ops::AddAssign for Ratio\nwhere\n T: Copy + std::ops::Add + std::ops::Mul,\n{\n fn add_assign(&mut self, rhs: Ratio) {\n let den = self.1 * rhs.1;\n self.0 = self.0 * rhs.1 + self.1 * rhs.0;\n self.1 = den;\n }\n}\n\nimpl std::ops::Sub for Ratio\nwhere\n T: Copy + std::ops::Sub + std::ops::Mul,\n{\n type Output = Ratio;\n fn sub(self, rhs: Ratio) -> Self::Output {\n Ratio(self.0 * rhs.1 - self.1 * rhs.0, self.1 * rhs.1)\n }\n}\n\nimpl std::ops::Mul for Ratio\nwhere\n T: std::ops::Mul,\n{\n type Output = Ratio;\n fn mul(self, rhs: Ratio) -> Self::Output {\n Ratio(self.0 * rhs.0, self.1 * rhs.1)\n }\n}\nimpl std::ops::MulAssign for Ratio\nwhere\n T: std::ops::MulAssign,\n{\n fn mul_assign(&mut self, rhs: Ratio) {\n self.0 *= rhs.0;\n self.1 *= rhs.1;\n }\n}\n\nimpl std::ops::Div for Ratio\nwhere\n T: std::ops::Mul,\n{\n type Output = Ratio;\n fn div(self, rhs: Ratio) -> Self::Output {\n Ratio(self.0 * rhs.1, self.1 * rhs.0)\n }\n}\n\n#[derive(Clone)]\npub struct Matrix {\n data: Vec,\n cols: usize,\n rows: usize,\n}\n\nimpl Matrix\nwhere\n T: std::default::Default + Clone,\n{\n pub fn new(rows: usize, cols: usize) -> Matrix {\n let data = vec![T::default(); cols * rows];\n Matrix {\n data: data,\n cols: cols,\n rows: rows,\n }\n }\n}\n\nimpl Matrix {\n pub fn rows(&self) -> std::slice::Chunks {\n self.data.chunks(self.cols)\n }\n pub fn rows_mut(&mut self) -> std::slice::ChunksMut {\n self.data.chunks_mut(self.cols)\n }\n pub fn elem(&self, row: usize, col: usize) -> &T {\n &self.data[self.cols * row + col]\n }\n pub fn elem_mut(&mut self, row: usize, col: usize) -> &mut T {\n &mut self.data[self.cols * row + col]\n }\n}\n\nimpl std::fmt::Debug for Matrix\nwhere\n T: std::fmt::Debug,\n{\n fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {\n self.rows()\n .try_for_each(|row| fmt.write_fmt(format_args!(\"{:?}\\n\", row)))\n }\n}\n\nimpl SelfIdentity for Matrix\nwhere\n T: Identity + std::default::Default + Clone,\n{\n fn self_identity(&self) -> Self {\n assert_eq!(self.cols, self.rows);\n let mut ret = Matrix::new(self.rows, self.cols);\n for (i, row) in ret.rows_mut().enumerate() {\n row[i] = T::identity();\n }\n ret\n }\n}\n\nimpl std::ops::Add for Matrix\nwhere\n T: Clone + std::default::Default + std::ops::Add,\n{\n type Output = Matrix;\n fn add(self, rhs: Matrix) -> Matrix {\n assert_eq!(self.cols, rhs.cols);\n assert_eq!(self.rows, rhs.rows);\n Matrix {\n data: self\n .data\n .iter()\n .zip(rhs.data)\n .map(|(a, b)| a.clone() + b.clone())\n .collect(),\n rows: self.rows,\n cols: self.cols,\n }\n }\n}\nimpl std::ops::Sub for Matrix\nwhere\n T: Clone + std::default::Default + std::ops::Sub,\n{\n type Output = Matrix;\n fn sub(self, rhs: Matrix) -> Matrix {\n assert_eq!(self.cols, rhs.cols);\n assert_eq!(self.rows, rhs.rows);\n Matrix {\n data: self\n .data\n .iter()\n .zip(rhs.data)\n .map(|(a, b)| a.clone() - b.clone())\n .collect(),\n rows: self.rows,\n cols: self.cols,\n }\n }\n}\nimpl std::ops::Mul for Matrix\nwhere\n T: Clone + std::default::Default + std::ops::AddAssign + std::ops::Mul,\n{\n type Output = Matrix;\n fn mul(self, rhs: Matrix) -> Matrix {\n assert_eq!(self.cols, rhs.rows);\n let mut ret: Matrix = Matrix::new(self.rows, rhs.cols);\n for (ret_row, self_row) in ret.rows_mut().zip(self.rows()) {\n for (rhs_row, self_el) in rhs.rows().zip(self_row) {\n for (ret_el, rhs_el) in ret_row.iter_mut().zip(rhs_row) {\n *ret_el += self_el.clone() * rhs_el.clone();\n }\n }\n }\n ret\n }\n}\n\nfn binary_power(a: &T, mut exp: u64) -> T\nwhere\n T: Clone + std::ops::Mul + SelfIdentity,\n{\n let mut base = a.clone();\n let mut acc = a.self_identity();\n while exp > 1 {\n if (exp & 1) == 1 {\n acc = acc * base.clone();\n }\n exp /= 2;\n base = base.clone() * base.clone();\n }\n if exp == 1 {\n acc = acc * base;\n }\n acc\n}\n\nimpl_token_stream_u!(usize);\ndefine_modular_type!(MOD7, 1_000_000_007);\ntype RatioMod = Ratio;\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "bcdf6915864253ce31fac32be9d831f3", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::cmp;\nuse std::collections::HashMap;\nfn read_i32s() -> io::Result> {\n\tlet mut input = String::new();\n\tio::stdin().read_line(&mut input)?;\n\tlet mut vec: Vec = Vec::new();\n\tfor num in input.split_whitespace() {\n\t\tvec.push(num.parse::().unwrap());\n\t}\n\treturn Ok(vec);\n}\n\nfn main() {\n\tlet vec = read_i32s().unwrap();\n\tlet _n = vec[0];\n\tlet vec = read_i32s().unwrap();\n\tlet mut cnt = HashMap::new();\n\tlet mut mx = 0;\n\tfor num in vec {\n\t\tlet count = cnt.entry(num).or_insert(0);\n\t\t*count += 1;\n\t\tmx = cmp::max(mx, num);\n\t}\n\tlet ans1 = mx;\n\tlet mut t = 1;\n\tloop {\n\t\tif t*t > mx {\n\t\t\tbreak;\n\t\t}\n\t\tif mx % t == 0 {\n\t\t\tlet count = cnt.entry(t).or_insert(0);\n\t\t\tif t*t == mx {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t*count -= 1;\n\t\t\tlet count = cnt.entry(mx/t).or_insert(0);\n\t\t\t*count -= 1;\n\t\t}\n\t\tt += 1;\n\t}\n\tmx = 0;\n\tfor (key, value) in cnt.iter() {\n\t\tif *value != 0 {\n\t\t\tmx = cmp::max(mx, *key);\n\t\t}\n\t}\n\tlet ans2 = mx;\n\tprintln!(\"{} {}\", ans1, ans2);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "65d294607443a2593e6529415002b7bd", "src_uid": "868407df0a93085057d06367aecaf9be", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::str::FromStr;\nuse std::io::stdin;\n\nfn get_vals(count: usize) -> Vec where\n T: FromStr,\n ::Err: std::fmt::Debug {\n let mut val = String::new();\n stdin().read_line(&mut val).expect(\"Failed to read line\");\n val.split_whitespace()\n .map(|x|\n x.parse::().expect(\"Failed to parse value\"))\n .take(count).collect()\n}\n\npub fn mashmokh() {\n let mut ins = get_vals::(2);\n let (n, k) = (ins.remove(0), ins.remove(0));\n let mut dp = vec![vec![0 as u32; k]; n];\n for x in dp[0].iter_mut() {\n *x = 1;\n }\n for i in dp.iter_mut() {\n i[0] = 1;\n }\n for i in 1..dp.len() {\n for j in 1..dp[i].len() {\n dp[i][j] = factor(i as i64 + 1)\n .into_iter()\n .map(|x| dp[x as usize - 1][j - 1])\n .sum()\n }\n }\n let ans: u32 = dp.iter_mut().map(|x| x[(k - 1) as usize]).sum();\n for i in dp {\n for j in i {\n print!(\"{0: <2}\", j);\n }\n println!();\n }\n println!(\"{}\", ans % 1000000007)\n}\n\npub fn factor(input: i64) -> Vec {\n let mut vector = vec![];\n\n for count in 1..(input + 1) {\n if input % count == 0 {\n vector.push(count);\n }\n }\n\n return vector;\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d7002f58f74497bce433e865607264f0", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Rust", "source_code": "use std::str::FromStr;\nuse std::io::stdin;\n\nfn get_vals(count: usize) -> Vec where\n T: FromStr,\n ::Err: std::fmt::Debug {\n let mut val = String::new();\n stdin().read_line(&mut val).expect(\"Failed to read line\");\n val.split_whitespace()\n .map(|x|\n x.parse::().expect(\"Failed to parse value\"))\n .take(count).collect()\n}\n\npub fn mashmokh() {\n let mut ins = get_vals::(2);\n let (n, k) = (ins.remove(0), ins.remove(0));\n let mut dp = vec![vec![0 as usize; k]; n];\n for x in dp[0].iter_mut() {\n *x = 1;\n }\n for i in dp.iter_mut() {\n i[0] = 1;\n }\n for i in 1..dp.len() {\n for j in 1..dp[i].len() {\n dp[i][j] = factor(i + 1)\n .into_iter()\n .map(|x| dp[x - 1][j - 1])\n .sum()\n }\n }\n let ans: usize = dp.iter_mut().map(|x| x[k - 1]).sum();\n // for i in dp {\n // for j in i {\n // print!(\"{0: <2}\", j);\n // }\n // println!();\n // }\n println!(\"{}\", ans % 1000000007)\n}\n\npub fn factor(input: usize) -> Vec {\n let mut vector = vec![];\n\n for count in 1..(input + 1) {\n if input % count == 0 {\n vector.push(count as usize);\n }\n }\n\n return vector;\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "b7efc273f43945097a66754235c6e219", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "Rust", "source_code": "use std::*;\n\nfn main () {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let a: i32 = buf.parse();\n println!(\"1\");\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "c88d0c0f761d5b41ae6872280c9fa4ce", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min};\nuse std::collections::HashSet;\n\nstruct Reader {}\n\nimpl Reader {\n #[allow(unused)]\n fn read_string() -> String {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n string.trim().to_string()\n }\n\n #[allow(unused)]\n fn read_tokens() -> Vec:: {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n let mut v = Vec::new();\n for value in string.split_whitespace() {\n v.push(value.to_string());\n }\n v\n }\n}\n\n//mod math;\n\npub fn generate_simple_numbers(max_value: u64) -> Vec {\n let mut src = vec![true; max_value as usize + 1];\n let mut dst = Vec::new();\n\n for i in 2 .. max_value as usize + 1 {\n if src[i] {\n let mut ind = i * i;\n while ind <= max_value as usize {\n src[ind] = false;\n ind += i;\n }\n dst.push(i as u64);\n }\n }\n dst\n}\n\nfn main() {\n let n = Reader::read_string().parse::().unwrap();\n let simple_numbers = generate_simple_numbers(3000);\n let mut ans = 0_i64;\n for i in 1..=n {\n let mut number = i;\n let mut map = std::collections::BTreeSet::::new();\n for value in simple_numbers.iter() {\n if *value > number {\n break;\n }\n while number % *value == 0 {\n map.insert(*value);\n number /= *value;\n }\n }\n if map.len() == 2 {\n ans += 1;\n }\n }\n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8b4f35c7c6c67152f1643e219397c71b", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\n#![allow(non_snake_case)]\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::Write;\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($e:expr),*) => {\n #[cfg(debug_assertions)]\n $({\n let (e, mut err) = (stringify!($e), std::io::stderr());\n writeln!(err, \"{} = {:?}\", e, $e).unwrap()\n })*\n };\n}\n\nfn main() {\n let n = read::();\n let a = read::()\n .chars()\n .map(|x| -(x.to_digit(36).unwrap() as i64 - 10))\n .collect::>();\n let mut dp = vec![std::i64::MAX; n];\n let mut color = vec![0; n];\n for i in 0..n {\n let mut pointer = dp.lower_bound(&a[i]);\n dp[pointer] = a[i];\n color[i] = pointer;\n }\n if dp.lower_bound(&std::i64::MAX) <= 2 {\n println!(\"YES\");\n for ch in color {\n print!(\"{}\", ch);\n }\n println!(\"\");\n } else {\n println!(\"NO\");\n }\n}\n\npub trait BinarySearch {\n fn lower_bound(&self, &T) -> usize;\n}\n\nimpl BinarySearch for [T] {\n fn lower_bound(&self, x: &T) -> usize {\n let mut low = 0;\n let mut high = self.len();\n\n while low != high {\n let mid = (low + high) / 2;\n match self[mid].cmp(x) {\n Ordering::Less => {\n low = mid + 1;\n }\n Ordering::Equal | Ordering::Greater => {\n high = mid;\n }\n }\n }\n low\n }\n}\n\nfn read() -> T {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn read_vec() -> Vec {\n read::()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "426aca7419ef9111ec2d37f9a7eeae0c", "src_uid": "9bd31827cda83eacfcf5e46cdeaabe2b", "difficulty": 1800.0} {"lang": "Rust", "source_code": "// Vicfred\n// https://codeforces.com/problemset/problem/546/C\n\nuse std::io;\nuse std::collections::HashSet;\nuse std::collections::VecDeque;\n\n#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]\nstruct Pair(i64, i64);\n\nfn main() {\n let mut n = String::new();\n\n io::stdin()\n .read_line(&mut n)\n .unwrap();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut a: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n a.pop_front();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut b: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n b.pop_front();\n\n let mut ans = 0;\n\n while !a.is_empty() && !b.is_empty() {\n ans += 1;\n\n println!(\"{:?}\", a);\n println!(\"{:?}\", b);\n\n let x = a.pop_front().unwrap();\n let y = b.pop_front().unwrap();\n\n states.insert(Pair(x,y));\n\n if x > y {\n a.push_back(y);\n a.push_back(x);\n } else {\n b.push_back(x);\n b.push_back(y);\n }\n if ans > 1000 {\n println!(\"-1\");\n return;\n }\n }\n\n let winner = if a.is_empty() {2} else {1};\n\n println!(\"{} {}\", ans, winner);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "822893329e40f9516b5e2fbf1d40f99d", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "Rust", "source_code": "use std::fs::File;\nuse std::io::prelude::*;\nuse std::path::Path;\n\nfn main() -> std::io::Result<()> {\n let mut file = File::open(Path::new(\"input.txt\")).unwrap_or(| | {\n\t\tprintln!(\"Error\");\n\t});\n\tlet mut f = File::create(Path::new(\"output.txt\"))?;\n let mut contents = String::new();\n file.read_to_string(&mut contents)?;\n\tlet g: Vec<&str> = contents.split(\"\\r\\n\").collect();\n\tlet num:u32 = g[0].parse().unwrap();\n\tlet v: Vec<&str> = g[1].split('W').collect();\n\tlet mut size = 0;\n\tif v[v.len()-1].len()==0 {\n\t\tsize=v.len()-1;\n\t} else {\n\t\tsize=v.len();\n\t}\n\tlet pr = format!(\"{}\\n\", size);\n\tf.write_all(pr.as_bytes())?;\n\tfor index in 0..size {\n\t\tlet pr = format!(\"{} \", v[index].len());\n\t\tf.write_all(pr.as_bytes())?;\n\t}\n\tOk(())\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "6e3e92110b20c48ad8d3ab491b741ef3", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn read_int() -> u16 {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n let x = input.trim().parse::().unwrap();\n x\n}\n\nfn read_int_vec() -> Vec{\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"read error\");\n let mut vec = input.split_whitespace()\n .map(|i| i.parse::().expect(\"parse error\"))\n .collect::>();\n vec\n}\n\nfn main() {\n \n let x = read_int() + 1;\n let vec = read_int_vec();\n let sum: u16 = vec.iter().sum();\n\n let mut total = 0;\n let mut range = 1..6;\n loop {\n match range.next() {\n Some(i) => {\n // println!(\"also: ({}+{}) % {} = {}\", sum, i, x, (((sum+i) % x) + x)% x);\n if !((((sum+i) % x) + x) % x == 1){\n // println!(\"====\");\n total = total + 1;\n }\n },\n None => { break }\n }\n }\n println!(\"}\", total);\n\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "3195610b9b4f62195f7f428c4825aaf0", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0} {"lang": "Rust", "source_code": "macro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn div_and_ceil(a: i32, b: i32) -> i32 {\n if a % b == 0 { a / b } else { a / b + 1 }\n}\n\nfn main() {\n let (guests, lists) = readln(i32, i32);\n \n let red = div_and_ceil(2 * guests, lists);\n let green = div_and_ceil(5 * guests, lists);\n let blue = div_and_ceil(8 * guests, lists);\n \n println!(\"{}\", red + green + blue);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "f440decd86ad176e026a152ea70207bb", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0} {"lang": "Rust", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nbool f_possible(int x, vector p) {\n int perm_count = 0;\n do {\n if ((((x % p[0]) % p[1]) % p[2]) % p[3] == x) {\n perm_count++;\n }\n if (perm_count >= 7) {\n return true;\n }\n }\n while (next_permutation(p.begin(), p.end()));\n return false;\n}\n\nint solve(const vector& p, int a, int b) {\n int ans = 0;\n for (int x = a; x <= b; x++) {\n if (f_possible(x, p)) {\n ans++;\n }\n }\n return ans;\n}\n\nint main() {\n vector p;\n for (int i = 0; i < 4; i++) {\n int x; cin >> x;\n p.push_back(x);\n }\n sort(p.begin(), p.end());\n int a, b;\n cin >> a >> b;\n int ans = solve(p, a, b);\n cout << ans << \"\\n\";\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "84a1823d2d5e3fe660f77b0dce472e5d", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\r\nuse std::io::{stdout, BufWriter, Write};\r\nfn main() {\r\n let out = stdout();\r\n let mut out = BufWriter::new(out.lock());\r\n\r\n inputv! {\r\n t:usize,\r\n }\r\n ModInt::set_modulus(1_000_000_007);\r\n let mut dpf = DpFactorial::new();\r\n\r\n for _ in 0..t {\r\n inputv! {\r\n n:usize,k:usize,\r\n }\r\n let mut ans = ModInt::new(0);\r\n for q in 0..=k {\r\n ans += dpf.get_combination(k, q) * ModInt::new(n - 1).pow(q as u64);\r\n }\r\n writeln!(out, \"{}\", ans).unwrap();\r\n }\r\n}\r\n\r\n//https://github.com/rust-lang-ja/ac-library-rs\r\n//https://github.com/manta1130/competitive-template-rs\r\n\r\nuse dpfactorial::*;\r\nuse modint::*;\r\n\r\npub mod dpfactorial {\r\n use crate::modint::*;\r\n\r\n #[derive(Default)]\r\n pub struct DpFactorial {\r\n normal: Vec,\r\n inv: Vec,\r\n }\r\n impl DpFactorial {\r\n #[allow(dead_code)]\r\n pub fn new() -> DpFactorial {\r\n let mut obj = DpFactorial {\r\n normal: Vec::new(),\r\n inv: Vec::new(),\r\n };\r\n obj.normal.push(ModInt::new(1));\r\n obj.inv.push(ModInt::new(1));\r\n obj\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_factorial(&mut self, n: usize) -> ModInt {\r\n if n < self.normal.len() {\r\n return self.normal[n];\r\n }\r\n for z in self.normal.len()..n as usize + 1 {\r\n let buf = ModInt::new(z);\r\n let buf = buf * self.normal[z - 1];\r\n\r\n self.normal.push(buf);\r\n }\r\n self.normal[n]\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_factorial_inv(&mut self, n: usize) -> ModInt {\r\n if n < self.inv.len() {\r\n return self.inv[n];\r\n }\r\n for z in self.inv.len()..n + 1 {\r\n let mut buf = ModInt::new(z);\r\n buf = buf.inv();\r\n let buf = buf * self.inv[z - 1];\r\n self.inv.push(buf);\r\n }\r\n self.inv[n]\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_combination(&mut self, n: usize, r: usize) -> ModInt {\r\n if n < r {\r\n return ModInt::new(0);\r\n }\r\n self.get_factorial(n) * self.get_factorial_inv(n - r) * self.get_factorial_inv(r)\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_permutation(&mut self, n: usize, r: usize) -> ModInt {\r\n if n < r {\r\n return ModInt::new(0);\r\n }\r\n self.get_factorial(n) * self.get_factorial_inv(n - r)\r\n }\r\n }\r\n}\r\npub mod internal_math {\r\n #![allow(dead_code)]\r\n use std::mem::swap;\r\n\r\n /* const */\r\n pub(crate) fn safe_mod(mut x: i64, m: i64) -> i64 {\r\n x %= m;\r\n if x < 0 {\r\n x += m;\r\n }\r\n x\r\n }\r\n\r\n pub(crate) struct Barrett {\r\n pub(crate) _m: u32,\r\n pub(crate) im: u64,\r\n }\r\n\r\n impl Barrett {\r\n pub(crate) fn new(m: u32) -> Barrett {\r\n Barrett {\r\n _m: m,\r\n im: (-1i64 as u64 / m as u64).wrapping_add(1),\r\n }\r\n }\r\n\r\n pub(crate) fn umod(&self) -> u32 {\r\n self._m\r\n }\r\n\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn mul(&self, a: u32, b: u32) -> u32 {\r\n mul_mod(a, b, self._m, self.im)\r\n }\r\n }\r\n\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn mul_mod(a: u32, b: u32, m: u32, im: u64) -> u32 {\r\n let mut z = a as u64;\r\n z *= b as u64;\r\n let x = (((z as u128) * (im as u128)) >> 64) as u64;\r\n let mut v = z.wrapping_sub(x.wrapping_mul(m as u64)) as u32;\r\n if m <= v {\r\n v = v.wrapping_add(m);\r\n }\r\n v\r\n }\r\n\r\n /* const */\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn pow_mod(x: i64, mut n: i64, m: i32) -> i64 {\r\n if m == 1 {\r\n return 0;\r\n }\r\n let _m = m as u32;\r\n let mut r: u64 = 1;\r\n let mut y: u64 = safe_mod(x, m as i64) as u64;\r\n while n != 0 {\r\n if (n & 1) > 0 {\r\n r = (r * y) % (_m as u64);\r\n }\r\n y = (y * y) % (_m as u64);\r\n n >>= 1;\r\n }\r\n r as i64\r\n }\r\n\r\n /* const */\r\n pub(crate) fn is_prime(n: i32) -> bool {\r\n let n = n as i64;\r\n match n {\r\n _ if n <= 1 => return false,\r\n 2 | 7 | 61 => return true,\r\n _ if n % 2 == 0 => return false,\r\n _ => {}\r\n }\r\n let mut d = n - 1;\r\n while d % 2 == 0 {\r\n d /= 2;\r\n }\r\n for &a in &[2, 7, 61] {\r\n let mut t = d;\r\n let mut y = pow_mod(a, t, n as i32);\r\n while t != n - 1 && y != 1 && y != n - 1 {\r\n y = y * y % n;\r\n t <<= 1;\r\n }\r\n if y != n - 1 && t % 2 == 0 {\r\n return false;\r\n }\r\n }\r\n true\r\n }\r\n\r\n /* const */\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn inv_gcd(a: i64, b: i64) -> (i64, i64) {\r\n let a = safe_mod(a, b);\r\n if a == 0 {\r\n return (b, 0);\r\n }\r\n\r\n let mut s = b;\r\n let mut t = a;\r\n let mut m0 = 0;\r\n let mut m1 = 1;\r\n\r\n while t != 0 {\r\n let u = s / t;\r\n s -= t * u;\r\n m0 -= m1 * u; // |m1 * u| <= |m1| * s <= b\r\n\r\n swap(&mut s, &mut t);\r\n swap(&mut m0, &mut m1);\r\n }\r\n if m0 < 0 {\r\n m0 += b / s;\r\n }\r\n (s, m0)\r\n }\r\n\r\n /* const */\r\n pub(crate) fn primitive_root(m: i32) -> i32 {\r\n match m {\r\n 2 => return 1,\r\n 167_772_161 => return 3,\r\n 469_762_049 => return 3,\r\n 754_974_721 => return 11,\r\n 998_244_353 => return 3,\r\n _ => {}\r\n }\r\n\r\n let mut divs = [0; 20];\r\n divs[0] = 2;\r\n let mut cnt = 1;\r\n let mut x = (m - 1) / 2;\r\n while x % 2 == 0 {\r\n x /= 2;\r\n }\r\n for i in (3..std::i32::MAX).step_by(2) {\r\n if i as i64 * i as i64 > x as i64 {\r\n break;\r\n }\r\n if x % i == 0 {\r\n divs[cnt] = i;\r\n cnt += 1;\r\n while x % i == 0 {\r\n x /= i;\r\n }\r\n }\r\n }\r\n if x > 1 {\r\n divs[cnt] = x;\r\n cnt += 1;\r\n }\r\n let mut g = 2;\r\n loop {\r\n if (0..cnt).all(|i| pow_mod(g, ((m - 1) / divs[i]) as i64, m) != 1) {\r\n break g as i32;\r\n }\r\n g += 1;\r\n }\r\n }\r\n}\r\npub mod modint {\r\n\r\n use crate::internal_math;\r\n use std::{\r\n cell::RefCell,\r\n convert::{Infallible, TryInto as _},\r\n fmt,\r\n hash::{Hash, Hasher},\r\n iter::{Product, Sum},\r\n marker::PhantomData,\r\n ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign},\r\n str::FromStr,\r\n sync::atomic::{self, AtomicU32, AtomicU64},\r\n thread::LocalKey,\r\n };\r\n\r\n pub type ModInt1000000007 = StaticModInt;\r\n pub type ModInt998244353 = StaticModInt;\r\n pub type ModInt = DynamicModInt;\r\n\r\n #[derive(Copy, Clone, Eq, PartialEq)]\r\n #[repr(transparent)]\r\n pub struct StaticModInt {\r\n val: u32,\r\n phantom: PhantomData M>,\r\n }\r\n\r\n impl StaticModInt {\r\n #[inline(always)]\r\n pub fn modulus() -> u32 {\r\n M::VALUE\r\n }\r\n\r\n #[inline]\r\n pub fn new(val: T) -> Self {\r\n Self::raw(val.rem_euclid_u32(M::VALUE))\r\n }\r\n\r\n #[inline]\r\n pub fn raw(val: u32) -> Self {\r\n Self {\r\n val,\r\n phantom: PhantomData,\r\n }\r\n }\r\n\r\n #[inline]\r\n pub fn val(self) -> u32 {\r\n self.val\r\n }\r\n\r\n #[inline]\r\n pub fn pow(self, n: u64) -> Self {\r\n ::pow(self, n)\r\n }\r\n\r\n #[inline]\r\n pub fn inv(self) -> Self {\r\n if M::HINT_VALUE_IS_PRIME {\r\n if self.val() == 0 {\r\n panic!(\"attempt to divide by zero\");\r\n }\r\n debug_assert!(\r\n internal_math::is_prime(M::VALUE.try_into().unwrap()),\r\n \"{} is not a prime number\",\r\n M::VALUE,\r\n );\r\n self.pow((M::VALUE - 2).into())\r\n } else {\r\n Self::inv_for_non_prime_modulus(self)\r\n }\r\n }\r\n }\r\n\r\n impl ModIntBase for StaticModInt {\r\n #[inline(always)]\r\n fn modulus() -> u32 {\r\n Self::modulus()\r\n }\r\n\r\n #[inline]\r\n fn raw(val: u32) -> Self {\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn val(self) -> u32 {\r\n self.val()\r\n }\r\n\r\n #[inline]\r\n fn inv(self) -> Self {\r\n self.inv()\r\n }\r\n }\r\n\r\n pub trait Modulus: 'static + Copy + Eq {\r\n const VALUE: u32;\r\n const HINT_VALUE_IS_PRIME: bool;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>>;\r\n }\r\n\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum Mod1000000007 {}\r\n\r\n impl Modulus for Mod1000000007 {\r\n const VALUE: u32 = 1_000_000_007;\r\n const HINT_VALUE_IS_PRIME: bool = true;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>> {\r\n thread_local! {\r\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\r\n }\r\n &BUTTERFLY_CACHE\r\n }\r\n }\r\n\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum Mod998244353 {}\r\n\r\n impl Modulus for Mod998244353 {\r\n const VALUE: u32 = 998_244_353;\r\n const HINT_VALUE_IS_PRIME: bool = true;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>> {\r\n thread_local! {\r\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\r\n }\r\n &BUTTERFLY_CACHE\r\n }\r\n }\r\n\r\n pub struct ButterflyCache {\r\n pub(crate) sum_e: Vec>,\r\n pub(crate) sum_ie: Vec>,\r\n }\r\n\r\n #[derive(Copy, Clone, Eq, PartialEq)]\r\n #[repr(transparent)]\r\n pub struct DynamicModInt {\r\n val: u32,\r\n phantom: PhantomData I>,\r\n }\r\n\r\n impl DynamicModInt {\r\n #[inline]\r\n pub fn modulus() -> u32 {\r\n I::companion_barrett().umod()\r\n }\r\n\r\n #[inline]\r\n pub fn set_modulus(modulus: u32) {\r\n if modulus == 0 {\r\n panic!(\"the modulus must not be 0\");\r\n }\r\n I::companion_barrett().update(modulus);\r\n }\r\n\r\n #[inline]\r\n pub fn new(val: T) -> Self {\r\n ::new(val)\r\n }\r\n\r\n #[inline]\r\n pub fn raw(val: u32) -> Self {\r\n Self {\r\n val,\r\n phantom: PhantomData,\r\n }\r\n }\r\n\r\n #[inline]\r\n pub fn val(self) -> u32 {\r\n self.val\r\n }\r\n\r\n #[inline]\r\n pub fn pow(self, n: u64) -> Self {\r\n ::pow(self, n)\r\n }\r\n\r\n #[inline]\r\n pub fn inv(self) -> Self {\r\n Self::inv_for_non_prime_modulus(self)\r\n }\r\n }\r\n\r\n impl ModIntBase for DynamicModInt {\r\n #[inline]\r\n fn modulus() -> u32 {\r\n Self::modulus()\r\n }\r\n\r\n #[inline]\r\n fn raw(val: u32) -> Self {\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn val(self) -> u32 {\r\n self.val()\r\n }\r\n\r\n #[inline]\r\n fn inv(self) -> Self {\r\n self.inv()\r\n }\r\n }\r\n\r\n pub trait Id: 'static + Copy + Eq {\r\n fn companion_barrett() -> &'static Barrett;\r\n }\r\n\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum DefaultId {}\r\n\r\n impl Id for DefaultId {\r\n fn companion_barrett() -> &'static Barrett {\r\n static BARRETT: Barrett = Barrett::default();\r\n &BARRETT\r\n }\r\n }\r\n\r\n pub struct Barrett {\r\n m: AtomicU32,\r\n im: AtomicU64,\r\n }\r\n\r\n impl Barrett {\r\n #[inline]\r\n pub const fn new(m: u32) -> Self {\r\n Self {\r\n m: AtomicU32::new(m),\r\n im: AtomicU64::new((-1i64 as u64 / m as u64).wrapping_add(1)),\r\n }\r\n }\r\n\r\n #[inline]\r\n const fn default() -> Self {\r\n Self::new(998_244_353)\r\n }\r\n\r\n #[inline]\r\n fn update(&self, m: u32) {\r\n let im = (-1i64 as u64 / m as u64).wrapping_add(1);\r\n self.m.store(m, atomic::Ordering::SeqCst);\r\n self.im.store(im, atomic::Ordering::SeqCst);\r\n }\r\n\r\n #[inline]\r\n fn umod(&self) -> u32 {\r\n self.m.load(atomic::Ordering::SeqCst)\r\n }\r\n\r\n #[inline]\r\n fn mul(&self, a: u32, b: u32) -> u32 {\r\n let m = self.m.load(atomic::Ordering::SeqCst);\r\n let im = self.im.load(atomic::Ordering::SeqCst);\r\n internal_math::mul_mod(a, b, m, im)\r\n }\r\n }\r\n\r\n impl Default for Barrett {\r\n #[inline]\r\n fn default() -> Self {\r\n Self::default()\r\n }\r\n }\r\n\r\n pub trait ModIntBase:\r\n Default\r\n + FromStr\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + Copy\r\n + Eq\r\n + Hash\r\n + fmt::Display\r\n + fmt::Debug\r\n + Neg\r\n + Add\r\n + Sub\r\n + Mul\r\n + Div\r\n + AddAssign\r\n + SubAssign\r\n + MulAssign\r\n + DivAssign\r\n {\r\n fn modulus() -> u32;\r\n\r\n fn raw(val: u32) -> Self;\r\n\r\n fn val(self) -> u32;\r\n\r\n fn inv(self) -> Self;\r\n\r\n #[inline]\r\n fn new(val: T) -> Self {\r\n Self::raw(val.rem_euclid_u32(Self::modulus()))\r\n }\r\n\r\n #[inline]\r\n fn pow(self, mut n: u64) -> Self {\r\n let mut x = self;\r\n let mut r = Self::raw(1);\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n r *= x;\r\n }\r\n x *= x;\r\n n >>= 1;\r\n }\r\n r\r\n }\r\n }\r\n\r\n pub trait RemEuclidU32 {\r\n fn rem_euclid_u32(self, modulus: u32) -> u32;\r\n }\r\n\r\n macro_rules! impl_rem_euclid_u32_for_small_signed {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n (self as i64).rem_euclid(i64::from(modulus)) as _\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n impl_rem_euclid_u32_for_small_signed!(i8, i16, i32, i64, isize);\r\n\r\n impl RemEuclidU32 for i128 {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n self.rem_euclid(i128::from(modulus)) as _\r\n }\r\n }\r\n\r\n macro_rules! impl_rem_euclid_u32_for_small_unsigned {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n self as u32 % modulus\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n macro_rules! impl_rem_euclid_u32_for_large_unsigned {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n (self % (modulus as $ty)) as _\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n impl_rem_euclid_u32_for_small_unsigned!(u8, u16, u32);\r\n impl_rem_euclid_u32_for_large_unsigned!(u64, u128);\r\n\r\n #[cfg(target_pointer_width = \"32\")]\r\n impl_rem_euclid_u32_for_small_unsigned!(usize);\r\n\r\n #[cfg(target_pointer_width = \"64\")]\r\n impl_rem_euclid_u32_for_large_unsigned!(usize);\r\n\r\n trait InternalImplementations: ModIntBase {\r\n #[inline]\r\n fn inv_for_non_prime_modulus(this: Self) -> Self {\r\n let (gcd, x) = internal_math::inv_gcd(this.val().into(), Self::modulus().into());\r\n if gcd != 1 {\r\n panic!(\"the multiplicative inverse does not exist\");\r\n }\r\n Self::new(x)\r\n }\r\n\r\n #[inline]\r\n fn default_impl() -> Self {\r\n Self::raw(0)\r\n }\r\n\r\n #[inline]\r\n fn from_str_impl(s: &str) -> Result {\r\n Ok(s.parse::()\r\n .map(Self::new)\r\n .unwrap_or_else(|_| todo!(\"parsing as an arbitrary precision integer?\")))\r\n }\r\n\r\n #[inline]\r\n fn hash_impl(this: &Self, state: &mut impl Hasher) {\r\n this.val().hash(state)\r\n }\r\n\r\n #[inline]\r\n fn display_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\r\n fmt::Display::fmt(&this.val(), f)\r\n }\r\n\r\n #[inline]\r\n fn debug_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\r\n fmt::Debug::fmt(&this.val(), f)\r\n }\r\n\r\n #[inline]\r\n fn neg_impl(this: Self) -> Self {\r\n Self::sub_impl(Self::raw(0), this)\r\n }\r\n\r\n #[inline]\r\n fn add_impl(lhs: Self, rhs: Self) -> Self {\r\n let modulus = Self::modulus();\r\n let mut val = lhs.val() + rhs.val();\r\n if val >= modulus {\r\n val -= modulus;\r\n }\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn sub_impl(lhs: Self, rhs: Self) -> Self {\r\n let modulus = Self::modulus();\r\n let mut val = lhs.val().wrapping_sub(rhs.val());\r\n if val >= modulus {\r\n val = val.wrapping_add(modulus)\r\n }\r\n Self::raw(val)\r\n }\r\n\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self;\r\n\r\n #[inline]\r\n fn div_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::mul_impl(lhs, rhs.inv())\r\n }\r\n }\r\n\r\n impl InternalImplementations for StaticModInt {\r\n #[inline]\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::raw((u64::from(lhs.val()) * u64::from(rhs.val()) % u64::from(M::VALUE)) as u32)\r\n }\r\n }\r\n\r\n impl InternalImplementations for DynamicModInt {\r\n #[inline]\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::raw(I::companion_barrett().mul(lhs.val, rhs.val))\r\n }\r\n }\r\n\r\n macro_rules! impl_basic_traits {\r\n () => {};\r\n (impl <$generic_param:ident : $generic_param_bound:tt> _ for $self:ty; $($rest:tt)*) => {\r\n impl <$generic_param: $generic_param_bound> Default for $self {\r\n #[inline]\r\n fn default() -> Self {\r\n Self::default_impl()\r\n }\r\n }\r\n\r\n impl <$generic_param: $generic_param_bound> FromStr for $self {\r\n type Err = Infallible;\r\n\r\n #[inline]\r\n fn from_str(s: &str) -> Result {\r\n Self::from_str_impl(s)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound, V: RemEuclidU32> From for $self {\r\n #[inline]\r\n fn from(from: V) -> Self {\r\n Self::new(from)\r\n }\r\n }\r\n\r\n #[allow(clippy::derive_hash_xor_eq)]\r\n impl<$generic_param: $generic_param_bound> Hash for $self {\r\n #[inline]\r\n fn hash(&self, state: &mut H) {\r\n Self::hash_impl(self, state)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> fmt::Display for $self {\r\n #[inline]\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n Self::display_impl(self, f)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> fmt::Debug for $self {\r\n #[inline]\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n Self::debug_impl(self, f)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> Neg for $self {\r\n type Output = $self;\r\n\r\n #[inline]\r\n fn neg(self) -> $self {\r\n Self::neg_impl(self)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> Neg for &'_ $self {\r\n type Output = $self;\r\n\r\n #[inline]\r\n fn neg(self) -> $self {\r\n <$self>::neg_impl(*self)\r\n }\r\n }\r\n\r\n impl_basic_traits!($($rest)*);\r\n };\r\n}\r\n\r\n impl_basic_traits! {\r\n impl _ for StaticModInt ;\r\n impl _ for DynamicModInt;\r\n }\r\n\r\n macro_rules! impl_bin_ops {\r\n () => {};\r\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~ <$rhs_ty:ty> -> $output:ty { { $lhs_body:expr } ~ { $rhs_body:expr } } $($rest:tt)*) => {\r\n impl <$($generic_param: $generic_param_bound),*> Add<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn add(self, rhs: $rhs_ty) -> $output {\r\n <$output>::add_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Sub<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn sub(self, rhs: $rhs_ty) -> $output {\r\n <$output>::sub_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Mul<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn mul(self, rhs: $rhs_ty) -> $output {\r\n <$output>::mul_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Div<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn div(self, rhs: $rhs_ty) -> $output {\r\n <$output>::div_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl_bin_ops!($($rest)*);\r\n };\r\n}\r\n\r\n macro_rules! impl_assign_ops {\r\n () => {};\r\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~= <$rhs_ty:ty> { _ ~= { $rhs_body:expr } } $($rest:tt)*) => {\r\n impl <$($generic_param: $generic_param_bound),*> AddAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn add_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self + apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> SubAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn sub_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self - apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> MulAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn mul_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self * apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> DivAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn div_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self / apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl_assign_ops!($($rest)*);\r\n };\r\n}\r\n\r\n #[inline]\r\n fn apply O, X, O>(f: F, x: X) -> O {\r\n f(x)\r\n }\r\n\r\n impl_bin_ops! {\r\n for > ~ > -> StaticModInt { { |x| x } ~ { |x| x } }\r\n for > ~ <&'_ StaticModInt > -> StaticModInt { { |x| x } ~ { |&x| x } }\r\n for <&'_ StaticModInt > ~ > -> StaticModInt { { |&x| x } ~ { |x| x } }\r\n for <&'_ StaticModInt > ~ <&'_ StaticModInt > -> StaticModInt { { |&x| x } ~ { |&x| x } }\r\n for > ~ > -> DynamicModInt { { |x| x } ~ { |x| x } }\r\n for > ~ <&'_ DynamicModInt> -> DynamicModInt { { |x| x } ~ { |&x| x } }\r\n for <&'_ DynamicModInt> ~ > -> DynamicModInt { { |&x| x } ~ { |x| x } }\r\n for <&'_ DynamicModInt> ~ <&'_ DynamicModInt> -> DynamicModInt { { |&x| x } ~ { |&x| x } }\r\n\r\n for > ~ -> StaticModInt { { |x| x } ~ { StaticModInt::::new } }\r\n for > ~ -> DynamicModInt { { |x| x } ~ { DynamicModInt::::new } }\r\n }\r\n\r\n impl_assign_ops! {\r\n for > ~= > { _ ~= { |x| x } }\r\n for > ~= <&'_ StaticModInt > { _ ~= { |&x| x } }\r\n for > ~= > { _ ~= { |x| x } }\r\n for > ~= <&'_ DynamicModInt> { _ ~= { |&x| x } }\r\n\r\n for > ~= { _ ~= { StaticModInt::::new } }\r\n for > ~= { _ ~= { DynamicModInt::::new } }\r\n }\r\n\r\n macro_rules! impl_folding {\r\n () => {};\r\n (impl<$generic_param:ident : $generic_param_bound:tt> $trait:ident<_> for $self:ty { fn $method:ident(_) -> _ { _($unit:expr, $op:expr) } } $($rest:tt)*) => {\r\n impl<$generic_param: $generic_param_bound> $trait for $self {\r\n #[inline]\r\n fn $method(iter: S) -> Self\r\n where\r\n S: Iterator,\r\n {\r\n iter.fold($unit, $op)\r\n }\r\n }\r\n\r\n impl<'a, $generic_param: $generic_param_bound> $trait<&'a Self> for $self {\r\n #[inline]\r\n fn $method(iter: S) -> Self\r\n where\r\n S: Iterator,\r\n {\r\n iter.fold($unit, $op)\r\n }\r\n }\r\n\r\n impl_folding!($($rest)*);\r\n };\r\n}\r\n\r\n impl_folding! {\r\n impl Sum<_> for StaticModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\r\n impl Product<_> for StaticModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\r\n impl Sum<_> for DynamicModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\r\n impl Product<_> for DynamicModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\r\n }\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "4655ad102d6668969c2cd83a513e9fa6", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0} {"lang": "Rust", "source_code": "fn main() {\n let mut n_str = String::new();\n let mut numbers_str = String::new();\n std::io::stdin().read_line(&mut n_str);\n std::io::stdin().read_line(&mut numbers_str);\n\n let numbers_str = numbers_str.trim();\n\n let n: i32 = n_str.trim_end().parse().unwrap();\n\n let mut result = n / 11;\n\n let mut has_8_count = 0;\n\n for (_, c) in numbers_str.chars().enumerate(){\n if c == '8'{\n has_8_count += 1;\n }\n }\n\n if has_8_count < result {\n result = has_8_count;\n }\n\n println!(\"{}\", result);\n\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "5fcead7a37e641eff32db79dba838e8f", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn readln() -> Vec {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect()\n}\n\nconst NAMES: [&str; 5] = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n\nfn main() {\n let input = readln();\n let mut n = input[0] - 1;\n\n let mut cnt = 1;\n let mut total_len = 0;\n while total_len + cnt * 5 <= n {\n total_len += cnt * 5;\n cnt *= 2;\n }\n\n n -= total_len;\n n /= cnt;\n\n println!(\"{}\", NAMES[n as usize]);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "449ace68f57e656d8e83372abfc6c231", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Rust", "source_code": "fn readln() -> Vec {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect()\n}\nfn main() {\n let input = readln();\n let mut n = input[0] - 1;\n\n static NAMES: [&str; 5] = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n\n let mut cnt = 1;\n let mut total_len = 0;\n while total_len + cnt * 5 <= n {\n total_len += cnt * 5;\n cnt *= 2;\n }\n\n n -= total_len;\n n /= cnt;\n\n println!(\"{}\", NAMES[n as usize]);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "891a4621cffda2eafa38918e11819634", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Rust", "source_code": "fn readln() -> Vec {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect()\n}\nfn main() {\n let input = readln();\n let mut n = input[0] - 1;\n\n const NAMES: [&str; 5] = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n\n let mut cnt = 1;\n let mut total_len = 0;\n while total_len + cnt * 5 <= n {\n total_len += cnt * 5;\n cnt *= 2;\n }\n\n n -= total_len;\n n /= cnt;\n\n println!(\"{}\", NAMES[n as usize]);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "828e4de7fe4f6aead9139189b901d4a5", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead, Write};\nuse std::num::Wrapping;\nuse std::collections::{HashMap, HashSet};\n\nconst H1: Wrapping = Wrapping(327832409582091329);\nconst H2: Wrapping = Wrapping(234957239841289312);\n\n#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]\nstruct Variable([u8; 4]);\nconst RES_VAR: Variable = Variable([b'r', b'e', b's', 0]);\n\nimpl Variable {\n fn hash(&self) -> Wrapping {\n let mut hash = H1;\n for v in self.0.iter() {\n hash = (hash + Wrapping(*v as u64)) * H2;\n }\n hash\n }\n}\n\nfn is_char(s: u8) -> bool {\n match s {\n b'a' ... b'z' => true,\n b'A' ... b'Z' => true,\n b'0' ... b'9' => true,\n _ => false,\n }\n}\n\nfn read_var(s: &[u8]) -> (Variable, &[u8]) {\n let mut var = Variable([0; 4]);\n let mut i = 0;\n while i < s.len() && is_char(s[i]) {\n var.0[i] = s[i];\n i += 1;\n }\n (var, &s[i..])\n}\n\n#[derive(Clone, Copy)]\nenum Data {\n Input(Variable),\n Op(Wrapping, u8, Wrapping),\n}\n\nimpl Data {\n fn hash(&self) -> Wrapping {\n match self {\n Data::Input(v) => v.hash(),\n Data::Op(a, op, b) => {\n let op = Wrapping(*op as u64);\n (a * H2 + H1 + op) * H2 + b\n },\n }\n }\n}\n\nenum Command {\n Assign(Variable, Variable),\n Op(Variable, Variable, u8, Variable),\n}\n\nimpl Command {\n fn parse(s: &[u8]) -> Command {\n let (lvar, s) = read_var(&s);\n let (var1, s) = read_var(&s[1..]);\n if s.len() == 0 || !is_op(s[0]) {\n Command::Assign(lvar, var1)\n } else {\n let op = s[0];\n let (var2, _) = read_var(&s[1..]);\n Command::Op(lvar, var1, op, var2)\n }\n }\n\n fn print(&self) -> io::Result<()> {\n let stdout = io::stdout();\n let mut stdout = stdout.lock();\n match self {\n Command::Assign(lvar, var1) => {\n stdout.write_all(&lvar.0)?;\n stdout.write_all(b\"=\")?;\n stdout.write_all(&var1.0)?;\n stdout.write_all(b\"\\n\")?;\n Ok(())\n },\n Command::Op(lvar, var1, op, var2) => {\n stdout.write_all(&lvar.0)?;\n stdout.write_all(b\"=\")?;\n stdout.write_all(&var1.0)?;\n stdout.write_all(&[*op])?;\n stdout.write_all(&var2.0)?;\n stdout.write_all(b\"\\n\")?;\n Ok(())\n },\n }\n }\n}\n\nfn is_op(s: u8) -> bool {\n match s {\n b'$' | b'^' | b'#' | b'&' => true,\n _ => false,\n }\n}\n\nstruct VariableContext {\n vars: HashMap>,\n data: HashMap, Data>,\n input_vars: HashSet,\n}\n\nimpl VariableContext {\n fn new() -> Self {\n Self {\n vars: HashMap::new(),\n data: HashMap::new(),\n input_vars: HashSet::new(),\n }\n }\n\n fn hash_data(&mut self, data: Data) -> Wrapping {\n let hash = data.hash();\n self.data.entry(hash).or_insert(data);\n hash\n }\n\n fn get_var(&mut self, var: Variable) -> Wrapping {\n match self.vars.get(&var) {\n None => {\n self.input_vars.insert(var);\n self.hash_data(Data::Input(var))\n },\n Some(data) => *data,\n }\n }\n\n fn set_var(&mut self, var: Variable, data: Wrapping) {\n self.vars.insert(var, data);\n }\n}\n\nstruct OutputContext {\n used_vars: HashSet,\n data: HashMap, Data>,\n names: HashMap, Variable>,\n cur_name: i64,\n out: Vec,\n}\n\nimpl OutputContext {\n fn new(ctx: VariableContext) -> Self {\n let VariableContext { vars: _, data, input_vars: used_vars } = ctx;\n Self {\n used_vars: used_vars,\n data: data,\n names: HashMap::new(),\n cur_name: 0,\n out: Vec::new(),\n }\n }\n\n fn new_name(&mut self) -> Variable {\n loop {\n let mut v = Variable([0; 4]);\n let mut cur = self.cur_name;\n self.cur_name += 1;\n for i in 0..4 {\n v.0[i] = (cur % 26) as u8 + b'a';\n cur /= 26;\n }\n if !self.used_vars.contains(&v) {\n return v;\n }\n }\n }\n\n fn make_var(&mut self, data: Wrapping) -> Variable {\n match self.names.get(&data) {\n Some(v) => *v,\n None => {\n let x = *(self.data.get(&data).unwrap());\n match x {\n Data::Input(v) => v,\n Data::Op(a, op, b) => {\n let var = self.new_name();\n let var1 = self.make_var(a);\n let var2 = self.make_var(b);\n self.out.push(Command::Op(var, var1, op, var2));\n self.names.insert(data, var);\n var\n }\n }\n },\n }\n }\n\n fn output_result(&mut self, res: Wrapping) {\n let data = *(self.data.get(&res).unwrap());\n match data {\n Data::Input(v) => {\n if v != RES_VAR {\n self.out.push(Command::Assign(RES_VAR, v));\n }\n },\n Data::Op(a, op, b) => {\n let var1 = self.make_var(a);\n let var2 = self.make_var(b);\n self.out.push(Command::Op(RES_VAR, var1, op, var2));\n }\n }\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut lines = stdin.lock().lines();\n let n = lines.next().unwrap().unwrap().trim().parse::().unwrap();\n let mut context = VariableContext::new();\n for line in lines.take(n) {\n let cmd = Command::parse(line.unwrap().as_bytes());\n match cmd {\n Command::Assign(lvar, rvar) => {\n let data = context.get_var(rvar);\n context.set_var(lvar, data);\n },\n Command::Op(lvar, a, op, b) => {\n let x = context.get_var(a);\n let y = context.get_var(b);\n let h = context.hash_data(Data::Op(x, op, y));\n context.set_var(lvar ,h);\n },\n }\n }\n let res = context.get_var(RES_VAR);\n let mut context = OutputContext::new(context);\n context.output_result(res);\n println!(\"{}\", context.out.len());\n for entry in context.out.into_iter() {\n entry.print().unwrap();\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "54a09b99033afc1f85f709b4bc92343e", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "Rust", "source_code": "use std::io::{self, Read};\n\nfn main() -> () {\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n handle.read_to_string(&mut buffer).expect(\"stdin\");\n\n let arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n\n let mut n = arr.iter().nth(0).unwrap();\n\n let mut curr = 1;\n let mut total = 0;\n let mut count = 0;\n \n while total < n {\n count += 1;\n total += curr;\n curr = curr * 2;\n }\n\n println!(\"{}\", count );\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "e512601cfe0a121e01d94e55eb0bc4f4", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "Rust", "source_code": "fn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get { () => (get().parse().unwrap()) }\n \n \n let f0 = b\"What are you doing at the end of the world? Are you busy? Will you save us?\";\n let f1a = b\"What are you doing while sending \\\"\";\n let f1b = b\"\\\"? Are you busy? Will you send \\\"\";\n let f1c = b\"\\\"?\";\n \n let mut w = vec![0_u64; 100001];\n \n w[0] = f0.len() as u64;\n for i in 1..w.len() {\n w[i] = w[i-1] * 2 + (f1a.len() + f1b.len() + f1c.len()) as u64;\n }\n \n let q = get!();\n let mut v = vec![];\n for _ in 0..q {\n let mut n: usize = get!();\n let mut k: u64 = get!();\n k -= 1;\n loop {\n if k > w[n] {\n v.push(b'.');\n break;\n } else if n == 0 {\n v.push(f0[k as usize]);\n break;\n } else {\n n -= 1;\n if k < f1a.len() as u64 {\n v.push(f1a[k as usize]);\n break;\n }\n k -= f1a.len() as u64;\n if k < w[n] {\n continue;\n }\n k -= w[n];\n if k < f1b.len() as u64 {\n v.push(f1b[k as usize]);\n break;\n }\n k -= f1b.len() as u64;\n if k < w[n] {\n continue;\n }\n k -= w[n];\n if k < f1c.len() as u64 {\n v.push(f1c[k as usize]);\n break;\n }\n v.push(b'.');\n break;\n }\n }\n }\n println!(\"{}\", String::from_utf8(v).unwrap());\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "0229af252129164f3ac9563792b007df", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n#[allow(unused_imports)]\nuse std::io::stdin;\n\nmod util {\n use std::io::stdin;\n use std::str::FromStr;\n use std::fmt::Debug;\n\n #[allow(dead_code)]\n pub fn line() -> String {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().to_string()\n }\n\n #[allow(dead_code)]\n pub fn gets() -> Vec\n where\n ::Err: Debug,\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse().unwrap())\n .collect()\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\nfn f(i: usize, k: u64, ll: &Vec) -> char {\n let mut i = i;\n let mut k = k;\n\n loop {\n if i == 0 {\n let f0 = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\n return if f0.len() as u64 > k {\n f0.chars().nth(k as usize).unwrap()\n } else {\n '.'\n };\n } else {\n if k < 34 {\n let s1 = \"What are you doing while sending \\\"\";\n return s1.chars().nth(k as usize).unwrap();\n } else if k < 34 + ll[i - 1] {\n // f(i - 1, k - 34, ll)\n i -= 1;\n k -= 34;\n } else if k < 34 + ll[i - 1] + 32 {\n let s2 = \"\\\"? Are you busy? Will you send \\\"\";\n return s2.chars().nth((k - 34 - ll[i - 1]) as usize).unwrap();\n } else if k < 34 + ll[i - 1] + 32 + ll[i - 1] {\n // f(i - 1, k - 34 - ll[i - 1] - 32, ll)\n k -= 34 + ll[i - 1] + 32;\n i -= 1;\n } else if k < 34 + ll[i - 1] + 32 + ll[i - 1] + 2 {\n let s3 = \"\\\"?\";\n return s3.chars()\n .nth((k - 34 - ll[i - 1] - 32 - ll[i - 1]) as usize)\n .unwrap();\n } else {\n return '.';\n }\n }\n }\n\n}\n\nfn main() {\n let k_max: u64 = 1000000000000000000;\n\n let mut ll = Vec::new();\n ll.push(75u64);\n let mut n = 0;\n for i in 1..100001 {\n n = ll[i - 1] * 2 + 68;\n ll.push(n);\n if n > k_max {\n break;\n }\n }\n while ll.len() < 100001 {\n ll.push(n);\n }\n\n let mut ans = Vec::new();\n\n let n = get!(usize);\n\n for _ in 0..n {\n let (n, k) = get!(usize, u64);\n ans.push(f(n, k - 1, &ll));\n }\n\n println!(\"{}\", ans.into_iter().collect::());\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f33e05f367262c23bee89df4a2258679", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "Rust", "source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn solve() {\n let (a, b) = parse_line!(u64, u64);\n let mut pos = 0;\n let mut count = 0;\n while pos != a * b {\n let closest_a = (pos / a + 1) * a;\n let closest_b = (pos / b + 1) * b;\n if closest_a < closest_b {\n count += closest_a - pos;\n pos = closest_a;\n }else if closest_b < closest_a {\n pos = closest_b;\n }else if closest_a == closest_b {\n if a > b {\n count += closest_a - pos;\n }\n pos = closest_a;\n }\n }\n if count * 2 == a * b {\n println!(\"Equal\");\n }else if count * 2 > a * b {\n println!(\"Dasha\");\n }else{\n println!(\"Masha\");\n }\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "340657a94749ad2b08e1051b5109aad7", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Write, BufWriter};\n// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n let mut next = || { iter.next().unwrap() };\n input_inner!{next, $($r)*}\n };\n ($($r:tt)*) => {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input_inner!{next, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input_inner!{$next $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\nfn solve() {\n let out = std::io::stdout();\n let mut out = BufWriter::new(out.lock());\n macro_rules! puts {\n ($format:expr) => (write!(out,$format).unwrap());\n ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())\n }\n input! {\n n: usize,\n p: i64,\n s: [chars; n],\n }\n let mut a = 0;\n let mut tot = 0;\n for i in (0 .. n).rev() {\n if s[i] == \"halfplus\".chars().collect::>() {\n a = 2 * a + 1;\n tot += a;\n } else {\n a *= 2;\n tot += a;\n }\n }\n puts!(\"{}\\n\", tot * (p / 2));\n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e758d05421114fc5beb2eb7d26a0e538", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\n#![allow(non_snake_case)]\n\nuse std::cmp::{max, min, Ordering};\nuse std::collections::*;\nuse std::fmt::{Debug, Formatter};\nuse std::io::*;\nuse std::ops::*;\nuse std::*;\n\n// -----------------------------------------------\n// Framework\n// -----------------------------------------------\n\n#[allow(unused_macros)]\nmacro_rules! read {\n ([$t:ty] ; $n:expr) =>\n ((0..$n).map(|_| read!([$t])).collect::>());\n ($($t:ty),+ ; $n:expr) =>\n ((0..$n).map(|_| read!($($t),+)).collect::>());\n ([$t:ty]) =>\n (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>());\n ($t:ty) =>\n (rl().parse::<$t>().unwrap());\n ($($t:ty),*) => {{\n let buf = rl();\n let mut w = buf.split_whitespace();\n ($(w.next().unwrap().parse::<$t>().unwrap()),*)\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($arg:expr),*) => {\n #[cfg(debug_assertions)]\n {\n let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];\n stderr().write_fmt(format_args!(\"{:#?}\\n\", entries)).unwrap();\n }\n };\n}\n\n#[allow(dead_code)]\nfn rl() -> String {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim_right().to_owned()\n}\n\ntrait IteratorExt: Iterator + Sized {\n fn vec(self) -> Vec {\n self.collect()\n }\n}\n\nimpl IteratorExt for T {}\n\n// -----------------------------------------------\n// Solution\n// -----------------------------------------------\n\nfn is_vowel(c: char) -> bool {\n match c {\n 'a' | 'i' | 'u' | 'e' | 'o' => true,\n _ => false,\n }\n}\n\npub fn main() {\n let S = rl().chars().vec();\n\n let mut ok = true;\n for i in 0..S.len() {\n if S[i] == 'n' || is_vowel(S[i]) || (i + 1 < S.len() && is_vowel(S[i + 1])) {\n continue;\n }\n\n ok = false;\n break;\n }\n\n println!(\"{}\", if ok { \"YES\" } else { \"NO\" });\n return;\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f93104fbe841ecbd59393b66f4a2ae2a", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin()\n .read_line(& mut s)\n .expect(\"Deu Ruim\");\n \n let s = s.trim();\n let n = s.len();\n\n let mut res = true;\n\n for i in 0..n-1 {\n\n match (&s[i..i+1], &s[i+1..i+2]) {\n\n (\"a\",_)|(\"e\",_)|(\"i\",_)|(\"o\",_)|(\"u\", _) => (),\n (\"n\", _) => (),\n (_,\"a\")|(_,\"e\")|(_,\"i\")|(_,\"o\")|(_,\"u\") => (),\n (_, _) => res = false,\n }\n }\n\n match res {\n true => println!(\"YES\", ),\n _ => println!(\"NO\", )\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b8fa87c4b018f8b93ffd115685130cdc", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n p: [(chars, i32, i32); n],\n }\n let p = p\n .into_iter()\n .map(|p| ((p.0[0] == 'B') as usize, p.1, p.2))\n .collect::>();\n let mut sum = vec![([0, 0], 0, 0)];\n for &(x, y, z) in p.iter() {\n for i in 0..sum.len() {\n let (mut a, mut b, mut c) = sum[i];\n a[x] += 1;\n b += y;\n c += z;\n sum.push((a, b, c));\n }\n }\n let inf = std::i32::MAX / 2;\n let mut dp = vec![vec![vec![inf; 1 << n]; n + 1]; n + 1];\n dp[0][0][0] = 0;\n for i in 0..=n {\n for j in 0..=n {\n for k in 0..(1 << n) {\n let v = dp[i][j][k];\n if v == inf {\n continue;\n }\n let rem = [v - sum[k].0[0], v - sum[k].0[1]];\n for (l, p) in p.iter().enumerate() {\n if k >> l & 1 == 1 {\n continue;\n }\n let mut add = 0;\n add = max(add, p.1 - rem[0] - i as i32);\n add = max(add, p.2 - rem[1] - j as i32);\n let bit = k | (1 << l);\n if p.0 == 0 {\n dp[i + 1][j][bit] = std::cmp::min(dp[i + 1][j][bit], v + add);\n } else {\n dp[i][j + 1][bit] = std::cmp::min(dp[i][j + 1][bit], v + add);\n }\n }\n }\n }\n }\n let mut ans = inf;\n for dp in dp {\n for dp in dp {\n ans = std::cmp::min(ans, dp[(1 << n) - 1]);\n }\n }\n ans += n as i32;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e65afe3c12615bf318061f821541c69d", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n p: [(chars, i32, i32); n],\n }\n let p = p\n .into_iter()\n .map(|p| ((p.0[0] == 'B') as usize, p.1, p.2))\n .collect::>();\n let mut sum = vec![([0, 0], 0, 0)];\n for &(x, y, z) in p.iter() {\n for i in 0..sum.len() {\n let (mut a, mut b, mut c) = sum[i];\n a[x] += 1;\n b += y;\n c += z;\n sum.push((a, b, c));\n }\n }\n let inf = std::i32::MAX / 2;\n let mut now = vec![(0, 0, 0, 0)];// bit, R\u306e\u30d2\u30c3\u30c8\u3001B\u306e\u30d2\u30c3\u30c8\u3001\u6700\u5c0f\u5024\n for _ in 0..n {\n let mut next = std::collections::BTreeMap::new();\n for (bit, x, y, v) in now {\n// println!(\"{} {} {} {}\", bit, x, y, v);\n let rem_a = v - sum[bit].1 + x;\n let rem_b = v - sum[bit].2 + y;\n for (i, &(_, a, b)) in p.iter().enumerate() {\n if bit >> i & 1 == 1 {\n continue;\n }\n let mut x = x;\n let mut y = y;\n let mut add = 0;\n let mut p = max(0, a - rem_a);\n if p > 0 {\n x += std::cmp::min(p, sum[bit].0[0]);\n p -= sum[bit].0[0];\n }\n add = max(add, p);\n let mut p = max(0, b - rem_b);\n if p > 0 {\n y += std::cmp::min(p, sum[bit].0[1]);\n p -= sum[bit].0[1];\n }\n add = max(add, p);\n let v = v + add;\n let po = next.entry((bit | (1 << i), x, y)).or_insert(v);\n *po = std::cmp::min(*po, v);\n }\n }\n let mut a = vec![];\n for ((bit, x, y), v) in next {\n a.push((bit, x, y, v));\n }\n now = a;\n }\n let ans = now.into_iter().map(|p| p.3).min().unwrap() + n as i32;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "644931a4b7a740a7dac47c8a3919ed27", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\n// ---------- begin chmin, chmax ----------\ntrait ChangeMinMax {\n fn chmin(&mut self, x: Self) -> bool;\n fn chmax(&mut self, x: Self) -> bool;\n}\n\nimpl ChangeMinMax for T {\n fn chmin(&mut self, x: Self) -> bool {\n if *self > x {\n *self = x;\n true\n } else {\n false\n }\n }\n fn chmax(&mut self, x: Self) -> bool {\n if *self < x {\n *self = x;\n true\n } else {\n false\n }\n }\n}\n// ---------- end chmin, chmax ----------\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n p: [(chars, [i32; 2]); n],\n }\n let mut p = p\n .into_iter()\n .map(|p| ((p.0[0] == 'B') as usize, [p.1[0], p.1[1]]))\n .collect::>();\n let mut need = [0; 2];\n for p in p.iter_mut() {\n let n = n as i32;\n for (need, v) in need.iter_mut().zip(p.1.iter_mut()) {\n *need += max(0, *v - n);\n v.chmin(n);\n }\n }\n let mut sum = vec![[0i32; 2]];\n for &(x, _) in p.iter() {\n for i in 0..sum.len() {\n let mut a = sum[i];\n a[x] += 1;\n sum.push(a);\n }\n }\n let inf = std::i32::MAX / 2;\n let mut dp = vec![vec![vec![inf; 1 << n]; n.pow(2) + 1]; 2];\n let abs = (need[1] - need[0]).abs() as usize;\n dp[(need[0] >= need[1]) as usize][min(n * n, abs)][0] = 0;\n for bit in 0..(1 << n) {\n let sum = sum[bit];\n for rem in 0..=n.pow(2) {\n for i in 0..2 {\n let v = dp[i][rem][bit];\n if v == inf {\n continue;\n }\n for (j, &(_, p)) in p.iter().enumerate() {\n let k = bit | (1 << j);\n if k == bit {\n continue;\n }\n let p = [max(0, p[0] - sum[0]), max(0, p[1] - sum[1])];\n if rem as i32 + p[i ^ 1] >= p[i] {\n let x = rem as i32 + p[i ^ 1] - p[i];\n let v = v + p[i ^ 1];\n dp[i][min(x as usize, n.pow(2))][k].chmin(v);\n } else {\n let x = p[i] - rem as i32 - p[i ^ 1];\n let v = v + p[i] - rem as i32;\n dp[i ^ 1][min(x as usize, n.pow(2))][k].chmin(v);\n }\n }\n }\n }\n }\n let add = need.iter().copied().max().unwrap() + n as i32;\n let ans = add + dp.into_iter().flatten().map(|dp| dp[(1 << n) - 1]).min().unwrap();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "44584898410658d47f19f9610c5c9144", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0} {"lang": "Rust", "source_code": "use std::io::{self, Stdin};\nuse std::str::{self, FromStr};\nuse std::error::Error;\nuse std::cmp::*;\nuse std::thread;\nconst INF: i64 = 1i64 << 60;\nfn exec() {\n let mut sc = Scanner::new();\n let n: usize = sc.ne();\n let mut cards = Vec::new();\n for _ in 0..n {\n let c: String = sc.ne();\n let r: i64 = sc.ne();\n let b: i64 = sc.ne();\n let is_r = c == \"R\";\n cards.push((is_r, r, b));\n }\n let sn = 1 << n;\n let rn = n * (n + 1) / 2;\n let mut dp = vec![vec![-INF; rn]; sn];\n dp[0][0] = 0;\n for s in 0..sn {\n let mut rnum = 0;\n let mut bnum = 0;\n for i in 0..n {\n if (s >> i) & 1 == 0 {\n continue;\n }\n if cards[i].0 {\n rnum += 1;\n } else {\n bnum += 1;\n }\n }\n for i in 0..rn {\n // println!(\"{:b}, i: {}, {}\", s, i, dp[s][i]);\n if dp[s][i] == -INF {\n continue;\n }\n for j in 0..n {\n if (s >> j) & 1 == 1 {\n continue;\n }\n let ns = s | (1 << j);\n let ni = min(rnum, cards[j].1) as usize + i;\n dp[ns][ni] = max(dp[ns][ni], dp[s][i] + min(bnum, cards[j].2));\n }\n }\n }\n let rsum = cards.iter().fold(0, |acc, &t| acc + t.1);\n let bsum = cards.iter().fold(0, |acc, &t| acc + t.2);\n let mut ans = INF;\n for i in 0..rn {\n ans = min(ans, max(rsum - i as i64, bsum - dp[sn - 1][i]));\n // println!(\"{}\", ans);\n }\n println!(\"{}\", ans + n as i64);\n}\n\nconst DEFAULT_STACK: usize = 16 * 1024 * 1024;\nfn main() {\n let builder = thread::Builder::new();\n let th = builder.stack_size(DEFAULT_STACK);\n let handle = th.spawn(|| { exec(); }).unwrap();\n let _ = handle.join();\n}\n\n#[allow(dead_code)]\nstruct Scanner {\n stdin: Stdin,\n id: usize,\n buf: Vec,\n}\n\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n stdin: io::stdin(),\n id: 0,\n buf: Vec::new(),\n }\n }\n fn next_line(&mut self) -> Option {\n let mut res = String::new();\n match self.stdin.read_line(&mut res) {\n Ok(0) => return None,\n Ok(_) => Some(res),\n Err(why) => panic!(\"error in read_line: {}\", why.description()),\n }\n }\n fn next(&mut self) -> Option {\n while self.buf.len() == 0 {\n self.buf = match self.next_line() {\n Some(r) => {\n self.id = 0;\n r.trim().as_bytes().to_owned()\n }\n None => return None,\n };\n }\n let l = self.id;\n assert!(self.buf[l] != b' ');\n let n = self.buf.len();\n let mut r = l;\n while r < n && self.buf[r] != b' ' {\n r += 1;\n }\n let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() {\n Ok(s) => Some(s),\n Err(_) => {\n panic!(\"parse error: {:?}\",\n str::from_utf8(&self.buf[l..r]).unwrap())\n }\n };\n while r < n && self.buf[r] == b' ' {\n r += 1;\n }\n if r == n {\n self.buf.clear();\n } else {\n self.id = r;\n }\n res\n }\n fn ne(&mut self) -> T {\n self.next::().unwrap()\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "fc9f7bbfb75a511594f0bc0d289f1506", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\n// ---------- begin chmin, chmax ----------\ntrait ChangeMinMax {\n fn chmin(&mut self, x: Self) -> bool;\n fn chmax(&mut self, x: Self) -> bool;\n}\n\nimpl ChangeMinMax for T {\n fn chmin(&mut self, x: Self) -> bool {\n if *self > x {\n *self = x;\n true\n } else {\n false\n }\n }\n fn chmax(&mut self, x: Self) -> bool {\n if *self < x {\n *self = x;\n true\n } else {\n false\n }\n }\n}\n// ---------- end chmin, chmax ----------\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n p: [(chars, [i32; 2]); n],\n }\n let mut p = p\n .into_iter()\n .map(|p| ((p.0[0] == 'B') as usize, [p.1[0], p.1[1]]))\n .collect::>();\n let mut need = [0; 2];\n for p in p.iter_mut() {\n let n = n as i32;\n for (need, v) in need.iter_mut().zip(p.1.iter_mut()) {\n *need += max(0, *v - n + 1);\n v.chmin(n - 1);\n }\n }\n let mut sum = vec![[0i32; 2]];\n for &(x, _) in p.iter() {\n for i in 0..sum.len() {\n let mut a = sum[i];\n a[x] += 1;\n sum.push(a);\n }\n }\n let inf = std::i32::MAX / 2;\n let sup = (n - 1) * (n - 1);\n let mut dp = vec![vec![vec![inf; 1 << n]; sup + 1]; 2];\n let abs = (need[1] - need[0]).abs() as usize;\n dp[(need[0] >= need[1]) as usize][min(sup, abs)][0] = 0;\n for bit in 0..(1 << n) {\n let sum = sum[bit];\n for rem in 0..=sup {\n for i in 0..2 {\n let v = dp[i][rem][bit];\n if v == inf {\n continue;\n }\n for (j, &(_, p)) in p.iter().enumerate() {\n let k = bit | (1 << j);\n if k == bit {\n continue;\n }\n let p = [max(0, p[0] - sum[0]), max(0, p[1] - sum[1])];\n if rem as i32 + p[i ^ 1] >= p[i] {\n let x = rem as i32 + p[i ^ 1] - p[i];\n let v = v + p[i ^ 1];\n dp[i][min(x as usize, sup)][k].chmin(v);\n } else {\n let x = p[i] - rem as i32 - p[i ^ 1];\n let v = v + p[i] - rem as i32;\n dp[i ^ 1][min(x as usize, sup)][k].chmin(v);\n }\n }\n }\n }\n }\n let add = need.iter().copied().max().unwrap() + n as i32;\n let ans = add + dp.into_iter().flatten().map(|dp| dp[(1 << n) - 1]).min().unwrap();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "d93a7e39bd0c92ed443523daa1223eb8", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\nuse std::io::{BufReader, BufWriter, stdin, stdout, Write};\nuse std::cmp::{min, max};\nuse std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap};\n\nconst m:i64 = 1000000007;\n\nfn main() {\n\tlet mut inp = Iinput::default();\n\tlet out = &mut BufWriter::new(stdout());\n\tlet n:usize = inp.scan::();\n\tlet k:i64 = inp.scan::();\n\tlet mut nCr = vec![vec![0 as i64; n + 1]; n + 1];\n\tnCr[0][0] = 1;\n\tfor i in 1..n+1 {\n\t\tfor j in 0..i+1 {\n\t\t\tif j > 0 {\n\t\t\t\tnCr[i][j] += nCr[i - 1][j - 1];\n\t\t\t}\n\t\t\tif j < i {\n\t\t\t\tnCr[i][j] += nCr[i - 1][j];\n\t\t\t}\n\t\t\tnCr[i][j] %= m;\n\t\t}\n\t}\n\tlet mut dp = vec![0; n + 1];\n\tdp[0] = 1;\n\tlet mut pow2 = vec![1 as i64; n + 1];\n\tfor i in 1..n+1 {\n\t\tpow2[i] = pow2[i - 1] * (k - 1) % m;\n\t}\n\tfor _row in 0..n {\n\t\tlet mut tp = vec![0; n + 1];\n\t\tlet mut powa = 1 as i64;\n\t\tfor i in 0..n+1 {\n\t\t\tfor j in i..n+1 {\n\t\t\t\tlet mut val = pow2[n - j] * powa % m;\n\t\t\t\tif i == j {\n\t\t\t\t\tval += m - pow2[n];\n\t\t\t\t}\n\t\t\t\tval = val * nCr[n - i][n - j] % m;\n\t\t\t\ttp[j] = (tp[j] + val * dp[i]) % m;\n\t\t\t}\n\t\t\tpowa = powa * k % m;\n\t\t}\n\t\tdp = tp;\n\t}\n\twriteln!(out, \"{}\", dp[n]);\n}\n\n#[derive(Default)]\nstruct Iinput {\n\tbuffer: Vec\n}\n\nimpl Iinput {\n\tfn scan(&mut self) -> T {\n\t\tloop {\n\t\t\tif let Some(token) = self.buffer.pop() {\n\t\t\t\treturn token.parse().ok().expect(\"Parsing Error\");\n\t\t\t}\n\t\t\tlet mut s = String::new();\n\t\t\tstdin().read_line(&mut s).expect(\"Reading Error\");\n\t\t\tself.buffer = s.split_whitespace().rev().map(String::from).collect();\n\t\t}\n\t}\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c9e79c7385556a7218f199f48868898f", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 1_000_000_007;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\n/* \nimpl std::fmt::Display for ModInt {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n*/\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n self.pow(MOD - 2)\n }\n pub fn comb(n: u32, k: u32) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n let k = std::cmp::min(k, n - k);\n let mut nu = ModInt::one();\n let mut de = ModInt::one();\n for i in 0..k {\n nu *= ModInt(n - i);\n de *= ModInt(i + 1);\n }\n nu * de.inv()\n }\n}\n\n#[allow(dead_code)]\nstruct Precalc {\n inv: Vec,\n fact: Vec,\n ifact: Vec,\n}\n\n#[allow(dead_code)]\nimpl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);\n fact[i] = fact[i - 1] * ModInt(i as u32);\n ifact[i] = ifact[i - 1] * inv[i];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n}\n// ---------- end ModInt ----------\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// \u3053\u3053\u307e\u3067\n\nfn run() {\n input! {\n n: usize,\n k: u32,\n }\n let mut ans = ModInt::zero();\n let pc = Precalc::new(n);\n for i in 0..=n {\n for j in 0..=n {\n let v = (n - i) * (n - j);\n let way = ModInt(k).pow(v as u32) * ModInt(k - 1).pow((n * n - v) as u32);\n ans += ModInt(MOD - 1).pow((i + j) as u32) * pc.comb(n, i) * pc.comb(n, j) * way;\n }\n }\n println!(\"{}\", ans.0);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "da6befe89634059b551c9ba322ced052", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "Rust", "source_code": "//! http://codeforces.com/contest/287/problem/A\n\n#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(isize);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\n/// Stores elements in row-major order.\npub struct Matrix {\n pub elements: Vec,\n pub width: usize\n}\n\nimpl Matrix {\n pub fn row_major_index(&self, idx: (usize, usize)) -> usize {\n let (x, y) = idx;\n y * self.width + x\n }\n\n pub fn get(&self, idx: (usize, usize)) -> Option<&T> {\n let index = self.row_major_index(idx);\n if index < self.elements.len() {\n Some(&self.elements[index])\n } else {\n None\n }\n }\n\n pub fn get_mut(&mut self, idx: (usize, usize)) -> Option<&mut T> {\n let index = self.row_major_index(idx);\n if index < self.elements.len() {\n Some(&mut self.elements[index])\n } else {\n None\n }\n }\n}\n\nimpl Matrix where T: Default + Clone {\n pub fn new(width: usize, height: usize) -> Self {\n Matrix {\n elements: vec![T::default(); width * height],\n width: width\n }\n }\n}\n\nimpl Matrix where T: Clone {\n pub fn with_default(width: usize, height: usize, default: T) -> Self {\n Matrix {\n elements: vec![default; width * height],\n width: width\n }\n }\n}\n\nconst __IMPL_INDEX_FOR_MATRIX: () = {\n use std::ops::{Index, IndexMut};\n \n impl Index<(usize, usize)> for Matrix {\n type Output = T;\n fn index(&self, idx: (usize, usize)) -> &Self::Output {\n self.get(idx).unwrap()\n }\n }\n \n impl IndexMut<(usize, usize)> for Matrix {\n fn index_mut(&mut self, idx: (usize, usize)) -> &mut Self::Output {\n self.get_mut(idx).unwrap()\n }\n }\n};\n\n// -----------------------------------------------------------------------------\n\nfn main() {\n let mut square = Matrix::new(4, 4);\n for j in 0..4 {\n scanln!(row: String);\n for (i, &b) in row.as_bytes().iter().enumerate() {\n square[(i, j)] = if b == b'#' { 1u64 } else { 0u64 };\n }\n }\n for i in 0..3 {\n for j in 0..3 {\n let sum = square[(i, j)] + square[(i+1, j)]\n + square[(i, j+1)] + square[(i+1, j+1)];\n match sum {\n 0 | 1 | 3 | 4 => {\n println!(\"YES\");\n return;\n },\n _ => ()\n }\n }\n }\n println!(\"NO\");\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "574670de635a912406e9c747bb2a9f72", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "Rust", "source_code": "fn main() {\n let mut input = String::new();\n use std::io;\n use std::io::prelude::*;\n io::stdin().read_to_string(&mut input).unwrap();\n\n let mut it = input.split_whitespace();\n let n: usize = it.next().unwrap().parse().unwrap();\n\n let a: Vec<_> = it.next().unwrap().chars().take(n).map(|c| {\n match c {\n '0' => false,\n '1' => true,\n _ => panic!(\"\"),\n }\n }).collect();\n\n let ans = !(0..n).any(|i| {\n !a[i] &&\n (i == 0 || !a[i - 1]) &&\n (i == n - 1 || !a[i + 1])\n });\n\n let ans = ans &&\n (0..n - 1).all(|i| {\n !a[i] || !a[i + 1]\n });\n\n if ans {\n println!(\"Yes\");\n } else {\n println!(\"No\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "06265f4d4efb5b23cb798a8bd2a5a468", "src_uid": "c14d255785b1f668d04b0bf6dcadf32d", "difficulty": 1200.0} {"lang": "Rust", "source_code": "const INF: i64 = 1_000_000_000i64;\n\nstruct Graph {\n size: usize,\n edge: Vec<(usize, usize, i64, i64)>,\n}\n\nimpl Graph {\n fn new(size: usize) -> Self {\n Graph {\n size: size,\n edge: vec![],\n }\n }\n fn add_edge(&mut self, src: usize, dst: usize, capa: i64, cost: i64) {\n assert!(src < self.size && dst < self.size && src != dst);\n self.edge.push((src, dst, capa, cost));\n }\n fn solve(&self, src: usize, dst: usize, flow: i64) -> Option {\n if src == dst {\n return Some(0);\n }\n let size = self.size;\n let edge = &self.edge;\n let mut deg = vec![0; size];\n for &(a, b, _, _) in edge.iter() {\n deg[a] += 1;\n deg[b] += 1;\n }\n let mut graph: Vec<_> = deg.into_iter().map(|d| Vec::with_capacity(d)).collect();\n for &(a, b, capa, cost) in edge.iter() {\n let x = graph[a].len();\n let y = graph[b].len();\n graph[a].push((b, capa, cost, y));\n graph[b].push((a, 0, -cost, x));\n }\n let mut ans = 0;\n let mut dp = Vec::with_capacity(size);\n let mut elem = Vec::with_capacity(size);\n let mut que = std::collections::VecDeque::new();\n for _ in 0..flow {\n dp.clear();\n dp.resize(size, (INF, src, 0));// \u30b3\u30b9\u30c8\u3001\u89aa\u3001\u89aa\u304b\u3089\u306e\u756a\u53f7\n dp[src] = (0, src, 0);\n elem.clear();\n elem.resize(size, false);\n elem[src] = true;\n que.push_back(src);\n while let Some(v) = que.pop_front() {\n elem[v] = false;\n let (c, _, _) = dp[v];\n for (i, &(u, capa, cost, _)) in graph[v].iter().enumerate() {\n if capa == 0 {\n continue;\n }\n let c = c + cost;\n if c < dp[u].0 {\n dp[u] = (c, v, i);\n if !elem[u] {\n elem[u] = true;\n que.push_back(u);\n }\n }\n }\n }\n if dp[dst].0 == INF {\n return None;\n }\n ans += dp[dst].0;\n let mut pos = dst;\n while pos != src {\n let (_, parent, k) = dp[pos];\n let inv = graph[parent][k].3;\n graph[parent][k].1 -= 1;\n graph[pos][inv].1 += 1;\n pos = parent;\n }\n }\n Some(ans)\n }\n}\n\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: usize,\n m: usize,\n k: usize,\n c: i64,\n d: i64,\n a: [usize1; k],\n e: [(usize1, usize1); m],\n }\n let w = 101;\n let size = n * w + 2;\n let mut graph = Graph::new(size);\n let src = size - 1;\n let dst = src - 1;\n let pos = |a: usize, b: usize| -> usize {\n assert!(a < 101 && b < n);\n a * n + b\n };\n for a in a {\n graph.add_edge(src, pos(0, a), 1, 0);\n }\n for i in 0..w {\n graph.add_edge(pos(i, 0), dst, 50, c * i as i64);\n }\n for (a, b) in e {\n for i in 1..w {\n for j in 1..=n {\n let x = j as i64;\n graph.add_edge(pos(i - 1, a), pos(i, b), 1, d * (2 * x - 1));\n graph.add_edge(pos(i - 1, b), pos(i, a), 1, d * (2 * x - 1));\n }\n }\n }\n for i in 1..w {\n for j in 0..n {\n graph.add_edge(pos(i - 1, j), pos(i, j), 50, 0);\n }\n }\n let ans = graph.solve(src, dst, k as i64).unwrap();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "3415279b1b5b870e2efca4873534dbb3", "src_uid": "2d0aa75f2e63c4fb8c98742ac8cd821c", "difficulty": 2500.0} {"lang": "Rust", "source_code": "const INF: i64 = 1_000_000_000i64;\n\nstruct Graph {\n size: usize,\n edge: Vec<(usize, usize, i64, i64)>,\n}\n\nimpl Graph {\n fn new(size: usize) -> Self {\n Graph {\n size: size,\n edge: vec![],\n }\n }\n fn add_edge(&mut self, src: usize, dst: usize, capa: i64, cost: i64) {\n assert!(src < self.size && dst < self.size && src != dst);\n self.edge.push((src, dst, capa, cost));\n }\n fn solve(&self, src: usize, dst: usize, flow: i64) -> Option {\n if src == dst {\n return Some(0);\n }\n let size = self.size;\n let edge = &self.edge;\n let mut deg = vec![0; size];\n for &(a, b, _, _) in edge.iter() {\n deg[a] += 1;\n deg[b] += 1;\n }\n let mut graph: Vec<_> = deg.into_iter().map(|d| Vec::with_capacity(d)).collect();\n for &(a, b, capa, cost) in edge.iter() {\n let x = graph[a].len();\n let y = graph[b].len();\n graph[a].push((b, capa, cost, y));\n graph[b].push((a, 0, -cost, x));\n }\n let mut ans = 0;\n let mut dp = Vec::with_capacity(size);\n let mut elem = Vec::with_capacity(size);\n let mut que = std::collections::VecDeque::new();\n for _ in 0..flow {\n dp.clear();\n dp.resize(size, (INF, src, 0));// \u30b3\u30b9\u30c8\u3001\u89aa\u3001\u89aa\u304b\u3089\u306e\u756a\u53f7\n dp[src] = (0, src, 0);\n elem.clear();\n elem.resize(size, false);\n elem[src] = true;\n que.push_back(src);\n while let Some(v) = que.pop_front() {\n elem[v] = false;\n let (c, _, _) = dp[v];\n for (i, &(u, capa, cost, _)) in graph[v].iter().enumerate() {\n if capa == 0 {\n continue;\n }\n let c = c + cost;\n if c < dp[u].0 {\n dp[u] = (c, v, i);\n if !elem[u] {\n elem[u] = true;\n que.push_back(u);\n }\n }\n }\n }\n if dp[dst].0 == INF {\n return None;\n }\n ans += dp[dst].0;\n let mut pos = dst;\n while pos != src {\n let (_, parent, k) = dp[pos];\n let inv = graph[parent][k].3;\n graph[parent][k].1 -= 1;\n graph[pos][inv].1 += 1;\n pos = parent;\n }\n }\n Some(ans)\n }\n}\n\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: usize,\n m: usize,\n k: usize,\n c: i64,\n d: i64,\n a: [usize1; k],\n e: [(usize1, usize1); m],\n }\n let w = 101;\n let size = n * w + 2;\n let mut graph = Graph::new(size);\n let src = size - 1;\n let dst = src - 1;\n let pos = |a: usize, b: usize| -> usize {\n assert!(a < 101 && b < n);\n a * n + b\n };\n for a in a {\n graph.add_edge(src, pos(0, a), 1, 0);\n }\n for i in 0..w {\n graph.add_edge(pos(i, 0), dst, 50, c * i as i64);\n }\n for (a, b) in e {\n for i in 1..w {\n for j in 1..=k {\n let x = j as i64;\n graph.add_edge(pos(i - 1, a), pos(i, b), 1, d * (2 * x - 1));\n graph.add_edge(pos(i - 1, b), pos(i, a), 1, d * (2 * x - 1));\n }\n }\n }\n for i in 1..w {\n for j in 0..n {\n graph.add_edge(pos(i - 1, j), pos(i, j), 50, 0);\n }\n }\n let ans = graph.solve(src, dst, k as i64).unwrap();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "a419ccaee6ed3e27e31d0170a3a913e8", "src_uid": "2d0aa75f2e63c4fb8c98742ac8cd821c", "difficulty": 2500.0} {"lang": "Rust", "source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let n = input.u();\n let a = input.vi(n);\n let mut sol = 0;\n for i in 1..n {\n m!(>, sol, a[i] - a[i-1]);\n }\n let mut res = 1000;\n for i in 1..=n-2 {\n m!(<, res, a[i+1] - a[i-1]);\n }\n println!(\"{}\", sol.max(res));\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "572e53414158e9e1463d4ca6bb0bd34c", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n// use proconio::input;\nuse std::cmp::Ordering::*;\nuse std::collections::{BTreeMap, BTreeSet};\nuse std::io::{self, BufWriter, Write};\nuse std::str::{self, SplitAsciiWhitespace};\n\n// I have no idea what I'm doing\n\nmacro_rules! answer {\n ($out:ident, $ans:expr) => {\n writeln!($out, \"{}\", $ans)\n };\n}\n\nfn solve(mut a: Vec, i: usize) -> i32 {\n a.remove(i);\n a.windows(2).map(|v| v[1] - v[0]).max().unwrap()\n}\n\nfn main() -> Result<(), io::Error> {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = UnsafeScanner::new(stdin.lock());\n let mut out = BufWriter::new(stdout.lock());\n\n let n: usize = scan.token();\n let a: Vec = (0..n).map(|_| scan.token()).collect();\n\n let ans = (1..n-1).map(|i| solve(a.clone(), i)).min().unwrap();\n\n answer!(out, ans)\n}\n\n///////////////////////////////////////////////////////////////////////////////////////////////////\n\n/// Copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs\n/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts\n/// **REQUIRES** Rust 1.34 or higher\npub struct UnsafeScanner {\n reader: R,\n buf_str: Vec,\n buf_iter: SplitAsciiWhitespace<'static>,\n}\n\nimpl UnsafeScanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buf_str: vec![],\n buf_iter: \"\".split_ascii_whitespace(),\n }\n }\n\n /// This function should be marked unsafe, but noone has time for that in a\n /// programming contest. Use at your own risk!\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buf_iter.next() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n self.buf_str.clear();\n self.reader\n .read_until(b'\\n', &mut self.buf_str)\n .expect(\"Failed read\");\n self.buf_iter = unsafe {\n let slice = str::from_utf8_unchecked(&self.buf_str);\n std::mem::transmute(slice.split_ascii_whitespace())\n }\n }\n }\n\n pub fn pair(&mut self) -> (T, T) {\n (self.token(), self.token())\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "d144973c6971243e356e9d5ce86c1e0c", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str::FromStr;\n\nfn get_num() -> usize {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input).expect(\"\");\n\n usize::from_str(input.trim()).unwrap()\n}\n\nfn get_nums() -> Vec {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input).expect(\"\");\n\n input\n .trim()\n .split_whitespace()\n .map(|s| usize::from_str(s).unwrap())\n .collect::>()\n}\n\nfn main() {\n let n = get_num();\n let a = get_nums();\n\n let mut mn = std::usize::MAX;\n for i in 1..n - 1 {\n let mut mx = std::usize::MIN;\n let mut v = a.clone();\n v.remove(i);\n\n for j in 0..v.len() - 1 {\n mx = std::cmp::max(mx, v[j + 1] - v[j]);\n }\n\n mn = std::cmp::min(mn, mx);\n }\n\n println!(\"{}\", mn);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "337318a5a0425ece77d3864467c81040", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0} {"lang": "Rust", "source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let mut nums: Vec = scan.next_n(3);\n nums[0] = nums[0].min(nums[1] - 1);\n nums[1] = nums[1].min(nums[2] - 1).min(nums[0] + 1);\n nums[2] = nums[2].min(nums[1] + 1);\n nums[0] = nums[0].min(nums[1] - 1);\n println!(\"{}\", nums[0] + nums[1] + nums[2]);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1 << 23)\n .spawn(_main)\n .unwrap()\n .join()\n .unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "37effc4f50509bdf09c5695e1cb38b15", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Rust", "source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let a = input.i();\n let b = input.i();\n let c = input.i();\n println!(\"{}\", 3 * b.min(a + 1).min(c - 1));\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "06aaa0b29a983a5691861a03851931bb", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};\n#[allow(unused_imports)]\nuse std::io::{stdin, stdout, BufWriter, StdoutLock, Write};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n#[allow(unused_macros)]\nmacro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ 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 ) * } } ; }\n#[allow(unused_macros)]\nmacro_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 ) * } } ; }\n#[allow(unused_macros)]\nmacro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\n#[allow(dead_code)]\npub fn with_bufwriter) -> ()>(f: F) {\n let out = stdout();\n let writer = BufWriter::new(out.lock());\n f(writer)\n}\n#[allow(unused_macros)]\nmacro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , \" = {:?}, \" ) ,* ) , $ ( $ a ) ,* ) } ; }\n#[allow(dead_code)]\nfn main() {\n input!{\n y: u64,\n b: u64,\n r: u64,\n }\n let mut mr = r;\n let mut mb = r - 1;\n let mut my = r - 2;\n if b < mb {\n my = b - 1;\n mb = b;\n mr = b + 1;\n }\n if y < my {\n my = y;\n mb = y + 1;\n mr = y + 2;\n }\n println!(\"{}\", my + mb + mr);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1cc8c73a954b85f89a7a0333501facb5", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let (y, b, r) = readln!(i32, i32, i32);\n\n let (y1, b1, r1) = (y, y + 1, y + 2);\n let (y2, b2, r2) = (b - 1, b, b + 1);\n let (y3, b3, r3) = (r - 2, r - 1, r);\n\n if y1 <= y && b1 <= b && r1 <= r {\n println!(\"{}\", y1 + b1 + r1);\n } else if y2 <= y && b2 <= b && r2 <= r {\n println!(\"{}\", y2 + b2 + r2);\n } else {\n println!(\"{}\", y3 + b3 + r3);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7ef4ef737e1b3af79ac05358573fecc8", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::char;\nuse std::fs::File;\nuse std::io::Read;\n\n// fn pow_speedt_with_mod(mut p: i64, mut q: i64, m: i64) -> i64 {\n// p %= m;\n// let mut r = p;\n// let mut ret: i64 = 1;\n// while q > 0 {\n// ret *= if q % 2 == 1 {r} else {1};\n// r *= r;\n// r %= m;\n// q /= 2;\n// ret %= m;\n// }\n// return ret;\n// }\n\nfn main() {\n let inputstatus = 1;\n\n let mut buf = String::new();\n let filename = \"inputrust.txt\";\n\n if inputstatus == 0 {\n let mut f = File::open(filename).expect(\"file not found\");\n f.read_to_string(&mut buf)\n .expect(\"something went wrong reading the file\");\n } else {\n std::io::stdin().read_to_string(&mut buf).unwrap();\n }\n\n let mut iter = buf.split_whitespace();\n let n: usize = iter.next().unwrap().parse().unwrap();\n let mut p: usize = n;\n let mut q: usize = 0;\n let s: String = iter.next().unwrap().parse().unwrap();\n let mut v = vec![0; 26];\n let mut words = vec![];\n\n for c in s.chars() {\n if v[c as usize - 97] == 0 {\n v[c as usize - 97] = 1;\n if p > 0 {\n words.push(String::new());\n p -= 1;\n q += 1;\n }\n }\n words[q - 1].push(c);\n }\n if q == n {\n println!(\"YES\");\n for w in &words {\n println!(\"{}\", w);\n }\n } else {\n println!(\"NO\");\n }\n\n // if p + 1 >= m\n\n // println!(\"{}\", n);\n // println!(\"{}\", k);\n // println!(\"{:?}\", num);\n // println!(\"{:?}\", cum_num);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b8b0009e581ffcaa50585f82745016e9", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::io;\nuse std::mem::size_of_val;\nuse std::cmp::{max, min};\nuse std::rc::Rc;\nuse std::collections::btree_map::BTreeMap;\nuse std::io::{Write, BufRead, Read, BufReader};\nuse std::collections::{HashMap, VecDeque, BTreeSet};\nuse std::ptr::write_volatile;\nuse std::fs::File;\n\n#[allow(dead_code)]\nfn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\n#[allow(dead_code)]\nfn gets_from_file(f: &mut BufReader) -> String {\n let mut contents = String::new();\n f.read_line(&mut contents).unwrap();\n contents.trim().to_string()\n}\n\n#[allow(unused)]\nfn read_strings() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n let mut v = Vec::new();\n for value in string.split_whitespace() {\n v.push(value.to_string());\n }\n v\n}\n\n#[allow(unused)]\nfn read_array_i32() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n string.split_whitespace().map(|x| x.parse::().unwrap()).collect()\n}\n\n#[allow(unused)]\nfn read_array_usize() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n string.split_whitespace().map(|x| x.parse::().unwrap()).collect()\n}\n\n\n#[allow(unused_macros)]\nmacro_rules! read_array {\n ( $ty:ty, ... ) => {\n gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap())\n };\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\n// mod math;\n// mod binary_search;\n// mod graph;\n// mod structure;\n// mod fibonacci;\n// mod string;\n// mod permutations;\n// mod patterns;\n\n\n#[allow(dead_code)]\nfn memory_properties(value: &T)\n where\n T: std::fmt::Display + ?Sized,\n{\n println!(\n \"Variable address in memory = {:p}, Allocated bytes for type = {}\",\n value,\n size_of_val(value)\n );\n}\n\n#[allow(unused_macros)]\nmacro_rules! sum {\n ($($x:expr), *) => {\n {\n let mut res = 0;\n $(res += $x;)*\n res\n }\n };\n}\n\n#[allow(unused)]\n#[allow(non_upper_case_globals)]\nstatic mut array: [[u8;51];51] = [[0u8; 51]; 51];\nstatic ALPHABET: &str = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\n\nfn main() {\n\n /*\n * Write/Read File\n */\n // let mut file = File::open(\"search.in\").expect(\"file not found\");\n // let mut input = BufReader::new(file);\n // file = File::create(\"search.out\").expect(\"file not found\");\n // let mut output = std::io::BufWriter::new(&mut file);\n\n use std::io::Write;\n let out = std::io::stdout();\n let mut out = std::io::BufWriter::new(out.lock());\n\n let mut seq: BTreeSet = BTreeSet::new();\n let mut n = gets().parse::().unwrap() - 1;\n let s = gets();\n let mut indexes = vec![0;1];\n seq.insert(s.as_bytes()[0]);\n let mut idx = 1;\n while n > 0 && idx < s.len(){\n if !seq.contains(&s.as_bytes()[idx]) {\n indexes.push(idx);\n seq.insert(s.as_bytes()[idx]);\n n -= 1;\n }\n idx += 1;\n }\n if n > 0 {\n writeln!(out, \"NO\");\n } else {\n indexes.push(s.len());\n writeln!(out, \"YES\");\n let idx = 0;\n for i in 1..indexes.len() {\n writeln!(out, \"{}\", &s[indexes[i - 1]..indexes[i]]);\n }\n }\n\n // writeln!(out, \"{}\", \"Hello Rust\").unwrap();\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "ad96cdeaf3b1252bebc11909c2a6cf5d", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io;\n\n\nfn read_line() -> String {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n return String::from(input_line.trim());\n}\n\nfn read_line_vec() -> Vec {\n return read_line().split(' ')\n .map(|s| s.parse().unwrap())\n .collect();\n}\n\nfn resolve(n: u32) -> String {\n let s = match n {\n 0 => \"zero\",\n 10 => \"ten\",\n 1 => \"one\",\t\n 11 => \"eleven\",\t \t \n 2 => \"two\",\t\n 12 => \"twelve\",\n 20 => \"twenty\",\n 3 => \"three\",\n 13 => \"thirteen\",\n 30 => \"thirty\",\n 4 => \"four\",\n 14 => \"fourteen\",\n 40 => \"forty\",\n 5 => \"five\",\n 15 => \"fifteen\", \n 50 => \"fifty\",\n 6 => \"six\",\n 16 => \"sixteen\",\n 60 => \"sixty\",\n 7 => \"seven\",\n 17 => \"seventeen\",\t\n 70 => \"seventy\",\n 8 => \"eight\",\n 18 => \"eighteen\",\n 80 => \"eighty\",\n 9 => \"nine\",\n 19 => \"nineteen\",\n 90 => \"ninety\",\n _ => panic!(\"WHAAAAT\")\n };\n return String::from(s);\n}\n\nfn main() {\n let n: u32 = read_line().parse().unwrap();\n if n <= 20 {\n let s = resolve(n);\n println!(\"{}\", s);\n } else {\n let s2 = resolve(n % 10);\n let s1 = resolve(10 * (n / 10));\n println!(\"{}-{}\", s1, s2);\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "bf0997731f53e46800d93043429479e2", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\n\nfn read_line() -> String {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n return String::from(input_line.trim());\n}\n\nfn read_line_vec() -> Vec {\n return read_line().split(' ')\n .map(|s| s.parse().unwrap())\n .collect();\n}\n\nfn resolve(n: u32) -> String {\n let s = match n {\n 0 => \"zero\",\n 10 => \"ten\",\n 1 => \"one\",\t\n 11 => \"eleven\",\t \t \n 2 => \"two\",\t\n 12 => \"twelve\",\n 20 => \"twenty\",\n 3 => \"three\",\n 13 => \"thirteen\",\n 30 => \"thirty\",\n 4 => \"four\",\n 14 => \"fourteen\",\n 40 => \"forty\",\n 5 => \"five\",\n 15 => \"fifteen\", \n 50 => \"fifty\",\n 6 => \"six\",\n 16 => \"sixteen\",\n 60 => \"sixty\",\n 7 => \"seven\",\n 17 => \"seventeen\",\t\n 70 => \"seventy\",\n 8 => \"eight\",\n 18 => \"eighteen\",\n 80 => \"eighty\",\n 9 => \"nine\",\n 19 => \"nineteen\",\n 90 => \"ninety\",\n _ => panic!(\"WHAAAAT\")\n };\n return String::from(s);\n}\n\nfn main() {\n let n: u32 = read_line().parse().unwrap();\n if n <= 20 || n % 10 == 0 {\n let s = resolve(n);\n println!(\"{}\", s);\n } else {\n let s2 = resolve(n % 10);\n \n let s1 = resolve(10 * (n / 10));\n println!(\"{}-{}\", s1, s2);\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e0f672946f11ea8838b64f9e995681fe", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::collections::HashMap;\nuse std::io;\nuse std::str::FromStr;\n\nfn get_num() -> usize {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input).expect(\"\");\n\n usize::from_str(input.trim()).unwrap()\n}\n\nfn main() {\n let mut m = HashMap::new();\n\n m.insert(0, \"zero\");\n m.insert(1, \"one\");\n m.insert(2, \"two\");\n m.insert(3, \"three\");\n m.insert(4, \"four\");\n m.insert(5, \"five\");\n m.insert(6, \"six\");\n m.insert(7, \"seven\");\n m.insert(8, \"eight\");\n m.insert(9, \"nine\");\n m.insert(10, \"ten\");\n m.insert(11, \"eleven\");\n m.insert(12, \"twelve\");\n m.insert(13, \"thirteen\");\n m.insert(14, \"fourteen\");\n m.insert(15, \"fifteen\");\n m.insert(16, \"sixteen\");\n m.insert(17, \"seventeen\");\n m.insert(18, \"eighteen\");\n m.insert(19, \"nineteen\");\n m.insert(20, \"twenty\");\n m.insert(30, \"thirty\");\n m.insert(40, \"forty\");\n m.insert(50, \"fifty\");\n m.insert(60, \"sixty\");\n m.insert(70, \"seventy\");\n m.insert(80, \"eighty\");\n m.insert(90, \"ninety\");\n\n let n = get_num();\n\n if n < 20 || m.contains_key(&n) {\n println!(\"{}\", m.get(&n).unwrap());\n } else {\n println!(\n \"{}-{}\",\n m.get(&(n / 10 * 10)).unwrap(),\n m.get(&(n % 10)).unwrap()\n );\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "aba8cf02d06e78e7cb7ed467e58bae1d", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "Rust", "source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::*;\n#[allow(unused_imports)] use std::iter::*;\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($i:ident . $e:tt : $t:ty; $($a:ident),*) => {\n $( let $a: $t = $i.$e(); )*\n };\n ($i:ident . $e:tt; $($a:ident),*) => {\n $( let $a = $i.$e(); )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let n = input.u();\n let a = input.i();\n let a = a - 1;\n let mut d = vec![Vec::new(); n];\n for (i,t) in input.ii(n).enumerate() {\n let i = i as i32;\n d[(i-a).abs() as usize].push(t);\n }\n let sol: i32 = d.into_iter().map(|a| {\n let l = a.len() as i32;\n let s = a.into_iter().sum();\n if s == l { s } else { 0 }\n }).sum();\n println!(\"{}\", sol);\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "75d5149af5c493de4b93b9aaad0e518f", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).unwrap();\n let n_a: Vec = buffer.split_whitespace().map(|x| x.parse::().unwrap()).collect();\n let (_, a) = (n_a[0], n_a[1] - 1);\n buffer.clear();\n io::stdin().read_line(&mut buffer).unwrap();\n let s: Vec = buffer.split_whitespace().map(|x| x.parse::().unwrap()).collect();\n let i: usize = a;\n let mut d: usize = 1;\n let mut ans: u32 = 0;\n if s[a] == 1 { ans += 1};\n loop {\n let left_idx = i.checked_sub(d);\n let right_idx = i + d;\n\n let left = match left_idx {\n Some(x) => Some(s[x]),\n None => None\n };\n\n let right = match right_idx {\n x if x < s.len() => Some(s[x]),\n _ => None\n };\n\n ans += match (left, right) {\n (Some(1), Some(1)) => 2,\n (None, Some(1)) => 1,\n (Some(1), None) => 1,\n _ => 0\n };\n\n if left.is_none() && right.is_none() {\n break;\n }\n\n d += 1\n }\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "754ba45a28f35c795b1c1caf3bebff6b", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0} {"lang": "Rust", "source_code": "const N:usize = 505; \r\n\r\n\r\nfn main() {\r\n\r\n let mut str = String::new();\r\n\tstd::io::stdin().read_line(&mut str).expect(\"\");\r\n let input :Vec<&str> = str.trim().split(\" \").collect();\r\n let n = input[0].parse::().unwrap();\r\n let modn = input[1].parse::().unwrap();\r\n let mut dp0:Vec = vec![0;N*N];\r\n let mut dp1:Vec = vec![0;N*N];\r\n //let mut temp_dp0:Vec = vec![0;N*N];\r\n //let mut temp_dp1:Vec = vec![0;N*N];\r\n let shift = N*N/2;\r\n dp1[shift]=1;\r\n for _i in 1..n{\r\n let mut new_dp0 :Vec = vec![0;N*N];\r\n let mut new_dp1 :Vec = vec![0;N*N];\r\n\r\n //let mut new_dp0 = temp_dp0;\r\n //let mut new_dp1 = temp_dp1;\r\n //for j in 0..(N*N){\r\n // new_dp0[j]=0;\r\n // new_dp1[j]=0;\r\n ///}\r\n \r\n let i = _i as usize;\r\n let mut _j = 0;\r\n while _j < N*N-1{\r\n let j = _j as usize;\r\n _j += 1;\r\n //let j = _j as usize;\r\n if dp1[j]==0 && dp0[j]==0{\r\n continue;\r\n }\r\n \r\n new_dp1[j-i] = (new_dp1[j-i]+dp1[j]);\r\n new_dp1[j+1] = (new_dp1[j+1]-2*dp1[j] + modn + modn);\r\n new_dp1[j+i+2]=(new_dp1[j+i+2]+dp1[j]);\r\n\r\n new_dp0[j+1] = (new_dp0[j+1]+dp1[j]*(i as i64));\r\n new_dp0[j] = (new_dp0[j]+(modn-dp1[j])*(i as i64+1));\r\n new_dp0[j-i] = (new_dp0[j-i]+dp1[j]);\r\n\r\n let t:i64 = (i as i64 +1)*dp0[j];\r\n new_dp0[j] = (new_dp0[j]+t);\r\n new_dp0[j+1] = (new_dp0[j+1]+(modn-t)*2);\r\n new_dp0[j+2] = (new_dp0[j+2]+t);\r\n }\r\n //for j in shift-10..shift+11{\r\n // println!(\"{} {}\",j as i32-shift as i32,new_dp[j][0])\r\n //}\r\n for j in 0..(N*N-1){\r\n new_dp0[j+1]=(new_dp0[j+1]+new_dp0[j])%modn;\r\n new_dp1[j+1]=(new_dp1[j+1]+new_dp1[j])%modn;\r\n }\r\n for j in 0..(N*N-1){\r\n new_dp0[j+1]=(new_dp0[j+1]+new_dp0[j])%modn;\r\n new_dp1[j+1]=(new_dp1[j+1]+new_dp1[j])%modn;\r\n }\r\n //temp_dp0 = dp0;\r\n //temp_dp1 = dp1;\r\n dp0 = new_dp0;\r\n dp1 = new_dp1;\r\n }\r\n let mut ans:i64 = 0;\r\n for j in shift+1..N*N{\r\n ans = (ans + dp0[j])%modn;\r\n }\r\n println!(\"{}\",ans);\r\n\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "660f39f19aa24f37b97b2fa419bc6452", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Rust", "source_code": "// ---------- begin next_permutation ----------\r\nfn next_permutation(a: &mut [T]) -> bool {\r\n a.windows(2).rposition(|a| a[0] < a[1]).map_or(false, |x| {\r\n let y = a.iter().rposition(|b| a[x] < *b).unwrap();\r\n a.swap(x, y);\r\n a[(x + 1)..].reverse();\r\n true\r\n })\r\n}\r\n// ---------- end next_permutation ----------\r\n// ---------- begin ModInt ----------\r\nmod modint {\r\n\r\n #[allow(dead_code)]\r\n pub struct Mod;\r\n impl ConstantModulo for Mod {\r\n const MOD: u32 = 1_000_000_007;\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub struct StaticMod;\r\n static mut STATIC_MOD: u32 = 0;\r\n impl Modulo for StaticMod {\r\n fn modulo() -> u32 {\r\n unsafe { STATIC_MOD }\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl StaticMod {\r\n pub fn set_modulo(p: u32) {\r\n unsafe {\r\n STATIC_MOD = p;\r\n }\r\n }\r\n }\r\n\r\n use std::marker::*;\r\n use std::ops::*;\r\n\r\n pub trait Modulo {\r\n fn modulo() -> u32;\r\n }\r\n\r\n pub trait ConstantModulo {\r\n const MOD: u32;\r\n }\r\n\r\n impl Modulo for T\r\n where\r\n T: ConstantModulo,\r\n {\r\n fn modulo() -> u32 {\r\n T::MOD\r\n }\r\n }\r\n\r\n pub struct ModInt(pub u32, PhantomData);\r\n\r\n impl Clone for ModInt {\r\n fn clone(&self) -> Self {\r\n ModInt::new_unchecked(self.0)\r\n }\r\n }\r\n\r\n impl Copy for ModInt {}\r\n\r\n impl Add for ModInt {\r\n type Output = ModInt;\r\n fn add(self, rhs: Self) -> Self::Output {\r\n let mut d = self.0 + rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl AddAssign for ModInt {\r\n fn add_assign(&mut self, rhs: Self) {\r\n *self = *self + rhs;\r\n }\r\n }\r\n\r\n impl Sub for ModInt {\r\n type Output = ModInt;\r\n fn sub(self, rhs: Self) -> Self::Output {\r\n let mut d = T::modulo() + self.0 - rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl SubAssign for ModInt {\r\n fn sub_assign(&mut self, rhs: Self) {\r\n *self = *self - rhs;\r\n }\r\n }\r\n\r\n impl Mul for ModInt {\r\n type Output = ModInt;\r\n fn mul(self, rhs: Self) -> Self::Output {\r\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\r\n ModInt::new_unchecked(v as u32)\r\n }\r\n }\r\n\r\n impl MulAssign for ModInt {\r\n fn mul_assign(&mut self, rhs: Self) {\r\n *self = *self * rhs;\r\n }\r\n }\r\n\r\n impl Neg for ModInt {\r\n type Output = ModInt;\r\n fn neg(self) -> Self::Output {\r\n if self.0 == 0 {\r\n Self::zero()\r\n } else {\r\n Self::new_unchecked(T::modulo() - self.0)\r\n }\r\n }\r\n }\r\n\r\n impl std::fmt::Display for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::fmt::Debug for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::str::FromStr for ModInt {\r\n type Err = std::num::ParseIntError;\r\n fn from_str(s: &str) -> Result {\r\n let val = s.parse::()?;\r\n Ok(ModInt::new(val))\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: usize) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: u64) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: i64) -> ModInt {\r\n let m = T::modulo() as i64;\r\n ModInt::new((val % m + m) as u32)\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new_unchecked(d: u32) -> Self {\r\n ModInt(d, PhantomData)\r\n }\r\n pub fn zero() -> Self {\r\n ModInt::new_unchecked(0)\r\n }\r\n pub fn one() -> Self {\r\n ModInt::new_unchecked(1)\r\n }\r\n pub fn is_zero(&self) -> bool {\r\n self.0 == 0\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new(d: u32) -> Self {\r\n ModInt::new_unchecked(d % T::modulo())\r\n }\r\n pub fn pow(&self, mut n: u64) -> Self {\r\n let mut t = Self::one();\r\n let mut s = *self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t *= s;\r\n }\r\n s *= s;\r\n n >>= 1;\r\n }\r\n t\r\n }\r\n }\r\n}\r\n// ---------- end ModInt ----------\r\n\r\nuse modint::*;\r\ntype M = ModInt;\r\n\r\n// ---------- begin input macro ----------\r\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\r\nmacro_rules! input {\r\n (source = $s:expr, $($r:tt)*) => {\r\n let mut iter = $s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n ($($r:tt)*) => {\r\n let s = {\r\n use std::io::Read;\r\n let mut s = String::new();\r\n std::io::stdin().read_to_string(&mut s).unwrap();\r\n s\r\n };\r\n let mut iter = s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! input_inner {\r\n ($iter:expr) => {};\r\n ($iter:expr, ) => {};\r\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\r\n let $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n ($iter:expr, bytes) => {\r\n read_value!($iter, String).bytes().collect::>()\r\n };\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n// ---------- end input macro ----------\r\n\r\nuse std::collections::*;\r\nuse std::io::Write;\r\n\r\ntype Map = HashMap;\r\ntype Set = BTreeSet;\r\ntype Deque = VecDeque;\r\n\r\nfn run() {\r\n input!(n: usize, modulo: u32);\r\n StaticMod::set_modulo(modulo);\r\n /*\r\n for n in 1..=6 {\r\n let mut ans = 0;\r\n let mut a = (0..n).collect::>();\r\n while {\r\n let mut b = a.clone();\r\n next_permutation(&mut b);\r\n while {\r\n let inv = |a: &[usize]| -> usize {\r\n let mut cnt = 0;\r\n for i in 0..a.len() {\r\n for j in (i + 1)..a.len() {\r\n if a[i] > a[j] {\r\n cnt += 1;\r\n }\r\n }\r\n }\r\n cnt\r\n };\r\n if inv(&a) > inv(&b) {\r\n ans += 1;\r\n }\r\n next_permutation(&mut b)\r\n }{}\r\n next_permutation(&mut a)\r\n }{}\r\n println!(\"{}: {}\", n, ans);\r\n }\r\n */\r\n let mut binom = vec![vec![M::zero(); n + 1]; n + 1];\r\n binom[0][0] = M::one();\r\n for i in 1..=n {\r\n binom[i][0] = M::one();\r\n for j in 1..=i {\r\n binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];\r\n }\r\n }\r\n let mut fact = vec![M::one(); n + 1];\r\n for i in 1..=n {\r\n fact[i] = M::from(i) * fact[i - 1];;\r\n }\r\n let mut dp = Map::new();\r\n for rem in (1..=n).rev() {\r\n let mut next = Map::new();\r\n for i in 0..rem {\r\n for j in (i + 1)..rem {\r\n *next.entry(i as i32 - j as i32).or_insert(M::zero()) += fact[n - rem] * binom[n][rem];\r\n }\r\n }\r\n let mut trans = Map::new();\r\n for i in 0..rem {\r\n for j in 0..rem {\r\n *trans.entry(i as i32 - j as i32).or_insert(M::zero()) += M::one();\r\n }\r\n }\r\n for (diff, way) in dp {\r\n for (d, w) in trans.iter() {\r\n *next.entry(diff + *d).or_insert(M::zero()) += *w * way;\r\n }\r\n }\r\n dp = next;\r\n }\r\n let mut ans = M::zero();\r\n for (diff, way) in dp {\r\n if diff > 0 {\r\n ans += way;\r\n }\r\n }\r\n let ans = ans.0 % modulo;\r\n println!(\"{}\", ans);\r\n}\r\n\r\nfn main() {\r\n run();\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "eb73be0bbafecc4e864f7754881726e0", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Rust", "source_code": "const N:usize = 505; \r\n\r\n\r\nfn main() {\r\n\r\n let mut str = String::new();\r\n\tstd::io::stdin().read_line(&mut str).expect(\"\");\r\n let input :Vec<&str> = str.trim().split(\" \").collect();\r\n let n = input[0].parse::().unwrap();\r\n let modn = input[1].parse::().unwrap();\r\n let mut dp0:Vec = vec![0;N*N];\r\n let mut dp1:Vec = vec![0;N*N];\r\n let mut temp_dp0:Vec = vec![0;N*N];\r\n let mut temp_dp1:Vec = vec![0;N*N];\r\n let shift = N*N/2;\r\n dp1[shift]=1;\r\n for _i in 1..n{\r\n //let mut new_dp0 :Vec = vec![0;N*N];\r\n //let mut new_dp1 :Vec = vec![0;N*N];\r\n\r\n let mut new_dp0 = temp_dp0;\r\n let mut new_dp1 = temp_dp1;\r\n for j in 0..(N*N){\r\n new_dp0[j]=0;\r\n new_dp1[j]=0;\r\n }\r\n let i = _i as usize;\r\n for _j in 0..(N*N-1){\r\n let j = _j as usize;\r\n if dp1[j]==0 && dp0[j]==0{\r\n continue;\r\n }\r\n new_dp1[j-i] = (new_dp1[j-i]+dp1[j])%modn;\r\n new_dp1[j+1] = (new_dp1[j+1]-2*dp1[j] + modn + modn)%modn;\r\n new_dp1[j+i+2]=(new_dp1[j+i+2]+dp1[j])%modn;\r\n\r\n new_dp0[j+1] = (new_dp0[j+1]+dp1[j]*(i as i64))%modn;\r\n new_dp0[j] = (new_dp0[j]+(modn-dp1[j])*(i as i64+1))%modn;\r\n new_dp0[j-i] = (new_dp0[j-i]+dp1[j])%modn;\r\n\r\n let t:i64 = (i as i64 +1)*dp0[j]%modn;\r\n new_dp0[j] = (new_dp0[j]+t)%modn;\r\n new_dp0[j+1] = (new_dp0[j+1]+(modn-t)*2)%modn;\r\n new_dp0[j+2] = (new_dp0[j+2]+t)%modn;\r\n }\r\n //for j in shift-10..shift+11{\r\n // println!(\"{} {}\",j as i32-shift as i32,new_dp[j][0])\r\n //}\r\n for j in 0..(N*N-1){\r\n new_dp0[j+1]=(new_dp0[j+1]+new_dp0[j])%modn;\r\n new_dp1[j+1]=(new_dp1[j+1]+new_dp1[j])%modn;\r\n }\r\n for j in 0..(N*N-1){\r\n new_dp0[j+1]=(new_dp0[j+1]+new_dp0[j])%modn;\r\n new_dp1[j+1]=(new_dp1[j+1]+new_dp1[j])%modn;\r\n }\r\n temp_dp0 = dp0;\r\n temp_dp1 = dp1;\r\n dp0 = new_dp0;\r\n dp1 = new_dp1;\r\n }\r\n let mut ans:i64 = 0;\r\n for j in shift+1..N*N{\r\n ans = (ans + dp0[j])%modn;\r\n }\r\n println!(\"{}\",ans);\r\n\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2aeca943fb1f3475e5b7167b6fb54552", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\r\nmod modint {\r\n\r\n #[allow(dead_code)]\r\n pub struct Mod;\r\n impl ConstantModulo for Mod {\r\n const MOD: u32 = 1_000_000_007;\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub struct StaticMod;\r\n static mut STATIC_MOD: u32 = 0;\r\n impl Modulo for StaticMod {\r\n fn modulo() -> u32 {\r\n unsafe { STATIC_MOD }\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl StaticMod {\r\n pub fn set_modulo(p: u32) {\r\n unsafe {\r\n STATIC_MOD = p;\r\n }\r\n }\r\n }\r\n\r\n use std::marker::*;\r\n use std::ops::*;\r\n\r\n pub trait Modulo {\r\n fn modulo() -> u32;\r\n }\r\n\r\n pub trait ConstantModulo {\r\n const MOD: u32;\r\n }\r\n\r\n impl Modulo for T\r\n where\r\n T: ConstantModulo,\r\n {\r\n fn modulo() -> u32 {\r\n T::MOD\r\n }\r\n }\r\n\r\n pub struct ModInt(pub u32, PhantomData);\r\n\r\n impl Clone for ModInt {\r\n fn clone(&self) -> Self {\r\n ModInt::new_unchecked(self.0)\r\n }\r\n }\r\n\r\n impl Copy for ModInt {}\r\n\r\n impl Add for ModInt {\r\n type Output = ModInt;\r\n fn add(self, rhs: Self) -> Self::Output {\r\n let mut d = self.0 + rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl AddAssign for ModInt {\r\n fn add_assign(&mut self, rhs: Self) {\r\n *self = *self + rhs;\r\n }\r\n }\r\n\r\n impl Sub for ModInt {\r\n type Output = ModInt;\r\n fn sub(self, rhs: Self) -> Self::Output {\r\n let mut d = T::modulo() + self.0 - rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl SubAssign for ModInt {\r\n fn sub_assign(&mut self, rhs: Self) {\r\n *self = *self - rhs;\r\n }\r\n }\r\n\r\n impl Mul for ModInt {\r\n type Output = ModInt;\r\n fn mul(self, rhs: Self) -> Self::Output {\r\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\r\n ModInt::new_unchecked(v as u32)\r\n }\r\n }\r\n\r\n impl MulAssign for ModInt {\r\n fn mul_assign(&mut self, rhs: Self) {\r\n *self = *self * rhs;\r\n }\r\n }\r\n\r\n impl Neg for ModInt {\r\n type Output = ModInt;\r\n fn neg(self) -> Self::Output {\r\n if self.0 == 0 {\r\n Self::zero()\r\n } else {\r\n Self::new_unchecked(T::modulo() - self.0)\r\n }\r\n }\r\n }\r\n\r\n impl std::fmt::Display for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::fmt::Debug for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::str::FromStr for ModInt {\r\n type Err = std::num::ParseIntError;\r\n fn from_str(s: &str) -> Result {\r\n let val = s.parse::()?;\r\n Ok(ModInt::new(val))\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: usize) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: u64) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: i64) -> ModInt {\r\n let m = T::modulo() as i64;\r\n ModInt::new((val % m + m) as u32)\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new_unchecked(d: u32) -> Self {\r\n ModInt(d, PhantomData)\r\n }\r\n pub fn zero() -> Self {\r\n ModInt::new_unchecked(0)\r\n }\r\n pub fn one() -> Self {\r\n ModInt::new_unchecked(1)\r\n }\r\n pub fn is_zero(&self) -> bool {\r\n self.0 == 0\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new(d: u32) -> Self {\r\n ModInt::new_unchecked(d % T::modulo())\r\n }\r\n pub fn pow(&self, mut n: u64) -> Self {\r\n let mut t = Self::one();\r\n let mut s = *self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t *= s;\r\n }\r\n s *= s;\r\n n >>= 1;\r\n }\r\n t\r\n }\r\n }\r\n}\r\n// ---------- end ModInt ----------\r\n\r\nuse modint::*;\r\ntype M = ModInt;\r\n\r\n// ---------- begin input macro ----------\r\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\r\nmacro_rules! input {\r\n (source = $s:expr, $($r:tt)*) => {\r\n let mut iter = $s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n ($($r:tt)*) => {\r\n let s = {\r\n use std::io::Read;\r\n let mut s = String::new();\r\n std::io::stdin().read_to_string(&mut s).unwrap();\r\n s\r\n };\r\n let mut iter = s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! input_inner {\r\n ($iter:expr) => {};\r\n ($iter:expr, ) => {};\r\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\r\n let $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n ($iter:expr, bytes) => {\r\n read_value!($iter, String).bytes().collect::>()\r\n };\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n// ---------- end input macro ----------\r\n\r\nuse std::collections::*;\r\nuse std::io::Write;\r\n\r\ntype Map = HashMap;\r\ntype Set = BTreeSet;\r\ntype Deque = VecDeque;\r\n\r\n// \u4e00\u81f4\u3057\u3066\u308b\u9593\u306f\u8ee2\u5012\u6570\u4e00\u81f4\u3001\u5f8c\u308d\u306e\u5bc4\u4e0e\u3082\u4e00\u81f4\r\n// p_0 < q_0 \u306e\u554f\u984c\u304cn=2..50 \u3067\u89e3\u3051\u308c\u3070\u3044\u3044\r\n// \u521d\u9805\u3092\u6c7a\u3081\u305f\u3089\u3042\u3068\u306f\u8ee2\u5012\u6570\u3092\u4fdd\u6301\u3059\u308bdp\u3067\u3044\u3044\u3093\u3058\u3083\uff1f\r\n// N^5 \u306b\u306a\u3063\u3066\u308b\u304c\r\n// \u3044\u30847\u4e57\u3060\u3053\u308c\r\n\r\nfn run() {\r\n input!(n: usize, modulo: u32);\r\n StaticMod::set_modulo(modulo);\r\n let mut ans = M::zero();\r\n let mut binom = vec![vec![M::zero(); n + 1]; n + 1];\r\n binom[0][0] = M::one();\r\n for i in 1..=n {\r\n binom[i][0] = M::one();\r\n for j in 1..=i {\r\n binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];\r\n }\r\n }\r\n let mut dp = Map::new();\r\n for rem in (1..=n).rev() {\r\n let mut next = Map::new();\r\n for i in 0..rem {\r\n for j in (i + 1)..rem {\r\n *next.entry(i as i32 - j as i32).or_insert(M::zero()) += binom[n][rem];\r\n }\r\n }\r\n let mut trans = Map::new();\r\n for i in 0..rem {\r\n for j in 0..rem {\r\n *trans.entry(i as i32 - j as i32).or_insert(M::zero()) += M::one();\r\n }\r\n }\r\n for (diff, way) in dp {\r\n for (d, w) in trans.iter() {\r\n *next.entry(diff + *d).or_insert(M::zero()) += *w * way;\r\n }\r\n }\r\n dp = next;\r\n }\r\n let mut ans = M::zero();\r\n for (diff, way) in dp {\r\n if diff > 0 {\r\n ans += way;\r\n }\r\n }\r\n let ans = ans.0 % modulo;\r\n println!(\"{}\", ans);\r\n}\r\n\r\nfn main() {\r\n run();\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b26e26cd07b91d1482fc48bab9a1f0b9", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\r\nmod modint {\r\n\r\n #[allow(dead_code)]\r\n pub struct Mod;\r\n impl ConstantModulo for Mod {\r\n const MOD: u32 = 1_000_000_007;\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub struct StaticMod;\r\n static mut STATIC_MOD: u32 = 0;\r\n impl Modulo for StaticMod {\r\n fn modulo() -> u32 {\r\n unsafe { STATIC_MOD }\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl StaticMod {\r\n pub fn set_modulo(p: u32) {\r\n unsafe {\r\n STATIC_MOD = p;\r\n }\r\n }\r\n }\r\n\r\n use std::marker::*;\r\n use std::ops::*;\r\n\r\n pub trait Modulo {\r\n fn modulo() -> u32;\r\n }\r\n\r\n pub trait ConstantModulo {\r\n const MOD: u32;\r\n }\r\n\r\n impl Modulo for T\r\n where\r\n T: ConstantModulo,\r\n {\r\n fn modulo() -> u32 {\r\n T::MOD\r\n }\r\n }\r\n\r\n pub struct ModInt(pub u32, PhantomData);\r\n\r\n impl Clone for ModInt {\r\n fn clone(&self) -> Self {\r\n ModInt::new_unchecked(self.0)\r\n }\r\n }\r\n\r\n impl Copy for ModInt {}\r\n\r\n impl Add for ModInt {\r\n type Output = ModInt;\r\n fn add(self, rhs: Self) -> Self::Output {\r\n let mut d = self.0 + rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl AddAssign for ModInt {\r\n fn add_assign(&mut self, rhs: Self) {\r\n *self = *self + rhs;\r\n }\r\n }\r\n\r\n impl Sub for ModInt {\r\n type Output = ModInt;\r\n fn sub(self, rhs: Self) -> Self::Output {\r\n let mut d = T::modulo() + self.0 - rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl SubAssign for ModInt {\r\n fn sub_assign(&mut self, rhs: Self) {\r\n *self = *self - rhs;\r\n }\r\n }\r\n\r\n impl Mul for ModInt {\r\n type Output = ModInt;\r\n fn mul(self, rhs: Self) -> Self::Output {\r\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\r\n ModInt::new_unchecked(v as u32)\r\n }\r\n }\r\n\r\n impl MulAssign for ModInt {\r\n fn mul_assign(&mut self, rhs: Self) {\r\n *self = *self * rhs;\r\n }\r\n }\r\n\r\n impl Neg for ModInt {\r\n type Output = ModInt;\r\n fn neg(self) -> Self::Output {\r\n if self.0 == 0 {\r\n Self::zero()\r\n } else {\r\n Self::new_unchecked(T::modulo() - self.0)\r\n }\r\n }\r\n }\r\n\r\n impl std::fmt::Display for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::fmt::Debug for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::str::FromStr for ModInt {\r\n type Err = std::num::ParseIntError;\r\n fn from_str(s: &str) -> Result {\r\n let val = s.parse::()?;\r\n Ok(ModInt::new(val))\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: usize) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: u64) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: i64) -> ModInt {\r\n let m = T::modulo() as i64;\r\n ModInt::new((val % m + m) as u32)\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new_unchecked(d: u32) -> Self {\r\n ModInt(d, PhantomData)\r\n }\r\n pub fn zero() -> Self {\r\n ModInt::new_unchecked(0)\r\n }\r\n pub fn one() -> Self {\r\n ModInt::new_unchecked(1)\r\n }\r\n pub fn is_zero(&self) -> bool {\r\n self.0 == 0\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new(d: u32) -> Self {\r\n ModInt::new_unchecked(d % T::modulo())\r\n }\r\n pub fn pow(&self, mut n: u64) -> Self {\r\n let mut t = Self::one();\r\n let mut s = *self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t *= s;\r\n }\r\n s *= s;\r\n n >>= 1;\r\n }\r\n t\r\n }\r\n }\r\n}\r\n// ---------- end ModInt ----------\r\n\r\nuse modint::*;\r\ntype M = ModInt;\r\n\r\n// ---------- begin input macro ----------\r\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\r\nmacro_rules! input {\r\n (source = $s:expr, $($r:tt)*) => {\r\n let mut iter = $s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n ($($r:tt)*) => {\r\n let s = {\r\n use std::io::Read;\r\n let mut s = String::new();\r\n std::io::stdin().read_to_string(&mut s).unwrap();\r\n s\r\n };\r\n let mut iter = s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! input_inner {\r\n ($iter:expr) => {};\r\n ($iter:expr, ) => {};\r\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\r\n let $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n ($iter:expr, bytes) => {\r\n read_value!($iter, String).bytes().collect::>()\r\n };\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n// ---------- end input macro ----------\r\n\r\nuse std::collections::*;\r\nuse std::io::Write;\r\n\r\ntype Map = HashMap;\r\ntype Set = BTreeSet;\r\ntype Deque = VecDeque;\r\n\r\n// \u4e00\u81f4\u3057\u3066\u308b\u9593\u306f\u8ee2\u5012\u6570\u4e00\u81f4\u3001\u5f8c\u308d\u306e\u5bc4\u4e0e\u3082\u4e00\u81f4\r\n// p_0 < q_0 \u306e\u554f\u984c\u304cn=2..50 \u3067\u89e3\u3051\u308c\u3070\u3044\u3044\r\n// \u521d\u9805\u3092\u6c7a\u3081\u305f\u3089\u3042\u3068\u306f\u8ee2\u5012\u6570\u3092\u4fdd\u6301\u3059\u308bdp\u3067\u3044\u3044\u3093\u3058\u3083\uff1f\r\n// N^5 \u306b\u306a\u3063\u3066\u308b\u304c\r\n// \u3044\u30847\u4e57\u3060\u3053\u308c\r\n\r\nfn run() {\r\n input!(n: usize, modulo: u32);\r\n StaticMod::set_modulo(modulo);\r\n let mut ans = M::zero();\r\n let mut binom = vec![vec![M::zero(); n + 1]; n + 1];\r\n binom[0][0] = M::one();\r\n for i in 1..=n {\r\n binom[i][0] = M::one();\r\n for j in 1..=i {\r\n binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];\r\n }\r\n }\r\n let mut dp = Map::new();\r\n for rem in (1..=n).rev() {\r\n let mut next = Map::new();\r\n for i in 0..rem {\r\n for j in (i + 1)..rem {\r\n *next.entry(i as i32 - j as i32).or_insert(M::zero()) += binom[n][rem];\r\n }\r\n }\r\n let mut trans = Map::new();\r\n for i in 0..rem {\r\n for j in 0..rem {\r\n *trans.entry(i as i32 - j as i32).or_insert(M::zero()) += M::one();\r\n }\r\n }\r\n for (diff, way) in dp {\r\n for (d, w) in trans.iter() {\r\n *next.entry(diff + *d).or_insert(M::zero()) += *w * way;\r\n }\r\n }\r\n dp = next;\r\n }\r\n let mut ans = M::zero();\r\n for (diff, way) in dp {\r\n if diff > 0 {\r\n ans += way;\r\n }\r\n }\r\n println!(\"{}\", ans);\r\n}\r\n\r\nfn main() {\r\n run();\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "5c86f74b91bc0ab9075359da222a823d", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "Rust", "source_code": "fn is_sufficient(v: u64, n: u64, k: u64) -> bool {\n let summand_count = ((v as f64).log(k as f64).trunc() + 1_f64) as usize;\n // dbg!(summand_count);\n let sum: u64 = (0..summand_count).map(|x| v / k.checked_pow(x as u32).unwrap()).sum();\n // dbg!(sum);\n sum >= n\n}\n\nfn solve(n: u64, k: u64) -> u64 {\n let mut l: u64 = 1;\n let mut r: u64 = n + 1;\n while r - l > 2 {\n let m = l + (r - l) / 2;\n // dbg!(l, m, r);\n if is_sufficient(m, n, k) {\n // dbg!(\"YES\");\n r = m + 1;\n } else {\n // dbg!(\"NO\");\n l = m;\n }\n }\n // dbg!(is_sufficient(4, n, k));\n if is_sufficient(l, n, k) {l} else {l + 1}\n}\n\nfn main() {\n let (n, k) = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let mut n_k = buf.trim().split_whitespace().map(|x| x.parse::().unwrap());\n let n = n_k.next().unwrap();\n let k = n_k.next().unwrap();\n (n, k)\n };\n\n println!(\"{}\", solve(n, k));\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "9885c1705074f318ab9dacec3cdc28c9", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n let mut input = input.split_whitespace().map(|k| k.parse::().unwrap());\n let m = input.next().unwrap();\n let b = input.next().unwrap();\n\n let ans = (0..(m * b + 1)).map(|x| {\n let y = b - (x + m - 1) / m;\n let tmp = (x + 1) * (y + 1) * (x + y) / 2 ;\n tmp\n }).max().unwrap();\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "a8078515c66905f0c1381bffeaa218a1", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp;\nuse std::fs::File;\nuse std::io::Read;\n\n#[allow(dead_code)]\nfn pow_speedy_with_mod(mut p: i64, mut q: i64, m: i64) -> i64 {\n p %= m;\n let mut r = p;\n let mut ret: i64 = 1;\n while q > 0 {\n ret *= if q % 2 == 1 { r } else { 1 };\n r *= r;\n r %= m;\n q /= 2;\n ret %= m;\n }\n return ret;\n}\n\n#[allow(dead_code)]\nfn comb(n: usize, k: usize, m: i64, frac: &[i64], frac_inv: &[i64]) -> i64 {\n let mut ret = 1i64;\n if n < k {\n return 0;\n }\n ret *= frac[n] * frac_inv[n - k];\n ret %= m;\n ret *= frac_inv[k];\n ret %= m;\n ret\n}\n\nfn main() {\n let inputstatus = 1;\n\n let mut buf = String::new();\n let filename = \"inputrust.txt\";\n\n if inputstatus == 0 {\n let mut f = File::open(filename).expect(\"file not found\");\n f.read_to_string(&mut buf)\n .expect(\"something went wrong reading the file\");\n } else {\n std::io::stdin().read_to_string(&mut buf).unwrap();\n }\n\n let mut iter = buf.split_whitespace();\n\n let a: i64 = iter.next().unwrap().parse().unwrap();\n let mut b: i64 = iter.next().unwrap().parse().unwrap();\n let mut ans: i64 = 0;\n for i in 0..b + 1 {\n let x = a * i;\n ans = cmp::max(ans, (x + b) * (x + 1) * (b + 1) / 2);\n b -= 1;\n }\n println!(\"{}\", ans);\n // let n = iter.next().unwrap().parse().unwrap();\n\n // println!(\"{}\", n);\n // println!(\"{:?}\", cum_num);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2e68583173bf9ac73e932da09bfb96a2", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n let mut input = input.split_whitespace().map(|k| k.parse::().unwrap());\n let m = input.next().unwrap();\n let b = input.next().unwrap();\n\n let ans = (0..(m * b + 1)).map(|x| {\n let y = b - (x + m - 1) / m;\n (x + 1) * (y + 1) / 2 * (x + y)\n }).max().unwrap();\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e87c87509a4d5d9def3376c35a50431f", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "Rust", "source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn solve() {\n let mut n = parse_line!(u64);\n let mut result = 0;\n let mut add = 1;\n while n > 1 {\n result += n / 2 * add;\n add *= 2;\n n = (n + 1) / 2;\n }\n println!(\"{}\", result);\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "527c020071824745dfb7c57feb411b8a", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "Rust", "source_code": "fn main() {\n let mut input = String::new();\n use std::io;\n use std::io::prelude::*;\n io::stdin().read_to_string(&mut input).unwrap();\n\n let n: u64 = input.trim().parse().unwrap();\n\n let bc = n.next_power_of_two().trailing_zeros();\n\n let mut cb = 1;\n let mut ans = 0;\n for _ in 0..bc {\n let t = cb * ((n - 1 + cb) / (cb << 1));\n ans += t;\n cb <<= 1;\n }\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "480b1bb202ccf3b42d6dae8dd18997c5", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 1_000_000_007;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\nimpl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n\nimpl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n}\n\nimpl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt((val % MOD as usize) as u32)\n }\n}\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n assert!(self.0 > 0);\n self.pow(MOD - 2)\n }\n}\n// ---------- end ModInt ----------\n\nfn run() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut it = s.trim().split_whitespace();\n let n: u32 = it.next().unwrap().parse().unwrap();\n let k: usize = it.next().unwrap().parse().unwrap();\n let mut is_prime = vec![true; k + 1];\n for i in 2.. {\n if i * i > k {\n break;\n }\n if is_prime[i] {\n let mut j = i * i;\n while let Some(p) = is_prime.get_mut(j) {\n *p = false;\n j += i;\n }\n }\n }\n let mut mobius = vec![ModInt::one(); k + 1];\n for (i, p) in is_prime.into_iter().enumerate().skip(2) {\n if !p {\n continue;\n }\n let mut j = i;\n while let Some(x) = mobius.get_mut(j) {\n *x = -*x;\n j += i;\n }\n let k = i.saturating_mul(i);\n let mut j = k;\n while let Some(x) = mobius.get_mut(j) {\n *x = ModInt::zero();\n j += k;\n }\n }\n let pow: Vec = (0..=k).map(|k| ModInt::from(k).pow(n)).collect();\n let mut imos = vec![ModInt::zero(); 2 * k + 1];\n for (i, v) in mobius.into_iter().enumerate().skip(2) {\n if v.0 == 0 {\n continue;\n }\n for (x, &pow) in pow.iter().enumerate().skip(1) {\n if x * i > k {\n break;\n }\n let v = v * pow;\n let l = x * i;\n let r = (x + 1) * i;\n imos[l] += v;\n imos[r] -= v;\n }\n }\n let mut ans = ModInt::zero();\n for i in 1..=k {\n imos[i] = imos[i] + imos[i - 1];\n let way = ModInt::from(i).pow(n) + imos[i];\n ans += ModInt::new(way.0 ^ i as u32);\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c8117853e37c0e915740a8b671295d81", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 1_000_000_007;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\nimpl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n\nimpl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n}\n\nimpl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt((val % MOD as usize) as u32)\n }\n}\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n assert!(self.0 > 0);\n self.pow(MOD - 2)\n }\n}\n// ---------- end ModInt ----------\n\nfn run() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut it = s.trim().split_whitespace();\n let n: u32 = it.next().unwrap().parse().unwrap();\n let k: usize = it.next().unwrap().parse().unwrap();\n let mut is_prime = vec![true; k + 1];\n for i in 2.. {\n if i * i > k {\n break;\n }\n if is_prime[i] {\n let mut j = i * i;\n while let Some(p) = is_prime.get_mut(j) {\n *p = false;\n j += i;\n }\n }\n }\n let mut mobius = vec![ModInt::one(); k + 1];\n for (i, p) in is_prime.into_iter().enumerate().skip(2) {\n if !p {\n continue;\n }\n let mut j = i;\n while let Some(x) = mobius.get_mut(j) {\n *x = -*x;\n j += i;\n }\n let k = i.saturating_mul(i);\n let mut j = k;\n while let Some(x) = mobius.get_mut(j) {\n *x = ModInt::zero();\n j += k;\n }\n }\n let mut imos = vec![ModInt::zero(); 2 * k + 1];\n for (i, v) in mobius.into_iter().enumerate().skip(2) {\n if v.0 == 0 {\n continue;\n }\n for x in 1.. {\n if x * i > k {\n break;\n }\n let v = v * ModInt::from(x).pow(n);\n let l = x * i;\n let r = (x + 1) * i;\n imos[l] += v;\n imos[r] -= v;\n }\n }\n let mut ans = ModInt::zero();\n for i in 1..=k {\n imos[i] = imos[i] + imos[i - 1];\n let way = ModInt::from(i).pow(n) + imos[i];\n ans += ModInt::new(way.0 ^ i as u32);\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2f80d56b12120494e1c104c6fe0850c3", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str::FromStr;\n\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::cmp::{max, min};\n\nfn get_line() -> String {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input\n}\n\nfn get_vec() -> Vec\nwhere T: FromStr,\n ::Err: std::fmt::Debug,\n{\n get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn extended_euclid(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n (a, 1, 0)\n } else {\n let (d0, x0, y0) = extended_euclid(b, a % b);\n (d0, y0, x0 - a / b * y0)\n }\n}\n\nfn main() {\n let a: Vec = get_vec();\n\n let sum: u32 = a.iter().cloned().sum();\n\n if sum % 2 != 0 {\n println!(\"NO\");\n return;\n }\n\n for i in 0..6 {\n for j in i + 1..6 {\n for k in j + 1..6 {\n if a[i] + a[j] + a[k] == sum / 2 {\n println!(\"YES\");\n return;\n }\n }\n }\n }\n\n println!(\"NO\");\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "975640ec956f70582bdea75f4f538a3e", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet, BinaryHeap, VecDeque};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n#[allow(unused_imports)]\nuse std::io::stdin;\n\nmod util {\n use std::io::stdin;\n use std::str::FromStr;\n use std::fmt::Debug;\n\n #[allow(dead_code)]\n pub fn line() -> String {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().to_string()\n }\n\n #[allow(dead_code)]\n pub fn gets() -> Vec\n where\n ::Err: Debug,\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse().unwrap())\n .collect()\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\nfn main() {\n let a = get!(usize;;);\n\n for p in 0usize..1 << 6 {\n if p.count_ones() != 3 {\n continue;\n }\n\n let mut x = 0;\n let mut y = 0;\n\n for k in 0..6 {\n if (p >> k) & 1 == 1 {\n x += a[k];\n } else {\n y += a[k];\n }\n }\n if x == y {\n println!(\"YES\");\n return;\n }\n }\n println!(\"NO\");\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b80b1583db4cc57da0efd9dd25ca2bf7", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\nfn main(){\n let mut s=String::new();\n let mut c:usize=0;\n let mut a:Vec=Vec::new();\n let mut b:Vec=Vec::new();\n let mut n:usize=0;\n let mut sum:i32=0;\n let mut p:usize=0;\n io::stdin().read_line(&mut s).unwrap();\n s.trim();\n while c0{println!(\"YES\")}\n else{println!(\"NO\")}\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "ea588a68a2dffa98b05cedb1f7d47960", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0} {"lang": "Rust", "source_code": "//! http://codeforces.com/problemset/problem/808/C\n\n#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(isize);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\n// -----------------------------------------------------------------------------\n\nfn main() {\n use std::io::{self, Write, BufWriter};\n let __stdout = io::stdout();\n let mut __out = BufWriter::with_capacity(4096, __stdout.lock());\n\n macro_rules! put {\n ($fmt:expr) => { write!(__out, $fmt).unwrap(); };\n ($fmt:expr, $($arg:expr),+) => { write!(__out, $fmt, $($arg),+).unwrap(); }\n }\n macro_rules! putln {\n () => { writeln!(__out, \"\").unwrap(); };\n ($fmt:expr) => { writeln!(__out, $fmt).unwrap(); };\n ($fmt:expr, $($arg:expr),+) => { writeln!(__out, $fmt, $($arg),+).unwrap(); }\n }\n macro_rules! fflush {\n () => { __out.flush().unwrap(); }\n }\n\n scanln!(n: u32, w: u32);\n scanln!(cups: Vec);\n\n let half: u32 = cups.iter()\n .map(|&cap| (cap + 1) / 2)\n .sum();\n\n if half > w {\n putln!(\"-1\");\n return;\n }\n\n let mut rem = w - half;\n let mut cups: Vec<(usize, u32, u32)> = cups.into_iter()\n .enumerate()\n .map(|(i, max)| (i, max, (max + 1) / 2))\n .collect();\n cups.sort_by_key(|&(_, cap, _)| cap);\n for cup in cups.iter_mut().rev() {\n if rem == 0 { break; }\n let (_, ref mut max, ref mut amt) = *cup;\n let diff = std::cmp::min(*max - *amt, rem);\n rem -= diff;\n *amt += diff;\n }\n cups.sort_by_key(|&(i, _, _)| i);\n for &(i, _, amt) in cups.iter() {\n if i != 0 { put!(\" \"); }\n put!(\"{}\", amt);\n }\n putln!();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "78f9d3d938275316c5a0a6bc5b8bfe65", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "Rust", "source_code": "fn main() {\n let (a, b) = {\n let res = getvec::();\n (res[0], res[1])\n };\n let sa = a - b;\n let flag = sa.abs() >= 2 || a + b == 0;\n let res = match flag {\n true => \"NO\",\n false => \"YES\",\n };\n println!(\"{}\", res);\n}\n\n#[allow(dead_code)]\nfn next_line() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n input\n}\n\n#[allow(dead_code)]\nfn getnum() -> T {\n let res = next_line();\n res.trim().parse::().ok().unwrap()\n}\n\n#[allow(dead_code)]\nfn getvec() -> Vec {\n let res = next_line();\n res.split_whitespace().map(|x| x.parse::().ok().unwrap()).collect()\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e61e5a86638f98665699efaab930bab1", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Rust", "source_code": "//spnauti-rust\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::*;\n#[allow(unused_imports)] use std::collections::*;\n\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($i:ident . $e:tt : $t:ty, $($a:ident),*) => {\n $( let $a: $t = $i.$e(); )*\n };\n ($i:ident . $e:tt, $($a:ident),*) => {\n $( let $a = $i.$e(); )*\n };\n}\n\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl std::iter::Iterator where T::Err: Debug {\n //(0..n).map(|_| self.p())\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n l!(input.i, a, b);\n if a + b > 0 && (a - b).abs() <= 1 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "0ff6ca515077ce7bf808956f6485f650", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Rust", "source_code": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var, $t:ty, $($v:ident), *) => {\n read_line!(input_line);\n let mut iter = parse_token!($t, input_line);\n $(\n let $v = iter.next().unwrap();\n )*\n };\n (vec, $t:ty, $v:ident) => {\n read_line!(input_line);\n let iter = parse_token!($t, input_line);\n let $v: Vec<$t> = iter.collect();\n };\n ($($v:ident; $t:ty), *) => {\n read_line!(input_line);\n let mut iter = input_line.split_whitespace();\n $(\n let $v: $t = iter.next().unwrap().parse().unwrap();\n )*\n };\n}\n\nmacro_rules! parse_token {\n ($t:ty, $e:expr) => {\n $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());\n };\n}\n\nfn main() {\n read_line!(even;i64, odd;i64);\n if odd == 0 && even == 0 {\n println!(\"NO\"); // There must be one staircase\n return\n }\n if (odd - even).abs() <= 1 {\n // Valid count\n println!(\"YES\")\n } else {\n println!(\"NO\")\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c44342aed96501d666b0b1ecdaa7e12b", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\nuse std::io::{ self, Write };\nuse std::str::FromStr;\nuse std::cmp::{ min, max };\nuse std::collections::{ BinaryHeap, VecDeque };\n\nmacro_rules! trace {\n ($var:expr) => ({\n let _ = writeln!(&mut std::io::stderr(), \">>> {} = {:?}\", stringify!($var), $var);\n })\n}\nmacro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }\n\nfn main() {\n let mut sc = Scanner::new();\n let a: i32 = sc.cin();\n let b: i32 = sc.cin();\n\n let k = if a == b + 1 || a == b || a + 1 == b { \"YES\" } else { \"NO\" };\n println!(\"{}\", k);\n\n}\n\n#[allow(dead_code)]\nstruct Scanner { stdin: io::Stdin, buffer: VecDeque, }\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }\n fn reserve(&mut self) {\n while self.buffer.len() == 0 {\n let mut line = String::new();\n let _ = self.stdin.read_line(&mut line);\n for w in line.split_whitespace() {\n self.buffer.push_back(String::from(w));\n }\n }\n }\n fn cin(&mut self) -> T {\n self.reserve();\n match self.buffer.pop_front().unwrap().parse::() {\n Ok(a) => a,\n Err(_) => panic!(\"parse err\")\n }\n }\n fn get_char(&mut self) -> char {\n self.reserve();\n let head = self.buffer[0].chars().nth(0).unwrap();\n let tail = String::from( &self.buffer[0][1..] );\n if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }\n head\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7cc0c2a0f2f76adf051a67147f9e8294", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Rust", "source_code": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var, $t:ty, $($v:ident), *) => {\n read_line!(input_line);\n let mut iter = parse_token!($t, input_line);\n $(\n let $v = iter.next().unwrap();\n )*\n };\n (vec, $t:ty, $v:ident) => {\n read_line!(input_line);\n let iter = parse_token!($t, input_line);\n let $v: Vec<$t> = iter.collect();\n };\n ($($v:ident; $t:ty), *) => {\n read_line!(input_line);\n let mut iter = input_line.split_whitespace();\n $(\n let $v: $t = iter.next().unwrap().parse().unwrap();\n )*\n };\n}\n\nmacro_rules! parse_token {\n ($t:ty, $e:expr) => {\n $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());\n };\n}\n\nfn main() {\n read_line!(even;u64, odd;u64);\n if odd == even || odd == even + 1 {\n println!(\"YES\")\n } else {\n println!(\"NO\")\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "5c0c0a662f0ee9675d3e32deda0920d5", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Rust", "source_code": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var, $t:ty, $($v:ident), *) => {\n read_line!(input_line);\n let mut iter = parse_token!($t, input_line);\n $(\n let $v = iter.next().unwrap();\n )*\n };\n (vec, $t:ty, $v:ident) => {\n read_line!(input_line);\n let iter = parse_token!($t, input_line);\n let $v: Vec<$t> = iter.collect();\n };\n ($($v:ident; $t:ty), *) => {\n read_line!(input_line);\n let mut iter = input_line.split_whitespace();\n $(\n let $v: $t = iter.next().unwrap().parse().unwrap();\n )*\n };\n}\n\nmacro_rules! parse_token {\n ($t:ty, $e:expr) => {\n $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());\n };\n}\n\nfn main() {\n read_line!(even;i64, odd;i64);\n if (odd - even).abs() <= 1 {\n println!(\"YES\")\n } else {\n println!(\"NO\")\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1790fe0dc5dba5967b957059aa49cbe2", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::{io,cmp};fn main(){let mut x=String::new();io::stdin().read_line(&mut x);let y:Vec<&str>=x.split_whitespace().collect();let a:i32=y[0].parse().unwrap();let b:i32=y[1].parse().unwrap();if a<1&&b>0{print!(\"Impossible\");return}print!(\"{} {}\",cmp::max(a,b),cmp::max(a+b-1,a+0))}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "476095add8cb5f8fe1e61f281f1c807c", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Rust", "source_code": "//1.25.0 | JDoodle.Com & 1.26 | CodeForces.Com\nuse std::{io,cmp};\n\nfn main() {\n let mut input1 = String::new();\n io::stdin().read_line(&mut input1);\n let input2:Vec<&str> = input1.split_whitespace().collect();\n \n let grown_ups:i32 = input2[0].parse().unwrap();\n let children:i32 = input2[1].parse().unwrap();\n \n if grown_ups < 1 && children > 0 {\n print!(\"Impossible\");\n return\n }\n \n print!(\"{} {}\", cmp::max(grown_ups, children), cmp::max(grown_ups + children - 1, grown_ups + 0))\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "27c0ed1b60bacb3ed6f0dece3fd2726d", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Write, BufWriter};\n// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n ($($r:tt)*) => {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input_inner!{next, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input_inner!{$next $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, [ $t:tt ]) => {{\n let len = read_value!($next, usize);\n (0..len).map(|_| read_value!($next, $t)).collect::>()\n }};\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n/// Verified by https://atcoder.jp/contests/arc093/submissions/3968098\nmod mod_int {\n use std::ops::*;\n pub trait Mod: Copy { fn m() -> i64; }\n #[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]\n pub struct ModInt { pub x: i64, phantom: ::std::marker::PhantomData }\n impl ModInt {\n // x >= 0\n pub fn new(x: i64) -> Self { ModInt::new_internal(x % M::m()) }\n fn new_internal(x: i64) -> Self {\n ModInt { x: x, phantom: ::std::marker::PhantomData }\n }\n pub fn pow(self, mut e: i64) -> Self {\n debug_assert!(e >= 0);\n let mut sum = ModInt::new_internal(1);\n let mut cur = self;\n while e > 0 {\n if e % 2 != 0 { sum *= cur; }\n cur *= cur;\n e /= 2;\n }\n sum\n }\n #[allow(dead_code)]\n pub fn inv(self) -> Self { self.pow(M::m() - 2) }\n }\n impl>> Add for ModInt {\n type Output = Self;\n fn add(self, other: T) -> Self {\n let other = other.into();\n let mut sum = self.x + other.x;\n if sum >= M::m() { sum -= M::m(); }\n ModInt::new_internal(sum)\n }\n }\n impl>> Sub for ModInt {\n type Output = Self;\n fn sub(self, other: T) -> Self {\n let other = other.into();\n let mut sum = self.x - other.x;\n if sum < 0 { sum += M::m(); }\n ModInt::new_internal(sum)\n }\n }\n impl>> Mul for ModInt {\n type Output = Self;\n fn mul(self, other: T) -> Self { ModInt::new(self.x * other.into().x % M::m()) }\n }\n impl>> AddAssign for ModInt {\n fn add_assign(&mut self, other: T) { *self = *self + other; }\n }\n impl>> SubAssign for ModInt {\n fn sub_assign(&mut self, other: T) { *self = *self - other; }\n }\n impl>> MulAssign for ModInt {\n fn mul_assign(&mut self, other: T) { *self = *self * other; }\n }\n impl Neg for ModInt {\n type Output = Self;\n fn neg(self) -> Self { ModInt::new(0) - self }\n }\n impl ::std::fmt::Display for ModInt {\n fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {\n self.x.fmt(f)\n }\n }\n impl ::std::fmt::Debug for ModInt {\n fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {\n self.x.fmt(f)\n }\n }\n impl From for ModInt {\n fn from(x: i64) -> Self { Self::new(x) }\n }\n} // mod mod_int\n\nmacro_rules! define_mod {\n ($struct_name: ident, $modulo: expr) => {\n #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]\n struct $struct_name {}\n impl mod_int::Mod for $struct_name { fn m() -> i64 { $modulo } }\n }\n}\nconst MOD: i64 = 998244353;\ndefine_mod!(P, MOD);\ntype ModInt = mod_int::ModInt

;\n\n/// FFT (in-place, verified as NTT only)\n/// R: Ring + Copy\n/// Verified by: https://codeforces.com/contest/1096/submission/47672373\nmod fft {\n use std::ops::*;\n /// n should be a power of 2. zeta is a primitive n-th root of unity.\n /// one is unity\n /// Note that the result should be multiplied by 1/sqrt(n).\n pub fn transform(f: &mut [R], zeta: R, one: R)\n where R: Copy +\n Add +\n Sub +\n Mul {\n let n = f.len();\n assert!(n.is_power_of_two());\n {\n let mut i = 0;\n for j in 1 .. n - 1 {\n let mut k = n >> 1;\n loop {\n i ^= k;\n if k <= i { break; }\n k >>= 1;\n }\n if j < i { f.swap(i, j); }\n }\n }\n let mut zetapow = Vec::new();\n {\n let mut m = 1;\n let mut cur = zeta;\n while m < n {\n zetapow.push(cur);\n cur = cur * cur;\n m *= 2;\n }\n }\n let mut m = 1;\n while m < n {\n let base = zetapow.pop().unwrap();\n let mut r = 0;\n while r < n {\n let mut w = one;\n for s in r .. r + m {\n let u = f[s];\n let d = f[s + m] * w;\n f[s] = u + d;\n f[s + m] = u - d;\n w = w * base;\n }\n r += 2 * m;\n }\n m *= 2;\n }\n }\n}\n\nuse fft::*;\n\n// Depends on ModInt.rs\nfn fact_init(w: usize) -> (Vec, Vec) {\n let mut fac = vec![ModInt::new(1); w];\n let mut invfac = vec![0.into(); w];\n for i in 1 .. w {\n fac[i] = fac[i - 1] * i as i64;\n }\n invfac[w - 1] = fac[w - 1].inv();\n for i in (0 .. w - 1).rev() {\n invfac[i] = invfac[i + 1] * (i as i64 + 1);\n }\n (fac, invfac)\n}\n\nfn solve() {\n let out = std::io::stdout();\n let mut out = BufWriter::new(out.lock());\n macro_rules! puts {\n ($($format:tt)*) => (write!(out,$($format)*).unwrap());\n }\n input! {\n n: usize,\n k: usize,\n l: i64,\n }\n const N: usize = 4096;\n let (fac, invfac) = fact_init(N);\n\n let mut p = vec![ModInt::new(0); N];\n let mut q = vec![ModInt::new(0); N];\n p[1] = ModInt::new(2);\n p[2] = -ModInt::new(2);\n q[0] = ModInt::new(1);\n q[1] = -ModInt::new(2);\n q[2] = ModInt::new(2);\n\n let zeta = ModInt::new(3).pow((MOD - 1) / N as i64);\n transform(&mut p, zeta, ModInt::new(1));\n transform(&mut q, zeta, ModInt::new(1));\n\n let mut ans = vec![ModInt::new(0); N];\n let mut coef = vec![ModInt::new(0); N];\n for i in k..n + 1 {\n coef[i] = fac[n] * invfac[n - i] * invfac[i];\n }\n for j in 0..N {\n let mut pp = p[j].pow(k as i64);\n let mut qp = q[j].pow((n - k) as i64);\n let mut qinv = q[j].inv();\n for i in k..n + 1 {\n let coef = coef[i];\n ans[j] += pp * qp * coef;\n pp *= p[j];\n qp *= qinv;\n }\n }\n transform(&mut ans, zeta.inv(), ModInt::new(1));\n // eprintln!(\"ans = {:?}\", &ans[0..10]);\n let mut tot = ModInt::new(0);\n for i in 0..2 * n + 1 {\n tot += ans[i] * ModInt::new((i + 1) as i64).inv();\n }\n tot *= ModInt::new(N as i64).inv();\n puts!(\"{}\\n\", tot * l);\n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c749ad3b2365dbefd5752761014fbf4e", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 998_244_353;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\n/* \nimpl std::fmt::Display for ModInt {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n*/\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n self.pow(MOD - 2)\n }\n pub fn comb(n: u32, k: u32) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n let k = std::cmp::min(k, n - k);\n let mut nu = ModInt::one();\n let mut de = ModInt::one();\n for i in 0..k {\n nu *= ModInt(n - i);\n de *= ModInt(i + 1);\n }\n nu * de.inv()\n }\n}\n\n#[allow(dead_code)]\nstruct Precalc {\n inv: Vec,\n fact: Vec,\n ifact: Vec,\n}\n\n#[allow(dead_code)]\nimpl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);\n fact[i] = fact[i - 1] * ModInt(i as u32);\n ifact[i] = ifact[i - 1] * inv[i];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n}\n// ---------- end ModInt ----------\n\nfn run() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut it = s.trim().split_whitespace();\n let n: usize = it.next().unwrap().parse().unwrap();\n let k: usize = it.next().unwrap().parse().unwrap();\n let l: u32 = it.next().unwrap().parse().unwrap();\n let pc = Precalc::new(2 * n + 1);\n let mut dp = vec![ModInt::zero(); 2 * n + 1];\n dp[0] = ModInt::one();\n for i in 0..n {\n for j in (0..=(2 * i)).rev() {\n let p = dp[j];\n dp[j + 2] -= ModInt(2) * p;\n dp[j + 1] += ModInt(2) * p;\n dp[j] = ModInt(0);\n }\n }\n let mut ans = ModInt::zero();\n for i in (k..=n).rev() {\n let mut eval = ModInt::zero();\n for j in 0..=(2 * n) {\n eval += dp[j] * pc.inv(j + 1)\n }\n ans += pc.comb(n, i) * eval;\n let f = ModInt(2).inv();\n let mut next = vec![ModInt::zero(); 2 * n + 1];\n for j in (2..=(2 * n)).rev() {\n let v = dp[j];\n dp[j - 1] += v;\n next[j - 2] = -v * f;\n }\n dp = next;\n for j in (0..=(2 * (n - 1))).rev() {\n let v = dp[j];\n dp[j + 2] += ModInt(2) * v;\n dp[j + 1] -= ModInt(2) * v;\n }\n }\n ans *= ModInt(l);\n println!(\"{}\", ans.0);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "cc08cf3b5bbaf8273eba8e5abcf05fe3", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0} {"lang": "Rust", "source_code": "/*\n *\n * Author : fcbruce \n *\n * Time : Sat 10 Feb 2018 19:40:59\n *\n */\n\nfn check(x: i32, y: i32, z: i32) -> bool {\n return x < y && y < z && x + y > z;\n}\n\nfn main() {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).unwrap();\n\n let n: i32 = buffer.trim().parse::().unwrap() + 1;\n\n let mut sum = 0;\n\n for x in 1..n {\n for y in 1..x {\n let z = x ^ y;\n if z < n && check(y, x, z) {\n sum += 1;\n }\n }\n }\n\n println!(\"{}\", sum);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7a8ca7686ae82c068a66588da242f203", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Rust", "source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(\n &mut std::io::stdin(),\n &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n () => (get().parse::().unwrap());\n ($t:ty) => (get().parse::<$t>().unwrap());\n }\n \n let n = get!();\n let mut ans = 0;\n for a in 1..n+1 {\n for b in a..n+1 {\n let c = a ^ b;\n if c >= b && c <= n && a + b > c {\n // println!(\"{} {} {}\", a, b, c);\n ans += 1;\n }\n }\n }\n \n println!(\"{}\", ans);\n \n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f97c38b628106936f8e35eb2d5454bd9", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "Rust", "source_code": "use std::io::{self, Read};\nuse std::cmp;\n\nstatic M: i64 = 1000_000_007;\n\nfn exponentiate( base: i64, mut exponent: i64 ) -> i64 {\n let mut ans = 1;\n let mut accum = base;\n while exponent != 0 {\n if exponent & 1 != 0 {\n ans = (ans * accum) % M;\n }\n accum = (accum * accum) % M;\n exponent = exponent >> 1;\n }\n ans\n}\n\nfn main() -> () {\n \n let mut buffer = String::new();\n \n {\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n handle.read_to_string(&mut buffer).expect(\"stdin\");\n }\n \n let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n\n let n = arr[0];\n let m = arr[1];\n\n let ans = exponentiate((exponentiate(2,m)-1+M)%M,n);\n \n println!(\"{}\",ans);\n\n}\n\n#[test]\nfn test(){\n assert_eq!(27, exponentiate(3,3));\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1c64712be033cd4a0d84b04559312fa5", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "Rust", "source_code": "use std::io::BufRead;\n\nconst MOD: i64 = 1_000_000_007;\n\nfn power(a: i64, p: i64) -> i64 {\n if p == 0 {\n return 1;\n }\n let mut res = power(a, p / 2);\n res = (res * res) % MOD;\n if p % 2 != 0 {\n res = (res * a) % MOD;\n }\n res\n}\n\nfn solve(n: i64, m: i64) -> i64 {\n power((power(2, m) + MOD - 1) % MOD, n)\n}\n\nfn main() {\n let stdin = std::io::stdin();\n let mut handle = stdin.lock();\n let mut buf = String::new();\n handle.read_line(&mut buf).unwrap();\n let mut it = buf.split_whitespace();\n let (n, m): (i64, i64) = (\n it.next().unwrap().parse().unwrap(),\n it.next().unwrap().parse().unwrap(),\n );\n println!(\"{}\", solve(n, m));\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n #[test]\n fn test_power() {\n assert_eq!(power(0, 0), 1);\n assert_eq!(power(2, 1), 2);\n assert_eq!(power(2, 2), 4);\n assert_eq!(power(2, 3), 8);\n }\n\n #[test]\n fn test_solve() {\n assert_eq!(solve(1, 3), 7);\n assert_eq!(solve(2, 2), 9);\n assert_eq!(solve(1_000_000_000, 1_000_000_000), 751201557);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "62db6b605795192797e760428c85fd3b", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 1_000_000_007;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\n/* \nimpl std::fmt::Display for ModInt {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n*/\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n self.pow(MOD - 2)\n }\n pub fn comb(n: u32, k: u32) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n let k = std::cmp::min(k, n - k);\n let mut nu = ModInt::one();\n let mut de = ModInt::one();\n for i in 0..k {\n nu *= ModInt(n - i);\n de *= ModInt(i + 1);\n }\n nu * de.inv()\n }\n}\n\n#[allow(dead_code)]\nstruct Precalc {\n inv: Vec,\n fact: Vec,\n ifact: Vec,\n}\n\n#[allow(dead_code)]\nimpl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);\n fact[i] = fact[i - 1] * ModInt(i as u32);\n ifact[i] = ifact[i - 1] * inv[i];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n}\n// ---------- end ModInt ----------\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// \u3053\u3053\u307e\u3067\n\nfn run() {\n input! {\n n: u32,\n m: u32,\n }\n let ans = (ModInt(2).pow(m) - ModInt(1)).pow(n);\n println!(\"{}\", ans.0);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "de19c0ce77f38e9909469b3ca220d427", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "Rust", "source_code": "//! http://codeforces.com/contest/682/problem/A\n\n#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(isize);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\n// -----------------------------------------------------------------------------\n\nfn main() {\n scanln!(n: u64, m: u64);\n let (nt, nb) = (n / 5, n % 5);\n let (mt, mb) = (m / 5, m % 5);\n let mut add_to_five = 0;\n for i in 1..6 {\n let nf = nt + if i <= nb { 1 } else { 0 };\n let mf = mt + if i != 5 && 5 - i <= mb { 1 } else { 0 };\n add_to_five += nf * mf;\n }\n println!(\"{}\", add_to_five);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7e7b04e1ac863a4a89981027ae07ac28", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: i64 = scan.token();\n let m: i64 = scan.token();\n let mut ans: i64 = 0;\n for x in 1..=n {\n // How many multiples of 5 minus x are there in [1, m]?\n ans += (m + x) / 5 - (x + 5) / 5 + 1;\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "452a54d557f8875505c203a8f1348d02", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn gcd(a: u64, b: u64) -> u64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn lcm(a: u64, b: u64) -> u64 {\n if a == 0 || b == 0 {\n a + b\n } else {\n a / gcd(a, b) * b\n }\n}\n\nfn run() {\n input! {\n w: u64,\n c: [u64; 8],\n }\n let m = (1..=8).fold(0, |s, a| lcm(s, a));\n let mut ans = 0;\n let mut w = w;\n let mut c = c;\n for (i, c) in c.iter_mut().enumerate() {\n let k = (i + 1) as u64;\n let q = *c / (m / k);\n *c %= m / k;\n let d = std::cmp::min(w / m * m, q * m / k);\n ans += d;\n w -= d;\n }\n if w >= 8 * m {\n ans += c.iter().enumerate().fold(0, |s, (i, c)| s + (i + 1) as u64 * c);\n } else {\n let w = w as usize;\n let mut dp = vec![false; w + 1];\n dp[0] = true;\n for (i, &c) in c.iter().enumerate() {\n let k = i + 1;\n for _ in 0..c {\n for j in (k..=w).rev() {\n dp[j] |= dp[j - k];\n }\n }\n }\n ans += dp.iter().rposition(|p| *p).unwrap() as u64;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1c533cb3f21793edea2d0ec90c05859c", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn gcd(a: u64, b: u64) -> u64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn lcm(a: u64, b: u64) -> u64 {\n if a == 0 || b == 0 {\n a + b\n } else {\n a / gcd(a, b) * b\n }\n}\n\nfn run() {\n input! {\n w: u64,\n c: [u64; 8],\n }\n let m = (1..=8).fold(0, |s, a| lcm(s, a));\n let mut ans = 0;\n let mut w = w;\n let mut c = c;\n for (i, c) in c.iter_mut().enumerate() {\n let k = (i + 1) as u64;\n let v = m / k;\n let q = *c / v;\n let d = std::cmp::min(w / m * m, q * v * k);\n ans += d;\n w -= d;\n *c -= d / k;\n if *c > v {\n *c = v;\n }\n }\n println!(\"{} {}\", ans, w);\n if w >= 8 * m {\n ans += c.iter().enumerate().fold(0, |s, (i, c)| s + (i + 1) as u64 * c);\n } else {\n let w = w as usize;\n let mut dp = vec![false; w + 1];\n dp[0] = true;\n for (i, &c) in c.iter().enumerate() {\n print!(\"{} \", c);\n let k = i + 1;\n for _ in 0..c {\n for j in (k..=w).rev() {\n dp[j] |= dp[j - k];\n }\n }\n println!();\n }\n ans += dp.iter().rposition(|p| *p).unwrap() as u64;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "0451797fdd97026cc8fc5af6be8537ad", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn gcd(a: u64, b: u64) -> u64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn lcm(a: u64, b: u64) -> u64 {\n if a == 0 || b == 0 {\n a + b\n } else {\n a / gcd(a, b) * b\n }\n}\n\nfn run() {\n input! {\n w: u64,\n c: [u64; 8],\n }\n let m = (1..=8).fold(0, |s, a| lcm(s, a));\n let mut ans = 0;\n let mut w = w;\n let mut c = c;\n for (i, c) in c.iter_mut().enumerate() {\n let k = (i + 1) as u64;\n let v = m / k;\n let q = *c / v;\n *c %= v;\n let d = std::cmp::min(w / m * m, q * v * k);\n ans += d;\n w -= d;\n }\n if w >= 8 * m {\n ans += c.iter().enumerate().fold(0, |s, (i, c)| s + (i + 1) as u64 * c);\n } else {\n let w = w as usize;\n let mut dp = vec![false; w + 1];\n dp[0] = true;\n for (i, &c) in c.iter().enumerate() {\n let k = i + 1;\n for _ in 0..c {\n for j in (k..=w).rev() {\n dp[j] |= dp[j - k];\n }\n }\n }\n ans += dp.iter().rposition(|p| *p).unwrap() as u64;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "85fc8ad59babcc8143e0ddd0197db6f4", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn gcd(a: u64, b: u64) -> u64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn lcm(a: u64, b: u64) -> u64 {\n if a == 0 || b == 0 {\n a + b\n } else {\n a / gcd(a, b) * b\n }\n}\n\nfn run() {\n input! {\n w: u64,\n c: [u64; 8],\n }\n let m = (1..=8).fold(0, |s, a| lcm(s, a));\n let mut ans = 0;\n let mut w = w;\n let mut c = c;\n for (i, c) in c.iter_mut().enumerate() {\n let k = (i + 1) as u64;\n let v = m / k;\n let q = *c / v;\n let d = std::cmp::min(w / m * m, q * v * k);\n ans += d;\n w -= d;\n *c -= d / k;\n if *c > v {\n *c = v;\n }\n }\n if w >= 8 * m {\n ans += c.iter().enumerate().fold(0, |s, (i, c)| s + (i + 1) as u64 * c);\n } else {\n let w = w as usize;\n let mut dp = vec![false; w + 1];\n dp[0] = true;\n for (i, &c) in c.iter().enumerate() {\n let k = i + 1;\n for _ in 0..c {\n for j in (k..=w).rev() {\n dp[j] |= dp[j - k];\n }\n }\n println!();\n }\n ans += dp.iter().rposition(|p| *p).unwrap() as u64;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "a75764022f52a86efecbac3bf9389d15", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::io;\nuse std::cmp::{min, max};\nuse std::mem;\nuse std::str::FromStr;\nuse std::cmp::Ordering;\nuse std::collections::BinaryHeap;\n\npub struct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Scanner {\n Scanner {\n reader: reader,\n buffer: Vec::new(),\n }\n }\n\n /// Use \"turbofish\" syntax next::() to select data type of next token.\n pub fn next(&mut self) -> T\n where\n T::Err: ::std::fmt::Debug,\n {\n if let Some(front) = self.buffer.pop() {\n front.parse::().expect(&front)\n } else {\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Line not read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n self.next()\n }\n }\n\n pub fn next_vec(&mut self, len: usize) -> Vec\n where\n T::Err: ::std::fmt::Debug,\n {\n (0..len).map(|_| self.next::()).collect::>()\n }\n}\n\n#[derive(Copy, Clone, Eq, PartialEq, Debug)]\nstruct ReverseInt(i64);\n\nimpl Ord for ReverseInt {\n fn cmp(&self, other: &ReverseInt) -> Ordering {\n other.0.cmp(&self.0)\n }\n}\n\nimpl PartialOrd for ReverseInt {\n fn partial_cmp(&self, other: &ReverseInt) -> Option {\n Some(self.cmp(other))\n }\n}\n\nfn main1() {\n let stdin = io::stdin();\n let mut input = Scanner::new(stdin.lock());\n let n: usize = input.next();\n let mut v: Vec = input.next_vec(n);\n v.sort();\n println!(\"{}\", v[n / 2]);\n}\n\nfn main() {\n std::thread::Builder::new().stack_size(50 << 20)\n .spawn(main1).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b964efc60942d172ab1f3d137a4f38cc", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::io::Read;\n// use std::collections::VecDeque;\n\n\nfn main() {\n let mut input_text = String::new();\n io::stdin().read_to_string(&mut input_text).unwrap();\n let mut iter = input_text.split_whitespace().map(|x| x.parse::().unwrap());\n let n = iter.next().unwrap();\n let k = iter.next().unwrap();\n let mut ans = n / k * k;\n while ans <= n {\n ans += k\n }\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "8c089abccb211b3568af8519172087d8", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn run() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut it = s.trim().split_whitespace();\n let n: u64 = it.next().unwrap().parse().unwrap();\n let k: u64 = it.next().unwrap().parse().unwrap();\n let ans = n / k * k + k;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "83e79635f4b2b9de60f877ee12720cc0", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn gcd(a: u64, b: u64) -> u64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let mut ans: u64;\n if n == 1 {\n ans = 1;\n } else if n == 2 {\n ans = 2;\n } else if n == 3 {\n ans = 6;\n } else {\n // pick n and n - 1, find another number coprime to both\n ans = n * (n - 1);\n for p in (1..(n - 1)).rev() {\n if gcd(n, p) == 1 && gcd(n - 1, p) == 1 {\n ans *= p;\n break;\n }\n }\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e260c6d12704be955faa5b4a0bf281f0", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let ans: u64;\n if n == 1 {\n ans = 1;\n }\n else if n == 2 {\n ans = 2;\n }\n else if n == 3 {\n ans = 6;\n }\n else if n % 2 == 0 {\n let a = n - 1;\n let b = n - 2;\n let c = n - 3;\n ans = a * b * c;\n }\n else {\n let a = n;\n let b = n - 1;\n let c = n - 2;\n ans = a * b * c;\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "aa0b0fa6512ceac2c05f1955bfd25709", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nuse std::cmp::{min,max};\n\nfn main() {\n let a = {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n input.trim().chars().map(|k| k.to_digit(10).unwrap()).collect::>()\n };\n\n let la: Vec<_> = a.iter().cloned().take(3).collect();\n let ra: Vec<_> = a.iter().cloned().skip(3).collect();\n\n let l: u32 = a.iter().cloned().take(3).sum();\n let r: u32 = a.iter().cloned().skip(3).sum();\n\n let diff = r as i32 - l as i32;\n\n if diff == 0 {\n println!(\"0\");\n std::process::exit(0);\n }\n\n let (mut up, mut down) = if diff > 0 {\n (ra, la)\n } else {\n (la, ra)\n };\n\n let mut v = Vec::new();\n v.append(&mut up);\n v.append(&mut down);\n\n for a in v.iter_mut().skip(3) {\n *a = 9 - *a;\n }\n\n let diff = diff.abs();\n\n let mut sum = 0u32;\n\n for (i, k) in v.into_iter().rev().enumerate() {\n if sum >= diff as u32 {\n println!(\"{}\", i);\n std::process::exit(0);\n }\n sum += k;\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c662a6901db3a6914b6c859c673825a9", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Read, Write, BufWriter};\n#[allow(dead_code)]\nfn getline() -> String {\n let mut ret = String::new();\n std::io::stdin().read_line(&mut ret).ok().unwrap();\n ret\n}\nfn get_word() -> String {\n let mut stdin = std::io::stdin();\n let mut u8b: [u8; 1] = [0];\n loop {\n let mut buf: Vec = Vec::with_capacity(16);\n loop {\n let res = stdin.read(&mut u8b);\n if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {\n break;\n } else {\n buf.push(u8b[0]);\n }\n }\n if buf.len() >= 1 {\n let ret = String::from_utf8(buf).unwrap();\n return ret;\n }\n }\n}\n\n#[allow(dead_code)]\nfn get() -> T { get_word().parse().ok().unwrap() }\n\nfn solve() {\n let out = std::io::stdout();\n let mut out = BufWriter::new(out.lock());\n macro_rules! puts {\n ($format:expr) => (write!(out,$format).unwrap());\n ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())\n }\n let s: Vec = get_word().bytes().map(|x| x as i32 - 48).collect();\n let mut mi = 144;\n for mut v in 0 .. 1000000 {\n let mut t = [0; 6];\n for j in 0 .. 6 {\n t[5 - j] = v % 10;\n v /= 10;\n }\n let mut delta = 0;\n for j in 0 .. 3 { delta += t[j]; }\n for j in 3 .. 6 { delta -= t[j]; }\n let mut diff = 0;\n for j in 0 .. 6 {\n diff += if s[j] != t[j] { 1 } else { 0 };\n }\n if delta == 0 {\n mi = min(mi, diff);\n }\n }\n puts!(\"{}\\n\", mi);\n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "751bfbf3da40b9ec46ba957404a379cd", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nuse std::cmp::{min,max};\n\nfn main() {\n let a = {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n input.trim().chars().map(|k| k.to_digit(10).unwrap()).collect::>()\n };\n\n let la: Vec<_> = a.iter().cloned().take(3).collect();\n let ra: Vec<_> = a.iter().cloned().skip(3).collect();\n\n let l: u32 = a.iter().cloned().take(3).sum();\n let r: u32 = a.iter().cloned().skip(3).sum();\n\n let diff = r as i32 - l as i32;\n\n if diff == 0 {\n println!(\"0\");\n std::process::exit(0);\n }\n\n let (mut up, mut down) = if diff > 0 {\n (ra, la)\n } else {\n (la, ra)\n };\n\n let mut v = Vec::new();\n v.append(&mut up);\n v.append(&mut down);\n\n for a in v.iter_mut().skip(3) {\n *a = 9 - *a;\n }\n\n v.sort();\n\n let diff = diff.abs();\n\n let mut sum = 0u32;\n\n for (i, k) in v.into_iter().rev().enumerate() {\n if sum >= diff as u32 {\n println!(\"{}\", i);\n std::process::exit(0);\n }\n sum += k;\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "fdb5d7b81863c09788789483698dbf22", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io::{self, Read};\n\nfn main() -> () {\n\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n handle.read_to_string(&mut buffer).expect(\"stdin\");\n\n let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n\n let n = arr[0] as usize;\n let m = arr[1];\n\n let max_seats = arr.iter().skip(2).max().unwrap();\n let min_seats = arr.iter().skip(2).min().unwrap();\n\n println!(\"{} {}\", min_seats, max_seats + m );\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2516685c9c4ca5d818053c61cc0e1c74", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// \u3053\u3053\u307e\u3067\n\nfn run() {\n input! {\n n: usize,\n m: usize,\n a: [usize; n],\n }\n let max = *a.iter().max().unwrap() + m;\n let mut a = a;\n for _ in 0..m {\n let mut min = (1000000, 0);\n for (i, a) in a.iter().enumerate() {\n min = std::cmp::min(min, (*a, i));\n }\n a[min.1] += 1;\n }\n let min = *a.iter().max().unwrap();\n println!(\"{} {}\", min, max);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c9e14915edc2b03c48533e683b157461", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io::{self, Read};\n\nfn main() -> () {\n\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n handle.read_to_string(&mut buffer).expect(\"stdin\");\n\n let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n\n let n = arr[0];\n let m = arr[1];\n\n let max_seats = arr.iter().skip(2).max().unwrap();\n let s = arr.iter().skip(2).sum::();\n let b = (s + m)/n + if (s+m) % n != 0 { 1 } else { 0 };\n\n use std::cmp;\n \n println!(\"{} {}\", cmp::max( max_seats, &b ), max_seats + m );\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "0416e40cd0d3829b7abb1a31a291d76a", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "Rust", "source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(\n &mut std::io::stdin(),\n &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n () => (get!(i64));\n ($t:ty) => (get().parse::<$t>().unwrap());\n }\n \n let n = get!() + 1;\n let ans;\n if n == 1 {\n ans = 0;\n } else if n % 2 == 0 {\n ans = n / 2;\n } else {\n ans = n;\n }\n \n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7f58f36e30aa34fe88ca6779a610c103", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\nstruct Prng {\n a: i32,\n b: i32,\n m: i32,\n}\n\nimpl Prng {\n pub fn new(a: i32, b: i32, m: i32) -> Self {\n Self { a: a, b: b, m: m }\n }\n \n pub fn next(&self, r: i32) -> i32 {\n (self.a * r + self.b) % self.m \n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: i32 = scan.token();\n let b: i32 = scan.token();\n let m: i32 = scan.token();\n let r0: i32 = scan.token();\n\n let gen = Prng::new(a, b, m);\n let mut slow = r0;\n let mut fast = r0;\n loop {\n slow = gen.next(slow);\n fast = gen.next(gen.next(fast));\n if slow == fast {\n break;\n }\n }\n slow = r0;\n while slow != fast {\n slow = gen.next(slow);\n fast = gen.next(fast);\n }\n let mut period = 0;\n loop {\n slow = gen.next(slow);\n period += 1;\n if slow == fast {\n break;\n }\n }\n writeln!(out, \"{}\", period).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n\n pub fn tokens(&mut self) -> Vec {\n assert!(self.buffer.is_empty());\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n input\n .split_whitespace()\n .map(|x| x.parse().ok().expect(\"Failed parse\"))\n .collect()\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b9dfb3386f037f6a027eba49f1231a86", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::cmp::max;\n\ntrait Substring {\n fn substring(&self, start: i32, len: i32) -> String;\n}\n\nimpl Substring for String {\n\n fn substring(&self, start: i32, len: i32) -> String {\n self.chars().skip(start as usize).take(len as usize).collect()\n }\n}\n\nfn main() {\n\n let mut n: String = String::new();\n let mut inp: String = String::new();\n\n io::stdin().read_line(&mut n).unwrap();\n io::stdin().read_line(&mut inp).unwrap();\n\n let n: i32 = n.trim().parse().unwrap();\n\n let mut ans: Vec<_> = (0..n/2+1).filter(|&i: &i32| -> bool {\n inp.substring(0, i) == inp.substring(i, i)\n }).collect();\n\n let ans: i32 = ans.pop().unwrap();\n let display: i32 = n - max(ans-1, 0); \n\n println!(\"{}\", display);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7193e99de0bb99666fd44a066f2c0f5f", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "Rust", "source_code": "/* This code was written by\nRussell Emerine - linguist,\nmathematician, coder,\nmusician, and metalhead. */\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec,\n}\n\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scanner = Scanner::default();\n let braille: std::collections::HashMap, char> = vec![\n (vec![1, 0, 0, 1, 0], 'a'),\n (vec![1, 1, 0, 2, 0], 'b'),\n (vec![2, 0, 0, 1, 1], 'c'),\n (vec![2, 1, 0, 1, 2], 'd'),\n (vec![1, 1, 0, 1, 1], 'e'),\n (vec![2, 1, 0, 2, 1], 'f'),\n (vec![2, 2, 0, 2, 2], 'g'),\n (vec![1, 2, 0, 2, 1], 'h'),\n (vec![1, 2, 0, 1, 2], 'j'),\n (vec![1, 0, 1, 2, 0], 'k'),\n (vec![1, 1, 1, 3, 0], 'l'),\n (vec![2, 0, 1, 2, 1], 'm'),\n (vec![2, 1, 1, 2, 2], 'n'),\n (vec![1, 1, 1, 2, 1], 'o'),\n (vec![2, 1, 1, 3, 1], 'p'),\n (vec![2, 2, 1, 3, 2], 'q'),\n (vec![1, 2, 1, 3, 1], 'r'),\n (vec![1, 2, 1, 2, 2], 't'),\n (vec![1, 0, 2, 2, 1], 'u'),\n (vec![1, 1, 2, 3, 1], 'v'),\n (vec![2, 0, 2, 2, 2], 'x'),\n (vec![2, 1, 2, 2, 3], 'y'),\n (vec![1, 1, 2, 2, 2], 'z'),\n ]\n .into_iter()\n .collect();\n let n = scanner.next();\n println!(\n \"{}\",\n (0..n)\n .map(\n |_| braille[&(0..5).map(|_| scanner.next::()).collect::>()]\n .to_string()\n )\n .collect::>()\n .join(\"\")\n )\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7f6b75d059c7fa8911cd37a9906ae591", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "Rust", "source_code": "use std::io::Write;\n\npub struct Scanner {\n buffer: Vec\n}\n\nimpl Scanner {\n pub fn new() -> Scanner {\n Scanner { buffer: Vec::new() }\n }\n\n pub fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn calculate(n: usize, g: &Vec>, p: &Vec) -> i32 {\n let mut found: [[bool; 6]; 6] = [[false; 6]; 6];\n let mut ans: i32 = 0;\n for u in 0..n {\n for &v in g[u].iter() {\n let u = p[u];\n let v = p[v];\n if !found[u][v] {\n found[u][v] = true;\n found[v][u] = true;\n ans += 1;\n }\n }\n }\n return ans;\n}\n\nfn gen(d: usize, n: usize, g: &Vec>, p: &mut Vec) -> i32 {\n if d == n {\n return calculate(n, g, p);\n }\n let mut ans: i32 = 0;\n for x in 0..6 {\n p[d] = x;\n ans = std::cmp::max(ans, gen(d + 1, n, g, p));\n }\n return ans;\n}\n\nfn main() {\n let stdout = std::io::stdout();\n let mut out = std::io::BufWriter::new(stdout.lock());\n let mut scan = Scanner::new();\n\n let n: usize = scan.next();\n let m: usize = scan.next();\n let mut g: Vec> = vec![vec![]; n];\n for _ in 0..m {\n let u: usize = scan.next();\n let v: usize = scan.next();\n g[u - 1].push(v - 1);\n g[v - 1].push(u - 1);\n }\n let mut p: Vec = vec![0; n];\n let ans = gen(0, n, &g, &mut p);\n writeln!(out, \"{}\", ans).unwrap();\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "d943ac560f4ecccfaa9587b5017476de", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0} {"lang": "Rust", "source_code": "fn main(){\nprintln!(\"No\");\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "710041a73ae2dfad72fb9ce7e33bfbd3", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "Rust", "source_code": "fn main() {\n println!(\"No\");\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "065b0b4672ad0ad7d3cbe45012fee87f", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "Rust", "source_code": "use std::io::{self, Read};\nuse std::str::FromStr;\nuse std::fmt::Debug;\nuse std::vec::IntoIter;\nuse std::cmp::{max, min};\n\nstruct InputReader {\n tokens: IntoIter\n}\n\nimpl InputReader {\n fn new() -> InputReader {\n let mut input = String::new();\n io::stdin().read_to_string(&mut input).unwrap();\n let tokens: Vec = input.split_whitespace().map(|a| a.to_string()).collect();\n InputReader {\n tokens: tokens.into_iter()\n }\n }\n\n fn next(&mut self) -> String {\n self.tokens.next().unwrap()\n }\n\n fn next_val(&mut self) -> V {\n self.next().parse::().ok().unwrap()\n }\n\n fn next_val_array(&mut self, n: usize) -> Vec {\n let mut vec = Vec::with_capacity(n);\n for _ in 0..n {\n vec.push(self.next_val::());\n }\n vec\n }\n}\n\n\nfn main() {\n let mut reader = InputReader::new();\n let n: i64 = reader.next_val();\n let mut answer = (0i64, 0i64);\n let mut diff = i64::max_value();\n for a in 1..(n+1) {\n if n % a == 0 {\n let b = n / a;\n if b >= a && b - a < diff {\n diff = b - a;\n answer = (a, b);\n }\n }\n }\n println!(\"{} {}\", answer.0, answer.1);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "3f149629bc9f1a77e0dd03547fe1cd75", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0} {"lang": "Rust", "source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let n = input.i();\n let is_prime_o = |a: i32| -> bool {\n if a < 3 || a % 2 == 0 {\n return false;\n }\n let sq = ((a as f64).sqrt() + 1.0e-6) as i32;\n for i in 3..=sq {\n if a % i == 0 {\n return false;\n }\n }\n return true;\n };\n let print_exit = |sol: &[i32]| -> ! {\n println!(\"{}\", sol.len());\n for &a in sol {\n print!(\"{} \", a);\n }\n std::process::exit(0);\n };\n\n if is_prime_o(n) {\n print_exit(&[n]);\n } else {\n const X: usize = 100;\n let mut pairs = vec![None; X];\n for i in 3..X/2 {\n if is_prime_o(i as i32) {\n for j in i..X/2 {\n if is_prime_o(j as i32) {\n pairs[i + j] = Some((i as i32, j as i32));\n }\n }\n }\n }\n let pairs = pairs;\n for i in 6.. {\n assert!(i < X as i32);\n if let Some((a, b)) = pairs[i as usize] {\n if i < n && is_prime_o(n - i) {\n print_exit(&[a, b, n - i]);\n }\n }\n }\n }\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "5c7751712ff8866844637905e35401c4", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "Rust", "source_code": "//spnauti-rusT {{{\nuse std::io::*; use std::str::{self,*}; use std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)] macro_rules! m {\n\t($c:tt,$x:expr,$y:expr) => {{\n\t\tlet b=$y; let a=&mut$x; if b$c*a {*a=b; true} else {false}\n\t}};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};\n\t($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};\n\t(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: Vec::new(), pos: 0 }\n\t}\n\tfn next_line(&mut self) -> bool {\n\t\tself.buf.clear(); self.pos = 0;\n\t\tself.q.read_until(b'\\n', &mut self.buf).unwrap_or(0) > 0\n\t}\n\tfn is_ws(c: u8) -> bool {\n\t\tc == b' ' || c == b'\\r' || c == b'\\n' || c == b'\\t'\n\t}\n\tfn byte(&mut self) -> Option {\n\t\tif self.pos == self.buf.len() { if !self.next_line() { return None; } }\n\t\tself.pos += 1; Some(self.buf[self.pos - 1])\n\t}\n\tfn vb(&mut self) -> Vec {\n\t\tlet mut s = Vec::with_capacity(8);\n\t\tlet mut f = false;\n\t\tloop {\n\t\t\tif let Some(c) = self.byte() {\n\t\t\t\tif !Self::is_ws(c) {\n\t\t\t\t\ts.push(c);\n\t\t\t\t\tf = true;\n\t\t\t\t} else if f { break; }\n\t\t\t} else { break; }\n\t\t}\n\t\ts\n\t}\n\tfn s(&mut self) -> String { String::from_utf8(self.vb()).expect(\"invalid utf8\") }\n\tfn i(&mut self) -> i32 { self.p() }\n\tfn l(&mut self) -> i64 { self.p() }\n\tfn u(&mut self) -> usize { self.p() }\n\tfn f(&mut self) -> f64 { self.p() }\n\tfn vi(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vl(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vu(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn ii(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn iu(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn p(&mut self) -> T where T::Err: Debug {\n\t\tlet w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::().unwrap()\n\t}\n\tfn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n\t\t(0..n).map(|_|self.p()).collect()\n\t}\n\tfn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n\t\tself.vp(n).into_iter()\n\t}\n}\n//------------------- End rusT }}}\n\n// Mint (mod any) {{{\nmod mint {\n\tuse std::ops::*;\n\t#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Default)] pub struct Mint(i32,i32);\n\t#[allow(dead_code)] impl Mint {\n\t\tpub fn new>(a: T, m: T) -> Self { Self(Self::cv(a,m),m.into() as i32) }\n\t\tpub unsafe fn new_unchecked(a: i32, m: i32) -> Self { Self(a,m) }\n\t\tfn hi(mut a: i32, m: i32) -> i32 { if a >= m { a -= m; } a }\n\t\tfn lo(mut a: i32, m: i32) -> i32 { if a < 0 { a += m; } a }\n\t\tfn cv>(a: T, m: T) -> i32 { Self::lo((a.into() % m.into()) as i32, m.into() as i32) }\n\t\tpub unsafe fn inv(self) -> Self { self.pow(self.1-2) } // ONLY FOR PRIMES!\n\t\tpub fn pow>(self, b: T) -> Self {\n\t\t\tlet b = b.into(); if b == 0 { Self(1,self.1) } else {\n\t\t\t\tlet mut res = self.pow(b/2); res *= res; if b % 2 == 1 {res *= self;} res\n\t\t\t}\n\t\t}\n\t}\n\timpl Add for Mint { type Output = Self; fn add(self, a: Self) -> Self::Output { assert!(self.1==a.1); Self(Self::hi(self.0 + a.0, self.1), self.1) }}\n\timpl Sub for Mint { type Output = Self; fn sub(self, a: Self) -> Self::Output { assert!(self.1==a.1); Self(Self::lo(self.0 - a.0, self.1), self.1) }}\n\timpl Mul for Mint { type Output = Self; fn mul(self, a: Self) -> Self::Output { assert!(self.1==a.1); Self(Self::cv(self.0 as i64 * a.0 as i64, self.1 as i64), self.1) }}\n\timpl Div for Mint { type Output = Self; fn div(self, a: Self) -> Self::Output { self * unsafe {a.inv()} }}\n\timpl Neg for Mint { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0, self.1), self.1) }}\n\timpl AddAssign for Mint { fn add_assign(&mut self, a: Self) { *self = *self + a; } }\n\timpl SubAssign for Mint { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }\n\timpl MulAssign for Mint { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }\n\timpl DivAssign for Mint { fn div_assign(&mut self, a: Self) { *self = *self / a; } }\n\tuse std::fmt::{Display, Formatter, Result};\n\timpl Display for Mint { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, \"{}\", self.0) } }\n}\nuse mint::Mint;\n//}}}\n// Square Matrix (any) {{{\ntype MatT = Mint;\n#[derive(Debug,Clone)] struct Mat { n: usize, a: Vec, v0: MatT, v1: MatT }\n#[allow(dead_code)] impl Mat {\n\tfn new(n:usize,v0:MatT,v1:MatT)->Self{Self{n,a:vec![v0;n*n],v0,v1}}\n\tfn diag(n:usize,v0:MatT,v1:MatT,v:MatT)->Self{let mut m=Self::new(n,v0,v1);let mut p=0;for _ in 0..n{m.a[p]=v;p+=n+1;}m}\n\tfn pow(&self,n:u64)->Self{if n==0{Self::diag(self.n,self.v0,self.v1,self.v1)}else{let mut t=self.pow(n/2);t*=t.clone();if n%2==1{t*=self.clone();}t}}\n\tfn range(&self,r:Range,c:Range)->Vec>{if r.startMatT{self.a[r*self.n+c]}\n\tfn at_mut<'a>(&'a mut self,r:usize,c:usize)->&'a mut MatT{&mut self.a[r*self.n+c]}//'\n}\nimpl Mul for Mat{type Output=Self;fn mul(self,o:Self)->Self::Output{assert!(self.n==o.n);let n=self.n;let mut res=Self::new(n,self.v0,self.v1);\n\tfor ii in(0..n).map(|i|i*n){for j in 0..n{let mut t=self.v0;let mut kk=j;for k in 0..n{t+=self.a[ii+k]*o.a[kk];kk+=n;}res.a[ii+j]=t;}}res}}\nimpl Add for Mat{type Output=Self;fn add(mut self,o:Self)->Self{self+=o;self}}\nimpl Sub for Mat{type Output=Self;fn sub(mut self,o:Self)->Self{self-=o;self}}\nimpl MulAssign for Mat{fn mul_assign(&mut self,a:Self){*self=self.clone()*a;}}\nimpl AddAssign for Mat{fn add_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x+=y;}} }\nimpl SubAssign for Mat{fn sub_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x-=y;}} }\nimpl PartialEq for Mat{fn eq(&self,o:&Self)->bool{self.n==o.n&&self.a==o.a}}impl Eq for Mat{}\n// }}}\n\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tl!(n,k,l,m = rin.l());\n\tif l <= 60 && k >= 1 << l {\n\t\twriteln!(rout, \"0\").ok();\n\t\treturn;\n\t}\n\tlet m0 = Mint::new(0,m);\n\tlet m1 = Mint::new(1,m);\n\n\tlet b1 = k.count_ones() as i64;\n\tlet b0 = l - b1;\n\tlet mut f = Mat::new(2,m0,m1);\n\t*f.at_mut(0,0) = m0;\n\t*f.at_mut(0,1) = m1;\n\t*f.at_mut(1,0) = m1;\n\t*f.at_mut(1,1) = m1;\n\tlet res_f = f.pow(n as u64 + 2).at(0,1);\n\tlet res_b = Mint::new(2,m).pow(n);\n\tlet sol = (res_b - res_f).pow(b1) * res_f.pow(b0);\n\twriteln!(rout, \"{}\", sol).ok();\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "0559668c096e8cf132f5fbe382f562c2", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "Rust", "source_code": "// {{{ by shik\n\nuse std::io;\n\n#[allow(dead_code)]\nfn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\nmacro_rules! R {\n ( $ty:ty, ... ) => {\n gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap()).collect::>()\n };\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\nmacro_rules! W {\n ( $x:expr ) => {{\n println!(\"{}\", $x);\n }};\n ( $x:expr, $($xs:expr),* ) => {{\n print!(\"{} \", $x);\n W!($($xs),*);\n }}\n}\n\nmacro_rules! debug {\n ( $x:expr ) => {{\n println!(\"{} = {:?}\", stringify!($x), $x);\n }};\n ( $x:expr, $($xs:expr),* ) => {{\n print!(\"{} = {:?}, \", stringify!($x), $x);\n debug!($($xs),*);\n }}\n}\n\n// }}}\n\nfn main() {\n let (n, h) = R!(usize, usize);\n let mut dp = vec![vec![0i64; n + 1]; n + 1];\n dp[0][0] = 1;\n for i in 1..n + 1 {\n for j in 1..i + 1 {\n let mut s = 0i64;\n for k in 1..i + 1 {\n let l = k - 1;\n let r = i - k;\n for jl in 0..j {\n for jr in 0..j {\n if jl == j - 1 || jr == j - 1 {\n s += dp[l][jl] * dp[r][jr];\n }\n }\n }\n }\n dp[i][j] = s;\n }\n }\n let ans = (h..n + 1).fold(0i64, |s, i| s + dp[n][i]);\n W!(ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "4c581591a308f4011b13b2ee9a4eddb6", "src_uid": "faf12a603d0c27f8be6bf6b02531a931", "difficulty": 1900.0} {"lang": "Rust", "source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let mut n = input.i();\n let mut sol = Vec::new();\n while n > 0 {\n let mut t = n;\n let mut res = 0;\n for d in (0..=6).rev().map(|a| 10_i32.pow(a)) {\n let p = t / d;\n if p > 0 {\n t %= d;\n res += d;\n }\n }\n sol.push(res);\n n -= res;\n }\n println!(\"{}\", sol.len());\n for a in sol {\n print!(\"{} \", a);\n }\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "d69ca6a986c88221a208ca8253216d5e", "src_uid": "033068c5e16d25f09039e29c88474275", "difficulty": 1400.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str::FromStr;\nuse std::fmt;\n\nfn not_all_zero(vec: &[u32]) -> bool {\n vec.iter().any(|n| *n != 0)\n}\n\nfn take_row(vec: &mut [u32]) -> u32 {\n let mut n = 0;\n\n for (i, item) in vec.iter_mut().enumerate() {\n if *item > 0 {\n n += 10_u32.pow(i as u32);\n *item -= 1;\n }\n }\n\n n\n}\n\nfn main() {\n let mut n: u32 = read();\n let mut digits = Vec::new();\n\n while n > 0 {\n digits.push(n % 10);\n n /= 10;\n }\n\n let mut nums = Vec::new();\n\n while not_all_zero(&digits) {\n nums.push(take_row(&mut digits));\n }\n\n println!(\"{}\", nums.len());\n println!(\"{}\",\n nums\n .iter()\n .map(|n| n.to_string())\n .collect::>()\n .join(\" \")\n );\n}\n\nfn read_line() -> String {\n let mut pre_n = String::new();\n io::stdin().read_line(&mut pre_n).unwrap();\n pre_n\n}\n\nfn read() -> T\n where ::Err: fmt::Debug\n{\n read_line().trim().parse().unwrap()\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "daec74751b0b76736a3cf81a57333fc4", "src_uid": "033068c5e16d25f09039e29c88474275", "difficulty": 1400.0} {"lang": "Rust", "source_code": "fn read()->Vec{\n let mut line=String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace().map(|x|x.parse::().unwrap()).collect()\n}\nuse std::i32;\nfn main(){\n let vec=read();\n let stairs=i32::abs(vec[0]-vec[1])*vec[3];\n let lift=i32::abs(vec[0]-vec[1])*vec[4]+3*vec[5]+i32::abs(vec[0]-vec[2])*vec[4];\n if lift<=stairs{\n println!(\"YES\");\n }\n else{\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2aa9f4d4361c7bdfebb5cbb9337f15e7", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let mut s = s.split_whitespace();\n let x: i32 = s.next().unwrap().parse().unwrap();\n let y: i32 = s.next().unwrap().parse().unwrap();\n let z: i32 = s.next().unwrap().parse().unwrap();\n let t1: i32 = s.next().unwrap().parse().unwrap();\n let t2: i32 = s.next().unwrap().parse().unwrap();\n let t3: i32 = s.next().unwrap().parse().unwrap();\n if (x - y).abs() * t1 < ((x - z).abs() + (x - y).abs()) * t2 + 3 * t3 {\n println!(\"NO\");\n } else {\n println!(\"YES\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "aede1aac61e8a26eb1e98659c61971f2", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let mut s = s.split_whitespace();\n let x: i32 = s.next().unwrap().parse().unwrap();\n let y: i32 = s.next().unwrap().parse().unwrap();\n let z: i32 = s.next().unwrap().parse().unwrap();\n let t1: i32 = s.next().unwrap().parse().unwrap();\n let t2: i32 = s.next().unwrap().parse().unwrap();\n let t3: i32 = s.next().unwrap().parse().unwrap();\n if (x - y).abs() * t1 < ((x - z).abs() + (x - y).abs()) * t2 + 2 * t3 {\n println!(\"NO\");\n } else {\n println!(\"YES\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b27ef7f49527431a7b5609eb855cbf6e", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet, BinaryHeap};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n#[allow(unused_imports)]\nuse std::io::stdin;\n\nmod util {\n use std::io::stdin;\n use std::str::FromStr;\n use std::fmt::Debug;\n\n #[allow(dead_code)]\n pub fn line() -> String {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().to_string()\n }\n\n #[allow(dead_code)]\n pub fn gets() -> Vec\n where\n ::Err: Debug,\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse().unwrap())\n .collect()\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\nfn main() {\n let (n, k) = get!(u64, u64);\n\n let mut ans = 1;\n\n if k > 1 {\n for i in 2..k + 1 {\n let u = (n - i + 1..n + 1).fold(1, |a, b| a * b);\n let d = (1..i + 1).fold(1, |a, b| a * b);\n\n let c = u / d;\n\n ans += c * [1, 2, 9][(i - 2) as usize];\n }\n }\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "26f315406d92d152240d2beb0731c59b", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "Rust", "source_code": "fn main() {\n let v: Vec = vec![1,0,1,2,9];\n let mut ri = ReadIn::new();\n let tp = ri.int2();\n let mut ans:i64 = 1;\n for kk in 2..tp.1+1 {\n ans += cal(tp.0 as i64, kk as i64) * v[(kk as usize)] ;\n }\n println!(\"{}\", ans)\n}\n\nfn cal(n: i64, k: i64) -> i64{\n let mut up: i64 = 1;\n let mut down: i64 = 1;\n for kk in 0..k {\n up = up * (n - kk);\n down = down * (1 + kk);\n }\n up / down\n}\n\nuse std::iter::Map;\nuse std::str::SplitWhitespace;\nuse std::io::stdin;\nuse std::mem::forget;\n\npub struct ReadIn(pub String);\n\nimpl ReadIn {\n pub fn new() -> ReadIn {\n ReadIn(String::new())\n }\n fn read_i32(s: &str) -> i32 {\n s.parse().unwrap()\n }\n pub fn read_line(&mut self) {\n self.0.clear();\n forget(stdin().read_line(&mut self.0));\n }\n pub fn ints(&mut self) -> Map i32> {\n self.read_line();\n self.0.split_whitespace().map(ReadIn::read_i32)\n }\n pub fn int(&mut self) -> i32 {\n self.ints().next().unwrap()\n }\n pub fn int2(&mut self) -> (i32, i32) {\n let mut it = self.ints();\n (it.next().unwrap(), it.next().unwrap())\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "00ef31291fe4bb4a67ed23480f11a00e", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn egcd(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n return (a, 1, 0);\n }\n let (g, x1, y1) = egcd(b, a % b);\n (g, y1, x1 - (a / b) * y1)\n}\n\nfn ceil_div(num: i64, denom: i64) -> i64 {\n (num + denom - 1).div_euclid(denom)\n}\n\n// Check if the diophantine equation a * x + b * y = c has non-negative solutions.\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: i64 = scan.token();\n let b: i64 = scan.token();\n let c: i64 = scan.token();\n let (g, xg, yg) = egcd(a, b);\n if c % g == 0 {\n let x0 = xg * c / g;\n let y0 = yg * c / g;\n // xk = x0 + k * b / g\n // yk = y0 - k * a / g\n // xk >= 0 and yk >= 0\n // After solving for k:\n let ans = (y0 * g).div_euclid(a) - ceil_div(-x0 * g, b) + 1;\n if ans > 0 {\n writeln!(out, \"Yes\").ok();\n } else {\n writeln!(out, \"No\").ok();\n }\n } else {\n writeln!(out, \"No\").ok();\n }\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1638c580761d4e76f3d1e64a2d82dfad", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Rust", "source_code": "//! https://codeforces.com/contest/633/problem/A\n\nuse std::io;\n\n#[derive(Clone, Copy)]\nstruct Solution(i32, i32);\n\nfn main() {\n let mut inp = String::new();\n io::stdin().read_line(&mut inp).unwrap();\n let mut iter = inp.trim().split_whitespace();\n let a: i32 = iter.next().unwrap().parse().unwrap();\n let b: i32 = iter.next().unwrap().parse().unwrap();\n let c: i32 = iter.next().unwrap().parse().unwrap();\n\n println!(\"{}\", match find_if_poss(a, b, c) {\n true => \"Yes\",\n false => \"No\"\n })\n}\n\nfn gcd(a: i32, b: i32) -> (Solution, i32) {\n if a == 0 {\n (Solution(0, 1), b)\n } else {\n let (Solution(x1, y1), g) = gcd(b % a, a);\n (Solution(y1 - (b / a) * x1, x1), g)\n }\n}\n\nfn find_one(a: i32, b: i32, c: i32) -> Option<(Solution, i32)> {\n let (Solution(x, y), g) = gcd(a.abs(), b.abs());\n if c % g != 0 {\n None\n } else {\n let mult = c / g;\n\n let x = get_sign(a) * mult * x;\n let y = get_sign(b) * mult * y;\n\n Some((Solution(x, y), g))\n }\n}\n\nfn get_sign(i: i32) -> i32 {\n if i < 0 { -1 } else { 1 }\n}\n\nfn shift_solution(sol: Solution, ag: i32, bg: i32, offset: i32) -> Solution {\n Solution(sol.0 + bg * offset, sol.1 - ag * offset)\n}\n\nfn find_if_poss(a: i32, b: i32, c: i32) -> bool {\n match find_one(a, b, c) {\n Some((mut sol, g)) => {\n let sign_a = get_sign(a);\n let sign_b = get_sign(b);\n\n let maxx = c/a;\n let maxy = c/b;\n\n let a = a / g;\n let b = b / g;\n\n let minx_offset = -sol.0/b;\n sol = shift_solution(sol, a, b, minx_offset);\n if sol.0 < 0 {\n sol = shift_solution(sol, a, b, sign_b);\n }\n if sol.0 > maxx {\n return false;\n }\n let lx1 = sol.0;\n\n let maxx_offset = (maxx - sol.0)/b;\n sol = shift_solution(sol, a, b, maxx_offset);\n if sol.0 > maxx {\n sol = shift_solution(sol, a, b, -sign_b);\n }\n let rx1 = sol.0;\n\n let miny_offset = sol.1/a;\n sol = shift_solution(sol, a, b, miny_offset);\n if sol.1 < 0 {\n sol = shift_solution(sol, a, b, -sign_a);\n }\n if sol.1 > maxy {\n return false;\n }\n let mut lx2 = sol.0;\n\n let maxy_offset = (sol.1 - maxy) / a;\n sol = shift_solution(sol, a, b, maxy_offset);\n if sol.1 > maxy {\n sol = shift_solution(sol, a, b, sign_a);\n }\n let mut rx2 = sol.0;\n\n if lx2 > rx2 {\n let temp = lx2;\n lx2 = rx2;\n rx2 = temp;\n }\n\n let lx = if lx1 > lx2 { lx1 } else { lx2 };\n let rx = if rx1 < rx2 { rx1 } else { rx2 };\n\n if lx > rx {\n return false;\n }\n\n let count = (rx - lx)/b.abs() + 1;\n\n count > 0\n },\n None => false\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2f21a052d4e18e07c3b9db97f2641382", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn egcd(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n return (a, 1, 0);\n }\n let (g, x1, y1) = egcd(b, a % b);\n (g, y1, x1 - (a / b) * y1)\n}\n\nfn ceil_div(num: i64, denom: i64) -> i64 {\n (num + denom - 1).div_euclid(denom)\n}\n\n// Check if the diophantine equation a * x + b * y = c has non-negative solutions.\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: i64 = scan.token();\n let b: i64 = scan.token();\n let c: i64 = scan.token();\n let (g, xg, yg) = egcd(a, b);\n if c % g == 0 {\n let x0 = xg * c / g;\n let y0 = yg * c / g;\n // xk = x0 + k * b / g\n // yk = y0 - k * a / g\n // xk >= 0 and yk >= 0\n // After solving for k:\n let ans = y0 * g / a - ceil_div(-x0 * g, b) + 1;\n if ans >= 0 {\n writeln!(out, \"Yes\").ok();\n } else {\n writeln!(out, \"No\").ok();\n }\n } else {\n writeln!(out, \"No\").ok();\n }\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "136fb008e7d19f80f1e7c02c813d2aa6", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::collections::BinaryHeap;\nuse std::io;\n\nfn get_line() -> io::Result {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf)?;\n Ok(buf)\n}\n\nfn main() -> io::Result<()> {\n get_line()?;\n let buf = get_line()?;\n let mut iter = buf.split_ascii_whitespace().map(|x| x.parse().unwrap());\n\n let init = iter.next().unwrap();\n let a: Vec = iter.collect();\n\n let mut heap = BinaryHeap::from(a);\n let mut ans = 0;\n\n while *heap.peek().unwrap() >= init + ans {\n let top = heap.pop().unwrap();\n heap.push(top - 1);\n ans += 1;\n }\n\n println!(\"{}\", ans);\n\n Ok(())\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "da133da961d0c6fd0ac26e9cd0d3057c", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str::FromStr;\n\nfn get_nums() -> (i32, i32, i32, i32, i32, i32, i32, i32) {\n\tlet mut input = String::new();\n\n\tio::stdin().read_line(&mut input)\n\t\t.expect(\"\");\n\n\tlet v = input.trim()\n\t\t\t.split_whitespace()\n\t\t\t.map(|d| i32::from_str(d).unwrap())\n\t\t\t.collect::>();\n\n\t(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7])\n}\n\nfn main() {\n\tlet (n, k, l, c, d, p, nl, np) = get_nums();\n\n\tprintln!(\"{}\", min((k*l)/nl, c*d, p/np)/n);\n\n\tfn min(x: i32, y: i32, z: i32) -> i32 {\n\t\tif x < y {\n\t\t\tif x < z {\n\t\t\t\tx\n\t\t\t} else {\n\t\t\t\tz\n\t\t\t}\n\t\t} else if y < z {\n\t\t\ty\n\t\t} else {\n\t\t\tz\n\t\t}\n\t}\t\t\t\t\t\t\t\t\t\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f65d071214a8be903149dd5b179ae453", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "Rust", "source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let a = input.vp::(8);\n let sol = (a[1] * a[2] / a[6]).min(a[3] * a[4]).min(a[5] / a[7]) / a[0];\n println!(\"{}\", sol);\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "0f71c6eb5a2d697f65181ec0aec9f99c", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "Rust", "source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let n: usize = scan.next();\n let k: usize = scan.next();\n let l: usize = scan.next();\n let c: usize = scan.next();\n let d: usize = scan.next();\n let p: usize = scan.next();\n let nl: usize = scan.next();\n let np: usize = scan.next();\n let l_person = l*k/nl;\n let c_person = c*d;\n let p_person = p/np;\n let result = l_person.min(c_person).min(p_person)/n;\n println!(\"{}\", result);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "892b7827ae798872eb4a024ff9c66f95", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "Rust", "source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn is_leap(y: i64) -> bool {\n y % 400 == 0 || y % 4 == 0 && y % 100 != 0\n}\n\nfn parse_date() -> i64 {\n let s = parse_line!(String);\n let mut it = s.split(':');\n let y: i64 = it.next().unwrap().parse().unwrap();\n let m: i64 = it.next().unwrap().parse().unwrap();\n let d: i64 = it.next().unwrap().parse().unwrap();\n let mut result = d;\n for i in 0..y {\n result += 365;\n if is_leap(i) {\n result += 1;\n }\n }\n let days = [31, 28 + if is_leap(y) {1} else {0}, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n for i in 0..m - 1 {\n result += days[i as usize];\n }\n return result;\n}\n\nfn solve() {\n let from = parse_date();\n let to = parse_date();\n println!(\"{}\", (from - to).abs());\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "9a8b80f7d31d28104bc3d00a1f35dbeb", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::Read;\n#[allow(dead_code)]\nfn getline() -> String {\n let mut ret = String::new();\n std::io::stdin().read_line(&mut ret).ok().unwrap();\n ret\n}\nfn get_word() -> String {\n let mut stdin = std::io::stdin();\n let mut u8b: [u8; 1] = [0];\n loop {\n let mut buf: Vec = Vec::with_capacity(16);\n loop {\n let res = stdin.read(&mut u8b);\n if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {\n break;\n } else {\n buf.push(u8b[0]);\n }\n }\n if buf.len() >= 1 {\n let ret = String::from_utf8(buf).unwrap();\n return ret;\n }\n }\n}\n\n#[allow(dead_code)]\nfn get() -> T { get_word().parse().ok().unwrap() }\n\nconst INF: i64 = 1 << 60;\n\nfn calc(a: &[i64], h: i64, w: i64) -> i64 {\n // at most 34 = 2 * 17\n let n = a.len();\n let mut cur = HashSet::new();\n cur.insert((1, 1));\n for i in 0 .. n + 1 {\n let mut nxt = HashSet::new();\n for (x, y) in cur {\n if x >= h && y >= w {\n return i as i64;\n }\n if i < n {\n if x < h {\n nxt.insert((x * a[i], y));\n }\n if y < w {\n nxt.insert((x, a[i] * y));\n }\n }\n }\n cur = nxt;\n }\n return INF;\n}\n\nfn solve() {\n let a: i64 = get();\n let b: i64 = get();\n let h: i64 = get();\n let w: i64 = get();\n let n = get();\n let mut ary: Vec = (0 .. n).map(|_| get()).collect();\n ary.sort();\n ary.reverse();\n let mut mi = calc(&ary, (a + h - 1) / h, (b + w - 1) / w);\n mi = min(mi, calc(&ary, (b + h - 1) / h, (a + w - 1) / w));\n println!(\"{}\", if mi == INF { -1 } else { mi });\n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "4357bb1ac478f5fa11486ab06bf8db0c", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "Rust", "source_code": "use std::io::{ self, BufRead };\nuse std::collections::*;\n\nmacro_rules! scan_line {\n () => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n buffer\n });\n ( $($t:ty)+ ) => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n let mut chunks = buffer.split_whitespace();\n\n ($(\n {\n chunks.next()\n .expect(\"scan_line: failed at `next`, # of space separated strings not equal to requested #\")\n .parse::<$t>()\n .expect(\"scan_line: failed at `parse::<$t>`.\")\n },\n )+)\n })\n}\n\nfn main() {\n let (n, k, t) = scan_line!(i64 i64 i64);\n\n if t <= k {\n println!(\"{}\", t);\n } else if t <= n {\n println!(\"{}\", k);\n } else {\n let d = k - (t - n);\n println!(\"{}\", d);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "001d94e1edc6d0636306d4a303e5f11e", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\nfn main() {\n let mut text = String::new();\n stdin().read_line(&mut text).unwrap();\n let text = text.trim();\n let mut counter4: usize = 0;\n let mut counter7: usize = 0;\n for i in text.chars() {\n if '4' == i {\n counter4 += 1;\n } else if '7' == i {\n counter7 -= 1;\n }\n }\n if counter4 == 0 && counter7 == 0 {\n println!(\"-1\");\n } else if counter4 > counter7 {\n println!(\"4\")\n } else {\n println!(\"7\")\n }\n}\n\nfn delete_leading_zeroes(arr: Vec) -> Vec {\n let mut finded = false;\n let mut last = 0;\n for i in 0..arr.len() {\n if '0' == arr[i] {\n continue;\n } else {\n last = i;\n finded = true;\n break;\n }\n }\n if finded {\n arr[last..].to_vec()\n } else {\n arr\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "4a686e303c92295cb262fa6e94609770", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Write, BufWriter};\n// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n let mut next = || { iter.next().unwrap() };\n input_inner!{next, $($r)*}\n };\n ($($r:tt)*) => {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input_inner!{next, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input_inner!{$next $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\nconst INF: i64 = 1 << 60;\n\nfn dist((a, b): (i64, i64), (c, d): (i64, i64)) -> i64 {\n (a - c).abs() + (b - d).abs()\n}\n\nfn solve() {\n let out = std::io::stdout();\n let mut out = BufWriter::new(out.lock());\n macro_rules! puts {\n ($format:expr) => (write!(out,$format).unwrap());\n ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())\n }\n input! {\n n: usize,\n xy: [(i64, i64); n],\n }\n let mut s = Vec::new();\n for &(x, y) in xy.iter() {\n s.push(max(x, y));\n }\n s.sort();\n s.dedup();\n let m = s.len();\n let mut aa = vec![Vec::new(); m + 1];\n for &(x, y) in xy.iter() {\n let idx = s.binary_search(&max(x, y)).unwrap();\n aa[idx + 1].push((x, y));\n }\n aa[0].push((0, 0));\n for i in 0 .. m + 1 {\n for u in aa[i].iter_mut() { u.1 *= -1; }\n aa[i].sort();\n for u in aa[i].iter_mut() { u.1 *= -1; }\n if aa[i].len() == 1 {\n let v = aa[i][0];\n aa[i].push(v);\n }\n if aa[i].len() >= 2 {\n let v = aa[i].pop().unwrap();\n while aa[i].len() > 1 {\n aa[i].pop();\n }\n aa[i].push(v);\n }\n }\n let mut dp = vec![[INF; 2]; m + 1];\n dp[0][0] = 0;\n dp[0][1] = 0;\n for i in 0 .. m {\n for j in 0 .. 2 {\n for k in 0 .. 2 {\n dp[i + 1][1 - k] = min(dp[i + 1][1 - k], dp[i][j] + dist(aa[i][j], aa[i + 1][k]) + dist(aa[i + 1][k], aa[i + 1][1 - k]));\n }\n }\n }\n puts!(\"{}\\n\", min(dp[m][0], dp[m][1]));\n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b3ebe63633dff9388d2df08ce7e2e441", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "Rust 2021", "source_code": "// use wyf_lib::*;\n\nfn main() {\n let n: usize = read();\n let m: usize = read();\n\n if n == 1 {\n println!(\"1\");\n return;\n }\n\n let mut k = 0;\n while 1 << k < n {\n k += 1;\n }\n let mut dp = vec![false; k * m + 1];\n let mut cnts = vec![0];\n for i in 1..=k {\n let mut cnt = 0;\n for j in 1..=m {\n let cur = i * j;\n if !dp[cur] {\n dp[cur] = true;\n cnt += 1;\n }\n }\n cnts.push(cnt);\n }\n let mut counted = vec![false; n + 1];\n\n let mut res: i64 = 1;\n 'i: for i in 2..=n {\n let mut c = 1;\n let mut curr = i;\n\n while curr <= n {\n if counted[curr] {\n continue 'i;\n }\n counted[curr] = true;\n res += cnts[c];\n curr *= i;\n c += 1;\n }\n }\n\n res.println();\n}\n\nuse std::error;\nuse std::fmt;\nuse std::str::FromStr;\n\n#[non_exhaustive]\n#[derive(Debug, PartialEq)]\npub enum Error {\n MissingMatch,\n MissingClosingBrace,\n UnexpectedValue(u8, Option),\n InvalidUtf8(Vec),\n PartialUtf8(usize, Vec),\n Parse(String, &'static str),\n}\n\nimpl error::Error for Error {}\n\nimpl fmt::Display for Error {\n fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n use crate::Error::*;\n use std::str::from_utf8;\n\n match *self {\n InvalidUtf8(ref raw) => write!(f, \"input was not valid utf8: {:?}\", raw),\n Parse(ref s, arg) => write!(f, \"could not parse {} as target type of {}\", s, arg),\n UnexpectedValue(exp, act) => write!(\n f,\n \"found value {:?} not matching the pattern value {}\",\n act.map(|b| b as char),\n exp as char\n ),\n PartialUtf8(n, ref raw) => write!(\n f,\n \"input was only partially valid utf8: \\\"{}\\\" followed by {:?}\",\n from_utf8(&raw[..n]).unwrap(),\n &raw[n..]\n ),\n MissingMatch => write!(f, \"Bad read! format string: did not contain {{}}\"),\n MissingClosingBrace => write!(\n f,\n \"found single open curly brace at the end of the format string\"\n ),\n }\n }\n}\n\npub fn match_next(expected: u8, iter: &mut dyn Iterator) -> Result<(), Error> {\n let next = iter.next();\n if next != Some(expected) {\n return Err(Error::UnexpectedValue(expected, next));\n }\n Ok(())\n}\n\npub fn parse_capture(\n name: &'static str,\n next: Option,\n iter: &mut dyn Iterator,\n) -> Result\nwhere\n T: FromStr,\n ::Err: ::std::fmt::Debug,\n{\n static WHITESPACES: &[u8] = b\"\\t\\r\\n \";\n let raw: Vec = match next {\n Some(c) => iter.take_while(|&ch| ch != c).collect(),\n None => iter\n .skip_while(|ch| WHITESPACES.contains(ch))\n .take_while(|ch| !WHITESPACES.contains(ch))\n .collect(),\n };\n match String::from_utf8(raw) {\n Ok(s) => FromStr::from_str(&s).map_err(|_| Error::Parse(s, name)),\n Err(e) => {\n let n = e.utf8_error().valid_up_to();\n let raw = e.into_bytes();\n if n == 0 {\n Err(Error::InvalidUtf8(raw))\n } else {\n Err(Error::PartialUtf8(n, raw))\n }\n }\n }\n}\n\n#[macro_export]\nmacro_rules! try_read(\n () => { $crate::try_read!(\"{}\") };\n ($text:expr) => {{\n (|| -> std::result::Result<_, $crate::Error> {\n let __try_read_var__;\n $crate::try_scan!($text, __try_read_var__);\n Ok(__try_read_var__)\n })()\n }};\n ($text:expr, $input:expr) => {{\n (|| -> std::result::Result<_, $crate::Error> {\n let __try_read_var__;\n $crate::try_scan!($input => $text, __try_read_var__);\n Ok(__try_read_var__)\n })()\n }};\n);\n\n#[macro_export]\nmacro_rules! try_scan(\n ($pattern:expr, $($arg:expr),*) => {\n use ::std::io::Read;\n $crate::try_scan!(::std::io::stdin().bytes().map(std::result::Result::unwrap) => $pattern, $($arg),*);\n };\n ($input:expr => $pattern:expr, $($arg:expr),*) => {{\n $crate::try_scan!(@impl question_mark; $input => $pattern, $($arg),*)\n }};\n (@question_mark: $($e:tt)+) => {{\n ($($e)+)?\n }};\n (@unwrap: $($e:tt)+) => {{\n ($($e)+).unwrap()\n }};\n (@impl $action:tt; $input:expr => $pattern:expr, $($arg:expr),*) => {{\n #![allow(clippy::try_err)]\n use $crate::{Error, match_next, parse_capture};\n\n // typesafe macros :)\n let pattern: &'static str = $pattern;\n let stdin: &mut dyn Iterator = &mut ($input);\n\n let mut pattern = pattern.bytes();\n\n $(\n $arg = loop {\n match $crate::try_scan!(@$action: pattern.next().ok_or(Error::MissingMatch)) {\n b'{' => match $crate::try_scan!(@$action: pattern.next().ok_or(Error::MissingClosingBrace)) {\n b'{' => $crate::try_scan!(@$action: match_next(b'{', stdin)),\n b'}' => break $crate::try_scan!(@$action: parse_capture(stringify!($arg), pattern.next(), stdin)),\n _ => return $crate::try_scan!(@$action: Err(Error::MissingClosingBrace)),\n },\n c => $crate::try_scan!(@$action: match_next(c, stdin)),\n }\n };\n )*\n\n for c in pattern {\n $crate::try_scan!(@$action: match_next(c, stdin))\n }\n\n format_args!($pattern, $($arg),*);\n }};\n);\n\n#[macro_export]\nmacro_rules! read(\n ($($arg:tt)*) => {\n $crate::try_read!($($arg)*).unwrap()\n };\n);\n\n#[macro_export]\nmacro_rules! scan(\n ($text:expr, $($arg:expr),*) => {\n {\n use ::std::io::Read;\n $crate::scan!(::std::io::stdin().bytes().map(std::result::Result::unwrap) => $text, $($arg),*);\n }\n };\n ($input:expr => $pattern:expr, $($arg:expr),*) => {{\n $crate::try_scan!(@impl unwrap; $input => $pattern, $($arg),*)\n }};\n);\nuse std::marker::PhantomData;\r\nuse std::ops;\r\n\r\n// use text_io::read;\r\n\r\n/*** READ and WRITE ***/\r\n\r\npub trait Readable {\r\n fn read() -> Self;\r\n}\r\n\r\npub trait Printable {\r\n fn print(self: &Self);\r\n fn println(self: &Self) {\r\n self.print();\r\n println!();\r\n }\r\n}\r\n\r\nmacro_rules! impl_rp_simple {\r\n ($($t:ident), +) => {\r\n $(\r\n impl Readable for $t {\r\n fn read() -> Self {\r\n read!()\r\n }\r\n }\r\n\r\n impl Printable for $t {\r\n fn print(self: &Self) {\r\n print!(\"{self} \");\r\n }\r\n }\r\n )+\r\n };\r\n}\r\n\r\nimpl_rp_simple!(\r\n String, i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64, char\r\n);\r\n\r\nmacro_rules! impl_rp_tuple {\r\n () => {};\r\n ($t0:ident, $($t:ident,) *) => {\r\n impl<$t0: Readable, $($t: Readable), *> Readable for ($t0, $($t,)*) {\r\n fn read() -> Self {\r\n (read(), $(read::<$t>(),)*)\r\n }\r\n }\r\n\r\n impl<$t0: Printable, $($t: Printable), *> Printable for ($t0, $($t,)*) {\r\n fn print(self: &Self) {\r\n #[allow(non_snake_case)]\r\n let (ref $t0, $(ref $t,)*) = &self;\r\n $t0.print();\r\n $(\r\n $t.print();\r\n )*\r\n }\r\n }\r\n\r\n impl_rp_tuple!{$($t,) *}\r\n };\r\n}\r\n\r\nimpl Printable for Vec {\r\n fn print(self: &Self) {\r\n for x in self {\r\n x.print();\r\n }\r\n }\r\n}\r\n\r\nimpl Printable for [T] {\r\n fn print(self: &Self) {\r\n for x in self {\r\n x.print();\r\n }\r\n }\r\n}\r\n\r\nimpl_rp_tuple! {T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,}\r\n\r\npub fn read() -> T {\r\n T::read()\r\n}\r\n\r\npub fn readv(size: usize) -> Vec {\r\n let mut res = Vec::with_capacity(size);\r\n for _ in 0..size {\r\n res.push(read());\r\n }\r\n res\r\n}\r\n\r\npub fn readb() -> Vec {\r\n let s: String = read!();\r\n s.as_bytes().into_iter().cloned().collect()\r\n}\r\n\r\n/*** RECURSIVE LAMBDA ***/\r\n\r\nmacro_rules! recursive_fn {\r\n () => {};\r\n ($name0:ident $trait0:ident $_:ident $__:ident, $($name:ident $trait:ident $Arg:ident $arg:ident,)*) => {\r\n pub trait $trait0<$($Arg,)* Output> {\r\n fn call(&mut self, $($arg: $Arg,)*) -> Output;\r\n }\r\n\r\n pub struct $name0\r\n where\r\n F: FnMut(&mut dyn $trait0<$($Arg,)* Output>, $($Arg,)*) -> Output,\r\n {\r\n f: std::cell::UnsafeCell,\r\n $(\r\n $arg: PhantomData<$Arg>,\r\n )*\r\n phantom_output: PhantomData,\r\n }\r\n\r\n impl $name0\r\n where\r\n F: FnMut(&mut dyn $trait0<$($Arg,)* Output>, $($Arg,)*) -> Output,\r\n {\r\n pub fn new(f: F) -> Self {\r\n Self {\r\n f: std::cell::UnsafeCell::new(f),\r\n $(\r\n $arg: PhantomData,\r\n )*\r\n phantom_output: PhantomData,\r\n }\r\n }\r\n }\r\n\r\n impl $trait0<$($Arg,)* Output> for $name0\r\n where\r\n F: FnMut(&mut dyn $trait0<$($Arg,)* Output>, $($Arg,)*) -> Output,\r\n {\r\n fn call(&mut self, $($arg: $Arg,)*) -> Output {\r\n unsafe { (&mut *self.f.get())(self, $($arg,)*) }\r\n }\r\n }\r\n\r\n recursive_fn!{$($name $trait $Arg $arg,)*}\r\n };\r\n}\r\n\r\nrecursive_fn! {\r\n RecursiveFn11 Callable11 Arg11 arg11,\r\n RecursiveFn10 Callable10 Arg10 arg10,\r\n RecursiveFn9 Callable9 Arg9 arg9,\r\n RecursiveFn8 Callable8 Arg8 arg8,\r\n RecursiveFn7 Callable7 Arg7 arg7,\r\n RecursiveFn6 Callable6 Arg6 arg6,\r\n RecursiveFn5 Callable5 Arg5 arg5,\r\n RecursiveFn4 Callable4 Arg4 arg4,\r\n RecursiveFn3 Callable3 Arg3 arg3,\r\n RecursiveFn2 Callable2 Arg2 arg2,\r\n RecursiveFn1 Callable1 Arg1 arg1,\r\n RecursiveFn0 Callable0 Arg0 arg0,\r\n}\r\n\r\n/*** MOD ***/\r\n\r\n// gcd, x, y\r\npub fn extended_gcd(a: i64, b: i64) -> (i64, i64, i64) {\r\n if a == 0 {\r\n (b, 0, 1)\r\n } else {\r\n let (g, y, mut x) = extended_gcd(b % a, a);\r\n x -= (b / a) * y;\r\n (g, x, y)\r\n }\r\n}\r\n\r\npub trait HasConstVal {\r\n const VAL: i64;\r\n}\r\n\r\n// const of V has to be prime\r\n#[derive(Copy, Clone, Eq, PartialEq)]\r\npub struct ModBase {\r\n v: i64,\r\n phantom: PhantomData,\r\n}\r\n\r\nimpl ModBase {\r\n pub fn new(mut v: i64) -> Self {\r\n v %= M::VAL;\r\n if v < 0 {\r\n v = v + M::VAL;\r\n }\r\n Self {\r\n v,\r\n phantom: PhantomData,\r\n }\r\n }\r\n\r\n pub fn inv(&self) -> Self {\r\n let (_, x, _) = extended_gcd(self.v, M::VAL);\r\n Self::new(x)\r\n }\r\n\r\n pub fn pow(&self, n: usize) -> Self {\r\n let v = self.v;\r\n let mut res = Self::new(1);\r\n for _ in 0..n {\r\n res *= v;\r\n }\r\n res\r\n }\r\n}\r\n\r\nimpl ops::Add for ModBase {\r\n type Output = Self;\r\n\r\n fn add(self, rhs: i64) -> Self {\r\n Self::new(self.v + rhs)\r\n }\r\n}\r\n\r\nimpl ops::Add for ModBase {\r\n type Output = Self;\r\n\r\n fn add(self, rhs: Self) -> Self {\r\n Self::new(self.v + rhs.v)\r\n }\r\n}\r\n\r\nimpl ops::AddAssign for ModBase {\r\n fn add_assign(&mut self, rhs: i64) {\r\n self.v = (self.v + rhs) % M::VAL;\r\n }\r\n}\r\n\r\nimpl ops::AddAssign for ModBase {\r\n fn add_assign(&mut self, rhs: Self) {\r\n self.v = (self.v + rhs.v) % M::VAL;\r\n }\r\n}\r\n\r\nimpl ops::Sub for ModBase {\r\n type Output = Self;\r\n\r\n fn sub(self, rhs: i64) -> Self {\r\n Self::new(self.v - rhs)\r\n }\r\n}\r\n\r\nimpl ops::Sub for ModBase {\r\n type Output = Self;\r\n\r\n fn sub(self, rhs: Self) -> Self {\r\n Self::new(self.v - rhs.v)\r\n }\r\n}\r\n\r\nimpl ops::SubAssign for ModBase {\r\n fn sub_assign(&mut self, rhs: i64) {\r\n self.v = (self.v - rhs) % M::VAL;\r\n }\r\n}\r\n\r\nimpl ops::SubAssign for ModBase {\r\n fn sub_assign(&mut self, rhs: Self) {\r\n self.v = (self.v - rhs.v) % M::VAL;\r\n }\r\n}\r\n\r\nimpl ops::Mul for ModBase {\r\n type Output = Self;\r\n\r\n fn mul(self, rhs: i64) -> Self::Output {\r\n Self::new(self.v * rhs)\r\n }\r\n}\r\n\r\nimpl ops::Mul for ModBase {\r\n type Output = Self;\r\n\r\n fn mul(self, rhs: Self) -> Self::Output {\r\n Self::new(self.v * rhs.v)\r\n }\r\n}\r\n\r\nimpl ops::MulAssign for ModBase {\r\n fn mul_assign(&mut self, rhs: i64) {\r\n self.v = self.v * rhs % M::VAL;\r\n }\r\n}\r\n\r\nimpl ops::MulAssign for ModBase {\r\n fn mul_assign(&mut self, rhs: Self) {\r\n self.v = self.v * rhs.v % M::VAL;\r\n }\r\n}\r\n\r\nimpl ops::Div for ModBase {\r\n type Output = Self;\r\n\r\n fn div(self, rhs: i64) -> Self::Output {\r\n self * Self::new(rhs).inv()\r\n }\r\n}\r\n\r\nimpl ops::Div for ModBase {\r\n type Output = Self;\r\n\r\n fn div(self, rhs: Self) -> Self::Output {\r\n self * rhs.inv()\r\n }\r\n}\r\n\r\nimpl ops::DivAssign for ModBase {\r\n fn div_assign(&mut self, rhs: i64) {\r\n self.v = (Self::new(self.v) / rhs).v;\r\n }\r\n}\r\n\r\nimpl ops::DivAssign for ModBase {\r\n fn div_assign(&mut self, rhs: Self) {\r\n self.v = (Self::new(self.v) / rhs).v;\r\n }\r\n}\r\n\r\nimpl ops::Neg for ModBase {\r\n type Output = Self;\r\n\r\n fn neg(self) -> Self::Output {\r\n Self::new(-self.v)\r\n }\r\n}\r\n\r\nimpl ops::Deref for ModBase {\r\n type Target = i64;\r\n\r\n fn deref(&self) -> &Self::Target {\r\n &self.v\r\n }\r\n}\r\n\r\n#[macro_export]\r\nmacro_rules! Mod {\r\n ($val: expr) => {\r\n Mod!(Mod, ModV, $val);\r\n };\r\n ($name: ident, $v_name: ident, $val: expr) => {\r\n #[derive(Copy, Clone, Eq, PartialEq)]\r\n pub struct $v_name {}\r\n\r\n impl crate::HasConstVal for $v_name {\r\n const VAL: i64 = $val as i64;\r\n }\r\n\r\n type $name = ModBase<$v_name>;\r\n };\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "95a14fa46aa0c7a1eac7c4323815c75e", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "Rust", "source_code": "use std::io::{self, Stdin};\nuse std::str::{self, FromStr};\nuse std::error::Error;\nuse std::thread;\nuse std::collections::BTreeSet;\nfn exec() {\n let mut sc = Scanner::new();\n let s: String = sc.ne();\n let mut m = BTreeSet::new();\n let n = s.len();\n for i in 0..n {\n let mut ss = s[i..n].to_string();\n ss.push_str(&s[0..i]);\n m.insert(ss);\n }\n println!(\"{}\", m.len());\n}\nconst DEFAULT_STACK: usize = 16 * 1024 * 1024;\nfn main() {\n let builder = thread::Builder::new();\n let th = builder.stack_size(DEFAULT_STACK);\n let handle = th.spawn(|| { exec(); }).unwrap();\n let _ = handle.join();\n}\n\n#[allow(dead_code)]\nstruct Scanner {\n stdin: Stdin,\n id: usize,\n buf: Vec,\n}\n\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n stdin: io::stdin(),\n id: 0,\n buf: Vec::new(),\n }\n }\n fn next_line(&mut self) -> Option {\n let mut res = String::new();\n match self.stdin.read_line(&mut res) {\n Ok(0) => return None,\n Ok(_) => Some(res),\n Err(why) => panic!(\"error in read_line: {}\", why.description()),\n }\n }\n fn next(&mut self) -> Option {\n while self.buf.len() == 0 {\n self.buf = match self.next_line() {\n Some(r) => {\n self.id = 0;\n r.trim().as_bytes().to_owned()\n }\n None => return None,\n };\n }\n let l = self.id;\n assert!(self.buf[l] != b' ');\n let n = self.buf.len();\n let mut r = l;\n while r < n && self.buf[r] != b' ' {\n r += 1;\n }\n let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() {\n Ok(s) => Some(s),\n Err(_) => panic!(\"parse error\"),\n };\n while r < n && self.buf[r] == b' ' {\n r += 1;\n }\n if r == n {\n self.buf.clear();\n } else {\n self.id = r;\n }\n res\n }\n fn ne(&mut self) -> T {\n self.next::().unwrap()\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "89808c1933ab8bcaf1d97e86be3f94a6", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// \u3053\u3053\u307e\u3067\n\nfn run() {\n input! {\n a: (u32, u32),\n b: (u32, u32),\n s: chars,\n }\n let mut f = 0;\n f += s[0].to_digit(10).unwrap() * 10 * 60;\n f += s[1].to_digit(10).unwrap() * 60;\n f += s[3].to_digit(10).unwrap() * 10;\n f += s[4].to_digit(10).unwrap();\n assert!((f - 300) % a.0 == 0);\n let start = f;\n let end = start + a.1;\n let mut p = 300;\n let mut ans = 0;\n while p < 24 * 60 {\n let (s, e) = (p, p + b.1);\n let (l, r) = (std::cmp::max(s, start), std::cmp::min(e, end));\n if l < r {\n ans += 1;\n }\n p += b.0;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "793f93235e7acc2bf6e4b1d23a86d1ea", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::iter;\nuse std::cmp;\n\nfn main() {\n let (a, b): (f64, f64) = {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let n1 = a.sqrt().floor() - 1.0;\n\n let delta = 1.0 + 4.0 * b;\n let n2 = (delta.sqrt() - 1.0) / 2.0;\n let n2 = n2.floor();\n\n if n1 < n2 {\n println!(\"Vladik\");\n } else {\n println!(\"Valera\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "24960d7d81d636e65630c4d763502d6e", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::iter;\nuse std::cmp;\n\nfn main() {\n let (a, b): (f64, f64) = {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let delta = 1.0 + 4.0 * a;\n let n1 = (delta.sqrt() - 1.0) / 2.0;\n let n1 = n1.floor();\n\n let n2 = b.sqrt().floor() - 1.0;\n\n println!(\"{} {}\", n1, n2);\n\n if n2 < n1 {\n println!(\"Valera\");\n } else {\n println!(\"Vladik\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "6e991ac8d535e073ba556c1019473e11", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "Rust", "source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReaderB {\n bin: Box<[u8]>,\n it: RefCell>>\n}\n#[allow(dead_code)]\nimpl WordReaderB {\n fn from(mut r: T) -> Self {\n let mut bin = Vec::new();\n r.read_to_end(&mut bin).ok();\n let bin = bin.into_boxed_slice();\n let it = RefCell::new(Self::split(&bin).into_iter());\n Self { bin, it }\n }\n fn from_stdin() -> Self {\n Self::from(stdin())\n }\n fn split(a: &[u8]) -> Vec> {\n let mut res = Vec::new();\n let mut last = None;\n let mut space = vec![false; 256];\n for &c in b\" \\t\\n\\r\" {\n space[c as usize] = true;\n }\n for (i,&c) in a.iter().enumerate() {\n if space[c as usize] {\n if let Some(j) = last.take() {\n res.push(j..i);\n }\n } else {\n last.get_or_insert(i);\n }\n }\n if let Some(j) = last {\n res.push(j..a.len());\n }\n res\n }\n fn no_it() -> std::vec::IntoIter {\n Vec::new().into_iter()\n }\n fn bs(&self) -> &[u8] {\n &self.bin[self.it.borrow_mut().next().expect(\"EOF\")]\n }\n fn sl(&self) -> std::borrow::Cow {\n String::from_utf8_lossy(self.bs())\n }\n fn s(&self) -> String { self.sl().into_owned() }\n fn sk(&self, n: usize) {\n self.it.borrow_mut().nth(n - 1);\n }\n fn i(&self) -> i32 { self.p() }\n fn u(&self) -> usize { self.p() }\n fn f(&self) -> f64 { self.p() }\n fn vi(&self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn vu(&self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn ii(&self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn iu(&self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn p(&self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n fn ip(&self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let rin = WordReaderB::from_stdin();\n\n l!(a,b = rin.bs());\n let na = a.len();\n let nb = b.len();\n let nab = na.max(nb) * 2;\n\n type DP = Vec>>>;\n let mut dp = vec![vec![vec![None; nab + 1]; nb + 1]; na + 1];\n type Q = VecDeque<(usize, usize, usize, usize)>;\n let mut q = VecDeque::new();\n let f = |q: &mut Q, dp: &mut DP, ia: usize, ib: usize, iab: usize, ia0, ib0, iab0, d| {\n if ia <= na && ib <= nb && iab <= nab {\n let res = &mut dp[ia][ib][iab];\n if res.is_none() {\n *res = Some((ia0,ib0,iab0,d));\n q.push_back((ia,ib,iab,d));\n }\n }\n };\n f(&mut q, &mut dp, 0, 0, 0, 0, 0, 0, 0);\n\n loop {\n let (ia, ib, iab, d) = q.pop_front().unwrap();\n if (ia, ib, iab) == (na, nb, 0) {\n break;\n }\n let d = d + 1;\n for &x in b\"()\" {\n let iab1 = {\n if x == b'(' {\n iab + 1\n } else {\n if iab == 0 {\n continue;\n }\n iab - 1\n }\n };\n let ia1 = if ia < na && x == a[ia] {ia + 1} else {ia};\n let ib1 = if ib < nb && x == b[ib] {ib + 1} else {ib};\n f(&mut q, &mut dp, ia1, ib1, iab1, ia, ib, iab, d);\n }\n }\n let d = dp[na][nb][0].as_ref().unwrap().3;\n let mut sol = vec![b'_'; d];\n let (mut ia, mut ib, mut iab) = (na, nb, 0);\n while (ia, ib, iab) != (0, 0, 0) {\n let (ia0,ib0,iab0,d0) = *dp[ia][ib][iab].as_ref().unwrap();\n sol[d0 - 1] = if iab0 < iab {b'('} else {b')'};\n ia = ia0;\n ib = ib0;\n iab = iab0;\n }\n let sol = String::from_utf8(sol).unwrap();\n println!(\"{}\", sol);\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b05b2803f9b66f2a6182e9be9b9a5185", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// \u3053\u3053\u307e\u3067\n\nfn run() {\n input! {\n n: u64,\n }\n if n <= 2 {\n println!(\"1\");\n return;\n }\n let mut m = 4;\n let mut d = 1;\n while m + 1 < n {\n m = 2 * m - d;\n d ^= 1;\n }\n if m == n || m + 1 == n {\n println!(\"1\");\n } else {\n println!(\"0\");\n }\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e21e6b7a392089ce1478242a99d2230b", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// \u3053\u3053\u307e\u3067\n\nfn run() {\n input! {\n n: u64,\n }\n if n <= 2 {\n println!(\"1\");\n return;\n }\n let mut m = 4;\n let mut d = 1;\n while m + 1 < n {\n m = 2 * (m + 1) - d;\n d ^= 1;\n }\n if m == n || m + 1 == n {\n println!(\"1\");\n } else {\n println!(\"0\");\n }\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b525f456224010df7195b8beb8e20dbf", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "Rust", "source_code": "use std::str::{FromStr};\n\nfn main() {\n let mut r = Read::new();\n let ln = r.many();\n print!(\"{}\", solve(ln[0], ln[1], ln[2]));\n}\n\nfn solve(t: i32, l: i32, r: i32) -> i64 {\n let b = 1000000007;\n let mut f = vec![0;(r + 1) as usize];\n for i in 1..r as i64 + 1 {\n for j in 2..r as i64 / i + 1 {\n f[(i * j) as usize] = (f[i as usize] + i * j * (j - 1) / 2) % b;\n }\n }\n\n f[l as usize..r as usize + 1].iter().fold((0, 1), |(s, p), fi| ((s + p * fi) % b, p * t as i64 % b)).0\n}\n\nstruct Read { s: String }\n\nimpl Read {\n fn new() -> Read {\n Read{s: String::new()}\n }\n\n #[allow(unused_must_use)]\n fn line(&mut self) -> &str {\n self.s.clear();\n std::io::stdin().read_line(&mut self.s);\n self.s.trim()\n }\n \n fn one(&mut self) -> T where ::Err: std::fmt::Debug {\n self.line().parse().unwrap()\n }\n\n fn many(&mut self) -> Vec where ::Err: std::fmt::Debug {\n self.line().split(' ').map(|x| x.parse().unwrap()).collect()\n }\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "95e1147c82f77c5a2f87c3356916055b", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0} {"lang": "Rust", "source_code": "use std::io;\n\n\nfn main() {\n let mut line = String::new();\n io::stdin().read_line(&mut line).unwrap();\n let nkx : Vec = line.trim().split(\" \").map(|x| x.parse::().unwrap()).collect();\n let (n, k, x) : (usize, usize, usize) = (nkx[0], nkx[1], nkx[2]);\n\n line = String::new();\n io::stdin().read_line(&mut line).unwrap();\n let my_deeds : Vec = line.trim().split(\" \").map(|x| x.parse::().unwrap()).collect();\n\n let mut min_cost = 0;\n for i in 1..(n + 1) {\n if i <= k {\n min_cost += x;\n } else {\n min_cost += my_deeds[((n - i) as usize)];\n }\n }\n\n print!(\"{}\", min_cost);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "03d83bcbbbf86cde660abcffe386c9fb", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str::FromStr;\n\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::cmp::{max, min};\n\nfn get_line() -> String {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input\n}\n\nfn get_vec() -> Vec\nwhere T: FromStr,\n ::Err: std::fmt::Debug,\n{\n get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nconst N: i64 = 998_244_353;\n\nfn extended_euclid(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n (a, 1, 0)\n } else {\n let (d0, x0, y0) = extended_euclid(b, a % b);\n (d0, y0, x0 - a / b * y0)\n }\n}\n\nfn main() {\n let (n, k, x): (usize, usize, usize) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let a: Vec = get_vec();\n\n let ans = &a[..a.len() - k].iter().cloned().sum::() + k * x;\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f385e235c71f5e62d3169f8670265ac4", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "Rust", "source_code": "// use std::ops::{Index, IndexMut};\nuse std::cmp::{Ordering, min, max};\n// use std::collections::{BinaryHeap, BTreeMap};\n// use std::collections::btree_map::Entry::{Occupied, Vacant};\n// use std::clone::Clone;\n\nfn getline() -> String{\n let mut res = String::new();\n std::io::stdin().read_line(&mut res).ok();\n res\n}\n\nmacro_rules! split {\n ($x: expr) => {\n ($x).trim().split(' ').collect()\n }\n}\n\nmacro_rules! parse {\n ($x: expr) => {\n ($x).parse().unwrap()\n }\n}\n\nmacro_rules! readl {\n ($t: ty) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n let mut iter = iv.into_iter();\n iter.next().unwrap().parse::<$t>().unwrap()\n }\n };\n ($( $t: ty),+ ) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n let mut iter = iv.into_iter();\n ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) \n }\n };\n}\n\nmacro_rules! rvec {\n ($x: expr) => {\n ($x).into_iter().map(|x| parse!(x)).collect()\n }\n}\n\nmacro_rules! readlvec {\n ($t: ty) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n iv.into_iter().map(|x| x.parse().unwrap()).collect::>()\n }\n }\n}\n\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {}\", stringify!($x), $x)\n }\n}\n\nfn printvec(v: &Vec) where T: std::fmt::Display {\n for (i,e) in v.into_iter().enumerate() {\n if i != 0 {\n print!(\" \");\n }\n print!(\"{}\", e);\n }\n println!();\n}\n\nfn main() {\n let (n, k) = readl!(usize, i64);\n let a = readlvec!(i64);\n\n let inf: i64 = 1e18 as i64;\n let ma = a.iter().fold(0,|acc, &x| max(acc,x));\n let bo = (ma as f64).sqrt() as i64 + 2;\n // debug!(bo);\n let mut ans = 1;\n for i in 1..bo {\n let mut sum = 0;\n for e in &a {\n sum += (i-e%i)%i;\n }\n if sum <= k {\n ans = i;\n }\n }\n\n let mut qu = Vec::<(i64,usize)>::new();\n qu.push((bo,0));\n for i in 0..n {\n for j in 1..bo {\n if a[i]/j != 0 && bo <= a[i]/j {\n qu.push(((a[i]+j-1)/j,i));\n }\n }\n }\n qu.sort();\n let mut qui = qu.into_iter();\n let mut b = vec![0;n];\n let mut pre = -100;\n if let Some((di,i)) = qui.next() {\n for i in 0..n {\n b[i] = (a[i]+di-1)/di;\n }\n pre = di;\n }\n let mut sb = b.iter().fold(0,|acc, &x| acc+x);\n let sa = a.iter().fold(0,|acc, &x| acc+x);\n let mut dis = 0;\n for (di, i) in qui {\n // debug!(i);\n // debug!(pre);\n // debug!(di);\n \n // // printvec(&mov);\n // printvec(&b);\n // debug!(sb);\n \n if pre*sb-sa <= k {\n let m = (k+sa-pre*sb)/sb;\n if pre+m < di {\n ans = pre+m;\n }\n }\n sb -= b[i];\n b[i] = (a[i]+di-1)/di;\n sb += b[i];\n pre = di;\n }\n // printvec(&b);\n // debug!(sb);\n // if sm <= k {\n // ans = pre;\n // } else {\n // let m = (k-sm)/sb;\n // debug!(m);\n // {\n // ans = pre+m;\n // }\n // }\n\n println!(\"{}\",ans);\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "f1b107ee0f16ffed45026d0e1b2abdf4", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "Rust", "source_code": "use std::ops::{Index, IndexMut};\nuse std::cmp::{Ordering};\nuse std::collections::{BinaryHeap, BTreeMap};\nuse std::collections::btree_map::Entry::{Occupied, Vacant};\n// use std::clone::Clone;\n\nfn getline() -> String{\n let mut res = String::new();\n std::io::stdin().read_line(&mut res).ok();\n res\n}\n\nmacro_rules! split {\n ($x: expr) => {\n ($x).trim().split(' ').collect()\n }\n}\n\nmacro_rules! parse {\n ($x: expr) => {\n ($x).parse().unwrap()\n }\n}\n\nmacro_rules! rvec {\n ($x: expr) => {\n ($x).into_iter().map(|x| parse!(x)).collect()\n }\n}\n\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {}\", stringify!($x), $x)\n }\n}\n\nfn printvec(v: &Vec) where T: std::fmt::Display {\n for (i,e) in v.into_iter().enumerate() {\n if i != 0 {\n print!(\" \");\n }\n print!(\"{}\", e);\n }\n println!();\n}\n\nfn main() {\n let s = getline();\n let iv:Vec<_> = split!(s);\n let n: usize = parse!(iv[0]);\n let s = getline();\n let iv: Vec<_> = split!(s);\n let a: Vec = rvec!(iv);\n \n let mut mp: BTreeMap> = BTreeMap::new();\n for (i,val) in a.into_iter().enumerate() {\n let vec = match mp.entry(val) {\n Vacant(entry) => entry.insert(vec![]),\n Occupied(entry) => entry.into_mut(),\n };\n vec.push(i);\n\n // (*mp.get_mut(&i).unwrap()).push(i as i32);\n }\n for (_,vec) in &mut mp {\n vec.sort();\n }\n let mut ans = 0_i64;\n let mut num = n;\n let mut pre = 0;\n let mut first = true;\n for (key,vec) in mp {\n let p = \n if first || vec[vec.len()-1] < pre || vec[0] >= pre {\n 0\n } else {\n let mut l = 0;\n let mut r = vec.len()-1;\n while l+1 < r {\n let m = (l+r)/2;\n if pre <= vec[m] {\n r = m;\n } else {\n l = m;\n }\n }\n r\n };\n for i in 0..vec.len() {\n if pre > vec[(p+i)%vec.len()] {\n ans += num as i64;\n }\n num -= 1;\n pre = vec[(p+i)%vec.len()];\n }\n first = false;\n }\n println!(\"{}\", ans+n as i64);\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "3b8d230cb14d4f0ac504478327a0d9dc", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "Rust", "source_code": "// use std::ops::{Index, IndexMut};\nuse std::cmp::{Ordering, min, max};\n// use std::collections::{BinaryHeap, BTreeMap};\n// use std::collections::btree_map::Entry::{Occupied, Vacant};\n// use std::clone::Clone;\n\nfn getline() -> String{\n let mut res = String::new();\n std::io::stdin().read_line(&mut res).ok();\n res\n}\n\nmacro_rules! split {\n ($x: expr) => {\n ($x).trim().split(' ').collect()\n }\n}\n\nmacro_rules! parse {\n ($x: expr) => {\n ($x).parse().unwrap()\n }\n}\n\nmacro_rules! readl {\n ($t: ty) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n let mut iter = iv.into_iter();\n iter.next().unwrap().parse::<$t>().unwrap()\n }\n };\n ($( $t: ty),+ ) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n let mut iter = iv.into_iter();\n ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) \n }\n };\n}\n\nmacro_rules! rvec {\n ($x: expr) => {\n ($x).into_iter().map(|x| parse!(x)).collect()\n }\n}\n\nmacro_rules! readlvec {\n ($t: ty) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n iv.into_iter().map(|x| x.parse().unwrap()).collect::>()\n }\n }\n}\n\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {}\", stringify!($x), $x)\n }\n}\n\nfn printvec(v: &Vec) where T: std::fmt::Display {\n for (i,e) in v.into_iter().enumerate() {\n if i != 0 {\n print!(\" \");\n }\n print!(\"{}\", e);\n }\n println!(\"\");\n}\n\nfn main() {\n let (n, k) = readl!(usize, i64);\n let a = readlvec!(i64);\n\n let ma = a.iter().fold(0,|acc, &x| max(acc,x));\n let bo = (ma as f64).sqrt() as i64 + 2;\n let mut ans = 1;\n for i in 1..bo {\n let mut sum = 0;\n for e in &a {\n sum += (i-e%i)%i;\n }\n if sum <= k {\n ans = i;\n }\n }\n\n let mut qu = Vec::<(i64,usize)>::new();\n qu.push((bo,0));\n for i in 0..n {\n for j in 1..bo {\n if a[i]/j != 0 && bo <= a[i]/j {\n qu.push(((a[i]+j-1)/j,i));\n }\n }\n }\n qu.sort();\n let mut qui = qu.into_iter();\n let mut b = vec![0;n];\n let mut pre = -100;\n if let Some((di,i)) = qui.next() {\n for i in 0..n {\n b[i] = (a[i]+di-1)/di;\n }\n pre = di;\n }\n let mut sb = b.iter().fold(0,|acc, &x| acc+x);\n let sa = a.iter().fold(0,|acc, &x| acc+x);\n for (di, i) in qui {\n if pre*sb-sa <= k {\n let m = (k+sa-pre*sb)/sb;\n if pre+m < di {\n ans = pre+m;\n }\n }\n sb -= b[i];\n b[i] = (a[i]+di-1)/di;\n sb += b[i];\n pre = di;\n }\n if pre*sb-sa <= k {\n let m = (k+sa-pre*sb)/sb;\n ans = pre+m;\n }\n\n println!(\"{}\",ans);\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2820f8e58137651b571c550a30abbfa3", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "Rust", "source_code": "// use std::ops::{Index, IndexMut};\nuse std::cmp::{Ordering, min, max};\n// use std::collections::{BinaryHeap, BTreeMap};\n// use std::collections::btree_map::Entry::{Occupied, Vacant};\n// use std::clone::Clone;\n\nfn getline() -> String{\n let mut res = String::new();\n std::io::stdin().read_line(&mut res).ok();\n res\n}\n\nmacro_rules! split {\n ($x: expr) => {\n ($x).trim().split(' ').collect()\n }\n}\n\nmacro_rules! parse {\n ($x: expr) => {\n ($x).parse().unwrap()\n }\n}\n\nmacro_rules! readl {\n ($t: ty) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n let mut iter = iv.into_iter();\n iter.next().unwrap().parse::<$t>().unwrap()\n }\n };\n ($( $t: ty),+ ) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n let mut iter = iv.into_iter();\n ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) \n }\n };\n}\n\nmacro_rules! rvec {\n ($x: expr) => {\n ($x).into_iter().map(|x| parse!(x)).collect()\n }\n}\n\nmacro_rules! readlvec {\n ($t: ty) => {\n {\n let s = getline();\n let iv: Vec<_> = split!(s);\n iv.into_iter().map(|x| x.parse().unwrap()).collect::>()\n }\n }\n}\n\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {}\", stringify!($x), $x)\n }\n}\n\nfn printvec(v: &Vec) where T: std::fmt::Display {\n for (i,e) in v.into_iter().enumerate() {\n if i != 0 {\n print!(\" \");\n }\n print!(\"{}\", e);\n }\n println!(\"\");\n}\n\nfn main() {\n let (n, k) = readl!(usize, i64);\n let a = readlvec!(i64);\n\n let inf: i64 = 1e18 as i64;\n let ma = a.iter().fold(0,|acc, &x| max(acc,x));\n let bo = (ma as f64).sqrt() as i64 + 2;\n // debug!(bo);\n let mut ans = 1;\n for i in 1..bo {\n let mut sum = 0;\n for e in &a {\n sum += (i-e%i)%i;\n }\n if sum <= k {\n ans = i;\n }\n }\n\n let mut qu = Vec::<(i64,usize)>::new();\n qu.push((bo,0));\n for i in 0..n {\n for j in 1..bo {\n if a[i]/j != 0 && bo <= a[i]/j {\n qu.push(((a[i]+j-1)/j,i));\n }\n }\n }\n qu.sort();\n let mut qui = qu.into_iter();\n let mut b = vec![0;n];\n let mut pre = -100;\n if let Some((di,i)) = qui.next() {\n for i in 0..n {\n b[i] = (a[i]+di-1)/di;\n }\n pre = di;\n }\n let mut sb = b.iter().fold(0,|acc, &x| acc+x);\n let sa = a.iter().fold(0,|acc, &x| acc+x);\n let mut dis = 0;\n for (di, i) in qui {\n // debug!(i);\n // debug!(pre);\n // debug!(di);\n \n // // printvec(&mov);\n // printvec(&b);\n // debug!(sb);\n \n if pre*sb-sa <= k {\n let m = (k+sa-pre*sb)/sb;\n if pre+m < di {\n ans = pre+m;\n }\n }\n sb -= b[i];\n b[i] = (a[i]+di-1)/di;\n sb += b[i];\n pre = di;\n }\n // printvec(&b);\n // debug!(sb);\n // if sm <= k {\n // ans = pre;\n // } else {\n // let m = (k-sm)/sb;\n // debug!(m);\n // {\n // ans = pre+m;\n // }\n // }\n if pre*sb-sa <= k {\n let m = (k+sa-pre*sb)/sb;\n {\n ans = pre+m;\n }\n }\n\n println!(\"{}\",ans);\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "a7afaaea9b5f06e7cc892f73dc214736", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "Rust", "source_code": "use std::io::{self, Read};\nuse std::iter::FromIterator;\n\n#[allow(dead_code)]\nstruct Source {\n chars: Box>,\n}\n\n#[allow(dead_code)]\nimpl Source {\n fn next_chr(&mut self) -> char {\n self.chars\n .by_ref()\n .skip_while(|c| char::is_whitespace(*c))\n .next()\n .expect(\"eof\")\n }\n\n fn next_str(&mut self) -> String {\n let it = self\n .chars\n .by_ref()\n .skip_while(|c| char::is_whitespace(*c))\n .take_while(|c| !char::is_whitespace(*c));\n let s = String::from_iter(it);\n if s.is_empty() {\n panic!(\"eof\")\n } else {\n s\n }\n }\n\n fn from_stdin() -> Self {\n let mut data = String::new();\n io::stdin().read_to_string(&mut data).expect(\"Input error\");\n Self::from_str(&data)\n }\n\n fn from_str(s: &str) -> Self {\n let data = String::from(s);\n let chars = data.chars().collect::>().into_iter();\n Source {\n chars: Box::new(chars),\n }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! input {\n ($src:expr; $($elem:tt)*) => {\n input_inner!($src, $($elem)*)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! input_inner {\n ($src:expr) => {};\n ($src:expr,) => {};\n ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {\n let mut $var = parse!($src, $ty);\n input_inner!($src $($rest)*)\n };\n ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {\n let $var = parse!($src, $ty);\n input_inner!($src $($rest)*)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! parse {\n ($src:expr, ( $($ty:tt),* )) => {\n ( $(parse!($src,$ty)),* )\n };\n ($src:expr, char) => {\n $src.next_chr()\n };\n ($src:expr, [ $ty:tt; $len:expr ]) => {\n (0..$len).map(|_| parse!($src,$ty)).collect::>()\n };\n ($src:expr, $ty:tt) => {\n parse_str!($src,$ty)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! parse_str {\n ($src:expr, chars) => {\n $src.next_str().chars().collect::>()\n };\n ($src:expr, $ty:ty) => {\n $src.next_str().parse::<$ty>().expect(\"Parse error\")\n };\n}\n\nuse std::cmp::min;\n\nfn max_height(pos: usize, height: usize, restriction: &[(usize, usize, usize)]) -> usize {\n restriction.iter().fold(height, |cur, (l, r, h)| {\n if *l <= pos && pos <= *r {\n min(cur, *h)\n } else {\n cur\n }\n })\n}\n\nfn main() {\n let mut src = Source::from_stdin();\n input! { src;\n n: usize, h: usize, m: usize,\n r: [(usize,usize,usize); m]\n }\n\n let res: usize = (1..=n)\n .map(|pos| {\n let h = max_height(pos, h, &r);\n h * h\n })\n .sum();\n\n println!(\"{}\", res)\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "512f3c668eb1b62639c4deaa1784cf90", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse utils::*;\n\npub fn main() {\n let i = stdin();\n let mut o = Vec::new();\n run(i.lock(), &mut o);\n stdout().write_all(&o).unwrap();\n}\n\n#[derive(PartialEq, Eq, Hash, Clone, Copy)]\nstruct Tile {\n num: usize,\n suit: char,\n}\nimpl CpIn for Tile {\n fn read_from(r: &mut CpReader) -> Self {\n let s = r.read_word_str();\n let num: usize = s[..1].parse().unwrap();\n Tile {\n num: num - 1,\n suit: s[1..].parse().unwrap(),\n }\n }\n}\n\npub fn run(i: R, o: &mut W) {\n let mut i = CpReader::new(i);\n let (t0, t1, t2) = i.read();\n writeln!(o, \"{}\", solve([t0, t1, t2])).unwrap();\n}\nfn solve(ts: [Tile; 3]) -> usize {\n let mut m = HashMap::new();\n for &t in &ts {\n *m.entry(t).or_insert(0) += 1;\n }\n let mut ans = 3 - *m.values().max().unwrap();\n\n for &suit in &['m', 'p', 's'] {\n let mut es = [false; 9];\n for &t in &ts {\n if t.suit == suit {\n es[t.num] = true;\n }\n }\n println!(\"{} {:?}\", suit, &es);\n for i in 0..9 - 3 {\n let mut c = 0;\n for j in 0..3 {\n if es[i + j] {\n c += 1;\n }\n }\n ans = min(ans, 3 - c);\n }\n }\n ans\n}\n\npub mod utils {\n use super::*;\n\n pub struct CpReader {\n r: R,\n b: Vec,\n }\n impl CpReader {\n pub fn new(r: R) -> Self {\n CpReader {\n r: r,\n b: Vec::new(),\n }\n }\n pub fn read_word(&mut self) -> &[u8] {\n self.b.clear();\n let mut consume = 0;\n loop {\n self.r.consume(consume);\n let b = self.r.fill_buf().unwrap();\n assert!(b.len() != 0);\n if let Some(p) = b.iter().position(|&x| x.is_ascii_whitespace()) {\n self.b.extend_from_slice(&b[..p]);\n consume = p + 1;\n break;\n }\n self.b.extend_from_slice(b);\n consume = b.len();\n }\n self.r.consume(consume);\n consume_ws(&mut self.r);\n &self.b\n }\n pub fn read_word_str(&mut self) -> &str {\n unsafe { std::str::from_utf8_unchecked(self.read_word()) }\n }\n\n pub fn read_line(&mut self) -> &[u8] {\n self.b.clear();\n self.r.read_until(b'\\n', &mut self.b).unwrap();\n let end = self\n .b\n .iter()\n .rposition(|x| !x.is_ascii_whitespace())\n .map(|idx| idx + 1)\n .unwrap_or(0);\n &self.b[..end]\n }\n pub fn read_line_str(&mut self) -> &str {\n unsafe { std::str::from_utf8_unchecked(self.read_line()) }\n }\n\n pub fn read(&mut self) -> T {\n T::read_from(self)\n }\n\n pub fn read_vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read()).collect()\n }\n pub fn read_iter<'a, T: CpIn>(&'a mut self, n: usize) -> CpIter<'a, R, T> {\n CpIter {\n r: self,\n n: n,\n _pd: Default::default(),\n }\n }\n }\n pub struct CpIter<'a, R: BufRead + 'a, T> {\n r: &'a mut CpReader,\n n: usize,\n _pd: std::marker::PhantomData T>,\n }\n impl<'a, R: BufRead, T: CpIn> Iterator for CpIter<'a, R, T> {\n type Item = T;\n fn next(&mut self) -> Option {\n if self.n == 0 {\n None\n } else {\n self.n -= 1;\n Some(self.r.read())\n }\n }\n }\n\n pub trait CpIn {\n fn read_from(r: &mut CpReader) -> Self;\n }\n\n impl CpIn for u64 {\n fn read_from(r: &mut CpReader) -> Self {\n read_u64_fast(&mut r.r)\n }\n }\n impl CpIn for i64 {\n fn read_from(r: &mut CpReader) -> Self {\n read_i64_fast(&mut r.r)\n }\n }\n impl CpIn for char {\n fn read_from(r: &mut CpReader) -> Self {\n let b = r.r.fill_buf().unwrap()[0] as char;\n r.r.consume(1);\n let s = r.r.fill_buf().unwrap()[0];\n assert!(s == b' ' || s == b'\\n');\n r.r.consume(1);\n b\n }\n }\n\n macro_rules! cpin_tuple {\n ($($t:ident),*) => {\n impl<$($t: CpIn),*> CpIn for ($($t),*) {\n fn read_from(r: &mut CpReader) -> Self {\n ($($t::read_from(r)),*)\n }\n }\n };\n }\n\n macro_rules! cpin_cast {\n ($t_self:ty, $t_read:ty) => {\n impl CpIn for $t_self {\n fn read_from(r: &mut CpReader) -> Self {\n <$t_read>::read_from(r) as $t_self\n }\n }\n };\n }\n macro_rules! cpin_parse {\n ($t:ty) => {\n impl CpIn for $t {\n fn read_from(r: &mut CpReader) -> Self {\n r.read_word_str().parse().unwrap()\n }\n }\n };\n }\n cpin_cast!(usize, u64);\n cpin_cast!(u32, u64);\n cpin_cast!(u16, u64);\n cpin_cast!(i32, i64);\n cpin_cast!(i16, i64);\n cpin_cast!(i8, i64);\n\n cpin_parse!(f64);\n\n cpin_tuple!(T1, T2);\n cpin_tuple!(T1, T2, T3);\n cpin_tuple!(T1, T2, T3, T4);\n cpin_tuple!(T1, T2, T3, T4, T5);\n\n fn read_u64_fast(r: &mut R) -> u64 {\n let mut value = 0;\n loop {\n let mut idx = 0;\n let buf_len;\n {\n let buf = r.fill_buf().unwrap();\n buf_len = buf.len();\n assert!(buf_len != 0);\n while idx < buf_len && b'0' <= buf[idx] && buf[idx] <= b'9' {\n value = value * 10 + (buf[idx] - b'0') as u64;\n idx += 1;\n }\n }\n if idx < buf_len {\n r.consume(idx);\n consume_ws(r);\n return value;\n }\n r.consume(idx);\n }\n }\n fn read_i64_fast(r: &mut R) -> i64 {\n let (consume, sign) = match r.fill_buf().unwrap()[0] {\n b'+' => (true, 1),\n b'-' => (true, -1),\n _ => (false, 1),\n };\n if consume {\n r.consume(1);\n }\n read_u64_fast(r) as i64 * sign\n }\n fn consume_ws(r: &mut R) {\n let mut c = 0;\n loop {\n r.consume(c);\n let b = r.fill_buf().unwrap();\n if b.len() == 0 {\n return;\n }\n if let Some(p) = b.iter().position(|&x| !x.is_ascii_whitespace()) {\n c = p;\n break;\n }\n c = b.len();\n }\n r.consume(c);\n }\n\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "9c231f8f47ccc04b22ac576adb08e549", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0} {"lang": "Rust", "source_code": "use std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse utils::*;\n\npub fn main() {\n let i = stdin();\n let mut o = Vec::new();\n run(i.lock(), &mut o);\n stdout().write_all(&o).unwrap();\n}\n\n#[derive(PartialEq, Eq, Hash, Clone, Copy)]\nstruct Tile {\n num: usize,\n suit: char,\n}\nimpl CpIn for Tile {\n fn read_from(r: &mut CpReader) -> Self {\n let s = r.read_word_str();\n let num: usize = s[..1].parse().unwrap();\n Tile {\n num: num - 1,\n suit: s[1..].parse().unwrap(),\n }\n }\n}\n\npub fn run(i: R, o: &mut W) {\n let mut i = CpReader::new(i);\n let (t0, t1, t2) = i.read();\n writeln!(o, \"{}\", solve([t0, t1, t2])).unwrap();\n}\nfn solve(ts: [Tile; 3]) -> usize {\n let mut m = HashMap::new();\n for &t in &ts {\n *m.entry(t).or_insert(0) += 1;\n }\n let mut ans = 3 - *m.values().max().unwrap();\n\n for &suit in &['m', 'p', 's'] {\n let mut es = [false; 9];\n for &t in &ts {\n if t.suit == suit {\n es[t.num] = true;\n }\n }\n for i in 0..9 - 3 {\n let mut c = 0;\n for j in 0..3 {\n if es[i + j] {\n c += 1;\n }\n }\n ans = min(ans, 3 - c);\n }\n }\n ans\n}\n\npub mod utils {\n use super::*;\n\n pub struct CpReader {\n r: R,\n b: Vec,\n }\n impl CpReader {\n pub fn new(r: R) -> Self {\n CpReader {\n r: r,\n b: Vec::new(),\n }\n }\n pub fn read_word(&mut self) -> &[u8] {\n self.b.clear();\n let mut consume = 0;\n loop {\n self.r.consume(consume);\n let b = self.r.fill_buf().unwrap();\n assert!(b.len() != 0);\n if let Some(p) = b.iter().position(|&x| x.is_ascii_whitespace()) {\n self.b.extend_from_slice(&b[..p]);\n consume = p + 1;\n break;\n }\n self.b.extend_from_slice(b);\n consume = b.len();\n }\n self.r.consume(consume);\n consume_ws(&mut self.r);\n &self.b\n }\n pub fn read_word_str(&mut self) -> &str {\n unsafe { std::str::from_utf8_unchecked(self.read_word()) }\n }\n\n pub fn read_line(&mut self) -> &[u8] {\n self.b.clear();\n self.r.read_until(b'\\n', &mut self.b).unwrap();\n let end = self\n .b\n .iter()\n .rposition(|x| !x.is_ascii_whitespace())\n .map(|idx| idx + 1)\n .unwrap_or(0);\n &self.b[..end]\n }\n pub fn read_line_str(&mut self) -> &str {\n unsafe { std::str::from_utf8_unchecked(self.read_line()) }\n }\n\n pub fn read(&mut self) -> T {\n T::read_from(self)\n }\n\n pub fn read_vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read()).collect()\n }\n pub fn read_iter<'a, T: CpIn>(&'a mut self, n: usize) -> CpIter<'a, R, T> {\n CpIter {\n r: self,\n n: n,\n _pd: Default::default(),\n }\n }\n }\n pub struct CpIter<'a, R: BufRead + 'a, T> {\n r: &'a mut CpReader,\n n: usize,\n _pd: std::marker::PhantomData T>,\n }\n impl<'a, R: BufRead, T: CpIn> Iterator for CpIter<'a, R, T> {\n type Item = T;\n fn next(&mut self) -> Option {\n if self.n == 0 {\n None\n } else {\n self.n -= 1;\n Some(self.r.read())\n }\n }\n }\n\n pub trait CpIn {\n fn read_from(r: &mut CpReader) -> Self;\n }\n\n impl CpIn for u64 {\n fn read_from(r: &mut CpReader) -> Self {\n read_u64_fast(&mut r.r)\n }\n }\n impl CpIn for i64 {\n fn read_from(r: &mut CpReader) -> Self {\n read_i64_fast(&mut r.r)\n }\n }\n impl CpIn for char {\n fn read_from(r: &mut CpReader) -> Self {\n let b = r.r.fill_buf().unwrap()[0] as char;\n r.r.consume(1);\n let s = r.r.fill_buf().unwrap()[0];\n assert!(s == b' ' || s == b'\\n');\n r.r.consume(1);\n b\n }\n }\n\n macro_rules! cpin_tuple {\n ($($t:ident),*) => {\n impl<$($t: CpIn),*> CpIn for ($($t),*) {\n fn read_from(r: &mut CpReader) -> Self {\n ($($t::read_from(r)),*)\n }\n }\n };\n }\n\n macro_rules! cpin_cast {\n ($t_self:ty, $t_read:ty) => {\n impl CpIn for $t_self {\n fn read_from(r: &mut CpReader) -> Self {\n <$t_read>::read_from(r) as $t_self\n }\n }\n };\n }\n macro_rules! cpin_parse {\n ($t:ty) => {\n impl CpIn for $t {\n fn read_from(r: &mut CpReader) -> Self {\n r.read_word_str().parse().unwrap()\n }\n }\n };\n }\n cpin_cast!(usize, u64);\n cpin_cast!(u32, u64);\n cpin_cast!(u16, u64);\n cpin_cast!(i32, i64);\n cpin_cast!(i16, i64);\n cpin_cast!(i8, i64);\n\n cpin_parse!(f64);\n\n cpin_tuple!(T1, T2);\n cpin_tuple!(T1, T2, T3);\n cpin_tuple!(T1, T2, T3, T4);\n cpin_tuple!(T1, T2, T3, T4, T5);\n\n fn read_u64_fast(r: &mut R) -> u64 {\n let mut value = 0;\n loop {\n let mut idx = 0;\n let buf_len;\n {\n let buf = r.fill_buf().unwrap();\n buf_len = buf.len();\n assert!(buf_len != 0);\n while idx < buf_len && b'0' <= buf[idx] && buf[idx] <= b'9' {\n value = value * 10 + (buf[idx] - b'0') as u64;\n idx += 1;\n }\n }\n if idx < buf_len {\n r.consume(idx);\n consume_ws(r);\n return value;\n }\n r.consume(idx);\n }\n }\n fn read_i64_fast(r: &mut R) -> i64 {\n let (consume, sign) = match r.fill_buf().unwrap()[0] {\n b'+' => (true, 1),\n b'-' => (true, -1),\n _ => (false, 1),\n };\n if consume {\n r.consume(1);\n }\n read_u64_fast(r) as i64 * sign\n }\n fn consume_ws(r: &mut R) {\n let mut c = 0;\n loop {\n r.consume(c);\n let b = r.fill_buf().unwrap();\n if b.len() == 0 {\n return;\n }\n if let Some(p) = b.iter().position(|&x| !x.is_ascii_whitespace()) {\n c = p;\n break;\n }\n c = b.len();\n }\n r.consume(c);\n }\n\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "29a7f6e1afcf2c6c71f0faaafed6d680", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0} {"lang": "Rust", "source_code": "macro_rules! input {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input!{$next $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, bytes) => {\n read_value!($next, String).into_bytes()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\nfn solve(bitmask: usize, times: &mut[Option], matches: &mut[Option<(usize, usize)>], objects: &[(i32, i32)], length: usize, handbag: (i32, i32)) -> i32 {\n if let Some(t) = times[bitmask] {\n return t;\n }\n for i in 0..length {\n if bitmask & (1 << i) > 0 {\n let mut best = solve(bitmask ^ (1 << i), times, matches, objects, length, handbag) + 2 * sq_dist(objects[i], handbag);\n matches[bitmask] = Some((i,i));\n for j in (i+1)..length {\n if bitmask & (1 << j) > 0 {\n let ans_j = solve(bitmask ^ (1 << i) ^ (1 << j), times, matches, objects, length, handbag) + sq_dist(objects[i], handbag) + sq_dist(objects[j], handbag) + sq_dist(objects[i], objects[j]);\n if ans_j < best {\n matches[bitmask] = Some((i,j));\n best = ans_j;\n }\n }\n }\n // dbg!(bitmask);\n // dbg!(best);\n times[bitmask] = Some(best);\n return best;\n }\n }\n unreachable!();\n}\n\nfn sq_dist(a: (i32, i32), b: (i32, i32)) -> i32 {\n (a.0-b.0)*(a.0-b.0) + (a.1-b.1)*(a.1-b.1)\n}\n\nfn main() {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input! {next,\n handbag: (i32, i32),\n n: usize,\n objects: [(i32, i32); n],\n }\n let mut times = vec![None; 1 << n];\n times[0] = Some(0);\n let mut matches = vec![None; 1 << n];\n println!(\"{}\", solve((1 << n) - 1, &mut times, &mut matches, &objects, n, handbag));\n // println!(\"{:?}\", times);\n // println!(\"{:?}\", matches);\n let mut bitmask = (1 << n) - 1;\n let mut result = String::new();\n result.push('0');\n while bitmask != 0 {\n let (i, j) = matches[bitmask].unwrap();\n if i == j {\n result.push_str(&format!(\" {} 0\", i+1));\n }\n else {\n result.push_str(&format!(\" {} {} 0\", i+1, j+1));\n }\n bitmask ^= (1 << i) | (1 << j);\n }\n println!(\"{}\", result);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "fd566ce452b78d8c2e68267d88d738d5", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "Rust", "source_code": "//spnauti-rusT {{{\nuse std::io::*; use std::str::{self,*}; use std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)] macro_rules! min {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! max {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};\n\t($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};\n\t(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};\n}\n#[allow(unused_macros)] macro_rules! v {\n\t([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};\n\t([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: v!([]), pos: 0 }\n\t}\n\tfn next_line(&mut self) -> bool {\n\t\tself.buf.clear(); self.pos = 0;\n\t\tself.q.read_until(b'\\n', &mut self.buf).unwrap_or(0) > 0\n\t}\n\tfn is_ws(c: u8) -> bool {\n\t\tc == b' ' || c == b'\\r' || c == b'\\n' || c == b'\\t'\n\t}\n\tfn byte(&mut self) -> Option {\n\t\tif self.pos == self.buf.len() { if !self.next_line() { return None; } }\n\t\tself.pos += 1; Some(self.buf[self.pos - 1])\n\t}\n\tfn vb(&mut self) -> Vec {\n\t\tlet mut s = v!([8]);\n\t\tlet mut f = false;\n\t\tloop {\n\t\t\tif let Some(c) = self.byte() {\n\t\t\t\tif !Self::is_ws(c) {\n\t\t\t\t\ts.push(c);\n\t\t\t\t\tf = true;\n\t\t\t\t} else if f { break; }\n\t\t\t} else { break; }\n\t\t}\n\t\ts\n\t}\n\tfn board(&mut self, r: usize, c: Option) -> Vec> {\n\t\tlet mut res = v!([r]);\n\t\tlet c = c.unwrap_or(0);\n\t\trep!{[r]\n\t\t\tlet t = self.vb();\n\t\t\tassert!(c == 0 || t.len() == c);\n\t\t\tres.push(t);\n\t\t}\n\t\tres\n\t}\n\tfn framed_board(&mut self, r: usize, c: usize, f: u8) -> Vec> {\n\t\tlet mut res = v!([r+2]);\n\t\tres.push( v!([c+2] = f) );\n\t\trep!{[r]\n\t\t\tlet mut t = self.vb();\n\t\t\tassert!(t.len() == c);\n\t\t\tt.reserve(2);\n\t\t\tt.insert(0,f);\n\t\t\tt.push(f);\n\t\t\tres.push(t);\n\t\t}\n\t\tres.push( v!([c+2] = f) );\n\t\tres\n\t}\n\tfn s(&mut self) -> String { String::from_utf8(self.vb()).expect(\"invalid utf8\") }\n\tfn i(&mut self) -> i32 { self.p() }\n\tfn l(&mut self) -> i64 { self.p() }\n\tfn u(&mut self) -> usize { self.p() }\n\tfn f(&mut self) -> f64 { self.p() }\n\tfn vi(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vl(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vu(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn ii(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn iu(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn p(&mut self) -> T where T::Err: Debug {\n\t\tlet w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::().unwrap()\n\t}\n\tfn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n\t\t(0..n).map(|_|self.p()).collect()\n\t}\n\tfn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n\t\tself.vp(n).into_iter()\n\t}\n\tfn graph(&mut self, n: usize, m: usize) -> Vec> {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); e[a].push(b); e[b].push(a); } e\n\t}\n\tfn graph_w(&mut self, n: usize, m: usize) -> Vec> where T::Err: Debug {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); let c: T = self.p(); e[a].push((b,c)); e[b].push((a,c)); } e\n\t}\n}\n//------------------- End rusT }}}\n\n// Field (mod prime) {{{\nmod field {\n\tuse std::ops::*;\n\t#[allow(dead_code)] pub const Z0: Field = Field(0);\n\t#[allow(dead_code)] pub const Z1: Field = Field(1);\n\tconst P5: i32 = 1_000_000_007;\n\tconst P6: i64 = P5 as i64;\n\t#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Default)] pub struct Field(i32);\n\t#[allow(dead_code)] impl Field {\n\t\tpub fn new>(a: T) -> Self { Self(Self::cv(a)) }\n\t\tpub fn new_unchecked(a: i32) -> Self { Self(a) }\n\t\tfn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }\n\t\tfn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }\n\t\tfn cv>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }\n\t\tpub fn inv(self) -> Self { self.pow(P5-2) }\n\t\tpub fn pow>(self, b: T) -> Self {\n\t\t\tlet b = b.into(); if b == 0 { Self(1) } else {\n\t\t\t\tlet mut res = self.pow(b/2); res *= res; if b % 2 == 1 {res *= self;} res\n\t\t\t}\n\t\t}\n\t}\n\timpl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}\n\timpl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}\n\timpl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}\n\timpl Div for Field { type Output = Self; fn div(self, a: Self) -> Self::Output { self * a.inv() }}\n\timpl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}\n\timpl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }\n\timpl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }\n\timpl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }\n\timpl DivAssign for Field { fn div_assign(&mut self, a: Self) { *self = *self / a; } }\n\tuse std::fmt::{Display, Formatter, Result};\n\timpl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, \"{}\", self.0) } }\n}\n#[allow(unused_imports)] use field::{Field, Field as Z, Z0, Z1};\n//}}}\n// Square Matrix (Field) {{{\ntype MatT = Field;\nconst MAT_T_0: MatT = Z0;\nconst MAT_T_1: MatT = Z1;\n#[derive(Debug,Clone)] struct Mat { n: usize, a: Vec }\n#[allow(dead_code)] impl Mat {\n\tfn new(n:usize)->Self{Self{n,a:vec![MAT_T_0;n*n]}}\n\tfn diag(n:usize,v:MatT)->Self{let mut m=Self::new(n);let mut p=0;for _ in 0..n{m.a[p]=v;p+=n+1;}m}\n\tfn pow(&self,n:u64)->Self{if n==0{Self::diag(self.n,MAT_T_1)}else{let mut t=self.pow(n/2);t*=t.clone();if n%2==1{t*=self.clone();}t}}\n\tfn range(&self,r:Range,c:Range)->Vec>{if r.startMatT{self.a[r*self.n+c]}\n\tfn at_mut<'a>(&'a mut self,r:usize,c:usize)->&'a mut MatT{&mut self.a[r*self.n+c]}//'\n}\nimpl Mul for Mat{type Output=Self;fn mul(self,o:Self)->Self::Output{assert!(self.n==o.n);let n=self.n;let mut res=Self::new(n);\n\tfor ii in(0..n).map(|i|i*n){for j in 0..n{let mut t=MAT_T_0;let mut kk=j;for k in 0..n{t+=self.a[ii+k]*o.a[kk];kk+=n;}res.a[ii+j]=t;}}res}}\nimpl Add for Mat{type Output=Self;fn add(mut self,o:Self)->Self{self+=o;self}}\nimpl Sub for Mat{type Output=Self;fn sub(mut self,o:Self)->Self{self-=o;self}}\nimpl MulAssign for Mat{fn mul_assign(&mut self,a:Self){*self=self.clone()*a;}}\nimpl AddAssign for Mat{fn add_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x+=y;}} }\nimpl SubAssign for Mat{fn sub_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x-=y;}} }\nimpl PartialEq for Mat{fn eq(&self,o:&Self)->bool{self.n==o.n&&self.a==o.a}}impl Eq for Mat{}\n// }}}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tlet n = rin.l();\n\tlet m = rin.u();\n\tlet mut mat = Mat::new(m);\n\tfor i in 1..m {\n\t\t*mat.at_mut(i,i-1) = Z1;\n\t}\n\t*mat.at_mut(0,0) = Z1;\n\t*mat.at_mut(0,m-1) = Z1;\n\tlet mat = mat.pow(n as u64);\n\tlet sol = mat.at(0,0);\n\twriteln!(rout, \"{}\", sol).ok();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "bcc92cdb531755033419116114cf5219", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "Rust", "source_code": "use std::io::{self, BufReader};\nuse std::io::prelude::*;\nuse std::collections::HashMap;\n\nfn insert_dist(dist: i32, c: char, dist_map: &mut HashMap, diff: i32) {\n if dist <= (13 + diff) {\n dist_map.insert(c, (dist - diff).abs());\n } else {\n dist_map.insert(c, 26 + diff - dist);\n }\n}\n\nfn solve(input: &mut dyn Read, output: &mut dyn Write) {\n let mut reader = BufReader::new(input);\n let mut input = String::new();\n let mut dist_a: HashMap = HashMap::new();\n let mut dist_c: HashMap = HashMap::new();\n let mut dist_t: HashMap = HashMap::new();\n let mut dist_g: HashMap = HashMap::new();\n\n for (i, c) in \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".chars().enumerate() {\n let dist = i as i32;\n insert_dist(dist, c, &mut dist_a, 0);\n insert_dist(dist, c, &mut dist_c, 2);\n if dist <= 6 {\n dist_t.insert(c, 7 + dist);\n } else {\n dist_t.insert(c, (dist - 19).abs());\n }\n insert_dist(dist, c, &mut dist_g, 6);\n }\n // for c in \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".chars() {\n // println!(\"{} {}\", c, dist_t[&c]);\n // }\n \n\n reader.read_line(&mut input).unwrap();\n let n: usize = input.trim().parse().unwrap();\n\n input.clear();\n reader.read_line(&mut input).unwrap();\n let s = input.trim();\n // println!(\"{:?}\", s);\n\n let char_vec: Vec = s.chars().collect();\n let mut min_sum = -1;\n for i in 0..n-3 {\n let sum = dist_a.get(&char_vec[i]).expect(\"has values\") + \n dist_c.get(&char_vec[i + 1]).expect(\"has values\") + \n dist_t.get(&char_vec[i + 2]).expect(\"has values\") + \n dist_g.get(&char_vec[i + 3]).expect(\"has values\");\n\n if min_sum == -1 || sum < min_sum {\n min_sum = sum;\n }\n }\n\n // for c in s.chars() {\n // println!(\"{:?}\", c);\n // }\n\n writeln!(output, \"{}\", min_sum).expect(\"correct output\");\n\n}\n\nfn main() {\n solve(&mut io::stdin(), &mut io::stdout());\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "d1eaf5e292d64294c6725c42ce587b5a", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nstatic ALPHABET: &str = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\nfn find_number_of_ops(length_of_string: usize, s: String) -> usize {\n let mut number_of_ops = vec![];\n for i in 0..length_of_string-3 {\n let substring = &s[i..i+4];\n let mut ops = 0;\n for (index_of_letter_in_substring, letter) in substring.chars().enumerate() {\n if letter != \"ACTG\".chars().nth(index_of_letter_in_substring).unwrap() {\n // number of operations is not zero for this letter\n let position_of_letter_in_alphabet = ALPHABET.find(letter).unwrap();\n let position_of_target_in_alphabet = ALPHABET.find(\"ACTG\".chars().nth(index_of_letter_in_substring).unwrap()).unwrap();\n let x: usize = (position_of_letter_in_alphabet as isize - position_of_target_in_alphabet as isize).abs() as usize;\n let y: usize = 26 - (position_of_target_in_alphabet as isize - position_of_letter_in_alphabet as isize).abs() as usize;\n ops += if x < y {x} else {y};\n }\n if index_of_letter_in_substring == 3 {\n number_of_ops.push(ops);\n }\n }\n }\n let mut minimum_ops = number_of_ops[0];\n for ops in number_of_ops.iter() {\n if ops < &minimum_ops {\n minimum_ops = *ops;\n }\n }\n minimum_ops\n}\n\nfn main() {\n let mut length_of_string = String::new();\n io::stdin().read_line(&mut length_of_string).unwrap();\n let length_of_string: usize = length_of_string.trim().parse().unwrap();\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n println!(\"{}\", find_number_of_ops(length_of_string, s.trim().to_string()));\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "df36a3460d13614f5eda3d9733443d2f", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io::{self, BufReader};\nuse std::io::prelude::*;\nuse std::collections::HashMap;\n\nfn insert_dist(dist: i32, c: char, dist_map: &mut HashMap, diff: i32) {\n if dist <= (13 + diff) {\n dist_map.insert(c, (dist - diff).abs());\n } else {\n dist_map.insert(c, 26 + diff - dist);\n }\n}\n\nfn solve(input: &mut dyn Read, output: &mut dyn Write) {\n let mut reader = BufReader::new(input);\n let mut input = String::new();\n let mut dist_a: HashMap = HashMap::new();\n let mut dist_c: HashMap = HashMap::new();\n let mut dist_t: HashMap = HashMap::new();\n let mut dist_g: HashMap = HashMap::new();\n\n for (i, c) in \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".chars().enumerate() {\n let dist = i as i32;\n insert_dist(dist, c, &mut dist_a, 0);\n insert_dist(dist, c, &mut dist_c, 2);\n if dist <= 6 {\n dist_t.insert(c, 7 + dist);\n } else {\n dist_t.insert(c, (dist - 19).abs());\n }\n insert_dist(dist, c, &mut dist_g, 6);\n }\n // for c in \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\".chars() {\n // println!(\"{} {}\", c, dist_t[&c]);\n // }\n \n\n reader.read_line(&mut input).unwrap();\n let n: usize = input.trim().parse().unwrap();\n\n input.clear();\n reader.read_line(&mut input).unwrap();\n let s = input.trim();\n // println!(\"{:?}\", s);\n\n let char_vec: Vec = s.chars().collect();\n let mut min_sum = i32::MAX;\n for i in 0..n-3 {\n let sum = dist_a.get(&char_vec[i]).expect(\"has values\") + \n dist_c.get(&char_vec[i + 1]).expect(\"has values\") + \n dist_t.get(&char_vec[i + 2]).expect(\"has values\") + \n dist_g.get(&char_vec[i + 3]).expect(\"has values\");\n\n if sum < min_sum {\n min_sum = sum;\n }\n }\n\n // for c in s.chars() {\n // println!(\"{:?}\", c);\n // }\n\n writeln!(output, \"{}\", min_sum).expect(\"correct output\");\n\n}\n\nfn main() {\n solve(&mut io::stdin(), &mut io::stdout());\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "34443326eea93666b4558b5a64ac99a0", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n\ntype GenError = Box;\ntype GenResult = Result;\n\nstruct Reader {\n\n}\n\nimpl Reader{\n #[allow(unused)]\n fn read_string() -> GenResult {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string)?;\n Ok(string.trim().to_string())\n }\n\n #[allow(unused)]\n fn read_tokens() -> GenResult> {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string)?;\n let mut v = Vec::new();\n for value in string.split_whitespace() {\n v.push(value.to_string());\n }\n Ok(v)\n }\n}\n\nfn main() {\n\n let tokens = Reader::read_tokens().unwrap();\n let n: i32 = tokens[0].parse().unwrap();\n let m: i32 = tokens[1].parse().unwrap();\n let k: i32 = tokens[2].parse().unwrap();\n\n let mut ans = 1000000;\n let mut index = 1;\n for value in Reader::read_tokens().unwrap() {\n let value : i32 = value.parse().unwrap();\n if value > 0 && value <= k {\n ans = min(ans, 10 * (index - m).abs());\n }\n index += 1;\n }\n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "ad1feae6cca83bf7289b526a8f543ff6", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 1_000_000_007;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\n/* \nimpl std::fmt::Display for ModInt {\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n*/\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n self.pow(MOD - 2)\n }\n pub fn comb(n: u32, k: u32) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n let k = std::cmp::min(k, n - k);\n let mut nu = ModInt::one();\n let mut de = ModInt::one();\n for i in 0..k {\n nu *= ModInt(n - i);\n de *= ModInt(i + 1);\n }\n nu * de.inv()\n }\n}\n\n#[allow(dead_code)]\nstruct Precalc {\n inv: Vec,\n fact: Vec,\n ifact: Vec,\n}\n\n#[allow(dead_code)]\nimpl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);\n fact[i] = fact[i - 1] * ModInt(i as u32);\n ifact[i] = ifact[i - 1] * inv[i];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n}\n// ---------- end ModInt ----------\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: usize,\n s: chars,\n }\n let len = s.len();\n let mut index = vec![vec![0; len + 1]; 2];\n for i in 0..len {\n if s[i] == '(' {\n index[0][i] = i + 1;\n let mut t = s.clone();\n t[i] = ')';\n for k in (1..=i).rev() {\n if s[0..k] == t[(i + 1 - k)..(i + 1)] {\n index[1][i] = k;\n break;\n }\n }\n } else {\n index[1][i] = i + 1;\n let mut t = s.clone();\n t[i] = '(';\n for k in (1..=i).rev() {\n if s[0..k] == t[(i + 1 - k)..(i + 1)] {\n index[0][i] = k;\n break;\n }\n }\n }\n }\n index[0][len] = len;\n index[1][len] = len;\n let mut dp = vec![vec![ModInt::zero(); n + 1]; len + 1];\n dp[0][0] = ModInt::one();\n for _ in 0..(2 * n) {\n let mut next = vec![vec![ModInt::zero(); n + 1]; len + 1];\n for j in 0..=len {\n for k in 0..=n {\n let v = dp[j][k];\n if k < n {\n next[index[0][j]][k + 1] += v;\n }\n if k > 0 {\n next[index[1][j]][k - 1] += v;\n }\n }\n }\n dp = next;\n }\n let ans = dp[len][0].0;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "eb71210c1ebfe5d27a90681a85047dbd", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\nuse std::io::*;\nuse std::cmp::*;\nuse std::collections::*;\n\nmacro_rules! debug(\n ($($arg:tt)*) => { {\n let r = writeln!(&mut ::std::io::stderr(), $($arg)*);\n r.expect(\"failed printing to stderr\");\n } }\n);\n\nstruct Scanner {\n buffer : std::collections::VecDeque\n}\n\nimpl Scanner {\n\n fn new() -> Scanner {\n Scanner {\n buffer: std::collections::VecDeque::new()\n }\n }\n\n fn process(&mut self) -> String {\n if self.buffer.len() == 0 {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).ok();\n for word in input.split_whitespace() {\n self.buffer.push_back(word.to_string())\n }\n }\n\n self.buffer.pop_front().unwrap()\n }\n\n #[allow(dead_code)]\n fn next(&mut self) -> T {\n self.process().parse::().ok().unwrap()\n }\n\n #[allow(dead_code)]\n fn next_char(&mut self) -> char {\n self.process().into_bytes()[0] as char\n }\n}\n\nfn count_char(x : char, y : char, z : char, target : char) -> i32 {\n (if x == target {1} else {0})\n + if y == target {1} else {0}\n + if z == target {1} else {0}\n}\n\nfn check_board(board: &[[char; 4];4]) -> String {\n // horizontal...\n for i in 0..4 {\n for j in 1..3 {\n let x_count = count_char(board[i][j], board[i][j+1], board[i][j-1], 'x');\n let e_count = count_char(board[i][j], board[i][j+1], board[i][j-1], '.');\n\n if x_count == 3 || (x_count == 2 && e_count == 1) {\n return \"YES\".to_string();\n }\n }\n }\n\n // vertical...\n for j in 0..4 {\n for i in 1..3 {\n let x_count = count_char(board[i][j], board[i+1][j], board[i-1][j], 'x');\n let e_count = count_char(board[i][j], board[i+1][j], board[i-1][j], '.');\n\n if x_count == 3 || (x_count == 2 && e_count == 1) {\n return \"YES\".to_string();\n }\n }\n }\n\n // left-diagonal...\n for j in 0..2 {\n for i in 0..2 {\n let x_count = count_char(board[i][j], board[i+1][j+1], board[i+2][j+2], 'x');\n let e_count = count_char(board[i][j], board[i+1][j+1], board[i+2][j+2], '.');\n\n if x_count == 3 || (x_count == 2 && e_count == 1) {\n return \"YES\".to_string();\n }\n }\n }\n\n // right-diagonal..\n for j in 0..2 {\n for i in 2..4 {\n let x_count = count_char(board[i][j], board[i-1][j+1], board[i-2][j+2], 'x');\n let e_count = count_char(board[i][j], board[i-1][j+1], board[i-2][j+2], '.');\n\n if x_count == 3 || (x_count == 2 && e_count == 1) {\n return \"YES\".to_string();\n }\n }\n }\n\n return \"NO\".to_string();\n}\n\nfn main() {\n let mut sin = Scanner::new();\n\n let mut board = [['.';4];4];\n\n for i in 0..4 {\n let line = sin.next::().into_bytes();\n for j in 0..4 {\n board[i][j] = line[j] as char;\n }\n }\n\n println!(\"{}\", check_board(&board));\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "db42980ddcfcef4dd3b2902d23460a73", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn solve() -> Vec {\n let mut input = \"\".split_ascii_whitespace();\n let mut read = || loop {\n if let Some(word) = input.next() {\n break word;\n }\n input = {\n let mut input = \"\".to_owned();\n io::stdin().read_line(&mut input).unwrap();\n if input.is_empty() {\n panic!(\"reached EOF\");\n }\n Box::leak(input.into_boxed_str()).split_ascii_whitespace()\n };\n };\n macro_rules! read(($ty:ty) => (read().parse::<$ty>().unwrap()));\n\n let mut rr = vec![\"\".to_string(); 0];\n\n let t = 1;\n for _ in 0..t {\n let n = read!(usize);\n let mut a = vec![0; n];\n for i in 0..n {\n a[i] = read!(usize);\n }\n\n a.sort();\n let mut v = vec![false; n];\n let mut r = 0;\n for i in 0..n {\n if v[i] {\n continue;\n }\n v[i] = true;\n r += 1;\n let mut c = 1;\n for j in (i + 1)..n {\n if !v[j] && a[j] >= c {\n v[j] = true;\n c += 1;\n }\n }\n }\n\n rr.push(format!(\"{}\", r));\n }\n\n rr\n}\n\n#[allow(dead_code)]\nfn main() {\n let output = solve();\n println!(\"{}\", output.join(\"\\n\"));\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "eedbca7a76e4a1ef0a07bc32d346d91e", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn dfs(a: &[u64], k: usize, sup: bool, used: u64, b: &mut Vec) {\n if k == a.len() {\n b.push(used);\n return;\n }\n let y = if !sup {\n a[k]\n } else {\n 6\n };\n for i in 0..=y {\n if used >> i & 1 == 0 {\n dfs(a, k + 1, sup || i < a[k], used | (1 << i), b);\n }\n }\n}\n\nfn run() {\n input! {\n n: u64,\n m: u64,\n }\n let mut a = vec![];\n let mut x = m - 1;\n if x == 0 {\n a.push(0);\n } else {\n while x > 0 {\n a.push(x % 7);\n x /= 7;\n }\n }\n a.reverse();\n let mut b = vec![];\n dfs(&a, 0, false, 0, &mut b);\n let sa = a;\n let mut a = vec![];\n let mut x = n - 1;\n if x == 0 {\n a.push(x);\n } else {\n while x > 0 {\n a.push(x % 7);\n x /= 7;\n }\n }\n if a.len() + sa.len() > 7 {\n println!(\"0\");\n return;\n }\n a.reverse();\n let mut c = vec![];\n dfs(&a, 0, false, 0, &mut c);\n let mut ans = 0;\n for b in b.iter() {\n for c in c.iter() {\n if *b & *c == 0 {\n ans += 1;\n }\n }\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1d5095bdf550d5cfb26adbab3eb1f308", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "Rust", "source_code": "macro_rules! scanln {\n () => ({\n let mut buffer = String::new();\n ::std::io::stdin().read_line(&mut buffer).expect(\"Unable to read line\");\n buffer\n });\n ($($t: ty),+) => ({\n scanln!($($t),+, |c: char| c.is_whitespace())\n });\n ($($t: ty),+, $sp: expr) => ({\n let mut buffer = scanln!();\n let mut iter = buffer.split($sp);\n ($(iter.next().unwrap().parse::<$t>().expect(\"Unable to parse token\")),+)\n });\n}\n\nfn main() {\n const MOD: u64 = 1000000009;\n let mut dp = vec![[[[[0u64; 2]; 32]; 32]; 32]; 1001].into_boxed_slice();\n let (n, h) = scanln!(usize, usize);\n dp[0][0][0][0][0] = 1;\n\n for i in 1..=n {\n for a in 0..=(h + 1) {\n for b in a..=(h + 1) {\n for c in b..=(h + 1) {\n for y in 0..2 {\n let val = dp[(i - 1) as usize][a][b][c][y];\n let ta = if a + 1 > h { h + 1 } else { a + 1 };\n let tb = if b + 1 > h { h + 1 } else { b + 1 };\n let tc = if c + 1 > h { h + 1 } else { c + 1 };\n dp[i][ta][tb][tc][y] += val;\n if y == 0 {\n dp[i][1][tb][tc][(ta > h) as usize] += val;\n dp[i][1][ta][tc][(tb > h) as usize] += val;\n dp[i][1][ta][tb][(tc > h) as usize] += val;\n } else {\n dp[i][tb][tc][h + 1][(ta > h) as usize] += val;\n dp[i][ta][tc][h + 1][(tb > h) as usize] += val;\n dp[i][ta][tb][h + 1][(tc > h) as usize] += val;\n }\n }\n }\n }\n }\n }\n\n let mut res = 0;\n\n for a in 0..=(h + 1) {\n for b in a..=(h + 1) {\n for c in b..=(h + 1) {\n for y in 0..2 {\n if (a < h) || (b < h) || (c < h) || (y == 0) {\n res += dp[n][a][b][c][y];\n }\n }\n }\n }\n }\n\n println!(\"{}\", res % MOD);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "234976fd83c2d1a4a9cb21df64379eb2", "src_uid": "9fe9658db35076c0bddc8b7ddce11013", "difficulty": 2300.0} {"lang": "Rust", "source_code": "macro_rules! scanln {\n () => ({\n let mut buffer = String::new();\n ::std::io::stdin().read_line(&mut buffer).expect(\"Unable to read line\");\n buffer\n });\n ($($t: ty),+) => ({\n scanln!($($t),+, |c: char| c.is_whitespace())\n });\n ($($t: ty),+, $sp: expr) => ({\n let mut buffer = scanln!();\n let mut iter = buffer.split($sp);\n ($(iter.next().unwrap().parse::<$t>().expect(\"Unable to parse token\")),+)\n });\n}\n\nfn main() {\n const MOD: u64 = 1000000009;\n let mut dp = vec![[[[[0u64; 2]; 32]; 32]; 32]; 1001].into_boxed_slice();\n let (n, h) = scanln!(usize, usize);\n dp[0][0][0][0][0] = 1;\n\n for i in 1..=n {\n for a in 0..=(h + 1) {\n for b in a..=(h + 1) {\n for c in b..=(h + 1) {\n for y in 0..2 {\n dp[(i - 1) as usize][a][b][c][y] %= MOD;\n let val = dp[(i - 1) as usize][a][b][c][y];\n let ta = if a + 1 > h { h + 1 } else { a + 1 };\n let tb = if b + 1 > h { h + 1 } else { b + 1 };\n let tc = if c + 1 > h { h + 1 } else { c + 1 };\n dp[i][ta][tb][tc][y] += val;\n if y == 0 {\n dp[i][1][tb][tc][(ta > h) as usize] += val;\n dp[i][1][ta][tc][(tb > h) as usize] += val;\n dp[i][1][ta][tb][(tc > h) as usize] += val;\n } else {\n dp[i][tb][tc][h + 1][(ta > h) as usize] += val;\n dp[i][ta][tc][h + 1][(tb > h) as usize] += val;\n dp[i][ta][tb][h + 1][(tc > h) as usize] += val;\n }\n }\n }\n }\n }\n }\n\n let mut res = 0;\n\n for a in 0..=(h + 1) {\n for b in a..=(h + 1) {\n for c in b..=(h + 1) {\n for y in 0..2 {\n if (a < h) || (b < h) || (c < h) || (y == 0) {\n res += dp[n][a][b][c][y];\n }\n }\n }\n }\n }\n\n println!(\"{}\", res % MOD);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b475828f91dbaac335f1b688a548d36c", "src_uid": "9fe9658db35076c0bddc8b7ddce11013", "difficulty": 2300.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::io;\nuse std::mem::size_of_val;\nuse std::cmp::{max, min};\nuse std::rc::Rc;\nuse std::collections::btree_map::BTreeMap;\nuse std::io::{Write, BufRead};\nuse std::collections::{HashMap, BTreeSet};\nuse std::ptr::write_volatile;\nuse std::process::exit;\nuse std::thread;\n\n#[allow(dead_code)]\nfn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\n#[allow(unused)]\nfn read_strings() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n let mut v = Vec::new();\n for value in string.split_whitespace() {\n v.push(value.to_string());\n }\n v\n}\n\n#[allow(unused)]\nfn read_array_i32() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n string.split_whitespace().map(|x| x.parse::().unwrap()).collect()\n}\n\n\n#[allow(unused_macros)]\nmacro_rules! read_array {\n ( $ty:ty, ... ) => {\n gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap())\n };\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\n// mod math;\n// mod binary_search;\n// mod graph;\n// mod structure;\n// mod fibonacci;\n// mod string;\n// mod permutations;\n// mod patterns;\n\n\n#[allow(dead_code)]\nfn memory_properties(value: &T)\n where\n T: std::fmt::Display + ?Sized,\n{\n println!(\n \"Variable address in memory = {:p}, Allocated bytes for type = {}\",\n value,\n size_of_val(value)\n );\n}\n\n#[allow(unused_macros)]\nmacro_rules! sum {\n ($($x:expr), *) => {\n {\n let mut res = 0;\n $(res += $x;)*\n res\n }\n };\n}\n\nstatic mut array: [[u8;51];51] = [[0u8; 51]; 51];\n\nfn main() {\n use std::io::Write;\n let out = std::io::stdout();\n let mut out = std::io::BufWriter::new(out.lock());\n\n let mut res = 0;\n let s = gets();\n let mut seq = BTreeSet::<&str>::new();\n for i in 0..s.len() {\n for j in i + 1 .. s.len() + 1 {\n if seq.contains(&s[i..j]){\n res = max(res, j - i);\n } else {\n seq.insert(&s[i..j]);\n }\n }\n }\n writeln!(out, \"{}\", res);\n // writeln!(out, \"{}\", \"Hello Rust\").unwrap();\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "a8411550d6f127b9a83c38566ed911c0", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "Rust", "source_code": "#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(isize);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\n// -----------------------------------------------------------------------------\n\nfn main() {\n scanln!(c: u32, v0: u32, v1: u32, a: u32, l: u32);\n let mut speed = v0;\n let mut pages = 0;\n let mut days = 0;\n loop {\n days += 1;\n pages += speed;\n if pages >= c { break; }\n speed = std::cmp::min(speed + a, v1);\n pages -= l;\n }\n println!(\"{}\", days);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1d7da85977e938e70aa4d360a23223e4", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str::FromStr;\n\nconst MAX: usize = 5;\n\nfn get_row() -> (i32, i32, i32) {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input)\n .expect(\"\");\n\n let v = input.trim()\n .split_whitespace()\n .map(|d| i32::from_str(d).unwrap())\n .collect::>();\n (v[0], v[1], v[2])\n} \n\nfn main() {\n let mut a = [[0;MAX]; MAX];\n\n for i in 0..3 {\n let (x, y, z) = get_row();\n a[i][0] = x;\n a[i][1] = y;\n a[i][2] = z;\n }\n\n let x = (a[0][2]+a[2][0] - (a[1][0]+ a[2][0] - (a[0][2]+a[1][2])))/2;\n let y = x + (a[1][0]+ a[2][0]-(a[0][1]+a[2][1]));\n let z = x + (a[1][0]+ a[2][0]-(a[0][2]+a[1][2]));\n\n a[0][0] = x;\n a[1][1] = y;\n a[2][2] = z;\n\n for i in 0..3 {\n for j in 0..3 {\n print!(\"{} \", a[i][j]);\n }\n println!();\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "93bd92ce9f908471b31ccea87deac63a", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "Rust", "source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\n#[allow(unused_macros)]\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nuse std::io::Write;\n\nfn solve(writer: &mut std::io::BufWriter) {\n let (l, r) = parse_line!(u64, u64);\n let mut bit = 1u64 << 63;\n while bit != 0 && l & bit == r & bit {\n bit >>= 1;\n }\n if bit == 0 {\n writeln!(writer, \"0\").unwrap();\n }else{\n writeln!(writer, \"{}\", bit | (bit - 1)).unwrap();\n }\n}\n\nfn main() {\n let mut writer = std::io::BufWriter::new(std::io::stdout());\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve(&mut writer);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "3adc437265fd771aa819ffceb4d705d8", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Rust", "source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n l!(l,r: i64 = input.p());\n if l == r {\n println!(\"0\");\n } else {\n let mut x = l ^ r;\n for i in 0..=5 {\n x |= x >> (1 << i);\n }\n println!(\"{}\", x);\n }\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "dc042c53058b9caf8eae6f9d19a46229", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "Rust", "source_code": "\nuse std::io::*;\nuse std::cmp::*;\n\nfn main() {\n let mut buf = String::new();\n stdin().read_to_string(&mut buf).ok().unwrap();\n let mut cin = buf.split_whitespace().map(|s| s.parse::().ok().unwrap());\n\n let l1 = cin.next().unwrap();\n let r1 = cin.next().unwrap();\n let l2 = cin.next().unwrap();\n let r2 = cin.next().unwrap();\n let k = cin.next().unwrap();\n\n let r = min(r1, r2);\n let l = max(l1, l2);\n\n println!(\"{}\", max(0, r - l + 1 - if l <= k && k <= r { 1 } else { 0 } ));\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "5c63039874b594153eb09e7017c0d008", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0} {"lang": "Rust", "source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 998_244_353;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\nimpl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n\nimpl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n}\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n self.pow(MOD - 2)\n }\n}\n// ---------- end ModInt ----------\n// ---------- begin Precalc ----------\n#[allow(dead_code)]\nstruct Precalc {\n inv: Vec,\n fact: Vec,\n ifact: Vec,\n}\n\n#[allow(dead_code)]\nimpl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);\n fact[i] = fact[i - 1] * ModInt(i as u32);\n ifact[i] = ifact[i - 1] * inv[i];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n}\n// ---------- end Precalc ----------\n\nfn run() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut it = s.trim().split_whitespace();\n let p: usize = it.next().unwrap().parse().unwrap();\n let s: usize = it.next().unwrap().parse().unwrap();\n let r: usize = it.next().unwrap().parse().unwrap();\n let pc = Precalc::new(s + p);\n let mut ans = ModInt::zero();\n for v in r..=s {\n if p * v == s {\n ans += pc.inv(p);\n }\n for k in 1..p {\n if k * v > s {\n break;\n }\n let rem = s - k * v;\n let q = p - k;\n let mut way = ModInt::zero();\n let mut sign = ModInt::one();\n for x in 0..=q {\n if x * v > rem {\n break;\n }\n way += sign * pc.comb(rem - x * v + q - 1, q - 1) * pc.comb(q, x);\n sign = -sign;\n }\n ans += pc.comb(p - 1, k - 1) * way * pc.inv(k);\n }\n }\n ans *= pc.comb(s - r + p - 1, p - 1).inv();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2957c792bbbaddb08906c4b21dead34e", "src_uid": "609195ef4a970c62a8210dafe118580e", "difficulty": 2500.0} {"lang": "Rust", "source_code": "macro_rules! input {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input!{$next $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, bytes) => {\n read_value!($next, String).into_bytes()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\nconst MOD: i64 = 1000000007;\n\n// assume a, b positive\nfn gcd(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n (1, 0, a)\n }\n else {\n let (x, y, d) = gcd(b, a%b); // xb + y(a-qb) = d where q = a/b\n (y, x-y*(a/b), d)\n }\n}\n\nfn factorial_mod(a: i64) -> i64 {\n if a == 0 {\n 1\n }\n else {\n a * factorial_mod(a-1) % MOD\n }\n}\n\nfn binomial_mod(n: i64, k: i64) -> i64 {\n let a = factorial_mod(k);\n let b = factorial_mod(n-k);\n let (inv_a, _, _) = gcd(a, MOD);\n let (inv_b, _, _) = gcd(b, MOD);\n let result = factorial_mod(n) * inv_a % MOD * inv_b % MOD;\n if result < 0 { result + MOD } else { result }\n}\n\nfn main() {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input! {next,\n n: i64,\n m: i64,\n k: i64,\n }\n println!(\"{}\", binomial_mod(n-1,2*k)*binomial_mod(m-1,2*k) % MOD);\n // println!(\"{:?}\", matches);\n\n // println!(\"{}\", result);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7731f9eb1e23e5dd65c493dad2441869", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// \u3053\u3053\u307e\u3067\n\nfn run() {\n input! {\n n: usize,\n m: usize,\n }\n let ans = if n == m {\n 0\n } else if m <= 1 {\n 1\n } else if m <= n / 2 {\n m\n } else {\n n - m\n };\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "382c031b4fb3c9498a605a7118e88a36", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\nuse std::io::{ self, Write };\nuse std::str::FromStr;\nuse std::cmp::{ min, max };\nuse std::collections::{ BinaryHeap, VecDeque };\n\nmacro_rules! trace {\n ($var:expr) => ({\n let _ = writeln!(&mut std::io::stderr(), \">>> {} = {:?}\", stringify!($var), $var);\n })\n}\nmacro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }\n\n\nfn main() {\n let mut sc = Scanner::new();\n let mut cost = vec![vec![0; 3]; 3];\n let mut memo = vec![vec![vec![0; 3]; 3]; 42];\n\n for i in 0..3 {\n for j in 0..3 {\n cost[i][j] = sc.cin::();\n }\n }\n\n for i in 0..3 {\n for j in 0..3 {\n if i == j { continue }\n let k = 3 - i - j;\n memo[1][i][j] = min(cost[i][k] + cost[k][j], cost[i][j]);\n }\n }\n\n let n: usize = sc.cin();\n\n for m in 2..(n+1) {\n for i in 0..3 {\n for j in 0..3 {\n if i == j { continue }\n let k = 3 - i - j;\n memo[m][i][j] =\n min(\n memo[m-1][i][k] + memo[m-1][k][j] + cost[i][j],\n memo[m-1][i][j] + cost[i][k] + memo[m-1][j][i] + cost[k][j] + memo[m-1][i][j]);\n }\n }\n // trace!(m);\n // for i in 0..3 {\n // for j in 0..3 {\n // print!(\"{} \", memo[m][i][j]);\n // }\n // println!(\"\");\n // }\n }\n\n println!(\"{}\", memo[n][0][2]);\n\n}\n\n#[allow(dead_code)]\nstruct Scanner { stdin: io::Stdin, buffer: VecDeque, }\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }\n fn reserve(&mut self) {\n while self.buffer.len() == 0 {\n let mut line = String::new();\n let _ = self.stdin.read_line(&mut line);\n for w in line.split_whitespace() {\n self.buffer.push_back(String::from(w));\n }\n }\n }\n fn cin(&mut self) -> T {\n self.reserve();\n match self.buffer.pop_front().unwrap().parse::() {\n Ok(a) => a,\n Err(_) => panic!(\"parse err\")\n }\n }\n fn get_char(&mut self) -> char {\n self.reserve();\n let head = self.buffer[0].chars().nth(0).unwrap();\n let tail = String::from( &self.buffer[0][1..] );\n if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }\n head\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e7542a94ff4cda420558134174819dad", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "Rust", "source_code": "fn read_line(mut buffer: &mut String) -> Vec {\n std::io::stdin().read_line(&mut buffer).expect(\"Error while reading input.\");\n let data = buffer.split_whitespace().map(|x| x.parse::().unwrap()).collect();\n buffer.clear();\n data\n}\n\nfn get_index(i: usize, n: usize) -> String {\n let bin_str = format!(\"{:0width$b}\", i, width = n);\n bin_str\n}\n\nfn limit(n: usize) -> usize {\n let mut n_bin = String::with_capacity(n);\n for _i in 0..n {\n n_bin.push('1');\n }\n let limit = usize::from_str_radix(&n_bin, 2).unwrap();\n limit\n}\nfn calculate(index: &String, c: &Vec, min: usize, max: usize, diff: usize) -> usize {\n let mut sum = 0;\n let mut cmin = 10_usize.pow(6) + 1;\n let mut cmax = 0;\n for (i, ch) in index.chars().enumerate() {\n if ch == '1' {\n if c[i] > cmax {\n cmax = c[i];\n }\n if c[i] < cmin {\n cmin = c[i];\n }\n sum += c[i]; \n }\n }\n // need to find min and max\n if sum >= min && sum <= max && (cmax - cmin) >= diff {\n return 1 \n }\n 0\n}\n\nfn get_count(index: &String) -> usize {\n let mut count = 0;\n for ch in index.split(\"\") {\n if ch == \"1\" {\n count += 1;\n }\n }\n count\n}\n\nfn main() {\n let mut buffer = String::new();\n \n let d = read_line(&mut buffer);\n //println!(\"D: {:?}\", d);\n \n let (n, min, max, diff) = (d[0], d[1], d[2], d[3]);\n \n let c = read_line(&mut buffer);\n //println!(\"c: {:?}\", c);\n\n let limit = limit(n);\n let mut result = 0;\n\n for i in 1..=limit {\n let index = get_index(i, n);\n let count = get_count(&index);\n if count > 1 { \n //println!(\"{:?}\", index);\n let res = calculate(&index, &c, min, max, diff);\n if res == 1 {\n //println!(\"now\");\n }\n result += res;\n }\n }\n println!(\"{}\", result);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "fbf7fc14140ba3aa67c7fdc2bae2d50f", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead};\n\nfn main() {\n let mut line = String::new();\n let stdin = io::stdin();\n stdin\n .lock()\n .read_line(&mut line)\n .expect(\"could not read line!\");\n\n let line = line.trim();\n let path = line\n .split('/')\n .filter(|s| !s.is_empty())\n .collect::>();\n\n println!(\"/{}\", path.join(\"/\"));\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "704d2f3001a5478e6fc9abafb3de700a", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "Rust", "source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 \u3088\u308a\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: usize,\n q: usize,\n op: [(bytes, bytes); q],\n }\n let mut p = vec![];\n for (a, b) in op {\n let a = (a[1] - b'a') as usize * 6 + (a[0] - b'a') as usize;\n let b = (b[0] - b'a') as usize;\n p.push((a, b));\n }\n let mut ok = vec![false; 6];\n ok[0] = true;\n for _ in 2..=n {\n let mut next = vec![false; ok.len() * 6];\n for (i, _) in ok.iter().enumerate().filter(|p| *p.1) {\n for &(a, b) in p.iter() {\n if i % 6 == b {\n next[(i / 6) * 36 + a] = true;\n }\n }\n }\n ok = next;\n }\n let ans = ok.into_iter().filter(|p| *p).count();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "090359f1c38588ba74db344f924c7321", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Read, Write, BufWriter};\n#[allow(dead_code)]\nfn getline() -> String {\n let mut ret = String::new();\n std::io::stdin().read_line(&mut ret).ok().unwrap();\n ret\n}\nfn get_word() -> String {\n let mut stdin = std::io::stdin();\n let mut u8b: [u8; 1] = [0];\n loop {\n let mut buf: Vec = Vec::with_capacity(16);\n loop {\n let res = stdin.read(&mut u8b);\n if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {\n break;\n } else {\n buf.push(u8b[0]);\n }\n }\n if buf.len() >= 1 {\n let ret = String::from_utf8(buf).unwrap();\n return ret;\n }\n }\n}\n\n#[allow(dead_code)]\nfn get() -> T { get_word().parse().ok().unwrap() }\n\nmod pollard_rho {\n use std::collections::HashMap;\n /// binary gcd\n pub fn gcd(mut x: i64, mut y: i64) -> i64 {\n if y == 0 { return x; }\n if x == 0 { return y; }\n let mut sh = 0;\n while ((x | y) & 1) == 0 {\n x >>= 1; y >>= 1; sh += 1;\n }\n while (x & 1) == 0 { x >>= 1; }\n while y != 0 {\n while (y & 1) == 0 { y >>= 1; }\n if x > y { let t = x; x = y; y = t; }\n y -= x;\n }\n x << sh\n }\n\n fn add_mod(x: i64, y: i64, n: i64) -> i64 {\n let z = x + y;\n if z >= n { z - n } else { z }\n }\n\n fn mul_mod(x: i64, mut y: i64, n: i64) -> i64 {\n assert!(x >= 0);\n assert!(x < n);\n let mut sum = 0;\n let mut cur = x;\n while y > 0 {\n if (y & 1) == 1 {\n sum = add_mod(sum, cur, n);\n }\n cur = add_mod(cur, cur, n);\n y >>= 1;\n }\n sum\n }\n\n fn mod_pow(x: i64, mut e: i64, n: i64) -> i64 {\n let mut prod = if n == 1 { 0 } else { 1 };\n let mut cur = x % n;\n while e > 0 {\n if (e & 1) == 1 {\n prod = mul_mod(prod, cur, n);\n }\n cur = mul_mod(cur, cur, n);\n e >>= 1;\n }\n prod\n }\n\n pub fn is_prime(n: i64) -> bool {\n if n <= 1 { return false; }\n let small = [2, 3, 5, 7, 11, 13];\n if small.iter().any(|&u| u == n) { return true; }\n if small.iter().any(|&u| n % u == 0) { return false; }\n let mut d = n - 1;\n let mut e = 0;\n while (d & 1) == 0 {\n d >>= 1;\n e += 1;\n }\n let a = [2, 325, 9375, 28178, 450775, 9780504, 1795265022];\n a.iter().all(|&a| {\n if a >= n { return true; }\n let mut x = mod_pow(a, d, n);\n if x == 1 { return true; }\n for _ in 0 .. e {\n if x == n - 1 {\n return true;\n }\n x = mul_mod(x, x, n);\n if x == 1 { return false; }\n }\n x == 1\n })\n }\n\n fn pollard_rho(n: i64, c: &mut i64) -> i64 {\n if n % 2 == 0 { return 2; }\n loop {\n let mut x: i64 = 2;\n let mut y = 2;\n let mut d = 1;\n let cc = *c;\n let f = |i| add_mod(mul_mod(i, i, n), cc, n);\n while d == 1 {\n x = f(x);\n y = f(f(y));\n d = gcd((x - y).abs(), n);\n }\n if d == n {\n *c += 1;\n continue;\n }\n return d;\n }\n }\n\n /// Outputs (p, e) in p's ascending order.\n pub fn factorize(x: i64) -> Vec<(i64, usize)> {\n if x <= 1 {\n return Vec::new();\n }\n let mut hm = HashMap::new();\n let mut pool = vec![x];\n let mut c = 1;\n while let Some(u) = pool.pop() {\n if is_prime(u) {\n *hm.entry(u).or_insert(0) += 1;\n continue;\n }\n let p = pollard_rho(u, &mut c);\n pool.push(p);\n pool.push(u / p);\n }\n let mut v: Vec<_> = hm.into_iter().collect();\n v.sort();\n v\n }\n} // mod pollard_rho\n\n/// Generates an Iterator over subsets of univ, in the descending order. \n/// Verified by: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3050308\nstruct SubsetIter { bits: Option, univ: usize }\nimpl Iterator for SubsetIter {\n type Item = usize;\n fn next(&mut self) -> Option {\n match self.bits {\n None => None,\n Some(bits) => {\n let ans = bits;\n self.bits =\n if bits == 0 { None }\n else { Some((bits - 1) & self.univ) };\n Some(ans)\n }\n }\n }\n}\nfn subsets(univ: usize) -> SubsetIter {\n SubsetIter { bits: Some(univ), univ }\n}\n\n\nuse pollard_rho::*;\n\nfn solve() {\n let n = get();\n let x: i64 = get();\n let y: i64 = get();\n if y % x != 0 {\n println!(\"0\");\n return;\n }\n let a: Vec = (0 .. n).map(|_| get()).collect();\n let b: Vec = a.iter().filter_map(|&a| if a % x == 0 { Some(a / x) } else { None }).collect();\n let c: Vec = a.iter().filter_map(|&a| if y % a == 0 { Some(y / a) } else { None }).collect();\n let y = y / x;\n let fac = factorize(y);\n let m = fac.len();\n let mut pat1 = vec![0i64; 1 << m];\n let mut pat2 = vec![0i64; 1 << m];\n for &b in &b {\n let mut hot = 0;\n for i in 0 .. m {\n let p = fac[i].0;\n if b % p == 0 {\n hot |= 1 << i;\n }\n }\n pat1[hot] += 1;\n }\n for &c in &c {\n let mut hot = 0;\n for i in 0 .. m {\n let p = fac[i].0;\n if c % p == 0 {\n hot |= 1 << i;\n }\n }\n pat2[hot] += 1;\n }\n let mut ans = 0;\n for bits in 0 .. 1 << m {\n for opp in subsets((1 << m) - 1 - bits) {\n ans += pat1[bits] * pat2[opp];\n }\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c809f84871c0d73502ddd6b587af7aad", "src_uid": "8d43a542d5bf79d15926c4a6a5ff608f", "difficulty": 2700.0} {"lang": "Rust", "source_code": "//spnauti-rust\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::*;\n#[allow(unused_imports)] use std::collections::*;\n\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\n#[allow(dead_code)]\nfn build_counting_hashmap(i: T) -> HashMap\n where T: Iterator {\n let mut m = HashMap::new();\n for k in i {\n let n = 1 + if let Some(&n) = m.get(&k) { n } else { 0 };\n m.insert(k, n);\n }\n m\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let mut a: i64 = input.p();\n let mut b: i64 = input.p();\n let mut sol = 0;\n while b > 0 {\n sol += a / b;\n let t = a % b;\n a = b;\n b = t;\n }\n println!(\"{}\", sol);\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "4639853673883f67012014ea271503a8", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n#[allow(unused_imports)]\nuse std::collections::{HashMap,HashSet,VecDeque};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn gcd(a: i64, b: i64) -> i64 {\n if a > b {\n return gcd(b,a);\n }\n if a == 0 {\n return 0;\n } else {\n return (b/a) + gcd(b%a,a);\n }\n}\n\nfn main() {\n let (a,b) = readln!(i64,i64);\n let res = gcd(a,b);\n println!(\"{}\",res);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b26f17fa51605823e1cc34438889a0bf", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "Rust", "source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n}\n\nfn gcd(a: usize, b: usize) -> usize {\n let mut x = a;\n let mut y = b;\n let mut tmp = 0usize;\n while x > 0 {\n tmp = x;\n x = y % x;\n y = tmp;\n }\n y\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let a: usize = scan.next();\n let b: usize = scan.next();\n let c: usize = scan.next();\n let d: usize = scan.next();\n let mut p = 0usize;\n let mut q = 0usize;\n if a * d >= c * b {\n p = c * b;\n q = a * d;\n } else {\n p = d * a;\n q = b * c;\n }\n p = q - p;\n let m = gcd(p, q);\n p = p / m;\n q = q / m;\n println!(\"{}/{}\", p, q);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1 << 23)\n .spawn(_main)\n .unwrap()\n .join()\n .unwrap();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2eb243e719fdaf90bb991e7342a37999", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn gcd(a: i64, b: i64) -> i64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn to_fraction(num: i64, denom: i64) -> (i64, i64) {\n let g = gcd(num, denom);\n (num / g, denom / g)\n}\n\nfn max_fraction(num1: i64, denom1: i64, num2: i64, denom2: i64) -> (i64, i64) {\n if num1 * denom2 < num2 * denom1 {\n to_fraction(num2, denom2)\n }\n else {\n to_fraction(num1, denom1)\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: i64 = scan.token();\n let b: i64 = scan.token();\n let c: i64 = scan.token();\n let d: i64 = scan.token();\n\n let num1 = a * d - b * c;\n let denom1 = a * d;\n let num2 = b * c - a * d;\n let denom2 = b * c;\n\n let ans = max_fraction(num1, denom1, num2, denom2);\n writeln!(out, \"{}/{}\", ans.0, ans.1).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "d5dd1dca7446f54392191239b0c1e887", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "Rust", "source_code": "fn main() {\n let mut sc = new(std::io::stdin());\n let n: usize = sc.next();\n let mut a: Vec = vec![];\n let mut tot = 0;\n for i in 0..n {\n a.push(sc.next());\n tot += a[i];\n }\n let mut dp = vec![vec![0;2]; n+1];\n for i in (0..n).rev() {\n if i == n - 1 {\n dp[i][0] = a[i];\n dp[i][1] = 0;\n } else {\n dp[i][0] = std::cmp::max(dp[i + 1][0], a[i] + dp[i + 1][1]);\n dp[i][1] = std::cmp::min(dp[i + 1][1] + a[i], dp[i + 1][0]);\n }\n }\n println!(\"{} {}\", tot - dp[0][0], dp[0][0]);\n}\n\nuse std::io;\nuse std::io::BufRead;\n\npub struct Scanner {\n br: io::BufReader,\n // Read tokens are stored in reversed order per line.\n buf: Vec,\n}\n\npub fn new(r: R) -> Scanner {\n Scanner::new(r)\n}\n\nimpl Scanner {\n #[inline]\n fn new(r: R) -> Scanner {\n Scanner {\n br: io::BufReader::new(r),\n buf: vec![],\n }\n }\n #[inline]\n pub fn next(&mut self) -> T\n where T: std::str::FromStr,\n T::Err: std::fmt::Debug\n {\n self.next_string().map(|s| s.parse::().expect(\"Parse failed: \")).unwrap()\n }\n fn next_string(&mut self) -> Option {\n self.buf.pop().or_else(|| match self.update() {\n true => self.next_string(),\n false => None,\n })\n }\n #[inline]\n fn update(&mut self) -> bool {\n let mut s = String::new();\n let res = self.br.read_line(&mut s);\n match res.expect(\"I/O error.\") {\n 0 => false,\n _ => {\n self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();\n true\n }\n }\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e48e427be748bbfbb9db7fb4de7b5178", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::cmp;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let n: i32 = input.trim().parse().unwrap();\n let mut segs: Vec<(i32, i32, i32)> = vec![];\n for i in 0..(n+1) {\n for j in (i+1)..(n+1) {\n segs.push((j-i,i,j));\n }\n }\n segs.sort();\n let mut result: i32 = 0;\n let mut flags: Vec = vec![false; segs.len()];\n for i in (0..segs.len()).rev() {\n if flags[i] { continue; }\n let (size, mut a, mut b) = segs[i];\n flags[i] = true;\n let mut cur: i32 = size;\n while cur < n {\n let mut did_something = false;\n for j in (0..segs.len()).rev() {\n if flags[j] { continue; }\n let (s, c, d) = segs[j];\n if a == d || b == c {\n if cur + s <= n {\n a = cmp::min(a, c);\n b = cmp::max(b, d);\n cur += s;\n flags[j] = true;\n did_something = true;\n }\n }\n }\n if !did_something { break; }\n }\n result += 1;\n }\n println!(\"{}\", result);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c099aaed4e128d83578f1dc86c829c43", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "Rust", "source_code": "\nfn main() {\n let areas: Vec = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();\n \n let a = (areas[0] * areas[1] / areas[2]).sqrt();\n let b = (areas[0] * areas[2] / areas[1]).sqrt();\n let c = (areas[2] * areas[1] / areas[0]).sqrt();\n let res = 4 * (a+b+c) as u32;\n\n println!(\"{}\", res);\n \n}\n\nfn get_input() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n buffer.trim().to_owned()\n}\n\nfn get_input_usize() -> usize {\n get_input().parse().unwrap()\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f3302eddd2152748f268dc749f93b77b", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "Rust", "source_code": "fn read_string() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n input\n}\n\nfn main(){\n let now_time = read_string().replace(\"\\n\", \"\").replace(\"\\r\", \"\");\n let sleep_time = read_string().replace(\"\\n\", \"\").replace(\"\\r\", \"\");\n let now_vec: Vec<&str> = now_time.split(\":\").collect();\n let sleep_vec: Vec<&str> = sleep_time.split(\":\").collect();\n let mut hours = now_vec[0].parse::().unwrap() - sleep_vec[0].parse::().unwrap();\n let mut minutes = now_vec[1].parse::().unwrap() - sleep_vec[1].parse::().unwrap();\n if hours < 0{\n hours = 24+hours;\n }\n if minutes < 0{\n minutes = 60+minutes\n }\n println!(\"{}{}:{}{}\", if hours<10 {\"0\"} else {\"\"}, hours, if minutes<10 {\"0\"} else {\"\"},minutes);\n }", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "5a9b5d1028addeda8a86eaf3051a29e5", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0} {"lang": "Rust", "source_code": "use std::io::{self, Write};\n\nfn read_line() -> String {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n s.trim().to_owned()\n}\n\nfn reads() -> Vec\nwhere\n T: std::str::FromStr,\n ::Err: std::fmt::Debug,\n{\n read_line()\n .split_whitespace()\n .map(|w| w.parse().unwrap())\n .collect()\n}\n\nfn main() {\n let n: usize = reads()[0];\n\n let mut aa: Vec = reads();\n\n while aa.len() > 0 {\n let mut maxi = 0;\n for i in 0..aa.len() {\n if aa[maxi] < aa[i] {\n maxi = i;\n }\n }\n\n if maxi > 0 && (aa[maxi - 1] - aa[maxi]).abs() >= 2 {\n println!(\"NO\");\n return;\n }\n\n if maxi + 1 < aa.len() && (aa[maxi + 1] - aa[maxi]).abs() >= 2 {\n println!(\"NO\");\n return;\n }\n\n aa.remove(maxi);\n }\n\n println!(\"YES\");\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "8ba6e046382b31e2e2ff766c23efce37", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() {\n let mut buf = String::new();\n for _i in 0..3 {\n let _ = stdin().read_line(&mut buf);\n buf = buf.trim_end().to_string();\n }\n\n let x = buf.as_bytes();\n let mut ans = true;\n for i in 0..x.len()/ 2 {\n ans = ans && x[i] == x[x.len() - i - 1];\n }\n\n println!(\"{}\", if ans { \"YES\" } else { \"NO\" });\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "48754fb5cfddbec112f196199d5b1610", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0}