{"lang": "Rust", "source_code": "use std::io;\nuse std::io::prelude::*;\n\nfn main() -> Result<()> {\n let mut input = String::new();\n\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 println!(\"{}\", div(n, k));\n Ok(())\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}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "23a081d51666b0d28eab1ec48ad0cbe2", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::stdin;\n\nfn main() {\n let line = String::new();\n 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": "e28b3cb3fc4fbcdab333af5bf72012d8", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut stdin = io::stdin();\n let mut stdin = stdin.lock();\n \n let mut line = String::new();\n stdin::read_line(&mut line);\n \n let parsed: usize = line.parse().unwrap();\n \n if parsed & 1 == 1 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "6b3ca426f0b02ceae8a3ed27acd813cf", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "extern crate utils;\nuse utils::*;\n\nfn main() {\n let input = read_line().parse::().unwrap();\n if input <= 2 { println!(\"NO\"); }\n else if input % 2 == 0 { println!(\"YES\"); }\n else { println!(\"NO\"); }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "a3b2490b74fcf9256e57648e714fa0b3", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn 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 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": "cc566b0ef9c05de61160e98a3f25e4ac", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "// https://codeforces.com/problemset/problem/4/A\n\nuse std::{\n io::{\n stdin,\n stdout,\n },\n vec::Vec,\n};\n\nfn main() {\n let inp = stdin();\n let mut num_str = String::new();\n inp.read_to_string(&mut num_str);\n\n let num = num_str.parse::().unwrap();\n\n if num % 2 == 0 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ee472d1d96f87fb7e74ee92ed133769f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\n\nfn is_splittable(weight: u32) {\n weight > 2 && weight % 2 == 0;\n}\n\n\nfn main() {\n let mut weight = String::new();\n io::stdin().read_line(&mut weight).unwrap();\n let weight: u32 = weight.trim().parse().unwrap();\n println!(\"{}\", if is_splittable(weigth) {\"YES\"} else {\"NO\"});\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "c3fa2801cbdb475587f48b2014a1b267", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n\n let mut x = String::new();\n\n io::stdin().read_line(&mut x).expect(\"error\");\n\n let x: u8 = x.trim().parse().expect(\"error\");\n\n if (res >= 1 | res <= 100) {\n let res = x % 2;\n\n if (res == 0) {\n println!(\"YES\");\n } \n }\n\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "1a3b219339c55012d9eae58bd59abd09", "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 = weight.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": "2e0087b5fb7cee97abf16f252cb39a21", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": " use std::io;\n \n fn main() {\n let mut stdin = io::stdin();\n let mut stdin = stdin.lock();\n \n let mut line = String::new();\n stdin.read_line(&mut line);\n \n let parsed: usize = line.parse().unwrap();\n \n if parsed & 1 == 1 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n }", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d53207c257d9a8a982819e1aa09000b0", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main () {\n // read\n let mut s = String::new();\n io::stdin().read_line(&mut s);\n\n let int_vec: Vec =s.trim()\n .split(\" \")\n .map(|x|{\n x.parse::().expect(\"not an integer\")\n })\n .collect();\n\n let mut a :u32 = int_vec[0];\n\n if a%2==0{\n println!(\"YES\");\n }else{\n println!(\"NO\");\n }\n\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "7633a9fbcbcf107e3f09c2bdfec266e2", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "Rust", "source_code": "// ---------- begin scannner ----------\r\n#[allow(dead_code)]\r\nmod scanner {\r\n\tuse std::str::FromStr;\r\n\tpub struct Scanner<'a> {\r\n\t\tit: std::str::SplitWhitespace<'a>,\r\n\t}\r\n\timpl<'a> Scanner<'a> {\r\n\t\tpub fn new(s: &'a String) -> Scanner<'a> {\r\n\t\t\tScanner {\r\n\t\t\t\tit: s.split_whitespace(),\r\n\t\t\t}\r\n\t\t}\r\n\t\tpub fn next(&mut self) -> T {\r\n\t\t\tself.it.next().unwrap().parse::().ok().unwrap()\r\n\t\t}\r\n\t\tpub fn next_bytes(&mut self) -> Vec {\r\n\t\t\tself.it.next().unwrap().bytes().collect()\r\n\t\t}\r\n\t\tpub fn next_chars(&mut self) -> Vec {\r\n\t\t\tself.it.next().unwrap().chars().collect()\r\n\t\t}\r\n\t\tpub fn next_vec(&mut self, len: usize) -> Vec {\r\n\t\t\t(0..len).map(|_| self.next()).collect()\r\n\t\t}\r\n\t}\r\n}\r\n// ---------- end scannner ----------\r\nuse std::io::Write;\r\nfn main() {\r\n\tuse std::io::Read;\r\n\tlet mut s = String::new();\r\n\tstd::io::stdin().read_to_string(&mut s).unwrap();\r\n\tlet mut sc = scanner::Scanner::new(&s);\r\n\tlet out = std::io::stdout();\r\n\tlet mut out = std::io::BufWriter::new(out.lock());\r\n\tlet t: usize = sc.next();\r\n\tfor _ in 0..t {\r\n\t\tsolve(&mut sc, &mut out);\r\n\t}\r\n}\r\nconst MOD: i64 = 10_i64.pow(9) + 7;\r\nfn binary_exponentiation(a: i32, b: i32) -> i32 {\r\n\tlet mut ans: i64 = 1;\r\n\tlet mut a: i64 = a as i64 % MOD;\r\n\tlet mut b = b;\r\n\twhile b != 0 {\r\n\t\tif 1 == (b & 1) {\r\n\t\t\tans = (ans * a as i64) % MOD;\r\n\t\t}\r\n\t\ta = (a * a) % MOD;\r\n\t\tb >>= 1;\r\n\t}\r\n\treturn ans as i32;\r\n}\r\nfn solve(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter) {\r\n\tlet (n, k): (i32, i8) = (sc.next(), sc.next());\r\n\tlet ans = binary_exponentiation(n.into(), k.into());\r\n\twriteln!(out, \"{}\", ans).ok();\r\n}\r\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ffc3711e69306b57d695b424801494a8", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0} {"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().to_string());\n }\n }\n println!();\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "fb4c57cc6a948185b7761dbc4b87a60e", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "Rust", "source_code": "fn main() {\n\tlet mut nums = String::new();\n\n\tstd::io::stdin().read_line(&mut nums).unwrap();\n\n\tlet nums : Vec = nums.split_ascii_whitespace()\n\t\t.take(3)\n\t\t.map(|x| x.parse().unwrap())\n\t\t.collect();\n\n\tlet (n, m, a) = (nums[0], nums[1], nums[2]);\n\tlet mut res = n / a + ((n % a > 0) as u32);\n\tres *= m / a + ((m % a > 0) as u32);\n\n\tprintln!(\"{}\", res);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ed30ce077d983a56047fd952e7fe65ae", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut buffer = String::new();\n\n io::stdin().read_line(&mut buffer).unwrap();\n let mut it = buffer.trim().split_whitespace()\n .map(|x| {x.parse::().unwrap()});\n\n let n = it.next().unwrap();\n let m = it.next().unwrap();\n let a = it.next().unwrap();\n let number_of_squares_required: = ((n/a).ceil() * (m/a).ceil());\n println!(\"{:?}\", number_of_squares_required);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "002250d3171f5288aa964651c4389626", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "pub fn read_word() -> String {\n\tuse std::io::prelude::*;\n\tlet mut word: Vec = vec![];\n\n\tfor c in ::std::io::stdin().bytes() {\n\t\tlet c = c.unwrap();\n\t\tif (c as char).is_whitespace() {\n\t\t\tif !word.is_empty() {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tword.push(c);\n\t\t}\n\t}\n\t::std::str::from_utf8(&word).unwrap().to_string()\n}\n\nmacro_rules! read {\n\t() => { read!(\"\") };\n\t($msg:expr) => {{\n\t\tuse std::io::Write;\n\t\tprint!(\"{}\", $msg);\n\t\tstd::io::stdout().flush().unwrap();\n\t\tstd::str::FromStr::from_str(&read_word()).unwrap()\n\t}};\n}\n\nfn main() {\n\tlets!{ n: f32, m: f32, a: f32 = read!() };\n\tprintln!(\"{:?}\", (n/a).ceil() * (m/a).ceil());\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "12160a68bc13545bf871af0f2edde63b", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::cmp;\nuse std::error::Error;\nuse std::io::{self, Read};\n\nfn main() -> Result<(), Box> {\n let mut stdin = io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line)?;\n let num_digits: usize = line.trim().parse()?;\n let mut digits = vec![0u8; num_digits];\n stdin.read_exact(&mut digits)?;\n let num_eights = digits.iter().filter(|c| **c == b'8').count();\n println!(\"{}\", cmp::min(num_digits / 11, num_eights));\n Ok(())\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "96c22eb4844e42589e610c9e15480bce", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n let mut x = Int::new();\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": "b14dbffdcc5688d6f2e4641878cb75d8", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.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\nfn solve() {\n let n: usize = get();\n let k = get();\n let m: i64 = get();\n let mut t: Vec = (0 .. k).map(|_| get()).collect();\n t.sort();\n let tsum: i64 = t.iter().sum();\n let mut ma = 0;\n for comp in 0 .. n + 1 {\n let rem = m - comp as i64 * tsum;\n if rem < 0 {\n break;\n }\n let mut remtask = Vec::new();\n for _ in 0 .. n - comp {\n remtask.append(&mut t.clone());\n }\n remtask.sort();\n let mut tot = 0;\n let mut pos = 0;\n while pos < remtask.len() {\n tot += remtask[pos];\n if tot > rem {\n break;\n }\n pos += 1;\n }\n ma = max(ma, comp * (t.len() + 1) + pos);\n }\n println!(\"{}\", ma);\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": true, "code_uid": "a46c15fb41b57048c9119e5fcf51cc9a", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "Rust", "source_code": "use std::io::prelude::*;\nuse std::io;\n\nfn main() {\n let stdin = io::stdin();\n let mut s = stdin.lock().lines().next().unwrap().unwrap();\n\n is_nice_word(&s);\n}\n\nfn is_nice_word(s: &String) {\n\n // list of the last position each letter A-Z was seen\n let mut laspos = [-1; 26];\n //how many wildcards '?' there were in the last 26 characters\n let mut wildcd = 0;\n\n for i in 0..(s.len()) {\n match s.chars().skip(i).next().unwrap() {\n '?' => {\n wildcd += 1;\n },\n chr => {\n laspos[((chr as u8) - ('A' as u8)) as usize] = i;\n }\n }\n\n if i > 26 {\n match s.chars().skip(i-26).next().unwrap() {\n '?' => {\n wildcd -= 1;\n },\n _ => ()\n }\n }\n\n // count how many letters occur in the last 26 characters and remember the ones that didn't\n // also keep track of how many wildcards we have seen\n let mut count = 0;\n let mut letters : Vec= vec![];\n for j in 0..26 {\n if i - laspos[j] < 26 {\n count += 1;\n } else {\n letters.push((('A' as u8) + j as u8) as char);\n }\n }\n \n //If we have seen enough characters and wildcards, print out the string.\n if count + wildcd >= 26 {\n for chr in s.chars().skip(i-25).take(26) {\n match chr {\n '?' => {\n print!(\"{}\", letters.pop().unwrap_or('?'));\n },\n c => {\n print!(\"{}\", c);\n }\n }\n }\n println!(\"\");\n return;\n }\n\n\n }\n\n println!(\"-1\");\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "c9a2092b56fede53bc63067331dde595", "src_uid": "a249431a4b0b1ade652997fe0b82edf3", "difficulty": 1300.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin()\n .readln(&mut s)\n .unwrap();\n\n let words = s\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n for i in 1..10 {\n if i * words[0] % 10 == words[1] || i * words[0] % 10 == 0 {\n println!(\"{}\", i);\n break;\n }\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "ea9131efff06e54a7d14ad994857701f", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "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!(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": true, "code_uid": "df2dee87265808ea147a12ddf6de1d39", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.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 c in input1.chars(){ \n blackCount += calcular_black(c); \n whiteCount += calcular_white(c);\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": "5e5d7c1c2c8622422951c6679f4f98eb", "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}\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\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": "1bd5ab3bbce8d9eef770f28734fb565d", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "Rust", "source_code": "pub fn get_digits_len(mut k: usize) -> usize {\n let mut n: usize = 1;\n \n loop {\n k /= 10;\n\n if k > 0 {\n n+=1;\n }else{\n break n;\n }\n }\n}\n\npub fn get_nth_right_digit(n: usize, k: usize) -> usize {\n \n (k/usize::pow(10, n as u32)) % 10\n}\n\npub fn get_kth(mut k: usize) -> usize {\n let mut x: usize = 1;\n\n 'outer: loop {\n let n = get_digits_len(x);\n\n if n > k {\n break get_nth_right_digit(n-k, x);\n } else if (k - n) == 0 {\n break get_nth_right_digit(0, x);\n } else {\n k -= n;\n }\n\n x += 1;\n }\n}\n\nuse std::{io, io::BufRead};\n\nfn main() {\n println!(\"{}\", io::stdin().lock().lines().take(1).map(|l| str::parse::(&l.unwrap()).unwrap()).map(|k| get_kth(k)).last().unwrap())\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "450e1a9c5e255cad57174f30a33d029e", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.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// Extended Euclidean GCD {{{\nfn extended_euclid(a: i64, b: i64) -> (i64,i64,i64) {\n\tif b == 0 {\n\t\t(a,1,0)\n\t} else {\n\t\tlet q = a.div_euclid(b);\n\t\tlet r = a.rem_euclid(b);\n\t\tlet (d,x,y) = extended_euclid(b, r);\n\t\t(d, y, x-q*y)\n\t}\n}//}}}\nfn div_floor(a: i64, b: i64) -> i64 {\n\tassert!(b != 0);\n\tlet (a,b) = if b < 0 {(-a,-b)} else {(a,b)};\n\tif a % b == 0 || a >= 0 {\n\t\ta / b\n\t} else {\n\t\ta / b - 1\n\t}\n}\nfn div_ceil(a: i64, b: i64) -> i64 {\n\tassert!(b != 0);\n\tlet (a,b) = if b < 0 {(-a,-b)} else {(a,b)};\n\tif a % b == 0 || a <= 0 {\n\t\ta / b\n\t} else {\n\t\ta / b + 1\n\t}\n}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tl!(n,p,a,b = rin.l());\n\tlet (g,x0,y0) = extended_euclid(a,b);\n\tif p % g == 0 {\n\t\tlet e = p / g;\n\t\tlet x = x0 * e;\n\t\tlet y = y0 * e;\n\t\tlet ca = -b / g;\n\t\tlet cb = a / g;\n\t\tlet kx0 = div_ceil(n - x, ca);\n\t\tlet kx1 = div_floor(-x, ca);\n\t\tlet ky0 = div_ceil(-y, cb);\n\t\tlet ky1 = div_floor(n - y, cb);\n\t\tlet k0 = kx0.max(ky0);\n\t\tlet k1 = kx1.min(ky1);\n\t\tif k0 <= k1 {\n\t\t\tfor k in vec![k0,k1] {\n\t\t\t\tlet xx = x + k * ca;\n\t\t\t\tlet yy = y + k * cb;\n\t\t\t\tif xx + yy <= n {\n\t\t\t\t\twriteln!(rout, \"{} {} {}\", xx, yy, n - xx - yy).ok();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\twriteln!(rout, \"-1\").ok();\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "be132f94538b9658cbb1e9445b564ba3", "src_uid": "503116e144d19eb953954d99c5526a7d", "difficulty": 2000.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,z)= scan!(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": "12ddf41f72254966619362e57668efc2", "src_uid": "e87d9798107734a885fd8263e1431347", "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": "5cd04de775758091f5f2bb964213b308", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.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 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) => 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": "60fc71dacfd194ba614fbab66c1c1655", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "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 mut t = String::new();\n io::stdin()\n .read_line(&mut t)\n .unwrap()\n .graphemes(true)\n .rev()\n .collect();\n\n if s == t {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "778003956280df7125b7a17f290d8723", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn read_line() -> String {\n let mut line = String::new();\n std::io::stdin()\n .read_line(&mut line)\n .expect(\"Could not read line\");\n String::from(&line[..line.len() - 1])\n}\n\nmacro_rules! read_line {\n ([$t: ty]) => {{\n read_line().split_whitespace().map(|token| {\n <$t as std::str::FromStr>::from_str(token).expect(\n &format!(concat!(\"Could not parse {} into \", stringify!($t)), token))\n })\n }};\n ($($t: ty),*) => {{\n let line = read_line();\n let mut iter = line.split_whitespace();\n ($({\n let token = iter.next().expect(\"Not enough tokens\");\n <$t as std::str::FromStr>::from_str(token).expect(\n &format!(concat!(\"Could not parse {} into \", stringify!($t)), token))\n }),*)\n }};\n}\n\nfn main() {\n read_line!(usize);\n enum State {\n Up,\n Hold,\n Down,\n }\n use State::*;\n let mut state = Up;\n let mut prev = 0;\n let mut ans = true;\n for x in read_line!([u16]) {\n match state {\n Hold => {\n if x > prev {\n ans = false;\n break;\n }\n }\n Down => {\n if x >= prev {\n ans = false;\n break;\n }\n }\n Up => {}\n }\n state = if x < prev {\n Down\n } else if x > prev {\n Up\n } else {\n Hold\n };\n prev = x;\n }\n println!(\"{}\", if ans { \"YES\" } else { \"NO\" });\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "aa4aa99edd9b5f9ef694491022d5d043", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\n#![allow(dead_code)]\n#![allow(unused_variables)]\nuse std::cmp::min;\nuse std::io;\nuse std::{io::prelude::*, io::*, str};\n\nstruct IO {\n buffer: Vec,\n out: BufWriter,\n}\nimpl IO {\n fn new() -> Self {\n Self {\n buffer: vec![],\n out: BufWriter::new(stdout()),\n }\n }\n fn read(&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 fn read_vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read::()).collect()\n }\n}\n\nconst MOD: u64 = 998244353;\n\nfn fastpow(mut a: u64, mut x: u64) -> u64 {\n let mut r = 1;\n while x != 0 {\n if x & 1 != 0 {\n r = (r * a) % MOD;\n }\n\n a = (a * a) % MOD;\n x >>= 1;\n }\n r\n}\n\nfn modinv(x: u64) -> u64 {\n fastpow(x, MOD - 2)\n}\n\nfn solve(io: &mut IO) -> Result<()> {\n let (n, x): (usize, usize) = (io.read(), io.read());\n let mut comb = vec![vec![1; n + 1]; n + 1];\n let mut fact = vec![1; n + 1];\n\n for i in 1..=n {\n fact[i] = (fact[i - 1] * (i as u64)) % MOD;\n\n for j in 1..=i {\n let rem = (fact[j] * fact[i - j]) % MOD;\n let rinv = modinv(rem);\n\n comb[i][j] = (fact[i] * rinv) % MOD;\n }\n }\n\n let mut dp = vec![vec![0; x + 1]; n + 1];\n dp[0].fill(1);\n\n for k in 2..=n {\n let mut sum = 0u64;\n for y in 1..=min(k - 1, x) {\n dp[k][y] = (fastpow(y as u64, k as u64) + MOD - sum) % MOD;\n sum = (sum + dp[k][y]) % MOD\n }\n\n for y in k..=x {\n for i in 0..k {\n let mut a = dp[k - i][y - (k - 1)] * fastpow((k - 1) as u64, i as u64) % MOD;\n a = (a * comb[k][i]) % MOD;\n\n dp[k][y] = (dp[k][y] + a) % MOD;\n }\n }\n }\n\n let mut cnt = 0;\n for y in 1..=x {\n cnt = (cnt + dp[n][y]) % MOD;\n }\n\n writeln!(io.out, \"{}\", cnt % MOD)\n //Ok(())\n}\n\nfn main() -> io::Result<()> {\n let mut io = IO::new();\n\n //for _ in 0..tc {\n solve(&mut io)\n //}\n //Ok(())\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2050d33113544bd71d6a78e9a96ddfc5", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn read_line() -> String {\n let mut line = String::new();\n io::stdin().read_line(&mut line).unwrap();\n line\n}\n\nfn main() {\n\n let line = read_line();\n let is_cap = line.trim().chars().skip(1).all(|ch| ch.is_uppercase());\n\n if !is_cap {\n print!(\"{}\", line);\n } else {\n print!(\"{}\", line.trim().chars().map(|ch| if ch.is_uppercase() { ch.to_ascii_lowercase() } else { ch.to_ascii_uppercase() }).collect::());\n }\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "94429ab8620bcaf6037a4a93f9ce3bae", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.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 = s.split_whitespace().map(|x| x.parse().unwrap()).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": "496b3600b3ef0835d2d9b7587e49bd32", "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 let mut arr : Vec = s.split_whitespace().map(|s| s.parse().unwrap()).collect();\n let n = arr[0];\n let k = arr[1];\n arr = s.split_whitespace().map(|s| s.parse().unwrap());\n let mut ans = 0;\n let mut reff : i32 = 0;\n for (i, x) in arr.enumerate() {\n if i == k-1 {\n reff = x;\n }\n if i < k || x == reff {\n ans ++;\n }\n }\n println!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "7d8aceb35ac97d2d10d017c6b1da3cf9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::{stdout, BufWriter, Write};\n\ntype Mint = ModInt1000000007;\n\nfn main() {\n inputv! {\n n:usize,x:usize,pos:usize\n }\n let mut f = vec![Mint::new(1)];\n for i in 1..1000 {\n let l = *f.last().unwrap();\n f.push(l * Mint::new(i));\n }\n let mut r_count = 0;\n let mut l_count = 0;\n let mut left = 0;\n let mut right = n;\n loop {\n let mid = (left + right) / 2;\n if mid == pos {\n break;\n } else if mid > pos {\n r_count += 1;\n right = mid;\n } else {\n l_count += 1;\n left = mid + 1;\n }\n }\n //dbg!(l_count, r_count);\n if n - x < r_count || x - 1 < l_count {\n println!(\"0\");\n return;\n }\n let mut ans = f[n - x] / f[n - x - r_count] * f[x - 1] / f[x - 1 - l_count]\n * f[n - l_count - r_count - 1];\n println!(\"{}\", ans);\n}\n\n\n//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", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "d72210131bb3315899ead91668f07056", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(dead_code)]\n#![allow(unused_labels)]\n\nuse std::cmp::*;\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\nuse std::io::*;\nuse std::str::FromStr;\nuse std::char::*;\nmacro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);}}\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\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\nconst MAX:i64 = 1000000009;\nconst INF:i64 = std::i64::MAX;\nconst MOD:i64 = 1e9 as i64 + 7;\n\nstruct Graph {\n e: Vec>,\n v: Vec,\n u: Vec,\n f: Vec,\n c: i64,\n flag: bool,\n vc: Vec,\n}\n\nimpl Graph {\n fn new(n:usize) -> Self {\n Graph {\n e: vec![vec![];n],\n v: vec![],\n u: vec![n;n],\n f: vec![false;n],\n c: 0,\n flag: true,\n vc: vec![0;n],\n }\n }\n\n fn dfs(&mut self, crt: usize) {\n self.f[crt] = true;\n self.c = self.e[crt].len() as i64;\n if self.c != 2 {\n self.flag = false;\n }\n\n for i in 0..self.e[crt].len() {\n let v = self.e[crt][i];\n if self.f[v] { continue; }\n self.dfs(v);\n }\n }\n}\n\nfn binary_search(s: &Vec, v:i64) -> usize {\n let mut left = 0;\n let mut right = s.len();\n\n while right-left > 1 {\n let mid = (right+left)/2;\n //debug!(left,mid,right,s[mid]);\n if s[mid] < v { left = mid; }\n else { right = mid; }\n }\n left\n}\n\nfn neighbors(tree: &BTreeSet, val: usize) -> (Option<&usize>, Option<&usize>) {\n use std::ops::Bound::*;\n\n let mut before = tree.range((Unbounded, Excluded(val)));\n let mut after = tree.range((Excluded(val), Unbounded));\n\n (before.next_back(), after.next())\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\nconst MAX_A:i64 = 1e16 as i64;\n\nfn gcd(a:i64, b:i64) -> i64 {\n if b==0 {return a;}\n gcd(b, a%b)\n}\n\nstruct BIT {\n n: usize,\n bit: Vec,\n}\n\nimpl BIT {\n fn new(n:usize) -> BIT {\n BIT {\n n,\n bit: vec![0;n+1],\n }\n }\n\n fn add(&mut self, a:usize, w:i64) {\n let mut x = a;\n while x <= self.n {\n self.bit[x] += w;\n x += (x as i64 & -(x as i64)) as usize;\n }\n }\n\n fn sum(&self, a:usize) -> i64 {\n let mut ret = 0;\n let mut x = a as i64;\n while x > 0 {\n ret += self.bit[x as usize];\n x -= x & -x;\n }\n ret\n }\n}\n\nfn prime_factor(n: i64) -> BTreeMap {\n let mut n = n;\n let mut map = BTreeMap::new();\n let mut i = 2;\n while i*i <= n {\n while n%i == 0 {\n let count = map.entry(i).or_insert(0);\n *count += 1;\n n /= i;\n }\n i += 1;\n }\n if n!=1 { map.insert(n,1); }\n map\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)*) => (let _ = write!(out,$($format)*););\n }\n\n input! {\n n: i64,\n }\n\n let fac = prime_factor(n);\n let d = *fac.iter().next().unwrap().0;\n //debug!(d);\n puts!(\"{}\\n\", n/d);\n}\n\n/*\n\nn \u304b\u3089\u6700\u5c0f\u306e\u7d20\u6570\u306e\u7d04\u6570\u3092\u5f15\u3044\u3066\u3044\u304f\u3001\u4f55\u56de\u64cd\u4f5c\u304c\u3067\u304d\u308b\u304b\u3002\n\n34, 32, 30, 28, .., 2, 0\n31, 0\n6, 4, 2, 0\n10, 8, 6, 4,\n\n\u7d04\u6570\u5217\u6319\u3001\u6700\u5c0f\u306e\u7d20\u6570\u898b\u3064\u3051\u308b\u3001\u305d\u308c\u3067\u5272\u308b\uff1f\n\n*", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2b93ab3a278cdcb0dab5f2dec9749b94", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0} {"lang": "Rust", "source_code": "use std::cmp;\nuse std::io;\nuse std::str::SplitWhitespace;\n\nfn main() {\n let size = read_size();\n\n let mut v: Vec = vec![0; size as usize];\n\n let array_str = read_line();\n let mut iter = array_str.split_whitespace();\n\n for i in 0..size {\n v[i as usize] = read_split(&mut iter);\n }\n\n v.sort();\n\n let mut total = 0;\n for el in v.iter() {\n total += el;\n }\n\n let mut answer = total;\n\n for el in v.iter() {\n total -= el;\n answer = cmp::max(answer, total - el);\n }\n\n println!(\"{}\", answer);\n}\n\nfn read_size() -> i32 {\n let size_str = read_line();\n let mut iter = size_str.split_whitespace();\n read_split(&mut iter)\n}\n\nfn read_split(iter: &mut SplitWhitespace) -> i32 {\n iter.next().unwrap_or(\"-1\").parse::().unwrap_or(-1)\n}\n\nfn read_line() -> String {\n let mut first_line = String::new();\n io::stdin()\n .read_line(&mut first_line)\n .expect(\"stdin read error\");\n first_line\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "453c8bb0596fe5cc3c5ecbed7b3b2154", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "Rust", "source_code": "def main():\n n = int(input())\n a = list(map(int, input().split(' ')))\n sum = 0\n for x in a:\n sum += x\n one = (2 * sum) // n\n used = [False] * n\n for i, x in enumerate(a):\n if not used[i]:\n used[i] = True\n for j, y in enumerate(a):\n if not used[j] and y == one - x:\n used[j] = True\n print(i + 1, j + 1, end = '\\n')\n break\n\nif __name__ == \"__main__\":\n main()\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "3a4eade08de652af29af7893f0c2ebb5", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::{cell::Cell, cmp::{Reverse, max, min}, collections::{BTreeMap, HashMap, HashSet}, error::Error, fmt::Display, io::{BufWriter, Read, Write}, iter::Peekable, mem::swap, ops::{Not, Range, RangeInclusive, Sub}, process::exit, rc::Rc, str::{FromStr, from_utf8, from_utf8_unchecked}};\n\nconst IO_BUF_SIZE: usize = 1 << 16;\nstruct Scanner<'a, R: Read> {\n src: &'a mut R,\n _buf: Vec,\n _pt: usize, // pointer\n _rd: usize, // bytes read\n}\n\n#[allow(dead_code)]\nimpl<'a, R: Read> Scanner<'a, R> {\n fn new(src: &'a mut R) -> Scanner<'a, R> {\n Scanner { src, _buf: vec![0; IO_BUF_SIZE], _pt: 1, _rd: 1 }\n }\n \n fn _check_buf(&mut self) {\n if self._pt == self._rd {\n self._rd = self.src.read(&mut self._buf).unwrap_or(0);\n self._pt = (self._rd == 0) as usize;\n }\n }\n \n // returns true if end of file\n fn eof(&mut self) -> bool {\n self._check_buf();\n self._rd == 0\n }\n \n // filters \\r, returns \\0 if eof\n fn byte(&mut self) -> u8 {\n loop {\n self._check_buf();\n if self._rd == 0 { return 0; }\n let res = self._buf[self._pt];\n self._pt += 1;\n if res != b'\\r' { return res; }\n }\n }\n \n fn char(&mut self) -> char { self.byte() as char }\n fn bytes_no_skip(&mut self, n: usize) -> Vec { (0..n).map(|_| self.byte()).collect() }\n fn bytes(&mut self, n: usize) -> Vec {\n let res = self.bytes_no_skip(n);\n self.byte();\n res\n }\n fn bytes2(&mut self, n: usize, m: usize) -> Vec> { (0..n).map(|_| self.bytes(m)).collect() }\n \n fn token_bytes(&mut self) -> Vec {\n let mut res = Vec::new();\n let mut c = self.byte();\n while c <= b' ' {\n if c == b'\\0' { return res; }\n c = self.byte();\n }\n loop {\n res.push(c);\n c = self.byte();\n if c <= b' ' { return res; }\n }\n }\n fn token(&mut self) -> String { unsafe { String::from_utf8_unchecked(self.token_bytes()) } }\n \n fn line_bytes(&mut self) -> Vec {\n let mut res = Vec::new();\n let mut c = self.byte();\n while c != b'\\n' && c != b'\\0' {\n res.push(c);\n c = self.byte();\n }\n res\n }\n fn line(&mut self) -> String { unsafe { String::from_utf8_unchecked(self.line_bytes()) } }\n \n fn read(&mut self) -> T { \n let token = self.token_bytes();\n unsafe { from_utf8_unchecked(&token).parse::().ok().unwrap() }\n }\n fn vec(&mut self, n: usize) -> Vec { (0..n).map(|_| self.read()).collect() }\n fn vec2(&mut self, n: usize, m: usize) -> Vec> { (0..n).map(|_| self.vec(m)).collect() }\n}\n\ntrait ToCharVec { fn to_char_vec(&self) -> Vec; }\nimpl ToCharVec for &str { fn to_char_vec(&self) -> Vec { self.chars().collect() } }\nimpl ToCharVec for String { fn to_char_vec(&self) -> Vec { self.chars().collect() } }\ntrait JoinToStr { \n fn join_to_str(&mut self, sep: &str) -> String;\n fn concat_to_str(&mut self) -> String;\n}\nimpl> JoinToStr for I { \n fn join_to_str(&mut self, sep: &str) -> String {\n let mut res = String::new();\n match self.next() {\n None => res,\n Some(first) => {\n res.push_str(&first.to_string());\n loop {\n match self.next() {\n None => break,\n Some(item) => {\n res.push_str(sep);\n res.push_str(&item.to_string())\n }\n }\n }\n res\n }\n }\n }\n \n fn concat_to_str(&mut self) -> String {\n let mut res = String::new();\n for item in self { res.push_str(&item.to_string()); }\n res\n }\n}\n\nmacro_rules! veci {\n ($n:expr , $i:ident : $gen:expr) => {{\n let n = $n;\n let mut list = Vec::with_capacity(n);\n for $i in 0..n {\n list.push($gen);\n }\n list\n }};\n ($n:expr , $gen:expr) => { veci!($n, __: $gen); }\n}\n\nfn abs_diff + PartialOrd>(x: T, y: T) -> T {\n if x < y { y - x } else { x - y }\n}\n\n// * end commons * //\n\nmod modint {\n\n use std::{convert::Infallible, iter::Sum, mem::swap, ops::AddAssign};\n\n pub trait RemEuclidU32: Copy {\n /// Calculates `self` _mod_ `modulus` losslessly.\n fn rem_euclid_u32(self, modulus: u32) -> u32;\n\n fn pow_mod(self, exponent: u64, modulus: u32) -> u32 {\n pow_mod_raw(self.rem_euclid_u32(modulus), exponent, modulus)\n }\n fn mul_mod(self, rhs: Rhs, modulus: u32) -> u32 {\n mul_mod_u32(self.rem_euclid_u32(modulus), rhs.rem_euclid_u32(modulus), modulus)\n }\n\n fn mod_pow_vec(self, n: usize, modulus: u32) -> Vec {\n let a = self.rem_euclid_u32(modulus);\n let mut res = vec![0u32; n+1];\n if modulus == 1 { return res; }\n res[0] = 1;\n for i in 1..=n {\n res[i] = mul_mod_u32(a, res[i-1], modulus);\n }\n res\n }\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 #[inline]\n pub fn mul_mod_u32(a: u32, b: u32, m: u32) -> u32 {\n ((a as u64) * (b as u64) % (m as u64)) as u32\n }\n\n #[inline]\n fn norm(a: u32, m: u32) -> u32 {\n (((a as i32) >> 31) as u32 & m) + a\n }\n // for a, b < m < 2^31, undefined otherwise\n #[inline]\n pub fn add_mod_raw(a: u32, b: u32, m: u32) -> u32 {\n sub_mod_raw(a, m-b, m)\n //norm(a.wrapping_add(b).wrapping_sub(m), m)\n }\n #[inline]\n pub fn sub_mod_raw(a: u32, b: u32, m: u32) -> u32 {\n let (r, c) = a.overflowing_sub(b);\n if c { r + m } else { r }\n //norm(a.wrapping_sub(b), m)\n }\n pub fn pow_mod_raw(a: u32, mut k: u64, m: u32) -> u32 {\n if m == 1 { return 0; }\n let mut a= a as u64;\n let m = m as u64;\n let mut r: u64 = 1;\n while k > 0 {\n if k & 1 == 1 {\n r = r * a % m;\n }\n k >>= 1;\n a = a * a % m;\n }\n return r as u32;\n }\n\n /// # Parameters\n /// * `b` `1 <= b`\n /// # Returns\n /// (x, g) s.t. g = gcd(a, b), xa = g (mod b), 0 <= x < b/g\n pub fn inv_gcd(a: i64, b: i64) -> (i64, i64) {\n let a = a.rem_euclid(b);\n if a == 0 { return (0, b); }\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;\n std::mem::swap(&mut s, &mut t);\n std::mem::swap(&mut m0, &mut m1);\n }\n\n if m0 < 0 { m0 += b / s; }\n (m0, s)\n }\n\n #[derive(Clone, Copy, PartialEq, Eq, Hash, Default)]\n #[repr(transparent)]\n pub struct ModInt { pub val: u32 }\n\n impl ModInt {\n #[inline(always)]\n pub fn modulus() -> u32 { crate::get_modulus() }\n pub fn new(val: I) -> Self { Self::raw(val.rem_euclid_u32(Self::modulus())) }\n #[inline]\n pub fn raw(val: u32) -> Self { Self { val } }\n pub fn inv(self) -> Self { \n let (x, gcd) = inv_gcd(self.val.into(), Self::modulus().into());\n if gcd != 1 { panic!(\"the multiplicative inverse {}^-1 mod {} does not exist\", self.val, Self::modulus()) }\n Self::raw(x as u32)\n }\n pub fn pow(self, k: u64) -> Self {\n Self::raw(pow_mod_raw(self.val, k, Self::modulus()))\n }\n pub fn pow_vec(self, n: usize) -> Vec {\n let mut res = vec![Self::raw(0); n+1];\n res[0] += 1;\n for i in 1..=n {\n res[i] = res[i-1] * self;\n }\n res\n }\n }\n\n #[inline]\n pub fn mi(val: I) -> ModInt { ModInt::new(val) }\n\n impl From for ModInt {\n #[inline]\n fn from(from: V) -> Self { Self::new(from) }\n }\n impl std::str::FromStr for ModInt {\n type Err = std::convert::Infallible;\n #[inline]\n fn from_str(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 impl std::fmt::Display for ModInt {\n #[inline]\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n std::fmt::Display::fmt(&self.val, f)\n }\n }\n impl std::fmt::Debug for ModInt {\n #[inline]\n fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n std::fmt::Debug::fmt(&self.val, f)\n }\n }\n impl std::ops::Neg for ModInt {\n type Output = ModInt;\n\n #[inline]\n fn neg(self) -> Self::Output {\n Self::raw(0) - self\n //Self::raw(norm(self.val.wrapping_neg(), Self::modulus()))\n }\n }\n\n impl std::ops::Add for ModInt {\n type Output = ModInt;\n #[inline]\n fn add(self, rhs: Self) -> Self::Output {\n Self::raw(add_mod_raw(self.val, rhs.val, Self::modulus()))\n }\n }\n impl std::ops::Sub for ModInt {\n type Output = ModInt;\n #[inline]\n fn sub(self, rhs: Self) -> Self::Output {\n Self::raw(sub_mod_raw(self.val, rhs.val, Self::modulus()))\n }\n }\n impl std::ops::Mul for ModInt {\n type Output = ModInt;\n #[inline]\n fn mul(self, rhs: Self) -> Self::Output {\n Self::raw(mul_mod_u32(self.val, rhs.val, Self::modulus()))\n }\n }\n impl std::ops::Div for ModInt {\n type Output = ModInt;\n #[inline]\n fn div(self, rhs: Self) -> Self::Output { self * rhs.inv() }\n }\n\n impl std::ops::Add for ModInt {\n type Output = ModInt;\n #[inline]\n fn add(self, rhs: I) -> Self::Output { self + Self::new(rhs) }\n }\n impl std::ops::Sub for ModInt {\n type Output = ModInt;\n #[inline]\n fn sub(self, rhs: I) -> Self::Output { self - Self::new(rhs) }\n }\n impl std::ops::Mul for ModInt {\n type Output = ModInt;\n #[inline]\n fn mul(self, rhs: I) -> Self::Output { self * Self::new(rhs) }\n }\n impl std::ops::Div for ModInt {\n type Output = ModInt;\n #[inline]\n fn div(self, rhs: I) -> Self::Output { self / Self::new(rhs) }\n }\n\n impl std::ops::AddAssign for ModInt {\n #[inline]\n fn add_assign(&mut self, rhs: Self) { *self = *self + rhs; }\n }\n impl std::ops::SubAssign for ModInt {\n #[inline]\n fn sub_assign(&mut self, rhs: Self) { *self = *self - rhs; }\n }\n impl std::ops::MulAssign for ModInt {\n #[inline]\n fn mul_assign(&mut self, rhs: Self) { *self = *self * rhs; }\n }\n impl std::ops::DivAssign for ModInt {\n #[inline]\n fn div_assign(&mut self, rhs: Self) { *self = *self / rhs; }\n }\n impl std::ops::AddAssign for ModInt {\n #[inline]\n fn add_assign(&mut self, rhs: I) { *self = *self + rhs; }\n }\n impl std::ops::SubAssign for ModInt {\n #[inline]\n fn sub_assign(&mut self, rhs: I) { *self = *self - rhs; }\n }\n impl std::ops::MulAssign for ModInt {\n #[inline]\n fn mul_assign(&mut self, rhs: I) { *self = *self * rhs; }\n }\n impl std::ops::DivAssign for ModInt {\n #[inline]\n fn div_assign(&mut self, rhs: I) { *self = *self / rhs; }\n }\n\n impl std::iter::Sum for ModInt {\n #[inline]\n fn sum>(iter: I) -> Self {\n iter.fold(Self::raw(0), std::ops::Add::add)\n }\n }\n impl std::iter::Product for ModInt {\n #[inline]\n fn product>(iter: I) -> Self {\n iter.fold(1.into(), std::ops::Mul::mul)\n }\n }\n}\n\nconst MODULUS: u32 = 998_244_353;\n//const MODULUS: u32 = 1_000_000_007;\n#[inline(always)]\nfn get_modulus() -> u32 { MODULUS }\n\n// static mut MODULUS: u32 = 998244353;\n// #[inline] fn get_modulus() -> u32 { unsafe { MODULUS } }\n// #[inline] fn set_modulus(value: u32) { unsafe { MODULUS = value; } }\n\nuse crate::modint::*;\n\n#[allow(non_snake_case, unused_macros)]\nfn main() -> Result<(), Box> {\n let mut INPUT = std::io::stdin();\n let OUTPUT = std::io::stdout();\n\n let mut inp = Scanner::new(&mut INPUT);\n let mut out = BufWriter::with_capacity(IO_BUF_SIZE, OUTPUT);\n\n macro_rules! inp {\n () => { inp.read(); };\n ($t: ty) => { inp.read::<$t>(); };\n ($t: ty, $($tt: ty),*) => { (inp.read::<$t>(), $(inp.read::<$tt>(),)*); };\n [$t: ty; $n: expr] => { inp.vec::<$t>($n); };\n }\n macro_rules! println { \n () => { writeln!(out).unwrap(); };\n ($exp: expr) => { writeln!(out, \"{}\", $exp).unwrap(); }; \n ($fmt: expr, $($arg : tt )*) => { writeln!(out, $fmt, $($arg)*).unwrap(); }\n }\n macro_rules! print { \n ($exp: expr) => { write!(out, \"{}\", $exp).unwrap(); }; \n ($fmt: expr, $($arg : tt )*) => { write!(out, $fmt, $($arg)*).unwrap(); }\n }\n\n { // solution start\n let num_cases = 1;//inp!(usize);\n\n for _case_num in 1..=num_cases {\n let n = inp!(usize);\n set_modulus(inp!());\n\n let mut dp = vec![mi(0); n+1];\n dp[1] = mi(1);\n dp[2] = mi(2);\n for i in 2..n {\n let d = dp[i];\n dp[i+1] += d + d + 1;\n let d = d - dp[i-1];\n for j in (i*2..=n).step_by(i) {\n dp[j] += d;\n }\n }\n\n let ans = dp[n];\n println!(ans);\n }\n } // solution end\n\n out.flush()?;\n Ok(())\n}\n\n\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "2a0b16ab41d384d7fdc54c1fb3cd0287", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0} {"lang": "Rust", "source_code": "\nfn run() {\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n let mut it = s.trim().split_whitespace();\n let n: usize = it.next().unwrap().parse().unwrap();\n let s: Vec = it.next().unwrap().chars().collect();\n let mut dp = vec![vec![0; n]; n];\n for len in 1..=n {\n for l in 0..=(n - len) {\n let r = l + len - 1;\n dp[l][r] = len;\n if l + 1 < n {\n dp[l][r] = dp[l + 1][r] + 1;\n }\n for k in (l + 1)..=r {\n if s[l] == s[k] {\n dp[l][r] = std::cmp::min(dp[l][r], dp[l + 1][k - 1] + dp[k][r]);\n }\n }\n }\n }\n println!(\"{}\", dp[0][n - 1]);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "69bb1eeb9fe3c90b54a0af47eca8a5eb", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.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\t{\n\t\t\t\tlet count = cnt.entry(mx/t).or_insert(0);\n\t\t\t\t*count -= 1;\n\t\t\t}\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": "94edcbeafd59dcc8a4c1b10879d041bb", "src_uid": "868407df0a93085057d06367aecaf9be", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::io::BufRead;\nuse std::f64::consts::PI;\n\n#[derive(Debug, Copy, Clone)]\nstruct Point {\n x: f64,\n y: f64,\n}\n\n#[derive(Debug, Copy, Clone)]\nstruct LinearEquation {\n a: f64,\n b: f64,\n c: f64\n}\n\nfn parse_point(s: String) -> Point {\n let split = s.split(' ').collect::>();\n assert!(split.len() == 2);\n let x: f64 = split[0].parse().unwrap();\n let y: f64 = split[1].parse().unwrap();\n Point { x, y }\n}\n\nfn sqr(x: f64) -> f64 {\n x * x\n}\n\nfn find_line_equation(a: Point, b: Point) -> LinearEquation {\n LinearEquation {\n a: 2. * (b.x - a.x),\n b: 2. * (b.y - a.y),\n c: sqr(a.x) + sqr(a.y) - sqr(b.x) - sqr(b.y)\n }\n}\n\nfn find_center(a: Point, b: Point, c: Point) -> Point {\n let eq1 = find_line_equation(a, b);\n let eq2 = find_line_equation(a, c);\n let da = eq1.c * eq2.b - eq1.b * eq2.c;\n let db = eq1.a * eq2.c - eq1.c * eq2.a;\n let dc = eq1.a * eq2.b - eq1.b * eq2.a;\n Point { x: -da / dc, y: -db / dc }\n}\n\nfn find_angle(p: Point, o: Point) -> f64 {\n let x = p.x - o.x;\n let y = p.y - o.y;\n (y.atan2(x) / (2. * PI) + 1.) % 1.\n}\n\nfn is_n_poly(a: f64, n: i32) -> bool {\n let d = 1. / (n as f64);\n let r = ((a / d).round() - a / d).abs();\n r < 0.0001\n}\n\nfn find_first_n(a1: f64, a2: f64) -> i32 {\n (1..101).find(|&n| is_n_poly(a1, n) && is_n_poly(a2, n)).unwrap()\n}\n\nfn find_area(a: Point, b: Point, c: Point) -> f64 {\n let o = find_center(a, b, c);\n let mut angles = [find_angle(a, o), find_angle(b, o), find_angle(c, o)];\n angles.sort_by(|a, b| a.partial_cmp(b).unwrap());\n let n = find_first_n(angles[1] - angles[0], angles[2] - angles[0]);\n let r_sqr = sqr(a.x - o.x) + sqr(a.y - o.y);\n let half_angle = PI / (n as f64);\n let triangle_size = r_sqr * f64::sin(half_angle) * f64::cos(half_angle);\n triangle_size * (n as f64)\n}\n\nfn main() {\n let stdin = io::stdin();\n let points = stdin.lock().lines().take(3).map(|s| parse_point(s.unwrap())).collect::>();\n assert!(points.len() == 3);\n print!(\"{}\", find_area(points[0], points[1], points[2]));\n}", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "e89786f1113ccbff2890568f0299e668", "src_uid": "980f4094b3cfc647d6f74e840b1bfb62", "difficulty": 2100.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#define xxxx x\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", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "7d06101f75484d7ed7fabe1c185ca25c", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.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 v_a = a_str.trim().chars()\n .map(|x| x.to_digit(10).unwrap() as i32)\n .collect::>();\n\n let mut b_str = String::new();\n io::stdin().read_line(&mut b_str).expect(\"\");\n let mut v_b = b_str.trim().chars()\n .map(|x| x.to_digit(10).unwrap() as i32)\n .collect::>();\n\n\n let n_b = 1;\n\n let mut res = String::new();\n v_a.sort();\n for i in 0..v_a.len() {\n for j in ((i + 1)..v_a.len()) {\n let mut t = v_a;\n t.swap(i, j);\n let n_t: i64 = t.iter().map(|x| x.to_string()).collect().parse().unwrap();\n let n_a: i64 = v_a.iter().map(|x| x.to_string()).collect().parse().unwrap();\n if (n_a < n_t && n_t < n_b) {\n v_a.swap(i, j);\n }\n }\n }\n res = v_a.iter().map(|x| x.to_string()).collect();\n println!(\"{}\", res);\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "5e73981a72290229b69f9a9048330554", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "Rust", "source_code": "// Basics\n\n#![allow(unused_imports)]\n#![allow(dead_code)]\n\nextern crate rand;\n\nuse std::io::prelude::*;\nuse std::mem;\nuse std::io;\nuse std::io::BufRead;\nuse std::io::BufReader;\nuse std::string;\nuse std::cmp::*;\nuse std::collections::*;\nuse std::vec::Vec;\nuse std::collections::LinkedList;\nuse std::num;\nuse std::ops;\nuse std::fmt::Debug;\nuse std::str::FromStr;\nuse rand::Rng;\nuse std::ops::Shr;\n\nstruct Cin {\n data: LinkedList,\n}\n\nimpl Cin {\n fn new() -> Self {\n Cin { data: LinkedList::new() }\n }\n fn read_line(&self) -> String {\n let mut s: String = String::new();\n io::stdin().read_line(&mut s).expect(\"err\");\n s\n }\n fn read_str(&mut self) -> String {\n if self.data.len() == 0 {\n let s = self.read_line();\n// let split = s.split(\"\\\\s+\");\n let split = s.split_whitespace();\n for el in split {\n self.data.push_back(String::from(el));\n }\n }\n self.data.pop_front().expect(\"empty\")\n }\n fn read_int(&mut self) -> i64 {\n self.read_str().parse().expect(\"err parse\")\n }\n fn read_vec(&mut self, size: &i64) -> Vec {\n let mut v: Vec = Vec::new();\n for _i in 0..*size {\n v.push(self.read_int());\n }\n v\n }\n}\n\nfn main() {\n let mut cin = Cin::new();\n let n: i64 = cin.read_int();\n let vec = cin.read_vec(&n);\n let mut s: HashSet = HashSet::new();\n let mut res: LinkedList = LinkedList::new();\n for i in 0..vec.len() {\n let ref value = vec[vec.len() - 1 - i];\n let option = s.get(value).is_some();\n if !option {\n s.insert(value.clone());\n res.push_front(*value);\n }\n }\n println!(\"{}\", res.len());\n for r in res { print!(\"{} \", r); }\n println!();\n}\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "301dbd08ff7fbfcef5611a7e53cf7136", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "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)] macro_rules! m {\n\t($c:tt, $x:expr, $y:expr) => {{\n\t\tlet b = $y; let a = &mut $x;\n\t\tif b $c *a { *a = b; true } else { false }\n\t}};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),* =$i:ident.$f:ident $a:tt) => {$(let$v=$i.$f$a;)*};\n\t($($v:ident),*:$t:ty=$i:ident.$f:ident $a:tt) => {$(let$v:$t=$i.$f$a;)*};\n\t(mut $($v:ident),+ =$i:ident.$f:ident $a:tt) => {$(let mut$v=$i.$f$a;)*};\n\t(mut $($v:ident),*:$t:ty=$i:ident.$f:ident $a:tt) => {$(let mut$v:$t=$i.$f$a;)*};\n}\nstruct WordReaderC {\n\tq: std::io::StdinLock<'static>, buf: Vec, pos: usize//'\n}\n#[allow(dead_code)]\nimpl 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 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}\nfn reader() -> WordReaderC { WordReaderC::new() }\nfn writer() -> BufWriter { BufWriter::new(stdout()) }\n//------------------- End rusT }}}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tl!(xor,sum = rin.l());\n\tlet check = |a: &Vec<_>| -> bool {\n\t\tlet mut x = 0;\n\t\tlet mut s = 0;\n\t\tfor &y in a {\n\t\t\tx ^= y;\n\t\t\ts += y;\n\t\t}\n\t\tx == xor && s == sum\n\t};\n\tlet mut sol = None;\n\tif xor == sum {\n\t\tif xor == 0 {\n\t\t\tsol = Some(Vec::new());\n\t\t} else {\n\t\t\tsol = Some(vec![xor]);\n\t\t}\n\t} else if xor < sum && (xor ^ sum) % 2 == 0 {\n\t\tlet d = sum - xor;\n\t\tlet h = d / 2;\n\t\tif check(&vec![xor^h,h]) {\n\t\t\tsol = Some(vec![xor^h,h]);\n\t\t} else\n\t\t\tsol = Some(vec![xor,h,h]);\n\t\t}\n\t}\n\tif let Some(res) = sol {\n\t\twriteln!(rout, \"{}\", res.len()).ok();\n\t\tfor x in res {\n\t\t\twrite!(rout, \"{} \", x).ok();\n\t\t}\n\t\twriteln!(rout, \"\").ok();\n\t} else {\n\t\twriteln!(rout, \"-1\").ok();\n\t}\n}\n\n", "lang_cluster": "Rust", "compilation_error": true, "code_uid": "8c307589e09bb5af93ae31130e1169d5", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "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, 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::*;\nuse std::collections::BTreeMap;\n\nfn run() {\n input! {\n n: usize,\n p: [usize; n],\n }\n let mut cnt = [0; 2];\n for p in p.iter() {\n if *p == 0 {\n continue;\n }\n cnt[*p % 2] += 1;\n }\n let even = n / 2 - cnt[0];\n let odd = (n + 1) / 2 - cnt[1];\n let inf = n;\n let mut dp = BTreeMap::<(usize, usize, usize), usize>::new();\n dp.insert((0, even, odd), 0);\n dp.insert((1, even, odd), 0);\n for p in p.iter().rev() {\n let mut next = BTreeMap::<(usize, usize, usize), usize>::new();\n for ((b, x, y), v) in dp {\n if *p == 0 {\n if x > 0 {\n let po = next.entry((0, x - 1, y)).or_insert(inf);\n *po = min(*po, v + (b ^ 0));\n }\n if y > 0 {\n let po = next.entry((1, x, y - 1)).or_insert(inf);\n *po = min(*po, v + (b ^ 1));\n }\n } else {\n let po = next.entry((*p % 2, x, y)).or_insert(inf);\n *po = min(*po, v + (b ^ (*p & 1)));\n }\n }\n dp = next;\n }\n let mut ans = inf;\n for (_, v) in dp {\n ans = min(ans, v);\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7a0df4cb381f0f828203c9e0b9211437", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0} {"lang": "Rust", "source_code": "use std::io;\n\nfn read_line() -> (f64) {\n let mut input = String::new();\n \n io::stdin().read_line(&mut input).unwrap();\n \n let n: f64 = input.trim().parse().unwrap();\n\n n\n}\n\nfn main(){\n \n let n = read_line();\n\n let log = n.log2().floor();\n let bacterias = 1.0 + (n - (2.0 as f64).powf(log));\n\n println!(\"{}\", bacterias as i64);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "fd6d1827ff8fc68859351ae03cf760fa", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "Rust", "source_code": "#![allow(dead_code, unused_imports)]\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.trim().to_string()\n}\n\nfn read() -> T\nwhere\n T: FromStr,\n ::Err: Debug,\n{\n read_stdin().parse::().unwrap()\n}\n\nfn read_usize() -> usize {\n read::()\n}\n\nfn read_2() -> (A, B)\nwhere\n A: FromStr,\n ::Err: Debug,\n B: FromStr,\n ::Err: Debug,\n{\n let s = read_stdin();\n let mut s = s.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_3() -> (A, B, C)\nwhere\n A: FromStr,\n ::Err: Debug,\n B: FromStr,\n ::Err: Debug,\n C: FromStr,\n ::Err: Debug,\n{\n let s = read_stdin();\n let mut s = s.split_whitespace();\n let a = s.next().unwrap().parse::().unwrap();\n let b = s.next().unwrap().parse::().unwrap();\n let c = s.next().unwrap().parse::().unwrap();\n (a, b, c)\n}\n\nfn read_4() -> (A, B, C, D)\nwhere\n A: FromStr,\n ::Err: Debug,\n B: FromStr,\n ::Err: Debug,\n C: FromStr,\n ::Err: Debug,\n D: FromStr,\n ::Err: Debug,\n{\n let s = read_stdin();\n let mut s = s.split_whitespace();\n let a = s.next().unwrap().parse::().unwrap();\n let b = s.next().unwrap().parse::().unwrap();\n let c = s.next().unwrap().parse::().unwrap();\n let d = s.next().unwrap().parse::().unwrap();\n (a, b, c, d)\n}\n\nfn read_multiple() -> Vec\nwhere\n ::Err: Debug,\n{\n read_stdin()\n .split_whitespace()\n .map(|x| x.parse::().expect(\"cannot parse stdin\"))\n .collect()\n}\n\n/// NOTE: sort iter beforehand if required\nfn count(iter: &mut impl Iterator) -> Vec<(T, usize)>\nwhere\n T: std::cmp::Ord,\n{\n let 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}\n\nfn partial_sum(v: impl Iterator) -> impl Iterator\nwhere\n T: Default + std::ops::Add + Copy,\n{\n v.scan(T::default(), |state, x| {\n *state = *state + x;\n Some(*state)\n })\n}\n\nfn max_subarray(v: impl Iterator) -> (i64, (usize, usize)) {\n //assert!(v.len() > 0);\n let mut best_sum = 0;\n let (mut best_start, mut best_end) = (0, 0);\n let mut current_sum = 0;\n let mut current_start = 0;\n for (end, val) in v.enumerate() {\n if current_sum <= 0 {\n current_start = end;\n current_sum = val;\n } else {\n current_sum += val;\n }\n if current_sum > best_sum {\n best_sum = current_sum;\n best_start = current_start;\n best_end = end + 1;\n }\n }\n (best_sum, (best_start, best_end))\n}\n\nfn gcd(mut a: u64, mut b: u64) -> u64 {\n while a != 0 {\n let old_m = a;\n a = b % a;\n b = old_m;\n }\n b\n}\n\n/// returns gcd, and pair (x, y), such that x * a + b * y == gcd\nfn egcd(a: i64, b: i64) -> (i64, i64, i64) {\n if a == 0 {\n (b, 0, 1)\n } else {\n let (g, x, y) = egcd(b % a, a);\n (g, y - (b / a) * x, x)\n }\n}\n\nfn factorize(mut n: u64) -> Vec {\n if n <= 3 {\n return vec![n];\n }\n let mut v = Vec::new();\n while n % 2 == 0 {\n n /= 2;\n v.push(2);\n }\n while n % 3 == 0 {\n n /= 3;\n v.push(3);\n }\n let mut f = 6;\n while (f - 1) * (f - 1) <= n {\n while n % (f - 1) == 0 {\n n /= f - 1;\n v.push(f - 1);\n }\n while n % (f + 1) == 0 {\n n /= f + 1;\n v.push(f + 1);\n }\n f += 6;\n }\n if n > 1 {\n v.push(n);\n }\n v\n}\n\nfn compact_factors(n: u64) -> Vec<(u64, usize)> {\n count(&mut factorize(n).into_iter())\n}\n\nfn all_factors(n: u64) -> Vec {\n if n == 0 {\n return vec![0];\n } else if n == 1 {\n return vec![1];\n }\n let factors = compact_factors(n);\n let mut v = vec![1];\n for (fac, num) in factors {\n let ori = v.clone();\n for i in 1..num + 1 {\n v.append(\n &mut ori\n .clone()\n .into_iter()\n .map(|f| f * fac.pow(i as u32))\n .collect::>(),\n )\n }\n }\n v.sort();\n v\n}\n\nfn abs_diff(a: T, b: T) -> T\nwhere\n T: PartialOrd + std::ops::Sub,\n{\n if a > b {\n a - b\n } else {\n b - a\n }\n}\n\nstruct Permutations {\n inner: Vec,\n state: Vec,\n i: usize,\n start: bool,\n}\n\nimpl Permutations {\n fn new(inner: Vec) -> Self {\n Self {\n state: vec![0; inner.len()],\n i: 0,\n start: true,\n inner,\n }\n }\n}\n\n/*impl From for Permutations\nwhere\n X: IntoIterator,\n{\n fn from(f: X) -> Self {\n Self::new(f.into_iter().collect::>())\n }\n}*/\n\nimpl Iterator for Permutations\nwhere\n T: Clone,\n{\n type Item = Vec;\n fn next(&mut self) -> Option {\n if self.start {\n self.start = false;\n return Some(self.inner.clone());\n }\n while self.i < self.inner.len() {\n if self.state[self.i] < self.i {\n if self.i % 2 == 0 {\n self.inner.swap(0, self.i)\n } else {\n self.inner.swap(self.state[self.i], self.i)\n }\n self.state[self.i] += 1;\n self.i = 0;\n return Some(self.inner.clone());\n } else {\n self.state[self.i] = 0;\n self.i += 1;\n }\n }\n None\n }\n}\n\nuse std::cmp::{max, min, Ord, Ordering};\nuse std::collections::{BinaryHeap, VecDeque};\nuse std::mem::swap;\n\n#[derive(Clone)]\nstruct Graph {\n nodes: usize,\n edges: Vec>,\n}\n\nimpl Graph {\n fn new(n: usize) -> Self {\n Self {\n nodes: n,\n edges: vec![Vec::new(); n + 1],\n }\n }\n\n fn add_edge(&mut self, x: usize, y: usize, cost: u64) {\n self.edges[x].push((y, cost));\n self.edges[y].push((x, cost));\n }\n\n fn dijkstra(&mut self, start: usize, end: usize) -> u64 {\n let mut dist = vec![None; self.nodes + 1];\n let mut prev = vec![None; self.nodes + 1];\n dist[start] = Some(0);\n let mut queue = (1..=self.nodes).collect::>();\n queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));\n queue.reverse();\n while let Some(next_node) = queue.pop() {\n if next_node == end {\n return dist[next_node].unwrap();\n }\n for (neighbour, cost) in self.edges[next_node].iter() {\n let alt = dist[next_node].unwrap() + cost;\n if dist[*neighbour].is_none() {\n dist[*neighbour] = Some(alt);\n prev[*neighbour] = Some(next_node);\n } else {\n if alt < dist[*neighbour].unwrap() {\n dist[*neighbour] = Some(alt);\n prev[*neighbour] = Some(next_node);\n }\n }\n }\n //println!(\"{:?} {:?}\", dist, prev);\n queue.sort_unstable_by_key(|node| dist[*node].unwrap_or(std::u64::MAX));\n queue.reverse();\n }\n 0\n }\n\n fn set_cost(&mut self, x: usize, y: usize, cost: u64) {\n for i in 0..self.edges[x].len() {\n if self.edges[x][i].0 == y {\n self.edges[x][i].1 = cost\n }\n }\n for i in 0..self.edges[y].len() {\n if self.edges[y][i].0 == x {\n self.edges[y][i].1 = cost\n }\n }\n }\n}\n\nconst MODULO: u64 = 1_000_000_007;\n\n#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]\nstruct BigPrimeRing {\n inner: u64,\n}\n\nimpl From for BigPrimeRing\nwhere\n T: Into,\n{\n fn from(n: T) -> Self {\n Self {\n inner: n.into() % MODULO,\n }\n }\n}\n\nimpl std::ops::Add for BigPrimeRing\nwhere\n T: Into,\n{\n type Output = BigPrimeRing;\n fn add(self, rhs: T) -> Self::Output {\n Self {\n inner: (self.inner + rhs.into().inner) % MODULO,\n }\n }\n}\n\nimpl std::ops::AddAssign for BigPrimeRing\nwhere\n T: Into,\n{\n fn add_assign(&mut self, rhs: T) {\n self.inner += rhs.into().inner;\n self.inner %= MODULO;\n }\n}\n\nimpl std::ops::Sub for BigPrimeRing\nwhere\n T: Into,\n{\n type Output = BigPrimeRing;\n fn sub(self, rhs: T) -> Self::Output {\n Self {\n inner: (self.inner + MODULO - rhs.into().inner) % MODULO,\n }\n }\n}\n\nimpl std::ops::SubAssign for BigPrimeRing\nwhere\n T: Into,\n{\n fn sub_assign(&mut self, rhs: T) {\n self.inner += MODULO;\n self.inner -= rhs.into().inner;\n self.inner %= MODULO;\n }\n}\n\nimpl std::ops::Mul for BigPrimeRing\nwhere\n T: Into,\n{\n type Output = BigPrimeRing;\n fn mul(self, rhs: T) -> Self::Output {\n Self {\n inner: (self.inner * rhs.into().inner) % MODULO,\n }\n }\n}\n\nimpl std::ops::MulAssign for BigPrimeRing\nwhere\n T: Into,\n{\n fn mul_assign(&mut self, rhs: T) {\n self.inner *= rhs.into().inner;\n self.inner %= MODULO;\n }\n}\n\nimpl BigPrimeRing {\n fn inverse(self) -> Self {\n if self.inner == 0 {\n return self;\n }\n let (_g, mut x, _y) = egcd(self.inner as i64, MODULO as i64);\n if x < 0 {\n x += MODULO as i64;\n }\n Self { inner: x as u64 }\n }\n}\n\nfn main() -> Result<(), Box> {\n println!(\"Karen\");\n Ok(())\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "858f1aa9c09cc7ff5912ec297238d44c", "src_uid": "1649d2592eadaa8f8d076eae2866cffc", "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(&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\nfn _main() {\n let mut scan = Scan::new();\n let a: usize = scan.next();\n let b: usize = scan.next();\n if a == b {\n println!(\"0 6 0\");\n } else if a < b {\n let middle = a.max(b) - a.min(b) - 1;\n println!(\n \"{} {} {}\",\n a + middle / 2,\n middle % 2,\n 6 - b + 1 + middle / 2\n );\n } else {\n let middle = a.max(b) - a.min(b) - 1;\n println!(\n \"{} {} {}\",\n 6 - a + 1 + middle / 2,\n middle % 2,\n b + middle / 2\n );\n }\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": "72d40bc6afec4004077d1012c88b1e66", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead};\n// use std::collections::*; // HashSet, HashMap, BTreeSet, BTreeMap, ...\n\nfn main() {\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 flv: Vec<_> = next_line\n .trim()\n .split(' ')\n .map(|n| {\n n.parse::().unwrap()\n })\n .collect();\n\n let n = flv[0];\n\n let mut s: String = lines.next()\n .unwrap()\n .unwrap()\n .trim()\n .to_string();\n\n for i in 2..n {\n if n % i == 0 {\n let tmp_end = s.split_off(i);\n s = s.chars().rev().collect();\n s.push_str(&tmp_end);\n // println!(\"{}: {}\", i, s);\n }\n }\n s = s.chars().rev().collect();\n\n println!(\"{}\", s);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "fa649cce61c2df64886c73a30645d5bd", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0} {"lang": "Rust 2021", "source_code": "#[allow(dead_code)]\nfn scan() -> T\n{\n\tstatic mut BUFFER: Vec = vec![];\n\tloop {\n\t\tif let Some(token) = unsafe { BUFFER.pop() } {\n\t\t\treturn token.parse().ok().unwrap();\n\t\t}\n\t\tlet mut input = String::new();\n\t\tstd::io::stdin().read_line(&mut input).ok();\n\t\tunsafe { BUFFER = input.split_whitespace().rev().map(String::from).collect(); }\n\t}\n}\n\nstruct Comb {\n\tmodu: i64,\n\tfact: Vec,\n\tifact: Vec,\n}\n\nimpl Comb {\n\tfn mpow(&self, mut x: i64, mut y: i64) -> i64\n\t{\n\t\tlet mut ans = 1;\n\t\twhile y > 0 {\n\t\t\tif y&1 == 1 {\n\t\t\t\tans = ans*x % self.modu;\n\t\t\t}\n\t\t\tx = x*x % self.modu;\n\t\t\ty >>= 1;\n\t\t}\n\t\tans\n\t}\n\n\tfn inv(&self, x: i64) -> i64 { self.mpow(x, self.modu-2) }\n\n\tfn new(modu: i64, size: usize) -> Self\n\t{\n\t\tassert!(size > 1);\n\t\tlet mut tmp = Self { modu, fact: vec![0; size], ifact: vec![0; size] };\n\t\ttmp.fact[0] = 1;\n\t\tfor i in 1..size {\n\t\t\ttmp.fact[i] = tmp.fact[i-1] * i as i64 % modu;\n\t\t}\n\t\ttmp.ifact[size-1] = tmp.inv(tmp.fact[size-1]);\n\t\tfor i in (1..size).rev() {\n\t\t\ttmp.ifact[i-1] = tmp.ifact[i] * i as i64 % modu;\n\t\t}\n\t\ttmp\n\t}\n\n\tfn C(&self, n: i64, r: i64) -> i64\n\t{\n\t\tif 0 <= r && r <= n {\n\t\t\tself.fact[n as usize] * self.ifact[r as usize] % self.modu * self.ifact[(n-r) as usize] % self.modu\n\t\t} else {\n\t\t\t0\n\t\t}\n\t}\n\n}\n\nfn main()\n{\n\tlet n = scan::();\n\tlet modu = scan::();\n\tlet cb = Comb::new(modu, n as usize + 10);\n\n\tlet mut ans = 0i64;\n\tfor a in 0..=n {\n\t\tlet b = n-a;\n\t\tlet mut s = 0i64;\n\t\tfor c in 0..=b {\n\t\t\ts += cb.C(b-1, c-1) * cb.C(a, c) % modu * cb.mpow(b, a-c) % modu * cb.mpow(n-1, c);\n\t\t}\n\t\tans += s * cb.C(n, a) % modu * cb.fact[b as usize] % modu;\n\t}\n\tans %= modu;\n\tprintln!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "64998571b2b20267491a3d07da890bf9", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0} {"lang": "Rust 2021", "source_code": "#[allow(dead_code)]\nfn scan() -> T\n{\n\tstatic mut BUFFER: Vec = vec![];\n\tloop {\n\t\tif let Some(token) = unsafe { BUFFER.pop() } {\n\t\t\treturn token.parse().ok().unwrap();\n\t\t}\n\t\tlet mut input = String::new();\n\t\tstd::io::stdin().read_line(&mut input).ok();\n\t\tunsafe { BUFFER = input.split_whitespace().rev().map(String::from).collect(); }\n\t}\n}\n\nstruct Comb {\n\tmodu: i64,\n\tfact: Vec,\n\tifact: Vec,\n}\n\nimpl Comb {\n\tfn mpow(&self, mut x: i64, mut y: i64) -> i64\n\t{\n\t\tlet mut ans = 1;\n\t\twhile y > 0 {\n\t\t\tif y&1 == 1 {\n\t\t\t\tans = ans*x % self.modu;\n\t\t\t}\n\t\t\tx = x*x % self.modu;\n\t\t\ty >>= 1;\n\t\t}\n\t\tans\n\t}\n\n\tfn inv(&self, x: i64) -> i64 { self.mpow(x, self.modu-2) }\n\n\tfn new(modu: i64, size: usize) -> Self\n\t{\n\t\tassert!(size > 1);\n\t\tlet mut tmp = Self { modu, fact: vec![0; size], ifact: vec![0; size] };\n\t\ttmp.fact[0] = 1;\n\t\tfor i in 1..size {\n\t\t\ttmp.fact[i] = tmp.fact[i-1] * i as i64 % modu;\n\t\t}\n\t\ttmp.ifact[size-1] = tmp.inv(tmp.fact[size-1]);\n\t\tfor i in (1..size).rev() {\n\t\t\ttmp.ifact[i-1] = tmp.ifact[i] * i as i64 % modu;\n\t\t}\n\t\ttmp\n\t}\n\n\tfn C(&self, n: i64, r: i64) -> i64\n\t{\n\t\tif 0 <= r && r <= n {\n\t\t\tself.fact[n as usize] * self.ifact[r as usize] % self.modu * self.ifact[(n-r) as usize] % self.modu\n\t\t} else {\n\t\t\t0\n\t\t}\n\t}\n\n}\n\nfn main()\n{\n\tlet n = scan::();\n\tlet modu = scan::();\n\tlet cb = Comb::new(modu, n as usize + 10);\n\n\tlet mut ans = 0i64;\n\tfor a in 0..=n {\n\t\tlet b = n-a;\n\t\tlet mut s = 0i64;\n\t\tfor c in 0..=b {\n\t\t\ts += cb.C(b-1, c-1) * cb.C(a, c) % modu * cb.mpow(b, a-c) % modu * cb.mpow(n-1, c) % modu;\n\t\t}\n\t\ts %= modu;\n\t\tans += s * cb.C(n, a) % modu * cb.fact[b as usize] % modu;\n\t}\n\tans %= modu;\n\tprintln!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "55f2c58762c27bde29b526ba07b9b365", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0} {"lang": "Rust 2021", "source_code": "#[allow(dead_code)]\nfn scan() -> T\n{\n\tstatic mut BUFFER: Vec = vec![];\n\tloop {\n\t\tif let Some(token) = unsafe { BUFFER.pop() } {\n\t\t\treturn token.parse().ok().unwrap();\n\t\t}\n\t\tlet mut input = String::new();\n\t\tstd::io::stdin().read_line(&mut input).ok();\n\t\tunsafe { BUFFER = input.split_whitespace().rev().map(String::from).collect(); }\n\t}\n}\n\nstruct Comb {\n\tmodu: i64,\n\tfact: Vec,\n\tifact: Vec,\n}\n\nimpl Comb {\n\tfn mpow(&self, mut x: i64, mut y: i64) -> i64\n\t{\n\t\tlet mut ans = 1;\n\t\twhile y > 0 {\n\t\t\tif y&1 == 1 {\n\t\t\t\tans = ans*x % self.modu;\n\t\t\t}\n\t\t\tx = x*x % self.modu;\n\t\t\ty >>= 1;\n\t\t}\n\t\tans\n\t}\n\n\tfn inv(&self, x: i64) -> i64 { self.mpow(x, self.modu-2) }\n\n\tfn new(modu: i64, size: usize) -> Self\n\t{\n\t\tassert!(size > 1);\n\t\tlet mut tmp = Self { modu, fact: vec![0; size], ifact: vec![0; size] };\n\t\ttmp.fact[0] = 1;\n\t\tfor i in 1..size {\n\t\t\ttmp.fact[i] = tmp.fact[i-1] * i as i64 % modu;\n\t\t}\n\t\ttmp.ifact[size-1] = tmp.inv(tmp.fact[size-1]);\n\t\tfor i in (1..size).rev() {\n\t\t\ttmp.ifact[i-1] = tmp.ifact[i] * i as i64 % modu;\n\t\t}\n\t\ttmp\n\t}\n\n\tfn C(&self, n: i64, r: i64) -> i64\n\t{\n\t\tif 0 <= r && r <= n {\n\t\t\tself.fact[n as usize] * self.ifact[r as usize] % self.modu * self.ifact[(n-r) as usize] % self.modu\n\t\t} else {\n\t\t\t0\n\t\t}\n\t}\n\n}\n\nfn main()\n{\n\tlet n = scan::();\n\tlet modu = scan::();\n\tlet cb = Comb::new(modu, n as usize + 10);\n\n\tlet mut ans = 0i64;\n\tfor a in 0..=n {\n\t\tlet b = n-a;\n let kooft_step = cb.inv(b) * (n-1) % modu;\n let mut kooft = cb.mpow(b, a);\n\t\tlet mut s = 0i64;\n\t\tfor c in 0..=std::cmp::min(a, b) {\n\t\t\ts += cb.C(b-1, c-1) * cb.C(a, c) % modu * kooft % modu;\n kooft = kooft * kooft_step % modu;\n\t\t}\n\t\ts %= modu;\n\t\tans += s * cb.C(n, a) % modu * cb.fact[b as usize] % modu;\n\t}\n\tans %= modu;\n\tprintln!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "adbdf86fbfc3c8b533e40fa2feae475f", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.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 mut n: u64 = it.next().unwrap().parse().unwrap();\n let m: usize = it.next().unwrap().parse().unwrap();\n let p = 10;\n let mut cnt = vec![0; p];\n while n > 0 {\n let k = (n % p as u64) as usize;\n cnt[k] += 1;\n n /= p as u64;\n }\n let mut step = vec![1; p + 1];\n for i in (0..p).rev() {\n step[i] = step[i + 1] * (cnt[i] + 1);\n }\n let len = step[0];\n let mut dp = vec![vec![0u64; len]; m];\n dp[0][len - 1] = 1;\n let mut q = std::collections::VecDeque::new();\n q.push_back((0, len - 1));\n while let Some((rem, v)) = q.pop_front() {\n for d in 0..p {\n let a = v % step[d] / step[d + 1];\n if a > 0 && !(d == 0 && v == len - 1) {\n let u = v - step[d + 1];\n let r = (10 * rem + d) % m;\n if dp[r][u] == 0 {\n q.push_back((r, u));\n }\n dp[r][u] += dp[rem][v];\n }\n }\n }\n let ans = dp[0][0];\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "2ec4efb24ca34f80568eb49d83d6db7e", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.0} {"lang": "Rust", "source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\nuse std::io::{StdinLock, stdin, BufRead};\nuse std::collections::*;\nuse std::cmp::*;\n\nfn scan_helper(lock : &mut StdinLock) -> String {\n let mut buffer = String::new();\n lock.read_line(&mut buffer).ok();\n buffer\n}\n\nmacro_rules! scan {\n ($lock:ident, $t:ty) => ({\n scan_helper(&mut $lock).split_whitespace()\n .next().unwrap()\n .parse::<$t>().unwrap()\n });\n ($lock:ident, $($t:ty),+) => ({\n let buffer = scan_helper(&mut $lock);\n let mut iter = buffer.split_whitespace();\n ($(\n {\n iter.next().unwrap()\n .parse::<$t>().unwrap()\n },\n )+)\n })\n}\n\nmacro_rules! scan_iter {\n ($lock:ident, $t:ty) => ({\n scan_helper(&mut $lock).split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect()\n })\n}\n\ntrait Ext {\n fn idx(&self) -> usize;\n fn num(&self) -> i64;\n}\n\nmacro_rules! ext {\n ($t:ty) => (\n impl Ext for $t {\n #[inline]\n fn idx(&self) -> usize {\n *self as usize\n }\n\n #[inline]\n fn num(&self) -> i64 {\n *self as i64\n }\n }\n )\n}\next!(i64);\next!(usize);\n\nmacro_rules! derive_regular {\n ($t:ty) => (\n impl Ord for $t {\n fn cmp(&self, other : &$t) -> Ordering {\n self.partial_cmp(other).unwrap()\n }\n }\n impl PartialEq for $t {\n fn eq(&self, other : &$t) -> bool {\n self.cmp(other) == Ordering::Equal\n }\n }\n impl Eq for $t {}\n )\n}\n\nfn solve(v : &Vec, n : i64, d : bool, memo : &mut HashMap<(i64, bool), (i64, i64)>) -> (i64, i64) {\n if n == v.len().num() {\n if d {\n return (0, 0);\n } else {\n return (0, 0);\n }\n }\n if let Some(&x) = memo.get(&(n, d)) {\n return x;\n }\n\n let mut take = solve(v, n+1, !d, memo);\n if d {\n take.1 += v[n.idx()];\n } else {\n take.0 += v[n.idx()];\n }\n let mut defer = solve(v, n+1, d, memo);\n if d {\n defer.0 += v[n.idx()];\n } else {\n defer.1 += v[n.idx()];\n }\n\n let result = if d {\n if take.1 >= defer.1 {\n take\n } else {\n defer\n }\n } else {\n if take.0 >= defer.0 {\n take\n } else {\n defer\n }\n };\n memo.insert((n, d), result);\n\n result\n}\n\nfn main() {\n let stdin = stdin();\n let mut s = stdin.lock();\n let n = scan!(s, i64);\n let data : Vec<_> = scan_iter!(s, i64);\n\n let mut memo = HashMap::new();\n\n let result = solve(&data, 0, true, &mut memo);\n println!(\"{} {}\", result.0, result.1);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "9c9936a304a5b9afe9dd2a0d8101a1e4", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "Rust", "source_code": "// ---------- 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\nfn run() {\r\n input! {\r\n s: bytes,\r\n }\r\n if s.len() > 1 && s[0] == b'0' {\r\n println!(\"0\");\r\n return;\r\n }\r\n let mut x = 1;\r\n if s.contains(&b'X') {\r\n x = 10;\r\n }\r\n let mut ans = 0;\r\n for v in 0..x {\r\n let mut dp = [0; 25];\r\n dp[0] = 1u64;\r\n for (i, s) in s.iter().enumerate() {\r\n if *s == b'_' {\r\n let mut s = 0;\r\n if i == 0 {\r\n s = 1;\r\n }\r\n let mut next = [0; 25];\r\n for d in s..10 {\r\n for (i, dp) in dp.iter().enumerate() {\r\n next[(i * 10 + d) % 25] += *dp;\r\n }\r\n }\r\n dp = next;\r\n } else if *s == b'X' {\r\n if i == 0 && v == 0 {\r\n dp = [0; 25];\r\n break;\r\n }\r\n let k = v;\r\n let mut next = [0; 25];\r\n for d in k..(k + 1) {\r\n for (i, dp) in dp.iter().enumerate() {\r\n next[(i * 10 + d) % 25] += *dp;\r\n }\r\n }\r\n dp = next;\r\n } else {\r\n let k = (*s - b'0') as usize;\r\n let mut next = [0; 25];\r\n for d in k..(k + 1) {\r\n for (i, dp) in dp.iter().enumerate() {\r\n next[(i * 10 + d) % 25] += *dp;\r\n }\r\n }\r\n dp = next;\r\n }\r\n }\r\n ans += dp[0];\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": "b64f24202d1dd66e1fabb572de2f997f", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "Rust", "source_code": "use std::io::{self, BufRead};\n\nfn compare(x: i32, y: i32) -> i32 {\n if x == y {\n return 0;\n }\n if (x == 2 && y == 4) || (x == 4 && y == 2) {\n return 0;\n }\n\n if x <= 3 && y <= 3 {\n return if x < y { -1 } else { 1 };\n }\n if x >= 3 && y >= 3 {\n return if x < y { 1 } else { -1 };\n }\n\n if x == 1 {\n return -1;\n }\n if y == 1 {\n return 1;\n }\n\n if x <= 3 { 1 } else { -1 }\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut input = String::new();\n stdin.lock().read_line(&mut input).unwrap();\n\n let tokens: Vec<&str> = input.split_whitespace().collect();\n let x = tokens[0].parse::().unwrap();\n let y = tokens[1].parse::().unwrap();\n\n match compare(x, y) {\n -1 => println!(\"<\"),\n 0 => println!(\"=\"),\n 1 => println!(\">\"),\n _ => println!(\"This shouldn't happen...\")\n };\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "b58dcdc08ee0cb962e921a278d225e57", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.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 main() {\n let n: usize = get_line().trim().parse().unwrap();\n\n let s = get_line().trim().to_string();\n\n let it = s.split_terminator(char::is_uppercase);\n\n let ans = it.map(|s| {\n s.bytes().fold(vec![false; 26], |mut acc, c| {\n acc[(c - b'a') as usize] = true;\n acc\n }).into_iter().filter(|&b| b).count()\n }).max().unwrap();\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "bdef1f871a37848dac3ba3fcd3b11170", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"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 let a1: isize = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let a2: isize = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let k1: isize = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let k2: isize = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let n: isize = input.trim().parse().unwrap();\n\n if n >= ((a1 * k1) + (a2 * k2)) {\n println!(\"{} {}\", a1 + a2, a1 + a2);\n return;\n }\n\n // Find minimum\n let minimum = if n - (a1 * (k1 - 1)) - (a2 * (k2 - 1)) > 0 {\n n - (a1 * (k1 - 1)) - (a2 * (k2 - 1))\n } else {\n 0\n };\n\n // Find maximum\n let mut maximum = 0;\n let mut cards_left = n;\n if (a1 * k1) < (a2 * k2) {\n cards_left -= a1 * k1;\n maximum += if cards_left >= 0 { a1 } else { n / k1 } + (cards_left / k2);\n } else {\n cards_left -= a2 * k2;\n println!(\"{}\", cards_left);\n maximum += if cards_left >= 0 { a2 } else { n / k2 } + (cards_left / k1);\n }\n\n println!(\"{} {}\", minimum, maximum);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f603203ed05c86f80a650f9fe26cd5d0", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io::{self, BufWriter, Write};\nuse std::str::{self, SplitAsciiWhitespace};\n\n// I have no idea what I'm doing\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\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 a: i32 = scan.token();\n let b: i32 = scan.token();\n let c: i32 = scan.token();\n let d: i32 = scan.token();\n\n if a == 0 && (c > 0 || d > 0) {\n writeln!(out, \"0\")?;\n return Ok(());\n }\n\n writeln!(out, \"{}\", match a == d {\n true => 1,\n false => 0,\n })?;\n\n Ok(())\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "451efebd53e52f6729c2912a15d1d6a3", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "Rust", "source_code": "fn main(){\n\tlet mut line = String::new();\n\n\tstd::io::stdin().read_line(&mut line)\n\t.expect(\"Reading n error!\");\n\t\n\tlet mut iter = line.split_whitespace();\n\n\tlet n:usize = iter.next().expect(\"\").parse()\n\t.expect(\"Error while parsing!\");\n\t\n\tlet m:usize = iter.next().expect(\"\").parse()\n\t.expect(\"Error while parsing!\");\n\t\n\tlet d:i64 = iter.next().expect(\"\").parse()\n\t.expect(\"Error while parsing!\");\n\t\n\tlet mut v1 = Vec::new();\n\tlet mut v2 = Vec::new();\n\t\n\tfor i in 0..n {\n\t let mut line = String::new();\n\t std::io::stdin().read_line(&mut line).expect(\"\");\n\t let mut iter = line.split_whitespace();\n\t \n\t let c:i64 = iter.next().expect(\"\").parse().expect(\"\");\n\t let w:i64 = iter.next().expect(\"\").parse().expect(\"\");\n\t \n\t v1.push((c, -w));\n\t}\n\t\n\tfor i in 0..m {\n\t let mut line = String::new();\n\t std::io::stdin().read_line(&mut line).expect(\"\");\n\t let mut iter = line.split_whitespace();\n\t \n\t let c:i64 = iter.next().expect(\"\").parse().expect(\"\");\n\t let w:i64 = iter.next().expect(\"\").parse().expect(\"\");\n\t \n\t v2.push((c, -w));\n\t}\n\t\n\tv1.sort();\n\tv2.sort();\n\t\n\tif v1[n - 1].0 + v2[m - 1].0 > d\n\t{\n\t println!(\"0\");\n\t return;\n\t}\n\t\n\tfor i in 0..n {\n\t v1[i].1 = -v1[i].1;\n\t}\n\t\n\tfor i in 0..m {\n\t v2[i].1 = -v2[i].1;\n\t}\n\t\n\tfor i in 1..n {\n\t v1[n - i - 1].0 += v1[n - i].0;\n\t v1[n - i - 1].1 += v1[n - i].1;\n\t}\n\t\n\tfor i in 1..m {\n\t v2[m - i - 1].0 += v2[m - i].0;\n\t v2[m - i - 1].1 += v2[m - i].1;\n\t}\n\n\tlet mut ans:i64 = 0 as i64;\n\t\n\tfor i in v1 {\n\t let mut lo:usize = 1;\n\t let mut hi:usize = m;\n\t while lo <= hi\n\t {\n\t let mid = (lo + hi) / 2;\n\t if i.1 + v2[mid - 1].1 > d\n\t {\n\t lo = mid + 1;\n\t }\n\t else\n\t {\n\t ans = std::cmp::max(ans, i.0 + v2[mid - 1].0);\n\t hi = mid - 1;\n\t }\n\t }\n\t}\n\t\n\tprintln!(\"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "87e8a48555fc29813f60bca9e9a7b70d", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "Rust", "source_code": "// use rand::Rng;\n\nuse std::collections::*;\nuse std::io;\n\nfn trim_newline(s: &mut String) {\n if s.ends_with('\\n') {\n s.pop();\n if s.ends_with('\\r') {\n s.pop();\n }\n }\n}\nmacro_rules! parse_input {\n ($t:ident) => {{\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n trim_newline(&mut input_line);\n input_line.parse::<$t>().unwrap()\n }};\n}\n\nmacro_rules! split_input {\n ($t:ident) => {{\n parse_input!(String)\n .split(\" \")\n .map(|z| z.parse::<$t>().unwrap())\n .collect::>()\n }};\n}\n\nfn main() {\n let a = split_input!(usize);\n let l = a[1] - a[0] + 1;\n if l < 3 || l == 3 && a[1] & 1 > 0 {\n println!(\"-1\");\n } else {\n let mut s = a[0];\n if s & 1 == 1 {\n s += 1;\n }\n println!(\"{} {} {}\", s, s + 1, s + 2);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "64497c3c9cd7010d90d0115b6413af26", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d", "difficulty": 1100.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 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 main() {\n let mut sin = Scanner::new();\n\n let n = sin.next();\n\n let mut array : Vec = Vec::new();\n\n for _ in 0..n {\n let a = sin.next();\n array.push(a);\n }\n\n let num_non_zeros = array.iter()\n .fold(0, |acc, &x| acc + if x != 0 {1} else {0});\n\n let mut answers : Vec<(usize, usize)> = Vec::new();\n\n if num_non_zeros == 0 {\n println!(\"NO\");\n } else if num_non_zeros == 1 {\n println!(\"YES\");\n println!(\"1\");\n println!(\"{} {}\", 1, array.len());\n } else {\n println!(\"YES\");\n\n let mut left = 0;\n let mut right = 0;\n let mut limit = array.len();\n\n for i in (0..n).rev() {\n if array[i] != 0 {\n limit = i;\n break;\n }\n }\n\n for _ in 0..limit {\n if array[right] == 0 {\n right += 1;\n } else {\n answers.push((left + 1, right + 1));\n left = right + 1;\n right += 1;\n }\n }\n\n answers.push((left + 1, array.len()));\n\n println!(\"{}\", answers.len());\n for t in answers {\n println!(\"{} {}\", t.0, t.1);\n }\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "5f0d84076228b697d19bd1aad56419e0", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "Rust", "source_code": "#[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 ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($next, $t);\n input_inner!{$next $($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(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n #[cfg(debug_assertions)]\n writeln!(&mut std::io::stderr(), concat!(\"[DEBUG] \", $(stringify!($a), \"={:?} \"),*), $($a),*);\n }\n}\n\n#[allow(unused_imports)]\nuse std::cmp::{min, max};\n#[allow(unused_imports)]\nuse std::io::{stdout, stdin, BufWriter, Write};\n\nfn main() {\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\n const MOD: u64 = 998244353;\n\n\n input!{\n w: usize,\n h: usize,\n }\n\n let mut ans = 4;\n for _ in 0..w-1 {\n ans *= 2;\n ans %= MOD;\n }\n for _ in 0..h-1 {\n ans *= 2;\n ans %= MOD;\n }\n puts!(\"{}\\n\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "19109677dc2d9d85f96bdb84dc9bf30f", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "Rust", "source_code": "#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]\nuse std::io::{stdin, Read, StdinLock};\nuse std::str::FromStr;\nuse std::fmt::*;\nuse std::str::*;\nuse std::cmp::*;\nuse std::collections::*;\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! readl {\n ($t: ty) => {\n {\n let s = getline();\n s.trim().parse::<$t>().unwrap()\n }\n };\n ($( $t: ty),+ ) => {\n {\n let s = getline();\n let mut iter = s.trim().split(' ');\n ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) \n }\n };\n}\n\nmacro_rules! readlvec {\n ($t: ty) => {\n {\n let s = getline();\n let iter = s.trim().split(' ');\n iter.map(|x| x.parse().unwrap()).collect::>()\n }\n }\n}\n\nmacro_rules! mvec {\n ($v: expr, $s: expr) => {\n vec![$v; $s]\n };\n ($v: expr, $s: expr, $($t: expr),*) => {\n vec![mvec!($v, $($t),*); $s]\n };\n}\n\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {:?}\", stringify!($x), $x)\n }\n}\n\nfn printiter<'a, T>(v: &'a T)\nwhere\n &'a T: std::iter::IntoIterator, \n <&'a T as std::iter::IntoIterator>::Item: 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\nstruct ContestPrinter {\n s: String,\n}\n\nimpl ContestPrinter {\n fn new() -> ContestPrinter {\n ContestPrinter {\n s: String::new(),\n }\n }\n\n fn print(&mut self, x: T)\n where T: std::fmt::Display {\n self.s.push_str(format!(\"{}\", x).as_str());\n }\n\n fn println(&mut self, x: T)\n where T: std::fmt::Display {\n self.s.push_str(format!(\"{}\\n\", x).as_str());\n }\n}\n\nimpl std::ops::Drop for ContestPrinter {\n fn drop(&mut self) {\n print!(\"{}\", self.s);\n }\n}\n\n\n\nfn main() {\n let mut printer = ContestPrinter::new();\n \n let s = readl!(String);\n let cs: Vec = s.chars().collect();\n\n let mut next: u8 = 0; // a\n let mut done = [false; 26];\n let mut out = String::new();\n for c in cs {\n let num = c as u8 - 'a' as u8;\n if next >= num {\n done[next as usize] = true;\n next += 1;\n out.push(('a' as u8 + next - 1 + if ((next - 1 - num) == 0) { 0 } else {next - 2 - num}) as char);\n } else {\n out.push(c);\n }\n if next >= 26 { break; }\n }\n let mut okay = true;\n for d in done.iter() { if !d { okay = false; } }\n if okay { printer.println(out); }\n else { printer.println(-1); }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "4f6e159c6cfb02f4380c283ceacc62a7", "src_uid": "f8ad543d499bcc0da0121a71a26db854", "difficulty": 1300.0} {"lang": "Rust", "source_code": "fn read_ints() -> Vec {\n let mut ln = String::new();\n std::io::stdin().read_line(&mut ln).expect(\"\");\n ln.split_whitespace().filter_map(|w| w.parse().ok()).collect()\n}\n\nconst MODULUS: i64 = 1000000007;\nconst NEG_INV2: i64 = (MODULUS - 1) / 2;\n\nfn qpow(mut base: i64, mut exp: i64) -> i64 {\n let mut ans = 1i64;\n while exp > 0 {\n if exp % 2 == 1 { ans = (ans * base) % MODULUS; }\n base = (base * base) % MODULUS;\n exp >>= 1;\n }\n ans\n}\n\nfn main() {\n let (x, k);\n if let [_x, _k] = read_ints()[..] { x = _x; k = _k; } else { panic!(\"> <\"); }\n\n if x == 0 {\n println!(0);\n } else {\n println!(\"{}\", ((x + NEG_INV2) * qpow(2, k + 1) + 1) % MODULUS);\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e525901d6852cb32974237d05a300c17", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "Rust", "source_code": "use std::io;\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 digits(mut n: u64) -> u64 {\n let mut count = 0u64;\n while n > 0 {\n count += 1;\n n /= 10;\n }\n return count;\n}\n\nfn main() {\n let n: u64 = read_line().parse().unwrap();\n \n let d = digits(n);\n let mut nums_counted = 0u64;\n let mut nines = 9u64;\n let mut res = 0u64;\n for i in 1 .. d {\n let cur_len = nines - nums_counted;\n nines = nines * 10 + 9;\n res += cur_len * i;\n nums_counted += cur_len;\n }\n \n let cur_len = n - nums_counted;\n res += cur_len * d;\n \n println!(\"{}\", res);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "4431b17cc2552a1dcba32eb6640847fa", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "Rust", "source_code": "fn main() {\n let mut input = String::new();\n use std::io::prelude::*;\n std::io::stdin().read_to_string(&mut input).unwrap();\n\n let mut it = input.split_whitespace().map(|x| {\n x.parse::().unwrap()\n });\n\n let (mut a, b, c) = (\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n );\n\n let mut ans = -1;\n let mut cnt = 0;\n\n for _ in 0..b + 10 {\n cnt += 1;\n a *= 10;\n let q = a / b;\n if q == c {\n ans = cnt;\n break;\n }\n a -= q * b;\n }\n\n println!(\"{}\", ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "673dba3864a70cf43df0828e9e17c4f5", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0} {"lang": "Rust", "source_code": "use std::fmt;\nuse std::io;\nuse std::io::prelude::*;\nuse std::str::FromStr;\n\nenum Direction {\n South,\n East,\n North,\n West,\n}\n\n#[derive(Debug, Clone)]\nstruct DirectionError;\n\nimpl FromStr for Direction {\n type Err = DirectionError;\n\n fn from_str(s: &str) -> Result {\n match s {\n \"South\" => Ok(Direction::South),\n \"East\" => Ok(Direction::East),\n \"North\" => Ok(Direction::North),\n \"West\" => Ok(Direction::West),\n _ => Err(DirectionError),\n }\n }\n}\n\nimpl fmt::Display for Direction {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n match self {\n Direction::South => write!(f, \"South\"),\n Direction::East => write!(f, \"East\"),\n Direction::North => write!(f, \"North\"),\n Direction::West => write!(f, \"West\"),\n }\n }\n}\n\nstruct Step {\n t: i32,\n dir: Direction,\n}\n#[derive(Debug, Clone)]\nstruct StepError;\n\nimpl FromStr for Step {\n type Err = StepError;\n\n fn from_str(s: &str) -> Result {\n let mut lines = s.trim().split_whitespace();\n let t = match lines.next() {\n Some(s_t) => match s_t.parse::() {\n Ok(n_t) => Ok(n_t),\n Err(_) => Err(StepError),\n },\n None => Err(StepError),\n }?;\n let dir = match lines.next() {\n Some(s_dir) => match s_dir.parse::() {\n Ok(n_dir) => Ok(n_dir),\n Err(_) => Err(StepError),\n },\n None => Err(StepError),\n }?;\n Ok(Step { t, dir })\n }\n}\n\nimpl fmt::Display for Step {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n write!(f, \"{} {}\", self.t, self.dir)\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n\n let mut lines = stdin.lock().lines();\n let n = lines\n .next()\n .unwrap()\n .unwrap()\n .trim()\n .parse::()\n .unwrap();\n\n let a = lines\n .take(n)\n .map(|s| s.unwrap().parse::().unwrap())\n .fold(0, |sum, step| {\n match step.dir {\n Direction::South => {\n if sum >= 40000 {\n println!(\"NO\");\n std::process::exit(0);\n }\n return sum + step.t;\n },\n Direction::North => {\n if sum <= 0 {\n println!(\"NO\");\n std::process::exit(0);\n }\n return sum - step.t;\n },\n Direction::East | Direction::West => {\n if sum == 0 || sum == 40000 {\n println!(\"NO\");\n std::process::exit(0);\n }\n return sum;\n }\n }\n });\n\n if a != 0 {\n println!(\"NO\");\n } else {\n println!(\"YES\");\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7ef5a44488342813f662dc85b3a4676d", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet};\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 get() -> T\n where\n ::Err: Debug,\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().parse().unwrap()\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 #[allow(dead_code)]\n pub fn get2() -> (T, U)\n where\n ::Err: Debug,\n ::Err: Debug,\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().unwrap(),\n iter.next().unwrap().parse().unwrap(),\n )\n }\n\n #[allow(dead_code)]\n pub fn get3() -> (S, T, U)\n where\n ::Err: Debug,\n ::Err: Debug,\n ::Err: Debug,\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().unwrap(),\n iter.next().unwrap().parse().unwrap(),\n iter.next().unwrap().parse().unwrap(),\n )\n }\n}\n\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {:?}\", stringify!($x), $x)\n }\n}\n\nfn main() {\n let (n, k, x): (usize, usize, usize) = util::get3();\n let a: Vec = util::gets();\n\n println!(\"{}\", a[..n - k].iter().sum::() + k * x);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "bd074be931977fcc6658d07907f567c7", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "Rust", "source_code": "use std::collections::HashMap;\nuse std::io;\n\nfn to_pairs(line: &str) -> Vec<(i32, i32)> {\n\tlet mut iter = line.trim().split_whitespace();\n\tlet mut ret = Vec::new();\n\twhile let Some(x) = iter.next() {\n\t\tret.push((x.parse().unwrap(),\n\t\t iter.next().unwrap().parse().unwrap()));\n\t}\n\tret.sort();\n\treturn ret\n}\n\nfn get_unique(s1: (i32, i32), s2: (i32, i32)) -> Option {\n\tlet mut v = Vec::new();\n\tv.push(s1.0);\n\tv.push(s1.1);\n\tv.push(s2.0);\n\tv.push(s2.1);\n\tv.sort();\n\tv.dedup();\n\tif v.len() != 3 { return None; }\n\tfor x in v {\n\t\tif (x == s1.0 || x == s1.1) && (x == s2.0 || x == s2.1) {\n\t\t\treturn Some(x);\n\t\t}\n\t}\n\treturn None;\n}\n\nfn get_only_bit(x: i32) -> Option {\n\tlet mut count = 0;\n\tlet mut last = 0;\n\tfor i in 1..10 {\n\t\tif (x >> i & 1) != 0 {\n\t\t\tcount += 1;\n\t\t\tlast = i;\n\t\t}\n\t}\n\tif count == 1 { return Some(last); }\n\treturn None;\n}\n\nfn solve(s1: Vec<(i32, i32)>, s2: Vec<(i32, i32)>) -> i32 {\n\tlet mut va: HashMap<(i32, i32), i32> = HashMap::new();\n\tlet mut vb: HashMap<(i32, i32), i32> = HashMap::new();\n\tlet mut vab = 0;\n\tfor a in s1.iter() {\n\t\tfor b in s2.iter() {\n\t\t\tif let Some(x) = get_unique(*a, *b) {\n\t\t\t\tva.entry(*a)\n\t\t\t\t\t.and_modify(|e| { *e |= 1 << x })\n\t\t\t\t\t.or_insert(1 << x);\n\t\t\t\tvb.entry(*b)\n\t\t\t\t\t.and_modify(|e| { *e |= 1 << x })\n\t\t\t\t\t.or_insert(1 << x);\n\t\t\t\tvab |= 1 << x;\n\t\t\t}\n\t\t}\n\t}\n\tif let Some(x) = get_only_bit(vab) { return x; }\n\tfor (_, v) in va.iter() {\n\t\tif let None = get_only_bit(*v) { return -1; }\n\t}\n\tfor (_, v) in vb.iter() {\n\t\tif let None = get_only_bit(*v) { return -1; }\n\t}\n\treturn 0;\n}\n\nfn main() -> io::Result<()> {\n\tlet f = io::stdin();\n\tlet mut line = String::new();\n\tf.read_line(&mut line)?;\n\tline.clear();\n\tf.read_line(&mut line)?;\n\tlet s1 = to_pairs(&line);\n\tline.clear();\n\tf.read_line(&mut line)?;\n\tlet s2 = to_pairs(&line);\n\tprintln!(\"{}\", solve(s1, s2));\n\n\tOk(())\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7fb2a76c89930a90f3ade39131789566", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "Rust", "source_code": "use std::io;\nfn main()\n{\n let mut n = String::new();\n io::stdin().read_line(&mut n).unwrap();\n let n : i32 = n.trim().parse().unwrap();\n for i in 2..(n as f64).sqrt() as i32 + 1\n {\n if n % i == 0\n {\n println!(\"{}{}\", i, n / i);\n }\n }\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "1c185b614852c1eb4205301d87978305", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "Rust", "source_code": "#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]\nuse std::io::{stdin, Read, StdinLock};\nuse std::str::FromStr;\nuse std::fmt::*;\nuse std::str::*;\nuse std::cmp::*;\nuse std::collections::*;\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! readl {\n ($t: ty) => {\n {\n let s = getline();\n s.trim().parse::<$t>().unwrap()\n }\n };\n ($( $t: ty),+ ) => {\n {\n let s = getline();\n let mut iter = s.trim().split(' ');\n ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) \n }\n };\n}\n\nmacro_rules! readlvec {\n ($t: ty) => {\n {\n let s = getline();\n let iter = s.trim().split(' ');\n iter.map(|x| x.parse().unwrap()).collect::>()\n }\n }\n}\n\nmacro_rules! mvec {\n ($v: expr, $s: expr) => {\n vec![$v; $s]\n };\n ($v: expr, $s: expr, $($t: expr),*) => {\n vec![mvec!($v, $($t),*); $s]\n };\n}\n\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {:?}\", stringify!($x), $x)\n }\n}\n\nfn printiter<'a, T>(v: &'a T)\nwhere\n &'a T: std::iter::IntoIterator, \n <&'a T as std::iter::IntoIterator>::Item: 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\nstruct ContestPrinter {\n s: String,\n}\n\nimpl ContestPrinter {\n fn new() -> ContestPrinter {\n ContestPrinter {\n s: String::new(),\n }\n }\n\n fn print(&mut self, x: T)\n where T: std::fmt::Display {\n self.s.push_str(format!(\"{}\", x).as_str());\n }\n\n fn println(&mut self, x: T)\n where T: std::fmt::Display {\n self.s.push_str(format!(\"{}\\n\", x).as_str());\n }\n}\n\nimpl std::ops::Drop for ContestPrinter {\n fn drop(&mut self) {\n print!(\"{}\", self.s);\n }\n}\n\nfn main() {\n let mut printer = ContestPrinter::new();\n \n let (mut L, mut R, mut A) = readl!(i32, i32, i32);\n if L > R {\n R += A;\n } else {\n L += A;\n }\n while (L - R).abs() > 1 {\n if (L == 0) | (R == 0) { break; }\n if L > R {\n L -= 1;\n R += 1;\n } else {\n R -= 1;\n L += 1;\n }\n }\n printer.println(2 * min(L, R));\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e774cb797dd6b5d5ad6bd84ab9dc4b71", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0} {"lang": "Rust", "source_code": "#![allow(dead_code)]\n#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(overflowing_literals)]\n#![allow(unused_must_use)]\n\nuse std::collections::*;\nuse std::io::*;\nuse std::cmp::{min, max};\nuse std::f64::consts::*;\nuse std::mem::swap;\nuse std::fs::File;\nuse std::rc::*;\nuse std::ascii::*;\nuse std::ops::*;\n\nconst INF: i32 = std::i32::MAX;\nconst LINF: i64 = std::i64::MAX;\nconst MOD: usize = 1000000007;\n\n#[derive(PartialEq, PartialOrd, Eq, Ord, Copy, Clone)]\nstruct Pair(A, B);\n\nstruct Input\n{\n\tbuffer: Buf\n}\n\nimpl Input\n{\n\tfn read_line(&mut self) -> String {\n\t\tlet mut v = Vec::new();\n\t\tlet mut x = [255u8];\n\t\tself.buffer.read(&mut x).expect(\"EOF\");\n\t\twhile x[0] < b' ' && x[0] != 255u8 {\n\t\t\tx[0] = 255u8;\n\t\t\tself.buffer.read(&mut x).expect(\"EOF\");\n\t\t}\n\t\twhile x[0] >= b' ' && x[0] != 255u8 {\n\t\t\tv.push(x[0]);\n\t\t\tx[0] = 255u8;\n\t\t\tself.buffer.read(&mut x).expect(\"EOF\");\n\t\t}\n\t\tString::from_utf8(v).unwrap()\n\t}\n\n\tfn read_word(&mut self) -> String {\n\t\tlet mut v = Vec::new();\n\t\tlet mut x = [255u8];\n\t\tself.buffer.read(&mut x).expect(\"EOF\");\n\t\twhile x[0] <= b' ' && x[0] != 255u8 {\n\t\t\tx[0] = 255u8;\n\t\t\tself.buffer.read(&mut x).expect(\"EOF\");\n\t\t}\n\t\twhile x[0] > b' ' && x[0] != 255u8 {\n\t\t\tv.push(x[0]);\n\t\t\tx[0] = 255u8;\n\t\t\tself.buffer.read(&mut x).expect(\"EOF\");\n\t\t}\n\t\tString::from_utf8(v).unwrap()\n\t}\n\t#[inline]\n\tfn read_int(&mut self) -> i32 {\n\t\tself.read_word().parse::().expect(\"Parsing error\")\n\t}\n\t#[inline]\n\tfn read_long(&mut self) -> i64 {\n\t\tself.read_word().parse::().expect(\"Parsing error\")\n\t}\n\t#[inline]\n\tfn read_usize(&mut self) -> usize {\n\t\tself.read_word().parse::().expect(\"Parsing error\")\n\t}\n\t#[inline]\n\tfn read_double(&mut self) -> f64 {\n\t\tself.read_word().parse::().expect(\"Parsing error\")\n\t}\n}\nmacro_rules! read {\n () => {};\n\t($inf:ident,$($t:ty),*) => ({($({$inf.read_word().parse::<$t>().expect(\"Parsing error\")}),*)});\n}\nfn gcd + Copy + Clone>(x: T, y: T) -> T {\n\tlet (mut a, mut b) = (x, y);\n\twhile b > T::from(0) {\n\t\ta %= b;\n\t\tswap(&mut a, &mut b);\n\t}\n\ta\n}\n\nfn main() {\n\tmatch std::env::var(\"home\") {\n\t\tOk(_x) => {\n\t\t\tlet mut inf = Input {\n\t\t\t\tbuffer: BufReader::new(File::open(\"input.txt\").expect(\"File not found\"))\n\t\t\t};\n\t\t\tlet mut ouf = BufWriter::new(stdout());\n\t\t\tsolve(&mut inf, &mut ouf);\n\t\t}\n\t\tErr(_e) => {\n\t\t\tlet mut inf = Input { buffer: BufReader::new(stdin()) };\n\t\t\tlet mut ouf = BufWriter::new(stdout());\n\t\t\tsolve(&mut inf, &mut ouf);\n\t\t}\n\t}\n}\n\nfn solve(inf: &mut Input, ouf: &mut Output)\n{\n\tlet n = read!(inf,usize);\n\tlet mut w = vec![0usize; 2 * n];\n\tfor i in 0..2 * n {\n\t\tw[i] = read!(inf,usize);\n\t}\n\tw.sort();\n\tlet mut ans = MOD;\n\tfor i in 0..3 {\n\t\tlet mut pos = i;\n\t\tlet mut p = 0;\n\t\twhile pos < 2 * n - 2 + i {\n\t\t\tp += w[pos + 1] - w[pos];\n\t\t\tpos += 2;\n\t\t}\n\t\tans = min(ans, p);\n\t}\n\twriteln!(ouf, \"{}\", ans);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "8c57b104f6b49e13814fd25edf8c8b87", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "Rust", "source_code": "use std::io::stdin;\nfn main(){\n let mut s:String=String::new();\n stdin().read_line(&mut s).unwrap();\n s.clear();\n stdin().read_line(&mut s).unwrap();\n s.trim();\n let b=\"aeyuio\";\n let mut c:usize=1;\n let mut p:i32=0;\n let mut l:i32=0;\n while cp=1,\n 'e'=>p=1,\n 'y'=>p=1,\n 'u'=>p=1,\n 'i'=>p=1,\n 'o'=>p=1,\n _=>p=0,\n }\n match s.chars().nth(c-1).unwrap(){\n 'a'=>l=1,\n 'e'=>l=1,\n 'y'=>l=1,\n 'u'=>l=1,\n 'i'=>l=1,\n 'o'=>l=1,\n _=>l=0,\n }\n if p==l{\n s.remove(c);\n }\n else{c+=1;}\n }\n println!(\"{}\",s);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "e13570ccc0c43f0295dc630c9ae3a8f9", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "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": false, "code_uid": "f27ac5b85b14df72e5c75f8392d95c50", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "Rust", "source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Write, BufWriter};\n\nconst DEBUG: bool = false;\n\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 calc_dp(s: &[i8], n: usize, fib: &[u64])\n -> (Vec, Vec>, Vec>, Vec>) {\n let m = s.len();\n // s appears as a substring of A[i]\n let mut dp0 = vec![0u64; n + 1];\n // dp1[i][j]: s.substr(0, j) == A[i].substr(A[i].len() - j, j), not covered by dp0\n let mut dp1 = vec![vec![0u64; m]; n + 1];\n // dp2[i][j]: s.substr(s.len() - j, j) == A[i].substr(0, j), not covered by dp0\n let mut dp2 = vec![vec![0u64; m]; n + 1];\n // dp3[i][j]: s.substr(j, A[i].len()) == A[i], not covered by dp0, dp1, dp2\n let mut dp3 = vec![vec![0u64; m]; n + 1];\n if m == 1 {\n dp0[s[0] as usize] = 1;\n } else {\n for i in 1 .. m - 1 {\n dp3[s[i] as usize][i] = 1;\n }\n dp1[s[0] as usize][1] = 1;\n dp2[s[m - 1] as usize][1] = 1;\n }\n for i in 2 .. n + 1 {\n dp0[i] = dp0[i - 2].saturating_add(dp0[i - 1]);\n for j in 1 .. m {\n dp0[i] = dp0[i].saturating_add(dp1[i - 2][j] * dp2[i - 1][m - j]);\n }\n for j in 1 .. m {\n dp1[i][j] = dp1[i - 1][j];\n dp2[i][j] = dp2[i - 2][j];\n }\n let l_fst = fib[i - 2];\n let l_snd = fib[i - 1];\n for j in 1 .. m {\n if (j as u64).saturating_add(l_snd) < m as u64 {\n dp1[i][j + l_snd as usize] =\n max(dp1[i][j + l_snd as usize],\n dp1[i - 2][j] * dp3[i - 1][j]);\n }\n if (j as u64).saturating_add(l_fst) < m as u64 {\n dp2[i][j + l_fst as usize] =\n max(dp2[i][j + l_fst as usize],\n dp3[i - 2][m - j - l_fst as usize]\n * dp2[i - 1][j]);\n }\n if (j as u64).saturating_add(l_fst) < m as u64 {\n dp3[i][j]\n = max(dp3[i][j], dp3[i - 2][j] * dp3[i - 1][j + l_fst as usize]);\n }\n }\n }\n if DEBUG {\n eprintln!(\"dp0 = {:?}, dp1 = {:?}, dp2 = {:?}, dp3 = {:?}\", dp0, dp1, dp2, dp3);\n }\n (dp0, dp1, dp2, dp3)\n \n}\n\nfn calc(s: &[i8], n: usize, fib: &[u64]) -> u64 {\n if s.len() == 0 {\n return fib[n];\n }\n if n == 0 {\n return if s.len() == 1 && s[0] == 0 { 1 } else { 0 }; \n }\n let (dp0, _, _, _) = calc_dp(s, n, fib);\n if DEBUG {\n eprintln!(\"s = {:?}, dp0 = {:?}\", s, dp0);\n }\n dp0[n]\n}\n\nfn terminates(s: &[i8], n: usize, fib: &[u64]) -> u64 {\n if s.len() == 0 {\n return 0;\n }\n let m = s.len();\n if n == 0 {\n return if s.len() == 1 && s[0] == 0 { 1 } else { 0 }; \n }\n // dp1[i][j]: s.substr(0, j) == A[i].substr(A[i].len() - j, j)\n let mut dp1 = vec![vec![0u64; m + 1]; n + 1];\n // dp3[i][j]: s.substr(j, A[i].len()) == A[i], not covered by dp0, dp1, dp2\n let mut dp3 = vec![vec![0u64; m]; n + 1];\n if m == 1 {\n dp1[s[0] as usize][1] = 1;\n } else {\n for i in 1 .. m {\n dp3[s[i] as usize][i] = 1;\n }\n dp1[s[0] as usize][1] = 1;\n }\n for i in 2 .. n + 1 {\n for j in 1 .. m + 1 {\n dp1[i][j] = dp1[i - 1][j];\n }\n let l_fst = fib[i - 2];\n let l_snd = fib[i - 1];\n for j in 1 .. m + 1 {\n if (j as u64).saturating_add(l_snd) <= m as u64 {\n dp1[i][j + l_snd as usize] = dp1[i - 2][j] * dp3[i - 1][j];\n }\n if (j as u64).saturating_add(l_fst) < m as u64 {\n dp3[i][j]\n = max(dp3[i][j], dp3[i - 2][j] * dp3[i - 1][j + l_fst as usize]);\n }\n }\n }\n if DEBUG {\n eprintln!(\"term s = {:?}, dp1 = {:?}, dp3 = {:?}\", s, dp1, dp3);\n }\n dp1[n][m]\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 let mut fib = vec![0u64; 100];\n fib[0] = 1;\n fib[1] = 1;\n for i in 2 .. 100 {\n fib[i] = fib[i - 1].saturating_add(fib[i - 2]);\n }\n if false {\n calc(&[1, 1], 4, &fib);\n return;\n }\n input! {\n n: usize,\n k: u64,\n m: usize,\n }\n let mut fib = vec![0u64; max(n, 2) + 1];\n fib[0] = 1;\n fib[1] = 1;\n for i in 2 .. n + 1 {\n fib[i] = fib[i - 1].saturating_add(fib[i - 2]);\n }\n let mut det = Vec::new();\n let mut acc: u64 = 0;\n for _ in 0 .. m {\n let exact = terminates(&det, n, &fib);\n if acc < k && acc + exact >= k {\n break;\n }\n if DEBUG {\n eprintln!(\"det = {:?}, acc = {}, exact = {}\", det, acc, exact);\n }\n acc += exact;\n det.push(0i8);\n let u = calc(&det, n, &fib);\n if acc.saturating_add(u) < k {\n acc += u;\n det.pop();\n det.push(1i8);\n }\n }\n for d in det {\n puts!(\"{}\", d);\n }\n puts!(\"\\n\");\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": "13c5d414466c769b3d335b3dbcc8e5ed", "src_uid": "7b4a057efee5264bfaaf60d50fccb92b", "difficulty": 2700.0} {"lang": "Rust", "source_code": "use std::io::{self, BufWriter, Write};\nuse std::str::{self, SplitAsciiWhitespace};\n\n// I have no idea what I'm doing\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 (l, r) = scan.pair::();\n\n const M: i64 = 1_000_000_007;\n\n let m0 = r/3 - (l-1)/3;\n let m1 = m0\n - if r%3 == 0 { 1 } else { 0 }\n + if (l-1)%3 == 0 { 1 } else { 0 };\n let m2 = m0\n - if r%3 <= 1 { 1 } else { 0 }\n + if (l-1)%3 <= 1 { 1 } else { 0 };\n\n dbg!(m0);\n dbg!(m1);\n dbg!(m2);\n\n let mut ans = [1_i64, 0, 0];\n for _ in 0..n {\n let mut nxt = [0_i64; 3];\n nxt[0] = m0 * ans[0] % M + m1 * ans[2] % M + m2 * ans[1];\n nxt[1] = m0 * ans[1] % M + m1 * ans[0] % M + m2 * ans[2];\n nxt[2] = m0 * ans[2] % M + m1 * ans[1] % M + m2 * ans[0];\n\n for i in 0..3 {\n ans[i] = nxt[i] % M;\n }\n }\n\n writeln!(out, \"{}\", ans[0])?;\n\n Ok(())\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": "5fe5af023102ab14b176e01fc7cac7d4", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "Rust 2021", "source_code": "// ---------- begin chmin, chmax ----------\r\npub trait ChangeMinMax {\r\n fn chmin(&mut self, x: Self) -> bool;\r\n fn chmax(&mut self, x: Self) -> bool;\r\n}\r\n\r\nimpl ChangeMinMax for T {\r\n fn chmin(&mut self, x: Self) -> bool {\r\n *self > x && {\r\n *self = x;\r\n true\r\n }\r\n }\r\n fn chmax(&mut self, x: Self) -> bool {\r\n *self < x && {\r\n *self = x;\r\n true\r\n }\r\n }\r\n}\r\n// ---------- end chmin, chmax ----------\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\n\r\ntype Map = BTreeMap;\r\ntype Set = BTreeSet;\r\ntype Deque = VecDeque;\r\n\r\n// \u30a2\u30ea\u30b9\u3068\u30dc\u30d6\u304c\u30b2\u30fc\u30e0\u3092\u3059\u308b\r\n// \u30a2\u30ea\u30b9\u306fN\u500b\u306e\u5b9d\u3092\u6301\u3063\u3066\u3044\u308b\u3002\r\n// i\u500b\u76ee\u306e\u5b9d\u306b\u306f A_i \u679a\u306e\u30b3\u30a4\u30f3\u304c\u5165\u3063\u3066\u3044\u308b\r\n// \u307e\u305fM\u500b\u306e\u9375\u304c\u3042\u308b\r\n// j\u500b\u76ee\u306e\u9375\u306e\u5024\u6bb5\u306f\u30b3\u30a4\u30f3B_j\u679a\u3067\u3042\u308b\r\n//\r\n// \u6700\u521d\u3001\u30a2\u30ea\u30b9\u306f\u5b9d\u306e\u3044\u304f\u3064\u304b\u306b\u9320\u3092\u3064\u3051\u308b\r\n// j\u756a\u76ee\u306e\u9320\u306fj\u756a\u76ee\u306e\u9375\u3067\u306e\u307f\u958b\u304f\u3053\u3068\u304c\u3067\u304d\u308b\r\n// i\u756a\u76ee\u306e\u5b9d\u306bj\u756a\u76ee\u306e\u9320\u3092\u3064\u3051\u308b\u306e\u306b\u304b\u304b\u308b\u30b3\u30b9\u30c8\u306f C_{i, j} \u3067\u3042\u308b\r\n//\r\n// \u9320\u3092\u3064\u3051\u7d42\u308f\u3063\u305f\u5f8c\u3001\u30dc\u30d6\u306f\u3044\u304f\u3064\u304b\u9375\u3092\u30a2\u30ea\u30b9\u304b\u3089\u8cb7\u3063\u3066\u5b9d\u3092\u958b\u3051\u308b\r\n// (\u5b9d\u304b\u3089\u624b\u306b\u5165\u3063\u305f\u30b3\u30a4\u30f3) - (\u9375\u3092\u8cb7\u3046\u306e\u306b\u4f7f\u3063\u305f\u30b3\u30a4\u30f3) > 0\r\n// \u3092\u6e80\u305f\u3059\u6642\u3001\u30dc\u30d6\u306e\u52dd\u3061\u3068\u306a\u308b\r\n//\r\n// \u30a2\u30ea\u30b9\u306f\u30dc\u30d6\u304c\u52dd\u3066\u306a\u3044\u3088\u3046\u306b\u9320\u3092\u3064\u3051\u308b\u6642\u3001\u6700\u5c0f\u30b3\u30b9\u30c8\u3092\u6c42\u3081\u3088\r\n// \u4e0d\u53ef\u80fd\u306a\u3089-1\u3092\u51fa\u529b\u305b\u3088\r\n//\r\n// 1 <= N, M <= 6\r\n// 1 <= A_i, B_j <= 4\r\n// 1 <= C_{i, j} <= 10^7\r\n//\r\n//\r\n// \u30e1\u30e2\r\n// sum b < sum a \u306a\u3089-1\r\n// \u305d\u3046\u3067\u306a\u3044\u306a\u3089\u9320\u3092\u5168\u90e8\u3064\u3051\u308c\u3070\u3068\u308a\u3042\u3048\u305a\u306f\u52dd\u3066\u308b\r\n// \u611a\u76f4\u89e3\u3063\u3066\u306a\u3093\u3060\uff1f\r\n// \u9320\u3092\u5168\u63a2\u7d22\r\n// \u305d\u306e\u5f8c\u9375\u306e\u8cb7\u3044\u65b9\u3092\u5168\u63a2\u7d22\r\n// \u30b3\u30b9\u30c8\u3092\u8a08\u7b97\u3057\u3066\u5229\u5f97\u306e\u6700\u5927\u5024\u3092\u8a08\u7b97\u3001\u7b54\u3048\u306e\u66f4\u65b0\r\n// \u3053\u308c\u3067\u3044\u3044\r\n// \u8a08\u7b97\u91cf O(2^(NM) * 2^(M) * N) \u304f\u3089\u3044\uff1f\r\n// \u5f53\u7136\u9593\u306b\u5408\u308f\u3093\r\n// \u9375\u306f\u5168\u63a2\u7d22\u305b\u305a\u3068\u3082\u30d5\u30ed\u30fc\u3067\u89e3\u3051\u308b\r\n// \u9375\u3001\u5b9d\u3067\u305d\u308c\u305e\u308c\u9802\u70b9\u3092\u4f5c\u308b\r\n// src -> \u9375i \u306bb_i\r\n// \u9375j -> \u5b9di \u306b\u9320\u304c\u3064\u3044\u3066\u308b\u306a\u3089inf\r\n// \u5b9di -> dst \u306ba_i\r\n// \u3092\u5f35\u3063\u3066\u30d5\u30ed\u30fc\u3092\u6d41\u3059\r\n// sum a_i > (\u6d41\u91cf)\r\n// \u306a\u3089\u30dc\u30d6\u306e\u52dd\u3061\r\n// \u3053\u308c\u3067\u3082\u307e\u3060\u9593\u306b\u5408\u308f\u306a\u3044\r\n// \r\n// \u30dc\u30d6\u306f\u9375\u3092\u8cb7\u308f\u306a\u3044\u3053\u3068\u3067\u5e38\u306b0\u3092\u9054\u6210\u3067\u304d\u308b\r\n// \u30a2\u30ea\u30b9\u306f\u30dc\u30d6\u306e\u6700\u9069\u6226\u7565\u304c\u3053\u308c\u306b\u306a\u308b\u3088\u3046\u306b\u3057\u305f\u3044\r\n// \u3064\u307e\u308a\u30ab\u30c3\u30c8\u304c\u5e38\u306b\u5b9d->dst \u306e\u3068\u3053\u308d\u306b\u306a\u308b\u3088\u3046\u306b\u3057\u305f\u3044\r\n// N, M, A, B \u304c\u5c0f\u3055\u3044\u306e\u3067\u3053\u308c\u3092\u305d\u306e\u307e\u307edp\u306b\u3059\u308b\r\n// \u5b9d\u306b\u3064\u3044\u3066\u30eb\u30fc\u30d7\u3092\u56de\u3057\u3064\u3064\u8fba\u3092\u5f35\u3063\u3066\u6d41\u91cf\u3092\u5168\u90e8\u8a66\u3059\r\n// \u8fba\u3092\u6e80\u305f\u3057\u305f\u3089\u6b21\u3078\r\n// \u307f\u305f\u3044\u306a\r\n\r\nfn run() {\r\n input! {\r\n n: usize,\r\n m: usize,\r\n a: [i32; n],\r\n b: [i32; m],\r\n c: [[i32; m]; n],\r\n }\r\n let mut memo = Map::new();\r\n memo.insert(b, 0);\r\n for (a, c) in a.into_iter().zip(c) {\r\n let mut dp = Map::new();\r\n for (b, v) in memo.into_iter() {\r\n dp.insert((a, b), v);\r\n }\r\n for (i, c) in c.into_iter().enumerate() {\r\n let mut next = dp.clone();\r\n for ((a, b), v) in dp {\r\n let v = v + c;\r\n for k in 1..=b[i].min(a) {\r\n let mut b = b.clone();\r\n b[i] -= k;\r\n let a = a - k;\r\n next.entry((a, b)).or_insert(v).chmin(v);\r\n }\r\n }\r\n dp = next;\r\n }\r\n memo = Map::new();\r\n for ((a, b), v) in dp {\r\n if a == 0 {\r\n memo.entry(b).or_insert(v).chmin(v);\r\n }\r\n }\r\n }\r\n let ans = memo.values().min().cloned().unwrap_or(-1);\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": "cbd24b77cfd0fb8eff505742a73534d6", "src_uid": "4dc5dc78bda59c1ec6dd8acd6f1d7333", "difficulty": 3200.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 s: chars,\n k: usize,\n }\n let mut ans = s;\n let mut candy = 0;\n let mut snow = 0;\n for &c in &ans {\n if c == '?' {\n candy += 1;\n } else if c == '*' {\n snow += 1;\n }\n }\n let length = ans.len() - (candy + snow);\n debug!(length);\n if length < k {\n if snow < k - length {\n println!(\"Impossible\");\n return;\n }\n let mut done = false;\n let mut i = 0;\n while i < ans.len() {\n if ans[i] == '?' {\n ans.remove(i);\n i -= 1;\n } else if ans[i] == '*' {\n ans.remove(i);\n i -= 1;\n if !done {\n for j in 0..k-length {\n let x = ans[i-1];\n ans.insert(i, x);\n i += 1;\n }\n done = true;\n }\n }\n i += 1;\n }\n } else {\n if length - k > candy + snow {\n println!(\"Impossible\");\n return;\n }\n let mut del = length - k;\n let mut index = 0;\n debug!(del);\n while del > 0 {\n if ans[index] == '?' || ans[index] == '*' {\n ans.remove(index-1);\n ans.remove(index-1);\n index -= 2;\n del -= 1;\n }\n index += 1;\n }\n debug!(ans);\n debug!(length);\n while index < ans.len() {\n if ans[index] == '?' || ans[index] == '*' {\n ans.remove(index);\n index -= 1;\n }\n index += 1;\n }\n }\n let str_ans: String = ans.into_iter().collect();\n println!(\"{}\", str_ans);\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7f65640f2eede6d997e3bc64b530df07", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.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 (_, _, 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": false, "code_uid": "d9b36a6d9343e06c880bce42d5bdfbd7", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "Rust", "source_code": "fn main() {\n use std::io::prelude::*;\n use std::io;\n\n let mut input = String::new();\n io::stdin().read_to_string(&mut input).unwrap();\n\n let a: Vec = input.split_whitespace().map(|x| x.parse().unwrap())\n .collect();\n\n let mut max_ans = 0;\n\n let modulo = |a, b| {\n if a < 0 {\n a % b + b\n } else {\n a % b\n }\n };\n let modsub = |a, b| {\n modulo(a - b, 14)\n };\n\n for (i, &ai) in a.iter().enumerate() {\n let q = ai / 14;\n let r = ai % 14;\n\n let mut ans = 0;\n let mut j = i + 1;\n for _ in 0..13 {\n let cnt = a[modulo(j, 14)] + q + if r < modsub(j, i) as i64 { 0 } else { 1 };\n if cnt % 2 == 0 {\n ans += cnt;\n }\n \n j += 1\n }\n\n if q % 2 == 0 {\n ans += q;\n }\n\n if max_ans < ans {\n max_ans = ans;\n }\n }\n\n println!(\"{}\", max_ans);\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "fcf4d26833d0dbe26759ebd16955194e", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.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::*;\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 r: f64 = input.p();\n let x: f64 = input.p();\n let y: f64 = input.p();\n let xx: f64 = input.p();\n let yy: f64 = input.p();\n println!(\"{}\", (((x - xx).powi(2) + (y - yy).powi(2)).sqrt() / (2. * r)).ceil());\n}\n\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "3ad766034a769e21d2675b294428c3b4", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.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 = 400;\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": "0a9c8456547ddf85336f37edf0612a92", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.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\nfn solve() {\n let mut n: i64 = get();\n let k: i32 = get();\n let mut cnt = 0;\n let mut kk = k;\n while kk > 0 {\n if n == 0 {\n cnt = max(cnt + k - kk - 1, 0);\n break;\n }\n if n % 10 != 0 {\n cnt += 1;\n } else {\n kk -= 1;\n }\n n /= 10;\n }\n println!(\"{}\", cnt);\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": "d38c9d6591b30ba71906151bb20a41e7", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0} {"lang": "Rust", "source_code": "use std::io::{self, Read as _};\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_to_string(&mut input).unwrap();\n let mut input = input.split_whitespace();\n macro_rules! read(\n (($($tt:tt),+)) => (($(read!($tt)),*));\n ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap());\n );\n\n let (s, e) = read!((String, String));\n let mut x = e.as_bytes()[0] as i64 - s.as_bytes()[0] as i64;\n let mut y = e.as_bytes()[1] as i64 - s.as_bytes()[1] as i64;\n println!(\"{}\", x.abs().max(y.abs()));\n while x != 0 || y != 0 {\n if x < 0 {\n print!(\"L\");\n x += 1;\n } else if x > 0 {\n print!(\"R\");\n x -= 1;\n }\n if y < 0 {\n print!(\"D\");\n y += 1;\n } else if y > 0 {\n print!(\"U\");\n y -= 1;\n }\n println!();\n }\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "c38b7873a7de252977989c146870e4f2", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9", "difficulty": 1000.0} {"lang": "Rust", "source_code": "use std::io;\nuse std::cmp;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let mut iter = s.trim().split_whitespace().map(|x| x.parse().unwrap());\n let (n, m, a, b): (u64, u64, u64, u64) = (iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap(), iter.next().unwrap());\n let demolition_cost = (n % m) * b;\n let build_cost = (m - (n % m)) * a;\n println!(\"{}\", cmp::min(demolition_cost, build_cost));\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "f239095c9a83acb63b8192a01addfb7c", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.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": "ebe38e3e5abc72d40d61c3768b5fed2e", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "Rust", "source_code": "fn main() {\n let (r1, r2) = parse();\n let (c1, c2) = parse();\n let (d1, d2) = parse();\n let mut v1 = vec![];\n let mut v2 = vec![];\n\n for a in 1..10 {\n for b in 1..10 {\n if a != b && a + b == d1 {\n v1.push((a, b));\n }\n if a != b && a + b == d2 {\n v2.push((a, b))\n }\n }\n }\n for a in &v1 {\n for b in &v2 {\n if a.0 + b.0 == r1\n && a.1 + b.1 == r2\n && a.0 != b.0\n && a.0 != b.1\n && a.1 != b.0\n && a.1 != b.1\n {\n print_result(*a, *b);\n return;\n }\n }\n }\n println!(\"-1\");\n}\nfn print_result(a: (usize, usize), b: (usize, usize)) {\n println!(\"{} {}\", a.0, b.0);\n println!(\"{} {}\", b.1, a.1)\n}\nfn parse() -> (usize, usize) {\n let mut text = String::new();\n std::io::stdin().read_line(&mut text).unwrap();\n let text: Vec = text\n .trim()\n .split_whitespace()\n .map(|e| e.parse().unwrap())\n .collect();\n (text[0], text[1])\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "d61306ce6f30a612ebe74952e1d30324", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.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 next(&mut self) -> T {\n\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 let front = self.buffer.pop_front().unwrap();\n front.parse::().ok().unwrap()\n }\n}\n\nfn main() {\n let mut s = Scanner::new();\n let input : String = s.next();\n println!(\"8\");\n}\n", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "7fe203b748bf78c7097609a9596df873", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "Rust", "source_code": "#[warn(unused_variables)]\nfn main() {\n let input = input_vec::(\" \");\n let n = input[0];\n let v = input[1];\n\n println!(\"{}\", if (n-1) <= v {n-1} else {(n-v+1)*(n-v)/2 + v-1})\n}\n\nfn input_str() -> String {\n let mut buff = String::new();\n std::io::stdin().read_line(&mut buff).expect(\"Err\");\n buff\n}\n\nfn input_() -> T\nwhere\n T: std::str::FromStr,\n ::Err: std::fmt::Debug,\n{\n input_str().trim().parse::().expect(\"Err pars\")\n}\n\n\nfn input_vec(sep: &str) -> Vec \nwhere\n T: std::str::FromStr,\n ::Err: std::fmt::Debug,\n{\n input_str().trim().split(sep).map(|c| c.parse::().expect(\"Err pars\")).collect()\n}\n\nfn input_vec_chars() -> Vec {\n input_str().trim().chars().collect()\n}", "lang_cluster": "Rust", "compilation_error": false, "code_uid": "07897468aa3c48558078643975c9d4cd", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.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\nconst MOD: u64 = 1000000007;\n\nfn mod_pow(mut a: u64, mut n: u64) -> u64 {\n let mut result = 1;\n while n != 0 {\n if n % 2 == 1 {\n result = result * a % MOD;\n }\n a = a * a % MOD;\n n /= 2;\n }\n return result;\n}\n\nfn calc(p: u64, mut n: u64) -> u64 {\n let mut cnt = 0;\n while n != 0 {\n n /= p;\n cnt += n;\n }\n return mod_pow(p, cnt);\n}\n\nfn solve(writer: &mut std::io::BufWriter) {\n let (mut x, n) = parse_line!(u64, u64);\n let mut result = 1;\n for i in 2..=x {\n if i * i > x {\n break;\n }\n if x % i == 0 {\n x /= i;\n while x % i == 0 {\n x /= i;\n }\n result = result * calc(i, n) % MOD;\n }\n }\n if x != 1 {\n result = result * calc(x, n) % MOD;\n }\n writeln!(writer, \"{}\", result).unwrap();\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": "7429b526e5ff80536d8b368a4558f0a2", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0}