{"similarity_score": 0.976354256233878, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "//spnauti-rusT {{{\nuse std::io::*; use std::str::{self,*}; use std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)] macro_rules! min {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! max {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};\n\t($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};\n\t(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};\n}\n#[allow(unused_macros)] macro_rules! v {\n\t([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};\n\t([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: v!([]), pos: 0 }\n\t}\n\tfn next_line(&mut self) -> bool {\n\t\tself.buf.clear(); self.pos = 0;\n\t\tself.q.read_until(b'\\n', &mut self.buf).unwrap_or(0) > 0\n\t}\n\tfn is_ws(c: u8) -> bool {\n\t\tc == b' ' || c == b'\\r' || c == b'\\n' || c == b'\\t'\n\t}\n\tfn byte(&mut self) -> Option {\n\t\tif self.pos == self.buf.len() { if !self.next_line() { return None; } }\n\t\tself.pos += 1; Some(self.buf[self.pos - 1])\n\t}\n\tfn vb(&mut self) -> Vec {\n\t\tlet mut s = v!([8]);\n\t\tlet mut f = false;\n\t\tloop {\n\t\t\tif let Some(c) = self.byte() {\n\t\t\t\tif !Self::is_ws(c) {\n\t\t\t\t\ts.push(c);\n\t\t\t\t\tf = true;\n\t\t\t\t} else if f { break; }\n\t\t\t} else { break; }\n\t\t}\n\t\ts\n\t}\n\tfn board(&mut self, r: usize, c: Option) -> Vec> {\n\t\tlet mut res = v!([r]);\n\t\tlet c = c.unwrap_or(0);\n\t\trep!{[r]\n\t\t\tlet t = self.vb();\n\t\t\tassert!(c == 0 || t.len() == c);\n\t\t\tres.push(t);\n\t\t}\n\t\tres\n\t}\n\tfn framed_board(&mut self, r: usize, c: usize, f: u8) -> Vec> {\n\t\tlet mut res = v!([r+2]);\n\t\tres.push( v!([c+2] = f) );\n\t\trep!{[r]\n\t\t\tlet mut t = self.vb();\n\t\t\tassert!(t.len() == c);\n\t\t\tt.reserve(2);\n\t\t\tt.insert(0,f);\n\t\t\tt.push(f);\n\t\t\tres.push(t);\n\t\t}\n\t\tres.push( v!([c+2] = f) );\n\t\tres\n\t}\n\tfn s(&mut self) -> String { String::from_utf8(self.vb()).expect(\"invalid utf8\") }\n\tfn i(&mut self) -> i32 { self.p() }\n\tfn l(&mut self) -> i64 { self.p() }\n\tfn u(&mut self) -> usize { self.p() }\n\tfn f(&mut self) -> f64 { self.p() }\n\tfn vi(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vl(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vu(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn ii(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn iu(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn p(&mut self) -> T where T::Err: Debug {\n\t\tlet w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::().unwrap()\n\t}\n\tfn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n\t\t(0..n).map(|_|self.p()).collect()\n\t}\n\tfn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n\t\tself.vp(n).into_iter()\n\t}\n\tfn graph(&mut self, n: usize, m: usize) -> Vec> {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); e[a].push(b); e[b].push(a); } e\n\t}\n\tfn graph_w(&mut self, n: usize, m: usize) -> Vec> where T::Err: Debug {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); let c: T = self.p(); e[a].push((b,c)); e[b].push((a,c)); } e\n\t}\n}\n//------------------- End rusT }}}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tlet s = rin.vb();\n\tlet n = s.len();\n\tlet mut sol = 1000;\n\tfor (y,x) in vec![(b'2',b'5'), (b'5',b'0'), (b'0',b'0')] {\n\t\tl!(mut px,py = n);\n\t\tfor i in (0..n).rev() {\n\t\t\tif px == n && s[i] == x {\n\t\t\t\tpx = i;\n\t\t\t} else if py == n && s[i] == y {\n\t\t\t\tpy = i;\n\t\t\t}\n\t\t}\n\t\tif px < n && py < n {\n\t\t\tlet mut res = 2*n - 3 - px - py;\n\t\t\tif px < py {\n\t\t\t\tres += 1;\n\t\t\t}\n\t\t\tmin!(sol, res);\n\t\t}\n\t}\n\tif sol < 1000 {\n\t\twriteln!(rout, \"{}\", sol).ok();\n\t} else {\n\t\twriteln!(rout, \"-1\").ok();\n\t}\n}\n", "lang": "Rust", "bug_code_uid": "0b143132176c30a52ff2d43e81e3a6c8", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "apr_id": "0a92e1e62ab6cac13ce3bca4519dc2c7", "difficulty": 2100, "tags": ["brute force", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7356637863315004, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "pub fn main() {\n let mut input = io::Input::new();\n}\n\n#[allow(unused)]\npub mod io {\n\n const BUFFER_SIZE: usize = 8192;\n\n use std::collections::VecDeque;\n use std::str::FromStr;\n use std::io;\n use std::io::Read;\n\n type AsciiStr = Vec;\n\n pub struct Input {\n token_buffer: VecDeque,\n remaining: String,\n }\n\n impl Input {\n\n pub fn new() -> Input {\n Input {\n token_buffer: VecDeque::with_capacity(100),\n remaining: String::new(),\n }\n }\n\n pub fn next(&mut self) -> T\n where T::Err: ::std::fmt::Debug\n {\n self.fill_buffer();\n self.token_buffer.pop_front().unwrap().parse().unwrap()\n }\n\n pub fn next_ascii_string(&mut self) -> AsciiStr {\n self.fill_buffer();\n Vec::from(self.token_buffer.pop_front().unwrap().as_bytes())\n }\n\n fn fill_buffer(&mut self) {\n while self.token_buffer.is_empty() {\n let mut minibuffer = [0u8; BUFFER_SIZE];\n let size = io::stdin().read(&mut minibuffer[..]).unwrap();\n\n self.remaining += &String::from_utf8_lossy(&minibuffer[..size]);\n\n if self.remaining.trim().len() > 0 {\n for token in self.remaining.trim().split_whitespace() {\n self.token_buffer.push_back(String::from(token))\n }\n\n if size > 0 && ! self.remaining.ends_with(|c: char|char::is_ascii_whitespace(&c)) {\n self.remaining = self.token_buffer.pop_back().unwrap();\n } else {\n self.remaining.clear();\n }\n\n } else if size == 0 {\n panic!(\"EOF\");\n }\n }\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "7f86b57896894da4c2674bef3eb0e82f", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "apr_id": "b7b9a897d31615cbed99b0c85eb6ad1f", "difficulty": 2100, "tags": ["brute force", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8718781725888325, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::Read;\n#[allow(dead_code)]\nfn getline() -> String {\n let mut ret = String::new();\n std::io::stdin().read_line(&mut ret).ok().unwrap();\n ret\n}\nfn get_word() -> String {\n let mut stdin = std::io::stdin();\n let mut u8b: [u8; 1] = [0];\n loop {\n let mut buf: Vec = Vec::with_capacity(16);\n loop {\n let res = stdin.read(&mut u8b);\n if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {\n break;\n } else {\n buf.push(u8b[0]);\n }\n }\n if buf.len() >= 1 {\n let ret = String::from_utf8(buf).unwrap();\n return ret;\n }\n }\n}\n\n#[allow(dead_code)]\nfn get() -> T { get_word().parse().ok().unwrap() }\n\nconst INF: i32 = 1 << 29;\n\nfn calc(n: &[char], pat: &[char]) -> i32 {\n let len = n.len();\n let mut mi = INF;\n for i in 0 .. len {\n if n[i] == '0' { continue; }\n for j in 0 .. len {\n if i == j || pat[0] != n[j] { continue; }\n for k in 0 .. len {\n if i == k || j == k || pat[1] != n[k] { continue; }\n let mut cost = 0;\n cost += i as i32;\n let mut x = if i < j { j } else { j + 1 } as i32;\n let mut y = if i < k { k } else { k + 1 } as i32;\n cost += (y - len as i32 + 1).abs();\n if x > y { x -= 1; }\n cost += (x - len as i32 + 2).abs();\n mi = min(mi, cost);\n }\n }\n }\n return mi;\n}\n\n\nfn solve() {\n let n: Vec = get_word().chars().collect();\n let mut mi = INF;\n for pat in [['0', '0'], ['2', '5'], ['5', '0'], ['7', '5']].iter() {\n mi = min(mi, calc(&n, pat));\n }\n println!(\"{}\", if mi == INF { -1 } else { mi }); \n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "8421d9a1b44ea6f353df9a1ee1ae32f8", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "apr_id": "59c4255933156ee9603dc2d650129a76", "difficulty": 2100, "tags": ["brute force", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9655316482139127, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_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::prelude::BufRead;\n#[allow(unused_imports)]\nuse std::io::{stdin, stdout, BufReader, BufWriter, Write};\n#[allow(unused_imports)]\nuse std::mem::swap;\n#[allow(unused_imports)]\nuse std::str::FromStr;\n\nfn main() {\n let mut buf = String::new();\n stdin().read_line(&mut buf).unwrap();\n let start;\n let end;\n {\n let line = buf.trim().split(\":\").collect::>();\n start = line[0].parse::().unwrap() * 60 + line[1].parse::().unwrap();\n }\n buf.clear();\n stdin().read_line(&mut buf).unwrap();\n {\n let line = buf.trim().split(\":\").collect::>();\n end = line[0].parse::().unwrap() * 60 + line[1].parse::().unwrap(); \n }\n let mid = (start + end) / 2;\n let (h, m) = (mid / 60, mid % 60);\n println!(\"{}:{}\", h, m);\n}\n\n#[allow(dead_code)]\nfn read() -> T\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n let mut buf = String::new();\n stdin().read_line(&mut buf).unwrap();\n return buf.trim().parse().unwrap();\n}\n\n#[allow(dead_code)]\nfn read_vector() -> Vec\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n let mut buf = String::with_capacity(100);\n stdin().read_line(&mut buf).unwrap();\n return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();\n}\n\n#[allow(dead_code)]\nfn read_matrix() -> Vec>\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n use std::io::prelude::*;\n let stdin = stdin();\n let mut reader = BufReader::with_capacity(100 * 1024, stdin);\n let mut line = String::with_capacity(100);\n let mut matrix: Vec> = Vec::new();\n\n while reader.read_line(&mut line).unwrap() > 0 {\n matrix.push(\n line.trim()\n .split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect(),\n );\n line.clear();\n }\n\n return matrix;\n}\n\n#[allow(dead_code)]\nfn read_chars() -> Vec {\n let stdin = stdin();\n let mut buf = String::new();\n let _bytes = stdin.read_line(&mut buf).unwrap();\n return buf.trim().chars().collect();\n}\n", "lang": "Rust", "bug_code_uid": "a14bbf97a291222ddc4932762b84a65e", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "apr_id": "e365867b2c50bf5dad6852620a075524", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9725925925925926, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_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 mut input: usize = scan.next();\n let mut result = true;\n let mut count4 = 0usize;\n let mut first = true;\n while input > 0 {\n let digit = input % 10;\n input /= 10;\n if digit == 4 {\n count4 += 1;\n if count4 > 2 || first {\n result = false;\n break;\n }\n } else if digit == 1 {\n count4 = 0;\n } else {\n result = false;\n break;\n }\n first = false;\n }\n println!(\"{}\", if result { \"YES\" } else { \"NO\" });\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": "Rust", "bug_code_uid": "d5c63d52f7e3ed87f4544bdae563bf50", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "apr_id": "671f9ffc444d21c51e0876885969a41d", "difficulty": 900, "tags": ["brute force", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.5588697017268446, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "fn input() -> u64 {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n}\n\nfn main() {\n let n = input();\n let (mut sum_a, mut sum_b) = (0u64, 0u64);\n for i in (1..=n).rev() {\n if sum_a < sum_b {\n sum_a += i;\n } else {\n sum_b += i;\n }\n }\n // dbg!(sum_a, sum_b);\n print!(\"{}\", sum_a.max(sum_b) - sum_a.min(sum_b))\n}", "lang": "Rust", "bug_code_uid": "04b291b820bbc9b2816ff48773a16f42", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "apr_id": "445cad06163bb184c5075c8bf98a5bb6", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8089330024813896, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let n: u64 = {\n let mut read_buf = String::new();\n io::stdin().read_line(&mut read_buf).unwrap();\n read_buf.trim().parse().unwrap()\n };\n if n == 1 {\n println!(\"1\");\n } else if n == 2 {\n println!(\"1\");\n } else if n == 3 {\n println!(\"0\");\n } else if n % 2 == 0 {\n println!(\"0\");\n } else {\n println!(\"1\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "b0328f1ac5564d10ef87a7e93ffc11ec", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "apr_id": "ab976da386d8ee9a9dd9fb0e0370220d", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.968421052631579, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n use std::io;\n use std::io::prelude::*;\n\n let stdin = io::stdin();\n let mut lc = 1;\n let mut str_len = 0;\n for line in stdin.lock().lines() {\n \tmatch lc {\n \t\t1 => {\n \t\t\tstr_len = line.unwrap().parse::().unwrap();\n \t\t},\n \t\t2 => {\n \t\t\tlet s = line.unwrap();\n \t\t\t// println!(\"{:?}\", s);\n \t\t\tlet mut num = 0;\n \t\t\tlet mut chars = s.chars();\n \t\t\tlet mut prev_ch = '1';\n \t\t\tfor ch in chars {\n \t\t\t\tmatch ch {\n\t \t\t\t\t'1' => {\n\t \t\t\t\t\tnum += 1;\n\t \t\t\t\t},\n\t \t\t\t\t'0' if prev_ch == '0' => {\n\t \t\t\t\t\tprint!(\"0\");\n\t \t\t\t\t}\n\t \t\t\t\t'0' => {\n\t \t\t\t\t\tprint!(\"{}\", num);\n\t \t\t\t\t\tnum = 0;\n\t \t\t\t\t}\n\t \t\t\t\t_ => panic!(\"SOS\"),\n \t\t\t\t}\n \t\t\t\tprev_ch = ch;\n \t\t\t}\n \t\t\tif num > 0 {\n\t \t\t\tprintln!(\"{}\", num);\n \t\t\t}\n \t\t}\n \t\t_ => {\n \t\t\tpanic!(\"SOS\");\n \t\t}\n \t}\n \tlc += 1;\n }\n}\n", "lang": "Rust", "bug_code_uid": "c8153838aced75335571cfdfad3c9078", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "apr_id": "cbf76210fd3e1eee3ab9b661c1b50cc2", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8422764227642277, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\n\nfn main() {\n io::stdin().read_line(&mut String::new()).expect(\"\");\n let mut s = String::new();\n io::stdin().read_line(&mut s).expect(\"\");\n let mut ans = String::new();\n let mut cnt = 0;\n for c in s.trim().chars() {\n if c == '0' {\n if cnt > 0 {\n ans += &cnt.to_string();\n cnt = 0;\n }\n ans.push_str(\"0\");\n continue;\n }\n cnt += 1;\n }\n if cnt > 0 {\n ans += &cnt.to_string();\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "98dfa054a743d19c7539b5dcd9081aed", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "apr_id": "e58f0d4fa1883f5151ddbd02ae808313", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9925890509203921, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 is_match(pat: &str, text: &str) -> bool {\n pat.chars().zip(text.chars())\n .all(|(p, t)| p == '.' || t == p)\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 pool: Vec<_> = \"vaporeon jolteon flareon espeon umbreon leafeon glaceon and sylveon\"\n .split_ascii_whitespace()\n .collect();\n\n let _n: usize = scan.token();\n let s: String = scan.token();\n\n writeln!(out, \"{}\", pool.into_iter().filter(|t| is_match(&s, t)).next().unwrap())?;\n\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "34ae542828ca686229bcf79b58e33644", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "apr_id": "070e9812cebf6b34d75929eb10ec8251", "difficulty": 1000, "tags": ["strings", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9766454352441614, "equal_cnt": 11, "replace_cnt": 8, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 10, "bug_source_code": "use std::io::{self, Read};\nuse std::str::SplitWhitespace;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_to_string(&mut buf).expect(\"Error\");\n let lines = buf.lines();\n let mut ship1 = Ship { w: 0, h: 0 };\n let mut ship2 = Ship { w: 0, h: 0 };\n for line in lines {\n let st = &mut line.split_whitespace();\n ship1.set_wh(get_value(st), get_value(st));\n ship2.set_wh(get_value(st), get_value(st));\n }\n println!(\"{}\",ship1_area(&ship1, &ship2));\n println!(\"{}\",ship2_area(&ship1, &ship2));\n\n println!(\n \"{}\",\n ship1_area(&ship1, &ship2) + ship2_area(&ship1, &ship2)\n )\n}\n\nfn ship1_area(ship1: &Ship, ship2: &Ship) -> u8 {\n let mut a = ship1.get_full_area() - (ship2.get_w() + 3);\n if ship2.get_w() >= ship1.get_w() {\n a -= 1;\n }\n a\n}\n\nfn ship2_area(ship1: &Ship, ship2: &Ship) -> u8 {\n if ship2.get_w() < ship1.get_w() {\n ship2.get_full_area() - (ship2.get_w()+1)\n } else {\n ship2.get_full_area() - ship1.get_w()\n }\n}\n\nfn get_value(ws: &mut SplitWhitespace) -> u8 {\n ws.next().unwrap().parse::().unwrap()\n}\n\nstruct Ship {\n w: u8,\n h: u8,\n}\n\nimpl Ship {\n fn set_wh(&mut self, w: u8, h: u8) {\n self.h = h;\n self.w = w;\n }\n\n fn get_w(&self) -> u8 {\n self.w\n }\n\n fn get_full_area(&self) -> u8 {\n (self.w * 2 + self.h * 2) + 4\n }\n}\n", "lang": "Rust", "bug_code_uid": "b8b2325775d0fb796082947bc6c8aea7", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "apr_id": "7c81c452d6ea789f9abeee33a2fdaa1b", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9780918727915194, "equal_cnt": 9, "replace_cnt": 8, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 8, "bug_source_code": "use std::io::{self, Read};\nuse std::str::SplitWhitespace;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_to_string(&mut buf).expect(\"Error\");\n let lines = buf.lines();\n let mut ship1 = Ship { w: 0, h: 0 };\n let mut ship2 = Ship { w: 0, h: 0 };\n for line in lines {\n let st = &mut line.split_whitespace();\n ship1.set_wh(get_value(st), get_value(st));\n ship2.set_wh(get_value(st), get_value(st));\n }\n //println!(\"{}\",ship1_area(&ship1, &ship2));\n //println!(\"{}\",ship2_area(&ship1, &ship2));\n\n println!(\n \"{}\",\n ship1_area(&ship1, &ship2) + ship2_area(&ship1, &ship2)\n )\n}\n\nfn ship1_area(ship1: &Ship, ship2: &Ship) -> u8 {\n let mut a = ship1.get_full_area() - (ship2.get_w() + 3);\n if ship2.get_w() >= ship1.get_w() {\n a -= 1;\n }\n a\n}\n\nfn ship2_area(ship1: &Ship, ship2: &Ship) -> u8 {\n if ship2.get_w() < ship1.get_w() {\n ship2.get_full_area() - (ship2.get_w()+1)\n } else {\n ship2.get_full_area() - ship1.get_w()\n }\n}\n\nfn get_value(ws: &mut SplitWhitespace) -> u8 {\n ws.next().unwrap().parse::().unwrap()\n}\n\nstruct Ship {\n w: u8,\n h: u8,\n}\n\nimpl Ship {\n fn set_wh(&mut self, w: u8, h: u8) {\n self.h = h;\n self.w = w;\n }\n\n fn get_w(&self) -> u8 {\n self.w\n }\n\n fn get_full_area(&self) -> u8 {\n (self.w * 2 + self.h * 2) + 4\n }\n}\n", "lang": "Rust", "bug_code_uid": "24ba725cd5c7e61287cf4c931252e9c4", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "apr_id": "7c81c452d6ea789f9abeee33a2fdaa1b", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9993698802772527, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn f(n: i64, l: i64, r: i64, t: i32, w: i32) -> i64 {\n let mut result = 0;\n if(n < r) {\n if(n >= l) {\n result += 1;\n }\n if(w == 0) {\n result += f(2*n, l, r, t+1, w);\n }\n result += f(3*n, l , r, t, w+1);\n }\n return result;\n}\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nfn main() {\n let (a, b) = parse_line!(i64, i64);\n \n\tlet mut cnt = f(1, a, b, 0, 0);\n\tprintln!(\"{}\", cnt);\n}", "lang": "Rust", "bug_code_uid": "b1cf82ba5851b0b45ebd46dd06d374d9", "src_uid": "05fac54ed2064b46338bb18f897a4411", "apr_id": "68397d82ccf6f53067b0b13e979c4706", "difficulty": 1300, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9846491228070176, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "#[allow(unused_imports)]\nuse std::io;\nuse std::cmp::{min, max};\npub struct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Scanner {\n Scanner {\n reader: reader,\n buffer: Vec::new(),\n }\n }\n\n /// Use \"turbofish\" syntax next::() to select data type of next token.\n pub fn next(&mut self) -> T\n where\n T::Err: ::std::fmt::Debug,\n {\n if let Some(front) = self.buffer.pop() {\n front.parse::().expect(&front)\n } else {\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Line not read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n self.next()\n }\n }\n\n pub fn next_vec(&mut self, len: usize) -> Vec\n where\n T::Err: ::std::fmt::Debug,\n {\n (0..len).map(|_| self.next::()).collect::>()\n }\n}\n\nfn main1() {\n let stdin = io::stdin();\n let mut input = Scanner::new(stdin.lock());\n let d = input.next_vec::(3);\n println!(\"{}\", min(d[0] + d[1] + d[2], 2 * (d[0] + d[1])))\n}\n\nfn main() {\n std::thread::Builder::new().stack_size(50 << 20)\n .spawn(main1).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "7a8d3106c903f92708b13c13839af7fa", "src_uid": "26cd7954a21866dbb2824d725473673e", "apr_id": "3979b82e149b46d10ab94418d15efd1b", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9284274193548387, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let d1: usize = scan.next();\n let d2: usize = scan.next();\n let d3: usize = scan.next();\n let result = (d1+d2+d3).min((d1+d2)*2).min(d1*2+d3*2);\n println!(\"{}\", result);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "5c2a0b47fb63f96570c9a7e4026d6da6", "src_uid": "26cd7954a21866dbb2824d725473673e", "apr_id": "d4aadb455fd6287a8d093e251fad2f05", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9071487263763353, "equal_cnt": 15, "replace_cnt": 7, "delete_cnt": 4, "insert_cnt": 4, "fix_ops_cnt": 15, "bug_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": "Rust", "bug_code_uid": "ff1aa20fa2430d55b90edc76969b9b55", "src_uid": "e8148140e61baffd0878376ac5f3857c", "apr_id": "4f828fcc6b9dc15a564f1cdd426345bd", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9914630556373271, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::cmp;\n\nfn main() {\n \"abc\".split_whitespace();\n let mut input = String::new();\n io::stdin().read_line(&mut input);\n let mut iter = input.split_whitespace();\n let distance: i64 = iter.next().expect(\"distance expected\").parse().expect(\"integer distance expected\");\n let km_per_stop: i64 = iter.next().expect(\"km_per_stop expected\").parse().expect(\"integer km_per_stop expected\");\n let car_km_time: i64 = iter.next().expect(\"car_km_time expected\").parse().expect(\"car_km_time distance expected\");\n let walk_km_time: i64 = iter.next().expect(\"walk_km_time expected\").parse().expect(\"walk_km_time distance expected\");\n let repair_time: i64 = iter.next().expect(\"repair_time expected\").parse().expect(\"repair_time distance expected\");\n\n let trip_time;\n let car_cost : i64 = car_km_time * km_per_stop - walk_km_time * km_per_stop + repair_time;\n if car_cost >= 0 {\n let car_dist = cmp::min(km_per_stop, distance);\n let walk_dist = distance - car_dist;\n trip_time = car_dist * car_km_time + walk_dist * walk_km_time;\n } else {\n let full_stops = distance / km_per_stop;\n let distance_cost = (full_stops * km_per_stop) * car_km_time;\n let repair_cost = (full_stops - 1) * repair_time;\n let full_stops_cost = distance_cost + repair_cost;\n\n let remaining_dist = distance % km_per_stop;\n let remaining_walk = remaining_dist * walk_km_time;\n let remaining_car = remaining_dist * car_km_time + repair_time;\n let remaining_cost = cmp::min(remaining_walk, remaining_car);\n\n trip_time = full_stops_cost + remaining_cost;\n }\n println!(\"{}\", trip_time);\n\n}\n", "lang": "Rust", "bug_code_uid": "2759fa8eb1dff046a7814f0358d4b28d", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "apr_id": "ffa199394471a444b8f6dd746de7b855", "difficulty": 1900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9963768115942029, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"input: read line failed\");\n let vec = input.trim().split_whitespace().map(|item| {\n item.parse::().expect(\"item: parse to i32 failed\")\n }).collect::>();\n\n let (mut width, mut height, mut rings) = (vec[0], vec[1], vec[2]);\n\n let mut amount = i32::default();\n\n while rings > 0 {\n amount += (width + height) * 2 - 4;\n width -= 2;\n height -= 2;\n rings -= 1;\n }\n\n println!(\"{}\", amount);\n}", "lang": "Rust", "bug_code_uid": "01b002035c184df4c737b3aa03a0ee13", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "apr_id": "83f43ea479c0c5a30eac7c806647de20", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9974554707379135, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rust\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::*;\n#[allow(unused_imports)] use std::collections::*;\n\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\n#[allow(dead_code)]\nfn build_counting_hashmap(i: T) -> HashMap\n where T: Iterator {\n let mut m = HashMap::new();\n for k in i {\n let n = 1 + if let Some(&n) = m.get(&k) { n } else { 0 };\n m.insert(k, n);\n }\n m\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let a = input.i();\n let b = input.i();\n let c = input.i();\n let d = b - a;\n if d == 0 || (d % c == 0 && d / c > 0) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "cbe6779e4ffd93ebe4ba5d925cffb43a", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "apr_id": "2943632c263306b3b64c87f16edb162b", "difficulty": 1100, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7480519480519481, "equal_cnt": 17, "replace_cnt": 12, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 16, "bug_source_code": "fn check_row(v: Vec) {\n let mut count = 0;\n let mut hole = false;\n for c in v {\n match (c, hole) {\n (0, false) => {if count != 0 { count += 1; hole = true }},\n (0, true) => {count = 0; hole = false},\n (1, _) => count += 1,\n (2, _) => count = 0,\n (_, _) => panic!(\"Invalid grid value\"),\n }\n if count == 5 {\n println!(\"YES\");\n std::process::exit(0);\n }\n }\n}\n\nfn main() {\n let mut grid: Vec = Vec::with_capacity(100);\n\n for _ in 0..10 {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n for c in input.trim().chars() {\n match c {\n '.' => grid.push(0),\n 'X' => grid.push(1),\n 'O' => grid.push(2),\n _ => panic!(\"Invalid character\"),\n }\n }\n }\n\n for i in 0..10 {\n let it = (0..100).filter_map(|k| if k / 10 == i {Some(grid[k])} else {None});\n check_row(it.collect());\n\n let it = (0..100).filter_map(|k| if k % 10 == i {Some(grid[k])} else {None});\n check_row(it.collect());\n }\n\n for i in 0..6 {\n check_row((i..10).zip(0..(10 - i)).map(|(i, j)| grid[10 * i + j]).collect());\n check_row((i..10).zip(0..(10 - i)).map(|(i, j)| grid[10 * j + i]).collect());\n check_row((i..10).zip((i..10).rev()).map(|(i, j)| grid[10 * j + i]).collect());\n }\n\n for i in 4..10 {\n check_row((0..(i + 1)).rev().zip(0..(i + 1)).map(|(i, j)| grid[10 * i + j]).collect());\n }\n\n println!(\"NO\");\n}\n", "lang": "Rust", "bug_code_uid": "97857db079c5f18193b63208f28071fe", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "apr_id": "2796263cc60576d89a31b2304239a3d4", "difficulty": 1600, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.26717144402379667, "equal_cnt": 15, "replace_cnt": 9, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 14, "bug_source_code": "use std::io;\n\nfn main() -> io::Result<()> {\n let coins = [100, 20, 10, 5, 1];\n let mut input = String::new();\n let mut ans = 0;\n let mut dollars;\n\n loop {\n ans = 0;\n\n if io::stdin().read_line(&mut input)? == 0 {\n break Ok(());\n }\n\n dollars = input.trim().parse::().unwrap();\n input.clear();\n\n for coin in &coins {\n ans += dollars / coin;\n dollars %= coin;\n\n if dollars == 0 {\n break;\n }\n }\n\n println!(\"{}\", ans);\n }\n}\n", "lang": "Rust", "bug_code_uid": "38821457bd119ef679e4ad8be6ae9f3c", "src_uid": "8aef4947322438664bd8610632fe0947", "apr_id": "3eea098ae6e2191b1423ad776c5bb587", "difficulty": 800, "tags": ["dp", "brute force"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5640822784810127, "equal_cnt": 24, "replace_cnt": 14, "delete_cnt": 4, "insert_cnt": 5, "fix_ops_cnt": 23, "bug_source_code": "use std::io;\n\nfn main() -> io::Result<()> {\n let mut input = String::new();\n let mut table = Vec::new();\n let mut ans = 0;\n let mut total = 0;\n let mut length: usize = 0;\n\n while io::stdin().read_line(&mut input)? != 0 {\n for chr in input.chars() {\n match chr {\n 'Q' => {\n if length == 0 {\n table.push(0);\n length += 1;\n continue;\n }\n ans += total;\n let mut t = total;\n for num in &table {\n t -= num;\n ans += t;\n }\n if table[length - 1] != 0 {\n table.push(0);\n length += 1;\n }\n }\n 'A' => {\n if length != 0 {\n table[length - 1] += 1;\n total += 1;\n }\n }\n _ => (),\n }\n }\n\n println!(\"{}\", ans);\n input.clear();\n table.clear();\n ans = 0;\n total = 0;\n length = 0;\n }\n\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "b19274fde245496de66933faefc45f83", "src_uid": "8aef4947322438664bd8610632fe0947", "apr_id": "3eea098ae6e2191b1423ad776c5bb587", "difficulty": 800, "tags": ["dp", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9748942172073343, "equal_cnt": 12, "replace_cnt": 9, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 12, "bug_source_code": "#![allow(unused_variables)]\n#![allow(unused_must_use)]\nuse std::io::{self, prelude::*};\nuse std::cmp::min;\n\n\nfn gcd(a: i32, b: i32) -> i32 {\n if a == 0 {\n return b;\n }\n\n if b == 0 {\n return a;\n }\n\n if a == b {\n return a;\n }\n\n if a>b {\n return gcd(a-b, b);\n }\n\n return gcd(a, b-a)\n\n}\nfn solve(mut input: FastInput, mut w: W) {\n let a: i32 = input.token();\n let b: i32 = input.token();\n let mut x: i32 = input.token();\n let mut y: i32 = input.token();\n let g = gcd(x,y);\n x = x / g;\n y = y / g;\n write!(w, \"{}\\n\", min(a/x, b/y));\n\n \n}\n \n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let input = FastInput::from(stdin.lock());\n let output = io::BufWriter::new(stdout.lock());\n solve(input, output)\n}\n\ntrait TokenStream {\n fn token(&mut self) -> T;\n}\n \nstruct FastInput {\n stdin: R,\n pos: usize,\n}\n \nimpl From for FastInput {\n fn from(r: R) -> Self {\n FastInput { stdin: r, pos: 0 }\n }\n}\n \nimpl TokenStream for FastInput {\n fn token(&mut self) -> u8 {\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n while self.pos < buf.len() {\n self.pos += 1;\n if buf[self.pos - 1] > 32 {\n return buf[self.pos - 1];\n }\n }\n if self.pos == 0 {\n return 0;\n }\n } else {\n return 0;\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nimpl TokenStream> for FastInput {\n fn token(&mut self) -> Vec {\n let mut ans = Vec::new();\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans.push(buf[self.pos]);\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nmacro_rules! impl_token_stream {\n ($($t:ident),+) => {$(\n impl TokenStream<$t> for FastInput {\n fn token(&mut self) -> $t {\n let mut ans = 0;\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans = ans * 10 + (buf[self.pos] - b'0') as $t;\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n }\n )+}\n}\n\n\nimpl_token_stream!(i32);", "lang": "Rust", "bug_code_uid": "d536b81fb6b0ffc3c7778964c69fe567", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "apr_id": "677f00fc9d1808440ead775d6bda5ef3", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9743155517922665, "equal_cnt": 13, "replace_cnt": 9, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 13, "bug_source_code": "#![allow(unused_variables)]\n#![allow(unused_must_use)]\nuse std::io::{self, prelude::*};\nuse std::cmp::min;\n\n\nfn gcd(a: i32, b: i32) -> i32 {\n if a == 0 {\n return b;\n }\n\n if b == 0 {\n return a;\n }\n\n if a == b {\n return a;\n }\n\n if a>b {\n return gcd(a-b, b);\n }\n\n return gcd(a, b-a)\n\n}\nfn solve(mut input: FastInput, mut w: W) {\n let a: i32 = input.token();\n let b: i32 = input.token();\n let mut x: i32 = input.token();\n let mut y: i32 = input.token();\n g = gcd(x,y);\n x = x / g;\n y = y / g;\n write!(w, \"{}\\n\", min(a/x, b/y));\n\n \n}\n \n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let input = FastInput::from(stdin.lock());\n let output = io::BufWriter::new(stdout.lock());\n solve(input, output)\n}\n\ntrait TokenStream {\n fn token(&mut self) -> T;\n}\n \nstruct FastInput {\n stdin: R,\n pos: usize,\n}\n \nimpl From for FastInput {\n fn from(r: R) -> Self {\n FastInput { stdin: r, pos: 0 }\n }\n}\n \nimpl TokenStream for FastInput {\n fn token(&mut self) -> u8 {\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n while self.pos < buf.len() {\n self.pos += 1;\n if buf[self.pos - 1] > 32 {\n return buf[self.pos - 1];\n }\n }\n if self.pos == 0 {\n return 0;\n }\n } else {\n return 0;\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nimpl TokenStream> for FastInput {\n fn token(&mut self) -> Vec {\n let mut ans = Vec::new();\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans.push(buf[self.pos]);\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nmacro_rules! impl_token_stream {\n ($($t:ident),+) => {$(\n impl TokenStream<$t> for FastInput {\n fn token(&mut self) -> $t {\n let mut ans = 0;\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans = ans * 10 + (buf[self.pos] - b'0') as $t;\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n }\n )+}\n}\n\n\nimpl_token_stream!(i32);", "lang": "Rust", "bug_code_uid": "cf4f44cc8c683855b5e7d0adb2ffe315", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "apr_id": "677f00fc9d1808440ead775d6bda5ef3", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.982228490832158, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "#![allow(unused_variables)]\n#![allow(unused_must_use)]\nuse std::io::{self, prelude::*};\nuse std::cmp::min;\n\n\nfn gcd(a: i64, b: i64) -> i64 {\n if a == 0 {\n return b;\n }\n\n if b == 0 {\n return a;\n }\n\n if a == b {\n return a;\n }\n\n if a>b {\n return gcd(a-b, b);\n }\n\n return gcd(a, b-a)\n\n}\nfn solve(mut input: FastInput, mut w: W) {\n let a: i64 = input.token();\n let b: i64 = input.token();\n let mut x: i64 = input.token();\n let mut y: i64 = input.token();\n let g = gcd(x,y);\n x = x / g;\n y = y / g;\n write!(w, \"{}\\n\", min(a/x, b/y));\n\n \n}\n \n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let input = FastInput::from(stdin.lock());\n let output = io::BufWriter::new(stdout.lock());\n solve(input, output)\n}\n\ntrait TokenStream {\n fn token(&mut self) -> T;\n}\n \nstruct FastInput {\n stdin: R,\n pos: usize,\n}\n \nimpl From for FastInput {\n fn from(r: R) -> Self {\n FastInput { stdin: r, pos: 0 }\n }\n}\n \nimpl TokenStream for FastInput {\n fn token(&mut self) -> u8 {\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n while self.pos < buf.len() {\n self.pos += 1;\n if buf[self.pos - 1] > 32 {\n return buf[self.pos - 1];\n }\n }\n if self.pos == 0 {\n return 0;\n }\n } else {\n return 0;\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nimpl TokenStream> for FastInput {\n fn token(&mut self) -> Vec {\n let mut ans = Vec::new();\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans.push(buf[self.pos]);\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n}\n \nmacro_rules! impl_token_stream {\n ($($t:ident),+) => {$(\n impl TokenStream<$t> for FastInput {\n fn token(&mut self) -> $t {\n let mut ans = 0;\n let mut parse_token = false;\n loop {\n if let Ok(buf) = self.stdin.fill_buf() {\n if !parse_token {\n while self.pos < buf.len() && buf[self.pos] <= 32 {\n self.pos += 1;\n }\n }\n while self.pos < buf.len() && buf[self.pos] > 32 {\n parse_token = true;\n ans = ans * 10 + (buf[self.pos] - b'0') as $t;\n self.pos += 1;\n }\n if self.pos != buf.len() || self.pos == 0 {\n return ans;\n }\n }\n self.stdin.consume(self.pos);\n self.pos = 0;\n }\n }\n }\n )+}\n}\n\n\nimpl_token_stream!(i64);", "lang": "Rust", "bug_code_uid": "519891a7e233b29cc3d15f4f45520706", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "apr_id": "677f00fc9d1808440ead775d6bda5ef3", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9980113201774514, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_parens)]\n#![allow(unused_imports)]\n#![allow(non_upper_case_globals)]\n#![allow(non_snake_case)]\n#![allow(unused_mut)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\n#[allow(unused_macros)]\nmacro_rules! invec {\n ( $ t : ty ) => {{\n let mut s = String::new();\n match std::io::stdin().read_line(&mut s) {\n Ok(0) => Vec::<$t>::new(),\n Ok(n) => s\n .trim()\n .split_whitespace()\n .map(|s| s.parse::<$t>().unwrap())\n .collect::>(),\n Err(_) => Vec::<$t>::new(),\n }\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n ($t:ty ;; $n:expr) => {\n (0..$n).map(|_| get!($t ;;)).collect::>()\n };\n}\n\n#[allow(unused_macros)]\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 mut 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\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($next:expr, [$t:tt]) => {\n {\n let len = read_value!($next, usize);\n (0..len).map(|_| read_value!($next, $t)).collect::>()\n }\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\n#[cfg(debug_assertions)]\nmacro_rules! mydbg {\n //($arg:expr) => (dbg!($arg))\n //($arg:expr) => (println!(\"{:?}\",$arg));\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n#[cfg(not(debug_assertions))]\nmacro_rules! mydbg {\n ($($arg:expr),*) => {};\n}\n\nmacro_rules! echo {\n ($($a:expr),*) => {\n $(println!(\"{}\",$a))*\n }\n}\n\nuse std::cmp::*;\nuse std::collections::*;\nuse std::ops::{Add, Div, Mul, Sub};\n\n#[allow(dead_code)]\nstatic INF_I64: i64 = i64::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_I32: i32 = i32::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_USIZE: usize = usize::max_value() / 2;\n#[allow(dead_code)]\nstatic M_O_D: usize = 1000000007;\n#[allow(dead_code)]\nstatic PAI: f64 = 3.1415926535897932;\n\ntrait IteratorExt: Iterator {\n fn toVec(self) -> Vec;\n}\n\nimpl IteratorExt for T {\n fn toVec(self) -> Vec {\n self.collect()\n }\n}\n\ntrait CharExt {\n fn toNum(&self) -> usize;\n fn toAlphabetIndex(&self) -> usize;\n fn toNumIndex(&self) -> usize;\n}\nimpl CharExt for char {\n fn toNum(&self) -> usize {\n return *self as usize;\n }\n fn toAlphabetIndex(&self) -> usize {\n return self.toNum() - 'a' as usize;\n }\n fn toNumIndex(&self) -> usize {\n return self.toNum() - '0' as usize;\n }\n}\n\ntrait VectorExt {\n fn joinToString(&self, s: &str) -> String;\n}\nimpl VectorExt for Vec {\n fn joinToString(&self, s: &str) -> String {\n return self\n .iter()\n .map(|x| x.to_string())\n .collect::>()\n .join(s);\n }\n}\n\ntrait StringExt {\n fn get_reverse(&self) -> String;\n}\nimpl StringExt for String {\n fn get_reverse(&self) -> String {\n self.chars().rev().collect::()\n }\n}\n\ntrait UsizeExt {\n fn pow(&self, n: usize) -> usize;\n}\nimpl UsizeExt for usize {\n fn pow(&self, n: usize) -> usize {\n return ((*self as u64).pow(n as u32)) as usize;\n }\n}\n\nfn main() {\n let s = get!(String).chars().toVec();\n let s2 = get!(String).chars().toVec();\n mydbg!(s, s2);\n let mut a = true;\n let mut b = true;\n\n let mut h = vec![0; 26];\n let mut h2 = vec![0; 26];\n\n let mut cur = 0;\n for &c in &s2 {\n a = false;\n while cur < s.len() {\n if s[cur] == c {\n a = true;\n break;\n }\n cur += 1;\n }\n }\n\n if a {\n echo!(\"automaton\");\n return;\n }\n a = true;\n if s.len() <= s2.len() {\n a = false;\n }\n\n for &c in &s {\n let c = c as usize - 'a' as usize;\n h[c] += 1;\n }\n for &c in &s2 {\n let c = c as usize - 'a' as usize;\n h2[c] += 1;\n }\n\n for i in 0..26 {\n if h[i] != h2[i] {\n b = false;\n }\n }\n\n if b {\n echo!(\"array\");\n return;\n }\n b = true;\n for i in 0..26 {\n if h[i] < h2[i] {\n b = false;\n }\n }\n if a && b {\n echo!(\"both\");\n return;\n }\n echo!(\"need tree\");\n}\n", "lang": "Rust", "bug_code_uid": "85adf4a2bc8b6ce90fded2ef260f0aec", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "apr_id": "ef7d8c7c6280941138fe884118a39728", "difficulty": 1400, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.991672975018925, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "macro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let length = readln!(usize);\n\n if length % 2 == 0 {\n println!(\"{}\", length);\n } else {\n println!(\"0\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "2227cb4d7b635d96ad29f966d2894669", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "apr_id": "698b8b6d6d97997eb592ffc41086c007", "difficulty": 1000, "tags": ["dp", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9939485627836612, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nfn get_nums() -> (usize, usize, usize, usize) {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input).expect(\"\");\n\n let v = input\n .trim()\n .split_whitespace()\n .map(|s| usize::from_str(s).unwrap())\n .collect::>();\n\n (v[0], v[1], v[2], v[3])\n}\n\nfn main() {\n let (a, b, c, d) = get_nums();\n\n let misha = std::cmp::max(3 * a / 10, a / 250 * c);\n let vasya = std::cmp::max(3 * b / 10, b / 250 * d);\n\n if misha > vasya {\n println!(\"Misha\");\n } else if misha < vasya {\n println!(\"Vasya\");\n } else {\n println!(\"Tie\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "e5e34c5fe9c21533fbe3a4ec75c5f6f8", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "apr_id": "d661e089a1b38ffae48f2778a617e983", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9994086339444116, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "// ---------- begin input macro ----------\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n// ---------- end input macro ----------\n\nfn fact(n: u64) -> u64 {\n (1..=n).product()\n}\n\nfn run() {\n input! {\n n: u64,\n }\n let mut ans = fact(n) / fact(n / 2) / fact(n / 2) / 2;\n if n / 2 > 3 {\n ans *= (fact(n / 2 - 1)).pow(2);\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "6846da05aaecc4cdece8cbb6f6e1fea5", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "apr_id": "45cdd3f4e0a521b3bac55c138d801fa4", "difficulty": 1300, "tags": ["math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9951768488745981, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "//! https://codeforces.com/problemset/problem/630/I\n//! To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes.\n//! The parking lot before the office consists of one line of (2n - 2) parking spaces. Unfortunately the total number of cars is greater than the parking lot capacity. Furthermore even amount of cars of each make is greater than the amount of parking spaces! That's why there are no free spaces on the parking lot ever.\n//! Looking on the straight line of cars the company CEO thought that parking lot would be more beautiful if it contained exactly n successive cars of the same make. Help the CEO determine the number of ways to fill the parking lot this way.\nuse std::io;\n\nfn main() {\n let mut inp = String::new();\n io::stdin().read_line(&mut inp).unwrap();\n let inp: u64 = inp.trim().parse().unwrap();\n\n let ans: u64 = (inp -2 ) * 6 * binexp(4, inp - 2);\n println!(\"{}\", ans);\n}\n\nfn binexp(mut x: u64, mut y: u64) -> u64 {\n let mut res = 1;\n while y != 0 {\n if y & 1 == 1 {\n res *= x;\n }\n x*=x;\n y>>=1;\n }\n res\n}\n\n\n\n\n\n\n\n\n", "lang": "Rust", "bug_code_uid": "2b9c0aa28013038f03b15d043067997f", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "apr_id": "089da582488fee2d6f69a54791d91158", "difficulty": 1700, "tags": ["math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9888765294771968, "equal_cnt": 11, "replace_cnt": 10, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\n\nfn steps(dist: i32, counter: &mut i32) -> &i32 {\n match dist {\n dist if dist <= 0 => (),\n dist if dist % 5 == 0 => {\n *counter += 1;\n steps(dist - 5, counter);\n }\n dist if dist % 4 == 0 => {\n *counter += 1;\n steps(dist - 4, counter);\n }\n dist if dist % 3 == 0 => {\n *counter += 1;\n steps(dist - 3, counter);\n }\n dist if dist % 2 == 0 => {\n *counter += 1;\n steps(dist - 2, counter);\n }\n dist if dist % 1 == 0 => {\n *counter += 1;\n steps(dist - 1, counter);\n }\n _ => (),\n }\n counter\n}\n\nfn main() {\n let mut buffer = String::new();\n let _ = io::stdin().read_line(&mut buffer);\n\n let mut counter = 0;\n\n println!(\"{}\", steps(buffer.trim().parse().unwrap(), &mut counter));\n}\n", "lang": "Rust", "bug_code_uid": "14a527803a1d2c98e672a8e5ff72af3e", "src_uid": "4b3d65b1b593829e92c852be213922b6", "apr_id": "d3ed6caa680fd99f2d84e3c623d41ae3", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9505582137161085, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{BufReader, BufRead};\n\nfn main() -> Result<(), Box> {\n let distance = BufReader::new(std::io::stdin())\n .lines()\n .map(Result::unwrap)\n .next()\n .unwrap()\n .parse::()?;\n\n println!(\"{}\", distance / 5 + 1);\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "4840e4efa34bedce947e6924932a1fbd", "src_uid": "4b3d65b1b593829e92c852be213922b6", "apr_id": "218f82b2ab158c2f441dda63e2f0efda", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.4457831325301205, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "fn main() {\n let mut text = String::new();\n std::io::stdin().read_line(&mut text).expect(\"\");\n println!(\"{}\", resolver(text.trim().parse().expect(\"msg: &str\"), 0));\n}\n\nfn resolver(value: usize, step: usize) -> usize {\n if value == 1 {\n step + 1\n } else if value % 5 == 0 {\n (value / 5) + step\n } else if value % 4 == 0 {\n (value / 4) + step\n } else if value % 3 == 0 {\n (value / 3) + step\n } else if value % 2 == 0 {\n (value / 2) + step\n } else {\n resolver(value - 5, step + 1)\n }\n}\n", "lang": "Rust", "bug_code_uid": "b5b95201b382bfa910540d05d25774cd", "src_uid": "4b3d65b1b593829e92c852be213922b6", "apr_id": "ec511f408493739ac3566311aebbc512", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9245505719992737, "equal_cnt": 18, "replace_cnt": 8, "delete_cnt": 2, "insert_cnt": 7, "fix_ops_cnt": 17, "bug_source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 1_000_000_007;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\nimpl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n\nimpl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n}\n\nimpl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt((val % MOD as usize) as u32)\n }\n}\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n assert!(self.0 > 0);\n self.pow(MOD - 2)\n }\n}\n// ---------- end ModInt ----------\n// ---------- begin Precalc ----------\n#[allow(dead_code)]\nstruct Precalc {\n inv: Vec,\n fact: Vec,\n ifact: Vec,\n}\n\n#[allow(dead_code)]\nimpl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n inv[i] = -inv[MOD as usize % i] * ModInt(MOD / i as u32);\n fact[i] = fact[i - 1] * ModInt(i as u32);\n ifact[i] = ifact[i - 1] * inv[i];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n}\n// ---------- end Precalc ----------\n// ---------- begin Aho-Corasick ----------\nconst F: usize = 2;\n\nfn convert(s: Vec) -> Vec {\n let mut a = Vec::with_capacity(s.len());\n for c in s {\n let k = c.to_digit(10).unwrap() as usize;\n a.push(k);\n }\n a\n}\n\nstruct ACTrieNode {\n elem: bool,\n fail: usize,\n depth: usize,\n next: [usize; F],\n}\n\nimpl ACTrieNode {\n fn new() -> ACTrieNode {\n ACTrieNode {\n elem: false,\n fail: 0,\n depth: 0,\n next: [0; F],\n }\n }\n}\n\nstruct AhoCorasick {\n node: Vec,\n}\n\n#[allow(dead_code)]\nimpl AhoCorasick {\n fn new() -> Self {\n let root = ACTrieNode::new();\n AhoCorasick {\n node: vec![root],\n }\n }\n fn insert(&mut self, s: &Vec) -> usize {\n let node = &mut self.node;\n let mut v = 0;\n for &k in s {\n if node[v].next[k] == 0 {\n node[v].next[k] = node.len();\n let mut t = ACTrieNode::new();\n t.depth = node[v].depth + 1;\n node.push(t);\n }\n v = node[v].next[k];\n }\n node[v].elem = true;\n v\n }\n fn build(&mut self) {\n let mut q = std::collections::VecDeque::new();\n let node = &mut self.node;\n for i in 0..F {\n if node[0].next[i] != 0 {\n q.push_back(node[0].next[i]);\n }\n }\n while let Some(v) = q.pop_front() {\n for i in 0..F {\n let u = node[v].next[i];\n if u == 0 {\n continue;\n }\n let mut fail = node[v].fail;\n while fail > 0 && node[fail].next[i] == 0 {\n fail = node[fail].fail;\n }\n let f = node[fail].next[i];\n node[u].fail = f;\n q.push_back(u);\n }\n }\n }\n fn next(&self, v: usize, k: usize) -> usize {\n self.node[v].next[k]\n }\n fn trans(&self, mut v: usize, k: usize) -> usize {\n let node = &self.node;\n while v > 0 && node[v].next[k] == 0 {\n v = node[v].fail;\n }\n node[v].next[k]\n }\n fn elem(&self, k: usize) -> bool {\n self.node[k].elem\n }\n fn fail(&self, k: usize) -> usize {\n self.node[k].fail\n }\n fn depth(&self, k: usize) -> usize {\n self.node[k].depth\n }\n fn get_size(&self) -> usize {\n self.node.len()\n }\n}\n// ---------- end Aho-Corasick ----------\n// ---------- begin Matrix ----------\n#[allow(dead_code)]\nmod matrix {\n use std::ops::{Add, Mul};\n pub trait SemiRing: Add + Mul + Copy {\n fn zero() -> Self;\n fn one() -> Self;\n }\n pub const SIZE: usize = 202;\n #[derive(Clone)]\n pub struct SquareMatrix {\n buf: [[T; SIZE]; SIZE],\n }\n impl SquareMatrix {\n pub fn zero() -> Self {\n let z = T::zero();\n SquareMatrix {\n buf: [[z; SIZE]; SIZE],\n }\n }\n pub fn identity() -> Self {\n let mut m = Self::zero();\n for i in 0..SIZE {\n m.buf[i][i] = T::one();\n }\n m\n }\n pub fn set_at(&mut self, i: usize, j: usize, v: T) {\n self.buf[i][j] = v;\n }\n pub fn get_at(&self, i: usize, j: usize) -> T {\n self.buf[i][j]\n }\n pub fn matmul(&self, rhs: &Self) -> Self {\n let mut res = Self::zero();\n for (x, a) in res.buf.iter_mut().zip(self.buf.iter()) {\n for (a, b) in a.iter().zip(rhs.buf.iter()) {\n for (x, b) in x.iter_mut().zip(b.iter()) {\n *x = *x + *a * *b;\n }\n }\n }\n res\n }\n pub fn matadd(&self, rhs: &Self) -> Self {\n let mut c = Self::zero();\n for (c, (a, b)) in c.buf.iter_mut().zip(self.buf.iter().zip(rhs.buf.iter())) {\n for (c, (a, b)) in c.iter_mut().zip(a.iter().zip(b.iter())) {\n *c = *a + *b;\n }\n }\n c\n }\n pub fn matpow(&self, mut n: usize) -> Self {\n let mut t = Self::identity();\n let mut s = self.clone();\n while n > 0 {\n if n & 1 == 1 {\n t = t.matmul(&s);\n }\n s = s.matmul(&s);\n n >>= 1;\n }\n t\n }\n }\n}\n// ---------- end Matrix ----------\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// ここまで\n\nuse matrix::*;\n\nimpl SemiRing for ModInt {\n fn zero() -> Self {\n ModInt::zero()\n }\n fn one() -> Self {\n ModInt::one()\n }\n}\n\nfn run() {\n input! {\n n: usize,\n x: usize,\n s: chars,\n }\n let s = convert(s);\n let mut aho = AhoCorasick::new();\n aho.insert(&s);\n aho.build();\n type M = SquareMatrix;\n let mut zero = M::identity();\n for i in 0..=n {\n let v = aho.trans(i, 0);\n let u = zero.get_at(v, i);\n zero.set_at(v, i, u + ModInt::one());\n let u = zero.get_at(n + 1 + v, n + 1 + i);\n zero.set_at(n + 1 + v, n + 1 + i, u + ModInt::one());\n if v == n {\n let u = zero.get_at(n + 1 + v, i);\n zero.set_at(n + 1 + v, i, u + ModInt::one());\n }\n }\n /*\n println!(\"zero\");\n for i in 0..(2 * n + 2) {\n for j in 0..(2 * n + 2) {\n print!(\"{} \", zero.get_at(i, j));\n }\n println!();\n }\n println!();\n */\n let mut one = M::identity();\n for i in 0..=n {\n let v = aho.trans(i, 1);\n let u = one.get_at(v, i);\n one.set_at(v, i, u + ModInt::one());\n let u = one.get_at(n + 1 + v, n + 1 + i);\n one.set_at(n + 1 + v, n + 1 + i, u + ModInt::one());\n if v == n {\n let u = one.get_at(n + 1 + v, i);\n one.set_at(n + 1 + v, i, u + ModInt::one());\n }\n }\n /*\n println!(\"one\");\n for i in 0..(2 * n + 2) {\n for j in 0..(2 * n + 2) {\n print!(\"{} \", one.get_at(i, j));\n }\n println!();\n }\n println!();\n */\n let mut dp = vec![];\n dp.push(zero);\n dp.push(one);\n for i in 2..=x {\n let v = dp[i - 2].matmul(&dp[i - 1]);\n dp.push(v);\n }\n /*\n for i in 0..(2 * n + 2) {\n for j in 0..(2 * n + 2) {\n print!(\"{} \", dp[x].get_at(i, j));\n }\n println!();\n }\n */\n let mut ans = ModInt::zero();\n for k in 0..=n {\n ans += dp[x].get_at(n + 1 + k, 0);\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "232ebc1616a6e1c434b54de35cc20a62", "src_uid": "52c6aa73ff4460799402c646c6263630", "apr_id": "cfbea02d6f6bbc10c291b785d6033975", "difficulty": 2400, "tags": ["matrices", "dp", "combinatorics"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8856128856128856, "equal_cnt": 20, "replace_cnt": 7, "delete_cnt": 2, "insert_cnt": 10, "fix_ops_cnt": 19, "bug_source_code": "use std::cmp;\nuse std::iter;\nuse std::io;\nuse std::io::BufRead;\n\nmod lib {\npub fn bam() {\n println!(\"Hi!\")\n}\n}\n\nfn is_square(n: u32) -> bool {\n let mut l: u64 = 1;\n let mut r: u64 = 60000;\n while r - l > 1 {\n let m = (r + l) / 2;\n if m * m > 0 && m * m <= n as u64 {\n l = m\n } else {\n r = m\n }\n }\n return l * l == n as u64;\n}\n\nfn recurse(n: u32, mut f: F) {\n if n < 10 {\n return; \n }\n\n let mut pow10: u64 = 1;\n while (n as u64) >= pow10 {\n if pow10 * 10 > (n as u64) && ((n as u64) % pow10 < pow10 / 10) {\n continue\n }\n f(((n as u64 / (pow10 * 10) * pow10) + (n as u64 % pow10)) as u32);\n\n pow10 *= 10;\n }\n}\n\nfn get(n: u32, xs: &mut Vec>>) -> Option {\n if xs[n as usize].is_none() {\n if is_square(n) {\n xs[n as usize] = Some(Some(0));\n } else {\n let mut result: Option = None;\n recurse(n, |n_rm| {\n if let Some(k_rm) = get(n_rm, xs) {\n result = result.map_or(\n Some(k_rm + 1), |k| Some(cmp::min(k, k_rm + 1))\n );\n }\n });\n xs[n as usize] = Some(result);\n }\n }\n return xs[n as usize].unwrap();\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut input = stdin.lock().lines().flat_map(\n |x| x.unwrap().split_whitespace().map(|x| x.to_string()).collect::>()\n );\n let n: u32 = input.next().unwrap().parse().unwrap();\n\n let mut array: Vec<_> = iter::repeat(None).take(100000).collect();\n if let Some(k) = get(n, &mut array) {\n println!(\"{}\", k);\n } else {\n println!(\"-1\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "21125c3949e3e1131e04dbc78aef7922", "src_uid": "fa4b1de79708329bb85437e1413e13df", "apr_id": "7b32cf1ed29161f72206044e32b937d3", "difficulty": 1400, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9837184873949579, "equal_cnt": 9, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 8, "bug_source_code": "use std::cmp;\nuse std::iter;\nuse std::io;\nuse std::io::BufRead;\n\nmod lib {\npub fn bam() {\n println!(\"Hi!\")\n}\n}\n\nfn is_square(n: u32) -> bool {\n let mut l: u64 = 1;\n let mut r: u64 = 60000;\n while r - l > 1 {\n let m = (r + l) / 2;\n if m * m > 0 && m * m <= n as u64 {\n l = m\n } else {\n r = m\n }\n }\n return l * l == n as u64;\n}\n\nfn recurse(n: u32, mut f: F) {\n if n < 10 {\n return; \n }\n\n let mut pow10: u64 = 1;\n while (n as u64) >= pow10 {\n if pow10 * 10 > (n as u64) && ((n as u64) % pow10 < pow10 / 10) {\n continue\n }\n f(((n as u64 / (pow10 * 10) * pow10) + (n as u64 % pow10)) as u32);\n\n pow10 *= 10;\n }\n}\n\nfn get(n: u32, xs: &mut Vec>>) -> Option {\n if n as usize >= xs.len() || xs[n as usize].is_none() {\n let res = if is_square(n) {\n Some(0)\n } else {\n let mut result: Option = None;\n recurse(n, |n_rm| {\n if let Some(k_rm) = get(n_rm, xs) {\n result = result.map_or(\n Some(k_rm + 1), |k| Some(cmp::min(k, k_rm + 1))\n );\n }\n });\n result\n };\n\n if (n as usize) < xs.len() {\n xs[n as usize] = Some(res);\n }\n return res;\n }\n return xs[n as usize].unwrap();\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut input = stdin.lock().lines().flat_map(\n |x| x.unwrap().split_whitespace().map(|x| x.to_string()).collect::>()\n );\n let n: u32 = input.next().unwrap().parse().unwrap();\n\n let mut array: Vec<_> = iter::repeat(None).take(100000).collect();\n if let Some(k) = get(n, &mut array) {\n println!(\"{}\", k);\n } else {\n println!(\"-1\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "7b8615dd120e3b5e8030c419cd210e06", "src_uid": "fa4b1de79708329bb85437e1413e13df", "apr_id": "7b32cf1ed29161f72206044e32b937d3", "difficulty": 1400, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9965156794425087, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Read, Write, BufWriter};\n#[allow(dead_code)]\nfn getline() -> String {\n let mut ret = String::new();\n std::io::stdin().read_line(&mut ret).ok().unwrap();\n ret\n}\nfn get_word() -> String {\n let mut stdin = std::io::stdin();\n let mut u8b: [u8; 1] = [0];\n loop {\n let mut buf: Vec = Vec::with_capacity(16);\n loop {\n let res = stdin.read(&mut u8b);\n if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {\n break;\n } else {\n buf.push(u8b[0]);\n }\n }\n if buf.len() >= 1 {\n let ret = String::from_utf8(buf).unwrap();\n return ret;\n }\n }\n}\n\n#[allow(dead_code)]\nfn get() -> T { get_word().parse().ok().unwrap() }\n\nfn is_square(s: Vec) -> bool {\n if s.len() == 0 { return false; }\n if s.len() >= 2 && s[0] == 0 { return false; }\n let mut val = 0;\n for u in s {\n val *= 10;\n val += u as i64;\n }\n let mut pass = 0;\n let mut fail = 1 << 16;\n while fail - pass > 1 {\n let mid = (fail + pass) / 2;\n if mid * mid <= val { pass = mid; }\n else { fail = mid; }\n }\n pass * pass == val\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 n: Vec<_> = get_word().chars().map(|c| c as u8 as i32 - b'0' as i32).collect();\n let len = n.len();\n let mut ans = 1 << 20;\n for bits in 0 .. 1usize << len {\n let mut t = Vec::new();\n for i in 0 .. len {\n if (bits & 1 << i) == 0 {\n t.push(n[i]);\n }\n }\n if is_square(t) {\n ans = min(ans, bits.count_ones() as i32);\n }\n }\n puts!(\"{}\\n\", if ans == 1 << 20 { -1 } else { ans });\n}\n\nfn main() {\n // In order to avoid potential stack overflow, spawn a new thread.\n let stack_size = 104_857_600; // 100 MB\n let thd = std::thread::Builder::new().stack_size(stack_size);\n thd.spawn(|| solve()).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "b0901a08e38e1026e173e23fc7b202db", "src_uid": "fa4b1de79708329bb85437e1413e13df", "apr_id": "52d21329080eca4450dad5168a5c9e3d", "difficulty": 1400, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9499799919967987, "equal_cnt": 9, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 7, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nmacro_rules! except {\n ($result: expr) => {\n match $result {\n Err(e) => panic!(\"{}\", e),\n Ok(m) => m,\n }\n };\n ($result: expr, $msg: expr) => {\n match $result {\n Err(e) => panic!(\"{}: {}\", $msg, e),\n Ok(m) => m,\n }\n };\n}\n\nfn parse_line() -> Vec {\n let mut input = String::new();\n except!(io::stdin().read_line(&mut input));\n input.trim().split_whitespace()\n .map(|x| except!(x.parse::()))\n .collect()\n}\n\n\nfn main() {\n let nm = parse_line();\n let (n, m) = (nm[0], nm[1]);\n if n > m {\n println!(\"0\");\n return\n }\n let a = parse_line();\n let mut counts = a.iter().fold([0u8; 101], |mut v, &x| {v[x as usize] += 1; v});\n counts.sort_unstable_by(|x, y| y.cmp(x));\n let mut nums = vec![0u8; n as usize];\n for _ in 0..n {\n let (index, _) = nums.iter().enumerate()\n .max_by_key(|&(i, v)| counts[i] / (v + 1)).unwrap();\n nums[index] += 1;\n }\n let (index, _) = nums.iter().filter(|&v| *v != 0).enumerate()\n .min_by_key(|&(i, v)| counts[i] / v).unwrap();\n println!(\"{}\", counts[index] / nums[index]);\n}\n", "lang": "Rust", "bug_code_uid": "279bd0544933cd741f63f2000e92bcbb", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "apr_id": "eb5ec24a4e7ae22379f4799cecd98304", "difficulty": 1200, "tags": ["brute force", "implementation", "binary search"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9643899591360187, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nmacro_rules! except {\n ($result: expr) => {\n match $result {\n Err(e) => panic!(\"{}\", e),\n Ok(m) => m,\n }\n };\n ($result: expr, $msg: expr) => {\n match $result {\n Err(e) => panic!(\"{}: {}\", $msg, e),\n Ok(m) => m,\n }\n };\n}\n\nfn parse_line() -> Vec {\n let mut input = String::new();\n except!(io::stdin().read_line(&mut input));\n input.trim().split_whitespace()\n .map(|x| except!(x.parse::()))\n .collect()\n}\n\n\nfn main() {\n let n = parse_line()[0];\n let a = parse_line();\n let counts = a.iter().fold([0u8; 101], |mut v, &x| {v[x as usize] += 1; v});\n for i in 1..101 {\n if n > counts.iter().fold(0, |v, x| v + x / i) {\n println!(\"{}\", i - 1);\n return\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "a35f15a5c4bd086751d7325f486c4551", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "apr_id": "eb5ec24a4e7ae22379f4799cecd98304", "difficulty": 1200, "tags": ["brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9986910994764397, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nmacro_rules! unwrap {\n ($result: expr) => {\n match $result {\n Err(e) => panic!(\"{}\", e),\n Ok(m) => m,\n }\n };\n}\n\nfn parse_line() -> Vec {\n let mut input = String::new();\n unwrap!(io::stdin().read_line(&mut input));\n input.trim().split_whitespace()\n .map(|x| unwrap!(x.parse::()))\n .collect()\n}\n\nconst MAXN: u8 = 100;\n\nfn main() {\n let n = parse_line()[0];\n let a = parse_line();\n let counts = a.iter().fold([0u8; MAXN as usize + 1], |mut v, &x| {v[x as usize] += 1; v});\n for i in 1..counts.len() as u8 / n + 1 {\n if n > counts.iter().fold(0, |v, x| v + x / i) {\n println!(\"{}\", i - 1);\n return\n }\n }\n println!(\"{}\", MAXN);\n}\n", "lang": "Rust", "bug_code_uid": "b58c7d16c032090c120f9d4b240041b0", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "apr_id": "eb5ec24a4e7ae22379f4799cecd98304", "difficulty": 1200, "tags": ["brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7213114754098361, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 5, "bug_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(s: String) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n s.split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn main() {\n let (n, m): (u64, u64) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n if n <= m {\n println!(\"{}\", n);\n return;\n }\n\n let delta_sqrt = {\n let tmp = 8 * (n - m) - 1;\n let tmp = tmp as f64;\n tmp.sqrt()\n };\n\n let k = (delta_sqrt - 1.0) / 2.0;\n let k = k.ceil() as u64;\n\n let ans = m + k;\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "2d9c14493f5741f6b72bc3c0abdd027c", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "apr_id": "01b04a08ce7a369d57e14c6d27f16682", "difficulty": 1600, "tags": ["math", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9963898916967509, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_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\n/// min{x | x * (x + 1) / 2 >= v }\nfn calc(v: i64) -> i64 {\n assert! (v > 0);\n let piv = (v as f64).sqrt() as i64;\n for k in max(piv - 2, 0) .. piv + 3 {\n if k * (k + 1) >= 2 * v {\n return k;\n }\n }\n panic!();\n}\n\nfn solve() {\n let n: i64 = get();\n let m: i64 = get();\n if n <= m {\n println!(\"{}\", n);\n return;\n }\n println!(\"{}\", m + calc(n - m));\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": "Rust", "bug_code_uid": "b522e81374021e6d27ac822fffa106c6", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "apr_id": "8d1fdb6cb2c19d1ff4d7d54cac721a74", "difficulty": 1600, "tags": ["math", "binary search"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7223436816790555, "equal_cnt": 11, "replace_cnt": 9, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 10, "bug_source_code": "use std::fmt::Debug;\nuse std::str::FromStr;\n\npub struct TokenReader {\n reader: std::io::Stdin,\n tokens: Vec,\n index: usize,\n}\n\nimpl TokenReader {\n pub fn new() -> Self {\n Self {\n reader: std::io::stdin(),\n tokens: Vec::new(),\n index: 0,\n }\n }\n\n pub fn next(&mut self) -> T\n where\n T: FromStr,\n T::Err: Debug,\n {\n if self.index >= self.tokens.len() {\n self.load_next_line();\n }\n self.index += 1;\n self.tokens[self.index - 1].parse().unwrap()\n }\n\n pub fn vector(&mut self) -> Vec\n where\n T: FromStr,\n T::Err: Debug,\n {\n if self.index >= self.tokens.len() {\n self.load_next_line();\n }\n self.index = self.tokens.len();\n self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()\n }\n\n pub fn load_next_line(&mut self) {\n let mut line = String::new();\n self.reader.read_line(&mut line).unwrap();\n\n self.tokens = line\n .split_whitespace()\n .map(String::from)\n .collect();\n self.index = 0;\n }\n}\n\nfn gcd(mut a: i32, mut b: i32) -> i32 {\n while b != 0 {\n let r = a % b;\n a = b;\n b = r;\n }\n a\n}\n\nfn lcm(a: i32, b: i32) -> i32 {\n ((a as i64 * b as i64) / (gcd(a, b) as i64)) as i32\n}\n\nfn solve(n: i32) -> (i32, i32) {\n let mut res = (n / 2, n - n / 2);\n let mut res_lcm = lcm(res.0, res.1);\n\n let mut i = 1i64;\n while i * i <= n as i64 {\n if n % i as i32 != 0 {\n i += 1;\n continue;\n }\n\n let a = i as i32;\n let b = n - a;\n let curr_lcm = lcm(a, b);\n\n if curr_lcm < res_lcm && a > 0 && b > 0 {\n res_lcm = curr_lcm;\n res = (a, b);\n }\n\n let a = n / i as i32;\n let b = n - a;\n let curr_lcm = lcm(a, b);\n\n if curr_lcm < res_lcm && a > 0 && b > 0 {\n res_lcm = curr_lcm;\n res = (a, b);\n }\n i += 1;\n }\n res\n}\n\nfn main() {\n let mut reader = TokenReader::new();\n let tests = reader.next();\n\n for _ in 0..tests {\n let n = reader.next();\n let (a, b) = solve(n);\n println!(\"{} {}\", a, b);\n }\n}\n", "lang": "Rust", "bug_code_uid": "bd94bbdfaad374997e6dd55f2a936d5a", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "apr_id": "a47baa30bec83071a5dce6386c2f0ab9", "difficulty": 1300, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6564282580078982, "equal_cnt": 13, "replace_cnt": 11, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 12, "bug_source_code": "use std::fmt::Debug;\nuse std::str::FromStr;\n\npub struct TokenReader {\n reader: std::io::Stdin,\n tokens: Vec,\n index: usize,\n}\n\nimpl TokenReader {\n pub fn new() -> Self {\n Self {\n reader: std::io::stdin(),\n tokens: Vec::new(),\n index: 0,\n }\n }\n\n pub fn next(&mut self) -> T\n where\n T: FromStr,\n T::Err: Debug,\n {\n if self.index >= self.tokens.len() {\n self.load_next_line();\n }\n self.index += 1;\n self.tokens[self.index - 1].parse().unwrap()\n }\n\n pub fn vector(&mut self) -> Vec\n where\n T: FromStr,\n T::Err: Debug,\n {\n if self.index >= self.tokens.len() {\n self.load_next_line();\n }\n self.index = self.tokens.len();\n self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()\n }\n\n pub fn load_next_line(&mut self) {\n let mut line = String::new();\n self.reader.read_line(&mut line).unwrap();\n\n self.tokens = line\n .split_whitespace()\n .map(String::from)\n .collect();\n self.index = 0;\n }\n}\n\nfn gcd(mut a: i32, mut b: i32) -> i32 {\n while b != 0 {\n let r = a % b;\n a = b;\n b = r;\n }\n a\n}\n\nfn lcm(a: i32, b: i32) -> i32 {\n ((a as i64 * b as i64) / (gcd(a, b) as i64)) as i32\n}\n\nfn is_prime(n: i32) -> bool {\n if n < 2 {\n return false;\n }\n\n let mut i: i64 = 2;\n while i * i <= n as i64 {\n if n as i64 % i == 0 {\n return false;\n }\n i += 1;\n }\n true\n}\n\nfn solve(n: i32) -> (i32, i32) {\n if n % 2 == 0 {\n return (n / 2, n / 2);\n }\n if is_prime(n) {\n return (1, n - 1);\n }\n\n let mut res = (n / 2, n / 2 + 1);\n let mut res_lcm = lcm(res.0, res.1);\n\n for i in 1..=n/2 + 1 {\n let a = i;\n let b = n - i;\n let curr_lcm = lcm(a, b);\n\n if curr_lcm < res_lcm {\n res_lcm = curr_lcm;\n res = (a, b);\n }\n }\n res\n}\n\nfn main() {\n let mut reader = TokenReader::new();\n let tests = reader.next();\n\n for _ in 0..tests {\n let n = reader.next();\n let (a, b) = solve(n);\n println!(\"{} {}\", a, b);\n }\n}\n", "lang": "Rust", "bug_code_uid": "7cf181cf0de2665310ae56864e75a201", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "apr_id": "a47baa30bec83071a5dce6386c2f0ab9", "difficulty": 1300, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9945054945054945, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{self, Stdin, stdin};\nuse std::str::FromStr;\nuse std::error::Error;\n\nfn main() -> Result<(), Box> {\n let stdin = stdin();\n\n let cases = {\n let mut l = line(&stdin)?;\n let mut ite = l.trim().split(' ');\n usize::from_str(ite.next().unwrap())?\n };\n\n for _ in 0..cases {\n let it = {\n let mut l = line(&stdin)?;\n let mut ite = l.trim().split(' ');\n u32::from_str(ite.next().unwrap())?\n };\n\n let mut best: u32 = 1;\n for d in 2..=f64::sqrt(it as f64) as u32 {\n if it % d == 0 {\n let nd = it / d;\n if nd > best {\n best = nd;\n }\n }\n }\n println!(\"{} {}\", best, it / best);\n }\n\n Ok(())\n}\n\nfn line(s: &Stdin) -> io::Result {\n let mut i = String::new();\n s.read_line(&mut i)?;\n Ok(i)\n}\n", "lang": "Rust", "bug_code_uid": "1607427ae511eaafdfcddd66867dd3db", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "apr_id": "1f509a66365f2f5e44bfa22e2c4e63fe", "difficulty": 1300, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9979577944179714, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "#![allow(unused_imports)]\n#![allow(non_snake_case)]\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::Write;\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($e:expr),*) => {\n #[cfg(debug_assertions)]\n $({\n let (e, mut err) = (stringify!($e), std::io::stderr());\n writeln!(err, \"{} = {:?}\", e, $e).unwrap()\n })*\n };\n}\n\nfn get_primes(n: i64) -> Vec {\n let mut is_prime = vec![true; n as usize + 1];\n let mut primes = Vec::new();\n is_prime[0] = false;\n is_prime[1] = false;\n\n for i in 2..n + 1 {\n if is_prime[i as usize] {\n primes.push(i);\n let mut j = 2 * i;\n while j < n {\n is_prime[j as usize] = false;\n j += i;\n }\n }\n }\n primes\n}\n\nfn main() {\n let n = read::();\n let primes = get_primes(1001);\n 'outer: for _ in 0..n {\n let n = read::();\n for &p in primes.iter() {\n if n % p == 0 {\n println!(\"{} {}\", n / p, n - n / p);\n continue 'outer;\n }\n }\n println!(\"{} {}\", 1, n - 1);\n }\n}\n\nfn read() -> T {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn read_vec() -> Vec {\n read::()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n", "lang": "Rust", "bug_code_uid": "e72e1bdfcf7111a1595ac81e22dc3403", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "apr_id": "5b4ec947b9d3b03e606036b7b4e01ff1", "difficulty": 1300, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7466780968709815, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "/*\n date : 2020 / 5 / 5\n author : quickn (quickn.ga)\n email : quickwshell@gmail.com\n*/\n\nuse std::io::{self, BufWriter, Write};\n\nmod scanner {\n use std::{io, str};\n /* https://github.com/EbTech/rust-algorithms */\n\n /// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts\n /// **REQUIRES** Rust 1.34 or higher\n pub struct UnsafeScanner {\n reader: R,\n buf_str: Vec,\n buf_iter: str::SplitAsciiWhitespace<'static>,\n }\n\n impl UnsafeScanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buf_str: Vec::new(),\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}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let (mut scan, mut sout) = (\n scanner::UnsafeScanner::new(stdin.lock()),\n BufWriter::new(stdout.lock()),\n );\n let t: usize = scan.token();\n for i in 0..t {\n let n: usize = scan.token();\n let mut d: usize = 0;\n let mut d2: usize = n;\n use std::cmp::{max, min};\n for a in 1..=((n as f64).sqrt() as usize) {\n if n % a == 0 {\n d = max(d, a);\n d2 = min(d2, n/a);\n }\n }\n d = max(d, d2);\n writeln!(sout, \"{} {}\", d, n-d).ok();\n }\n}\n", "lang": "Rust", "bug_code_uid": "7989c6ec32c503fa74f8ad6aad0510d8", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "apr_id": "0655ee7f37ca730528012cb8fc0e7a2b", "difficulty": 1300, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.992831541218638, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let n = input.i() - 1;\n let mut sol = 0;\n for i in 1.. {\n if i * i > n { break; }\n if i * i == n { sol += 1; }\n else if n % i == 0 { sol += 2; }\n }\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "1451832ba3a877bf778671639c0a2de1", "src_uid": "89f6c1659e5addbf909eddedb785d894", "apr_id": "2c595706eddf1c4505184b465c20b9d0", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7392607392607392, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io::{BufReader, BufRead};\n\nfn main() -> Result<(), Box> {\n let n = BufReader::new(std::io::stdin())\n .lines()\n .next()\n .unwrap()?\n .parse::()?;\n\n let sqrt = (n as f32).sqrt().floor() as usize;\n let mut factors = 0;\n\n for factor in 1..=sqrt {\n if n % factor == 0 {\n factors += if factor == sqrt { 1 } else { 2 };;\n }\n }\n\n println!(\"{}\", factors - 1);\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "00767821fd3608d6bf6408c17aca0445", "src_uid": "89f6c1659e5addbf909eddedb785d894", "apr_id": "f0655fd2a5d35cf691e6c02443e8f72c", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.904891304347826, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn get_line() -> io::Result {\n\tlet mut buffer = String::new();\n\tio::stdin().read_line(&mut buffer)?;\n\tOk(buffer)\n}\n\nfn main() {\n\tlet employees;\n\t{\n\t\tlet input = get_line().unwrap();\n\t\temployees = input.trim().parse::().unwrap();\n\t}\n\n\tfor i in 1..employees {\n\t\tif (employees - i) % i == 0 {\n\t\t\tprint!(\"{}\", i);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n", "lang": "Rust", "bug_code_uid": "18c1725ab3348617e82935517896dfde", "src_uid": "89f6c1659e5addbf909eddedb785d894", "apr_id": "c0f9471e36dfaafc9c190c7e5d5adba4", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.4631803628601921, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\n\nfn main() -> io::Result<()> {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input)?;\n\n let n = input.trim().parse::().unwrap();\n\n input.clear();\n io::stdin().read_line(&mut input)?;\n\n let v: Vec = input\n .trim()\n .split(' ')\n .map(|x| x.parse::().unwrap())\n .collect();\n\n let mut easy = 0;\n for i in 0..n {\n if v[i] != 0 {\n easy = 1\n }\n }\n\n if easy == 0 {\n print!(\"EASY\");\n } else {\n print!(\"HARD\");\n }\n\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "6758f883cb9d1e1d180b251079b56e37", "src_uid": "89f6c1659e5addbf909eddedb785d894", "apr_id": "fa448f9aa53b6bca19f1c2f6f7dff002", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6996402877697842, "equal_cnt": 9, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer)\n .expect(\"Failed to read line\");\n let num_employees = buffer.trim().parse::().expect(\"parse error\");\n let max_tl = num_employees.sqrt().floor() as i32;\n let num_employees = num_employees as i32;\n\n let mut count = 1;\n for tl in 1..max_tl {\n if num_employees % tl == 0 {\n count += 1;\n }\n }\n println!(\"{}\", count)\n}\n", "lang": "Rust", "bug_code_uid": "31b1c488a510384fc9b680f7486a231d", "src_uid": "89f6c1659e5addbf909eddedb785d894", "apr_id": "f4bdb6443cbec3d95615230235d37c4e", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9754973313925279, "equal_cnt": 12, "replace_cnt": 8, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "//---------- begin union_find ----------\n#[allow(dead_code)]\nmod union_find {\n pub struct UF {\n p: Vec,\n }\n impl UF {\n pub fn new(n: usize) -> UF {\n UF {p: vec![-1; n] }\n }\n pub fn init(&mut self) {\n for p in self.p.iter_mut() {\n *p = -1;\n }\n }\n pub fn root(&self, mut x: usize) -> usize {\n while self.p[x] >= 0 {\n x = self.p[x] as usize;\n }\n x\n }\n pub fn same(&self, x: usize, y: usize) -> bool {\n self.root(x) == self.root(y)\n }\n pub fn unite(&mut self, x: usize, y: usize) -> Option<(usize, usize)> {\n let mut x = self.root(x);\n let mut y = self.root(y);\n if x == y {\n return None;\n }\n if self.p[x] > self.p[y] {\n std::mem::swap(&mut x, &mut y);\n }\n self.p[x] += self.p[y];\n self.p[y] = x as i32;\n Some((x, y))\n }\n pub fn parent(&self, x: usize) -> Option {\n let p = self.p[x];\n if p >= 0 {\n Some(p as usize)\n } else {\n None\n }\n }\n pub fn get_size(&self, x: usize) -> usize {\n let r = self.root(x);\n (-self.p[r]) as usize\n }\n }\n}\n//---------- end union_find ----------\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 input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: usize,\n m: usize,\n e: [(usize1, usize1); m],\n }\n let mut e = e;\n e.sort();\n let mut deg = vec![0; n];\n for &(a, b) in e.iter() {\n deg[a] += 1;\n deg[b] += 1;\n }\n let mut ans = vec![n; n];\n for i in 0..n {\n if deg[i] == n - 1 {\n ans[i] = 1;\n }\n }\n let mut u = union_find::UF::new(n);\n for &(a, b) in e.iter() {\n if deg[a] != n - 1 && deg[b] == n - 1 {\n u.unite(a, b);\n }\n }\n let mut id = 0;\n let mut add = 2;\n for i in 0..n {\n if deg[i] != n - 1 && i == u.root(i) {\n ans[i] = id;\n id += add;\n add = 1;\n }\n }\n if id > 3 {\n println!(\"No\");\n return;\n }\n for i in 0..n {\n for j in (i + 1)..n {\n if ans[i] == ans[j] || ans[i] == ans[j] + 1 || ans[i] + 1 == ans[j] {\n if e.binary_search(&(i, j)).is_err() {\n println!(\"No\");\n return;\n }\n }\n }\n }\n println!(\"Yes\");\n let mut s = String::new();\n let op: Vec = \"abc\".chars().collect();\n for a in ans {\n s.push(op[a]);\n }\n println!(\"{}\", s);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "c32e36a8df2890ca010292a64d7884e9", "src_uid": "e71640f715f353e49745eac5f72e682a", "apr_id": "747587b198f71454286c0a4d2b4b3432", "difficulty": 1800, "tags": ["graphs", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5609593604263824, "equal_cnt": 7, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "use std::io::{self, Read};\n\nfn read_line() -> Vec {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n return buf.trim().split(\" \")\n .map(|x| {x.parse::().unwrap() })\n .collect();\n}\n\n\nfn main(){\n \n let mut line = read_line();\n let (a, b) = (line[0], line[1]);\n line = read_line();\n let (c, d) = (line[0], line[1]);\n \n let mut ans = -1;\n\n 'outer: for i in 1..101 {\n\n for j in 1..101 {\n if ((a*i + b) == (c*j + d)){\n ans = a*i + b;\n break 'outer;\n }\n }\n }\n\n println! (\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "170d272bb3bfc4cfc68145950c2cdf1a", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "apr_id": "569dee3f27149bd1b0d86d8160074389", "difficulty": 1200, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9668654738237243, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_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(s: String) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n s.split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn extended_euclid(a: i32, b: i32) -> (i32, i32, i32) {\n if b == 0 {\n (a, 1, 0)\n } else {\n let (d, x, y) = extended_euclid(b, modulo(a, b));\n (d, y, x - a / b * y)\n }\n}\n\nfn modulo(a: i32, b: i32) -> i32 {\n let ret_val = a % b;\n if ret_val < 0 {\n ret_val + b\n } else {\n ret_val\n }\n}\n\nfn main() {\n let (a, b): (i32, i32) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n \n let (c, d): (i32, i32) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let e = d - b;\n\n let (g, x, y) = extended_euclid(a, c);\n\n let ans = if e % g != 0 {\n -1\n } else {\n let x1 = x * e / g;\n let x2 = modulo(x1, c / g);\n b + x2 * a\n };\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "2f0585fcc4c0e41e0267681b8f2f418e", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "apr_id": "5182b5f9a1af609b581559eeef1c0041", "difficulty": 1200, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.996042216358839, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n l!(t,s,x = input.i());\n if x >= t && (x == t || (x - t) % s <= 1) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "052d7c67f9c63d279955ed68c9887f53", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "apr_id": "15a6fc216daedfe27104984e0245fc0d", "difficulty": 900, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9994155464640561, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "macro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn div_and_ceil(a: i32, b: i32) -> i32 {\n if a % b == 0 { a / b } else { a / b + 1 }\n}\n\nfn main() {\n let (guests, lists) = readln(i32, i32);\n \n let red = div_and_ceil(2 * guests, lists);\n let green = div_and_ceil(5 * guests, lists);\n let blue = div_and_ceil(8 * guests, lists);\n \n println!(\"{}\", red + green + blue);\n}", "lang": "Rust", "bug_code_uid": "e69d7f9554efaeedb2bec209413114a2", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "apr_id": "29dc6bac2e621f4df0d3017e34c8f7a6", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9855569155446756, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn solve() {\n let (n, m) = parse_line!(usize, usize);\n let l = parse_line_to_vec!(usize);\n let mut result = vec![0; n];\n let mut ok = true;\n for i in 1..m {\n let leader = l[i - 1] - 1;\n let diff = (n + l[i] - l[i - 1]) % n;\n if result[leader] == 0 {\n result[leader] = diff;\n }else if result[leader] != diff {\n ok = false;\n }\n }\n for i in 0..n {\n if result[i] == 0 {\n continue;\n }\n let mut local = true;\n for j in 0..i {\n local &= result[i] != result[j];\n }\n ok &= local;\n }\n if !ok {\n return println!(\"-1\");\n }\n let mut s = std::collections::HashSet::::new();\n s.extend(result.iter());\n let mut next = 1;\n for i in 0..n {\n if result[i] != 0 {\n continue;\n }\n while s.contains(&next) {\n next += 1;\n }\n result[i] = next;\n next += 1;\n }\n for x in result {\n print!(\"{} \", x);\n }\n println!();\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang": "Rust", "bug_code_uid": "a12ffa849899ea83ac984d4fb760db24", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "apr_id": "4fd85c0ac7fb65ca4b79ef61c8877b8d", "difficulty": 1600, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9899086977414705, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, BufRead};\nuse std::fs;\n\nfn main() {\n let stdin = io::stdin();\n let line = stdin.lock()\n .lines()\n .next()\n .expect(\"there was no next line\")\n .expect(\"the line could not be read\");\n\n let numbers: Vec<_> = line.split(\" \").collect();\n let v: i32 = numbers[0].parse().unwrap();\n// let b: i32 = numbers[1].parse().unwrap();\n\n println!(\"{}\", 1);\n}\n\n//fn main() {\n// let mut line = String::new();\n// let stdin = io::stdin();\n// stdin.lock().read_line(&mut line).expect(\"Could not read line\");\n// println!(\"{}\", line)\n//}\n\n/*\nfn main() {\n let stdin = io::stdin();\n let lines: Vec = stdin.lock().lines().map(|x| x.unwrap()).collect();\n\n let line = &lines[0];\n\n// let data = fs::read_to_string(\"test\").expect(\"Unable to read file\");\n// println!(\"{}\", data);\n\n\n let numbers: Vec<_> = line.split(\" \").collect();\n let a: i32 = numbers[0].parse().unwrap();\n let b: i32 = numbers[1].parse().unwrap();\n\n println!(\"{}\", a + b);\n}\n\n*/", "lang": "Rust", "bug_code_uid": "e981939d71d9493f2e26d2c4f9638f16", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "apr_id": "5f54cf783ad482bf971370e3d7c1a485", "difficulty": 800, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9997994786444756, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "const INF: i64 = 1_000_000_000i64;\n\nstruct Graph {\n size: usize,\n edge: Vec<(usize, usize, i64, i64)>,\n}\n\nimpl Graph {\n fn new(size: usize) -> Self {\n Graph {\n size: size,\n edge: vec![],\n }\n }\n fn add_edge(&mut self, src: usize, dst: usize, capa: i64, cost: i64) {\n assert!(src < self.size && dst < self.size && src != dst);\n self.edge.push((src, dst, capa, cost));\n }\n fn solve(&self, src: usize, dst: usize, flow: i64) -> Option {\n if src == dst {\n return Some(0);\n }\n let size = self.size;\n let edge = &self.edge;\n let mut deg = vec![0; size];\n for &(a, b, _, _) in edge.iter() {\n deg[a] += 1;\n deg[b] += 1;\n }\n let mut graph: Vec<_> = deg.into_iter().map(|d| Vec::with_capacity(d)).collect();\n for &(a, b, capa, cost) in edge.iter() {\n let x = graph[a].len();\n let y = graph[b].len();\n graph[a].push((b, capa, cost, y));\n graph[b].push((a, 0, -cost, x));\n }\n let mut ans = 0;\n let mut dp = Vec::with_capacity(size);\n let mut elem = Vec::with_capacity(size);\n let mut que = std::collections::VecDeque::new();\n for _ in 0..flow {\n dp.clear();\n dp.resize(size, (INF, src, 0));// コスト、親、親からの番号\n dp[src] = (0, src, 0);\n elem.clear();\n elem.resize(size, false);\n elem[src] = true;\n que.push_back(src);\n while let Some(v) = que.pop_front() {\n elem[v] = false;\n let (c, _, _) = dp[v];\n for (i, &(u, capa, cost, _)) in graph[v].iter().enumerate() {\n if capa == 0 {\n continue;\n }\n let c = c + cost;\n if c < dp[u].0 {\n dp[u] = (c, v, i);\n if !elem[u] {\n elem[u] = true;\n que.push_back(u);\n }\n }\n }\n }\n if dp[dst].0 == INF {\n return None;\n }\n ans += dp[dst].0;\n let mut pos = dst;\n while pos != src {\n let (_, parent, k) = dp[pos];\n let inv = graph[parent][k].3;\n graph[parent][k].1 -= 1;\n graph[pos][inv].1 += 1;\n pos = parent;\n }\n }\n Some(ans)\n }\n}\n\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: usize,\n m: usize,\n k: usize,\n c: i64,\n d: i64,\n a: [usize1; k],\n e: [(usize1, usize1); m],\n }\n let w = 101;\n let size = n * w + 2;\n let mut graph = Graph::new(size);\n let src = size - 1;\n let dst = src - 1;\n let pos = |a: usize, b: usize| -> usize {\n assert!(a < 101 && b < n);\n a * n + b\n };\n for a in a {\n graph.add_edge(src, pos(0, a), 1, 0);\n }\n for i in 0..w {\n graph.add_edge(pos(i, 0), dst, 50, c * i as i64);\n }\n for (a, b) in e {\n for i in 1..w {\n for j in 1..=n {\n let x = j as i64;\n graph.add_edge(pos(i - 1, a), pos(i, b), 1, d * (2 * x - 1));\n graph.add_edge(pos(i - 1, b), pos(i, a), 1, d * (2 * x - 1));\n }\n }\n }\n for i in 1..w {\n for j in 0..n {\n graph.add_edge(pos(i - 1, j), pos(i, j), 50, 0);\n }\n }\n let ans = graph.solve(src, dst, k as i64).unwrap();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "13ca23f41a5bd1e46f82bac5c01d7074", "src_uid": "2d0aa75f2e63c4fb8c98742ac8cd821c", "apr_id": "a0261e11ee3560ab8f62a8ab2915ac05", "difficulty": 2500, "tags": ["graphs", "flows"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9984202211690363, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\nuse std::io::Write;\n\n// Outline\n// read in numberse first and parse\n\nfn main() {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input)\n .expect(\"Couldn't read line.\");\n\n let input: Vec = input\n .split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect();\n\n let number_of_pages: u32 = input[0];\n let current_page: u32 = input[1];\n let range_of_pages: u32 = input[2];\n\n let lower_bound = {\n if current_page - range_of_pages <= 0 {\n 1\n } else {\n current_page - range_of_pages\n }\n };\n\n let higher_bound = {\n if current_page + range_of_pages > number_of_pages {\n number_of_pages\n } else {\n current_page + range_of_pages\n }\n };\n\n if higher_bound != number_of_pages && lower_bound != 1 {\n print!(\"<< \");\n io::stdout().flush().unwrap();\n for page in lower_bound..higher_bound+1 {\n if page == current_page {\n print!(\"({}) \", page);\n io::stdout().flush().unwrap();\n } else {\n print!(\"{} \", page);\n io::stdout().flush().unwrap();\n }\n }\n print!(\">>\");\n io::stdout().flush().unwrap();\n } else if higher_bound == number_of_pages && lower_bound != 1 {\n print!(\"<< \");\n io::stdout().flush().unwrap();\n for page in lower_bound..higher_bound+1 {\n if page == current_page {\n print!(\"({}) \", page);\n io::stdout().flush().unwrap();\n } else {\n print!(\"{} \", page);\n io::stdout().flush().unwrap();\n }\n }\n } else if higher_bound == number_of_pages && lower_bound == 1 {\n for page in lower_bound..higher_bound+1 {\n if page == current_page {\n print!(\"({}) \", page);\n io::stdout().flush().unwrap();\n } else {\n print!(\"{} \", page);\n io::stdout().flush().unwrap();\n }\n }\n } else if higher_bound != number_of_pages && lower_bound == 1 {\n for page in lower_bound..higher_bound+1 {\n if page == current_page {\n print!(\"({}) \", page);\n io::stdout().flush().unwrap();\n } else {\n print!(\"{} \", page);\n io::stdout().flush().unwrap();\n }\n }\n print!(\">>\");\n io::stdout().flush().unwrap();\n }\n}\n", "lang": "Rust", "bug_code_uid": "6cd76b93e739ae94cfe2ed76a1d90d32", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "apr_id": "9be9e1cd3edc6f8a7c63b3b19e56c14e", "difficulty": null, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8819875776397516, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: usize,\n a: [usize; n],\n }\n let mut cnt = vec![0; 10];\n for a in a {\n for i in 0..10 {\n cnt[i] += (a >> i) & 1;\n }\n }\n for i in 0..10 {\n if cnt[i] % (n / 2) != 0 {\n println!(\"Alice\");\n return;\n }\n }\n println!(\"Bob\");\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "f21a1d0d3dcbb8a921ea6779ebef1764", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "apr_id": "302c27e5664e0770fe8416fe67a7e906", "difficulty": 2000, "tags": ["games"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9651741293532339, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused_imports)]\nuse std::io::stdin;\n \n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nuse std::cmp::{ min, max };\n\ntype Point = (i128, i128);\n\nfn intersect(a: &Point, b: &Point, c: &Point, d: &Point) -> (Point, Point) {\n let l = max(min(a.0, b.0), min(c.0, d.0));\n let r = min(max(a.0, b.0), max(c.0, d.0));\n let u = min(max(a.1, b.1), max(c.1, d.1));\n let d = max(min(a.1, b.1), min(c.1, d.1));\n if l >= r || u <= d {\n ((0,0), (0,0))\n } else {\n ((l, d), (r, u))\n }\n}\n\nfn area(x: &Point, y: &Point) -> i128 {\n (x.0 - y.0).abs() * (x.1 - y.1).abs()\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let (p1, p2): (Point, Point) = ((scan.next::(), scan.next::()),(scan.next::(), scan.next::()));\n let (p3, p4): (Point, Point) = ((scan.next::(), scan.next::()),(scan.next::(), scan.next::()));\n let (p5, p6): (Point, Point) = ((scan.next::(), scan.next::()),(scan.next::(), scan.next::()));\n let wb1 = intersect(&p1, &p2, &p3, &p4);\n let wb2 = intersect(&p1, &p2, &p5, &p6);\n let sb1b2 = intersect(&wb1.0, &wb1.1, &wb2.0, &wb2.1);\n let a = area(&p1, &p2);\n let b = area(&wb1.0, &wb1.0);\n let c = area(&wb2.0, &wb2.0);\n let d = area(&sb1b2.0, &sb1b2.0);\n println!(\"{}\", if a > b + c -d { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "3f190255e2f7cca2ee84d2326461002c", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "apr_id": "03714133f273afd69e503c5bfc419c21", "difficulty": 1700, "tags": ["geometry", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7794751273012143, "equal_cnt": 9, "replace_cnt": 5, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 9, "bug_source_code": "use std::collections::HashMap;\nuse std::io;\n\nfn solve() -> Vec {\n let mut input = \"\".split_ascii_whitespace();\n let mut read = || loop {\n if let Some(word) = input.next() {\n break word;\n }\n input = {\n let mut input = \"\".to_owned();\n io::stdin().read_line(&mut input).unwrap();\n if input.is_empty() {\n panic!(\"reached EOF\");\n }\n Box::leak(input.into_boxed_str()).split_ascii_whitespace()\n };\n };\n macro_rules! read(($ty:ty) => (read().parse::<$ty>().unwrap()));\n\n let mut rr = vec![\"\".to_string(); 0];\n\n let t = 1;\n for _ in 0..t {\n let n = read!(usize);\n let mut a = vec![0; n];\n for i in 0..n {\n a[i] = read!(usize);\n }\n\n let mut c: HashMap = HashMap::new();\n for i in 0..n {\n *(c.entry(a[i]).or_insert(0)) += 1;\n }\n\n let mut r = 1;\n for (k, t) in c.iter() {\n if r < *t {\n r = *t;\n }\n }\n\n rr.push(format!(\"{}\", r));\n }\n\n rr\n}\n\n#[allow(dead_code)]\nfn main() {\n let output = solve();\n println!(\"{}\", output.join(\"\\n\"));\n}\n", "lang": "Rust", "bug_code_uid": "be39a8143fafb384f03bfbbc6068ec76", "src_uid": "7c710ae68f27f140e7e03564492f7214", "apr_id": "891adecf89a4b0c3460cf5638697bbfc", "difficulty": 1400, "tags": ["greedy", "sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5542168674698795, "equal_cnt": 10, "replace_cnt": 8, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nfn get_num() -> usize{\n let mut input = String::new();\n\n io::stdin().read_line(&mut input)\n .expect(\"\");\n\n usize::from_str(input.trim()).unwrap()\n}\n\nfn main() {\n let n = get_num();\n\n let m = n / 7;\n let r = n % 7;\n\n println!(\"{} {}\", m * 2, m * 2 + if r == 0 { 0 } else if r == 1 { 1 } else { 2 });\n}\n", "lang": "Rust", "bug_code_uid": "bb66dac2166f47243cea2f6c7fea49c7", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "apr_id": "82ed7b2871d83a20553ea3afca535b86", "difficulty": 900, "tags": ["brute force", "math", "constructive algorithms", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9268188606784724, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_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 _ = readl!(usize);\n let vs = readlvec!(i32);\n \n let mut ans: i32 = 0;\n for i in 0..(vs.len()+1) {\n let mut b: i32 = 0;\n for j in 0..i {\n b += vs[j];\n }\n let mut c: i32 = 0;\n for j in i..vs.len() {\n c += vs[j];\n }\n ans = max(ans, b - c);\n }\n printer.println(ans);\n}", "lang": "Rust", "bug_code_uid": "244782b8526db125ba2e116a2bb6eea8", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "apr_id": "ad46e6f9976b0fb066cf94d7694b1f40", "difficulty": 800, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9766517635370094, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_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": "Rust", "bug_code_uid": "394687deb6831d34d3c1014813293b06", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "apr_id": "984449904d28e308e37c729846af9e26", "difficulty": 800, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.2884770346494762, "equal_cnt": 16, "replace_cnt": 10, "delete_cnt": 6, "insert_cnt": 0, "fix_ops_cnt": 16, "bug_source_code": "use std::collections::VecDeque;\n\nfn main() {\n let mut queue = VecDeque::new();\n queue.push_back(\"Sheldon\");\n queue.push_back(\"Leonard\");\n queue.push_back(\"Penny\");\n queue.push_back(\"Rajesh\");\n queue.push_back(\"Howard\");\n\n let mut n = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse::().expect(\"Invalid input.\") - 1\n };\n\n while n >= queue.len() {\n let first = queue\n .pop_front()\n .expect(\"Problems extracting first element\");\n queue.push_back(first);\n queue.push_back(first);\n n -= 1;\n }\n\n println!(\"{}\", queue.get(n).expect(\"Couldn't get nth element\"));\n}", "lang": "Rust", "bug_code_uid": "959ed082e7edc3b0ca4c1e3cbb46fec9", "src_uid": "023b169765e81d896cdc1184e5a82b22", "apr_id": "536339136da3c4e2fe4daeaf6b32cec3", "difficulty": 1100, "tags": ["math", "implementation"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9199821189092534, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn main() {\n let mut ss: String = String::new();\n io::stdin().read_line(&mut ss).unwrap();\n let n: u64 = ss.trim().parse().unwrap();\n\n let mut l: u64 = 1;\n let mut r: u64 = (n/2) + (n%2);\n let mut m: u64;\n\n if tryv(n, 1) { println!(\"1\"); return; }\n\n loop {\n if l + 1 == r {\n break;\n }\n m = (l + r) / 2;\n if tryv(n, m) {\n r = m; \n } else {\n l = m;\n } \n }\n\n println!(\"{}\", r);\n return;\n}\n\nfn tryv(nn: u64, k: u64) -> bool {\n // println!(\"n: {}, k: {}\", nn, k);\n // println!(\"=====================\");\n if k == 0 { return false; }\n let mut n = nn;\n let mut v: u64 = 0;\n loop {\n if v >= nn/2 {\n return true;\n } else if v + n < nn/2 {\n return false;\n }\n\n if k >= n {\n v += n;\n n = 0;\n } else {\n v += k;\n n -= k;\n }\n \n n -= n/10;\n // println!(\"left: {}, vasya: {}\", n, v);\n }\n}\n", "lang": "Rust", "bug_code_uid": "a0580aad7e305980c79f2d8a8f0b1fd8", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "apr_id": "0b126178c9b203713376524f963d682a", "difficulty": 1500, "tags": ["implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9851325145442793, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut input = String::new();\n use std::io::{self, prelude::*};\n io::stdin().read_to_string(&mut input).unwrap();\n\n let n: u64 = input.trim().parse().unwrap();\n\n let check = |k| {\n let mut n = n;\n\n let mut v = 0;\n let mut p = 0;\n loop {\n if n < k {\n n = 0;\n v += n;\n break;\n }\n n -= k;\n v += k;\n\n let q = n / 10;\n n -= q;\n p += q;\n }\n\n p <= v\n };\n\n let mut low = 0;\n let mut up = (n + 1) / 2;\n\n while low + 1 != up {\n let cur = (low + up) / 2;\n if check(cur) {\n up = cur;\n } else {\n low = cur;\n }\n }\n\n println!(\"{}\", up);\n}\n", "lang": "Rust", "bug_code_uid": "f1202035ae375857b326d88f8a1328bd", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "apr_id": "bc843e93d01aa55818b752d4be200daf", "difficulty": 1500, "tags": ["implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9382940108892922, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n\n let mut input = buf\n .split_whitespace()\n .map(|s| s.parse::().unwrap());\n\n // length\n let n = input.next().unwrap();\n // route 1 (+)\n let a = input.next().unwrap();\n let x = input.next().unwrap();\n // route 2 (-)\n let b = input.next().unwrap();\n let y = input.next().unwrap();\n\n println!(\"{}\", match solve(n, a, x, b, y) {\n true => \"YES\",\n false => \"NO\",\n });\n}\n\nfn solve(n: i32, a: i32, x: i32, b: i32, y: i32) -> bool {\n let x = if x < a { x + n } else { x };\n let y = if y > b { y - n } else { y };\n (y .. b + 1).rev().zip(a .. x + 1).any(|(i, j)| i % n == j % n)\n}\n\n#[cfg(test)]\nmod test {\n\n use super::solve;\n #[test]\n fn test1() {\n assert_eq!(solve(5, 1, 4, 3, 2), true);\n }\n #[test]\n fn test2() {\n assert_eq!(solve(10, 2, 1, 9, 10), false);\n }\n #[test]\n fn test3() {\n assert_eq!(solve(82, 9, 11, 15, 79), false);\n }\n}", "lang": "Rust", "bug_code_uid": "f88eac00bf50faa66f37ec23f525b54b", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "apr_id": "4d80b86b9916240c36da3a8e8f3eafc7", "difficulty": 900, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9354654483152485, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 5, "bug_source_code": "fn read_string() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n input\n}\n\nfn main(){\n let now_time = read_string().replace(\"\\n\", \"\").replace(\"\\r\", \"\");\n let sleep_time = read_string().replace(\"\\n\", \"\").replace(\"\\r\", \"\");\n let now_vec: Vec<&str> = now_time.split(\":\").collect();\n let sleep_vec: Vec<&str> = sleep_time.split(\":\").collect();\n let mut hours = now_vec[0].parse::().unwrap() - sleep_vec[0].parse::().unwrap();\n let mut minutes = now_vec[1].parse::().unwrap() - sleep_vec[1].parse::().unwrap();\n if hours < 0{\n hours = 24+hours;\n }\n if minutes < 0{\n minutes = 60+minutes\n }\n println!(\"{}{}:{}{}\", if hours<10 {\"0\"} else {\"\"}, hours, if minutes<10 {\"0\"} else {\"\"},minutes);\n }", "lang": "Rust", "bug_code_uid": "5603326474d64aaa044763b9b1ad50d7", "src_uid": "595c4a628c261104c8eedad767e85775", "apr_id": "76d664a15e576e8c6c0f63f661726a91", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8815331010452961, "equal_cnt": 20, "replace_cnt": 12, "delete_cnt": 5, "insert_cnt": 3, "fix_ops_cnt": 20, "bug_source_code": "macro_rules! read {\n ( $( $type_:ty ),+ ) => {\n {\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"error while reading line\");\n let tokens : Vec = line.as_str().split_whitespace().map(|x| x.to_string()).collect();\n let mut _tokens : &[String] = &tokens;\n ($(\n {\n let tmp : $type_ = _tokens[0].parse().expect(\"error while parsing value\");\n _tokens = &_tokens[1..];\n tmp\n }\n ),*)\n }\n };\n}\nmacro_rules! read_vec {\n ( $type_:ty ) => {\n {\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"error while reading line\");\n line.as_str().split_whitespace().map(|x| x.parse().expect(\"error while parsing\")).collect::>()\n }\n };\n}\nmacro_rules! lazy_constant {\n (static $name:ident: $type_:ty = $initializer:expr;) => {\n use std::sync::{Once, ONCE_INIT};\n use std::boxed::Box;\n static INIT: Once = ONCE_INIT;\n static mut VALUE: *const $type_ = 0 as * const $type_;\n INIT.call_once(|| {\n unsafe {\n VALUE = Box::into_raw(Box::new($initializer));\n }\n });\n let $name: & $type_ = unsafe { VALUE.as_ref().unwrap() };\n };\n}\nuse std::io;\nfn main() {\n let _ = read!(i32);\n let text = read!(String);\n let text = text.as_bytes();\n \n for i in 0 .. text.len() {\n if text[i] == *text.get(i + 1).unwrap_or(&b'#') {\n if text[i] != b'?' {\n println!(\"No\");\n return;\n }\n else if i > 0 && i + 2 < text.len() && text[i - 1] != text[i + 2] && text[i - 1] != b'?' && text[i + 2] != b'?' {\n println!(\"No\");\n return;\n }\n }\n }\n println!(\"Yes\");\n}", "lang": "Rust", "bug_code_uid": "8e4d0ed616ebf5b6cca9645fccfd4d71", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "apr_id": "b9b39d1f9527734e471c7118c0511d16", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6776504297994269, "equal_cnt": 12, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 11, "bug_source_code": "\nuse std::io;\n\n#[derive(Debug, Copy, Clone, PartialEq)]\nenum Color {\n C,\n Y,\n M,\n U,\n}\n\nimpl Color {\n fn create(c: char) -> Self {\n match c {\n 'C' => Color::C,\n 'Y' => Color::Y,\n 'M' => Color::M,\n _ => Color::U,\n }\n }\n}\n\npub fn main() {\n let input = get_input();\n let length = input.len();\n let mut unknowns = 0;\n let mut unknown_location = 0;\n //println!(\"{:?}\", input);\n if input[0] == Color::U {\n unknowns += 1;\n unknown_location = 0;\n }\n for i in 1..length {\n if input[i] == Color::U {\n unknowns += 1;\n unknown_location = i;\n } else if input[i] == input[i - 1] {\n println!(\"No\");\n return;\n }\n }\n //println!(\"{}\", unknowns);\n if unknowns == 0 {\n println!(\"No\");\n return;\n } else if unknowns >= 2 {\n println!(\"Yes\");\n return;\n } else {\n if unknown_location == 0 || unknown_location == length - 1 {\n println!(\"Yes\");\n return;\n } else if input[unknown_location + 1] == input[unknown_location - 1] {\n println!(\"Yes\");\n return;\n } else {\n println!(\"No\");\n return;\n }\n }\n println!(\"Yes\");\n}\n\nfn get_input() -> Vec {\n let mut input = String::new();\n io::stdin().read_line(&mut input);\n let mut input = String::new();\n io::stdin().read_line(&mut input);\n input.trim().chars().map(|c| Color::create(c)).collect()\n}\n", "lang": "Rust", "bug_code_uid": "ca5bf0f42c8fbea065c3026940d40c4b", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "apr_id": "ce788ce9f44c8793b28fae7a1b7d8b25", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9992542878448919, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::stdin;\nuse std::isize;\nfn main() {\n let (x,y) = parse_input();\n let abs_x = x.abs();\n let abs_y = y.abs();\n let a = abs_x+abs_y;\n if abs_x == x && abs_y == y{\n print(0,a ,a,0)\n }else if abs_x != x && abs_y !=y{\n print(-a,0,0,a)\n }else if abs_x !=x {\n print(-a,0,0,a)\n }else{\n print(0,-a,a,0)\n }\n}\nfn parse_input()->(isize,isize){\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n let v:Vec = input.trim().split_whitespace().map(|e| e.parse().unwrap()).collect();\n (v[0],v[1])\n}\nfn print(a:isize,b:isize,c:isize,d:isize){\n println!(\"{} {} {} {}\",a,b,c,d)\n}", "lang": "Rust", "bug_code_uid": "d4d89f1d4a59d74d75c726b5c8edb307", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "apr_id": "57d66e7244bcf333f870f3decfcf0a64", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9994054696789536, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "//! http://codeforces.com/contest/742/problem/A\n\n#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(isize);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\n// -----------------------------------------------------------------------------\n\nfn main() {\n scanln!(n: u32);\n if n == 0 { println!(\"1\"); }\n else {\n println!(\"{}\",\n match n % 4 {\n 1 => 8,\n 2 => 4,\n 3 => 2,\n 4 => 6,\n _ => unreachable!()\n }\n );\n }\n}\n", "lang": "Rust", "bug_code_uid": "a6c63b5425e10daf94bc3bdcda08b2ac", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "apr_id": "076a0e5b2038a4c7eadb0d2a20addd0a", "difficulty": 1000, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9809264305177112, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let n = input.i();\n println!(\"{}\", [6,8,4,2][(n % 4) as usize]);\n}\n\n", "lang": "Rust", "bug_code_uid": "6dd4b1c77a37bcea97d9be58ec24d324", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "apr_id": "a2e79768df7680b79c9f0447f025b446", "difficulty": 1000, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9151386713351147, "equal_cnt": 13, "replace_cnt": 9, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 12, "bug_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! vec_dim {\n\t([$d:expr]$($s:tt)+) => {vec![vec_dim!($($s)+);$d]}; (=$e:expr) => {$e};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: 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// Field (mod prime) {{{\nmod field {\n\tuse std::ops::*;\n\tconst P5: i32 = 1_000_000_007;\n\tconst P6: i64 = P5 as i64;\n\t#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Default)] pub struct Field(i32);\n\t#[allow(dead_code)] impl Field {\n\t\tpub fn new>(a: T) -> Self { Self(Self::cv(a)) }\n\t\tpub fn new_unchecked(a: i32) -> Self { Self(a) }\n\t\tfn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }\n\t\tfn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }\n\t\tfn cv>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }\n\t\tpub fn inv(self) -> Self { self.pow(P5-2) }\n\t\tpub fn pow>(self, b: T) -> Self {\n\t\t\tlet b = b.into(); if b == 0 { Self(1) } else {\n\t\t\t\tlet mut res = self.pow(b/2); res *= res; if b % 2 == 1 {res *= self;} res\n\t\t\t}\n\t\t}\n\t}\n\timpl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}\n\timpl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}\n\timpl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}\n\timpl Div for Field { type Output = Self; fn div(self, a: Self) -> Self::Output { self * a.inv() }}\n\timpl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}\n\timpl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }\n\timpl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }\n\timpl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }\n\timpl DivAssign for Field { fn div_assign(&mut self, a: Self) { *self = *self / a; } }\n\tuse std::fmt::{Display, Formatter, Result};\n\timpl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, \"{}\", self.0) } }\n}\nuse field::Field as Z;\n//}}}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tl!(r,g = rin.u());\n\tlet mut dp = vec![ (r,g,Z::new(1)) ];\n\tlet mut sum = dp[0].2;\n\tlet mut sol = sum;\n\tfor n in 1.. {\n\t\tif dp.len() == 0 {\n\t\t\tbreak;\n\t\t}\n\t\tsol = sum;\n\t\tlet mut dp1 = Vec::new();\n\t\tfor (r,g,v) in dp.drain(..) {\n\t\t\tif r >= n {\n\t\t\t\tdp1.push( (r-n,g,v) );\n\t\t\t}\n\t\t\tif g >= n {\n\t\t\t\tdp1.push( (r,g-n,v) );\n\t\t\t}\n\t\t}\n\t\tdp1.sort();\n\t\tlet mut last_r = r+1;\n\t\tsum = Z::new(0);\n\t\tfor (r,g,v) in dp1 {\n\t\t\tsum += v;\n\t\t\tif r == last_r {\n\t\t\t\tdp.last_mut().unwrap().2 += v;\n\t\t\t} else {\n\t\t\t\tlast_r = r;\n\t\t\t\tdp.push( (r,g,v) );\n\t\t\t}\n\t\t}\n\t}\n\twriteln!(rout, \"{}\", sol).ok();\n}\n", "lang": "Rust", "bug_code_uid": "4029d75826a670f45202777fac6f7ea4", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "apr_id": "07d4dc2a4cd41c70c32033f083100e3a", "difficulty": 2000, "tags": ["dp"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9747386759581882, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn find_min(m: usize, s: usize) -> String {\n let mut num = vec![0; m];\n num[0] = 1;\n let mut i = m - 1;\n let mut sum = 1;\n\n while sum + 9 < s {\n num[i] = 9;\n i -= 1;\n sum += 9;\n }\n\n num[i] += (s - sum) as u8;\n vec_to_num(&num)\n}\n\nfn find_max(m: usize, s: usize) -> String {\n let mut num = vec![9; m];\n let mut i = m - 1;\n let mut sum = 9 * m;\n\n while sum - 9 > s {\n num[i] = 0;\n i -= 1;\n sum -= 9;\n }\n\n num[i] -= (sum - s) as u8;\n vec_to_num(&num)\n}\n\nfn vec_to_num(v: &Vec) -> String {\n v.into_iter()\n .map(|digit| (digit + 48) as char)\n .collect::()\n}\n\nfn main() {\n let (m, s) = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let temp: Vec = buf\n .trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect();\n (temp[0], temp[1])\n };\n\n if s < 1 || s > 9 * m {\n println!(\"-1 -1\");\n } else {\n println!(\"{} {}\", find_min(m, s), find_max(m, s))\n }\n}", "lang": "Rust", "bug_code_uid": "6d39104489356a15b3c063c9a04e2c1d", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "261207d1686ba711353e320fee7c518c", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9962692135502164, "equal_cnt": 8, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "fn get_max_digits(length: usize, sum: u32) -> Option> {\n if length == 0 {\n return None;\n }\n if (sum == 0) && (length > 1) {\n return None;\n }\n if sum == 0 {\n return Some(vec![0]);\n }\n let mut result: Vec = Vec::with_capacity(length);\n let mut rest_sum: u32 = sum;\n let first_digit: u32;\n if rest_sum > 9 {\n first_digit = 9;\n } else {\n first_digit = rest_sum;\n }\n result.push(first_digit);\n rest_sum -= first_digit;\n\n for _ in 1..length {\n let digit: u32;\n if rest_sum > 9 {\n digit = 9;\n } else {\n digit = rest_sum;\n }\n result.push(digit);\n rest_sum -= digit;\n }\n\n if rest_sum == 0 {\n return Some(result);\n } else {\n return None;\n }\n}\n\nfn get_min_digits(length: usize, sum: u32) -> Option> {\n if (sum == 0) && (length > 1) {\n return None;\n }\n if sum == 0 {\n return Some(vec![0]);\n }\n let mut result: Vec = Vec::with_capacity(length);\n let mut rest_sum: u32 = sum - 1;\n\n for _ in 1..length {\n let digit: u32;\n if rest_sum > 9 {\n digit = 9;\n } else {\n digit = rest_sum;\n }\n result.push(digit);\n rest_sum -= digit;\n }\n\n if rest_sum >= 9 {\n return None;\n }\n\n let last_digit: u32 = rest_sum + 1;\n result.push(last_digit);\n\n result.reverse();\n return Some(result);\n}\n\n#[cfg(test)]\nmod tests {\n use super::{get_max_digits, get_min_digits};\n\n #[test]\n fn test1() {\n assert_eq!(get_max_digits(2, 15), Some(vec![9, 6]));\n assert_eq!(get_min_digits(2, 15), Some(vec![6, 9]));\n }\n #[test]\n fn test2() {\n assert_eq!(get_max_digits(3, 0), None);\n assert_eq!(get_min_digits(3, 0), None);\n }\n #[test]\n fn test3() {\n assert_eq!(get_max_digits(1, 0), Some(vec![0]));\n assert_eq!(get_min_digits(1, 0), Some(vec![0]));\n }\n #[test]\n fn test4() {\n assert_eq!(get_max_digits(1, 9), Some(vec![9]));\n assert_eq!(get_min_digits(1, 9), Some(vec![9]));\n }\n #[test]\n fn test5() {\n assert_eq!(get_max_digits(2, 12), Some(vec![9, 3]));\n assert_eq!(get_min_digits(2, 12), Some(vec![3, 9]));\n }\n}\n\nuse std::io::{stdin, stdout, BufRead, Write};\n\nfn main() {\n let stdin = stdin();\n let mut stdin_lock = stdin.lock();\n\n let stdout = stdout();\n let mut stdout_lock = stdout.lock();\n\n let mut input_str: String = String::new();\n stdin_lock.read_line(&mut input_str).unwrap();\n let mut input_tokens = input_str.trim().split_whitespace();\n let length: usize = input_tokens.next().unwrap().parse().unwrap();\n let sum: u32 = input_tokens.next().unwrap().parse().unwrap();\n\n if let Some(max_digits_array) = get_max_digits(length, sum) {\n for digit in max_digits_array {\n write!(stdout_lock, \"{}\", digit).unwrap();\n }\n } else {\n write!(stdout_lock, \"-1\").unwrap();\n }\n write!(stdout_lock, \" \").unwrap();\n\n if let Some(min_digits_array) = get_min_digits(length, sum) {\n for digit in min_digits_array {\n write!(stdout_lock, \"{}\", digit).unwrap();\n }\n } else {\n write!(stdout_lock, \"-1\").unwrap();\n }\n\n writeln!(stdout_lock, \"\").unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "01ec0ced0ac0f5833564d1ae80ef4dd9", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "7e54870e62b15fd31142bc432d6b13b4", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9915110356536503, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::cmp;\nuse std::process;\nfn main()\n{\n let mut s=String::new();\n io::stdin().read_line(&mut s).expect(\"read error\");\n let vec=s.split_whitespace()\n .map(|x|\n x.parse::().expect(\"parse error\"))\n .collect::>();\n if (vec[0]>1 && vec[1]<1) || (vec[0]*90\n {\n n1=n1-1;\n let x:i64=cmp::min(9,n2);\n n2-=x;\n ans1+=&x.to_string();\n }\n n1=vec[0];\n n2=vec[1];\n while n1>0{\n n1=n1-1;\n let mut x:i64=0;\n if n1==vec[0]-1{\n x=1;\n }\n x=cmp::max(x,n2-9*n1);\n n2-=x;\n ans2+=&x.to_string();\n }\n println!(\"{} {}\",ans2,ans1);\n}", "lang": "Rust", "bug_code_uid": "adb3eaec08ad5650bdf9a3805f8acef6", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "e30efa0b7b45a6abb76859cbbc3a3a83", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9795817958179582, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "fn main() -> Result<(), Box> {\n let data = read_input();\n let (len, sum) = (data[0], data[1]);\n\n if 9 * len < sum {\n println!(\"-1 -1\");\n return Ok(());\n }\n\n if sum == 0 {\n println!(\"0 0\");\n return Ok(());\n }\n\n if sum == 1 {\n let mut ans = String::with_capacity(len);\n ans.push('1');\n \n for _ in 1..len {\n ans.push('0');\n }\n println!(\"{} {}\", ans, ans);\n return Ok(());\n }\n\n if (sum >= 1 && sum <= 9) && (len == 1) {\n println!(\"{} {}\", sum, sum);\n return Ok(());\n }\n\n if sum % 9 == 0 && sum / 9 == len {\n let mut ans = String::with_capacity(len);\n for _ in 0..len {\n ans.push('9')\n }\n println!(\"{} {}\", ans, ans);\n return Ok(());\n }\n\n let mut digits = vec![0; len];\n let mut max_digits = vec![0; len];\n \n let nines = sum / 9;\n let rem = sum % 9;\n\n let start = len - nines;\n for i in (start..len).rev() {\n digits[i] = 9;\n }\n\n if len - nines > 1 {\n if rem > 0 {\n digits[start - 1] = rem - 1;\n digits[0] = 1;\n } else {\n digits[start] -= 1;\n digits[0] = 1;\n }\n } else {\n if rem > 0 {\n digits[0] = rem;\n } else {\n digits[start] -= 1;\n digits[0] = 1;\n }\n }\n\n for i in 0..nines {\n max_digits[i] = 9;\n }\n if rem != 0 {\n max_digits[nines] = rem;\n }\n\n for d in digits {\n print!(\"{}\", d);\n }\n print!(\" \");\n\n for d in max_digits {\n print!(\"{}\", d);\n }\n println!();\n\n Ok(())\n}\n\nfn read_input() -> Vec {\n let mut buffer = String::new();\n\n std::io::stdin()\n .read_line(&mut buffer)\n .expect(\"Failed to get input\");\n\n buffer\n .trim()\n .split_whitespace()\n .map(|x| x.parse().expect(\"Failed to parse number\"))\n .collect()\n}\n", "lang": "Rust", "bug_code_uid": "c413040ed9998c7af981cd4d72293c47", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "e2b77aaa68c5d3c8a35377b661e05c47", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.984660766961652, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "// https://codeforces.com/problemset/problem/489/C\nuse std::io;\nuse std::char;\n\nfn reverse(cadena: &String) -> String {\n let mut ans = String::from(\"\");\n for ch in cadena.chars().rev() {\n ans.push(ch);\n }\n ans\n}\n\nfn main() {\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let words: Vec =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let m = words[0] as usize;\n let mut s = words[1];\n let mut _t = words[1];\n\n if s == 0 && m != 1 {\n println!(\"-1 -1\");\n return;\n }\n\n if s == 0 && m == 1 {\n println!(\"0 0\");\n return;\n }\n\n // lets construct maxima\n let mut maxima = String::from(\"\");\n\n while s > 0 {\n if s >= 9 {\n maxima = format!(\"9{}\", maxima);\n s -= 9;\n } else {\n maxima = format!(\"{}{}\", maxima, s);\n s -= s;\n }\n }\n \n if maxima.len() > m {\n maxima = String::from(\"-1\");\n }\n\n while maxima.len() < m {\n maxima = format!(\"{}0\", maxima);\n }\n\n // lets construct minima\n let mut chars: Vec = reverse(&maxima).chars().collect();\n let mut minima = String::from(\"\");\n\n if chars[0] == '0' {\n chars[0] = '1';\n for i in 1..chars.len() {\n if chars[i] != '0' {\n chars[i] = char::from_digit(chars[i].to_digit(10).unwrap()-1,10).unwrap();\n break;\n }\n }\n }\n\n for ch in chars {\n minima.push(ch);\n }\n\n if maxima == \"-1\" {\n minima = String::from(\"-1\");\n }\n\n println!(\"{} {}\", minima, maxima);\n}\n\n", "lang": "Rust", "bug_code_uid": "472aa3904b679fb68a9a605e67e37035", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "da543f6b3dcee1eae18515c3caf8ec68", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6377708978328174, "equal_cnt": 7, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 6, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let m: isize = scan.next();\n let s: isize = scan.next();\n let nnines = s / 9;\n let last = s % 9;\n if nnines > m || nnines == m && last != 0 || m>1 && s == 0 {\n println!(\"-1 -1\");\n } else if m == 1 && s == 0 {\n println!(\"0 0\");\n } else if m == 1 {\n println!(\"{} {}\", s, s);\n } else if nnines == m {\n let sol = format!(\"{}\", \"9\".repeat(nnines as usize));\n println!(\"{} {}\", sol, sol);\n } else {\n let sol_max = format!(\"{}{}{}\", \"9\".repeat(nnines as usize), last,\n \"0\".repeat((m -nnines -1).max(0) as usize));\n let mut sol_min: String = String::new();\n if nnines == 0 {\n sol_min = format!(\"1{}{}\",\"0\".repeat((m - 2).max(0) as usize ), last-1);\n } else {\n if last == 0 {\n sol_min = format!(\"1{}8{}\", \"0\".repeat((m -nnines -1).max(0) as usize),\n \"9\".repeat((nnines -1).max(0) as usize));\n } else {\n sol_min = format!(\"{}{}{}\", last, \n \"0\".repeat((m -nnines -1).max(0) as usize),\n \"9\".repeat(nnines as usize));\n }\n }\n println!(\"{} {}\", sol_min, sol_max);\n }\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n\n", "lang": "Rust", "bug_code_uid": "41ec4950458e78c6338bff76c67245aa", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "a30d1421c3929e57689d1a3316c7e3df", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9976359338061466, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\n\nfn read_line(buf: &mut String) {\n buf.clear();\n match io::stdin().read_line(buf) {\n Err(error) => println!(\"error! {}\",error),\n _ => {}\n }\n}\n\nfn is_valid(m: i32, n: i32) -> bool {\n if n==0 || n>9*m {\n return false;\n }\n return true;\n}\nfn get_max(m:i32,n:i32) {\n let mut max = Vec::::new();\n max.reserve(m as usize);\n for _ in 0..m {\n max.push(0);\n }\n let mut n_copy = n;\n for index in 0..m {\n if n_copy > 9 {\n max[index as usize]+=9;\n n_copy -= 9;\n }\n else {\n max[index as usize]+= n_copy as u8;\n break;\n }\n }\n print!(\" \");\n for x in max {\n print!(\"{}\",x);\n }\n println!(\"\");\n\n}\nfn get_min(m:i32, n:i32) {\n let mut min = Vec::::new();\n min.reserve(m as usize);\n min.push(1);\n for _ in 1..m {\n min.push(0);\n }\n let mut n_copy = n-1;\n for index in (0..(m)).rev() {\n if n_copy > 9 {\n min[index as usize]+=9;\n n_copy -= 9;\n }\n else {\n min[index as usize]+= n_copy as u8;\n break;\n }\n }\n for x in min {\n print!(\"{}\",x);\n }\n\n}\n\nfn main() {\n let mut buf : String = String::new();\n read_line(&mut buf);\n let mut string_iter = buf.trim().split_whitespace();\n let m = string_iter.next().unwrap().parse::().unwrap();\n let n = string_iter.next().unwrap().parse::().unwrap();\n\n if !is_valid(m,n) {\n if m==0 {\n println!(\"0 0\");\n }\n else{\n println!(\"-1 -1\");\n }\n }\n else {\n get_min(m,n);\n get_max(m,n);\n }\n}\n", "lang": "Rust", "bug_code_uid": "a2b3870823cfc87d1174043fe5db3513", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "09bcf17cdaf46245eb5d7926567fdd36", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9290554005579912, "equal_cnt": 11, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 7, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\nuse std::io::Stdin;\nuse std::str::FromStr;\n\nfn read_line(stdin : &Stdin, line : &mut String) {\n match stdin.read_line(line) {\n Ok(_) => return,\n Err(msg) => panic!(\"Could not read line! Message: {}.\", msg),\n }\n}\n\nfn parse_t(s : &str) -> T {\n match s.trim().parse() {\n Ok(y) => y,\n Err(_) => panic!(\"Could not read from string!\"),\n }\n}\n\nfn read_ts(stdin : &Stdin, ts : &mut Vec) {\n let mut line = String::new();\n read_line(stdin, &mut line);\n let word_iter = line.split_whitespace();\n for word in word_iter {\n let x = parse_t(word);\n ts.push(x);\n }\n}\n\nfn max_num_with_m_digits_and_digit_sum(m : usize, s : usize, max_num : &mut Vec) {\n if s == 0 {\n if m == 1 {\n max_num.push(0);\n } else {\n // Do nothing ...\n }\n } else {\n let mut cur_sum = 0;\n for _ in 0 .. m {\n let diff = s - cur_sum; \n if diff >= 9 {\n max_num.push(9);\n cur_sum = cur_sum + 9;\n } else {\n max_num.push(diff as u8);\n cur_sum = cur_sum + diff;\n }\n }\n }\n}\n\nfn min_num_with_m_digits_and_digit_sum(m : usize, max_num : &mut Vec) {\n if max_num.is_empty() {\n // Do nothing ...\n } else {\n max_num.reverse();\n if max_num[0] == 0 {\n if m == 1 {\n // Do nothing ...\n } else {\n max_num[0] = 1;\n for i in 1 .. m {\n if max_num[i] == 0 {\n // Do nothing ...\n } else {\n max_num[i] = max_num[i] - 1;\n break;\n }\n }\n }\n }\n }\n}\n\nfn print_vec(v : &Vec) {\n for &x in v.iter() {\n print!(\"{}\", x);\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut m_s = vec![];\n read_ts(&stdin, &mut m_s);\n let m = m_s[0];\n let s = m_s[1];\n let mut max_num = vec![];\n max_num_with_m_digits_and_digit_sum(m, s, &mut max_num);\n if max_num.is_empty() {\n println!(\"-1 -1\");\n } else {\n let mut max_num_copy = max_num.to_vec();\n min_num_with_m_digits_and_digit_sum(m, &mut max_num_copy);\n print_vec(&max_num_copy);\n print!(\" \");\n print_vec(&max_num);\n println!();\n }\n}", "lang": "Rust", "bug_code_uid": "6bbecea2e81d3edf422d79ac87a5598b", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "66556ede020b474be9d1d0f980c41d99", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8673395818312906, "equal_cnt": 9, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_source_code": "fn solve() {\n let (m, s): (i32, i32) = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let mut ws = buf.split_whitespace();\n let m = ws.next().unwrap().parse().unwrap();\n let s = ws.next().unwrap().parse().unwrap();\n (m, s)\n };\n\n let check = |m: i32, s: i32| (s >= 0) && s <= 9 * m;\n\n let mut ans = String::new();\n let mut sum = s;\n for i in 0..m {\n for d in 0..10 {\n if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {\n sum -= d;\n ans.push_str(&d.to_string());\n break;\n }\n }\n }\n\n ans.push(' ');\n sum = s;\n for i in 0..m {\n for d in (0..10).rev() {\n if (i > 0 || d > 0 || (m == 1 && d == 0)) && check(m - i - 1, sum - d) {\n sum -= d;\n ans.push_str(&d.to_string());\n break;\n }\n }\n }\n\n if ans.chars().next().unwrap() == '0' {\n println!(\"-1 -1\");\n return;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n // let t: u32 = {\n // let mut buf = String::new();\n // std::io::stdin().read_line(&mut buf).unwrap();\n // buf.trim_end().parse().unwrap()\n // };\n\n // for _ in 0..t {}\n solve();\n}\n", "lang": "Rust", "bug_code_uid": "31e84dc7579e6b5c7b64bd9d22148599", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "9ff214af40bdc95d2b7726443dc4fffd", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9928301886792453, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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\n\nfn main() {\n let stdin = stdin();\n let mut s = stdin.lock();\n let (m, s) = scan!(s, usize, i64);\n let mut smallest = vec![0; m];\n let mut largest = vec![0; m];\n let lower_bound = if m == 1 { 0 } else { 1 };\n let upper_bound = (9*m).num();\n\n if s >= lower_bound && s <= upper_bound {\n let mut temp = s;\n for i in 0..m {\n if temp > 9 {\n largest[i] = 9;\n temp -= 9;\n } else {\n largest[i] = temp;\n break;\n }\n }\n\n temp = s;\n for i in (0..m).rev() {\n if temp > 9 {\n smallest[i] = 9;\n temp -= 9;\n } else {\n smallest[i] = temp;\n break;\n }\n }\n\n let mut flag = false;\n for i in 0..m {\n if smallest[i] != 0 || flag {\n flag = true;\n print!(\"{}\", smallest[i]);\n } \n }\n if !flag {\n print!(\"0\");\n }\n print!(\" \");\n\n flag = false;\n for i in 0..m {\n if largest[i] != 0 || flag {\n flag = true;\n print!(\"{}\", largest[i]);\n }\n }\n if !flag {\n print!(\"0\");\n }\n } else {\n println!(\"-1 -1\");\n }\n}", "lang": "Rust", "bug_code_uid": "0fc19434c10061e316d690ddfbcda099", "src_uid": "75d062cece5a2402920d6706c655cad7", "apr_id": "a221795fad0a16e4af14f82299269fc8", "difficulty": 1400, "tags": ["dp", "greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9891891891891892, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n#[allow(unused_imports)]\nuse std::collections::{HashMap,HashSet,VecDeque};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let (a,b,s) = readln!(i32,i32,i32);\n println!(\"{}\", if s >= a+b && ((s-(a+b))%2) == 0 { \"Yes\" } else { \"No\" });\n}\n", "lang": "Rust", "bug_code_uid": "96ad0dd2bd0e46b8416efc7b44d1937f", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "apr_id": "a23de35e8b3960b5263f65163dd95708", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9661266568483063, "equal_cnt": 8, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_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 let s: usize = scan.next();\n let result: bool = s >= (a + b) && (s - (a + b)) % 2 == 0;\n println!(\"{}\", if result { \"Yes\" } else { \"No\" });\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": "Rust", "bug_code_uid": "86a3d0ab78936df37619ecb6890ec668", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "apr_id": "dd24ac86518b9e88dce6a353f9cb449d", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9980372914622179, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nconst LETTERS: &str = \"abcdefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ\";\n\nfn main() {\n let mut x = String::new();\n\n io::stdin().read_line(&mut x).expect(\"error\");\n\n let lenght = x.len();\n\n if lenght >= 1 && lenght <= 100 {\n\n let mut _z = 0;\n\n let mut _upper = 0;\n let mut _down = 0;\n\n for y in x.trim().as_bytes() {\n\n for z in LETTERS.as_bytes() {\n if z.eq_ignore_ascii_case(&y) {\n _z += 1;\n }\n }\n\n if _z > 0 {\n _z = 0;\n } else {\n panic!(\"phrase contains non-latin characters\");\n }\n\n if y.is_ascii_uppercase() {\n _upper += 1;\n } else if y.is_ascii_lowercase() {\n _down += 1;\n }\n\n }\n\n if _upper < _down || _upper == _down {\n println!(\"{}\", x.to_lowercase());\n } else {\n println!(\"{}\", x.to_uppercase());\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "43c6fab0b5770cc341c8330b777bea1e", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "apr_id": "f0ab5c8ef13e85d27e4ae93f9520e2d1", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.850909090909091, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let mut buf = String::new();\n let _ = stdin().read_line(&mut buf);\n let (mut l, mut h) = (0, 0);\n for i in buf.trim_end().as_bytes() {\n if *i >= 65 && *i <= 91 {\n h += 1;\n } else {\n l += 1;\n }\n }\n if l == h {\n println!(\"{}\", buf.to_lowercase());\n } else {\n println!(\"{}\", buf.to_uppercase());\n }\n}\n", "lang": "Rust", "bug_code_uid": "61d3e2d2a1e7e266f743b0cc44b5925b", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "apr_id": "1399a155b2f7053cf400202981bd31c5", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999322951929587, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::io::{Error, ErrorKind};\nuse std::str::FromStr;\n\nstruct IO {\n buffer: Vec\n}\n\nimpl IO {\n fn new() -> IO {\n IO { buffer: Vec::new() }\n }\n /*\n pub fn reset(&mut self) {\n self.buffer = Vec::new();\n }\n */\n\n fn try_parse(s: String) -> Result \n where T: FromStr {\n let res = (&s).parse::()?;\n Ok(res)\n }\n\n fn receive(&mut self) -> Result \n where T: FromStr {\n let ref mut stdio = &mut io::stdin();\n if let Some(s) = self.buffer.pop() {\n return match IO::try_parse::(s) {\n Ok(value) => Ok(value),\n _ => Err(Error::new(ErrorKind::Other, \"cannot parse to desired type\"))\n }\n }\n\n let mut input = String::new();\n if let Err(error) = stdio.read_line(&mut input) {\n return Err(error)\n }\n\n input = input.trim().to_string();\n\n self.buffer.extend:: >(input.split(' ').map(|s| s.to_string()).collect());\n\n return self.receive::()\n }\n}\n\nfn main() {\n let mut sio = IO::new();\n let s = sio.receive::().unwrap();\n let q = s.bytes().collect:: >();\n let mut diff = 0;\n for i in 0..s.len() {\n if q[i] != q[s.len() - 1 - i] {\n diff += 1;\n }\n }\n if diff == 2 || (diff == 1 && s.len() % 2 == 1){\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang": "Rust", "bug_code_uid": "aee6584baf641aa505b9d10b42d9cb61", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "apr_id": "aca9f0340a29263222277ffb9869eac6", "difficulty": 1000, "tags": ["brute force", "constructive algorithms", "strings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9487388120423108, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 5, "bug_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 input: Vec = scan.next::().chars().collect();\n let mut changes = 0;\n for i in 0..(input.len() / 2) {\n if input[i] != input[input.len() - i - 1] {\n changes += 1;\n if changes > 1 {\n println!(\"NO\");\n return;\n }\n }\n }\n println!(\"{}\", if changes == 1 { \"YES\" } else { \"NO\" });\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": "Rust", "bug_code_uid": "7867109faf148e77c9a1e1a8dd2eaf3e", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "apr_id": "757da573377a12c4776e72f4e1afdedd", "difficulty": 1000, "tags": ["brute force", "constructive algorithms", "strings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9953531598513011, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{Read, stdin};\n\nfn main() {\n let mut buf = String::new();\n stdin().read_to_string(&mut buf).unwrap();\n let mut tok = buf.split_whitespace();\n let mut get = || tok.next().unwrap();\n macro_rules! get {\n ($t:ty) => (get().parse::<$t>().unwrap());\n () => (get!(usize));\n }\n \n let _n = get!();\n let k = get!();\n let s = get().as_bytes();\n let mut xs = vec![false; 30];\n for &ch in s {\n xs[ch as usize - b'a' as usize] = true;\n }\n let xs: Vec<_> = xs\n .into_iter()\n .enumerate()\n .filter(|(_, v)| *v)\n .collect();\n \n if k * 2 > 26 || xs.len() < k {\n println!(\"-1\");\n return;\n }\n \n let mut ans = 0;\n let mut b = xs.len();\n let mut c = 0;\n for (i, _) in xs.iter() {\n let i = *i;\n if b + 1 != i {\n ans += i + 1;\n b = i;\n c += 1;\n if c >= k {\n break;\n }\n }\n }\n if c < k {\n println!(\"-1\");\n } else {\n println!(\"{}\", ans);\n }\n \n}", "lang": "Rust", "bug_code_uid": "9291e04bc0539517750d581e5b671980", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "apr_id": "f6579b7646397b44b50550bcf36e62ef", "difficulty": 900, "tags": ["greedy", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6527554842161584, "equal_cnt": 19, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 12, "fix_ops_cnt": 19, "bug_source_code": "fn count_ways(n: usize) -> usize {\n let mut dynamic = vec![vec![0; 4]; n + 1];\n dynamic[1] = vec![1usize; 4];\n *dynamic[1].last_mut().unwrap() = 0;\n \n for step_count in 2..=n {\n for vertex_id in 0..=3 {\n for neighbor_id in (0..=3).filter(|&x| x != vertex_id) {\n dynamic[step_count][vertex_id] += dynamic[step_count - 1][neighbor_id];\n }\n dynamic[step_count] %= 1000000007;\n }\n }\n *dynamic.last().unwrap().last().unwrap()\n}\n\n\nfn main() {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let n = buf.trim().parse::().unwrap();\n println!(\"{}\", count_ways(n));\n}", "lang": "Rust", "bug_code_uid": "8547e8d04b320c3c0654990d812e0fb2", "src_uid": "77627cc366a22e38da412c3231ac91a8", "apr_id": "da031b8a5e0ab47b39db964fda05c930", "difficulty": 1500, "tags": ["matrices", "dp", "math"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.4457831325301205, "equal_cnt": 10, "replace_cnt": 7, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 10, "bug_source_code": "use std::cmp::min;\nuse std::io::stdin;\n\nfn main() {\n let (a, b) = {\n let mut buf = String::new();\n stdin().read_line(&mut buf).expect(\"Failed to read\");\n let nums: Vec = buf\n .trim()\n .split_ascii_whitespace()\n .map(|c| c.parse().unwrap())\n .collect();\n (nums[0], nums[1])\n };\n let (k, j) = {\n let mut i = b;\n let mut j = 0;\n while i % 2 == 0 {\n i /= 2;\n j += 1;\n }\n (i, j)\n };\n if a >= k {\n println!(\"{}\", a - k + j);\n } else {\n let mut moves = 0;\n let mut a = a;\n while k > 2 * a {\n moves += 1;\n a *= 2;\n }\n let type_a = 2 * a - k + 1;\n let type_b = (2 * a - k - 1) / 2 + 2;\n println!(\"{}\", moves + min(type_a, type_b) + j);\n }\n // if a > b {\n // println!(\"{}\", a - b);\n // } else {\n // let k = {\n // let mut i = b;\n // while i % 2 == 0 {\n // i /= 2;\n // }\n // i\n // };\n // let mut moves = 0;\n // let mut a = a;\n // while k > 2 * a {\n // a *= 2;\n // moves += 1;\n // }\n // let type_a = 2 * a - k + 1;\n // let type_b = (2 * a - k - 1) / 2 + 2;\n // println!(\"{}\", moves + min(type_a, type_b) + (b / k - 1));\n}\n", "lang": "Rust", "bug_code_uid": "41d51a2ab3fb18c0b8de039c81b68caf", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "b862acc580067b7adc6bcdd357839f36", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.973404255319149, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 12, "bug_source_code": "#![allow(unused_parens)]\n#![allow(unused_imports)]\n#![allow(non_upper_case_globals)]\n#![allow(non_snake_case)]\n#![allow(unused_mut)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\n#[allow(unused_macros)]\nmacro_rules! invec {\n ( $ t : ty ) => {{\n let mut s = String::new();\n match std::io::stdin().read_line(&mut s) {\n Ok(0) => Vec::<$t>::new(),\n Ok(n) => s\n .trim()\n .split_whitespace()\n .map(|s| s.parse::<$t>().unwrap())\n .collect::>(),\n Err(_) => Vec::<$t>::new(),\n }\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n ($t:ty ;; $n:expr) => {\n (0..$n).map(|_| get!($t ;;)).collect::>()\n };\n}\n\n#[allow(unused_macros)]\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 mut 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\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($next:expr, [$t:tt]) => {\n {\n let len = read_value!($next, usize);\n (0..len).map(|_| read_value!($next, $t)).collect::>()\n }\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\n#[cfg(debug_assertions)]\nmacro_rules! mydbg {\n //($arg:expr) => (dbg!($arg))\n //($arg:expr) => (println!(\"{:?}\",$arg));\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n#[cfg(not(debug_assertions))]\nmacro_rules! mydbg {\n ($($arg:expr),*) => {};\n}\n\nmacro_rules! echo {\n ($($a:expr),*) => {\n $(println!(\"{}\",$a))*\n }\n}\n\nuse std::cmp::*;\nuse std::collections::*;\nuse std::ops::{Add, Div, Mul, Sub};\n\n#[allow(dead_code)]\nstatic INF_I64: i64 = i64::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_I32: i32 = i32::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_USIZE: usize = usize::max_value() / 2;\n#[allow(dead_code)]\nstatic M_O_D: usize = 1000000007;\n#[allow(dead_code)]\nstatic PAI: f64 = 3.1415926535897932;\n\ntrait IteratorExt: Iterator {\n fn toVec(self) -> Vec;\n}\n\nimpl IteratorExt for T {\n fn toVec(self) -> Vec {\n self.collect()\n }\n}\n\ntrait CharExt {\n fn toNum(&self) -> usize;\n fn toAlphabetIndex(&self) -> usize;\n fn toNumIndex(&self) -> usize;\n}\nimpl CharExt for char {\n fn toNum(&self) -> usize {\n return *self as usize;\n }\n fn toAlphabetIndex(&self) -> usize {\n return self.toNum() - 'a' as usize;\n }\n fn toNumIndex(&self) -> usize {\n return self.toNum() - '0' as usize;\n }\n}\n\ntrait VectorExt {\n fn joinToString(&self, s: &str) -> String;\n}\nimpl VectorExt for Vec {\n fn joinToString(&self, s: &str) -> String {\n return self\n .iter()\n .map(|x| x.to_string())\n .collect::>()\n .join(s);\n }\n}\n\ntrait StringExt {\n fn get_reverse(&self) -> String;\n}\nimpl StringExt for String {\n fn get_reverse(&self) -> String {\n self.chars().rev().collect::()\n }\n}\n\ntrait UsizeExt {\n fn pow(&self, n: usize) -> usize;\n}\nimpl UsizeExt for usize {\n fn pow(&self, n: usize) -> usize {\n return ((*self as u64).pow(n as u32)) as usize;\n }\n}\n\nfn main() {\n let (n, m) = get!(usize, usize);\n let mut ans = INF_USIZE;\n let mut kouho = VecDeque::new();\n let n = 99;\n let m = 100;\n kouho.push_back((n, 0));\n while !kouho.is_empty() {\n let (a, depth) = kouho.pop_front().unwrap();\n mydbg!(a);\n if a == m {\n echo!(depth);\n return;\n }\n if a - 1 != 0 {\n kouho.push_back((a - 1, depth + 1));\n }\n if a * 2 < m * 3 {\n kouho.push_back((a * 2, depth + 1));\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "79ce119c15b4da8762bf60aa599df8a4", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "e934e5afbb9f5e63a8b88a3fd3e099a9", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9757520206649446, "equal_cnt": 10, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 10, "bug_source_code": "#![allow(unused_parens)]\n#![allow(unused_imports)]\n#![allow(non_upper_case_globals)]\n#![allow(non_snake_case)]\n#![allow(unused_mut)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\n#[allow(unused_macros)]\nmacro_rules! invec {\n ( $ t : ty ) => {{\n let mut s = String::new();\n match std::io::stdin().read_line(&mut s) {\n Ok(0) => Vec::<$t>::new(),\n Ok(n) => s\n .trim()\n .split_whitespace()\n .map(|s| s.parse::<$t>().unwrap())\n .collect::>(),\n Err(_) => Vec::<$t>::new(),\n }\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n ($t:ty ;; $n:expr) => {\n (0..$n).map(|_| get!($t ;;)).collect::>()\n };\n}\n\n#[allow(unused_macros)]\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 mut 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\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($next:expr, [$t:tt]) => {\n {\n let len = read_value!($next, usize);\n (0..len).map(|_| read_value!($next, $t)).collect::>()\n }\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\n#[cfg(debug_assertions)]\nmacro_rules! mydbg {\n //($arg:expr) => (dbg!($arg))\n //($arg:expr) => (println!(\"{:?}\",$arg));\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n#[cfg(not(debug_assertions))]\nmacro_rules! mydbg {\n ($($arg:expr),*) => {};\n}\n\nmacro_rules! echo {\n ($($a:expr),*) => {\n $(println!(\"{}\",$a))*\n }\n}\n\nuse std::cmp::*;\nuse std::collections::*;\nuse std::ops::{Add, Div, Mul, Sub};\n\n#[allow(dead_code)]\nstatic INF_I64: i64 = i64::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_I32: i32 = i32::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_USIZE: usize = usize::max_value() / 2;\n#[allow(dead_code)]\nstatic M_O_D: usize = 1000000007;\n#[allow(dead_code)]\nstatic PAI: f64 = 3.1415926535897932;\n\ntrait IteratorExt: Iterator {\n fn toVec(self) -> Vec;\n}\n\nimpl IteratorExt for T {\n fn toVec(self) -> Vec {\n self.collect()\n }\n}\n\ntrait CharExt {\n fn toNum(&self) -> usize;\n fn toAlphabetIndex(&self) -> usize;\n fn toNumIndex(&self) -> usize;\n}\nimpl CharExt for char {\n fn toNum(&self) -> usize {\n return *self as usize;\n }\n fn toAlphabetIndex(&self) -> usize {\n return self.toNum() - 'a' as usize;\n }\n fn toNumIndex(&self) -> usize {\n return self.toNum() - '0' as usize;\n }\n}\n\ntrait VectorExt {\n fn joinToString(&self, s: &str) -> String;\n}\nimpl VectorExt for Vec {\n fn joinToString(&self, s: &str) -> String {\n return self\n .iter()\n .map(|x| x.to_string())\n .collect::>()\n .join(s);\n }\n}\n\ntrait StringExt {\n fn get_reverse(&self) -> String;\n}\nimpl StringExt for String {\n fn get_reverse(&self) -> String {\n self.chars().rev().collect::()\n }\n}\n\ntrait UsizeExt {\n fn pow(&self, n: usize) -> usize;\n}\nimpl UsizeExt for usize {\n fn pow(&self, n: usize) -> usize {\n return ((*self as u64).pow(n as u32)) as usize;\n }\n}\n\nfn main() {\n let (n, m) = get!(usize, usize);\n let mut ans = INF_USIZE;\n let mut kouho = VecDeque::new();\n kouho.push_back((n, 0));\n while !kouho.is_empty() {\n let (a, depth) = kouho.pop_front().unwrap();\n //mydbg!(a);\n if a == m {\n echo!(depth);\n return;\n }\n if a - 1 != 0 {\n kouho.push_back((a - 1, depth + 1));\n }\n if a * 2 < m * 2 {\n kouho.push_back((a * 2, depth + 1));\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "0e2c900dd7c7ed5e27fcd64a8ad38df3", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "e934e5afbb9f5e63a8b88a3fd3e099a9", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9916483516483516, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let (n,m) = readln!(i32,i32);\n let mut x = m;\n let mut res = 0;\n while x>n {\n if x%2 == 1 {\n res += 1;\n }\n res += 1;\n x /= 2;\n }\n res += n-x;\n println!(\"{}\",res);\n}\n", "lang": "Rust", "bug_code_uid": "41dbbfce2c7461fa1503534f18fefce9", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "ba06b7f3187e8cb39f964b66c0a29b7a", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.5712338104976141, "equal_cnt": 13, "replace_cnt": 7, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 12, "bug_source_code": "// https://codeforces.com/problemset/problem/520/B\nuse std::io;\n\nfn main() {\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let words: Vec =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let mut n = words[0];\n let m = words[1];\n\n let mut j = 1;\n\n while 2*n < m {\n j += 1;\n n = 2*n;\n }\n\n j -= 1;\n\n println!(\"{}\", j+i64::abs(m-n));\n}\n\n", "lang": "Rust", "bug_code_uid": "33bf7cbfddd3d6de9698676f8462ed86", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "4909446e7d8a6234962c3a6c96046600", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9989806320081549, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "// https://codeforces.com/problemset/problem/520/B\nuse std::io;\nuse std::collections::VecDeque;\n\nfn main() {\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let words: Vec =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let n = words[0];\n let m = words[1];\n\n let mut distance = [1<<30;10005];\n distance[n as usize] = 0;\n\n let mut q = VecDeque::::new();\n q.push_back(n);\n\n while !q.is_empty() {\n let u = q.pop_front().unwrap();\n let v = (2*u) as usize;\n let x = (u-1) as usize;\n\n\n if distance[v] == 1<<30 && (v as i64) < 2*m {\n distance[v] = distance[u as usize] + 1;\n q.push_back(v as i64);\n }\n\n if distance[x] == 1<<30 && x > 0 {\n distance[x] = distance[u as usize] + 1;\n q.push_back(u-1);\n }\n }\n println!(\"{}\", distance[m as usize]);\n}\n\n", "lang": "Rust", "bug_code_uid": "79569a503adf862bdcc8be1ef5d8b100", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "4909446e7d8a6234962c3a6c96046600", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6086021505376344, "equal_cnt": 12, "replace_cnt": 5, "delete_cnt": 3, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n}\n\nfn dfs_moves(acc: usize, current: usize, goal: usize, visited: &mut [bool;20000]) -> usize {\n if visited[current] { return std::usize::MAX; }\n visited[current] = true;\n if current >= goal {\n return acc + current - goal;\n }\n let mut result = dfs_moves(acc + 1, current*2, goal, visited);\n if current > 1 {\n let decr_move = dfs_moves(acc + 1, current-1, goal, visited); \n result = result.min(decr_move);\n }\n result\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let n: usize = scan.next();\n let m: usize = scan.next();\n if m<= n {\n println!(\"{}\", n - m);\n return;\n }\n let mut seen = [false; 20000];\n let result = dfs_moves(0, n, m, &mut seen);\n println!(\"{}\", result);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "fe8f62dc047bb5708d7640d145472884", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "810be5c3207457b11db84f0a1dc25d62", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6288848263254113, "equal_cnt": 10, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 9, "bug_source_code": "fn solve() {\n let (n, m): (usize, usize) = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let mut ws = buf.split_whitespace();\n let n = ws.next().unwrap().parse().unwrap();\n let m = ws.next().unwrap().parse().unwrap();\n (n, m)\n };\n\n let mut dp = vec![100000; 10010];\n dp[n] = 0;\n for i in 0..n {\n dp[i] = n as i32 - i as i32;\n }\n\n for i in (n + 1)..10000 {\n if i % 2 == 0 {\n dp[i] = dp[i / 2] + 1;\n }\n }\n\n for i in (0..10000).rev() {\n dp[i] = dp[i].min(dp[i + 1] + 1);\n }\n\n println!(\"{}\", dp[m]);\n}\n\nfn main() {\n // let t: u32 = {\n // let mut buf = String::new();\n // std::io::stdin().read_line(&mut buf).unwrap();\n // buf.trim_end().parse().unwrap()\n // };\n\n // for _ in 0..t {}\n solve();\n}\n", "lang": "Rust", "bug_code_uid": "e568f1cb6d01d189351cf25fae27d64d", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "dcdbbea6956bb2ef70bfeffe42ca7448", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6131471785922048, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "fn solve() {\n let (n, m): (i32, i32) = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let mut ws = buf.split_whitespace();\n let n = ws.next().unwrap().parse().unwrap();\n let m = ws.next().unwrap().parse().unwrap();\n (n, m)\n };\n\n println!(\"{}\", bfs(n, m));\n}\n\nfn bfs(n: i32, m: i32) -> i32 {\n let mut q = std::collections::VecDeque::new();\n\n q.push_back((n, 0));\n while !q.is_empty() {\n let x = q.pop_front().unwrap();\n if x.0 == m {\n return x.1;\n }\n if x.0 < 0 {\n continue;\n }\n q.push_back((x.0 - 1, x.1 + 1));\n q.push_back((x.0 * 2, x.1 + 1));\n }\n\n 1\n}\n\nfn main() {\n // let t: u32 = {\n // let mut buf = String::new();\n // std::io::stdin().read_line(&mut buf).unwrap();\n // buf.trim_end().parse().unwrap()\n // };\n\n // for _ in 0..t {}\n solve();\n}\n", "lang": "Rust", "bug_code_uid": "548c202e451fc2e28264250c2fffe1b4", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "apr_id": "dcdbbea6956bb2ef70bfeffe42ca7448", "difficulty": 1400, "tags": ["dfs and similar", "greedy", "shortest paths", "math", "implementation", "graphs"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6926503340757239, "equal_cnt": 5, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "fn main() {\n let a = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().to_string()\n };\n let b = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().to_string()\n };\n let x = i32::from_str_radix(&a, 2).unwrap();\n let y = i32::from_str_radix(&b, 2).unwrap();\n let z = x ^ y;\n \n println!(\"{}\", format!(\"{:b}\", z));\n}\n", "lang": "Rust", "bug_code_uid": "4771561cf8e5aa5aef4b56b2c7890232", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "apr_id": "db8288956adcefcc2cd7e04431dc14c6", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9857723577235772, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let mut a = String::new();\n let mut b = String::new();\n stdin().read_line(&mut a).unwrap();\n stdin().read_line(&mut b).unwrap();\n let a: Vec = a.chars().collect();\n let b: Vec = b.chars().collect();\n\n let mut answer = String::new();\n\n for i in 0..a.len() {\n if a[i] != b[i] {\n answer.push_str(\"1\");\n } else {\n answer.push_str(\"0\");\n }\n }\n\n println!(\"{}\", answer);\n}\n", "lang": "Rust", "bug_code_uid": "7b9b34e413c33792eb19f65be8bec712", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "apr_id": "c8f8d511ad78fc9003e550a120100808", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.41061130334486734, "equal_cnt": 5, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "use proconio::input;\n\nfn main() {\n input! {\n s:String,\n t:String,\n }\n\n let s: Vec = s.chars().collect();\n let t: Vec = t.chars().collect();\n let n = s.len();\n let mut ans = String::new();\n\n for i in 0..n {\n ans.push(if s.get(i) != t.get(i) { '1' } else { '0' });\n }\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "7540f5e109cdb5157e69947f13ab2f91", "src_uid": "3714b7596a6b48ca5b7a346f60d90549", "apr_id": "462e888bea35ef768f2bf34ab29acb55", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9943197186908304, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn egcd(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n return (a, 1, 0);\n }\n let (g, x1, y1) = egcd(b, a % b);\n (g, y1, x1 - (a / b) * y1)\n}\n\nfn ceil_div(num: i64, denom: i64) -> i64 {\n (num + denom - 1).div_euclid(denom)\n}\n\n// Check if the diophantine equation a * x + b * y = c has non-negative solutions.\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: i64 = scan.token();\n let b: i64 = scan.token();\n let c: i64 = scan.token();\n let (g, xg, yg) = egcd(a, b);\n if c % g == 0 {\n let x0 = xg * c / g;\n let y0 = yg * c / g;\n // xk = x0 + k * b / g\n // yk = y0 - k * a / g\n // xk >= 0 and yk >= 0\n // After solving for k:\n let ans = y0 * g / a - ceil_div(-x0 * g, b) + 1;\n if ans >= 0 {\n writeln!(out, \"Yes\").ok();\n } else {\n writeln!(out, \"No\").ok();\n }\n } else {\n writeln!(out, \"No\").ok();\n }\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "bd5d0c1155cfc293e9dec0df662d693e", "src_uid": "e66ecb0021a34042885442b336f3d911", "apr_id": "722fa00dddb4948b1fd8bdae15a6fd84", "difficulty": 1100, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9989047097480832, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() { \n let mut inp = String::new();\n io::stdin().read_line(&mut inp)\n .expect(\"F#K\");\n let mut ct = 0;\n let mut lchar: char = '2';\n for sym in inp.chars(){\n if sym==lchar {\n ct += 1;\n if ct == 6 {\n println!(\"YES\");\n ::std::process::exit(0);\n }\n }else{\n ct == 0;\n }\n lchar = sym;\n } \n println!(\"NO\");\n} \n", "lang": "Rust", "bug_code_uid": "9f4ff8f2238dea7eee358716dfa9cf82", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "0cd9dee375026ca4fd159efc12fbe0df", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9454870420017873, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self};\n\nfn read_line() -> String {\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n a_str.trim().to_string()\n}\n\nfn main() -> io::Result<()> {\n let a = read_line();\n let mut ceros = 0;\n let mut unos = 0;\n for x in a.chars() {\n if x == '0' {\n ceros += 1;\n } else {\n unos += 1;\n }\n if ceros == 7 || unos == 7 {\n println!(\"YES\");\n return Ok(())\n }\n }\n println!(\"NO\");\n Ok(())\n}", "lang": "Rust", "bug_code_uid": "3fefafe513910a756f9c7ab50acc7e75", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "e1707941479f427c2116dcdb331202fe", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.715372907153729, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\nuse std::io::prelude::*;\nfn main() {\n let mut score = String::new();\n io::stdin().read_line(&mut score).expect(\"Error\");\n if score.len()<=7||score.contains(\"0000000\") || score.contains(\"1111111\") {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "cd3f376bc3b57b4560d5c9fd559242af", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "45ae8c1290eb527e3306043f83e363b2", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9581294181620446, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self};\nuse std::cmp::max;\n\nfn main() {\n let input = read_string();\n let max_seq_len = count_max_sequence_length(input);\n if max_seq_len >= 7 {\n println!(\"YES\")\n } else {\n println!(\"NO\")\n }\n\n}\n\nfn read_string() -> String {\n let mut input = String::new();\n let _read_result = io::stdin().read_line(&mut input);\n return input.trim().parse().unwrap();\n}\n\n\nfn count_max_sequence_length(input_str: String) -> u16 {\n let bytes = input_str.as_bytes();\n let mut max_sequence_length = 1;\n let mut current_sequence_length = 1;\n for i in 1..input_str.len() {\n if bytes[i - 1] == bytes[i] {\n current_sequence_length += 1\n } else {\n max_sequence_length = max(max_sequence_length, current_sequence_length);\n current_sequence_length = 1\n }\n }\n return max_sequence_length;\n}", "lang": "Rust", "bug_code_uid": "3948ca4dbc562b1b7455784b40b7f2a8", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "c8c51117d60a1fdae88f630f9ef4cd29", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9964422940088231, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "#![allow(unused_macros)]\n#![allow(unused_mut)]\n\n#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io;\nuse std::io::Write;\nuse std::str;\n#[allow(unused_imports)]\nuse std::prelude::*;\n\n// credit tanakh input macro\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 mut 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\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\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// credit ebtech scanner\npub struct UnsafeScanner {\n reader: R,\n buf_str: Vec,\n buf_iter: str::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\n\nfn solve() {\n #[allow(unused_variables)]\n let (stdin, stdout) = (io::stdin(), io::stdout());\n //let mut scan = UnsafeScanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n\n input! {\n s: String,\n }\n\n let mut l = 0;\n let mut r = 1;\n let mut v = vec![];\n\n for c in s.chars() {\n v.push(c);\n }\n let length = v.len();\n if length < 7 {\n writeln!(out, \"{}\", \"NO\").ok();\n return;\n }\n\n while r != length + 1{\n if r - l >= 7 {\n writeln!(out, \"{}\", \"YES\").ok();\n return;\n } else if v[r - 1] == v[r] {\n r += 1;\n } else {\n l = r;\n r += 1;\n }\n }\n writeln!(out, \"{}\", \"NO\").ok();\n\n}\n\n\n// credit kobae964\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}", "lang": "Rust", "bug_code_uid": "73fd0ddc6e0b39dee6bf9a1e6e51e751", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "7e6c30460a1d8e878e4e976af6bd6338", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9800221975582686, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn is_dangerous(input: &str) -> bool {\n let danger = 7;\n let bytes = input.as_bytes();\n \n let mut max = 0;\n let mut seq0 = 0;\n let mut seq1 = 0;\n for (i, &byte) in bytes.iter().enumerate(){\n match byte {\n b'0' => {\n seq0 += 1;\n if seq1 > max {\n max = seq1;\n }\n seq1 = 0;\n },\n b'1' => {\n seq1 += 1;\n if seq0 > max {\n max = seq0; \n }\n seq0 = 0;\n },\n _ => (),\n }\n }\n\n max >= danger\n}\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input)\n .expect(\"Failed to read line˜!\");\n\n if is_dangerous(&input) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "44af7e56711cf3164b31cf7c0452492a", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "82c324e6546304c1f4008780118e481b", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7960033305578684, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "fn read() -> String {\n let mut res = String::new();\n std::io::stdin().read_line(&mut res).expect(\"???\");\n res\n}\n\nfn parse_int(s: &str) -> usize {\n s.trim().parse().expect(\"???\")\n}\n\nfn parse_ints(s: &str) -> Vec {\n s.split_whitespace().map(parse_int).collect()\n}\n\nfn main() {\n let s = read().into_bytes();\n\n let mut n = 0;\n let mut curr = b' ';\n\n for c in s.into_iter() {\n if c == curr {\n n += 1;\n } else {\n curr = c;\n }\n }\n\n println!(\"{}\", if n >= 7 { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "dae5ebf27575776edc63e22bbc302f94", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "dff2498503894d3efcac97194b631a79", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8936567164179104, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io::*;\n\nfn read(i: &mut StdinLock) -> T {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let positions: String = read(sin);\n\n if positions.contains(\"01111111\") || positions.contains(\"10000000\") {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "961901715091de67f549a78d03cbc92a", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "ab175f0cd430f9639e1bdba5a7557eb3", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9585439838220424, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s = s.trim().to_string();\n let len = s.len();\n let mut cnt = 1;\n let mut ans = 1;\n for i in 1..len {\n if s.chars().nth(i) == s.chars().nth(i-1) {\n cnt += 1;\n if cnt > ans {\n ans = cnt;\n }\n } else {\n cnt = 1;\n }\n }\n if ans >= len / 2 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang": "Rust", "bug_code_uid": "f4223e8a352ce5fa4d3da04dc5ed42e7", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "68e1cdce3d9cdae8f3eecf93bc67f7cc", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9950980392156863, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nfn main() {\n let input = read();\n let mut val = 'a';\n let mut count = 1;\n let mut danger = 0;\n for d in input.chars(){\n if d == val{\n count += 1;\n if count == 7 {\n danger = 1;\n break;\n }\n }\n else {\n count = 1;\n val = d;\n }\n }\n if danger == 1{\n println!(\"Yes\");\n }\n else{\n println!(\"No\");\n }\n}\nfn read() -> String{\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input.trim().parse::().unwrap()\n}", "lang": "Rust", "bug_code_uid": "9b40d65b66dac3d041c7411fa7f236ca", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "3652ff386f55aca367e6939b75c9ed9a", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.998211091234347, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "\npub fn main(){\n let input = input();\n let chars: Vec = input.trim().chars().collect();\n let mut team = chars[0];\n let mut streak = 0;\n for c in chars {\n let current = c;\n if current != team {\n streak = 0;\n team = current;\n } else {\n streak += 1;\n }\n if streak >= 7 {\n println!(\"YES\");\n return;\n }\n }\n println!(\"NO\");\n}\n\nfn input() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input);\n input\n}\n", "lang": "Rust", "bug_code_uid": "a451e38777f08e8f959d82b7ed48e59b", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "b11494f86c2c43910e7fd3f54d2ba24e", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.03680203045685279, "equal_cnt": 14, "replace_cnt": 14, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 15, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{min,max};\nuse std::collections::{*};\nuse std::io::{BufWriter, stdin, stdout, Write};\nconst BITS: usize = 19;\n \n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n \nfn main() {\n let mut scanner = Scanner::default();\n let (n, m): (u64, u64) = (scanner.next(), scanner.next());\n let mut ans: u64 = 0;\n for i in 1..(m+1) {\n \tif m % i == 0 {\n \t\tans+=1;\n \t}\n }\n if ans > 2 {\n \tprint![\"NO\"];\n } else {\n \tprint![\"YES\"];\n }\n \n}", "lang": "Rust", "bug_code_uid": "cd5a741866c97054f409acee010fe6a6", "src_uid": "9d52ff51d747bb59aa463b6358258865", "apr_id": "7c57dd45b9594cf68a14144e209530a4", "difficulty": 800, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9513803049031726, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, prelude::*};\n\n\n#[allow(unused_must_use)]\nfn solve(mut scan: Scanner, mut w: W) {\n let n = scan.token::();\n let m = scan.token::();\n\n let mut primes = [true; 51];\n\n primes[0] = false;\n primes[1] = false;\n\n for i in 2usize..=50 {\n for j in ((2*i)..=50).step_by(i) {\n primes[j] = false;\n }\n }\n\n let mut i = n;\n assert!(primes[i]);\n\n let mut ans = \"YES\";\n while i < 50 {\n i += 1;\n if primes[i] == true {\n if i != m {\n ans = \"NO\"\n }\n break;\n }\n }\n\n writeln!(w, \"{}\", ans);\n}\n \nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let reader = Scanner::new(stdin.lock());\n let writer = io::BufWriter::new(stdout.lock());\n solve(reader, writer);\n}\n\n#[allow(dead_code)]\nfn matrix_to_str(matrix: &Vec>, separator: &str) -> String { \n use std::fmt::Write;\n let mut ans = String::new();\n for line in matrix.iter() {\n for elem in line.iter() {\n write!(&mut ans, \"{}{}\", elem.to_string(), separator).unwrap();\n }\n write!(&mut ans, \"\\n\").unwrap();\n }\n ans\n}\npub struct Scanner {\n reader: B,\n buf_str: Vec,\n buf_iter: std::str::SplitWhitespace<'static>,\n}\nimpl Scanner {\n pub fn new(reader: B) -> Self {\n Self {\n reader,\n buf_str: Vec::new(),\n buf_iter: \"\".split_whitespace()\n }\n }\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.read_until(b'\\n', &mut self.buf_str).expect(\"Failed read\");\n self.buf_iter = unsafe {\n let slice = std::str::from_utf8_unchecked(&self.buf_str);\n std::mem::transmute(slice.split_whitespace()) }\n }\n }\n pub fn get_matrix(&mut self, m: usize, n: usize) -> Vec> {\n // m rows and n columns\n let mut ans: Vec> = Vec::with_capacity(m);\n for i in 0..m {\n ans.push(Vec::with_capacity(n));\n for _ in 0..n {\n ans[i].push(self.token::());\n }\n }\n ans\n }\n}\n", "lang": "Rust", "bug_code_uid": "d057847debd0760f471069c9038b1488", "src_uid": "9d52ff51d747bb59aa463b6358258865", "apr_id": "7b16a0182e6b4488ba133715dc9fa824", "difficulty": 800, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.998567335243553, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{stdin, BufRead, Stdin, StdinLock};\n\nfn get_average_time(time1: (usize, usize), time2: (usize, usize)) -> (usize, usize) {\n let time1_minutes: usize = time1.0 * 60 + time1.1;\n let time2_minutes: usize = time2.0 * 60 + time2.1;\n\n let time3_minutes = (time1_minutes + time2_minutes) / 2;\n\n return ((time3_minutes / 60), (time3_minutes % 60));\n}\n\n#[cfg(test)]\nmod test {\n use super::get_average_time;\n\n #[test]\n fn test1() {\n let time1: (usize, usize) = (10, 0);\n let time2: (usize, usize) = (11, 0);\n let time_result: (usize, usize) = get_average_time(time1, time2);\n\n assert_eq!(time_result, (10, 30));\n }\n #[test]\n fn test2() {\n let time1: (usize, usize) = (11, 10);\n let time2: (usize, usize) = (11, 12);\n let time_result: (usize, usize) = get_average_time(time1, time2);\n\n assert_eq!(time_result, (11, 11));\n }\n #[test]\n fn test3() {\n let time1: (usize, usize) = (1, 2);\n let time2: (usize, usize) = (3, 2);\n let time_result: (usize, usize) = get_average_time(time1, time2);\n\n assert_eq!(time_result, (2, 2));\n }\n}\n\nfn read_data() -> ((usize, usize), (usize, usize)) {\n let stdin_stream: Stdin = stdin();\n let mut stdin_handle: StdinLock = stdin_stream.lock();\n\n let mut str1: String = String::new();\n stdin_handle.read_line(&mut str1).unwrap();\n let str1_tokens: Vec = str1\n .trim()\n .split(\":\")\n .map(|s| s.parse::().unwrap())\n .collect();\n\n let mut str2: String = String::new();\n stdin_handle.read_line(&mut str2).unwrap();\n let str2_tokens: Vec = str2\n .trim()\n .split(\":\")\n .map(|s| s.parse::().unwrap())\n .collect();\n\n return (\n (str1_tokens[0], str1_tokens[1]),\n (str2_tokens[0], str2_tokens[1]),\n );\n}\n\nfn main() {\n let (time1, time2): ((usize, usize), (usize, usize)) = read_data();\n\n let time_result: (usize, usize) = get_average_time(time1, time2);\n\n println!(\"{}:{}\", time_result.0, time_result.1);\n}\n", "lang": "Rust", "bug_code_uid": "d6a049f802bf53a9efd85a1b4d935d8e", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "apr_id": "54501dd4b630e19e599e353fc4eb0d3b", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.976551724137931, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::collections::HashSet;\n\nfn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n let line = line.trim();\n let characters: HashSet<_> = line.chars().collect();\n println!(\"{}\", if characters.len() == 27 { \"YES\" } else { \"NO\" })\n}\n", "lang": "Rust", "bug_code_uid": "0c125299ccbd741d16979274012b4d0a", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "apr_id": "7b6c0de6a345291fe37080584309bd03", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9803921568627451, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn digit_sum(x: i64) -> i64 {\n let mut x = x;\n let mut ans = 0;\n while x > 0 {\n ans += x % 10;\n x /= 10;\n }\n ans\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: u32 = scan.token();\n let b: i64 = scan.token();\n let c: i64 = scan.token();\n let mut ans = Vec::new();\n\n for s_x in 1i64..=81i64 {\n let x = b * s_x.pow(a) + c;\n if digit_sum(x) == s_x {\n ans.push(x.to_string());\n }\n }\n writeln!(out, \"{}\", ans.len()).ok();\n writeln!(out, \"{}\", ans.join(\" \")).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "9c79050fb59b45fbf236bf4b2a5fc749", "src_uid": "e477185b94f93006d7ae84c8f0817009", "apr_id": "3085815f87cf2a2fe288a94def80eae2", "difficulty": 1500, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9986754966887417, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn digit_sum(x: i64) -> i64 {\n let mut x = x;\n let mut ans = 0;\n while x > 0 {\n ans += x % 10;\n x /= 10;\n }\n ans\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: u32 = scan.token();\n let b: i64 = scan.token();\n let c: i64 = scan.token();\n let mut ans = Vec::new();\n\n for s_x in 1i64..=81i64 {\n let x = b * s_x.pow(a) + c;\n if x >= 1000000000 {\n break;\n }\n if x < digit_sum(x) == s_x {\n ans.push(x.to_string());\n }\n }\n writeln!(out, \"{}\", ans.len()).ok();\n writeln!(out, \"{}\", ans.join(\" \")).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "80bd00269e32fc0d5770e923aade078f", "src_uid": "e477185b94f93006d7ae84c8f0817009", "apr_id": "3085815f87cf2a2fe288a94def80eae2", "difficulty": 1500, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9999171293610674, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_parens)]\n#![allow(unused_imports)]\n#![allow(non_upper_case_globals)]\n#![allow(non_snake_case)]\n#![allow(unused_mut)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\n#[allow(unused_macros)]\nmacro_rules! invec {\n ( $ t : ty ) => {{\n let mut s = String::new();\n match std::io::stdin().read_line(&mut s) {\n Ok(0) => Vec::<$t>::new(),\n Ok(n) => s\n .trim()\n .split_whitespace()\n .map(|s| s.parse::<$t>().unwrap())\n .collect::>(),\n Err(_) => Vec::<$t>::new(),\n }\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n ($t:ty ;; $n:expr) => {\n (0..$n).map(|_| get!($t ;;)).collect::>()\n };\n}\n\n#[allow(unused_macros)]\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 mut 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\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($next:expr, [$t:tt]) => {\n {\n let len = read_value!($next, usize);\n (0..len).map(|_| read_value!($next, $t)).collect::>()\n }\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\n#[cfg(debug_assertions)]\nmacro_rules! mydbg {\n //($arg:expr) => (dbg!($arg))\n //($arg:expr) => (println!(\"{:?}\",$arg));\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n#[cfg(not(debug_assertions))]\nmacro_rules! mydbg {\n ($($arg:expr),*) => {};\n}\n\nmacro_rules! echo {\n ($($a:expr),*) => {\n $(println!(\"{}\",$a))*\n }\n}\n\nuse std::cmp::*;\nuse std::collections::*;\nuse std::ops::{Add, Div, Mul, Sub};\n\n#[allow(dead_code)]\nstatic INF_I64: i64 = i64::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_I32: i32 = i32::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_USIZE: usize = usize::max_value() / 2;\n#[allow(dead_code)]\nstatic M_O_D: usize = 1000000007;\n#[allow(dead_code)]\nstatic PAI: f64 = 3.1415926535897932;\n\ntrait IteratorExt: Iterator {\n fn toVec(self) -> Vec;\n}\n\nimpl IteratorExt for T {\n fn toVec(self) -> Vec {\n self.collect()\n }\n}\n\ntrait CharExt {\n fn toNum(&self) -> usize;\n fn toAlphabetIndex(&self) -> usize;\n fn toNumIndex(&self) -> usize;\n}\nimpl CharExt for char {\n fn toNum(&self) -> usize {\n return *self as usize;\n }\n fn toAlphabetIndex(&self) -> usize {\n return self.toNum() - 'a' as usize;\n }\n fn toNumIndex(&self) -> usize {\n return self.toNum() - '0' as usize;\n }\n}\n\ntrait VectorExt {\n fn joinToString(&self, s: &str) -> String;\n}\nimpl VectorExt for Vec {\n fn joinToString(&self, s: &str) -> String {\n return self\n .iter()\n .map(|x| x.to_string())\n .collect::>()\n .join(s);\n }\n}\n\ntrait StringExt {\n fn get_reverse(&self) -> String;\n}\nimpl StringExt for String {\n fn get_reverse(&self) -> String {\n self.chars().rev().collect::()\n }\n}\n\ntrait UsizeExt {\n fn pow(&self, n: usize) -> usize;\n}\nimpl UsizeExt for usize {\n fn pow(&self, n: usize) -> usize {\n return ((*self as u64).pow(n as u32)) as usize;\n }\n}\n\nfn main() {\n let (a, b, c) = get!(i64, i64, i64);\n let mut k = vec![];\n for i in 0..100 {\n k.push((b * ((i as i64).pow(a as u32)) + c, i));\n }\n let mut ans = vec![];\n for &(d, e) in &k {\n if d < 0 {\n continue;\n } else if d > 10_i64.pow(9) {\n continue;\n }\n let f = d\n .to_string()\n .chars()\n .map(|x| x as usize - '0' as usize)\n .fold(0, |a, x| a + x);\n if f == e {\n ans.push(d);\n }\n }\n echo!(ans.len());\n echo!(ans.joinToString(\" \"));\n}\n", "lang": "Rust", "bug_code_uid": "b4666cd17669764d661e8c6d555cd030", "src_uid": "e477185b94f93006d7ae84c8f0817009", "apr_id": "b9d5f814ea70f5a504337dec691dd2ab", "difficulty": 1500, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9987684729064039, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n}\n\nfn sumdigits(x: i64) -> usize {\n let mut result = 0usize;\n let mut tmp = x;\n while tmp > 0 {\n result += (tmp % 10) as usize;\n tmp /= 10;\n }\n result\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let a: u32 = scan.next();\n let b: isize = scan.next();\n let c: isize = scan.next();\n let mut result: Vec = vec![];\n for i in 0usize..=72 {\n let x: i64 = (i.pow(a) as i64) * (b as i64) + (c as i64);\n if x <= 0 {\n continue;\n }\n if x >= 1000000000 {\n break;\n }\n if sumdigits(x) == i {\n result.push(x);\n }\n }\n println!(\"{}\", result.len());\n for &item in &result {\n print!(\"{} \", item);\n }\n if result.len() != 0 {\n println!();\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": "Rust", "bug_code_uid": "6620152ff6498fc221f85871a8ec903f", "src_uid": "e477185b94f93006d7ae84c8f0817009", "apr_id": "f0939a6d20c6a06c3b44f3272980db7f", "difficulty": 1500, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9982964224872232, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_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": "Rust", "bug_code_uid": "bbb93825da15ff40f6ad15166b40918e", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "apr_id": "2970cb549e980ec29be0211962ba29ed", "difficulty": 1000, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8746177370030581, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n let mut v: Vec = line.trim().split(\" \").map(|s| s.parse::().unwrap()).collect();\n v.sort();\n println!(\"{}\", v.iter().map(|i| i.to_string()).collect::>().connect(\" \"));\n}\n", "lang": "Rust", "bug_code_uid": "2be64f89694a5b96058bec79d887347e", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "apr_id": "55251895f1618e14ab9f00e618a32791", "difficulty": 900, "tags": ["greedy", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9181286549707602, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 8, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_vec(split_char: char) -> Vec {\n read_str()\n .split(split_char)\n .map(|value| value.parse::().ok().expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n read_str();\n let mut blocks: Vec = read_vec(' ');\n blocks.sort();\n println!(\"{}\", blocks.join(\" \"));\n}", "lang": "Rust", "bug_code_uid": "a45b96f3cfca071a1aa9b2bd30134e15", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "apr_id": "29cb147a021a212dd6e28c267c76771f", "difficulty": 900, "tags": ["greedy", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9651006711409396, "equal_cnt": 9, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 8, "bug_source_code": "use std::io::stdin;\nuse std::cmp::min;\n\nfn main() {\n let mut input_line = String::new();\n stdin().read_line(&mut input_line);\n\n let input_iter = input_line.\n split_whitespace().\n map(|x| x.parse::().unwrap());\n\n let input: Vec<_> = input_iter.collect();\n\n let owned = input[0];\n if owned % 4 == 0 {\n // Already meet criteria\n println!(\"0\");\n return;\n }\n\n let purchase = 4 - owned % 4;\n\n let mut dp = vec![usize::max_value(); 9];\n dp[0] = 0;\n\n for i in 0..9 {\n for j in 1..4 {\n if i >= j {\n dp[i] = min(dp[i - j] + input[j], dp[i]);\n }\n }\n }\n\n println!(\"{}\", min(dp[purchase], dp[purchase + 4]));\n}", "lang": "Rust", "bug_code_uid": "09657457186ad84e7ef069e4a3d85951", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "apr_id": "749c87be8fff192265b9d0d793b1edb0", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9956178790534619, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::prelude::*;\nuse std::io;\nuse std::str::FromStr;\n#[cfg(local)]\nuse std::fs::File;\n#[cfg(local)]\nuse std::io::BufReader;\n\nuse std::cmp;\n\n#[cfg(local)]\nfn buf_read() -> io::Result<(Vec)> {\n let f = try!(File::open(\"input.txt\"));\n let input_lines: Vec<_> = BufReader::new(f).lines().collect();\n let lines: Vec = input_lines.into_iter().map(|e| e.unwrap()).collect();\n Ok((lines))\n}\n\n#[cfg(not(local))]\nfn buf_read() -> io::Result<(Vec)> {\n let stdin = io::stdin();\n let input_lines: Vec<_> = stdin.lock().lines().collect();\n let lines: Vec = input_lines.into_iter().map(|e| e.unwrap()).collect();\n Ok((lines))\n}\n\nfn main() {\n type Element = i64;\n let input = buf_read().unwrap();\n let mut input_vectors: Vec> = vec![];\n for input_line in input {\n let input_str: Vec = input_line.split(' ').map(String::from).collect();\n let mut input_vector: Vec = vec![];\n for input_elem_str in input_str {\n let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();\n input_vector.push(elem);\n }\n input_vectors.push(input_vector);\n }\n let k = input_vectors[0][0];\n let a = input_vectors[0][1];\n let b = input_vectors[0][2];\n let c = input_vectors[0][3];\n let required_copies = match k % 4 {\n 0 => 0,\n n => 4 - n,\n };\n let cost = match required_copies {\n 1 => cmp::min(a * 1, cmp::min(b * 1, cmp::min(c * 1, c * 3))),\n 2 => cmp::min(cmp::min(a * 2, b * 1), cmp::min(a * 1 + c * 1, c * 2)),\n 3 => cmp::min(a * 3, cmp::min(a * 1 + b * 1, c * 1)),\n _ => 0,\n };\n println!(\"{}\", cost);\n}\n", "lang": "Rust", "bug_code_uid": "0551849fc86cc1439636dcca5726e689", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "apr_id": "6ebb75b191f8a237766576659a2951b1", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9973045822102425, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, Stdin};\nuse std::str::{self, FromStr};\nuse std::error::Error;\nuse std::thread;\nuse std::cmp::*;\nfn exec() {\n let mut sc = Scanner::new();\n let n: usize = sc.ne();\n let a: usize = sc.ne();\n let b: usize = sc.ne();\n let c: usize = sc.ne();\n let ans = match n % 4 {\n 0 => 0,\n 1 => min(a * 3, min(a + b, c)),\n 2 => min(a * 2, min(c * 2, b)),\n _ => min(a, b + c),\n };\n println!(\"{}\", ans);\n}\n\nfn main() {\n const DEFAULT_STACK: usize = 16 * 1024 * 1024;\n let builder = thread::Builder::new();\n let th = builder.stack_size(DEFAULT_STACK);\n let handle = th.spawn(|| { exec(); }).unwrap();\n let _ = handle.join();\n}\n\n#[allow(dead_code)]\nstruct Scanner {\n stdin: Stdin,\n id: usize,\n buf: Vec,\n}\n\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n stdin: io::stdin(),\n id: 0,\n buf: Vec::new(),\n }\n }\n fn next_line(&mut self) -> Option {\n let mut res = String::new();\n match self.stdin.read_line(&mut res) {\n Ok(0) => return None,\n Ok(_) => Some(res),\n Err(why) => panic!(\"error in read_line: {}\", why.description()),\n }\n }\n fn next(&mut self) -> Option {\n while self.buf.len() == 0 {\n self.buf = match self.next_line() {\n Some(r) => {\n self.id = 0;\n r.trim().as_bytes().to_owned()\n }\n None => return None,\n };\n }\n let l = self.id;\n assert!(self.buf[l] != b' ');\n let n = self.buf.len();\n let mut r = l;\n while r < n && self.buf[r] != b' ' {\n r += 1;\n }\n let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() {\n Ok(s) => Some(s),\n Err(_) => panic!(\"parse error\"),\n };\n while r < n && self.buf[r] == b' ' {\n r += 1;\n }\n if r == n {\n self.buf.clear();\n } else {\n self.id = r;\n }\n res\n }\n fn ne(&mut self) -> T {\n self.next::().unwrap()\n }\n}\n", "lang": "Rust", "bug_code_uid": "3b3b62d76c4596b25cf990f2372d768d", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "apr_id": "cbf95f18b103cf261963429dfb83e686", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.4079280940308827, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "macro_rules! scanln {\n () => ({\n let mut buffer = String::new();\n ::std::io::stdin().read_line(&mut buffer).expect(\"Unable to read line\");\n buffer\n });\n ($($t: ty),+) => ({\n scanln!($($t),+, |c: char| c.is_whitespace())\n });\n ($($t: ty),+, $sp: expr) => ({\n let mut buffer = scanln!();\n let mut iter = buffer.split($sp);\n ($(iter.next().unwrap().parse::<$t>().expect(\"Unable to parse token\")),+)\n });\n}\n\nfn main() {\n const MOD: u64 = 1000000009;\n let mut dp = vec![[[[[0u64; 2]; 32]; 32]; 32]; 1001].into_boxed_slice();\n let (n, h) = scanln!(usize, usize);\n dp[0][0][0][0][0] = 1;\n\n for i in 1..=n {\n for a in 0..=(h + 1) {\n for b in a..=(h + 1) {\n for c in b..=(h + 1) {\n for y in 0..2 {\n let val = dp[(i - 1) as usize][a][b][c][y];\n let ta = if a + 1 > h { h + 1 } else { a + 1 };\n let tb = if b + 1 > h { h + 1 } else { b + 1 };\n let tc = if c + 1 > h { h + 1 } else { c + 1 };\n dp[i][ta][tb][tc][y] += val;\n if y == 0 {\n dp[i][1][tb][tc][(ta > h) as usize] += val;\n dp[i][1][ta][tc][(tb > h) as usize] += val;\n dp[i][1][ta][tb][(tc > h) as usize] += val;\n } else {\n dp[i][tb][tc][h + 1][(ta > h) as usize] += val;\n dp[i][ta][tc][h + 1][(tb > h) as usize] += val;\n dp[i][ta][tb][h + 1][(tc > h) as usize] += val;\n }\n }\n }\n }\n }\n }\n\n let mut res = 0;\n\n for a in 0..=(h + 1) {\n for b in a..=(h + 1) {\n for c in b..=(h + 1) {\n for y in 0..2 {\n if (a < h) || (b < h) || (c < h) || (y == 0) {\n res += dp[n][a][b][c][y];\n }\n }\n }\n }\n }\n\n println!(\"{}\", res % MOD);\n}", "lang": "Rust", "bug_code_uid": "ca3e1d085e87fd3bcb977a7b1e75cb0f", "src_uid": "9fe9658db35076c0bddc8b7ddce11013", "apr_id": "f1c6ff9d22a9da670fb41c63ca8052cd", "difficulty": 2300, "tags": ["dp"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9925211434961907, "equal_cnt": 24, "replace_cnt": 3, "delete_cnt": 20, "insert_cnt": 0, "fix_ops_cnt": 23, "bug_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 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 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\nfn main() -> Result<(), Box> {\n for _ in 0..read_usize() {\n let (a1, a2, a3) = read_3::();\n let (b1, b2, b3) = read_3::();\n let not_wins = [(0, 0), (1, 1), (2, 2), (0, 2), (1, 0), (2, 1)];\n let mut min_wins = None;\n for perm in Permutations::new(not_wins.to_vec()) {\n let mut tmpa = [a1, a2, a3];\n let mut tmpb = [b1, b2, b3];\n for (a, b) in perm {\n let m = min(tmpa[a], tmpb[b]);\n tmpa[a] -= m;\n tmpb[b] -= m;\n }\n if let Some(m) = min_wins {\n min_wins = Some(min(m, tmpa.iter().sum::()))\n } else {\n min_wins = Some(tmpa.iter().sum::())\n }\n }\n let max_wins = min(a1, b2) + min(a2, b3) + min(a3, b1);\n println!(\"{} {}\", min_wins.unwrap(), max_wins);\n }\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "3e4908d92748e89ecc8e60048332eb7d", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "apr_id": "d7a75a3e1714668fab5000fd954f830d", "difficulty": 1800, "tags": ["flows", "greedy", "math", "brute force", "constructive algorithms"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.546583850931677, "equal_cnt": 58, "replace_cnt": 30, "delete_cnt": 13, "insert_cnt": 14, "fix_ops_cnt": 57, "bug_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\nconst M: i64 = 1_000_000_007;\n\n// fn mul(a: i64, b: i64) -> i64 { a * b % M }\nfn add(a: i64, b: i64) -> i64 {\n let x = (a + b) % M;\n x\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let n = input.u();\n let tt = input.i();\n let mut t = vec![0; n];\n let mut g = vec![0; n];\n let mut z = vec![0; 4];\n for i in 0..n {\n t[i] = input.i();\n g[i] = input.i();\n z[g[i] as usize] += 1;\n }\n let sumt: i32 = t.iter().sum();\n\n let dp2 = {\n let mut dp2 = HashMap::<(i32,i32,i32),i64>::new();\n let mut dp = HashMap::<(i32,i32,i32,i32,i32),i64>::new();\n for g in 1..4 {\n dp.insert((0,0,0,0,g), 1);\n }\n for _i in 0..n {\n let mut d = HashMap::<(i32,i32,i32,i32,i32),i64>::new();\n for ((h,a,b,c,l), y) in dp.into_iter() {\n let mut p = [0,a,b,c];\n for g in 1..4 {\n if (h == 0 && g != l) || (h > 0 && g == l) {\n continue;\n }\n p[g as usize] += 1;\n if (1..4).all(|i| p[i] <= z[i]) {\n let key = (h + 1, p[1], p[2], p[3], g);\n let res = add(y * p[g as usize] as i64, *d.get(&key).unwrap_or(&0));\n d.insert(key, res);\n }\n p[g as usize] -= 1;\n }\n }\n\n for (&(_,a,b,c,_),&x) in d.iter() {\n let key = (a,b,c);\n let res = *dp2.get(&key).unwrap_or(&0);\n dp2.insert(key, add(res, x));\n }\n dp = d;\n // println!(\"\\n-----------------------: {}\", _i);\n // for ((h,a,b,c,g),x) in dp.iter() {\n // println!(\"{} {} {} {} {}: {}\", h,a,b,c,g,x);\n // }\n }\n dp2\n };\n // eprintln!(\"DP2\");\n // for ((a,b,c),x) in dp2.iter() {\n // println!(\"dp2 {} {} {} : {}\", a,b,c,x);\n // }\n\n let dp1 = {\n let mut st = [0; 4];\n st[3] = 1;\n st[2] = st[3] * (z[3] + 1);\n st[1] = st[2] * (z[2] + 1);\n st[0] = st[1] * (z[1] + 1);\n let st = st;\n let sz = (st[0] * (sumt + 1)) as usize;\n\n // println!(\"st {} {} {} {}\", st[0], st[1], st[2], st[3]);\n // println!(\"z {} {} {} {}\", z[0], z[1], z[2], z[3]);\n\n let mut aa = vec![0; sz];\n // println!(\"{}\", aa.len());\n let mut dp = HashSet::::new();\n dp.insert(0);\n aa[0] = 1;\n for i in 0..n {\n let mut d = HashSet::::new();\n let mut a = vec![0; sz];\n let x = t[i];\n let g = g[i] as usize;\n for &s in dp.iter() {\n let s = s as usize;\n let key = s + (x * st[0]) as usize + st[g] as usize;\n d.insert(key as i32);\n a[key] += aa[s];\n }\n for key in d.into_iter() {\n let s = key as usize;\n aa[s] += a[s];\n dp.insert(key);\n }\n }\n let mut dp1 = HashMap::<(i32,i32,i32),i64>::new();\n let min = st[0] * tt;\n let max = st[0] * (tt + 1);\n for s in dp.into_iter() {\n if min <= s && s < max {\n let a = s % st[0] / st[1];\n let b = s % st[1] / st[2];\n let c = s % st[2] / st[3];\n dp1.insert((a,b,c),aa[s as usize]);\n }\n }\n dp1\n };\n // eprintln!(\"DP1\");\n // for ((a,b,c),&x) in dp1.iter() {\n // println!(\"dp1 {} {} {} : {}\", a,b,c,x);\n // }\n\n let mut sol: i64 = 0;\n for a in 0..z[1]+1 {\n let a = a as i32;\n for b in 0..z[2]+1 {\n let b = b as i32;\n for c in 0..z[3]+1 {\n let c = c as i32;\n let x = dp1.get(&(a,b,c)).unwrap_or(&0);\n let y = dp2.get(&(a,b,c)).unwrap_or(&0);\n sol = add(sol, x * y);\n }\n }\n }\n sol = (sol % M + M) % M;\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "4c1393e3ca39101ac88724ae3942c69e", "src_uid": "ed5f913afe829c65792b54233a256757", "apr_id": "cfe8c4904d78cea8f78b13cecbaafffd", "difficulty": 2600, "tags": ["dp", "combinatorics"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9997202171115215, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 4, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "//spnauti-rust\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::*;\n#[allow(unused_imports)] use std::collections::*;\n\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\n#[allow(dead_code)]\nfn build_counting_hashmap(i: T) -> HashMap\n where T: Iterator {\n let mut m = HashMap::new();\n for k in i {\n let n = 1 + if let Some(&n) = m.get(&k) { n } else { 0 };\n m.insert(k, n);\n }\n m\n}\n\nconst P5: i32 = 1_000_000_007;\nconst P6: i64 = P5 as i64;\n#[derive(Debug,Clone,Copy)]\nstruct Field(i32);\n#[allow(dead_code)]\nimpl Field {\n fn new>(a: T) -> Self { Self(Self::cv(a)) }\n fn new_unchecked(a: i32) -> Self { Self(a) }\n fn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }\n fn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }\n fn cv>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }\n}\nimpl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}\nimpl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}\nimpl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}\nimpl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}\nimpl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }\nimpl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }\nimpl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }\nuse std::fmt::{Display, Formatter, Result};\nimpl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, \"{}\", self.0) } }\n// impl Default for Field { fn default() -> Self { Field(0) }}\nimpl Default for &Field { fn default() -> Self { &Field(0) }}\nimpl PartialEq for Field { fn eq(&self, a: &Self) -> bool { self.0 == a.0 } }\nimpl PartialOrd for Field { fn partial_cmp(&self, a: &Self) -> Option { Some(self.0.cmp(&a.0)) } }\nimpl Eq for Field {}\nimpl Ord for Field { fn cmp(&self, a: &Self) -> Ordering { self.0.cmp(&a.0) } }\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let n = input.u();\n let tt = input.i();\n let mut t = vec![0; n];\n let mut g = vec![0; n];\n let mut z = vec![0; 4];\n for i in 0..n {\n t[i] = input.i();\n g[i] = input.i();\n z[g[i] as usize] += 1;\n }\n let sumt: i32 = t.iter().sum();\n\n let dp2 = {\n let mut dp2 = HashMap::<(i32,i32,i32),Field>::new();\n let mut dp = HashMap::<(i32,i32,i32,i32,i32),Field>::new();\n for g in 1..4 {\n dp.insert((0,0,0,0,g), Field(1));\n }\n for _i in 0..n {\n let mut d = HashMap::<(i32,i32,i32,i32,i32),Field>::new();\n for ((h,a,b,c,l), y) in dp.into_iter() {\n let mut p = [0,a,b,c];\n let mut pf = [Field(0),Field(a),Field(b),Field(c)];\n for g in 1..4 {\n let gu = g as usize;\n if (h == 0 && g != l) || (h > 0 && g == l) {\n continue;\n }\n p[gu] += 1;\n pf[gu] += Field(1);\n if (1..4).all(|i| p[i] <= z[i]) {\n let key = (h + 1, p[1], p[2], p[3], g);\n let res = y * pf[g as usize] + *d.get(&key).unwrap_or_default();\n d.insert(key, res);\n }\n p[gu] -= 1;\n pf[gu] -= Field(1);\n }\n }\n\n for (&(_,a,b,c,_),&x) in d.iter() {\n let key = (a,b,c);\n let res = *dp2.get(&key).unwrap_or_default();\n dp2.insert(key, res + x);\n }\n dp = d;\n // println!(\"\\n-----------------------: {}\", _i);\n // for ((h,a,b,c,g),x) in dp.iter() {\n // println!(\"{} {} {} {} {}: {}\", h,a,b,c,g,x);\n // }\n }\n dp2\n };\n // eprintln!(\"DP2\");\n // for ((a,b,c),x) in dp2.iter() {\n // println!(\"dp2 {} {} {} : {}\", a,b,c,x);\n // }\n\n let dp1 = {\n let mut st = [0; 3];\n st[2] = 1;\n st[1] = st[2] * (z[2] + 1);\n st[0] = st[1] * (z[1] + 1);\n let st = st;\n let sz = (st[0] * (sumt + 1)) as usize;\n\n let mut aa = vec![Field(0); sz];\n let mut dp = HashSet::::new();\n dp.insert(0);\n aa[0] = Field(1);\n for i in 0..n {\n if g[i] == 3 { continue; }\n\n let mut d = HashSet::::new();\n let mut a = vec![Field(0); sz];\n let x = t[i];\n let g = g[i] as usize;\n for &s in dp.iter() {\n let key = s + (x * st[0]) + st[g];\n d.insert(key);\n a[key as usize] += aa[s as usize];\n }\n for key in d.into_iter() {\n let s = key as usize;\n aa[s] += a[s];\n dp.insert(key);\n }\n }\n let mut dp1 = HashMap::<(i32,i32,i32),Field>::new();\n for s in dp.into_iter() {\n let t = s / st[0];\n let a = s % st[0] / st[1];\n let b = s % st[1] / st[2];\n dp1.insert((t,a,b),aa[s as usize]);\n }\n dp1\n };\n // eprintln!(\"DP1\");\n // for ((a,b,c),x) in dp1.iter() {\n // println!(\"dp1 {} {} {} : {}\", a,b,c,x);\n // }\n\n let dp3 = {\n let mut st = [0; 4];\n st[3] = 1;\n st[0] = st[3] * (z[3] + 1);\n let st = st;\n let sz = (st[0] * (sumt + 1)) as usize;\n\n let mut aa = vec![Field(0); sz];\n let mut dp = HashSet::::new();\n dp.insert(0);\n aa[0] = Field(1);\n for i in 0..n {\n if g[i] != 3 { continue; }\n\n let mut d = HashSet::::new();\n let mut a = vec![Field(0); sz];\n let x = t[i];\n let g = g[i] as usize;\n for &s in dp.iter() {\n let key = s + (x * st[0]) + st[g];\n d.insert(key);\n a[key as usize] += aa[s as usize];\n }\n for key in d.into_iter() {\n let s = key as usize;\n aa[s] += a[s];\n dp.insert(key);\n }\n }\n let mut dp3 = HashMap::<(i32,i32),Field>::new();\n for s in dp.into_iter() {\n let t = s / st[0];\n let c = s % st[0] / st[3];\n dp3.insert((t,c),aa[s as usize]);\n }\n dp3\n };\n // eprintln!(\"DP3\");\n // for ((a,b),x) in dp3.iter() {\n // println!(\"dp3 {} {} : {}\", a,b,x);\n // }\n\n let dp1 = {\n let mut dp = HashMap::<(i32,i32,i32),Field>::new();\n for (&(tab,a,b),&res1) in &dp1 {\n let tc = tt - tab;\n if tc < 0 { continue; }\n for c in 0..=z[3] {\n if let Some(&res2) = dp3.get(&(c,tc)) {\n let res3 = *dp.get(&(a,b,c)).unwrap_or_default();\n dp.insert((a,b,c), res3 + res1*res2);\n }\n }\n }\n dp\n };\n // println!(\"DP1\");\n // println!(\"DP1\");\n // for ((a,b,c),&x) in dp1.iter() {\n // println!(\"dpX {} {} {} : {}\", a,b,c,x);\n // }\n\n let mut sol = Field::new_unchecked(0);\n for a in 0..=z[1] as i32 {\n for b in 0..=z[2] as i32 {\n for c in 0..=z[3] as i32 {\n let x = *dp1.get(&(a,b,c)).unwrap_or_default();\n let y = *dp2.get(&(a,b,c)).unwrap_or_default();\n sol += x * y;\n }\n }\n }\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "c5451611f01ff4ba5c4ebd8b86b7c7df", "src_uid": "ed5f913afe829c65792b54233a256757", "apr_id": "cfe8c4904d78cea8f78b13cecbaafffd", "difficulty": 2600, "tags": ["dp", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9991830065359477, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn solve() {\n let (al, ar) = parse_line!(i32, i32);\n let (bl, br) = parse_line!(i32, i32);\n let mut ok = false;\n ok |= br >= al - 1 && br < (al + 1) * 2;\n ok |= bl >= ar - 1 && bl < (ar + 1) * 2;\n println!(\"{}\", if ok {\"YES\"} else {\"NO\"})\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang": "Rust", "bug_code_uid": "0a5026477ce25fbfcc22b34d0d7b5fcf", "src_uid": "36b7478e162be6e985613b2dad0974dd", "apr_id": "01ae165a2e67fbe8e15179555620647c", "difficulty": 1300, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8905809362662155, "equal_cnt": 14, "replace_cnt": 2, "delete_cnt": 7, "insert_cnt": 4, "fix_ops_cnt": 13, "bug_source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(dead_code)]\n\nuse std::char::*;\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse std::str::FromStr;\n\nmacro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);}}\nmacro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }\nmacro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }\nmacro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\n\n\nfn read() -> T {\n let stdin = stdin();\n let stdin = stdin.lock();\n let token: String = stdin\n .bytes()\n .map(|c| c.expect(\"failed to read char\") as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect();\n token.parse().ok().expect(\"failed to parse token\")\n}\n\nuse std::f64;\n\nfn min(a:T, b:T) -> T {\n if a < b { a }\n else { b }\n}\n\nfn max(a:T, b:T) -> T {\n if a < b { b }\n else { a }\n}\n\nuse std::hash::Hash;\nfn inc(map:&mut BTreeMap, key:T) {\n let count = map.entry(key).or_insert(0);\n *count += 1;\n}\n\nfn digit(ch: char) -> i64 {\n return (ch as u8 - b'0') as i64\n}\n\nconst MAX:usize = 30;\nconst INF:i64 = std::i64::MAX;\nconst MOD:i64 = 1e9 as i64 + 7;\n\nfn gcd(x:i64, y:i64) -> i64 {\n if y==0 { return x; }\n gcd(y, x%y)\n}\n\nfn divisor(n:usize) -> Vec {\n let mut res = Vec::new();\n let mut i = 1;\n while i*i <= n {\n if n%i == 0 {\n res.push(i);\n if i != n/i { res.push(n/i); }\n }\n i += 1;\n }\n res.sort();\n res\n}\n\nfn main() {\n //let t:usize = read();\n\n //'outer: for _ in 0..t {\n let s:Vec = read::().chars().collect();\n let t:Vec = read::().chars().collect();\n\n let mut ans = 0;\n for i in 0..s.len() {\n for j in i+1..s.len() {\n // remain string\n let mut ss = vec![];\n for k in 0..i { ss.push(s[k]); }\n for k in j+1..s.len() { ss.push(s[k]); }\n let m = ss.len();\n let mut idx = 0;\n for k in 0..m {\n if idx >= t.len() { break; }\n if ss[k] == t[idx] {\n idx += 1;\n }\n }\n if idx >= t.len() {\n //debug!(i,j,ss);\n ans = max(ans, j-i+1);\n }\n }\n }\n println!(\"{}\", ans);\n\n //}\n}\n\n/*\n\n\n*/\n", "lang": "Rust", "bug_code_uid": "33ef846508beee43db9f3ab21f890609", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "apr_id": "724e39a79aede88ea0fe497da8e8ff11", "difficulty": 1600, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9975179260893546, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min};\n#[allow(unused_imports)]\nuse std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};\n#[allow(unused_imports)]\nuse std::fs::File;\n#[allow(unused_imports)]\nuse std::io::prelude::*;\n#[allow(unused_imports)]\nuse std::io::{stdin, stdout, BufReader, BufWriter, Stdin, Stdout, Write};\n#[allow(unused_imports)]\nuse std::mem::swap;\n#[allow(unused_imports)]\nuse std::str::FromStr;\n \ntype BoxResult = Result>;\n \nfn main() {\n let mut scanner = Scanner::new(stdin());\n let s = scanner.read_chars().unwrap();\n let t = scanner.read_chars().unwrap();\n let mut maximum = 0;\n for i in 0..(s.len() - 1) {\n for j in i..s.len() {\n if judge(&s, &t, i, j) {\n maximum = max(j - i + 1, maximum);\n }\n }\n }\n println!(\"{}\", maximum);\n}\n\nfn judge(s: &[char], t: &[char], start: usize, end: usize) -> bool {\n let mut index = 0;\n for i in 0..s.len() {\n if i >= start && i <= end {\n continue;\n }\n if s[i] == t[index] {\n index += 1;\n }\n if index == t.len() {\n break;\n }\n }\n index == t.len()\n}\n \n#[allow(dead_code)]\nstruct Scanner {\n reader: BufReader,\n buffer: String,\n}\n \nimpl Scanner\nwhere\n R: Read,\n{\n #[allow(dead_code)]\n fn new(inner: R) -> Scanner {\n let reader = BufReader::new(inner);\n let buffer = String::new();\n Scanner {\n reader: reader,\n buffer: buffer,\n }\n }\n \n #[allow(dead_code)]\n fn with_capacity(capacity: usize, inner: R) -> Scanner {\n let reader = BufReader::with_capacity(capacity, inner);\n let buffer = String::new();\n Scanner {\n reader: reader,\n buffer: buffer,\n }\n }\n \n #[allow(dead_code)]\n fn read(&mut self) -> BoxResult\n where\n T: FromStr,\n T::Err: std::fmt::Debug,\n T::Err: std::error::Error,\n T::Err: 'static,\n {\n self.reader.read_line(&mut self.buffer)?;\n let parsed = self.buffer.trim().parse()?;\n self.buffer.clear();\n Ok(parsed)\n }\n \n #[allow(dead_code)]\n fn read_vector(&mut self) -> BoxResult>\n where\n T: FromStr,\n T::Err: std::fmt::Debug,\n T::Err: std::error::Error,\n T::Err: 'static,\n {\n self.reader.read_line(&mut self.buffer)?;\n let parsed_vec = self\n .buffer\n .trim()\n .split_whitespace()\n .map(|s| s.parse())\n .collect::, _>>()?;\n self.buffer.clear();\n Ok(parsed_vec)\n }\n \n #[allow(dead_code)]\n fn read_matrix(&mut self, lines: usize) -> BoxResult>>\n where\n T: FromStr,\n T::Err: std::fmt::Debug,\n T::Err: std::error::Error,\n T::Err: 'static,\n {\n let mut parsed_matrix = vec![];\n for _ in 0..lines {\n self.reader.read_line(&mut self.buffer)?;\n parsed_matrix.push(\n self.buffer\n .trim()\n .split_whitespace()\n .map(|s| s.parse())\n .collect::, _>>()?,\n );\n self.buffer.clear();\n }\n Ok(parsed_matrix)\n }\n \n #[allow(dead_code)]\n fn read_chars(&mut self) -> BoxResult> {\n self.reader.read_line(&mut self.buffer)?;\n let chars = self.buffer.trim().chars().collect::>();\n self.buffer.clear();\n Ok(chars)\n }\n}", "lang": "Rust", "bug_code_uid": "b0df93e2cc7c5be589afaaca31cfd61f", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "apr_id": "8913766dfb9b3e3b86513fc9deef4217", "difficulty": 1600, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9773202029245002, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "// use rand::Rng;\nuse std::collections::HashMap;\nuse std::io;\nmacro_rules! parse_input {\n ($x:expr, $t:ident) => {\n $x.trim().parse::<$t>().unwrap()\n };\n}\n\nmacro_rules! split_line {\n ($y:expr, $t:ident) => {\n $y.split(\" \")\n .map(|z| parse_input!(z, $t))\n .collect::>();\n };\n}\n\nstruct xorrand {\n state: u64,\n}\n#[allow(dead_code)]\nimpl xorrand {\n fn rand(&mut self) -> u64 {\n let mut x = self.state;\n x ^= x << 13;\n x ^= x >> 7;\n x ^= x << 17;\n self.state = x;\n self.state.wrapping_mul(0x2545F4914F6CDD1Du64)\n }\n\n fn randint(&mut self, start: u64, end: u64) -> u64 {\n return (self.rand() % (end - start)) + start;\n }\n\n fn randfloat(&mut self) -> f64 {\n 1.0 / (self.rand() as f64)\n }\n\n fn new(seed: u64) -> xorrand {\n xorrand { state: seed }\n }\n\n fn newtime() -> xorrand {\n let start = std::time::SystemTime::now();\n let ms = start\n .duration_since(std::time::UNIX_EPOCH)\n .unwrap()\n .as_secs();\n xorrand { state: ms }\n }\n\n fn shuffle(&mut self, tgt: &mut Vec) {\n for i in 0..tgt.len() - 1 {\n let j = self.randint(i as u64, tgt.len() as u64) as usize;\n let c = tgt[j].clone();\n tgt[j] = tgt[i].clone();\n tgt[i] = c;\n }\n }\n}\n\n#[derive(Debug, Clone)]\nstruct segment {\n start_0: i64,\n start_1: i64,\n end_0: i64,\n end_1: i64,\n}\n\nimpl segment {}\n\nfn solve(a: String, b: String) {\n let mut counters = vec![Vec::::new(); b.len() + 2];\n let mut start = 1;\n for i in 0..a.len() {\n for j in 0..start {\n if a.as_bytes()[i] == b.as_bytes()[j] {\n counters[j + 1].push(i as i64);\n }\n start = std::cmp::min(b.len(), std::cmp::max(start, j + 2));\n }\n }\n let mut end = a.len() as i64;\n for i in (0..b.len()).rev() {\n counters[i + 1].retain(|&x| x < end);\n end = *counters[i + 1].iter().max().unwrap();\n }\n counters[0].push(-1);\n counters[b.len() + 1].push(a.len() as i64);\n let mut best = 0;\n for i in 0..counters.len() - 1 {\n best = std::cmp::max(\n best,\n counters[i + 1].iter().max().unwrap() - counters[i].iter().min().unwrap() - 1,\n );\n }\n println!(\"{}\", best);\n}\n\nfn main() {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n let mut ss = String::new();\n io::stdin().read_line(&mut ss).unwrap();\n let ss = parse_input!(ss, String);\n let input_line = parse_input!(input_line, String);\n solve(input_line, ss);\n // let numTests = parse_input!(input_line, String);\n // solve(numTests as usize, &tgt);\n // // // let numTests = 1;\n // // let mut rng = rand::thread_rng();\n // for _ in 0..numTests {\n // let mut input_line = String::new();\n // io::stdin().read_line(&mut input_line).unwrap();\n // let s = split_line!(input_line, i64);\n // let mut input_line = String::new();\n // io::stdin().read_line(&mut input_line).unwrap();\n // let v = split_line!(input_line, i64);\n // // let v: Vec = (0..10).map(|_| rng.gen_range(0, 10000)).collect();\n\n // solve(s, v);\n // }\n}\n", "lang": "Rust", "bug_code_uid": "fcdd9f7da2459bb9733927d66ab4edba", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "apr_id": "9857b9d9924cc68347b61204c7e839c0", "difficulty": 1600, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9965217391304347, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::cmp::Ordering::*;\n\nfn input_split() -> Vec {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect()\n}\n\nfn main() {\n let input = input_split();\n let first = input[0] * input[1] + 2 * input[3];\n let second = input[0] * input[2] + 2 * input[4];\n print!(\n \"{}\",\n match first.cmp(&second) {\n Less => \"First\",\n Greater => \"Second\",\n Equal => \"Friendship\",\n }\n );\n}", "lang": "Rust", "bug_code_uid": "55d34e601c0553769105c422efc6fc65", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "apr_id": "4faca448ed54ca8b6aa8397baa18565c", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9985096870342772, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input)\n .expect(\"Failed to read line\");\n let input = input.trim().split(\" \").collect::>();\n\n let s = str_to_int(input[0]);\n let v1 = str_to_int(input[1]);\n let v2 = str_to_int(input[2]);\n let t1 = str_to_int(input[3]);\n let t2 = str_to_int(input[4]);\n\n let cli1 = s*v1 + 2*t1;\n let cli2 = s*v2 + 2*t2;\n\n if cli1 < cli2 {\n println!(\"First\");\n } else if cli1 > cli2 {\n println!(\"second\");\n } else {\n println!(\"Friendship\");\n }\n}\n\nfn str_to_int(a:&str) -> i32 {\n a.parse::().unwrap()\n}\n", "lang": "Rust", "bug_code_uid": "3277db3700f04daaf979e54976ac27a3", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "apr_id": "cccdae4d75941036fbce2dd7a9eecd8d", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.302158273381295, "equal_cnt": 7, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "fn main() {\n let n = read_line().parse::().unwrap();\n let mut s: isize = 0;\n\n for i in 1..=n {\n if i % 2 == 0 {\n s += i\n } else {\n s -= i\n }\n }\n println!(\"{}\", s);\n}", "lang": "Rust", "bug_code_uid": "7721bf4e1a5679f566681d74f9fb444d", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "abb931d09cab7480f2c980d609a487b6", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6842105263157895, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "fn main() {\n let n = read_line().parse::().unwrap();\n let mut s: isize = 0;\n\n for i in 1..=n {\n if i % 2 == 0 {\n s += i\n } else {\n s -= i\n }\n }\n println!(\"{}\", s);\n}\n\nfn read_line() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Ошибка чтения\");\n\n buffer.trim().to_string()\n}", "lang": "Rust", "bug_code_uid": "9bcccc48fc2cc91af856b605e1cabfc0", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "abb931d09cab7480f2c980d609a487b6", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999347045380346, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::io::{Write};\nuse std::str;\n\n/// Reads white-space separated tokens one at a time.\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n /// Use \"turbofish\" syntax token::() to select data type of next token.\n ///\n /// # Panics\n ///\n /// Panics if there's an I/O error or if the token cannot be parsed as T.\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\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: str::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\npub fn scanner_from_file(filename: &str) -> Scanner> {\n let file = std::fs::File::open(filename).expect(\"Input file not found\");\n Scanner::new(io::BufReader::new(file))\n}\n\npub fn writer_to_file(filename: &str) -> io::BufWriter {\n let file = std::fs::File::create(filename).expect(\"Output file not found\");\n io::BufWriter::new(file)\n}\n\nfn solve() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n let n = scan.token::();\n let mut ans = n / 2;\n if n % 2 == 1 {\n ans = -ans-1;\n }\n out.write(format!(\"{}\", ans).as_bytes()).unwrap();\n // let k = scan.token::();\n // let mut arr = scan.token::().chars().collect::>();\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(64 * 1024 * 1024)\n .spawn(solve)\n .unwrap()\n .join()\n .unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "192d6aecc929083a115a61569a975486", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "a136d840231ad1cbf49f8886495ae6f2", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9892086330935251, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::mem;\nuse std::io;\nuse std::string;\nuse std::cmp::*;\nuse std::collections::*;\n\nfn load() -> Vec {\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"Failed to read line\");\n let vec: Vec<&str> = line.split(\" \").collect();\n let mut data : Vec = Vec::new();\n for i in vec {\n let el : i32 = i.trim().parse().unwrap();\n data.push(el);\n }\n data\n}\n\nfn main() {\n let s = load()[0];\n println!(\"{}\", ((s+1)/2)*(1-2*(s%2)));\n}\n// min, max\n// HashSet, insert, contains\n// Vec, len, sort\n", "lang": "Rust", "bug_code_uid": "fa71ea66ebb771780b790fc5c5725660", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "8f00cf88e2e26e07a1c80e1bc0465d23", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4539877300613497, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\n\nfn main() {\n\tlet mut n = String::new();\n\tio::stdin().read_line(&mut n).unwrap();\n\tlet n: i32 = n.trim().parse().unwrap();\n\n\tlet mut ans = 0;\n\tfor num in 1..=n {\n\t\tif num % 2 == 0 {\n\t\t\tans += num;\n\t\t} else {\n\t\t\tans -= num;\n\t\t}\n\t}\n\tprintln!(\"{}\", ans);\n}\n\n", "lang": "Rust", "bug_code_uid": "ebeecf61fcf97b7df7fa0e09d37cbdcf", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "26cb5674bda9c1afe51fb8109effc871", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4621212121212121, "equal_cnt": 7, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_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 read_line_val() -> i32 {\n return read_line().parse().unwrap();\n}\n\nfn main() {\n let n = read_line_val();\n\n let mut res = 0;\n\n for i in 1..n + 1 {\n if i % 2 == 0 {\n res += i;\n } else {\n res -= i;\n }\n }\n\n println!(\"{}\", res);\n}", "lang": "Rust", "bug_code_uid": "5c78f8c5b177602477f63cbd851a35ae", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "a70a3c1568e58b0780b4983ab9d0cf4d", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.46515151515151515, "equal_cnt": 6, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_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 read_line_val() -> i64 {\n return read_line().parse().unwrap();\n}\n\nfn main() {\n let n = read_line_val();\n\n let mut res = 0;\n\n for i in 1..n + 1 {\n if i % 2 == 0 {\n res += i;\n } else {\n res -= i;\n }\n }\n\n println!(\"{}\", res);\n}", "lang": "Rust", "bug_code_uid": "328cae69d2dd2e4ffdffb65e81c565aa", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "a70a3c1568e58b0780b4983ab9d0cf4d", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5600448933782267, "equal_cnt": 15, "replace_cnt": 11, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 16, "bug_source_code": "fn main() {\n let m: u32 = get_input().split_ascii_whitespace().last().unwrap().parse().unwrap();\n let mut children: Vec = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();\n \n let res = children.iter().enumerate().max_by(|x, y| x.1.cmp(y.1)).unwrap().0 + 1;\n\n println!(\"{}\", res);\n}\n\n\nfn get_input() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n buffer.trim().to_owned()\n}\n\nfn get_input_usize() -> usize {\n get_input().parse().unwrap()\n}", "lang": "Rust", "bug_code_uid": "430b8507d00e5915033fb6254b2c5153", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "apr_id": "b6f0ffa119323952621927a5a26b8ecb", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9933899905571294, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io::stdin;\n\nfn get_input(input: &mut String) {\n input.clear();\n stdin().read_line(input).expect(\"error\");\n}\n\nfn main() {\n let mut input = String::new();\n get_input(&mut input);\n let mut numbers = input.trim().split_whitespace().filter_map(|n| n.parse::().ok());\n let n = numbers.next().unwrap();\n let k = numbers.next().unwrap();\n\n let mut local_n = 1;\n let mut local_k = k;\n while local_k % 2 != 1 {\n local_k >>= 1;\n local_n += 1;\n }\n\n println!(\"{}\", local_n);\n}\n", "lang": "Rust", "bug_code_uid": "5c3009285892f0ab665ab8a9b9fc2b84", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "apr_id": "ec64ce32315bb79503df61c5c8aac9eb", "difficulty": 1200, "tags": ["implementation", "constructive algorithms", "bitmasks", "binary search"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.24283935242839352, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\nuse std::cmp::Ordering;\n\nfn sequence_position(level: u32, idx: u32) -> u32 {\n match level {\n 1 => 1,\n _ => {\n let half_length = 2_u32.pow(level - 1);\n match idx.cmp(&half_length) {\n Ordering::Less => sequence_position(level - 1, idx),\n Ordering::Equal => level,\n Ordering::Greater => sequence_position(level - 1, idx - half_length)\n }\n }\n }\n}\n\nfn main() {\n let mut input_str = String::new();\n io::stdin().read_line(&mut input_str).unwrap();\n\n let mut iter = input_str.trim().split_whitespace();\n let level: u32 = iter.next().unwrap().parse().unwrap();\n let position: u32 = iter.next().unwrap().parse().unwrap();\n\n println!(\"{}\", sequence_position(level, position));\n}", "lang": "Rust", "bug_code_uid": "a76bcc490aa93c084902ba8144edf860", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "apr_id": "948bcbda9140e682c9facc9fdb4c3903", "difficulty": 1200, "tags": ["implementation", "constructive algorithms", "bitmasks", "binary search"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9897112512446067, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let s = input.bs();\n let mut p = 0;\n for i in 1.. {\n print!(\"{}\", s[p] as char);\n p += i;\n if p >= s.len() {\n break;\n }\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "27a2d1a6afbe1464a60fd4062b903868", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "apr_id": "ae8d769bef79f45e8cbfbf778383cf76", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9916107382550335, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused)] use std::io::*;\n#[allow(unused)] use std::collections::*;\n#[allow(unused)] use std::mem::*;\n#[allow(unused)] use std::num::*;\n#[allow(unused)] fn strarr() -> Vec {\n let mut inp = String::new();\n stdin().read_line(&mut inp).ok();\n inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).map(|x| x.to_string()).collect() }\n#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{\n let s = strarr(); let mut cnt : usize = 0;\n fn next(cnt: &mut usize, p: &Vec) -> T where T:std::str::FromStr { *cnt += 1; p[*cnt-1].parse().ok().unwrap() }\n ($(next::<$x>(&mut cnt, &s)), +)\n }}; }\n#[allow(unused)] macro_rules! arr { ($n:expr, $T:ty) => {{\n let mut s = strarr(); let mut v = Vec::new();\n for i in 0..$n { v.push(s[i as usize].parse::<$T>().unwrap()); } v\n }}; }\n\nfn main()\n{\n let mut ans : i32 = 0;\n \n 'mainloop:\n for i in -2..=2\n {\n let c = arr!(5, i32);\n for j in -2..=2\n {\n let t = c[(j as usize) + 2];\n if t == 1\n {\n ans = i32::abs(i + j);\n break 'mainloop;\n }\n }\n }\n \n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "d95f97c2253320d49c9596d58805a143", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "e57cc6fe5ed52f9980a0ea02dcc6fc2e", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.986627043090639, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::error::Error;\nuse std::io;\n\nfn get_lines() -> io::Result {\n\tlet mut buffer = String::new();\n\tio::stdin().read_line(&mut buffer)?;\n\tOk(buffer)\n}\n\n#[inline(always)]\nfn manhattan_distance(xa: i8, xb: i8, ya: i8, yb: i8) -> i8 {\n\ti8::abs(xb - xa) + i8::abs(yb - ya)\n}\n\nfn main() -> Result<(), Box> {\n\tlet mut matrix = vec![];\n\tlet mut x = 0;\n\tlet mut y = 0;\n\tfor i in 0..5 {\n\t\tlet rows: Vec = get_lines()?\n\t\t\t.split_whitespace()\n\t\t\t.map(|s| s.parse::().unwrap())\n\t\t\t.collect();\n\t\tfor j in 0..5 {\n\t\t\tif rows[j] == 1 {\n\t\t\t\tx = j;\n\t\t\t\ty = i;\n\t\t\t}\n\t\t}\n\t\tmatrix.push(rows);\n\t}\n\tprint!(\"{}\", manhattan_distance(x as i8, y as i8, 2, 2));\n\tOk(())\n}\n", "lang": "Rust", "bug_code_uid": "8c4323f198663efdcb2cfc70018f420e", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "07c0f4382021c97648bd8f6a3ff57260", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9873134328358208, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::*;\n\nfn reads_n(i: &mut StdinLock, n: u32) -> Vec> {\n let mut v2 = Vec::new();\n for _ in 0..n {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n let v = s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect();\n v2.push(v);\n }\n v2\n}\n\nfn search_coord(matrix: Vec>) -> (u8, u8) {\n let mut x = 0;\n let mut y = 0;\n\n for item in matrix.into_iter() {\n x = 0;\n\n for i in item.into_iter() {\n if i == 1 {\n return (x, y);\n }\n x += 1;\n }\n y += 1\n }\n\n (0, 0)\n}\n\nfn distance(a: &(u8, u8), b: &(u8, u8)) -> u8 {\n let ax = a.0 as i64;\n let ay = a.1 as i64;\n let bx = b.0 as i64;\n let by = b.1 as i64;\n\n let diffx = if 0 < (bx - ax) { bx - ax } else { ax - bx };\n let diffy = if 0 < (by - ay) { by - ay } else { ay - by };\n\n diffx as u8 + diffy as u8\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let matrix: Vec> = reads_n(sin, 5);\n let coord = search_coord(matrix);\n\n let mut least: u8 = 255;\n let target: (u8, u8) = (2, 2);\n\n let dist = distance(&target, &coord);\n\n println!(\"{}\", least);\n}\n", "lang": "Rust", "bug_code_uid": "5a30fe81f15bdd2779bdb368bc170c5e", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "916b119f1397a06f8601a27ffe31853b", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9650445510623715, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut guess = String::new();\n let mut i_2:i32 = 0;\n for i in 0_i32..5 {\n io::stdin()\n .read_line(&mut guess)\n .expect(\"Failed to read line\");\n \n for elem in guess.chars() {\n if elem == '1'{\n i_2 +=1;\n\n let aux_i = if (i_2 % 5) == 0 {i_2 + 1} else {i_2};\n let line = aux_i/5;\n let col = i_2%5;\n let mut mv = col-2;\n mv = mv.abs() + (line - 3).abs();\n print!(\"{}\",mv);\n std::process::exit(0);\n }\n else if elem == '0'{\n i_2 +=1;\n }\n }\n guess = String::new();\n }\n}\n", "lang": "Rust", "bug_code_uid": "745a908b30a9aa3dc51027e263916938", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "08806a09c04b6e3c967fe73ee784e615", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7710109622411693, "equal_cnt": 13, "replace_cnt": 9, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 12, "bug_source_code": "use std::io;\n\nfn get_vec_of_numbers() -> Vec {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"Failed to read from stdin\");\n let numbers: Vec = buffer.trim().split(\" \").map(|x| x.trim().parse::().expect(\"Not an integer\")).collect();\n numbers\n}\n\nfn main(){\n let mut matrix: Vec> = Vec::new();\n let mut index_of_one: u32 = 27;\n for i in 0..5 {\n let row = get_vec_of_numbers();\n match row.iter().position(|&x| x == 1) {\n Some(x) => {\n index_of_one = ((i*5)+1+x) as u32\n },\n None => {},\n }\n matrix.push(row);\n }\n let column_gap = (13 - index_of_one) / 5;\n let minimum_number_of_moves = 13 - ((column_gap * 5) + index_of_one);\n println!(\"{}\",minimum_number_of_moves);\n}", "lang": "Rust", "bug_code_uid": "f04ea01cb85ad81d27d6e5ba40bb85c7", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "aaf543252ed4b5ba110b19b4867ed05c", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8486753480017961, "equal_cnt": 22, "replace_cnt": 9, "delete_cnt": 5, "insert_cnt": 8, "fix_ops_cnt": 22, "bug_source_code": "use std::io::stdin;\nfn main() {\n //let mut matrix: [[bool; 5]; 5 as usize] = [[false; 5 as usize]; 5 as usize];\n println!(\"{}\", nearest_middle(parse_matrix()));\n}\nfn parse_matrix() -> Vec {\n let mut result: Vec = vec![];\n for _ in 0..5 {\n let mut row = String::new();\n stdin().read_line(&mut row).expect(\"\");\n let rw: Vec = row\n .trim()\n .split_whitespace()\n .map(|e| {\n return match e.parse::() {\n Ok(a) => {\n if a == 1 {\n return true;\n } else {\n return false;\n }\n }\n _ => false,\n };\n })\n .collect();\n result.extend(rw);\n }\n result\n}\nfn nearest_middle(v: Vec) -> usize {\n if let Some(a) = v.iter().position(|val| *val) {\n return ((v.len() - 1) / 2) - a;\n } else {\n 0\n }\n}\n", "lang": "Rust", "bug_code_uid": "a7f44dcf6bf820f68bf5c96442a48db3", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "b7d605b26628acd09e02425ef47569fc", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5887265135699373, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{self, Read};\nuse std::collections::BTreeSet;\n\nfn main() -> () {\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n handle.read_to_string(&mut buffer).unwrap();\n\n let mut arr = buffer.split_whitespace().take(1).map(|x| x.parse::().unwrap() ).collect::>();\n let n = arr[0] as usize;\n let mut num = buffer.split_whitespace().skip(1).take(1).next().unwrap();\n let mut b = vec![];\n for i in num.chars() {\n let digit = i as u32 - '0' as u32;\n b.push(digit);\n }\n let s : u32 = b.iter().sum();\n \n 'outer: for i in 1..s+1 {\n if s % i == 0 {\n let ss = s / i;\n let mut segsum = 0;\n let mut count_seg = 0;\n for j in 0..n {\n segsum += b[j];\n if segsum == ss {\n segsum = 0;\n count_seg += 1;\n } else if segsum > ss {\n continue 'outer;\n }\n }\n if count_seg > 1 {\n println!(\"YES\");\n return\n }\n }\n }\n\n println!(\"NO\");\n}\n", "lang": "Rust", "bug_code_uid": "dbe8ec388f7d2ce0bd97c85c7ac84c8f", "src_uid": "410296a01b97a0a39b6683569c84d56c", "apr_id": "6901f45eb656614f625c4f24c53e7d5b", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9912023460410557, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input_text = String::new();\n io::stdin()\n .read_line(&mut input_text)\n .expect(\"failed to read from stdin\");\n\n let trimmed = input_text.trim();\n let mut no_of_digits: u32 = 0;\n match trimmed.parse::() {\n Ok(i) => no_of_digits = i,\n Err(..) => println!(\"this was not an integer: {}\", trimmed),\n };\n\n let mut input_digits = String::new();\n \tio::stdin()\n .read_line(&mut input_digits)\n .expect(\"failed to read from stdin\");\n let digits = input_digits.trim();\n\n \tlet mut answer : bool = false;\n \tlet total_sum: u32 = digits.chars().map(|x| x.to_digit(10).unwrap()).sum();\n for i in 1..total_sum {\n let mut sum: u32 = 0;\n \tfor c in digits.chars() {\n\t\t\tlet current_digit = c.to_digit(10).unwrap();\n\t\t\tsum += current_digit;\n\t\t\tif sum == i {\n\t\t\t\tsum = 0;\n\t\t\t}\n \t}\n \tif sum == 0 {\n \t\tanswer = true;\n \t}\n }\n if answer {\n \tprintln!(\"YES\");\n } else {\n \tprintln!(\"NO\");\n }\n}", "lang": "Rust", "bug_code_uid": "07818730060626b1a6e0b134af536a97", "src_uid": "410296a01b97a0a39b6683569c84d56c", "apr_id": "3362e86296b2a64770dc0c36f682a20b", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9936575052854123, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let k: i32 = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().parse().unwrap()\n };\n\n let l: i32 = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().parse().unwrap()\n };\n\n let m: i32 = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().parse().unwrap()\n };\n\n let n: i32 = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().parse().unwrap()\n };\n\n let d: i32 = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().parse().unwrap()\n };\n\n let x = vec![k, l, m, n];\n let ret = (0..d).fold(0, |total, i| if x.iter().any(|&k| i % k == 0) {\n total + 1\n } else {\n total\n });\n println!(\"{:?}\", ret);\n}\n", "lang": "Rust", "bug_code_uid": "15f90c338448bfc61c83642575133136", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "apr_id": "9358470bd149528dbf02418c85a34933", "difficulty": 800, "tags": ["math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9941176470588236, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 5, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_int() -> T{\n read_str().parse::().ok().expect(\"Error\")\n}\n\nfn main() {\n let (k, l, m, n, d): (u32, u32, u32, u32, u32) = (\n read_int(), read_int(), read_int(), read_int(), read_int());\n\n let mut total: u32 = 0;\n for index in 1..d {\n if index % k == 0 { total += 1; }\n else if index % l == 0 { total += 1; }\n else if index % m == 0 { total += 1; }\n else if index % n == 0 { total += 1; }\n }\n print!(\"{}\", total);\n}", "lang": "Rust", "bug_code_uid": "7320688f6e5a6fa8eacd1020a246d459", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "apr_id": "a6d7304a35586ea22e8c76df28a0b47f", "difficulty": 800, "tags": ["math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9991617770326907, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n l!(r,c,rr,cc = input.u());\n let mut g = Vec::with_capacity(r * c);\n {\n l!(g0,x,y,z: i64 = input.p());\n g.push(g0);\n for _ in 1..r*c {\n let a = *g.last().unwrap();\n g.push((a * x + y) % z);\n }\n }\n\n let mut b = vec![vec![0; c]; r];\n let mut gi = g.into_iter();\n for i in 0..r {\n for j in 0..c {\n b[i][j] = gi.next().unwrap();\n }\n }\n let b = b;\n\n let mut x = vec![vec![0; c]; r];\n for i in 0..r {\n let b = &b[i];\n let mut q = VecDeque::new();\n for j in 0..c {\n if !q.is_empty() && *q.front().unwrap() + cc <= j {\n q.pop_front();\n }\n while !q.is_empty() && b[*q.back().unwrap()] >= b[j] {\n q.pop_back();\n }\n q.push_back(j);\n if j + 1 >= cc {\n x[i][j] = b[*q.front().unwrap()];\n }\n }\n }\n\n let mut sol = 0;\n for j in cc - 1..c {\n let mut q = VecDeque::new();\n for i in 0..r {\n if !q.is_empty() && *q.front().unwrap() + rr <= i {\n q.pop_front();\n }\n while !q.is_empty() && b[*q.back().unwrap() as usize][j] >= b[i][j] {\n q.pop_back();\n }\n q.push_back(i);\n if i + 1 >= rr {\n sol += b[*q.front().unwrap()][j];\n }\n }\n }\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "65cf8e4d2c7d6fae7e78de41d29baf73", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "apr_id": "ffed4f5ed1fc4ecdf5f68970772b94c8", "difficulty": 2100, "tags": ["data structures", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6583388704318937, "equal_cnt": 21, "replace_cnt": 15, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 20, "bug_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)*) => (writeln!(out,$($format)*).unwrap());\n }\n\n input!{\n n: usize,\n m: usize,\n a: usize,\n b: usize,\n g0: u64,\n x: u64,\n y: u64,\n z: u64,\n }\n\n let mut hs = vec![];\n let mut g = g0;\n for _ in 0..n*m {\n hs.push(g);\n g = (g * x + y) % z;\n }\n\n use std::collections::BTreeMap;\n\n let mut ans = 0;\n for i in 0..n-a+1 {\n let mut bs = BTreeMap::new();\n for i in i..i+a {\n for j in 0..b {\n let idx = i*m + j;\n *bs.entry(hs[idx]).or_insert(0) += 1;\n }\n }\n\n for j in 0..m-b+1 {\n if j > 0 {\n // Update map\n for i in i..i+a {\n let idx = i*m + j-1;\n let cnt = bs[&hs[idx]];\n if cnt == 1 {\n bs.remove(&hs[idx]);\n } else {\n *bs.entry(hs[idx]).or_insert(0) -= 1;\n }\n\n let idx = i*m + j+b-1;\n *bs.entry(hs[idx]).or_insert(0) += 1;\n }\n }\n let (&v, _) = bs.iter().next().unwrap();\n ans += v;\n }\n }\n puts!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "f561859523b6780f958aaae40e01198f", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "apr_id": "4a037e3278cd5d04ef69cce1e979fe48", "difficulty": 2100, "tags": ["data structures", "two pointers"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6044226044226044, "equal_cnt": 27, "replace_cnt": 19, "delete_cnt": 2, "insert_cnt": 5, "fix_ops_cnt": 26, "bug_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)*) => (writeln!(out,$($format)*).unwrap());\n }\n\n input!{\n n: usize,\n m: usize,\n a: usize,\n b: usize,\n g0: u64,\n x: u64,\n y: u64,\n z: u64,\n }\n\n let mut hs = vec![];\n let mut g = g0;\n for _ in 0..n*m {\n hs.push(g);\n g = (g * x + y) % z;\n }\n\n use std::collections::BTreeMap;\n\n\n const INF: u64 = 1 << 32;\n let mut mins = vec![vec![INF; m]; n];\n\n for i in 0..n-a+1 {\n let mut bs = BTreeMap::new();\n for j in 0..b {\n let idx = i*m + j;\n *bs.entry(hs[idx]).or_insert(0) += 1;\n }\n\n for j in 0..m-b+1 {\n if j > 0 {\n // Update map\n let idx = i*m + j-1;\n let cnt = bs[&hs[idx]];\n if cnt == 1 {\n bs.remove(&hs[idx]);\n } else {\n *bs.entry(hs[idx]).or_insert(0) -= 1;\n }\n\n let idx = i*m + j+b-1;\n *bs.entry(hs[idx]).or_insert(0) += 1;\n }\n let (&v, _) = bs.iter().next().unwrap();\n mins[i][j] = v;\n }\n }\n\n debug!(hs);\n debug!(mins);\n\n let mut ans = 0;\n for j in 0..m-b+1 {\n let mut bs = BTreeMap::new();\n for i in 0..a {\n *bs.entry(mins[i][j]).or_insert(0) += 1;\n }\n\n for i in 0..n-a+1 {\n if i > 0 {\n // Update map\n let prev = mins[i-1][j];\n let cnt = bs[&prev];\n if cnt == 1 {\n bs.remove(&prev);\n } else {\n *bs.entry(prev).or_insert(0) -= 1;\n }\n\n *bs.entry(mins[i][j]).or_insert(0) += 1;\n }\n\n let (&v, _) = bs.iter().next().unwrap();\n ans += v;\n }\n }\n puts!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "37ede0a993dc22fdc3f91e0f779c2149", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "apr_id": "4a037e3278cd5d04ef69cce1e979fe48", "difficulty": 2100, "tags": ["data structures", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9963416172574745, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "// ---------- begin Foldable Deque ----------\nstruct FoldableDeque {\n front: Vec<(T, T)>,\n back: Vec<(T, T)>,\n op: F,\n}\n\n#[allow(dead_code)]\nimpl FoldableDeque\nwhere T: Clone,\n F: Fn(&T, &T) -> T,\n{\n fn new(op: F) -> Self {\n FoldableDeque {\n front: Vec::new(),\n back: Vec::new(),\n op: op,\n }\n }\n fn find(&self) -> Option {\n match (self.front.last(), self.back.last()) {\n (Some(a), Some(b)) => Some((self.op)(&a.1, &b.1)),\n (Some(a), None) => Some(a.1.clone()),\n (None, Some(b)) => Some(b.1.clone()),\n (None, None) => None,\n }\n }\n fn clear(&mut self) {\n self.front.clear();\n self.back.clear();\n }\n fn len(&self) -> usize {\n self.front.len() + self.back.len()\n }\n fn push_back(&mut self, val: T) {\n let sum = if let Some(p) = self.back.last() {\n (self.op)(&p.1, &val)\n } else {\n val.clone()\n };\n self.back.push((val, sum));\n }\n fn push_front(&mut self, val: T) {\n let sum = if let Some(p) = self.front.last() {\n (self.op)(&val, &p.1)\n } else {\n val.clone()\n };\n self.front.push((val, sum));\n }\n fn pop_front(&mut self) -> Option {\n if self.len() == 0 {\n return None;\n }\n if self.front.is_empty() {\n let a = self.back.clone();\n let m = (self.back.len() + 1) / 2;\n self.back.clear();\n let (f, b) = a.split_at(m);\n for v in f.iter().rev() {\n self.push_front(v.0.clone());\n }\n for v in b.iter() {\n self.push_back(v.0.clone());\n }\n }\n self.front.pop().map(|p| p.0)\n }\n fn pop_back(&mut self) -> Option {\n if self.len() == 0 {\n return None;\n }\n if self.back.is_empty() {\n let a = self.front.clone();\n let m = self.front.len() / 2;\n self.front.clear();\n let (f, b) = a.split_at(m);\n for v in f.iter().rev() {\n self.push_front(v.0.clone());\n }\n for v in b.iter() {\n self.push_back(v.0.clone());\n }\n }\n self.back.pop().map(|p| p.0)\n }\n}\n// ---------- end Foldable Deque ----------\n\nuse std::io::Read;\n\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 h: usize = it.next().unwrap().parse().unwrap();\n let w: usize = it.next().unwrap().parse().unwrap();\n let r: usize = it.next().unwrap().parse().unwrap();\n let c: usize = it.next().unwrap().parse().unwrap();\n let mut g: u64 = it.next().unwrap().parse().unwrap();\n let x: u64 = it.next().unwrap().parse().unwrap();\n let y: u64 = it.next().unwrap().parse().unwrap();\n let z: u64 = it.next().unwrap().parse().unwrap();\n let mut a = vec![0u32; h * w];\n for a in a.iter_mut() {\n *a = g as u32;\n g = (g * x + y) % z;\n }\n let mut b = vec![0u32; h * (w - c + 1)];\n let op = |a: &u32, b: &u32| std::cmp::min(*a, *b);\n let mut q = FoldableDeque::new(op);\n for (i, a) in a.chunks(w).enumerate() {\n for a in a.iter().take(c - 1) {\n q.push_back(*a);\n }\n for (b, a) in b[i..].iter_mut().step_by(w - c + 1).zip(a.iter().skip(c - 1)) {\n q.push_back(*a);\n *b = q.find().unwrap();\n q.pop_front();\n }\n }\n let mut ans = 0u64;\n for b in b.chunks(h) {\n q.clear();\n for b in b.iter().take(r - 1) {\n q.push_back(*b);\n }\n for b in b.iter().skip(r - 1) {\n q.push_back(*b);\n ans += q.find().unwrap() as u64;\n q.pop_front();\n }\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "1df5c4b9ac8e10c59eaaadf19eaf6830", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "apr_id": "32b7fe73bfb9416476eeae82a087ea10", "difficulty": 2100, "tags": ["data structures", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9610721123165284, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 7, "bug_source_code": "use std:: io;\n\nfn read_ints() -> Vec {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.split_whitespace().filter_map(|ss| ss.parse().ok()).collect()\n}\n\nfn main() {\n let k: u8;\n if let [_, _k] = read_ints()[..] { k = _k; } else { panic!(\"x\"); }\n\n let a: Vec = read_ints();\n\n let mut ans: u8 = 0;\n let mut flag: usize = 0;\n for (i, aa) in a.iter().enumerate() {\n if aa <= &k {\n ans += 1;\n } else {\n flag = i;\n break;\n }\n }\n flag = a.len() - flag;\n for (i, aa) in a.iter().rev().enumerate() {\n if i <= flag && aa <= &k {\n ans += 1;\n } else {\n break;\n }\n }\n\n println!(\"{}\", ans);\n\n return;\n}\n", "lang": "Rust", "bug_code_uid": "d9c04085d1d8e14d0633f7eb2fc12849", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "apr_id": "f801ad7284ec1f62b5dcbfad55bddc94", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9896698399837959, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "fn main() {\n let stdin = std::io::stdin();\n let lock = stdin.lock();\n let mut r = io::Reader::new(lock);\n let mut w = io::Writer::new();\n\n let l = ['c', 'o', 'd', 'e', 'f', 'o', 'r', 'c', 'e', 's'];\n let mut v = vec![1usize; 10];\n let mut max_comb = 1;\n let mut selection = 0;\n let n: usize = r.read()[0];\n \n while max_comb <= n {\n for i in 0..v.len() {\n let comb = compute(&v, i);\n if comb > max_comb {\n selection = i;\n max_comb = comb;\n }\n }\n v[selection] += 1;\n }\n\n for i in 0..v.len() {\n for _ in 0..v[i] {\n w.push(l[i]);\n }\n }\n w.push('\\n');\n \n w.write();\n}\n\nfn compute(v: &Vec, i: usize) -> usize {\n let mut comb = 1;\n for j in 0..v.len() {\n comb *= if j == i { v[j] + 1 } else { v[j] }\n }\n\n comb\n}\n\npub mod io {\n use std::fmt::{Debug, Display};\n use std::io::{BufRead, StdinLock};\n use std::str::FromStr;\n\n pub struct Reader<'a> {\n buffer: String,\n lock: StdinLock<'a>,\n }\n\n impl<'a> Reader<'a> {\n pub fn new(lock: StdinLock<'a>) -> Self {\n Reader {\n buffer: String::with_capacity(4 * 1024 * 1024),\n lock,\n }\n }\n\n pub fn read(&mut self) -> Vec\n where\n T: Copy + FromStr + Display,\n ::Err: Debug,\n {\n self.buffer.clear();\n\n self.lock\n .read_line(&mut self.buffer)\n .expect(\"Failed to get input\");\n\n self.buffer\n .trim()\n .split_whitespace()\n .map(|x| x.parse().expect(\"Failed to parse value\"))\n .collect()\n }\n }\n\n pub struct Writer {\n buffer: String,\n }\n\n impl Writer {\n pub fn new() -> Self {\n Writer {\n buffer: String::with_capacity(4 * 1024 * 1024),\n }\n }\n\n pub fn push(&mut self, data: T) {\n self.buffer.push_str(&format!(\"{}\", data));\n }\n\n pub fn pushw(&mut self, data: T) {\n self.buffer.push_str(&format!(\"{} \", data));\n }\n\n pub fn pushln(&mut self, data: T) {\n self.buffer.push_str(&format!(\"{}\\n\", data));\n }\n\n pub fn write(&self) {\n print!(\"{}\", self.buffer);\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "a3f8e0a5b48b24023cc1b513b043623e", "src_uid": "8001a7570766cadcc538217e941b3031", "apr_id": "cec56fe64938f33a792c3d1ba045e5ae", "difficulty": 1500, "tags": ["greedy", "math", "brute force", "strings", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8706867671691793, "equal_cnt": 11, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 6, "fix_ops_cnt": 10, "bug_source_code": "#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]\nuse std::cmp::*;\nuse std::collections::*;\nuse std::mem::*;\n\nfn main() {\n let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());\n let mut io = IO::new(r.lock(), w.lock(), e.lock());\n assert_eq!(!0usize, std::usize::MAX); //🙊\n assert!(0 == 0); //😇\n let k = io.read::();\n io.write(\"codeforce\");\n for _ in 0..k {\n io.write(\"s\");\n }\n}\n\nstatic MX: usize = 1010101;\nstatic MOD: i64 = 1000000007;\nstatic INF: i64 = std::i64::MAX >> 1;\n// IO\nuse std::io::*;\nstruct IO {\n Read: R,\n Write: BufWriter,\n Error: BufWriter,\n}\nimpl IO {\n fn new(r: R, w: W, e: E) -> IO {\n IO {\n Read: r,\n Write: BufWriter::new(w),\n Error: BufWriter::new(e),\n }\n }\n fn read(&mut self) -> T\n where\n T: std::str::FromStr,\n {\n let next: String = self\n .Read\n .by_ref()\n .bytes()\n .map(|c| c.unwrap() as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect();\n next.parse().ok().unwrap()\n }\n fn chars(&mut self) -> Vec {\n self.read::().chars().collect()\n }\n fn chari(&mut self) -> Vec {\n self.chars()\n .iter()\n .map(|&c| (c as u8 - b'0') as i64)\n .collect::>()\n }\n fn readn(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read::()).collect::>()\n }\n fn readmat(&mut self, n: usize, m: usize) -> Vec> {\n (0..n).map(|_| self.readn(m)).collect()\n }\n fn write(&mut self, val: S) {\n self.Write.write(val.to_string().as_bytes());\n }\n fn writeln(&mut self, val: S) {\n self.Write.write(val.to_string().as_bytes());\n self.Write.write(b\"\\n\");\n }\n fn debug(&mut self, val: S) {\n writeln!(self.Error, \"(debug) {:?}\", &val);\n }\n fn debug2(&mut self, val1: S, val2: T) {\n writeln!(self.Error, \"(debug2) {:?} -> {:?}\", val1, val2);\n }\n fn debug3(\n &mut self,\n val1: S,\n val2: T,\n val3: U,\n ) {\n writeln!(\n self.Error,\n \"(debug3) {:?} -> {:?} -> {:?}\",\n val1, val2, val3\n );\n }\n}\n", "lang": "Rust", "bug_code_uid": "19dffc29d695afc00e6deb51b5633b3b", "src_uid": "8001a7570766cadcc538217e941b3031", "apr_id": "fadfdab8f7750ccf88fdb929c8c441ea", "difficulty": 1500, "tags": ["greedy", "math", "brute force", "strings", "constructive algorithms"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7159726538222498, "equal_cnt": 19, "replace_cnt": 10, "delete_cnt": 3, "insert_cnt": 5, "fix_ops_cnt": 18, "bug_source_code": "fn solve() {\n let mut n: i32 = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim_end().parse().unwrap()\n };\n\n let mut v = Vec::new();\n let mut i = 0;\n for i in 0..10 {\n v.push((i, 1));\n }\n while n > 0 {\n v[i].1 += 1;\n i += 1;\n i %= 10;\n n /= 2;\n }\n\n let s = \"codeforces\";\n for a in v {\n print!(\"{}\", (s.chars().nth(a.0).unwrap()).to_string().repeat(a.1));\n }\n}\n\nfn main() {\n // let t: u32 = {\n // let mut buf = String::new();\n // std::io::stdin().read_line(&mut buf).unwrap();\n // buf.trim_end().parse().unwrap()\n // };\n\n // for _ in 0..t {}\n solve();\n}\n", "lang": "Rust", "bug_code_uid": "a699e5c9b5976186e41812f35c1d5c8f", "src_uid": "8001a7570766cadcc538217e941b3031", "apr_id": "6938ba11e2eb958ff651dd0eccf72923", "difficulty": 1500, "tags": ["greedy", "math", "brute force", "strings", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9966139954853274, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn solve() {\n let mut n: i32 = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim_end().parse().unwrap()\n };\n\n let mut v = vec![1; 10];\n\n let mut i = 0;\n loop {\n let mut m = v.iter().fold(1, |mul, a| mul * a);\n if m >= n {\n break;\n }\n v[i] += 1;\n i += 1;\n i %= 10;\n }\n\n for (i, a) in v.iter().enumerate() {\n print!(\n \"{}\",\n \"codeforces\"\n .chars()\n .nth(i)\n .unwrap()\n .to_string()\n .repeat(*a as usize)\n );\n }\n}\n\nfn main() {\n // let t: u32 = {\n // let mut buf = String::new();\n // std::io::stdin().read_line(&mut buf).unwrap();\n // buf.trim_end().parse().unwrap()\n // };\n\n // for _ in 0..t {}\n solve();\n}\n", "lang": "Rust", "bug_code_uid": "2f01c39f6293f91e749d0db14336874c", "src_uid": "8001a7570766cadcc538217e941b3031", "apr_id": "6938ba11e2eb958ff651dd0eccf72923", "difficulty": 1500, "tags": ["greedy", "math", "brute force", "strings", "constructive algorithms"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9961734693877551, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nfn main(){\n let mut s=String::new();\n io::stdin().read_line(&mut s).expect(\"Something is wrong\");\n let n=&s[0..s.find(' ').unwrap()];\n let mut n:i64=n.trim().parse().unwrap();\n let k=&s[s.find(' ').unwrap()+1..s.len()]; \n let mut k:i64=k.trim().parse().unwrap();\n let mut a:i64=n;\n let mut p:i64=0;\n while a%10==0{\n p+=1;\n a/=10;\n }\n if p>=k{println!(\"{} {}\",n,a)}\n else{k=k-p;\n match a%10{\n 1|3|7|9=>{for c in 0..k{n*=10}println!(\"{}\",n)},\n 5=>{while a%5==0{p+=1;a/=5;}if k>=p{for c in 0..p{n*=2}for c in 0..k-p{n*=10}}else{for c in 0..k{n*=2}}println!(\"{}\",n);},\n _=>{while a%2==0{p+=1;a/=2;}if k>=p{for c in 0..p{n*=5}for c in 0..k-p{n*=10}}else{for c in 0..k{n*=5}}println!(\"{}\",n);},\n }\n}\n}\n", "lang": "Rust", "bug_code_uid": "31a81e9c426e25fceab62222be5dcc39", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "apr_id": "975df4e9f390eed9ff2845ca73a1350b", "difficulty": 1100, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9990925589836661, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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 mut res = 0usize;\n let n: usize = scan.next();\n let m: usize = scan.next();\n let limit: usize = n.max(m);\n for i in 0..limit {\n for j in 0..limit {\n if i * i + j == n && i + j * j == m {\n res += 1;\n }\n }\n }\n println!(\"{}\", res);\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": "Rust", "bug_code_uid": "35ad5c068d18779e888e045d6bbbedea", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "apr_id": "75d1e0b34c0c2f5201e6eb283c1ee5f3", "difficulty": 800, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9983948635634029, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn read_line() -> Option {\n let stdin = std::io::stdin();\n let mut line = String::new();\n if stdin.read_line(&mut line).unwrap_or(0) > 0 {\n Some(line.trim().into())\n } else {\n None\n }\n}\n\nfn main() {\n fn should_flip(c: char) -> bool {\n (\n (c.is_digit(10) && (c as u8 - '0' as u8) % 2 == 0) ||\n (['a', 'e', 'i', 'o', 'u'].iter().find(|&&a| a == c).is_some())\n )\n }\n let flips = read_line()\n .expect(\"should have line\")\n .chars()\n .fold(0, |acc, c| if should_flip(c) { acc + 1 } else { acc });\n println!(\"{}\", flips);\n}\n", "lang": "Rust", "bug_code_uid": "ae89415ce97184d3fb186d251733c3ec", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "apr_id": "e40e6adfaa736dcc6903959c31bd51d9", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9396429583451402, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nconst MOD: u64 = 1_000_000_007;\n\nfn mod_pow(r: u64, mut n: u64) -> u64 {\n let mut t = 1;\n let mut s = r % MOD;\n while n > 0 {\n if n & 1 == 1 {\n t = t * s % MOD;\n }\n s = s * s % MOD;\n n >>= 1;\n }\n t\n}\n\nfn run() {\n input! {\n n: u64,\n m: u64,\n k: i32,\n }\n let mut ans = if k == 1 {\n 1 + (mod_pow(2, n - 1) - 1) * (mod_pow(2, m - 1) - 1)\n } else {\n mod_pow(2, n - 1) * mod_pow(2, m - 1)\n };\n ans %= MOD;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "86e66816e83637c8ebe85da56c61e89a", "src_uid": "6b9eff690fae14725885cbc891ff7243", "apr_id": "113ad9a6e82f93d238a96b2de29fb8b7", "difficulty": 1800, "tags": ["math", "combinatorics", "number theory", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9809412679891093, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::cmp::{max, min};\n\nfn get_line() -> String {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input\n}\n\nfn get_vec() -> Vec\nwhere T: FromStr,\n ::Err: std::fmt::Debug,\n{\n get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nconst p: i64 = 1_000_000_007;\n\nfn main() {\n let (n, m, k) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|x| x.parse::().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n // (2^{n - 1})^{m - 1}\n // 2^{n + m - 2}\n\n if k == -1 && (n + m) % 2 != 0 {\n println!(\"0\");\n return;\n }\n\n let n0 = ((n - 1) % p) * ((m - 1) % p) % p;\n\n let mut two_pow_two_pow = Vec::new();\n\n let mul = |a, b| {\n ((a % p) * (b % p)) % p\n };\n\n let mut i = 2;\n for _ in 0..40 {\n two_pow_two_pow.push(i);\n i = mul(i, i);\n }\n\n let mut ans = 1;\n\n for i in 0..40 {\n if n0 & (1 << i) != 0 {\n ans = mul(ans, two_pow_two_pow[i]);\n }\n }\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "426af614f0febd02f540aa864e83daf8", "src_uid": "6b9eff690fae14725885cbc891ff7243", "apr_id": "fc23fe4fed4bcc92b24ee6fe2617df4f", "difficulty": 1800, "tags": ["math", "combinatorics", "number theory", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9922848664688427, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "fn read_line() -> String {\n let stdin = std::io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).unwrap();\n String::from(line.trim())\n}\n\nmacro_rules! scan_line {\n ($($ty: ty),*) => {{\n let line = read_line();\n let mut tok = line.split_whitespace();\n ($(tok.next().unwrap().parse::<$ty>().unwrap()),*)\n }}\n}\n\nconst MOD: i64 = 1_000_000_007;\n\nfn pow_with_mod(mut a: i64, mut n: i64) -> i64 {\n let mut acc = 1;\n a = a % MOD;\n while n > 0 {\n if n & 1 == 1 {\n acc = (acc * a) % MOD;\n }\n a = (a * a) % MOD;\n n >>= 1;\n }\n acc\n}\n\nfn main() {\n let (n, m, _) = scan_line!(i64, i64, i32);\n let ans = if n % 2 != m % 2 {\n 0\n } else {\n pow_with_mod(pow_with_mod(2, n - 1), m - 1)\n };\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "061dc0f0c448a17202a091b3df7809e8", "src_uid": "6b9eff690fae14725885cbc891ff7243", "apr_id": "ab8ae9b2b09129d02f3f75814a1a3985", "difficulty": 1800, "tags": ["math", "combinatorics", "number theory", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8729543162956643, "equal_cnt": 65, "replace_cnt": 42, "delete_cnt": 5, "insert_cnt": 17, "fix_ops_cnt": 64, "bug_source_code": "// ---------- begin Matrix ----------\n#[allow(dead_code)]\nmod matrix {\n use std::ops::{Add, Mul};\n pub trait SemiRing: Add + Mul + Copy {\n fn zero() -> Self;\n fn one() -> Self;\n }\n pub const SIZE: usize = 128;\n #[derive(Clone)]\n pub struct SquareMatrix {\n buf: [[T; SIZE]; SIZE],\n }\n impl SquareMatrix {\n pub fn zero() -> Self {\n let z = T::zero();\n SquareMatrix {\n buf: [[z; SIZE]; SIZE],\n }\n }\n pub fn identity() -> Self {\n let mut m = Self::zero();\n for i in 0..SIZE {\n m.buf[i][i] = T::one();\n }\n m\n }\n pub fn get_mut(&mut self, i: usize, j: usize) -> &mut T {\n &mut self.buf[i][j]\n }\n pub fn get(&self, i: usize, j: usize) -> &T {\n &self.buf[i][j]\n }\n pub fn matmul(&self, rhs: &Self) -> Self {\n let mut res = Self::zero();\n for (x, a) in res.buf.iter_mut().zip(self.buf.iter()) {\n for (a, b) in a.iter().zip(rhs.buf.iter()) {\n for (x, b) in x.iter_mut().zip(b.iter()) {\n *x = *x + *a * *b;\n }\n }\n }\n res\n }\n pub fn matadd(&self, rhs: &Self) -> Self {\n let mut c = Self::zero();\n for (c, (a, b)) in c.buf.iter_mut().zip(self.buf.iter().zip(rhs.buf.iter())) {\n for (c, (a, b)) in c.iter_mut().zip(a.iter().zip(b.iter())) {\n *c = *a + *b;\n }\n }\n c\n }\n pub fn matpow(&self, mut n: usize) -> Self {\n let mut t = Self::identity();\n let mut s = self.clone();\n while n > 0 {\n if n & 1 == 1 {\n t = t.matmul(&s);\n }\n s = s.matmul(&s);\n n >>= 1;\n }\n t\n }\n }\n}\n// ---------- end Matrix ----------\n// ---------- begin ModInt ----------\nmod modint {\n\n #[allow(dead_code)]\n pub struct Mod;\n impl ConstantModulo for Mod {\n const MOD: u32 = 1_000_000_007;\n }\n\n #[allow(dead_code)]\n pub struct StaticMod;\n static mut STATIC_MOD: u32 = 0;\n impl Modulo for StaticMod {\n fn modulo() -> u32 {\n unsafe { STATIC_MOD }\n }\n }\n\n #[allow(dead_code)]\n impl StaticMod {\n pub fn set_modulo(p: u32) {\n unsafe {\n STATIC_MOD = p;\n }\n }\n }\n\n use std::marker::*;\n use std::ops::*;\n\n pub trait Modulo {\n fn modulo() -> u32;\n }\n\n pub trait ConstantModulo {\n const MOD: u32;\n }\n\n impl Modulo for T\n where\n T: ConstantModulo,\n {\n fn modulo() -> u32 {\n T::MOD\n }\n }\n\n pub struct ModInt(pub u32, PhantomData);\n\n impl Clone for ModInt {\n fn clone(&self) -> Self {\n ModInt::new_unchecked(self.0)\n }\n }\n\n impl Copy for ModInt {}\n\n impl Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: Self) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n ModInt::new_unchecked(d)\n }\n }\n\n impl AddAssign for ModInt {\n fn add_assign(&mut self, rhs: Self) {\n *self = *self + rhs;\n }\n }\n\n impl Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: Self) -> Self::Output {\n let mut d = T::modulo() + self.0 - rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n ModInt::new_unchecked(d)\n }\n }\n\n impl SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: Self) {\n *self = *self - rhs;\n }\n }\n\n impl Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: Self) -> Self::Output {\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\n ModInt::new_unchecked(v as u32)\n }\n }\n\n impl MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: Self) {\n *self = *self * rhs;\n }\n }\n\n impl Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n if self.0 == 0 {\n Self::zero()\n } else {\n Self::new_unchecked(T::modulo() - self.0)\n }\n }\n }\n\n impl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n }\n\n impl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n }\n\n impl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: u64) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: i64) -> ModInt {\n let m = T::modulo() as i64;\n ModInt::new((val % m + m) as u32)\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n pub fn new_unchecked(d: u32) -> Self {\n ModInt(d, PhantomData)\n }\n pub fn zero() -> Self {\n ModInt::new_unchecked(0)\n }\n pub fn one() -> Self {\n ModInt::new_unchecked(1)\n }\n pub fn is_zero(&self) -> bool {\n self.0 == 0\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n pub fn new(d: u32) -> Self {\n ModInt::new_unchecked(d % T::modulo())\n }\n pub fn pow(&self, mut n: u64) -> Self {\n let mut t = Self::one();\n let mut s = *self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(&self) -> Self {\n assert!(self.0 != 0);\n self.pow(T::modulo() as u64 - 2)\n }\n }\n\n #[allow(dead_code)]\n pub fn mod_pow(r: u64, mut n: u64, m: u64) -> u64 {\n let mut t = 1 % m;\n let mut s = r % m;\n while n > 0 {\n if n & 1 == 1 {\n t = t * s % m;\n }\n s = s * s % m;\n n >>= 1;\n }\n t\n }\n}\n// ---------- end ModInt ----------\n// ---------- begin Precalc ----------\nmod precalc {\n use super::modint::*;\n #[allow(dead_code)]\n pub struct Precalc {\n inv: Vec>,\n fact: Vec>,\n ifact: Vec>,\n }\n #[allow(dead_code)]\n impl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n fact[i] = fact[i - 1] * ModInt::new_unchecked(i as u32);\n }\n ifact[n] = fact[n].inv();\n if n > 0 {\n inv[n] = ifact[n] * fact[n - 1];\n }\n for i in (1..n).rev() {\n ifact[i] = ifact[i + 1] * ModInt::new_unchecked((i + 1) as u32);\n inv[i] = ifact[i] * fact[i - 1];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n assert!(n > 0);\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn perm(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[n - k]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n }\n}\n// ---------- end Precalc ----------\n// ---------- begin input macro ----------\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n// ---------- end input macro ----------\n\nuse modint::*;\ntype M = ModInt;\n\nuse matrix::*;\ntype Mat = SquareMatrix;\n\nimpl SemiRing for M {\n fn zero() -> Self {\n M::zero()\n }\n fn one() -> Self {\n M::one()\n }\n}\n\nfn run() {\n input! {\n w: [usize; 7],\n }\n // 0: 置いてok\n // 1: おいたらダメ\n let mut mat = vec![];\n for i in 1..=7 {\n let mut m = Mat::zero();\n for j in 0..(1 << i) {\n for k in 0..(1 << (2 * i - 1)) {\n if j & k > 0 {\n continue;\n }\n let mut next = 0;\n for x in 0..i {\n let left = x == 0 || (k >> (i + x - 1)) & 1 == 1;\n let down = k >> x & 1 == 1;\n let right = x == i - 1 || (k >> (i + x)) & 1 == 1;\n if left && down && right {\n next |= 1 << x;\n }\n }\n *m.get_mut(next, j) += M::one();\n }\n }\n mat.push(m);\n let mut m = Mat::zero();\n for j in 0..(1 << i) {\n *m.get_mut(j, j) = M::one();\n }\n mat.push(m);\n }\n let mul = |m: &Mat, b: &[M]| -> Vec {\n let mut res = vec![M::zero(); b.len()];\n for i in 0..b.len() {\n for j in 0..b.len() {\n res[i] += *m.get(i, j) * b[j];\n }\n }\n res\n };\n let mut b = vec![M::zero(); 1 << 7];\n let mut ini = false;\n let mut w = w;\n for (i, (w, mat)) in w.iter_mut().zip(mat.chunks(2)).enumerate().rev() {\n if !ini && *w > 0 {\n *w -= 1;\n ini = true;\n let i = i + 1;\n for k in 0..(1 << (i - 1)) {\n let mut bit = 0;\n for x in 0..i {\n let left = x == 0 || k >> (x - 1) & 1 == 1;\n let down = true;\n let right = x == i - 1 || k >> x & 1 == 1;\n if left && right && down {\n bit |= 1 << x;\n }\n }\n b[bit] += M::one();\n }\n }\n b = mul(&mat[1], &b);\n b = mul(&mat[0].matpow(*w), &b);\n }\n let ans = b[0];\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "1428e6a4417da1121b3d3aaaa9d9eee9", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "apr_id": "d0c9884934c199dfe05a6e8acd4b1539", "difficulty": 2700, "tags": ["matrices", "dp"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7010983685995801, "equal_cnt": 44, "replace_cnt": 30, "delete_cnt": 5, "insert_cnt": 8, "fix_ops_cnt": 43, "bug_source_code": "// ---------- begin Matrix ----------\nmod matrix {\n use std::ops::*;\n pub trait SemiRing: Add + Mul + Copy {\n fn zero() -> Self;\n fn one() -> Self;\n }\n #[derive(Clone)]\n pub struct SquareMatrix {\n size: usize,\n buf: Box<[R]>,\n }\n #[allow(dead_code)]\n impl SquareMatrix {\n pub fn zero(size: usize) -> Self {\n SquareMatrix {\n size: size,\n buf: vec![R::zero(); size * size].into_boxed_slice(),\n }\n }\n pub fn identity(size: usize) -> Self {\n let mut e = Self::zero(size);\n for i in 0..size {\n e.buf[i * size + i] = R::one();\n }\n e\n }\n pub fn get(&self, x: usize, y: usize) -> &R {\n assert!(x < self.size && y < self.size);\n &self.buf[x * self.size + y]\n }\n pub fn get_mut(&mut self, x: usize, y: usize) -> &mut R {\n assert!(x < self.size && y < self.size);\n &mut self.buf[x * self.size + y]\n }\n pub fn matadd(&self, rhs: &Self) -> Self {\n assert!(self.size == rhs.size);\n let buf: Vec = self\n .buf\n .iter()\n .zip(rhs.buf.iter())\n .map(|p| *p.0 + *p.1)\n .collect();\n SquareMatrix {\n size: self.size,\n buf: buf.into_boxed_slice(),\n }\n }\n pub fn matmul(&self, rhs: &Self) -> Self {\n let size = self.size;\n assert!(size == rhs.size);\n let mut res = Self::zero(size);\n for (x, a) in res.buf.chunks_mut(size).zip(self.buf.chunks(size)) {\n for (a, b) in a.iter().zip(rhs.buf.chunks(size)) {\n for (x, b) in x.iter_mut().zip(b.iter()) {\n *x = *x + *a * *b;\n }\n }\n }\n res\n }\n pub fn mat_pow(&self, mut n: usize) -> Self {\n let size = self.size;\n let mut t = Self::identity(size);\n let mut s = self.clone();\n while n > 0 {\n if n & 1 == 1 {\n t = t.matmul(&s);\n }\n s = s.matmul(&s);\n n >>= 1;\n }\n t\n }\n }\n #[allow(dead_code)]\n impl> SquareMatrix {\n pub fn matsub(&self, rhs: &Self) -> Self {\n assert!(self.size == rhs.size);\n let buf: Vec = self\n .buf\n .iter()\n .zip(rhs.buf.iter())\n .map(|p| *p.0 - *p.1)\n .collect();\n SquareMatrix {\n size: self.size,\n buf: buf.into_boxed_slice(),\n }\n }\n }\n}\n// ---------- end Matrix ----------\n// ---------- begin ModInt ----------\nmod modint {\n\n #[allow(dead_code)]\n pub struct Mod;\n impl ConstantModulo for Mod {\n const MOD: u32 = 1_000_000_007;\n }\n\n #[allow(dead_code)]\n pub struct StaticMod;\n static mut STATIC_MOD: u32 = 0;\n impl Modulo for StaticMod {\n fn modulo() -> u32 {\n unsafe { STATIC_MOD }\n }\n }\n\n #[allow(dead_code)]\n impl StaticMod {\n pub fn set_modulo(p: u32) {\n unsafe {\n STATIC_MOD = p;\n }\n }\n }\n\n use std::marker::*;\n use std::ops::*;\n\n pub trait Modulo {\n fn modulo() -> u32;\n }\n\n pub trait ConstantModulo {\n const MOD: u32;\n }\n\n impl Modulo for T\n where\n T: ConstantModulo,\n {\n fn modulo() -> u32 {\n T::MOD\n }\n }\n\n pub struct ModInt(pub u32, PhantomData);\n\n impl Clone for ModInt {\n fn clone(&self) -> Self {\n ModInt::new_unchecked(self.0)\n }\n }\n\n impl Copy for ModInt {}\n\n impl Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: Self) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n ModInt::new_unchecked(d)\n }\n }\n\n impl AddAssign for ModInt {\n fn add_assign(&mut self, rhs: Self) {\n *self = *self + rhs;\n }\n }\n\n impl Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: Self) -> Self::Output {\n let mut d = T::modulo() + self.0 - rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n ModInt::new_unchecked(d)\n }\n }\n\n impl SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: Self) {\n *self = *self - rhs;\n }\n }\n\n impl Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: Self) -> Self::Output {\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\n ModInt::new_unchecked(v as u32)\n }\n }\n\n impl MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: Self) {\n *self = *self * rhs;\n }\n }\n\n impl Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n if self.0 == 0 {\n Self::zero()\n } else {\n Self::new_unchecked(T::modulo() - self.0)\n }\n }\n }\n\n impl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n }\n\n impl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n }\n\n impl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: u64) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: i64) -> ModInt {\n let m = T::modulo() as i64;\n ModInt::new((val % m + m) as u32)\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n pub fn new_unchecked(d: u32) -> Self {\n ModInt(d, PhantomData)\n }\n pub fn zero() -> Self {\n ModInt::new_unchecked(0)\n }\n pub fn one() -> Self {\n ModInt::new_unchecked(1)\n }\n pub fn is_zero(&self) -> bool {\n self.0 == 0\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n pub fn new(d: u32) -> Self {\n ModInt::new_unchecked(d % T::modulo())\n }\n pub fn pow(&self, mut n: u64) -> Self {\n let mut t = Self::one();\n let mut s = *self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(&self) -> Self {\n assert!(self.0 != 0);\n self.pow(T::modulo() as u64 - 2)\n }\n }\n\n #[allow(dead_code)]\n pub fn mod_pow(r: u64, mut n: u64, m: u64) -> u64 {\n let mut t = 1 % m;\n let mut s = r % m;\n while n > 0 {\n if n & 1 == 1 {\n t = t * s % m;\n }\n s = s * s % m;\n n >>= 1;\n }\n t\n }\n}\n// ---------- end ModInt ----------\n// ---------- begin Precalc ----------\nmod precalc {\n use super::modint::*;\n #[allow(dead_code)]\n pub struct Precalc {\n inv: Vec>,\n fact: Vec>,\n ifact: Vec>,\n }\n #[allow(dead_code)]\n impl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n fact[i] = fact[i - 1] * ModInt::new_unchecked(i as u32);\n }\n ifact[n] = fact[n].inv();\n if n > 0 {\n inv[n] = ifact[n] * fact[n - 1];\n }\n for i in (1..n).rev() {\n ifact[i] = ifact[i + 1] * ModInt::new_unchecked((i + 1) as u32);\n inv[i] = ifact[i] * fact[i - 1];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n assert!(n > 0);\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn perm(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[n - k]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n }\n}\n// ---------- end Precalc ----------\n// ---------- begin input macro ----------\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n// ---------- end input macro ----------\n\nuse modint::*;\ntype M = ModInt;\n\nuse matrix::*;\ntype Mat = SquareMatrix;\n\nimpl SemiRing for M {\n fn zero() -> Self {\n M::zero()\n }\n fn one() -> Self {\n M::one()\n }\n}\n\nfn run() {\n input! {\n w: [usize; 7],\n }\n // 0: 置いてok\n // 1: おいたらダメ\n let mut mat = vec![];\n for i in 1..=7 {\n let mut m = Mat::zero(1 << 7);\n for j in 0..(1 << i) {\n for k in 0..(1 << (2 * i - 1)) {\n if j & k > 0 {\n continue;\n }\n let mut next = 0;\n for x in 0..i {\n let left = x == 0 || (k >> (i + x - 1)) & 1 == 1;\n let down = k >> x & 1 == 1;\n let right = x == i - 1 || (k >> (i + x)) & 1 == 1;\n if left && down && right {\n next |= 1 << x;\n }\n }\n *m.get_mut(next, j) += M::one();\n }\n }\n mat.push(m);\n let mut m = Mat::zero(1 << 7);\n for j in 0..(1 << i) {\n *m.get_mut(j, j) = M::one();\n }\n mat.push(m);\n }\n let mul = |m: &Mat, b: &[M]| -> Vec {\n let mut res = vec![M::zero(); b.len()];\n for i in 0..b.len() {\n for j in 0..b.len() {\n res[i] += *m.get(i, j) * b[j];\n }\n }\n res\n };\n let mut b = vec![M::zero(); 1 << 7];\n let mut ini = false;\n let mut w = w;\n for (i, (w, mat)) in w.iter_mut().zip(mat.chunks(2)).enumerate().rev() {\n if !ini && *w > 0 {\n *w -= 1;\n ini = true;\n let i = i + 1;\n for k in 0..(1 << (i - 1)) {\n let mut bit = 0;\n for x in 0..i {\n let left = x == 0 || k >> (x - 1) & 1 == 1;\n let down = true;\n let right = x == i - 1 || k >> x & 1 == 1;\n if left && right && down {\n bit |= 1 << x;\n }\n }\n b[bit] += M::one();\n }\n }\n b = mul(&mat[1], &b);\n b = mul(&mat[0].mat_pow(*w), &b);\n }\n let ans = b[0];\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "df36058a25cce35d451a3760450b4a2f", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "apr_id": "d0c9884934c199dfe05a6e8acd4b1539", "difficulty": 2700, "tags": ["matrices", "dp"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9997386987196237, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "// ---------- begin ModInt ----------\nmod modint {\n\n #[allow(dead_code)]\n pub struct Mod;\n impl Modulo for Mod {\n fn modulo() -> u32 {\n 1_000_000_007\n }\n fn rem() -> u32 {\n 2226617417\n }\n fn ini() -> u64 {\n 582344008\n }\n }\n\n use std::marker::*;\n use std::ops::*;\n\n pub trait Modulo {\n fn modulo() -> u32;\n fn rem() -> u32;\n fn ini() -> u64;\n }\n\n pub struct ModInt(pub u32, PhantomData);\n\n impl Clone for ModInt {\n fn clone(&self) -> Self {\n Self::new_unchecked(self.0)\n }\n }\n\n impl Copy for ModInt {}\n\n impl Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: Self) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n Self::new_unchecked(d)\n }\n }\n\n impl AddAssign for ModInt {\n fn add_assign(&mut self, rhs: Self) {\n *self = *self + rhs;\n }\n }\n\n impl Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: Self) -> Self::Output {\n let mut d = T::modulo() + self.0 - rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n ModInt::new_unchecked(d)\n }\n }\n\n impl SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: Self) {\n *self = *self - rhs;\n }\n }\n\n impl Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: Self) -> Self::Output {\n ModInt::new_unchecked(Self::reduce(self.0 as u64 * rhs.0 as u64))\n }\n }\n\n impl MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: Self) {\n *self = *self * rhs;\n }\n }\n\n impl Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n if self.0 == 0 {\n Self::zero()\n } else {\n Self::new_unchecked(T::modulo() - self.0)\n }\n }\n }\n\n impl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n }\n\n impl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n }\n\n impl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: u64) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: i64) -> ModInt {\n let m = T::modulo() as i64;\n ModInt::new((val % m + m) as u32)\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n fn reduce(x: u64) -> u32 {\n let b = (x as u32 * T::rem()) as u64;\n let t = x + b * T::modulo() as u64;\n let mut c = (t >> 32) as u32;\n if c >= T::modulo() {\n c -= T::modulo();\n }\n c as u32\n }\n fn new_unchecked(d: u32) -> Self {\n Self(d, PhantomData)\n }\n pub fn is_zero(&self) -> bool {\n self.0 == 0\n }\n pub fn new(d: u32) -> Self {\n Self::new_unchecked(Self::reduce(d as u64 * T::ini()))\n }\n pub fn zero() -> Self {\n Self::new(0)\n }\n pub fn one() -> Self {\n Self::new(1)\n }\n pub fn get(&self) -> u32 {\n Self::reduce(self.0 as u64)\n }\n /*\n pub fn pow(&self, mut n: u64) -> Self {\n let mut t = Self::one();\n let mut s = *self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(&self) -> Self {\n assert!(self.0 != 0);\n self.pow(T::modulo() as u64 - 2)\n }\n */\n }\n\n #[allow(dead_code)]\n pub fn mod_pow(r: u64, mut n: u64, m: u64) -> u64 {\n let mut t = 1 % m;\n let mut s = r % m;\n while n > 0 {\n if n & 1 == 1 {\n t = t * s % m;\n }\n s = s * s % m;\n n >>= 1;\n }\n t\n }\n}\n// ---------- end ModInt ----------\n// ---------- begin Matrix ----------\nmod matrix {\n use std::ops::*;\n pub trait SemiRing: Add + Mul + Copy {\n fn zero() -> Self;\n fn one() -> Self;\n }\n #[derive(Clone)]\n pub struct SquareMatrix {\n size: usize,\n buf: Box<[R]>,\n }\n #[allow(dead_code)]\n impl SquareMatrix {\n pub fn zero(size: usize) -> Self {\n SquareMatrix {\n size: size,\n buf: vec![R::zero(); size * size].into_boxed_slice(),\n }\n }\n pub fn identity(size: usize) -> Self {\n let mut e = Self::zero(size);\n for i in 0..size {\n e.buf[i * size + i] = R::one();\n }\n e\n }\n pub fn get(&self, x: usize, y: usize) -> &R {\n assert!(x < self.size && y < self.size);\n &self.buf[x * self.size + y]\n }\n pub fn get_mut(&mut self, x: usize, y: usize) -> &mut R {\n assert!(x < self.size && y < self.size);\n &mut self.buf[x * self.size + y]\n }\n pub fn matadd(&self, rhs: &Self) -> Self {\n assert!(self.size == rhs.size);\n let buf: Vec = self\n .buf\n .iter()\n .zip(rhs.buf.iter())\n .map(|p| *p.0 + *p.1)\n .collect();\n SquareMatrix {\n size: self.size,\n buf: buf.into_boxed_slice(),\n }\n }\n pub fn matmul(&self, rhs: &Self) -> Self {\n let size = self.size;\n assert!(size == rhs.size);\n let mut res = Self::zero(size);\n for (x, a) in res.buf.chunks_mut(size).zip(self.buf.chunks(size)) {\n for (a, b) in a.iter().zip(rhs.buf.chunks(size)) {\n for (x, b) in x.iter_mut().zip(b.iter()) {\n *x = *x + *a * *b;\n }\n }\n }\n res\n }\n pub fn mat_pow(&self, mut n: usize) -> Self {\n let size = self.size;\n let mut t = Self::identity(size);\n let mut s = self.clone();\n while n > 0 {\n if n & 1 == 1 {\n t = t.matmul(&s);\n }\n s = s.matmul(&s);\n n >>= 1;\n }\n t\n }\n }\n #[allow(dead_code)]\n impl> SquareMatrix {\n pub fn matsub(&self, rhs: &Self) -> Self {\n assert!(self.size == rhs.size);\n let buf: Vec = self\n .buf\n .iter()\n .zip(rhs.buf.iter())\n .map(|p| *p.0 - *p.1)\n .collect();\n SquareMatrix {\n size: self.size,\n buf: buf.into_boxed_slice(),\n }\n }\n }\n}\n// ---------- end Matrix ----------\n// ---------- begin input macro ----------\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n// ---------- end input macro ----------\n\nuse modint::*;\ntype M = ModInt;\n\nuse matrix::*;\ntype Mat = SquareMatrix;\n\nimpl SemiRing for M {\n fn zero() -> Self {\n M::zero()\n }\n fn one() -> Self {\n M::one()\n }\n}\n\nfn run() {\n input! {\n w: [usize; 7],\n }\n // 0: 置いてok\n // 1: おいたらダメ\n let mut mat = vec![];\n for i in 1..=7 {\n let mut m = Mat::zero(1 << i);\n for j in 0..(1 << i) {\n for k in 0..(1 << (2 * i - 1)) {\n if j & k > 0 {\n continue;\n }\n let mut next = 0;\n for x in 0..i {\n let left = x == 0 || (k >> (i + x - 1)) & 1 == 1;\n let down = k >> x & 1 == 1;\n let right = x == i - 1 || (k >> (i + x)) & 1 == 1;\n if left && down && right {\n next |= 1 << x;\n }\n }\n *m.get_mut(next, j) += M::one();\n }\n }\n mat.push(m);\n let mut m = Mat::zero(1 << i);\n for j in 0..(1 << i) {\n *m.get_mut(j, j) = M::one();\n }\n mat.push(m);\n }\n let mul = |m: &Mat, b: &[M]| -> Vec {\n let mut res = vec![M::zero(); b.len()];\n for i in 0..b.len() {\n for j in 0..b.len() {\n res[i] += *m.get(i, j) * b[j];\n }\n }\n res\n };\n let mut b = vec![M::zero(); 1 << 7];\n let mut ini = false;\n let mut w = w;\n for (i, (w, mat)) in w.iter_mut().zip(mat.chunks(2)).enumerate().rev() {\n if !ini && *w > 0 {\n *w -= 1;\n ini = true;\n let i = i + 1;\n for k in 0..(1 << (i - 1)) {\n let mut bit = 0;\n for x in 0..i {\n let left = x == 0 || k >> (x - 1) & 1 == 1;\n let down = true;\n let right = x == i - 1 || k >> x & 1 == 1;\n if left && right && down {\n bit |= 1 << x;\n }\n }\n b[bit] += M::one();\n }\n }\n b = mul(&mat[1], &b);\n b = mul(&mat[0].mat_pow(*w), &b);\n b.truncate(1 << i);\n }\n let ans = b[0];\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "aa5d64db94cd1be8b00eaaf49386e1a5", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "apr_id": "d0c9884934c199dfe05a6e8acd4b1539", "difficulty": 2700, "tags": ["matrices", "dp"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9950061114021302, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "// ---------- begin ModInt ----------\n// モンゴメリ乗算を用いる\n// ほぼCodeforces用\n// 素数のみ\nmod modint {\n\n use std::marker::*;\n use std::ops::*;\n\n pub trait Modulo {\n fn modulo() -> u32;\n fn rem() -> u32;\n fn ini() -> u64;\n }\n\n pub enum Mod1_000_000_007 {}\n\n impl Modulo for Mod1_000_000_007 {\n fn modulo() -> u32 {\n 1_000_000_007\n }\n fn rem() -> u32 {\n 2226617417\n }\n fn ini() -> u64 {\n 582344008\n }\n }\n\n #[allow(dead_code)]\n pub enum Mod998_244_353 {}\n\n impl Modulo for Mod998_244_353 {\n fn modulo() -> u32 {\n 998_244_353\n }\n fn rem() -> u32 {\n 998244351\n }\n fn ini() -> u64 {\n 932051910\n }\n }\n\n #[allow(dead_code)]\n pub fn generate_umekomi_modulo(p: u32) {\n assert!(p < (1 << 31) && p > 2 && p & 1 == 1 && (2u32..).take_while(|v| v * v <= p).all(|k| p % k != 0));\n let mut t = 1u32;\n let mut s = !p + 1;\n let mut n = !0u32 >> 2;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n let mut ini = (1u64 << 32) % p as u64;\n ini = (ini << 32) % p as u64;\n assert!(t * p == !0);\n println!(\"pub enum Mod{} {{}}\", p);\n println!(\"impl Modulo for Mod_{} {{\", p);\n println!(\" fn modulo() -> u32 {{\");\n println!(\" {}\", p);\n println!(\" }}\");\n println!(\" fn rem() -> u32 {{\");\n println!(\" {}\", t);\n println!(\" }}\");\n println!(\" fn ini() -> u32 {{\");\n println!(\" {}\", ini);\n println!(\" }}\");\n }\n\n pub struct ModInt(pub u32, PhantomData);\n\n impl Clone for ModInt {\n fn clone(&self) -> Self {\n ModInt::build(self.0)\n }\n }\n\n impl Copy for ModInt {}\n\n impl Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: Self) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n Self::build(d)\n }\n }\n\n impl AddAssign for ModInt {\n fn add_assign(&mut self, rhs: Self) {\n *self = *self + rhs;\n }\n }\n\n impl Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: Self) -> Self::Output {\n let mut d = T::modulo() + self.0 - rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n Self::build(d)\n }\n }\n\n impl SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: Self) {\n *self = *self - rhs;\n }\n }\n\n impl Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: Self) -> Self::Output {\n Self::build(Self::reduce(self.0 as u64 * rhs.0 as u64))\n }\n }\n\n impl MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: Self) {\n *self = *self * rhs;\n }\n }\n\n impl Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n if self.0 == 0 {\n Self::zero()\n } else {\n Self::build(T::modulo() - self.0)\n }\n }\n }\n\n impl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.get())\n }\n }\n\n impl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n }\n\n impl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: u64) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: i64) -> ModInt {\n let m = T::modulo() as i64;\n ModInt::new((val % m + m) as u32)\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n fn build(d: u32) -> Self {\n ModInt(d, PhantomData)\n }\n pub fn zero() -> Self {\n Self::build(0)\n }\n pub fn is_zero(&self) -> bool {\n self.0 == 0\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n fn reduce(x: u64) -> u32 {\n let b = (x as u32 * T::rem()) as u64;\n let t = x + b * T::modulo() as u64;\n let mut c = (t >> 32) as u32;\n if c >= T::modulo() {\n c -= T::modulo();\n }\n c as u32\n }\n pub fn new_unchecked(d: u32) -> Self {\n Self::build(Self::reduce(d as u64 * T::ini()))\n }\n pub fn new(d: u32) -> Self {\n Self::new_unchecked(d % T::modulo())\n }\n pub fn one() -> Self {\n Self::new_unchecked(0)\n }\n pub fn get(&self) -> u32 {\n Self::reduce(self.0 as u64)\n }\n pub fn pow(&self, mut n: u64) -> Self {\n let mut t = Self::one();\n let mut s = *self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(&self) -> Self {\n assert!(!self.is_zero());\n self.pow(T::modulo() as u64 - 2)\n }\n }\n}\n// ---------- end ModInt ----------\n// ---------- begin Precalc ----------\nmod precalc {\n use super::modint::*;\n #[allow(dead_code)]\n pub struct Precalc {\n inv: Vec>,\n fact: Vec>,\n ifact: Vec>,\n }\n #[allow(dead_code)]\n impl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n fact[i] = fact[i - 1] * ModInt::new_unchecked(i as u32);\n }\n ifact[n] = fact[n].inv();\n if n > 0 {\n inv[n] = ifact[n] * fact[n - 1];\n }\n for i in (1..n).rev() {\n ifact[i] = ifact[i + 1] * ModInt::new_unchecked((i + 1) as u32);\n inv[i] = ifact[i] * fact[i - 1];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n assert!(n > 0);\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn perm(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[n - k]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n }\n}\n// ---------- end Precalc ----------\n// ---------- begin Matrix ----------\nmod matrix {\n use std::ops::*;\n pub trait SemiRing: Add + Mul + Copy {\n fn zero() -> Self;\n fn one() -> Self;\n }\n #[derive(Clone)]\n pub struct SquareMatrix {\n size: usize,\n buf: Box<[R]>,\n }\n #[allow(dead_code)]\n impl SquareMatrix {\n pub fn zero(size: usize) -> Self {\n SquareMatrix {\n size: size,\n buf: vec![R::zero(); size * size].into_boxed_slice(),\n }\n }\n pub fn identity(size: usize) -> Self {\n let mut e = Self::zero(size);\n for i in 0..size {\n e.buf[i * size + i] = R::one();\n }\n e\n }\n pub fn get(&self, x: usize, y: usize) -> &R {\n assert!(x < self.size && y < self.size);\n &self.buf[x * self.size + y]\n }\n pub fn get_mut(&mut self, x: usize, y: usize) -> &mut R {\n assert!(x < self.size && y < self.size);\n &mut self.buf[x * self.size + y]\n }\n pub fn matadd(&self, rhs: &Self) -> Self {\n assert!(self.size == rhs.size);\n let buf: Vec = self\n .buf\n .iter()\n .zip(rhs.buf.iter())\n .map(|p| *p.0 + *p.1)\n .collect();\n SquareMatrix {\n size: self.size,\n buf: buf.into_boxed_slice(),\n }\n }\n pub fn matmul(&self, rhs: &Self) -> Self {\n let size = self.size;\n assert!(size == rhs.size);\n let mut res = Self::zero(size);\n for (x, a) in res.buf.chunks_mut(size).zip(self.buf.chunks(size)) {\n for (a, b) in a.iter().zip(rhs.buf.chunks(size)) {\n for (x, b) in x.iter_mut().zip(b.iter()) {\n *x = *x + *a * *b;\n }\n }\n }\n res\n }\n pub fn mat_pow(&self, mut n: usize) -> Self {\n let size = self.size;\n let mut t = Self::identity(size);\n let mut s = self.clone();\n while n > 0 {\n if n & 1 == 1 {\n t = t.matmul(&s);\n }\n s = s.matmul(&s);\n n >>= 1;\n }\n t\n }\n }\n #[allow(dead_code)]\n impl> SquareMatrix {\n pub fn matsub(&self, rhs: &Self) -> Self {\n assert!(self.size == rhs.size);\n let buf: Vec = self\n .buf\n .iter()\n .zip(rhs.buf.iter())\n .map(|p| *p.0 - *p.1)\n .collect();\n SquareMatrix {\n size: self.size,\n buf: buf.into_boxed_slice(),\n }\n }\n }\n}\n// ---------- end Matrix ----------\n// ---------- begin input macro ----------\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n// ---------- end input macro ----------\n\nuse modint::*;\ntype M = ModInt;\n\nuse matrix::*;\ntype Mat = SquareMatrix;\n\nimpl SemiRing for M {\n fn zero() -> Self {\n M::zero()\n }\n fn one() -> Self {\n M::one()\n }\n}\n\nfn run() {\n input! {\n w: [usize; 7],\n }\n // 0: 置いてok\n // 1: おいたらダメ\n let mut mat = vec![];\n for i in 1..=7 {\n let mut m = Mat::zero(1 << 7);\n for j in 0..(1 << i) {\n for k in 0..(1 << (2 * i - 1)) {\n if j & k > 0 {\n continue;\n }\n let mut next = 0;\n for x in 0..i {\n let left = x == 0 || (k >> (i + x - 1)) & 1 == 1;\n let down = k >> x & 1 == 1;\n let right = x == i - 1 || (k >> (i + x)) & 1 == 1;\n if left && down && right {\n next |= 1 << x;\n }\n }\n *m.get_mut(next, j) += M::one();\n }\n }\n mat.push(m);\n let mut m = Mat::zero(1 << 7);\n for j in 0..(1 << i) {\n *m.get_mut(j, j) = M::one();\n }\n mat.push(m);\n }\n let mul = |m: &Mat, b: &[M]| -> Vec {\n let mut res = vec![M::zero(); b.len()];\n for i in 0..b.len() {\n for j in 0..b.len() {\n res[i] += *m.get(i, j) * b[j];\n }\n }\n res\n };\n let mut b = vec![M::zero(); 1 << 7];\n let mut ini = false;\n let mut w = w;\n for (i, (w, mat)) in w.iter_mut().zip(mat.chunks(2)).enumerate().rev() {\n if !ini && *w > 0 {\n *w -= 1;\n ini = true;\n let i = i + 1;\n for k in 0..(1 << (i - 1)) {\n let mut bit = 0;\n for x in 0..i {\n let left = x == 0 || k >> (x - 1) & 1 == 1;\n let down = true;\n let right = x == i - 1 || k >> x & 1 == 1;\n if left && right && down {\n bit |= 1 << x;\n }\n }\n b[bit] += M::one();\n }\n }\n b = mul(&mat[1], &b);\n b = mul(&mat[0].mat_pow(*w), &b);\n }\n let ans = b[0].get();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n\n", "lang": "Rust", "bug_code_uid": "85150d92f40f65a207db575977e9e24f", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "apr_id": "d0c9884934c199dfe05a6e8acd4b1539", "difficulty": 2700, "tags": ["matrices", "dp"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.742885506287227, "equal_cnt": 24, "replace_cnt": 15, "delete_cnt": 5, "insert_cnt": 3, "fix_ops_cnt": 23, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n p: [(chars, i32, i32); n],\n }\n let p = p\n .into_iter()\n .map(|p| ((p.0[0] == 'B') as usize, p.1, p.2))\n .collect::>();\n let mut sum = vec![([0, 0], 0, 0)];\n for &(x, y, z) in p.iter() {\n for i in 0..sum.len() {\n let (mut a, mut b, mut c) = sum[i];\n a[x] += 1;\n b += y;\n c += z;\n sum.push((a, b, c));\n }\n }\n let inf = std::i32::MAX / 2;\n let mut now = vec![(0, 0, 0, 0)];// bit, Rのヒット、Bのヒット、最小値\n for _ in 0..n {\n let mut next = std::collections::BTreeMap::new();\n for (bit, x, y, v) in now {\n// println!(\"{} {} {} {}\", bit, x, y, v);\n let rem_a = v - sum[bit].1 + x;\n let rem_b = v - sum[bit].2 + y;\n for (i, &(_, a, b)) in p.iter().enumerate() {\n if bit >> i & 1 == 1 {\n continue;\n }\n let mut x = x;\n let mut y = y;\n let mut add = 0;\n let mut p = max(0, a - rem_a);\n if p > 0 {\n x += std::cmp::min(p, sum[bit].0[0]);\n p -= sum[bit].0[0];\n }\n add = max(add, p);\n let mut p = max(0, b - rem_b);\n if p > 0 {\n y += std::cmp::min(p, sum[bit].0[1]);\n p -= sum[bit].0[1];\n }\n add = max(add, p);\n let v = v + add;\n let po = next.entry((bit | (1 << i), x, y)).or_insert(v);\n *po = std::cmp::min(*po, v);\n }\n }\n let mut a = vec![];\n for ((bit, x, y), v) in next {\n a.push((bit, x, y, v));\n }\n now = a;\n }\n let ans = now.into_iter().map(|p| p.3).min().unwrap() + n as i32;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "5d0f78efd3797c54d8832e368593442c", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "apr_id": "3e643c1885a6e04b2ac9288f3cb53b0e", "difficulty": 2400, "tags": ["dp", "brute force", "bitmasks"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6183358832529128, "equal_cnt": 45, "replace_cnt": 35, "delete_cnt": 3, "insert_cnt": 7, "fix_ops_cnt": 45, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\n// ---------- begin chmin, chmax ----------\ntrait ChangeMinMax {\n fn chmin(&mut self, x: Self) -> bool;\n fn chmax(&mut self, x: Self) -> bool;\n}\n\nimpl ChangeMinMax for T {\n fn chmin(&mut self, x: Self) -> bool {\n if *self > x {\n *self = x;\n true\n } else {\n false\n }\n }\n fn chmax(&mut self, x: Self) -> bool {\n if *self < x {\n *self = x;\n true\n } else {\n false\n }\n }\n}\n// ---------- end chmin, chmax ----------\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n p: [(chars, i32, i32); n],\n }\n let mut p = p\n .into_iter()\n .map(|p| ((p.0[0] == 'B') as usize, p.1, p.2))\n .collect::>();\n let mut add = 0;\n for p in p.iter_mut() {\n let n = n as i32;\n let mut v = 0;\n v.chmax(p.1 - n);\n v.chmax(p.2 - n);\n add += v;\n p.1.chmin(n);\n p.2.chmin(n);\n }\n let mut sum = vec![[0i32; 2]];\n for &(x, _, _) in p.iter() {\n for i in 0..sum.len() {\n let mut a = sum[i];\n a[x] += 1;\n sum.push(a);\n }\n }\n let inf = std::i32::MAX / 2;\n let mut dp_a = std::collections::BTreeMap::new();\n let mut dp_b = std::collections::BTreeMap::new();\n dp_a.insert((0, 0), 0);\n dp_b.insert((0, 0), 0);\n for _ in 0..n {\n let mut next_a = std::collections::BTreeMap::new();\n let mut next_b = std::collections::BTreeMap::new();\n for ((bit, rem), v) in dp_a {\n let sum = sum[bit];\n for (i, &(_, a, b)) in p.iter().enumerate() {\n if bit >> i & 1 == 1 {\n continue;\n }\n let k = bit | (1 << i);\n let a = max(0, a - sum[0]);\n let b = max(0, b - sum[1]);\n if rem + b >= a {\n let x = rem + b - a;\n let po = next_a.entry((k, x)).or_insert(inf);\n po.chmin(v + b);\n } else {\n let x = a - (rem + b);\n let po = next_b.entry((k, x)).or_insert(inf);\n po.chmin(v + b + x);\n }\n }\n }\n for ((bit, rem), v) in dp_b {\n let sum = sum[bit];\n for (i, &(_, a, b)) in p.iter().enumerate() {\n if bit >> i & 1 == 1 {\n continue;\n }\n let k = bit | (1 << i);\n let a = max(0, a - sum[0]);\n let b = max(0, b - sum[1]);\n if rem + a >= b {\n let x = rem + a - b;\n let po = next_b.entry((k, x)).or_insert(inf);\n po.chmin(v + a);\n } else {\n let x = b - (rem + a);\n let po = next_a.entry((k, x)).or_insert(inf);\n po.chmin(v + a + x);\n }\n }\n }\n dp_a = next_a;\n dp_b = next_b;\n }\n let ans = add + dp_a.values().chain(dp_b.values()).cloned().min().unwrap() + n as i32;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "975302ae61a7923fd21a3e618662f03e", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "apr_id": "3e643c1885a6e04b2ac9288f3cb53b0e", "difficulty": 2400, "tags": ["dp", "brute force", "bitmasks"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9986220719027934, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\n// ---------- begin chmin, chmax ----------\ntrait ChangeMinMax {\n fn chmin(&mut self, x: Self) -> bool;\n fn chmax(&mut self, x: Self) -> bool;\n}\n\nimpl ChangeMinMax for T {\n fn chmin(&mut self, x: Self) -> bool {\n if *self > x {\n *self = x;\n true\n } else {\n false\n }\n }\n fn chmax(&mut self, x: Self) -> bool {\n if *self < x {\n *self = x;\n true\n } else {\n false\n }\n }\n}\n// ---------- end chmin, chmax ----------\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n p: [(chars, [i32; 2]); n],\n }\n let mut p = p\n .into_iter()\n .map(|p| ((p.0[0] == 'B') as usize, [p.1[0], p.1[1]]))\n .collect::>();\n let mut need = [0; 2];\n for p in p.iter_mut() {\n let n = n as i32;\n for (need, v) in need.iter_mut().zip(p.1.iter_mut()) {\n *need += max(0, *v - n + 1);\n v.chmin(n - 1);\n }\n }\n let mut sum = vec![[0i32; 2]];\n for &(x, _) in p.iter() {\n for i in 0..sum.len() {\n let mut a = sum[i];\n a[x] += 1;\n sum.push(a);\n }\n }\n let inf = std::i32::MAX / 2;\n let sup = (n - 1) * (n - 1);\n let mut dp = vec![vec![vec![inf; 1 << n]; sup + 1]; 2];\n let abs = (need[1] - need[0]).abs() as usize;\n dp[(need[0] >= need[1]) as usize][min(sup, abs)][0] = 0;\n for bit in 0..(1 << n) {\n let sum = sum[bit];\n for rem in 0..=n.pow(2) {\n for i in 0..2 {\n let v = dp[i][rem][bit];\n if v == inf {\n continue;\n }\n for (j, &(_, p)) in p.iter().enumerate() {\n let k = bit | (1 << j);\n if k == bit {\n continue;\n }\n let p = [max(0, p[0] - sum[0]), max(0, p[1] - sum[1])];\n if rem as i32 + p[i ^ 1] >= p[i] {\n let x = rem as i32 + p[i ^ 1] - p[i];\n let v = v + p[i ^ 1];\n dp[i][min(x as usize, sup)][k].chmin(v);\n } else {\n let x = p[i] - rem as i32 - p[i ^ 1];\n let v = v + p[i] - rem as i32;\n dp[i ^ 1][min(x as usize, sup)][k].chmin(v);\n }\n }\n }\n }\n }\n let add = need.iter().copied().max().unwrap() + n as i32;\n let ans = add + dp.into_iter().flatten().map(|dp| dp[(1 << n) - 1]).min().unwrap();\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "5602982b39560939ed2933c76572d0f9", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "apr_id": "3e643c1885a6e04b2ac9288f3cb53b0e", "difficulty": 2400, "tags": ["dp", "brute force", "bitmasks"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6262135922330098, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).unwrap();\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n })\n}\n\nfn main() {\n let (mut r, mut g, mut b) = parse_line!(u32, u32, u32);\n if r > g {\n std::mem::swap(&mut r, &mut g)\n }\n if g > b {\n std::mem::swap(&mut g, &mut b)\n }\n let s = r + g + b;\n let v = r + g;\n println!(\"{:?}\", if s / 3 < v { s / 3 } else { v });\n}\n", "lang": "Rust", "bug_code_uid": "05b634d44075b9eef079d75ddfdf8aa2", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "apr_id": "bc59b5e5751ffd1a648bcaf877f2a93f", "difficulty": 1800, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9925017041581459, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n}\n\nfn _main() -> std::io::Result<()> {\n let mut scan = Scan::new();\n let n: usize = scan.next();\n let mut oddeven = false;\n let mut parx = 0usize;\n let mut pary = 0usize;\n for _ in 0..n {\n let x: usize = scan.next();\n let y: usize = scan.next();\n parx = (parx + x) & 1;\n pary = (pary + y) & 1;\n if (x & 1) ^ (y & 1) == 1 {\n oddeven = true;\n }\n }\n if parx == 0 && pary == 0 {\n println!(\"0\");\n } else if n > 1 && oddeven {\n println!(\"1\");\n } else {\n println!(\"-1\");\n }\n Ok(())\n}\n\nfn main() -> std::io::Result<()> {\n std::thread::Builder::new()\n .stack_size(1 << 23)\n .spawn(_main)\n .unwrap()\n .join()\n .unwrap()?;\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "cd212935d7b8f2ef178ff1cc774d9c9e", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "apr_id": "812c3e8268e3a8828ff15841b5b4eec4", "difficulty": 1200, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9703915950334289, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{Read,stdin};\n\nfn main() {\n let mut buf = String::new();\n stdin().read_to_string(&mut buf).unwrap();\n let mut tok = buf.split_whitespace();\n let mut get = || tok.next().unwrap();\n macro_rules! get {\n ($t:ty) => (get().parse::<$t>().unwrap());\n () => (get!(i64));\n }\n \n let _n = get!();\n let k = get!();\n let mut a = get!();\n \n for _ in 0..k {\n if a % 10 == 0 {\n a /= 10;\n } else {\n a -= 1;\n }\n }\n \n println!(\"{}\", a);\n}", "lang": "Rust", "bug_code_uid": "af57984540aa684e415bbdb8d7dd3c2c", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "489a0e38fbd5f93680300e15958866b7", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9710982658959537, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main(){\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"Failed to read input\");\n\n let mut iter = buffer.split_whitespace();\n let mut first_number: i32 = iter.next().unwrap()\n .trim().parse().unwrap();\n let second_number: i32 = iter.next().unwrap()\n .trim().parse().unwrap();\n\n for k in 0..second_number {\n if first_number % 10 == 0 {\n first_number = first_number / 10;\n } else {\n first_number = first_number - 1;\n }\n } \n\n \n println!(\"The input is {} and {}\", first_number, second_number);\n}", "lang": "Rust", "bug_code_uid": "4b67d1568773929653a19569a4ef362d", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "7f9f2fedbd997887d612c816796fb2ba", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.989492119089317, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn subtract(n: u32) -> u32{\n if n % 10 == 0{\n n / 10\n }\n else{\n n - 1\n }\n}\n\nfn main(){\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"Failed to read line\");\n let mut line = line.trim().split(\" \");\n\n let n = line.next().expect(\"Not enough input\")\n .parse::.expect(\"Not an integer\");\n let k = line.next().expect(\"Not enough input\")\n .parse::.expect(\"Not an integer\");\n\n for _i in 0..k{\n let n = subtract(n);\n }\n\n println!(\"{}\", n);\n}\n", "lang": "Rust", "bug_code_uid": "7e0d37d750b4792ad29ed0ffeb53c0dd", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "3a2606118815c033d99780e4fe4cfccb", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.826890756302521, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn get_input(buffer: &mut String) -> io::Result<()> {\n\tio::stdin().read_line(buffer)?;\n\tOk(())\n}\n\nfn main() -> io::Result<()> {\n\tlet mut buffer = String::new();\n\tget_input(&mut buffer)?;\n\tlet input: Vec<_> = buffer.split_whitespace().collect();\n\tif input.len() != 2 {\n\t\treturn Err(io::Error::new(\n\t\t\tio::ErrorKind::Other,\n\t\t\t\"Bad input !\".to_string(),\n\t\t));\n\t}\n\tlet mut n = input[0].parse::().unwrap();\n\tlet mut k = input[1].parse::().unwrap();\n\tprintln!(\"{} {}\", n, k);\n\twhile k > 0 {\n\t\tif n % 10 == 0 {\n\t\t\tn /= 10;\n\t\t} else {\n\t\t\tn -= 1;\n\t\t}\n\t\tk -= 1;\n\t}\n\tprint!(\"{}\", n);\n\tOk(())\n}\n", "lang": "Rust", "bug_code_uid": "5d75bc689bb19e2680d0afa1ef00b00d", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "7bc358904a9381bc5bf09819865e54e9", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.6257982120051085, "equal_cnt": 8, "replace_cnt": 5, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_source_code": "use std::env;\n\nfn main() {\n let args: Vec = env::args().collect();\n let mut n: usize = args[1].parse().unwrap();\n let k: usize = args[2].parse().unwrap();\n\n for _ in 1..=k {\n if n % 10 == 0 {\n n = n / 10;\n } \n else {\n n = n - 1;\n }\n }\n println!(\"{}\", n);\n}\n", "lang": "Rust", "bug_code_uid": "05190dcc169a505876e0111578456a11", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "198506e33da5756f0dc39a2c967b10b3", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999633431085044, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self, Read};\nuse std::collections::HashMap;\n\nstruct Node {\n white: bool,\n black: bool,\n left: bool,\n right: bool,\n count: u32,\n}\n\nfn update_tree(tree: &mut Vec, index: usize, l: usize, r: usize, left: usize, right: usize) {\n let mid :usize = (l + r) / 2;\n if tree[index].black && !tree[index].white {\n return;\n }\n if l == left && r == right {\n tree[index].black = true;\n tree[index].white = false;\n tree[index].left = true;\n tree[index].right = true;\n tree[index].count = 1;\n return;\n } else if mid >= right {\n update_tree(tree, index * 2 + 1, l, mid, left, right);\n } else if mid + 1 <= left {\n update_tree(tree, index * 2 + 2, mid + 1, r, left, right);\n } else {\n update_tree(tree, index * 2 + 1, l, mid, left, mid);\n update_tree(tree, index * 2 + 2, mid + 1, r, mid + 1, right);\n }\n tree[index].white = tree[index * 2 + 1].white & tree[index * 2 + 2].white;\n tree[index].black = tree[index * 2 + 1].black & tree[index * 2 + 2].black;\n tree[index].left = tree[index * 2 + 1].left;\n tree[index].right = tree[index * 2 + 2].right;\n if tree[index * 2 + 1].right && tree[index * 2 + 2].left {\n tree[index].count = tree[index * 2 + 1].count + tree[index * 2 + 2].count - 1;\n } else {\n tree[index].count = tree[index * 2 + 1].count + tree[index * 2 + 2].count;\n }\n return;\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buf :String = String::new();\n\n match handle.read_to_string(&mut buf) {\n Ok(_v) => (),\n Err(e) => panic!(\"{}\", e),\n }\n let lines: Vec<&str> = buf.split(\"\\r\\n\").collect();\n\n let n :usize = lines[0].parse().unwrap();\n\n let mut points = HashMap::new();\n let mut query: Vec<(u32,u32)> = Vec::new();\n\n for i in 1..(n+1) {\n let pair: Vec<&str> = lines[i].split(\" \").collect();\n let l :u32 = pair[0].parse().unwrap();\n let r :u32 = pair[1].parse().unwrap();\n points.insert(l, 0);\n points.insert(r, 0);\n query.push((l,r));\n }\n let mut v :Vec = Vec::new(); \n for (point, _v) in points.iter() {\n v.push(*point);\n }\n v.sort();\n for i in 0..v.len() {\n points.insert(v[i], i);\n }\n let mut tree: Vec = Vec::new();\n for _i in 0..(2*v.len()) {\n tree.push(Node {count: 0, black: false, white: true, left: false, right: false});\n }\n for i in 0..n {\n let l :usize = *points.get(&query[i].0).unwrap();\n let r :usize = *points.get(&query[i].1).unwrap();\n update_tree(&mut tree, 0, 0, v.len() - 2, l, r - 1);\n print!(\"{} \", tree[0].count);\n }\n}", "lang": "Rust", "bug_code_uid": "12b0648041ef4f9829dfb56673b9e150", "src_uid": "3979abbe7bad0f3b5cab15c1cba19f6b", "apr_id": "6dd21e81cbad015d7c2014a2740b31ae", "difficulty": 2100, "tags": ["data structures"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8548812664907651, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "fn main() {\n let mut n: u16 = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n };\n let (mut level, mut level_blocks) = (0, 1);\n while level_blocks <= n {\n level += 1;\n level_blocks = level * (level + 1) / 2;\n n -= level_blocks;\n }\n println!(\"{}\", level);\n}", "lang": "Rust", "bug_code_uid": "4640df536acd474756a4e4360b37bac6", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "apr_id": "bfcd9d19a62ea058aeb577de0d8f4320", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8319327731092437, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "/*input\n1\n*/\nfn main() {\n let mut input = format!(\"\");\n std::io::stdin().read_line(&mut input).expect(\"\");\n let mut input_num: i16 = input.trim().parse::().unwrap();\n let mut substractor: i16 = 0;\n let mut iter: i16 = 1;\n loop {\n substractor = substractor + iter;\n input_num = input_num - substractor;\n iter = iter + 1;\n if input_num - substractor <= 0 {\n break;\n }\n }\n println!(\"{}\", iter - 1);\n}\n", "lang": "Rust", "bug_code_uid": "3e5cf5b7af1edbef89c9284844aee32c", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "apr_id": "29f2bafd551ec1cdab3762c1ee207de5", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7509881422924901, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "\nfn main() {\n let areas: Vec = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();\n let sum: u32 = areas.iter().sum();\n let result = 4 * sum;\n\n println!(\"{}\", result);\n \n}\n\nfn get_input() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n buffer.trim().to_owned()\n}\n\nfn get_input_usize() -> usize {\n get_input().parse().unwrap()\n}\n", "lang": "Rust", "bug_code_uid": "4e506899bcbcd81d7b8e459c2e8f8388", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "apr_id": "b13a024ebbac7ee06462948235cf6e08", "difficulty": 1100, "tags": ["geometry", "math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9652002626395273, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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 (a, b): (u64, u64) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|x| x.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let ans = (a..b).fold(1, |acc, k| ((k + 1) * acc) % 10);\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "2c61b5ad35448a82b8f894c5753d1467", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "apr_id": "e15b60c9453a2dd76ae579729d9ba0ce", "difficulty": 1100, "tags": ["math"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9971098265895953, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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 let (a, b) = read_2::();\n let mut res = 1;\n for i in (a + 1)..=b {\n res *= i;\n res %= 10;\n }\n println!(\"{}\", res);\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "080d5c9fcaeeb9cb2fd874f2a0e47d22", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "apr_id": "9822e11e220f5d0f01f111b2712c29a2", "difficulty": 1100, "tags": ["math"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9890534449452673, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "// Basics\n\n#![allow(unused_imports)]\n\nuse std::mem;\nuse std::io;\nuse std::string;\nuse std::cmp::*;\nuse std::collections::*;\n\nfn load() -> Vec {\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"Failed to read line\");\n let vec: Vec<&str> = line.split(\" \").collect();\n let mut data: Vec = Vec::new();\n for i in vec {\n let el: i32 = i.trim().parse().unwrap();\n data.push(el);\n }\n data\n}\n\nfn main() {\n let w = load();\n let (a, b) = (w[0], w[1]);\n if b - a >= 10 {\n println!(\"0\");\n } else {\n let mut end = 1;\n for i in (a + 1)..(b + 1) {\n end *= i;\n }\n println!(\"{}\", (end % 10));\n }\n}\n\n//\n//mod strings;\n//\n//fn main() {\n// strings_sample();\n//}\n", "lang": "Rust", "bug_code_uid": "c5de287cf14e0e5d7b04d3b57069795a", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "apr_id": "412dbb80ed62d261c85c28a1e8238cb9", "difficulty": 1100, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9548272807794509, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn read_line() -> String {\n let stdin = std::io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).unwrap();\n String::from(line.trim())\n}\n\nmacro_rules! scan_line {\n ($($ty: ty),*) => {{\n let line = read_line();\n let mut tok = line.split_whitespace();\n ($(tok.next().unwrap().parse::<$ty>().unwrap()),*)\n }}\n}\n\nfn main() {\n let (a, b) = scan_line!(u64, u64);\n let mut acc = 1;\n for i in (a + 1)..(b + 1) {\n acc = (acc * i % 10) % 10;\n }\n println!(\"{}\", acc);\n}\n", "lang": "Rust", "bug_code_uid": "4351d44dd50a3ef66bdf33b69f26bb5f", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "apr_id": "8933a34cf9fd02b3afa8cb7ec37cfe16", "difficulty": 1100, "tags": ["math"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9457943925233645, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let s: usize = usize::from_str_radix(buf.trim(), 2).unwrap();\n\n let mut k = 0;\n while 4usize.pow(k) < s {\n k += 1;\n }\n\n println!(\"{}\", k);\n}\n", "lang": "Rust", "bug_code_uid": "9d5862945492c0ab4dc218cd60bf840d", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "apr_id": "6c71bd0cfe605b8e5537f045f0b894e7", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8802773811951866, "equal_cnt": 10, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 10, "bug_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 let mut bout = BufWriter::new(stdout());\n\n let n = input.u();\n for _ in 0..n {\n let mut a: i64 = input.p();\n let mut sol = 0;\n while a % 2 == 0 {\n a /= 2;\n sol += 1;\n }\n while a % 3 == 0 {\n a /= 3;\n sol += 2;\n }\n while a % 5 == 0 {\n a /= 5;\n sol += 3;\n }\n if a != 1 {\n sol = -1;\n }\n writeln!(bout, \"{}\", sol).ok();\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "8ef7006c3604a2274506cb29abc0fc82", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "apr_id": "14cf56e087f7ef2eda495bf6d9ea9010", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9969325153374233, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 s = input.bs();\n let n = s.len();\n let sol = n / 2 + (if s[1..].iter().any(|x| *x == b'1') {1} else {0});\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "2240ecc772a51016b4e31ed9e4d08d19", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "apr_id": "14cf56e087f7ef2eda495bf6d9ea9010", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9993235625704623, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_variables)]\n#![allow(unused_must_use)]\n\nuse std::io::{self, prelude::*};\n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let mut input = Input::new(stdin.lock());\n let mut output = io::BufWriter::new(stdout.lock());\n macro_rules! puts {\n ($($format:tt)*) => (write!(output ,$($format)*).unwrap());\n }\n let s: String = input.next();\n let s = s.into_bytes();\n let mut s2: Vec = s\n .as_slice()\n .rchunks(2)\n .map(|chunk| {\n if chunk.len() == 1 {\n chunk[0] - b'0'\n } else {\n (chunk[0] - b'0') * 2 + chunk[1] - b'0'\n }\n })\n .collect();\n s2.as_mut_slice().reverse();\n if s2[0] != 1 || s2[1..].iter().any(|&c| c != 0) {\n puts!(\"{}\\n\", s2.len());\n return;\n }\n puts!(\"{}\\n\", s2.len() - 1);\n}\n\nstruct Input {\n lines: io::Lines,\n cur: String,\n split: std::str::SplitAsciiWhitespace<'static>, //'\n}\n\nimpl Input {\n fn new(reader: R) -> Input {\n use std::mem::transmute;\n\n let mut lines = reader.lines();\n let cur = lines.next().unwrap().unwrap();\n let split = unsafe { transmute(cur.split_ascii_whitespace()) };\n Input { lines, cur, split }\n }\n fn update(&mut self) {\n use std::mem::transmute;\n self.cur = self.lines.next().unwrap().unwrap();\n unsafe { self.split = transmute(self.cur.split_ascii_whitespace()) };\n }\n fn next(&mut self) -> F {\n loop {\n if let Some(thing) = self.split.next() {\n return thing.parse().ok().unwrap();\n }\n self.update();\n }\n }\n fn iter(&mut self) -> InputIter {\n InputIter {\n input: self,\n _phantom: std::marker::PhantomData,\n }\n }\n}\n\nstruct InputIter<'a, R, I> {\n input: &'a mut Input,\n _phantom: std::marker::PhantomData,\n}\n\nimpl<'a, R, I> Iterator for InputIter<'a, R, I>\nwhere\n R: BufRead,\n I: std::str::FromStr,\n{\n type Item = I;\n fn next(&mut self) -> Option {\n Some(self.input.next())\n }\n}\n", "lang": "Rust", "bug_code_uid": "a9ac5c2db5c110b19327ab1c7ec1d645", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "apr_id": "48b7d34666b575f2420ab34a9968e6a7", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5147812376823019, "equal_cnt": 9, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 9, "bug_source_code": "use std::io::{stdin, stdout, Write, BufReader, BufRead, Read};\n\nfn solve(input: &mut BufRead, output: &mut Write) {\n let mut input = BufReader::new(input);\n\n let mut line = String::with_capacity(100);\n input.read_line(&mut line).unwrap();\n let line = line.trim();\n\n if line.chars().next().unwrap() == '0' {\n output.write(b\"0\");\n } else if line.chars().skip(1).position(|it| it == '1') == None {\n output.write(format!(\"{}\", line.len() / 2).as_bytes());\n } else {\n output.write(format!(\"{}\", line.len() / 2 + 1).as_bytes());\n }\n\n}\n\nfn main() {\n let stdin = stdin();\n let stdout = stdout();\n solve(&mut stdin.lock(), &mut stdout.lock());\n}\n\n#[cfg(test)]\nmod tests {\n use std::fs::File;\n use solve;\n use std::io::BufReader;\n\n #[test]\n fn basic_test() {\n let mut f = BufReader::new(\"bbaba\nbb\n\".as_bytes());\n let mut buf: Vec = Vec::new();\n\n solve(&mut f, &mut buf);\n\n let res = String::from_utf8(buf).unwrap();\n assert_eq!(res, \"3\\n\");\n }\n\n #[test]\n fn basic_test2() {\n let mut f = BufReader::new(\"baaba\nab\n\".as_bytes());\n let mut buf: Vec = Vec::new();\n\n solve(&mut f, &mut buf);\n\n let res = String::from_utf8(buf).unwrap();\n assert_eq!(res, \"2\\n\");\n }\n\n #[test]\n fn basic_test3() {\n let mut f = BufReader::new(\"abcde\nabcde\n\".as_bytes());\n let mut buf: Vec = Vec::new();\n\n solve(&mut f, &mut buf);\n\n let res = String::from_utf8(buf).unwrap();\n assert_eq!(res, \"0\\n\");\n }\n\n #[test]\n fn basic_test4() {\n let mut f = BufReader::new(\"asdfasdf\nfasd\n\".as_bytes());\n let mut buf: Vec = Vec::new();\n\n solve(&mut f, &mut buf);\n\n let res = String::from_utf8(buf).unwrap();\n assert_eq!(res, \"3\\n\");\n }\n}", "lang": "Rust", "bug_code_uid": "6ceec13d9617477ea3f534fad5968dee", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "apr_id": "30fb7ae3b9fcaf08789001843362bc68", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9955472228732131, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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, bytes) => {\n read_value!($next, String).into_bytes()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_imports)]\nuse std::cmp::{max, min};\n#[allow(unused_imports)]\nuse std::collections::{BinaryHeap, HashMap};\n\n#[allow(dead_code)]\ntype Graph = Vec>;\n\nfn main() {\n input! {\n s: chars,\n }\n\n let mut ans = (s.len() + 1) / 2;\n\n let mut ok = false;\n for i in 1..s.len() {\n if s[i] == '1' {\n ok = true;\n }\n }\n if !ok {\n ans -= 1;\n }\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "b199d20f0de987f6a9cdbb5c61def931", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "apr_id": "de8b8173d7a16a92f265847bd4a2c1ec", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9959560947429231, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nmacro_rules! parse_input {\n ($x:expr, $t:ident) => ($x.parse::<$t>().unwrap())\n}\n\nmacro_rules! parse_inputs {\n ($x:expr, $t:ident) => ($x.map(|s| s.parse::<$t>().unwrap()).collect::>())\n}\n\nmacro_rules! print_err {\n ($($arg:tt)*) => (\n {\n use std::io::Write;\n writeln!(&mut ::std::io::stderr(), $($arg)*).ok();\n }\n )\n}\n\nfn main() {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n let cs = input_line.chars();\n\n let mut max = 0;\n let mut j = 0;\n for c in cs {\n j += 1;\n if c == 'A' || c == 'I' || c == 'U' || c == 'E' || c == 'O' || c == 'Y' {\n if max < j {\n max = j;\n }\n j = 0;\n }\n }\n j += 1;\n if max < j {\n max = j;\n }\n println!(\"{}\", max);\n}\n", "lang": "Rust", "bug_code_uid": "3cbd4343eae1ec6337c5f6288edc33d0", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "apr_id": "fd9617d1f08e70eed1046f0de50c2082", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9997010463378176, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let m = \"AEIOU\".chars().collect::>();\n let mut s = String::from(\"A\");\n s.push_str(input.sl());\n s.push_str(\"A\");\n let i = s.chars().enumerate().filter(|(_,c)| m.contains(c)).map(|(a,_)| a);\n let j = i.clone();\n let sol = i.skip(1).zip(j).map(|(a,b)| a - b).max().unwrap();\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "5410461d94fb7011a94a5f181ef303a2", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "apr_id": "3a9fc2d418a16fb9a6d9a8c021a042e4", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.990990990990991, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn is_vowel(c: char) -> bool {\n return c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U';\n}\nfn _main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n let mut result = 0usize;\n let mut index = 0usize;\n for c in line.trim().chars() {\n index += 1;\n if is_vowel(c) {\n result = result.max(index);\n index = 0;\n }\n }\n index += 1;\n result = result.max(index);\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "ad5925e2d3c420f2a476b608288d57a9", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "apr_id": "829bdc59b5391fa247532127c72a9ca1", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.5785417901600475, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "fn main() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let ints = s.split_whitespace().map(|x| x.parse().unwrap()).collect::>();\n let mut n1 = ints[0];\n let mut n2 = ints[1];\n let mut k = std::collections::HashMap::new();\n k.insert(true,ints[2]);\n k.insert(false,ints[3]);\n\n let mut firstplayer = true;\n\n loop {\n if (k[&true]>n1 && k[&true]> n2) || k[&false] > n1 && k[&false] > n2 {\n break;\n }\n\n if n1 > n2 {\n if (k[&firstplayer]>n1) {\n break;\n }\n n1-=k[&firstplayer]; \n } else{\n if (k[&firstplayer]>n2) {\n break;\n }\n n2-=k[&firstplayer]; \n }\n firstplayer = !firstplayer;\n }\n println!(\"{}\", if !firstplayer {\"First\"} else {\"Second\"});\n }\n", "lang": "Rust", "bug_code_uid": "4972bff99e8a206b4d0bf12b506a627d", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "apr_id": "d1b32fe0bbccc4e92461329f3b0763ce", "difficulty": 800, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9864422627395979, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io::{self, Read};\n\nfn main() -> () {\n\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n handle.read_to_string(&mut buffer).expect(\"stdin\");\n\n let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n\n let n = arr[0] as usize;\n let a = arr[1];\n let b = arr[2];\n\n let v = arr.drain(3..).collect::>();\n\n let mut cost = 0;\n \n for i in 0..n / 2 + 1 {\n if v[i] != 2 && v[n-1-i] != 2 {\n if v[i] != v[n-1-i] {\n println!(\"-1\");\n return\n }\n } else if v[i] == 2 && v[n-1-i] == 2 {\n use std::cmp;\n cost += cmp::min( a, b ) * if i != n-1-i { 2 } else { 1 };\n } else if v[i] != 2 && i != n-1-i {\n cost += if v[i] == 0 { a } else { b };\n } else if v[n-1-i] != 2 && i != n-1-i {\n cost += if v[n-1-i] == 0 { a } else { b };\n } else {\n panic!();\n }\n }\n \n println!(\"{:?}\",cost);\n}\n", "lang": "Rust", "bug_code_uid": "5b0f2e281fd0bc72eb59315060f1a1b4", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "apr_id": "bc54c2e14b6585718526cec4c24e906b", "difficulty": 1000, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9529130087789306, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, Read};\n\nfn main() -> () {\n\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n handle.read_to_string(&mut buffer).expect(\"stdin\");\n\n let mut arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n\n let n = arr[0];\n let m = arr[1];\n\n let max_seats = arr.iter().skip(2).max().unwrap();\n let min_seats = arr.iter().skip(2).min().unwrap();\n let s = arr.iter().skip(2).sum::();\n let b = (s + m)/n + if (s+m) % n != 0 { 1 } else { 0 };\n\n use std::cmp;\n \n println!(\"{} {}\", cmp::max( min_seats, &b ), max_seats + m );\n}\n", "lang": "Rust", "bug_code_uid": "06e66e3770a711b7c5d7b0a2bb5b5131", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "apr_id": "27aae2dd998e27316b1266e233902636", "difficulty": 1100, "tags": ["implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9724770642201835, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "// 991A\nuse std::io;\n\nfn main() {\n let (a, b, c, n): (u32, u32, u32, u32) = read_two(&io::stdin());\n if a + b - c + 1 > n {\n println!(\"{}\", -1);\n } else {\n println!(\"{}\", n - (a + b - c));\n }\n}\n\nfn read_two(stdin: &io::Stdin) -> (T, T, T, T)\nwhere\n T: std::str::FromStr,\n ::Err: std::fmt::Debug,\n{\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let mut iter = s.trim().split_whitespace().map(|x| x.parse().unwrap());\n (\n iter.next().unwrap(),\n iter.next().unwrap(),\n iter.next().unwrap(),\n iter.next().unwrap(),\n )\n}\n", "lang": "Rust", "bug_code_uid": "cb0b0e21eaf2cc777dbd3ccb1f4e2ad6", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "apr_id": "2463dae0def92f1b2844645b789f1b27", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6214160327677004, "equal_cnt": 12, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 12, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let (n, _) = {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n let mut it = input.split_whitespace().map(|k| k.parse::().unwrap());\n (it.next().unwrap(), it.next().unwrap())\n };\n\n let mut a = String::new();\n stdin().read_line(&mut a).unwrap();\n let a = a.split_whitespace().map(|k| k.parse::().unwrap());\n let (al, n_al) = a.fold((0, 0), |(al, n_al), ai| (al + ai % 2, n_al + ai / 2));\n\n if al + n_al <= n * 4 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "422c620b99d8c8d9855dfc53815cfe62", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "apr_id": "00b9b8f38bb4c8c75619294bf47854d4", "difficulty": 1900, "tags": ["greedy", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7002477291494632, "equal_cnt": 10, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 9, "bug_source_code": "fn main() {\n let mut input = String::new();\n use std::io;\n use std::io::prelude::*;\n io::stdin().read_to_string(&mut input).unwrap();\n\n let mut it = input.split_whitespace();\n\n let p: usize = it.next().unwrap().parse().unwrap();\n let y: usize = it.next().unwrap().parse().unwrap();\n\n let mut bl = vec![false; y + 1];\n\n bl[0] = true;\n bl[1] = true;\n\n for i in 2..p + 1 {\n for j in (1..).take_while(|&j| i * j <= y) {\n bl[i * j] = true;\n }\n }\n\n let ans = bl.into_iter().rposition(|x| !x);\n\n match ans {\n Some(ans) => println!(\"{}\", ans),\n None => println!(\"-1\"),\n }\n}\n", "lang": "Rust", "bug_code_uid": "76f95724940276ac2039b648c425d1df", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "apr_id": "0edc55180bb34db0d4a1b8c4ed398753", "difficulty": 1400, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9866903283052352, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut input = String::new();\n use std::io;\n use std::io::prelude::*;\n io::stdin().read_to_string(&mut input).unwrap();\n\n let mut it = input.split_whitespace();\n\n let p: u64 = it.next().unwrap().parse().unwrap();\n let y: u64 = it.next().unwrap().parse().unwrap();\n\n let ans = (3..y + 1).rev().find(|&i| {\n let k = std::cmp::min(p, (y as f64).sqrt().floor() as u64);\n (2..k + 1).all(|j| i % j != 0) && i > p\n });\n\n match ans {\n Some(ans) => println!(\"{}\", ans),\n None => println!(\"-1\"),\n }\n}\n", "lang": "Rust", "bug_code_uid": "d783248dbcede756c781a7688ce1c95e", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "apr_id": "0edc55180bb34db0d4a1b8c4ed398753", "difficulty": 1400, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9864791779340184, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::stdin;\nuse std::io::prelude::*;\nuse std::iter::*;\nuse std::str::SplitWhitespace;\nuse std::cmp::min;\n\nfn main() {\n let mut input = InRead::new();\n let n = input.int();\n let a = input.int();\n let b = input.int();\n let c = input.int();\n let x = min(a, b);\n let res = x + min(x, c) * (n - 2);\n println!(\"{}\", res);\n}\n\nstruct InRead(String);\n\nimpl InRead {\n fn new() -> InRead {\n InRead(String::new())\n }\n fn get_line(self: &mut Self) {\n self.0.clear();\n stdin().read_line(&mut self.0);\n }\n fn parse_int(s: &str) -> i32 { s.parse().unwrap() }\n fn ints(self: &mut Self) -> Map i32> {\n self.get_line();\n self.0.split_whitespace().map(InRead::parse_int)\n }\n fn int_vec(self: &mut Self) -> Vec { self.ints().collect() }\n fn int(self: &mut Self) -> i32 { self.ints().next().unwrap() }\n}\n\n\n", "lang": "Rust", "bug_code_uid": "343b0a201b09bbb45e65b3cbf1f85825", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "apr_id": "120412ba9ee8eaad031e92dcc08a4285", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9974937343358395, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn read_int() -> u8 {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n let x = input.trim().parse::().unwrap();\n x\n}\n\nfn main(){\n let n = read_int();\n let a = read_int();\n let b = read_int();\n let c = read_int();\n\n let mut location = \"R\";\n let mut dist = 0;\n let mut meals = 1;\n while meals < n{\n let trip = match location {\n \"R\" => {\n if a < b{\n location = \"O\";\n a\n }else{\n location = \"E\";\n b\n }\n },\n \"E\" => {\n if c < b{\n location = \"O\";\n c\n }else{\n location = \"R\";\n b\n }\n },\n \"O\" => {\n if a < c{\n location = \"R\";\n a\n }else{\n location = \"E\";\n c\n }\n },\n _ => {break},\n };\n meals = meals + 1;\n dist = dist + trip;\n }\n println!(\"{}\", dist);\n}", "lang": "Rust", "bug_code_uid": "acdcf03a527d88c5582d3d2b0e546f79", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "apr_id": "5cb4c2c56187f530a6a1a38a26312547", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6593647316538883, "equal_cnt": 8, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn main() {\n let stdin = io::stdin();\n\n let mut ln = String::new();\n stdin.read_line(&mut ln).unwrap();\n let mut iter = ln.split_whitespace();\n let n:u32 = iter.next().unwrap().parse().unwrap();\n let mut m:u32 = iter.next().unwrap().parse::().unwrap() / n;\n\n let mut count = 0;\n while m > 1 && m % 2 == 0 {\n m /= 2;\n count += 1;\n }\n while m > 1 {\n m /= 3;\n count += 1;\n }\n println!(\"{}\", count);\n}\n", "lang": "Rust", "bug_code_uid": "cafc6026c3e9ae0bddc4e91780604b47", "src_uid": "3f9980ad292185f63a80bce10705e806", "apr_id": "129d9090cb48f76fdfb3c81220b2e9f9", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8523985239852399, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_source_code": "#![allow(unused_imports)]\n\nuse std::cmp::*;\nuse std::collections::*;\n\nfn power(n: i64, p: i64) -> i64 {\n let mut i = 0;\n let mut r = n;\n while r % p == 0 {\n r = r / p;\n i += 1;\n } \n return i;\n}\n\nfn main() {\n let nn = read_ints();\n let (n, m) = (nn[0], nn[1]);\n\n let n2 = power(n, 2);\n let n3 = power(n, 3);\n let m2 = power(m, 2);\n let m3 = power(m, 3);\n if m2 < n2 || m3 < n3 {\n println!(\"{}\", -1);\n } else {\n println!(\"{}\", m2 + m3 - n2 - n3);\n }\n}\n\nfn read_line() -> String {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n return s;\n}\n\nfn read_ints() -> Vec {\n return read_line()\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n}\n", "lang": "Rust", "bug_code_uid": "93af2771580848971202be82e6939ec1", "src_uid": "3f9980ad292185f63a80bce10705e806", "apr_id": "353587cd65f150f38b30e54361afbc77", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9579690652320108, "equal_cnt": 7, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "#![allow(dead_code, clippy::many_single_char_names, unused_variables, non_snake_case, unused_macros, unused_imports, non_upper_case_globals)]\nuse std::{\n collections::*,\n io::{stdin, StdinLock, stdout, StdoutLock, BufReader, BufRead, BufWriter, Write},\n mem::swap\n};\n\nfn parse(n: &str) -> T {\n match n.parse::() {\n Ok(x) => x,\n _ => panic!()\n }\n}\n\nmacro_rules! fill {\n ($r: expr, str, $($x: ident),+) => { fill!($r, str, 30, $($x),+) };\n ($r: expr, $t: ty, $($x: ident),+) => { fill!($r, $t, 30, $($x),+) };\n ($r: expr, str, $c: expr, $($x: ident),+) => {\n let t = read!($r, $c);\n let mut t = t.split(' ');\n\n $(\n $x = t.next().unwrap();\n )+\n };\n ($r: expr, $t: ty, $c: expr, $($x: ident),+) => {\n let t = read!($r, $c);\n let mut t = t.split(' ').map(parse::<$t>);\n\n $(\n $x = t.next().unwrap();\n )+\n }\n}\n\nmacro_rules! read {\n ($r: expr) => { read!($r, 20) };\n ($r: expr, str) => { read!($r, 20) };\n ($r: expr, $t: ty) => { parse::<$t>(&read!($r, 20)) };\n ($r: expr, str, $c: expr) => { read!($r, $c) };\n ($r: expr, $t: ty, $c: expr) => { parse::<$t>(&read!($r, $c)) };\n ($r: expr, $c: expr) => {\n {\n let mut s = String::with_capacity($c+2);\n $r.read_line(&mut s).unwrap();\n\n assert!(s.len() <= $c+2);\n\n if s.ends_with('\\n') {\n s.pop();\n if s.ends_with('\\r') {\n s.pop();\n }\n }\n s\n }\n }\n}\n\nmacro_rules! read_vec {\n ($r: expr) => { read_vec!($r, str, 10_000) };\n ($r: expr, str) => { read_vec!($r, str, 10_000) };\n ($r: expr, $t: ty) => { read_vec!($r, $t, 10_000) };\n ($r: expr, $c: expr) => { read_vec!($r, str, $c) };\n ($r: expr, str, $c: expr) => {\n {\n let v = read!($r, $c).split(' ').collect::>();\n assert!(v.len() <= $c); // $c is upper bound of string\n v\n }\n };\n ($r: expr, $t: ty, $c: expr) => { \n {\n let v = read!($r, $c).split(' ').map(parse::<$t>).collect::>();\n assert!(v.len() <= $c);\n v\n }\n };\n}\n\n\nfn main() {\n let r = stdin();\n let mut r = BufReader::with_capacity(10000, r.lock());\n\n let w = stdout();\n let mut w = BufWriter::with_capacity(10000, w.lock());\n unsafe { solve(&mut r, &mut w); }\n}\n\nconst M: usize = std::usize::MAX;\n\nunsafe fn solve(r: &mut BufReader, w: &mut BufWriter) {\n let (a, b);\n fill!(r, usize, 19, a, b);\n\n if b%a != 0 {\n write!(w, \"-1\").unwrap();\n } else {\n let m = b/a;\n let mut acc = m.trailing_zeros();\n\n let mut m = m>>acc;\n\n while m != 1 {\n acc += 1;\n m /= 3;\n }\n write!(w, \"{}\", acc).unwrap();\n }\n}", "lang": "Rust", "bug_code_uid": "16ad64da10949b50c5ce7933923c0930", "src_uid": "3f9980ad292185f63a80bce10705e806", "apr_id": "bb1da417860b02fdc80d0ef818c65ea2", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9515536251252924, "equal_cnt": 10, "replace_cnt": 6, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 9, "bug_source_code": "#![allow(dead_code, clippy::many_single_char_names, unused_variables, non_snake_case, unused_macros, unused_imports, non_upper_case_globals)]\nuse std::{\n collections::*,\n io::{stdin, StdinLock, stdout, StdoutLock, BufReader, BufRead, BufWriter, Write},\n mem::swap\n};\n\nfn parse(n: &str) -> T {\n match n.parse::() {\n Ok(x) => x,\n _ => panic!()\n }\n}\n\nmacro_rules! fill {\n ($r: expr, str, $($x: ident),+) => { fill!($r, str, 30, $($x),+) };\n ($r: expr, $t: ty, $($x: ident),+) => { fill!($r, $t, 30, $($x),+) };\n ($r: expr, str, $c: expr, $($x: ident),+) => {\n let t = read!($r, $c);\n let mut t = t.split(' ');\n\n $(\n $x = t.next().unwrap();\n )+\n };\n ($r: expr, $t: ty, $c: expr, $($x: ident),+) => {\n let t = read!($r, $c);\n let mut t = t.split(' ').map(parse::<$t>);\n\n $(\n $x = t.next().unwrap();\n )+\n }\n}\n\nmacro_rules! read {\n ($r: expr) => { read!($r, 20) };\n ($r: expr, str) => { read!($r, 20) };\n ($r: expr, $t: ty) => { parse::<$t>(&read!($r, 20)) };\n ($r: expr, str, $c: expr) => { read!($r, $c) };\n ($r: expr, $t: ty, $c: expr) => { parse::<$t>(&read!($r, $c)) };\n ($r: expr, $c: expr) => {\n {\n let mut s = String::with_capacity($c+2);\n $r.read_line(&mut s).unwrap();\n\n assert!(s.len() <= $c+2);\n\n if s.ends_with('\\n') {\n s.pop();\n if s.ends_with('\\r') {\n s.pop();\n }\n }\n s\n }\n }\n}\n\nmacro_rules! read_vec {\n ($r: expr) => { read_vec!($r, str, 10_000) };\n ($r: expr, str) => { read_vec!($r, str, 10_000) };\n ($r: expr, $t: ty) => { read_vec!($r, $t, 10_000) };\n ($r: expr, $c: expr) => { read_vec!($r, str, $c) };\n ($r: expr, str, $c: expr) => {\n {\n let v = read!($r, $c).split(' ').collect::>();\n assert!(v.len() <= $c); // $c is upper bound of string\n v\n }\n };\n ($r: expr, $t: ty, $c: expr) => { \n {\n let v = read!($r, $c).split(' ').map(parse::<$t>).collect::>();\n assert!(v.len() <= $c);\n v\n }\n };\n}\n\n\nfn main() {\n let r = stdin();\n let mut r = BufReader::with_capacity(10000, r.lock());\n\n let w = stdout();\n let mut w = BufWriter::with_capacity(10000, w.lock());\n unsafe { solve(&mut r, &mut w); }\n}\n\nconst M: usize = std::usize::MAX;\n\nunsafe fn solve(r: &mut BufReader, w: &mut BufWriter) {\n let (a, b);\n fill!(r, usize, 19, a, b);\n\n if ((b%3 != 0 && b%2 != 0) || b%a != 0 )&& b != a {\n write!(w, \"-1\").unwrap();\n } else {\n let m = b/a;\n let mut acc = m.trailing_zeros();\n\n let mut m = m>>acc;\n\n while m != 1 {\n acc += 1;\n m /= 3;\n }\n write!(w, \"{}\", acc).unwrap();\n }\n}", "lang": "Rust", "bug_code_uid": "56370855504e98f2eb1f6a3806e3db0c", "src_uid": "3f9980ad292185f63a80bce10705e806", "apr_id": "bb1da417860b02fdc80d0ef818c65ea2", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9835855894265615, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "\n#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet, BinaryHeap};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n#[allow(unused_imports)]\nuse std::io::stdin;\n\nmod util {\n use std::io::stdin;\n use std::str::FromStr;\n use std::fmt::Debug;\n\n #[allow(dead_code)]\n pub fn line() -> String {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().to_string()\n }\n\n #[allow(dead_code)]\n pub fn gets() -> Vec\n where\n ::Err: Debug,\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse().unwrap())\n .collect()\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\nfn main() {\n let str :Vec = util::line().chars().collect();\n let mut flag = 0;\n let mut ans =0;\n for c in str {\n if c == '1' {\n flag = 1;\n } else if flag == 1 {\n ans += 1;\n }\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "7b4dc658705815c03423b4dbf7146445", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "apr_id": "e1515dde1f67e657f96d0db37817800d", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9490616621983914, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\n\nfn read_line() -> String {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n return String::from(input_line.trim());\n}\n\n\nfn main() {\n let s = read_line();\n \n match s.chars().filter(|x| *x == '0').count() >= 6 {\n true => println!(\"yes\"),\n false => println!(\"no\")\n } \n\n}\n", "lang": "Rust", "bug_code_uid": "a9f32016ea7dc75efd8e659b7782c6c3", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "apr_id": "70ffa6ff710dd8a3e082f90b87e7629e", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8093862815884476, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::{io, process};\n\nfn main() {\n\tlet n: u8 = {\n\t\tlet mut line = String::new();\n\t\tio::stdin().read_line(&mut line).unwrap();\n\t\tline.trim().parse().unwrap()\n\t};\n\n\tlet mut a: Vec = {\n\t\tlet mut line = String::new();\n\t\tio::stdin().read_line(&mut line).unwrap();\n\t\tline.trim().split(' ').map(|a| a.parse().unwrap()).collect()\n\t};\n\n\ta.sort();\n\n\t// remove duplicates\n\tlet mut i = a.len() - 1;\n\tloop {\n\t\tfor j in (0..a.len()).rev() {\n\t\t\tif i == j {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif a[i] == a[j] {\n\t\t\t\tif i > j {\n\t\t\t\t\ta.remove(i);\n\t\t\t\t\ta.remove(j);\n\t\t\t\t} else {\n\t\t\t\t\ta.remove(j);\n\t\t\t\t\ta.remove(i);\n\t\t\t\t}\n\t\t\t\ti -= 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif i == 0 {\n\t\t\tbreak;\n\t\t}\n\t\ti -= 1;\n\t}\n\n\tassert!(a.len() % 2 == 0);\n\n\tlet mut pb0 = 0u32;\n\tfor s in a\n\t\t.iter()\n\t\t.enumerate()\n\t\t.filter(|s| s.0 % 2 == 0)\n\t\t.map(|s| *s.1)\n\t\t.zip(a.iter().enumerate().filter(|s| s.0 % 2 == 1).map(|s| *s.1))\n\t{\n\t\tpb0 += s.1 as u32 - s.0 as u32;\n\t}\n\n\tif a.len() < 3 {\n\t\tprintln!(\"{}\", pb0);\n\t\tprocess::exit(0);\n\t}\n\n\tlet mut pb1 = 0u32;\n\tlet mut b: Vec = a\n\t\t.iter()\n\t\t.enumerate()\n\t\t.filter(|s| s.0 % 2 == 0)\n\t\t.map(|s| *s.1)\n\t\t.collect();\n\tprintln!(\"{:?}\", b);\n\tb.remove(0);\n\tlet lasti = b.len() - 1;\n\tb.remove(lasti);\n\tfor s in a\n\t\t.iter()\n\t\t.enumerate()\n\t\t.filter(|s| s.0 % 2 == 1)\n\t\t.map(|s| *s.1)\n\t\t.zip(b)\n\t{\n\t\tpb1 += s.1 as u32 - s.0 as u32;\n\t}\n\tpb1 += a[a.len() - 1] as u32 - a[0] as u32;\n\n\tprintln!(\"{}\", pb0.min(pb1));\n}\n", "lang": "Rust", "bug_code_uid": "962975651f2b4b9e16cbf26c92839837", "src_uid": "55485fe203a114374f0aae93006278d3", "apr_id": "917edcf5237b897f45c56c3c66a4f719", "difficulty": 800, "tags": ["sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7748344370860927, "equal_cnt": 6, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "use std::io::{stdin};\n\nfn main() {\n let mut students_count = String::new();\n stdin().read_line(&mut students_count).expect(\"expected count input\");\n let _count : u32 = students_count.trim().parse().unwrap();\n let mut students_score = String::with_capacity(500);\n stdin().read_line(&mut students_score).expect(\"expected students score\");\n let mut scores_arr : Vec = students_score.trim().split(\" \")\n .map(|score| score.parse::().unwrap())\n .collect();\n scores_arr.sort();\n let mut max_diff : u32 = 0;\n for i in 0..(scores_arr.len() - 1) {\n let diff : u32 = scores_arr[i + 1] - scores_arr[i];\n if diff > max_diff {\n max_diff = diff;\n }\n }\n println!(\"{}\", max_diff)\n}", "lang": "Rust", "bug_code_uid": "4f234ed0bb8c84b5ac87e2ed49784355", "src_uid": "55485fe203a114374f0aae93006278d3", "apr_id": "5f534be04c18fbc8c27e5b5e539a95c4", "difficulty": 800, "tags": ["sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999656002751978, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n}\n\nfn find(src: u64, num: u64, n4: usize, n7: usize, result: &mut u64) {\n if num > 1000000000 {\n return;\n }\n if n4 == n7 && num >= src && (num - src) < (*result - src) {\n *result = num;\n }\n find(src, num * 10 + 4, n4 + 1, n7, result);\n find(src, num * 10 + 7, n4, n7 + 1, result);\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let n: u64 = scan.next();\n let mut result = std::u64::MAX;\n find(n, 0, 0, 0, &mut result);\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "6828c5105c741a0b3b7d021a9e88b0a2", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "apr_id": "2e244684edcde7092733b3074f3a1a31", "difficulty": 1300, "tags": ["brute force", "bitmasks", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9990867579908675, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self, Read};\n\nfn main() -> () {\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n handle.read_to_string(&mut buffer).expect(\"stdin\");\n\n let arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n\n let mut n = arr.iter().nth(0).unwrap();\n\n let mut curr = 1;\n let mut total = 0;\n let mut count = 0;\n \n while total < n {\n count += 1;\n total += curr;\n curr = curr * 2;\n }\n\n println!(\"{}\", count );\n}\n", "lang": "Rust", "bug_code_uid": "a2a5b709260e29cd8b7c18bd958eb6dc", "src_uid": "95cb79597443461085e62d974d67a9a0", "apr_id": "645e88aa9b125f9adb6598dd711da40c", "difficulty": 1300, "tags": ["math", "constructive algorithms", "greedy"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9545454545454546, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "// This file is a \"Hello, world!\" in Rust language for wandbox.\nuse std::io;\n\nfn main()\n{\n let stdin = io::stdin();\n let mut buffer = String::new();\n stdin.read_line(&mut buffer).unwrap();\n let mut n = buffer.parse::().unwrap();\n let mut cnt = 0;\n while n > 0 {\n n >>= 1;\n cnt += 1;\n }\n \n println!(\"{}\", cnt);\n}\n\n// Rust language references:\n// https://www.rust-lang.org/\n", "lang": "Rust", "bug_code_uid": "697bb3e736ee7bc819d8bc8b9ee9937f", "src_uid": "95cb79597443461085e62d974d67a9a0", "apr_id": "9f5f6ced4c697e7aac07d2f7b1202121", "difficulty": 1300, "tags": ["math", "constructive algorithms", "greedy"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.029693486590038315, "equal_cnt": 17, "replace_cnt": 14, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 18, "bug_source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nbool f_possible(int x, vector p) {\n int perm_count = 0;\n do {\n if ((((x % p[0]) % p[1]) % p[2]) % p[3] == x) {\n perm_count++;\n }\n if (perm_count >= 7) {\n return true;\n }\n }\n while (next_permutation(p.begin(), p.end()));\n return false;\n}\n\nint solve(const vector& p, int a, int b) {\n int ans = 0;\n for (int x = a; x <= b; x++) {\n if (f_possible(x, p)) {\n ans++;\n }\n }\n return ans;\n}\n\nint main() {\n vector p;\n for (int i = 0; i < 4; i++) {\n int x; cin >> x;\n p.push_back(x);\n }\n sort(p.begin(), p.end());\n int a, b;\n cin >> a >> b;\n int ans = solve(p, a, b);\n cout << ans << \"\\n\";\n}", "lang": "Rust", "bug_code_uid": "ca2a96317f1315be9348f2462a4bc7f7", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "apr_id": "93cbd23285bfaa1827232d98698b0b22", "difficulty": 1100, "tags": ["number theory", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9931201942533388, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let p1: i32 = scan.token();\n let p2: i32 = scan.token();\n let p3: i32 = scan.token();\n let p4: i32 = scan.token();\n let a: i32 = scan.token();\n let b: i32 = scan.token();\n let ans = b.min(p1).min(p2).min(p3).min(p4) - a.max(0);\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "aaea6da79fa91bc1e29865819524e7d1", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "apr_id": "93cbd23285bfaa1827232d98698b0b22", "difficulty": 1100, "tags": ["number theory", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8969957081545065, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "// Practice Codeforces\n// author: Leonardone @ NEETSDKASU\n\n// 解説読後\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(\n &mut std::io::stdin(),\n &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n ($t:ty) => (get().parse::<$t>().unwrap());\n () => (get!(i64));\n }\n \n let n = get!();\n let m = get!(usize);\n \n if n < 2000 {\n let ans = brute_force(n, m as i64);\n println!(\"{}\", ans);\n }\n \n let mut xs = vec![0; m];\n \n for i in 0..m {\n let mut c = n / m as i64;\n if i as i64 <= n % m as i64 {\n c += 1;\n }\n xs[i] += c;\n }\n xs[0] -= 1;\n // println!(\"{:?}\", xs);\n let mut ans = 0;\n let c = n / m as i64;\n for i in 0..xs.len() {\n for j in 0..xs.len() {\n let k = (i*i+j*j) % m;\n if k == 0 {\n ans += xs[i] * xs[j];\n }\n }\n }\n\n println!(\"{}\", ans);\n}\n\n\nfn brute_force(n: i64, m: i64) -> i64 {\n let mut ret = 0;\n for i in 1..=n {\n for j in 1..=n {\n let k = i * i + j * j;\n if k % m == 0 {\n ret += 1;\n }\n }\n }\n ret\n}\n", "lang": "Rust", "bug_code_uid": "20c7fb410c6afc3e9685759e68e80ca8", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "apr_id": "2171813dc9b73801f365bd227ec68ad6", "difficulty": 1600, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.939786156443444, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io::stdin;\n\npub fn process(n: i32, m: i32) -> u64 {\n let mut res: u64 = 0;\n for i in 1..=m {\n for j in 1..=m {\n if (i * i + j * j) % m != 0 { continue }\n let k = ((n - i) / m) as u64;\n let l = ((n - j) / m) as u64;\n res += ((k + 1) * (l + 1));\n }\n }\n res\n}\n\nfn main() {\n let mut s = String::new();\n stdin().read_line(&mut s).unwrap();\n let mut input = s.split_whitespace();\n let n = input.next().unwrap().parse::().unwrap();\n let m = input.next().unwrap().parse::().unwrap();\n\n println!(\"{}\", process(n, m));\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test1() {\n assert_eq!(process(3, 3), 1);\n }\n\n #[test]\n fn test2() {\n assert_eq!(process(6, 5), 13);\n }\n\n #[test]\n fn test3() {\n assert_eq!(process(1000_000_000, 1), 1000_000_000_000_000_000);\n }\n}\n", "lang": "Rust", "bug_code_uid": "538c833a096b3d8526bc4f9545b4a094", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "apr_id": "51ae1e2563d11f5efe40e39402f5f8b0", "difficulty": 1600, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9964253798033958, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, prelude::*};\nuse std::str;\nuse std::string::String;\nuse std::vec::Vec;\n\n#[allow(unused_must_use)]\nfn run(mut reader: Scanner, mut writer: W) {\n let n: usize = reader.next();\n let k: usize = reader.next();\n\n let mut scores: Vec = reader.next_line().split_whitespace().map(|n| n.parse().unwrap()).collect();\n scores.sort_unstable();\n scores.reverse();\n\n let mut count: i32 = 0;\n let minimum_score: i32 = scores[k];\n for i in 0..n {\n if scores[i] >= minimum_score && scores[i] > 0 {\n count += 1;\n }\n }\n\n writeln!(writer, \"{}\", count);\n\n io::stdout().flush().unwrap();\n}\n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n\n let reader = Scanner::new(stdin.lock());\n let writer = io::BufWriter::new(stdout.lock());\n run(reader, writer);\n}\n\npub struct Scanner {\n reader: B,\n buffer_string: Vec,\n buffer_iterator: str::SplitWhitespace<'static>,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Self {\n return Self {\n reader,\n buffer_string: Vec::new(),\n buffer_iterator: \"\".split_whitespace()\n };\n }\n\n pub fn next(&mut self) -> T {\n loop {\n //if buffer already exists, just use existing buffer\n if let Some(token) = self.buffer_iterator.next() {\n return token.parse().ok().expect(\"Fail to parse token\");\n }\n\n //get new line\n self.buffer_string.clear();\n self.reader.read_until(b'\\n', &mut self.buffer_string).expect(\"Failed to read\");\n\n //split by white space\n self.buffer_iterator = unsafe {\n let slice = str::from_utf8_unchecked(&self.buffer_string);\n std::mem::transmute(slice.split_whitespace())\n };\n }\n }\n\n pub fn next_line(&mut self) -> String {\n //reset buffer\n self.buffer_iterator = \"\".split_whitespace();\n self.buffer_string.clear();\n\n let mut input: String = String::new();\n self.reader.read_line(&mut input).expect(\"Failed to read line\");\n return input.trim().to_string();\n }\n}", "lang": "Rust", "bug_code_uid": "46cb72965e6c2ca7350184582c0bf4ad", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "19058045f0404f7494b468a1435a162a", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9982788296041308, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nfn main() {\n let mut input = String::new();\n let mut n: i64;\n let mut k : i64;\n let mut numbers: Vec = Vec::new();\n io::stdin().read_line(& mut input).expect(\"test\");\n io::stdin().read_line(&mut input).expect(\"test\");\n let mut vec = input.split_whitespace().map(|x| x.parse::().expect(\"error\")).collect::>();\n let mut count = 0;\n let len = (vec[1] + 2) as usize;\n let max = vec[len];\n for i in 2..vec.len(){\n if vec[i] > 0 && vec[i] >=max {\n count+=1;\n }\n }\n\n println!(\"{}\", count);\n}\n", "lang": "Rust", "bug_code_uid": "15757813a66a4d54ab441ece807be929", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "d747cbc4fa84e06121f92ce4006c6f8b", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9984152139461173, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "// 158A\n// solved: 4\n\nuse std::io;\n\nfn main() {\n let mut nk = String::new();\n let mut scores = String::new();\n io::stdin().read_line(&mut nk).unwrap();\n io::stdin().read_line(&mut scores).unwrap();\n let nk: Vec<_> = nk.trim().split(\" \").map(|x| x.parse::().unwrap()).collect();\n let mut scores: Vec<_> = scores.trim().split(\" \").map(|x| x.parse::().unwrap()).collect();\n let n = nk[0];\n let k = nk[1];\n scores.sort();\n let score_to_beat = scores[n-1-k];\n let result = scores.into_iter().filter(|&x| x >= score_to_beat && x > 0).collect::>().len();\n println!(\"{}\", result);\n}\n", "lang": "Rust", "bug_code_uid": "0de07e337203aeb47539cbcb4274ef38", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "ceaea38356589ea26ad651baa1eb36e0", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9993544222078761, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main(){\n\tlet mut s = String::new();\n std::io::stdin()\n .read_line(&mut s)\n .unwrap();\n\n\n let sp:Vec<&str> = s.trim().split_whitespace().collect();\n\n let n:i64 = sp[0].trim().parse().unwrap();;\n let k:usize = sp[1].trim().parse().unwrap();;\n\n\n\tlet mut s = String::new();\n std::io::stdin()\n .read_line(&mut s)\n .expect(\"failed to read input.\");\n\n let sa:Vec<&str> = s.trim().split_whitespace().collect();\n\n let mut len = 0;\n let mut kNum = -1;\n \n for (i, s) in sa.iter().enumerate(){\n \tlet mut i = i + 1\n \tlet mut cur:i64 = s.trim().parse().unwrap();\n \tif i == k {\n \t\tkNum = cur;\n \t}\n\t \tif cur > 0 && (i < k || (i >= k && kNum == cur))\n\t \t{\n\t \t\tlen += 1;\n\t \t}\n \t\n }\n\n print!(\"{:?}\", len);\n}", "lang": "Rust", "bug_code_uid": "2b3e26f40d6fc3cdcc3b87af9e601665", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "f30efdf91870431218882eed7d1b777d", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9991349480968859, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n\n match io::stdin().read_line(&mut input) {\n Ok(_) => {\n let v: Vec = input\n .trim()\n .split_whitespace()\n .map(|val| val.parse::().unwrap())\n .collect();\n\n let k = v[1];\n\n let mut nums_input = String::new();\n\n match io::stdin().read_line(&mut nums_input) {\n Ok(_) => {\n let mut count = 0;\n let nums: Vec = nums_input\n .trim()\n .split_whitespace()\n .map(|val| val.parse::().unwrap())\n .collect();\n\n let threshold = nums[k];\n\n for num in nums.iter() {\n if num >= &threshold && num > &0 {\n count += 1;\n }\n }\n\n println!(\"{}\", count);\n },\n Err(e) => println!(\"{}\", e)\n }\n },\n Err(e) => println!(\"{}\", e)\n }\n}", "lang": "Rust", "bug_code_uid": "7c2cca29b346a83ba9c4b5bd9cedc67f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "35f005411abb7e61d9ba0f0a6472646c", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9949494949494949, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "// https://codeforces.com/contest/1293/problem/F\n//\n#![allow(unused_imports)]\nuse std::io::*;\nuse std::io::Write;\nuse std::fmt::*;\nuse std::str::*;\nuse std::cmp::*;\nuse std::collections::*;\n\n// Input macros.\n// Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\n#[allow(unused_macros)]\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\n#[allow(unused_macros)]\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, [ next / $t:tt ]) => {\n {\n let len = read_value!($iter, usize);\n (0..len).map(|_| read_value!($iter, $t)).collect::>()\n }\n };\n\n ($iter:expr, switch) => {\n {\n let ty = read_value!($iter, i32);\n if ty == 1 {\n vec![ty, read_value!($iter, i32), read_value!($iter, i32)]\n } else if ty == 2 {\n vec![ty, read_value!($iter, i32)]\n } else {\n vec![ty, read_value!($iter, i32)]\n }\n }\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_line {\n ($t:tt) => {\n {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n s.trim_right().parse::<$t>().unwrap()\n }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! dvec {\n ($t:expr ; $len:expr) => {\n vec![$t; $len]\n };\n\n ($t:expr ; $len:expr, $($rest:expr),*) => {\n vec![dvec!($t; $($rest),*); $len]\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! ifv {\n ($t:expr, $a:expr, $b: expr) => {\n if $t { $a } else { $b }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! fill {\n ($t:expr, $v:expr) => {\n for i in 0..$t.len() {\n $t[i] = $v;\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! join {\n ($t:expr, $glue:expr) => {\n $t.into_iter().map(|w| w.to_string()).collect::>().join($glue)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\n// ===\n\n\nfn generate_primes(upto: usize) -> (Vec, Vec) {\n let mut is_prime = vec![true; upto+1];\n is_prime[0] = false;\n is_prime[1] = false;\n for i in 2..upto+1 {\n if is_prime[i] {\n let mut ii = i * i;\n while ii <= upto {\n is_prime[ii] = false;\n ii += i;\n }\n }\n }\n\n let mut primes = vec![];\n for i in 0..upto+1 {\n if is_prime[i] {\n primes.push(i as i64);\n }\n }\n (primes, is_prime)\n}\n//===\n\nstruct Graph {\n graph: Vec>,\n vec: Vec,\n edges: Vec<(usize, usize, i64)>,\n mark: Vec,\n dcost: Vec,\n}\n\nimpl Graph {\n fn generate_next(&mut self, cnt: i64) -> usize {\n self.vec.push(cnt);\n self.vec.len() - 1\n }\n fn add_edge(&mut self, u: usize, v: usize, len: i64) {\n self.edges.push((u, v, len));\n }\n}\n\nfn dfs(l: usize, r: usize, depth: usize, parent: usize, table: &Vec<(Vec, usize, i64)>, graph: &mut Graph) {\n if l == r {\n if table[l].1 >= 2 {\n let nid = graph.generate_next(table[l].2);\n let mut d = 0;\n\n let pn = table[0].0.len();\n for i in depth..pn {\n d += table[l].0[i];\n }\n graph.add_edge(parent, nid, d);\n }\n return;\n }\n\n if table[l].0[depth] == table[r].0[depth] {\n if table[l].0[depth] == 0 {\n dfs(l, r, depth+1, parent, table, graph);\n } else {\n let nid = graph.generate_next(0);\n graph.add_edge(parent, nid, table[l].0[depth]);\n dfs(l, r, depth+1, nid, table, graph);\n }\n return;\n }\n\n let mut ll = l;\n let mut last_value = 0;\n let mut cparent = parent;\n while ll <= r {\n let mut rr = ll;\n while rr <= r && table[ll].0[depth] == table[rr].0[depth] {\n rr += 1;\n }\n // [ll, rr)\n let add_len = table[ll].0[depth] - last_value;\n assert!(add_len >= 0);\n if add_len == 0 {\n dfs(ll, rr-1, depth+1, parent, table, graph);\n } else {\n let nid = graph.generate_next(0);\n graph.add_edge(cparent, nid, add_len);\n dfs(ll, rr-1, depth+1, nid, table, graph);\n cparent = nid;\n }\n last_value = table[ll].0[depth];\n ll = rr;\n }\n}\n\n\nfn dfs2(now: usize, par: usize, g: &mut Graph) -> (i64, i64) {\n let mut total_mark = g.vec[now];\n let mut total_cost = 0;\n for (to, len) in g.graph[now].clone() {\n if to == par {\n continue;\n }\n let (m, c) = dfs2(to, now, g);\n total_mark += m;\n total_cost += c + m * len;\n }\n g.mark[now] = total_mark;\n g.dcost[now] = total_cost;\n (total_mark, total_cost)\n}\n\nfn dfs3(now: usize, par: usize, g: &mut Graph) -> i64 {\n let mut best = g.dcost[now];\n for (to, len) in g.graph[now].clone() {\n if to == par {\n continue;\n }\n let mark_back = g.mark[to];\n let dcost_back = g.dcost[to];\n let reduce_cost = g.dcost[to] + g.mark[to] * len;\n let reduce_mark = g.mark[to];\n\n\n g.dcost[to] += (g.dcost[now] - reduce_cost) + (g.mark[now] - reduce_mark) * len;\n g.mark[to] += (g.mark[now] - reduce_mark);\n\n best = min(best, dfs3(to, now, g));\n\n g.mark[to] = mark_back;\n g.dcost[to] = dcost_back;\n\n }\n // debug!(now, best);\n best\n}\n\nconst LIMIT: usize = 5000;\n\nfn main() {\n input! {\n n: usize,\n k: [usize; n]\n };\n\n let mut deg = vec![0; LIMIT+1];\n for k in k {\n deg[k] += 1;\n }\n let (primes, is_prime) = generate_primes(LIMIT+1);\n\n let mut pn = primes.len();\n let mut vec = vec![];\n // let mut edges = vec![];\n\n let mut l = LIMIT;\n while l >= 2 {\n let mut lw = l;\n while !is_prime[lw] {\n lw -= 1;\n }\n\n for num in (lw..=l).rev() {\n let mut ptbl = vec![0; pn];\n for i in 0..pn {\n let mut num = num as i64;\n while num >= primes[i] {\n ptbl[i] += num / primes[i];\n num /= primes[i];\n }\n }\n ptbl.reverse();\n vec.push((ptbl, num, deg[num]));\n }\n l = lw-1;\n }\n vec.push((vec![0; pn], 1, deg[1]));\n vec.sort();\n\n let mut graph = Graph { vec: vec![], edges: vec![], graph: vec![], mark: vec![], dcost: vec![] };\n graph.generate_next(deg[1]);\n\n dfs(0, vec.len()-1, 0, 0, &vec, &mut graph);\n\n let vn = graph.vec.len();\n\n let mut deg = graph.vec.clone();\n let mut g = vec![vec![]; vn];\n for &(u, v, len) in &graph.edges {\n g[u].push((v, len));\n g[v].push((u, len));\n }\n graph.graph = g;\n graph.mark = vec![0; vn];\n graph.dcost = vec![0; vn];\n\n dfs2(0, vn, &mut graph);\n\n // debug!(graph.graph);\n // debug!(graph.vec);\n\n let ans = dfs3(0, vn, &mut graph);\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "45573bb45e701d16543e92c5a196d31b", "src_uid": "40002052843ca0357dbd3158b16d59f4", "apr_id": "b4c00737341c24a80ca89eb4d74ecdeb", "difficulty": 2700, "tags": ["dp", "number theory", "math", "graphs", "trees"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9947681760779361, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "// https://codeforces.com/contest/1293/problem/F\n//\n#![allow(unused_imports)]\nuse std::io::*;\nuse std::io::Write;\nuse std::fmt::*;\nuse std::str::*;\nuse std::cmp::*;\nuse std::collections::*;\n\n// Input macros.\n// Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\n#[allow(unused_macros)]\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\n#[allow(unused_macros)]\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, [ next / $t:tt ]) => {\n {\n let len = read_value!($iter, usize);\n (0..len).map(|_| read_value!($iter, $t)).collect::>()\n }\n };\n\n ($iter:expr, switch) => {\n {\n let ty = read_value!($iter, i32);\n if ty == 1 {\n vec![ty, read_value!($iter, i32), read_value!($iter, i32)]\n } else if ty == 2 {\n vec![ty, read_value!($iter, i32)]\n } else {\n vec![ty, read_value!($iter, i32)]\n }\n }\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_line {\n ($t:tt) => {\n {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n s.trim_right().parse::<$t>().unwrap()\n }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! dvec {\n ($t:expr ; $len:expr) => {\n vec![$t; $len]\n };\n\n ($t:expr ; $len:expr, $($rest:expr),*) => {\n vec![dvec!($t; $($rest),*); $len]\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! ifv {\n ($t:expr, $a:expr, $b: expr) => {\n if $t { $a } else { $b }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! fill {\n ($t:expr, $v:expr) => {\n for i in 0..$t.len() {\n $t[i] = $v;\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! join {\n ($t:expr, $glue:expr) => {\n $t.into_iter().map(|w| w.to_string()).collect::>().join($glue)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\n// ===\n\n\nfn generate_primes(upto: usize) -> (Vec, Vec) {\n let mut is_prime = vec![true; upto+1];\n is_prime[0] = false;\n is_prime[1] = false;\n for i in 2..upto+1 {\n if is_prime[i] {\n let mut ii = i * i;\n while ii <= upto {\n is_prime[ii] = false;\n ii += i;\n }\n }\n }\n\n let mut primes = vec![];\n for i in 0..upto+1 {\n if is_prime[i] {\n primes.push(i as i64);\n }\n }\n (primes, is_prime)\n}\n//===\n\nstruct Graph {\n graph: Vec>,\n vec: Vec,\n edges: Vec<(usize, usize, i64)>,\n mark: Vec,\n dcost: Vec,\n}\n\nimpl Graph {\n fn generate_next(&mut self, cnt: i64) -> usize {\n self.vec.push(cnt);\n self.vec.len() - 1\n }\n fn add_edge(&mut self, u: usize, v: usize, len: i64) {\n self.edges.push((u, v, len));\n }\n}\n\nfn dfs(l: usize, r: usize, depth: usize, parent: usize, table: &Vec<(Vec, usize, i64)>, graph: &mut Graph) {\n if l == r {\n if table[l].1 >= 2 {\n let nid = graph.generate_next(table[l].2);\n let mut d = 0;\n\n let pn = table[0].0.len();\n for i in depth..pn {\n d += table[l].0[i];\n }\n graph.add_edge(parent, nid, d);\n }\n return;\n }\n\n if table[l].0[depth] == table[r].0[depth] {\n if table[l].0[depth] == 0 {\n dfs(l, r, depth+1, parent, table, graph);\n } else {\n let nid = graph.generate_next(0);\n graph.add_edge(parent, nid, table[l].0[depth]);\n dfs(l, r, depth+1, nid, table, graph);\n }\n return;\n }\n\n let mut ll = l;\n let mut last_value = 0;\n let mut cparent = parent;\n while ll <= r {\n let mut rr = ll;\n while rr <= r && table[ll].0[depth] == table[rr].0[depth] {\n rr += 1;\n }\n // [ll, rr)\n let add_len = table[ll].0[depth] - last_value;\n assert!(add_len >= 0);\n if add_len == 0 {\n dfs(ll, rr-1, depth+1, parent, table, graph);\n } else {\n let nid = graph.generate_next(0);\n graph.add_edge(cparent, nid, add_len);\n dfs(ll, rr-1, depth+1, nid, table, graph);\n cparent = nid;\n }\n last_value = table[ll].0[depth];\n ll = rr;\n }\n}\n\n\nfn dfs2(now: usize, par: usize, g: &mut Graph) -> (i64, i64) {\n let mut total_mark = g.vec[now];\n let mut total_cost = 0;\n for (to, len) in g.graph[now].clone() {\n if to == par {\n continue;\n }\n let (m, c) = dfs2(to, now, g);\n total_mark += m;\n total_cost += c + m * len;\n }\n g.mark[now] = total_mark;\n g.dcost[now] = total_cost;\n (total_mark, total_cost)\n}\n\nfn dfs3(now: usize, par: usize, g: &mut Graph) -> i64 {\n let mut best = g.dcost[now];\n for (to, len) in g.graph[now].clone() {\n if to == par {\n continue;\n }\n let mark_back = g.mark[to];\n let dcost_back = g.dcost[to];\n let reduce_cost = g.dcost[to] + g.mark[to] * len;\n let reduce_mark = g.mark[to];\n\n\n g.dcost[to] += (g.dcost[now] - reduce_cost) + (g.mark[now] - reduce_mark) * len;\n g.mark[to] += (g.mark[now] - reduce_mark);\n\n best = min(best, dfs3(to, now, g));\n\n g.mark[to] = mark_back;\n g.dcost[to] = dcost_back;\n\n }\n // debug!(now, best);\n best\n}\n\nconst LIMIT: usize = 5;\n\nfn main() {\n input! {\n n: usize,\n k: [usize; n]\n };\n\n let mut deg = vec![0; LIMIT+1];\n for k in k {\n deg[k] += 1;\n }\n let (primes, is_prime) = generate_primes(LIMIT+1);\n\n let mut pn = primes.len();\n let mut vec = vec![];\n // let mut edges = vec![];\n\n let mut l = LIMIT;\n while l >= 2 {\n let mut lw = l;\n while !is_prime[lw] {\n lw -= 1;\n }\n\n for num in (lw..=l).rev() {\n let mut ptbl = vec![0; pn];\n for i in 0..pn {\n let mut num = num as i64;\n while num >= primes[i] {\n ptbl[i] += num / primes[i];\n num /= primes[i];\n }\n }\n ptbl.reverse();\n vec.push((ptbl, num, deg[num]));\n }\n l = lw-1;\n }\n vec.push((vec![0; pn], 1, deg[1]));\n vec.sort();\n\n let mut graph = Graph { vec: vec![], edges: vec![], graph: vec![], mark: vec![], dcost: vec![] };\n graph.generate_next(deg[1]);\n\n dfs(0, vec.len()-1, 0, 0, &vec, &mut graph);\n\n let vn = graph.vec.len();\n\n let mut deg = graph.vec.clone();\n let mut g = vec![vec![]; vn];\n for &(u, v, len) in &graph.edges {\n g[u].push((v, len));\n g[v].push((u, len));\n }\n graph.graph = g;\n graph.mark = vec![0; vn];\n graph.dcost = vec![0; vn];\n\n dfs2(0, vn, &mut graph);\n\n // debug!(graph.graph);\n // debug!(graph.vec);\n\n let ans = dfs3(0, vn, &mut graph);\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "a5ad50712d8072e14dafc3c053c95a26", "src_uid": "40002052843ca0357dbd3158b16d59f4", "apr_id": "b4c00737341c24a80ca89eb4d74ecdeb", "difficulty": 2700, "tags": ["dp", "number theory", "math", "graphs", "trees"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.98, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut black = 0;\n let mut white = 0;\n let mut x = 0;\n let mut weights: [i32; 2];\n let mut line = String::new();\n while x < 8 {\n io::stdin().read_line(&mut line).expect(\"error: unable to read user input\");\n weights = weight(&line);\n black += weights[0];\n white += weights[1];\n x += 1;\n }\n if black > white {\n println!(\"Black\");\n } else if black < white {\n println!(\"White\");\n } else {\n println!(\"Draw\");\n }\n}\n\nfn weight(x: &str) -> [i32; 2] {\n let mut b = 0;\n let mut w = 0;\n for i in x.chars() {\n match i {\n 'q' => b += 9,\n 'r' => b += 5,\n 'b' => b += 3,\n 'n' => b += 3,\n 'p' => b += 1,\n 'Q' => w += 9,\n 'R' => w += 5,\n 'B' => w += 3,\n 'N' => w += 3,\n 'P' => w += 1,\n _ => (),\n };\n }\n let arr: [i32; 2] = [b, w];\n return arr;\n}", "lang": "Rust", "bug_code_uid": "a751bddd5a63f5355ae4fc067102a53f", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "6819ff294aab65023add2f407800be24", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9959919839679359, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut black = 0;\n let mut white = 0;\n let mut x = 0;\n let mut weights: [i32; 2];\n while x < 8 {\n let line = String::new();\n io::stdin().read_line(&line).expect(\"error: unable to read user input\");\n weights = weight(&line);\n black += weights[0];\n white += weights[1];\n x += 1;\n }\n if black > white {\n println!(\"Black\");\n } else if black < white {\n println!(\"White\");\n } else {\n println!(\"Draw\");\n }\n}\n\nfn weight(x: &str) -> [i32; 2] {\n let mut b = 0;\n let mut w = 0;\n for i in x.chars() {\n match i {\n 'q' => b += 9,\n 'r' => b += 5,\n 'b' => b += 3,\n 'n' => b += 3,\n 'p' => b += 1,\n 'Q' => w += 9,\n 'R' => w += 5,\n 'B' => w += 3,\n 'N' => w += 3,\n 'P' => w += 1,\n _ => (),\n };\n }\n let arr: [i32; 2] = [b, w];\n return arr;\n}", "lang": "Rust", "bug_code_uid": "cb3c52b6408e3ecacb13f104fd62cef7", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "6819ff294aab65023add2f407800be24", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9994314951677089, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n#[allow(unused_imports)]\nuse std::collections::HashMap;\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let mut weights : HashMap = HashMap::new();\n weights.insert(String::from(\"q\"),9);\n weights.insert(String::from(\"r\"),5);\n weights.insert(String::from(\"b\"),3);\n weights.insert(String::from(\"n\"),3);\n weights.insert(String::from(\"p\"),3);\n weights.insert(String::from(\"k\"),0);\n let mut a = String::new();\n for _ in 0..8 {\n a += &readln!();\n }\n let w :i32 = a.chars().filter(|c|c.is_uppercase()).map(|x|x.to_lowercase()).map(|x| {\n let sx : String = x.to_string();\n weights.get(&sx).unwrap()\n }).sum();\n let b :i32 = a.chars().filter(|c|c.is_lowercase()).map(|x|{\n let sx : String = x.to_string();\n weights.get(&sx).unwrap()\n }).sum();\n println!(\"{}\",if w>b { \"White\" } else if w bs{\n println!(\"White\");\n }\n if ws == bs{\n println!(\"Draw\");\n }\n if ws < bs{\n println!(\"Black\");\n }\n}\n\nfn countblack(s: String) -> i32{\n let mut b:i32 = 0;\n for x in s.chars() {\n match x {\n 'Q' => b=b+9,\n 'R' => b=b+5,\n 'B' => b=b+3,\n 'N' => b=b+3,\n 'P' => b=b+1,\n _ => b=b+0\n };\n }\n return b;\n}\n\nfn countwhite(s: String) -> i32{\n let mut b:i32 = 0;\n for x in s.chars() {\n match x {\n 'q' => b=b+9,\n 'r' => b=b+5,\n 'b' => b=b+3,\n 'n' => b=b+3,\n 'p' => b=b+1,\n _ => b=b+0\n };\n }\n return b;\n}\n", "lang": "Rust", "bug_code_uid": "3751544c66bbb15f530f71a711087fce", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "0c0b34134f76dc2104abfe3b1884ab79", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9984673261808555, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::io::prelude::*;\n\nfn main() {\n let l1 = read_line_iter();\n let l2 = read_line_iter();\n let l3 = read_line_iter();\n let l4 = read_line_iter();\n let l5 = read_line_iter();\n let l6 = read_line_iter();\n let l7 = read_line_iter();\n let l8 = read_line_iter();\n\n let L1 = l1.as_bytes();\n let L2 = l2.as_bytes();\n let L3 = l3.as_bytes();\n let L4 = l4.as_bytes();\n let L5 = l5.as_bytes();\n let L6 = l6.as_bytes();\n let L7 = l7.as_bytes();\n let L8 = l8.as_bytes();\n\n let mut white = 0;\n let mut black = 0;\n\n //println!(\n // \"L1:{},L2:{},L3:{},L4:{},L5:{},L6:{},L7:{},L8:{}\",\n // l1,l2,l3,l4,l5,l6,l7,l8\n //);\n for i in 0..8{\n match L1[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n for i in 0..8{\n match L2[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n for i in 0..8{\n match L3[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n for i in 0..8{\n match L4[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n for i in 0..8{\n match L5[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n for i in 0..8{\n match L6[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n for i in 0..8{\n match L7[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n for i in 0..8{\n match L8[i] as char{\n 'p' => black += 1,\n 'n' => black += 3,\n 'b' => black += 3,\n 'r' => black += 5,\n 'q' => black += 9,\n 'P' => white += 1,\n 'N' => white += 3,\n 'B' => white += 3,\n 'R' => white += 5,\n 'Q' => white += 9,\n _ => (),\n }\n }\n let advantage = white-black;\n match advantage{\n 1..=40 => println!(\"White\"),\n -40..=-1 => println!(\"Black\"),\n _ => println!(\"Draw\"),\n }\n \n}\n\nfn read_line_iter() -> String {\n let stdin = io::stdin();\n // Read one line of input iterator-style\n let input = stdin.lock().lines().next();\n input\n .expect(\"No lines in buffer\")\n .expect(\"Failed to read line\")\n .trim()\n .to_string()\n}", "lang": "Rust", "bug_code_uid": "5e55d15cd7c0fc2bd603e193c680d413", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "7a43ec03e533c0dc342f65ab93f42f85", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.70550621669627, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 12, "bug_source_code": "use std::io;\n\nfn main() { \n let mut points = 0;\n let mut owned_string: String = \"hello \".to_owned();\n for _ in 0..8 {\n let mut input = String::new();\n match io::stdin().read_line(&mut input) {\n Ok(_) => {\n let borrowed_string: &str = &input;\n owned_string.push_str(borrowed_string);\n }\n Err(error) => println!(\"error: {}\", error),\n } \n }\n let char_vec: Vec = owned_string.chars().collect();\n for c in char_vec {\n match c {\n 'q' => points = points - 9,\n 'r' => points = points - 3,\n 'b' => points = points - 3,\n 'n' => points = points - 5,\n 'p' => points = points - 1,\n 'k' => points = points - 0,\n 'Q' => points = points + 9,\n 'R' => points = points + 3,\n 'B' => points = points + 3,\n 'N' => points = points + 5,\n 'P' => points = points + 1,\n 'K' => points = points + 0,\n '.' => points = points + 0,\n _ => points = points + 0,\n }\n }\n if points < 0{\n println!(\"Black\")\n \n } \n else if points>0 {\n println!(\"White\")\n }\n else{\n println!(\"Draw\")\n }\n \n}", "lang": "Rust", "bug_code_uid": "aac62eb9db91afeaca920600e04dd2d3", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "62e0304c6dc3e8cc2c4443be617efd23", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9560185185185185, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "fn black_points(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 white_points(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 main(){\n let mut number = 1;\n let mut whiter_counter = 0;\n let mut black_counter = 0;\n while number <= 8{\n let mut line1 = String::new();\n let b1 = std::io::stdin().read_line(&mut line1).unwrap();\n for c in line1.chars(){\n black_counter += black_points(c);\n whiter_counter += white_points(c);\n\n }\n number += 1;\n }\n if whiter_counter > black_counter{\n println!(\"White\");\n }\n else{\n println!(\"Black\");\n }\n }", "lang": "Rust", "bug_code_uid": "90d386dff73bf8d2c072d0eb617e5e08", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "67171c2f5cab2494333b5c3a7cfcea9e", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.867680958967266, "equal_cnt": 9, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nfn main() {\n\n //variable a retornar, tiene que ser mutable\n let mut sum :i32 = 0;\n \n //para iterar\n let mut n :i32 = 0;\n\n //Se tiene que iterar IO sino da error en runtime\n while n < 8{\n //varible que guardara el input\n let mut input = String::new();\n //se consigue la linea\n io::stdin().read_line(&mut input).unwrap();\n //se calcula \n sum += valor(input);\n\n n += 1;\n }\n\n //match algo forzado pero interesante implementacion\n //asi obtenemos un numero unico 1 -> whit e , 0 -> draw y -1 -> black\n\n println!(\"{}\",sum);\n}\n\nfn valor(linea: String) -> i32{\n //variable a retornar\n let mut st :i32 = 0;\n\n for c in linea.chars(){\n match c{\n 'Q' => st += 9,\n 'R' => st += 5,\n 'B' => st += 3,\n 'N' => st += 3,\n 'P' => st += 1,\n 'q' => st -= 9,\n 'r' => st -= 5,\n 'b' => st -= 3,\n 'n' => st -= 3,\n 'p' => st -= 1,\n _ => (),\n };\n }\n\n st\n}", "lang": "Rust", "bug_code_uid": "d39373a805f86f974a0706b833cb7bf4", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "421d74aaab078a5bae31be6e1ab9ebd4", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.905726872246696, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn main() {\n\n //variable a retornar, tiene que ser mutable\n let mut sum :i32 = 0;\n \n //para iterar\n let mut n :i32 = 0;\n\n //Se tiene que iterar IO sino da error en runtime\n while n < 8{\n //varible que guardara el input\n let mut input = String::new();\n //se consigue la linea\n io::stdin().read_line(&mut input).unwrap();\n //se calcula \n sum += valor(input);\n\n n += 1;\n }\n\n //match algo forzado pero interesante implementacion\n //asi obtenemos un numero unico 1 -> whit e , 0 -> draw y -1 -> black\n\n match sum/sum.abs(){\n 1 => println!(\"White\"),\n 0 => println!(\"Draw\"),\n _ => println!(\"Black\"),\n\n }\n}\n\nfn valor(linea: String) -> i32{\n //variable a retornar\n let mut st :i32 = 0;\n\n for c in linea.chars(){\n match c{\n 'Q' => st += 9,\n 'R' => st += 5,\n 'B' => st += 3,\n 'N' => st += 3,\n 'P' => st += 1,\n 'q' => st -= 9,\n 'r' => st -= 5,\n 'b' => st -= 3,\n 'n' => st -= 3,\n 'p' => st -= 1,\n _ => (),\n };\n }\n\n st\n}", "lang": "Rust", "bug_code_uid": "d7fae2150334d399143aa8c8e3e849f5", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "421d74aaab078a5bae31be6e1ab9ebd4", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.993367722918202, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "fn valores (mut ptj: i32,i:char) -> i32 {\n match i {\n 'q' => ptj+=9,\n 'r' => ptj+=5,\n 'b' | 'n' => ptj+=3,\n 'p' => ptj+=1,\n 'Q' => ptj-=9,\n 'R' => ptj-=5,\n 'B' | 'N' => ptj-=3,\n 'P' => ptj-=1,\n _ => 0,\n };\n ptj\n}\n\nfn main(){\n let mut puntaje=0;\n for i in 0..8{\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n for j in input.chars(){\n puntaje=valores(puntaje,j);\n }\n } \n if puntaje<0{\n println!(\"Black\");\n }\n else if puntaje>0{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n}", "lang": "Rust", "bug_code_uid": "f255ce36fe2c5c5ba76986f609daff11", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "0968fb5f6dc9d19debf2c2d5867ae7a0", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9970631424375918, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn valores (mut ptj: i32,i:char) -> i32 {\n match i {\n 'q' => ptj+=9,\n 'r' => ptj+=5,\n 'b' | 'n' => ptj+=3,\n 'p' => ptj+=1,\n 'Q' => ptj-=9,\n 'R' => ptj-=5,\n 'B' | 'N' => ptj-=3,\n 'P' => ptj-=1,\n _ => ptj+=0,\n };\n ptj\n}\n\nfn main(){\n let mut puntaje=0;\n for i in 0..8{\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n for j in input.chars(){\n puntaje=valores(puntaje,j);\n }\n } \n if puntaje<0{\n println!(\"Black\");\n }\n else if puntaje>0{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n}", "lang": "Rust", "bug_code_uid": "55e41e083d703ae8f6c53813ccaecd6e", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "0968fb5f6dc9d19debf2c2d5867ae7a0", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9210392256749873, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "use std::mem;\n\nstruct 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 mut n: usize = scan.next();\n let mut m: usize = scan.next();\n if n > m {\n mem::swap(&mut n, &mut m);\n }\n let over = 2.min(m - n);\n let result = (n * 2 + over) / 3;\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "56d89be64dcfd18831192c8aa4d237ec", "src_uid": "0718c6afe52cd232a5e942052527f31b", "apr_id": "9f1f0c296b4d215757dbcaa88ce6bc3d", "difficulty": 1300, "tags": ["number theory", "greedy", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9652226967663209, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\n\n// type Matrix = Vec>;\n\nfn read_line() -> String {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n return String::from(input_line.trim());\n}\n\nfn read_line_vec() -> Vec {\n return read_line().split(' ')\n .map(|s| s.parse().unwrap())\n .collect();\n}\n\nfn read_line_pair() -> (i64, i64) {\n let vec = read_line_vec();\n return (vec[0], vec[1]);\n}\n\n\nfn main() {\n \n let (mut n, mut m) = read_line_pair();\n \n let mut count = 0;\n \n while n > 0 && m > 0 {\n if n > m {\n n -= 2;\n m -= 1;\n } else {\n n -= 1;\n m -= 2;\n }\n count += 1;\n }\n \n println!(\"{}\", count);\n\n // println!(\"{:?} {:?}\", l, r);\n \n}\n", "lang": "Rust", "bug_code_uid": "0f4b335bf8cef23b344032b09a40ba33", "src_uid": "0718c6afe52cd232a5e942052527f31b", "apr_id": "acbd01d28c931f0d626f719a4ce8a590", "difficulty": 1300, "tags": ["number theory", "greedy", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9991659716430359, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::io;\nuse std::mem::size_of_val;\nuse std::cmp::{max, min};\nuse std::rc::Rc;\nuse std::collections::btree_map::BTreeMap;\nuse std::io::{Write, BufRead};\nuse std::collections::{HashMap, BTreeSet};\nuse std::ptr::write_volatile;\nuse std::process::exit;\nuse std::thread;\n\n#[allow(dead_code)]\nfn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\n#[allow(unused)]\nfn read_strings() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n let mut v = Vec::new();\n for value in string.split_whitespace() {\n v.push(value.to_string());\n }\n v\n}\n\n#[allow(unused)]\nfn read_array_i32() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n string.split_whitespace().map(|x| x.parse::().unwrap()).collect()\n}\n\n\n#[allow(unused_macros)]\nmacro_rules! read_array {\n ( $ty:ty, ... ) => {\n gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap())\n };\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\n// mod math;\n// mod binary_search;\n// mod graph;\n// mod structure;\n// mod fibonacci;\n// mod string;\n// mod permutations;\n// mod patterns;\n\n\n#[allow(dead_code)]\nfn memory_properties(value: &T)\n where\n T: std::fmt::Display + ?Sized,\n{\n println!(\n \"Variable address in memory = {:p}, Allocated bytes for type = {}\",\n value,\n size_of_val(value)\n );\n}\n\n#[allow(unused_macros)]\nmacro_rules! sum {\n ($($x:expr), *) => {\n {\n let mut res = 0;\n $(res += $x;)*\n res\n }\n };\n}\n\nstatic mut array: [[u8;51];51] = [[0u8; 51]; 51];\n\nfn main() {\n use std::io::Write;\n let out = std::io::stdout();\n let mut out = std::io::BufWriter::new(out.lock());\n\n let mut res = 0;\n let s = gets();\n let mut seq = BTreeSet::<&str>::new();\n for i in 0..s.len() - 1 {\n for j in i + 1 .. s.len() + 1 {\n if seq.contains(&s[i..j]){\n res = max(res, j - i);\n } else {\n seq.insert(&s[i..j]);\n }\n }\n }\n writeln!(out, \"{}\", res);\n // writeln!(out, \"{}\", \"Hello Rust\").unwrap();\n}", "lang": "Rust", "bug_code_uid": "71c8d68cf8473f80db27b05fbc101a0d", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "apr_id": "961a8104bc22359429873cbd35214a1d", "difficulty": 1200, "tags": ["brute force", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9738919247115968, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(&mut std::io::stdin(), &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n () => (get().parse::().unwrap());\n ($t:ty) => (get().parse::<$t>().unwrap()); }\n \n let mut field = vec![vec![]; 9];\n for i in 0..9 {\n for _ in 0..3 {\n field[i].push(get().as_bytes());\n }\n }\n let y = (get!(usize) - 1) % 3;\n let x = (get!(usize) - 1) % 3;\n \n let mut c = 0;\n for i in 0..3 {\n for &ch in &field[y*3+i][x][..] {\n if ch == b'.' {\n c += 1;\n }\n }\n }\n if c == 0 {\n for i in 0..9 {\n for j in 0..3 {\n if j > 0 { print!(\" \"); }\n for k in 0..3 {\n let ch = field[i][j][k];\n if ch == b'.' {\n print!(\"!\");\n } else {\n print!(\"{}\", ch as char);\n }\n }\n }\n println!();\n }\n return;\n }\n for i in 0..9 {\n for j in 0..3 {\n if j > 0 { print!(\" \"); }\n for k in 0..3 {\n let ch = field[i][j][k];\n if ch == b'.' && j == x && i / 3 == y {\n print!(\"!\");\n } else {\n print!(\"{}\", ch as char);\n }\n }\n }\n println!();\n }\n}", "lang": "Rust", "bug_code_uid": "080a91f00d09321de6fddc3a11f090eb", "src_uid": "8f0fad22f629332868c39969492264d3", "apr_id": "726b1e274b63ff2f4d836e804c924b09", "difficulty": 1400, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9814432989690721, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_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 p = input.bytes().position(|b| b'0' <= b && b <= b'9').unwrap();\n\n let grid: Vec<_> = input.as_bytes()[0..p].iter().filter_map(|&b| match b {\n b'.' => Some(Cell::Empty),\n b'x' => Some(Cell::Chip1),\n b'o' => Some(Cell::Chip2),\n _ => None,\n }).collect();\n\n let check = |x: usize, y: usize, grid: &Vec| {\n let x_off = 27 * x;\n let y_off = 3 * y;\n let mut it = grid[x_off + y_off..].iter().take(3)\n .chain(grid[x_off + y_off + 9..].iter().take(3))\n .chain(grid[x_off + y_off + 18..].iter().take(3));\n\n !it.all(|cell| match *cell {\n Cell::Empty => false,\n _ => true,\n })\n };\n\n let mut it = input[108..].split_whitespace();\n let x: usize = it.next().unwrap().parse::().unwrap() - 1;\n let y: usize = it.next().unwrap().parse::().unwrap() - 1;\n\n let bx = x % 3;\n let by = y % 3;\n\n let ans: Vec<_> = if !check(bx, by, &grid) {\n grid.into_iter().map(|cell| match cell {\n Cell::Empty => Cell::Possible,\n _ => cell,\n }).collect()\n } else {\n grid.into_iter().enumerate().map(|(i, cell)| {\n let x = i / 9;\n let y = i % 9;\n match cell {\n Cell::Empty if x / 3 == bx && y / 3 == by => Cell::Possible,\n _ => cell,\n }\n }).collect()\n };\n\n let mut ans_str = Vec::with_capacity(108);\n\n for (i, cell) in ans.into_iter().enumerate() {\n let next = match cell {\n Cell::Empty => b'.',\n Cell::Chip1 => b'x',\n Cell::Chip2 => b'o',\n Cell::Possible => b'!',\n };\n\n ans_str.push(next);\n\n if i % 9 == 8 {\n ans_str.push(b'\\n');\n } else if i % 3 == 2 {\n ans_str.push(b' ');\n }\n }\n\n let ans = String::from_utf8(ans_str).unwrap();\n\n print!(\"{}\", ans);\n}\n\n#[derive(Debug)]\nenum Cell {\n Empty,\n Chip1,\n Chip2,\n Possible,\n}\n", "lang": "Rust", "bug_code_uid": "cd9673103a9c6eaf9c58e4f18bb13f5c", "src_uid": "8f0fad22f629332868c39969492264d3", "apr_id": "d166d1771b672fa5508235f97879e832", "difficulty": 1400, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9841924398625429, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 p = input.bytes().position(|b| b'0' <= b && b <= b'9').unwrap();\n\n let grid: Vec<_> = input.as_bytes()[0..p].iter().filter_map(|&b| match b {\n b'.' => Some(Cell::Empty),\n b'x' => Some(Cell::Chip1),\n b'o' => Some(Cell::Chip2),\n _ => None,\n }).collect();\n\n let check = |x: usize, y: usize, grid: &Vec| {\n let x_off = 27 * x;\n let y_off = 3 * y;\n let mut it = grid[x_off + y_off..].iter().take(3)\n .chain(grid[x_off + y_off + 9..].iter().take(3))\n .chain(grid[x_off + y_off + 18..].iter().take(3));\n\n !it.all(|cell| match *cell {\n Cell::Empty => false,\n _ => true,\n })\n };\n\n let mut it = input[p..].split_whitespace();\n let x: usize = it.next().unwrap().parse::().unwrap() - 1;\n let y: usize = it.next().unwrap().parse::().unwrap() - 1;\n\n let bx = x % 3;\n let by = y % 3;\n\n let ans: Vec<_> = if !check(bx, by, &grid) {\n grid.into_iter().map(|cell| match cell {\n Cell::Empty => Cell::Possible,\n _ => cell,\n }).collect()\n } else {\n grid.into_iter().enumerate().map(|(i, cell)| {\n let x = i / 9;\n let y = i % 9;\n match cell {\n Cell::Empty if x / 3 == bx && y / 3 == by => Cell::Possible,\n _ => cell,\n }\n }).collect()\n };\n\n let mut ans_str = Vec::with_capacity(2 * p);\n\n for (i, cell) in ans.into_iter().enumerate() {\n let next = match cell {\n Cell::Empty => b'.',\n Cell::Chip1 => b'x',\n Cell::Chip2 => b'o',\n Cell::Possible => b'!',\n };\n\n ans_str.push(next);\n\n if i % 9 == 8 {\n ans_str.push(b'\\n');\n } else if i % 3 == 2 {\n ans_str.push(b' ');\n }\n }\n\n let ans = String::from_utf8(ans_str).unwrap();\n\n print!(\"{}\", ans);\n}\n\n#[derive(Debug)]\nenum Cell {\n Empty,\n Chip1,\n Chip2,\n Possible,\n}\n", "lang": "Rust", "bug_code_uid": "078c14ce9d05c0cb29e368bd9f26768f", "src_uid": "8f0fad22f629332868c39969492264d3", "apr_id": "d166d1771b672fa5508235f97879e832", "difficulty": 1400, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9098873591989988, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "#[allow(dead_code)]\nfn read() -> T {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n#[allow(dead_code)]\nfn read_vec() -> Vec {\n read::()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n#[allow(dead_code)]\nfn read_vec2(n: u32) -> Vec> {\n (0..n).map(|_| read_vec()).collect()\n}\n#[allow(dead_code)]\nfn yn(result: bool) {\n if result {\n println!(\"Yes\");\n } else {\n println!(\"No\");\n }\n}\n\nfn main() {\n let v = read_vec::();\n let n = v[0];\n let m = v[1];\n let a = v[2];\n\n println!(\"{}\", (n / a + 1) * (m / a + 1));\n}\n", "lang": "Rust", "bug_code_uid": "6af20532ef999e0534f66c0801dbebbc", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "a7cda1f862400cbf101d57de18842bd7", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.15508021390374332, "equal_cnt": 18, "replace_cnt": 16, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 19, "bug_source_code": "use std::io::{self, Read};\n\nfn main() {\n let stdin = io::stdin();\n let mut buf = String::new();\n stdin.read_line(&mut buf).unwrap();\n\n let input = buf.trim();\n let input = input.parse().expect(\"error parsing\");\n\n if can_div_melon(input) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n\nfn can_div_melon(input: u64) -> bool {\n input % 2 == 0\n}\n\n#[cfg(test)]\nmod test {\n use super::*;\n\n #[test]\n fn test_pave() {\n assert_eq!(true, can_div_melon(8));\n }\n}\n", "lang": "Rust", "bug_code_uid": "65641cdd3bc4968441a34cdd976d6c27", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "a12463f15132945dfbfe3c90fae3db65", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9951807228915662, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "\nfn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n let values = line\n .trim_end()\n .split(' ')\n .map(|x| x.parse::().unwrap())\n .collect::>();\n\n let m = values[0];\n let n = values[1];\n let a = values[2];\n\n let rows = (m + (a - 1)) / a;\n let cols = (n + (a - 1)) / a;\n \n println!(\"{}\", rows * cols);\n}\n", "lang": "Rust", "bug_code_uid": "38a941fef55ddba642c7359b82523e16", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "35536cff385f0264b0bf58af95359b14", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.42066420664206644, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let a : i32 = s.trim().parse().unwrap();\n if a > 2 && a % 2 == 0 {\n println!(\"YES\");\n }\n else {\n println!(\"NO\");\n }\n}", "lang": "Rust", "bug_code_uid": "33cbdc88a722e66d8c5e27b7de711344", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "bb484f6d5ac5070a3a27b28b19e41b50", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5586698337292162, "equal_cnt": 18, "replace_cnt": 11, "delete_cnt": 3, "insert_cnt": 3, "fix_ops_cnt": 17, "bug_source_code": "use std::env;\n\nstruct Theatre {\n width : u64,\n height : u64,\n stone_size : u64,\n}\n\nimpl Theatre {\n fn new(w : u64, h : u64, sw : u64) -> Theatre {\n Theatre {width : w, height : h, stone_size : sw}\n }\n\n fn stones(self) -> u64 {\n let kw = (self.width as f64) / (self.stone_size as f64);\n let kh = (self.height as f64) / (self.stone_size as f64);\n\n (kw.ceil() * kh.ceil()) as u64\n } \n\n}\n\nfn get_args() -> Result<(Theatre), i8> {\n\n if env::args().count() != 4 {\n return Err(-1);\n }\n\n let arg = env::args().skip(1);\n let mut tmpa : [u64; 3] = [0; 3];\n\n for (i,a) in arg.enumerate() {\n match a.parse::() {\n Ok(v) => tmpa[i] = v,\n Err(_) => return Err(-1),\n }\n }\n Ok(Theatre::new(tmpa[0], tmpa[1], tmpa[2]))\n}\n\n\nfn main() {\n match get_args() {\n Ok(t) => println!(\"{}\", t.stones()),\n Err(_) => panic!(\"Invalid argument\"),\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "c12fb32c15761d7951e35e087803f7a2", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "1820e2f1b2e2af97b5afd816fb92ddf3", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9851485148514851, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let mut s = buf.split_whitespace();\n let n: u32 = s.next().unwrap().trim().parse().unwrap();\n let m: u32 = s.next().unwrap().trim().parse().unwrap();\n let a: u32 = s.next().unwrap().trim().parse().unwrap();\n let res = ((n + a - 1) / a) * ((m + a - 1) / a);\n println!(\"{}\", res);\n}", "lang": "Rust", "bug_code_uid": "5fe9d5173bd377faa611eee2a24873c1", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "847de7e21b499a02262d24d62d82c48e", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9868421052631579, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "fn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn main() {\n let n: u64;\n let m: u64;\n let a: u64;\n\n { \n let values: Vec = read_str()\n .split_whitespace()\n .map(|value| value.parse::().expect(\"Error\"))\n .collect();\n n = values[0];\n m = values[1];\n a = values[2];\n }\n\n println!(\"{}\", ((n + a - 1) / a) + ((m + a - 1) / a));\n}\n", "lang": "Rust", "bug_code_uid": "aa03e34ea9f1f0527be5a6a1ac016321", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "e12fd327c7bd8419cf6c29e7a062cb58", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6411552346570397, "equal_cnt": 13, "replace_cnt": 11, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 12, "bug_source_code": "use std::env;\n\nfn count_num_flagstones(n : usize, m : usize, a : usize) -> usize {\n let n_div_a = n / a;\n let n_mod_a = n % a;\n let m_div_a = m / a;\n let m_mod_a = m % a;\n let t_1 = if n_mod_a > 0 { n_div_a + 1 } else { n_div_a };\n let t_2 = if m_mod_a > 0 { m_div_a + 1 } else { m_div_a };\n t_1 * t_2\n}\n\nfn main() {\n let args : Vec = env::args().collect();\n let n : usize = args[1].parse().unwrap();\n let m : usize = args[2].parse().unwrap();\n let a : usize = args[3].parse().unwrap();\n let result : usize = count_num_flagstones(n, m, a);\n println!(\"{}\", result);\n}\n", "lang": "Rust", "bug_code_uid": "1f4f515f0d1720740bc9a9a876b46e0c", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "7f4fc48f81bfca47f40c034ad6171519", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.992600422832981, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::Read;\n\nfn input(read_file: bool) -> String {\n if read_file {\n let mut file = std::fs::File::open(\"sample.txt\").unwrap();\n let mut buf = String::new();\n file.read_to_string(&mut buf).unwrap();\n buf\n } else {\n let mut buf = String::new();\n std::io::stdin().read_to_string(&mut buf).unwrap();\n buf.trim_end().to_owned()\n }\n}\n\nfn solve(ws: &mut std::str::SplitWhitespace) {\n let n: i32 = ws.next().unwrap().parse().unwrap();\n let m: i32 = ws.next().unwrap().parse().unwrap();\n let a: i32 = ws.next().unwrap().parse().unwrap();\n\n let round_up = |a: i32, b: i32| (a + b - 1) / b;\n println!(\"{}\", round_up(n, a) * round_up(m, a));\n}\n\nfn main() {\n const READ_FROM_FILE: bool = false;\n\n let s = input(READ_FROM_FILE);\n let mut ws = s.split_whitespace();\n\n // let t = ws.next().unwrap().parse().unwrap();\n // for _ in 0..t {}\n solve(&mut ws);\n}\n", "lang": "Rust", "bug_code_uid": "e7c5a4560e7152fdd15f69291c0cd2eb", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "1f11d4049e009e218b1d8a91a57c6b82", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9900709219858156, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "fn main() {\n let mut input = get_input().trim().to_string();\n let splited_str: Vec<&str> = input.split(' ').collect();\n let n = splited_str[0].parse::().unwrap();\n let m = splited_str[1].parse::().unwrap();\n let a = splited_str[2].parse::().unwrap();\n\n let result = (n / a).ceil() * (m / a).ceil();\n println!(\"{}\", result);\n}\n\nfn get_input() -> String {\n use std::io::{stdin,stdout,Write};\n let mut s=String::new();\n stdout().flush().expect(\"Output Error!\");\n stdin().read_line(&mut s).expect(\"Input Error!\");\n if let Some('\\n')=s.chars().next_back() {\n s.pop();\n }\n if let Some('\\r')=s.chars().next_back() {\n s.pop();\n }\n\n s\n}", "lang": "Rust", "bug_code_uid": "ad43437efd6ffb35b6e51d49ea4c851b", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "356d1c8d94d1ab549abcbcce64e89a31", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9718614718614719, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "fn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\nmacro_rules! scanln {\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\nfn main() -> () {\n\n let (n,m,a) = scanln!(i64, i64, i64);\n let ans = ((n + a - 1) / a) + ((m + a - 1) / a);\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "da0ab23e25d607f6311d50c986d3feeb", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "cb59f189392fe13b90d658723f832b28", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8509021842355176, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "fn readln() -> String {\n let stdin = std::io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).unwrap();\n String::from(line.trim())\n}\n\nmacro_rules! scanln {\n ($($ty: ty),*) => {{\n let line = readln();\n let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$ty>().unwrap()),*)\n }}\n}\n\nfn ceil(a: i32, b: i32) -> i32 {\n (a - 1) / b + 1\n}\n\nfn main() {\n let (n, m, a) = scanln!(i32, i32, i32);\n println!(\"{}\", ceil(n, a) * ceil(m, a));\n}\n", "lang": "Rust", "bug_code_uid": "41ff4dd1dae5af8fd9d5b644ef3dd048", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "7dc46983d21b6fb9209402b8a1558249", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9331756357185098, "equal_cnt": 19, "replace_cnt": 11, "delete_cnt": 1, "insert_cnt": 6, "fix_ops_cnt": 18, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\n// Be careful for n = 10^6. In Codeforces, usize is a 32-bit integer.\nfn sieve(n: i64) -> (Vec, Vec) {\n let mut is_prime = vec![true; (n as usize) + 1];\n let mut primes = Vec::new();\n for i in 2..=n {\n if is_prime[i as usize] {\n primes.push(i);\n let mut j = i * i;\n while j <= n {\n is_prime[j as usize] = false;\n j += i;\n }\n }\n }\n (primes, is_prime)\n}\n\nfn lower_bound(arr: &[i64], target: i64) -> usize {\n let mut lo = 0;\n let mut hi = arr.len();\n while lo < hi {\n let mid = lo + (hi - lo) / 2;\n if arr[mid] >= target {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n lo\n}\n\nfn count_primes(primes: &[i64], lo: i64, hi: i64) -> i64 {\n // How many primes are there in [lo, hi]?\n let lb_1 = lower_bound(primes, lo) as i64;\n let lb_2 = lower_bound(primes, hi + 1) as i64;\n lb_2 - lb_1\n}\n\nfn pred(a: i64, b: i64, k: i64, l: i64, primes: &[i64], is_prime: &[bool]) -> bool {\n // For ALL x in [a, b - l + 1], are there at least k prime numbers in [x, x + l - 1]?\n\n // window: [a, a + l - 1]\n let mut prime_count = count_primes(primes, a, a + l - 1);\n if prime_count < k {\n return false;\n }\n for i in 1..(b - l - a + 2) {\n // x = a + i\n // window: [a + i, a + i + l - 1] = [x, x + l - 1]\n // previous window: [x - 1, x + l - 2]\n // if a + i - 1 was prime, remove it\n if is_prime[(a + i - 1) as usize] {\n prime_count -= 1;\n }\n\n // if a + i + l - 1 is prime, add it\n if is_prime[(a + i + l - 1) as usize] {\n prime_count += 1;\n }\n\n if prime_count < k {\n return false;\n }\n }\n true\n}\n\nfn search_l(a: i64, b: i64, k: i64, primes: &[i64], is_prime: &[bool]) -> i64 {\n let mut lo = 1;\n let mut hi = b - a + 2;\n while lo < hi {\n let mid = lo + (hi - lo) / 2;\n if pred(a, b, k, mid, primes, is_prime) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n if lo == b - a + 2 {\n -1\n } else {\n lo\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: i64 = scan.token();\n let b: i64 = scan.token();\n let k: i64 = scan.token();\n\n let (primes, is_prime) = sieve(1000005);\n let ans = search_l(a, b, k, &primes, &is_prime);\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "d6ffbaf7de0196c3157f12280ad88fbb", "src_uid": "3e1751a2990134f2132d743afe02a10e", "apr_id": "573124214fa5cb80c9e764e7adcf140a", "difficulty": 1600, "tags": ["binary search", "number theory", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9971707010374096, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "use std::io::stdin;\nuse std::collections::HashSet;\n\nfn read_line<'a>() -> Result> {\n let mut line = String::new();\n stdin().read_line(&mut line)?;\n\n Ok(line.trim().to_owned())\n}\n\nfn main() -> Result<(), Box> {\n let line = read_line()?;\n let mut nums = line\n .split(' ')\n .map(|s| s.parse::().unwrap());\n\n let _ = nums.next().unwrap();\n let mut b = nums.next().unwrap();\n\n let line = read_line()?;\n\n let nums = line\n .split(' ')\n .map(|s| s.parse::().unwrap())\n .collect::>();\n\n let evency = nums\n .iter()\n .map(|n| if n % 2 == 0 { 1 } else { -1 })\n .collect::>();\n\n let mut split_points = HashSet::new();\n let mut s = 0;\n\n for (i, e) in evency[..evency.len() - 1].iter().enumerate() {\n s += e;\n\n // println!(\"{}, {}, {}\", i, s, e);\n\n if s == 0 {\n split_points.insert(i);\n }\n }\n\n let mut diffs = nums\n .iter()\n .zip(&nums[1..])\n .map(|(&prev, &curr)| (curr - prev).abs())\n .enumerate()\n .collect::>();\n \n diffs.sort_unstable_by_key(|&(_, diff)| diff);\n\n println!(\"diffs: {:?}\", diffs);\n println!(\"split_points: {:?}\", split_points);\n\n let mut ans = 0;\n\n for (i, diff) in diffs {\n if split_points.contains(&i) && b >= diff {\n println!(\"split at {}, price {}, current budget: {}\", i, diff, b);\n\n ans += 1;\n b -= diff;\n }\n }\n\n\n println!(\"{}\", ans);\n\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "25ee0bf055d6e81c0a0040c4955bece9", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "apr_id": "196799360c8b0c14a88466143a7218f8", "difficulty": 1200, "tags": ["dp", "greedy", "sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9972527472527473, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "/*\n *\n * Author : fcbruce \n *\n * Time : Sat 10 Feb 2018 20:02:28\n *\n */\n\nfn main() {\n\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).unwrap();\n let mut numbers = buffer.split_whitespace();\n let n: u64 = numbers.next().unwrap().parse::().unwrap();\n let k: u64 = numbers.next().unwrap().parse::().unwrap();\n\n let max: usize = 100000;\n\n let mut remainders = vec![false; max];\n\n let mut min = k + 1;\n\n for i in 1..std::cmp::min::(max as u64, k) {\n let r: usize = (n % i) as usize;\n if remainders[r] {\n min = i;\n break;\n }\n remainders[r] = true;\n }\n\n if k == 1 || k < min {\n println!(\"Yes\");\n } else {\n println!(\"No\");\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "21f0ed011352747802b699c218556fc5", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "apr_id": "7760a4060c5c61eaa9fcb74f3b287ea7", "difficulty": 1600, "tags": ["brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.5149518499746579, "equal_cnt": 8, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(\n &mut std::io::stdin(),\n &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n () => (get().parse::().unwrap());\n ($t:ty) => (get().parse::<$t>().unwrap());\n }\n \n let n = get!();\n let k = get!();\n \n if k >= n {\n println!(\"No\");\n return;\n }\n \n if n % k == k - 1 {\n println!(\"Yes\");\n } else {\n println!(\"No\");\n }\n}", "lang": "Rust", "bug_code_uid": "c35d239079ed9c792dc7daf013cfffd8", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "apr_id": "837a1cee223f3d11ccf9e83c526600a4", "difficulty": 1600, "tags": ["brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9837809093326243, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "// https://codeforces.com/contest/1156/problem/A\n//\n#![allow(unused_imports)]\nuse std::io::*;\nuse std::io::Write;\nuse std::fmt::*;\nuse std::str::*;\nuse std::cmp::*;\nuse std::collections::*;\n\n// Input macros.\n// Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\n#[allow(unused_macros)]\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\n#[allow(unused_macros)]\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, [ next / $t:tt ]) => {\n {\n let len = read_value!($iter, usize);\n (0..len).map(|_| read_value!($iter, $t)).collect::>()\n }\n };\n\n ($iter:expr, switch) => {\n {\n let ty = read_value!($iter, i32);\n if ty == 1 {\n vec![ty, read_value!($iter, i32), read_value!($iter, i32)]\n } else if ty == 2 {\n vec![ty, read_value!($iter, i32)]\n } else {\n vec![ty, read_value!($iter, i32)]\n }\n }\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_line {\n ($t:tt) => {\n {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n s.trim_right().parse::<$t>().unwrap()\n }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! dvec {\n ($t:expr ; $len:expr) => {\n vec![$t; $len]\n };\n\n ($t:expr ; $len:expr, $($rest:expr),*) => {\n vec![dvec!($t; $($rest),*); $len]\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! ifv {\n ($t:expr, $a:expr, $b: expr) => {\n if $t { $a } else { $b }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! fill {\n ($t:expr, $v:expr) => {\n for i in 0..$t.len() {\n $t[i] = $v;\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! join {\n ($t:expr, $glue:expr) => {\n $t.into_iter().map(|w| w.to_string()).collect::>().join($glue)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\n// ===\n\nfn main() {\n input! {\n n: usize,\n a: [usize1; n]\n };\n\n let INF = 1000000000i64;\n let table = vec![\n vec![-INF, 3, 4],\n vec![3, -INF, -INF],\n vec![4, -INF, -INF],\n ];\n\n let mut points = 0i64;\n for i in 1..n {\n points += table[a[i-1]][a[i]];\n }\n if points <= -1 {\n println!(\"Infinite\");\n } else {\n println!(\"Finite\");\n println!(\"{}\", points);\n }\n}\n", "lang": "Rust", "bug_code_uid": "35eff46aaa56db966f0f53a53cbad1e1", "src_uid": "6c8f028f655cc77b05ed89a668273702", "apr_id": "90a9d4f65426998645b81c70e3ec18c8", "difficulty": 1400, "tags": ["geometry"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9769057837727365, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_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\n#[allow(unused_imports)]\nuse std::io::Write;\ntype I = usize;\n\nfn main() {\n input!{\n n: usize,\n aa: [usize; n],\n }\n\n let mut ans: u64 = 0;\n for i in 1..n {\n let a1 = aa[i-1];\n let a2 = aa[i];\n let mut a = [a1, a2];\n a.sort();\n\n if a[0] != 1 {\n return println!(\"{}\", \"Infinite\");\n }\n\n if a[1] == 2 {\n ans += 3;\n } else {\n ans += 4;\n }\n }\n println!(\"{}\", \"Finite\");\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "6bead285213701bab1dc52bf6f809076", "src_uid": "6c8f028f655cc77b05ed89a668273702", "apr_id": "7005764578b108b97c646751a30354ee", "difficulty": 1400, "tags": ["geometry"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.948375929131453, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_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:usize = 30;\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(a: &Vec) -> usize {\n let mut left = -1;\n let mut right = a.len() as i64;\n\n while right - left > 1 {\n let mid:usize = ((right+left)/2) as usize;\n //debug!(left,mid,right);\n if is_ok(mid) { right = mid as i64; }\n else { left = mid as i64; }\n }\n right as usize\n}\n\nfn is_ok(key: usize) -> bool {\n true\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\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: usize,\n a: [i64;n]\n }\n\n let mut ans = 0;\n for i in 0..n-1 {\n if (a[i]==1 && a[i+1]==2) || (a[i]==2 && a[i+1]==1) {\n ans += 3;\n }\n else if (a[i]==1 && a[i+1]==3) || (a[i]==3 && a[i+1]==1) {\n ans += 4;\n }\n else {\n puts!(\"Infinite\\n\");\n return;\n }\n }\n puts!(\"Finite\\n\");\n puts!(\"{}\\n\", ans);\n\n}\n\n/*\n\n\n\n*/\n\n\n\n\n\n\n", "lang": "Rust", "bug_code_uid": "57a11eb3a7c43671ea1f34ab43a0e014", "src_uid": "6c8f028f655cc77b05ed89a668273702", "apr_id": "bc9feed884820a58c95f4f86747f7f3f", "difficulty": 1400, "tags": ["geometry"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9927853206839743, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "#![allow(dead_code, unused_imports, unused_macros)]\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 partial_max(v: impl Iterator) -> impl Iterator\nwhere\n T: Default + Ord + Copy,\n{\n v.scan(T::default(), |state, x| {\n *state = max(*state, x);\n Some(*state)\n })\n}\n\nfn partial_min(v: impl Iterator) -> impl Iterator {\n v.scan(std::u64::MAX, |state, x| {\n *state = min(*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\nmacro_rules! max_with {\n ($x: expr, $y: expr) => {\n $x = max($x, $y)\n };\n}\n\nmacro_rules! min_with {\n ($x: expr, $y: expr) => {\n $x = max($x, $y)\n };\n}\n\nfn is_prime(n: u64) -> bool {\n factorize(n).len() == 1\n}\n\nfn combination(n: u64, k: u64, m: u64) -> u64 {\n if n == 0 {\n return 1;\n }\n if k == 0 || k == n {\n return 1;\n }\n let new_k = if n - k < k { n - k } else { k };\n let mut res = 1;\n for i in ((n - new_k) + 1)..=n {\n res *= i;\n res %= m;\n }\n let mut den = 1;\n for i in 1..=(new_k) {\n den *= i;\n den %= m;\n }\n let (_one, inverse, _c) = egcd(den as i64, m as i64);\n let inverse = if inverse < 0 {\n m as i64 + inverse\n } else {\n inverse\n } as u64;\n //println!(\"inv: {} {}\", den, inverse);\n res *= inverse;\n res %= m;\n res\n}\n\nuse std::collections::HashSet;\nuse std::iter::FromIterator;\n\nfn main() -> Result<(), Box> {\n let _n = read_usize();\n let v = read_multiple::();\n let mut points = 0;\n let mut prev = v[0];\n for a in v.into_iter().skip(1) {\n if prev == 1 {\n if a == 2 {\n points += 3\n } else {\n points += 4;\n }\n } else if prev == 2 {\n if a == 1 {\n points += 3\n } else {\n println!(\"Infinite\");\n return Ok(());\n }\n } else {\n //prv == 3\n if a == 1 {\n points += 4\n } else {\n println!(\"Infinite\");\n return Ok(());\n }\n }\n prev = a;\n }\n println!(\"Finite\");\n println!(\"{}\", points);\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "ca619b6b48362253a62706ed47a18b60", "src_uid": "6c8f028f655cc77b05ed89a668273702", "apr_id": "cd6b23c82fedc1b0c6a86f82ffd1e89b", "difficulty": 1400, "tags": ["geometry"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9807714188189782, "equal_cnt": 8, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 7, "fix_ops_cnt": 7, "bug_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::{stderr, stdin, stdout, BufWriter, StdoutLock, Write};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n#[allow(unused_imports)]\nuse std::{i64, u64, usize};\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 ) * } } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ 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 , [ $ t : tt ] ) => { { let len = read_value ! ( $ next , usize ) ; ( 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)]\nstruct Writer {\n s: String,\n}\n#[allow(unused_imports)]\nuse std::fmt::Display;\n#[allow(dead_code)]\n#[doc = \" let mut writer = Writer::new();\"]\n#[doc = \" writer.writeln(hoge);\"]\n#[doc = \" writer.flush()\"]\nimpl Writer {\n #[allow(dead_code)]\n pub fn new() -> Writer {\n Writer { s: String::new() }\n }\n #[allow(dead_code)]\n pub fn flush(&mut self) {\n print!(\"{}\", self.s);\n self.s.clear();\n }\n pub fn write(&mut self, x: T) {\n self.s.push_str(&format!(\"{}\", x));\n }\n pub fn writeln(&mut self, x: T) {\n self.s.push_str(&format!(\"{}\", x));\n self.s.push('\\n');\n }\n #[allow(dead_code)]\n pub fn write_vec(&mut self, xs: &Vec) {\n if xs.len() == 0 {\n self.writeln(\"\");\n return;\n }\n self.write(&format!(\"{}\", xs[0]));\n for i in 1..xs.len() {\n self.write(&format!(\" {}\", xs[i]));\n }\n self.writeln(\"\");\n }\n}\n#[allow(unused_macros)]\nmacro_rules ! dbg { ( $ ( $ a : expr ) ,* ) => { writeln ! ( & mut stderr ( ) , concat ! ( $ ( stringify ! ( $ a ) , \" = {:?}, \" ) ,* ) , $ ( $ a ) ,* ) . unwrap ( ) ; } }\n#[allow(dead_code)]\nconst INF_U: u64 = 1_000_000_000_000_000;\n#[allow(dead_code)]\nconst INF_I: i64 = 1_000_000_000_000_000;\n#[allow(non_snake_case)]\n#[allow(dead_code)]\nfn main() {\n input! {\n n: usize,\n a: [usize; n]\n }\n let mut ans = 0;\n for i in 1..n {\n if a[i-1] == 1 {\n if a[i] == 2 {\n ans += 3;\n } else {\n ans += 4;\n }\n } else if a[i-1] == 2 {\n if a[i] == 1 {\n ans += 3;\n } else {\n println!(\"Infinite\");\n return;\n }\n } else {\n if a[i] == 1 {\n ans += 4;\n } else {\n println!(\"Infinite\");\n return;\n }\n }\n }\n println!(\"Finite\");\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "944c6e5091cd197de2eacd35ccbc6afa", "src_uid": "6c8f028f655cc77b05ed89a668273702", "apr_id": "f61e8e9d4f085f4d5f9ac7fdf8ff5c15", "difficulty": 1400, "tags": ["geometry"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9820913776535337, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "#[doc = \" https://github.com/hatoo/competitive-rust-snippets\"]\n#[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::iter::FromIterator;\n#[macro_export]\nmacro_rules ! chmax { ( $ x : expr , $ ( $ v : expr ) ,+ ) => { $ ( $ x = std :: cmp :: max ( $ x ,$ v ) ; ) + } ; }\n#[macro_export]\nmacro_rules ! chmin { ( $ x : expr , $ ( $ v : expr ) ,+ ) => { $ ( $ x = std :: cmp :: min ( $ x ,$ v ) ; ) + } ; }\n#[macro_export]\nmacro_rules ! max { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ xs : expr ) ,+ ) => { std :: cmp :: max ( $ x , max ! ( $ ( $ xs ) ,+ ) ) } ; }\n#[macro_export]\nmacro_rules ! min { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ xs : expr ) ,+ ) => { std :: cmp :: min ( $ x , min ! ( $ ( $ xs ) ,+ ) ) } ; }\n#[macro_export]\nmacro_rules ! dvec { ( $ t : expr ; $ len : expr ) => { vec ! [ $ t ; $ len ] } ; ( $ t : expr ; $ len : expr , $ ( $ rest : expr ) ,* ) => { vec ! [ dvec ! ( $ t ; $ ( $ rest ) ,* ) ; $ len ] } ; }\n#[doc = \" main\"]\n#[allow(unused_imports)]\nuse std::io::{stdin, stdout, BufWriter, Write};\n#[macro_export]\nmacro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut parser = Parser :: from_str ( $ s ) ; input_inner ! { parser , $ ( $ r ) * } } ; ( parser = $ parser : ident , $ ( $ r : tt ) * ) => { input_inner ! { $ parser , $ ( $ r ) * } } ; ( new_stdin_parser = $ parser : ident , $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let reader = std :: io :: BufReader :: new ( stdin . lock ( ) ) ; let mut $ parser = Parser :: new ( reader ) ; input_inner ! { $ parser , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { input ! { new_stdin_parser = parser , $ ( $ r ) * } } ; }\n#[macro_export]\nmacro_rules ! input_inner { ( $ parser : ident ) => { } ; ( $ parser : ident , ) => { } ; ( $ parser : ident , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ parser , $ t ) ; input_inner ! { $ parser $ ( $ r ) * } } ; }\n#[macro_export]\nmacro_rules ! read_value { ( $ parser : ident , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ parser , $ t ) ) ,* ) } ; ( $ parser : ident , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ parser , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ parser : ident , chars ) => { read_value ! ( $ parser , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ parser : ident , usize1 ) => { read_value ! ( $ parser , usize ) - 1 } ; ( $ parser : ident , $ t : ty ) => { $ parser . next ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\nuse std::io;\nuse std::io::BufRead;\nuse std::str;\npub struct Parser {\n reader: R,\n buf: Vec,\n pos: usize,\n}\nimpl Parser {\n pub fn from_str(s: &str) -> Parser {\n Parser {\n reader: io::empty(),\n buf: s.as_bytes().to_vec(),\n pos: 0,\n }\n }\n}\nimpl Parser {\n pub fn new(reader: R) -> Parser {\n Parser {\n reader: reader,\n buf: vec![],\n pos: 0,\n }\n }\n pub fn update_buf(&mut self) {\n self.buf.clear();\n self.pos = 0;\n loop {\n let (len, complete) = {\n let buf2 = self.reader.fill_buf().unwrap();\n self.buf.extend_from_slice(buf2);\n let len = buf2.len();\n if len == 0 {\n break;\n }\n (len, buf2[len - 1] <= 0x20)\n };\n self.reader.consume(len);\n if complete {\n break;\n }\n }\n }\n pub fn next(&mut self) -> Result {\n loop {\n let mut begin = self.pos;\n while begin < self.buf.len() && (self.buf[begin] <= 0x20) {\n begin += 1;\n }\n let mut end = begin;\n while end < self.buf.len() && (self.buf[end] > 0x20) {\n end += 1;\n }\n if begin != self.buf.len() {\n self.pos = end;\n return str::from_utf8(&self.buf[begin..end]).unwrap().parse::();\n } else {\n self.update_buf();\n }\n }\n }\n}\n#[allow(unused_macros)]\nmacro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , \" = {:?}, \" ) ,* ) , $ ( $ a ) ,* ) ; } }\n#[doc = \" https://github.com/hatoo/competitive-rust-snippets\"]\nconst BIG_STACK_SIZE: bool = true;\n#[allow(dead_code)]\nfn main() {\n use std::thread;\n if BIG_STACK_SIZE {\n thread::Builder::new()\n .stack_size(32 * 1024 * 1024)\n .name(\"solve\".into())\n .spawn(solve)\n .unwrap()\n .join()\n .unwrap();\n } else {\n solve();\n }\n}\nfn solve() {\n let out = stdout();\n let mut out = BufWriter::new(out.lock());\n input!{\n n:usize,\n a:[usize;n]\n }\n let mut tot = 0;\n for i in 1..n {\n let x = i-1;\n let y = i;\n match (a[x],a[y]) {\n (1,2) | (2,1) => {\n if tot != -1 {\n tot += 3\n }\n },\n (2,3) | (3,2) => {\n tot = -1\n },\n (1,3) | (3,1) => {\n if tot != -1 {\n tot += 4\n }\n },\n (_,_) => {\n\n }\n }\n }\n if tot == -1 {\n writeln!(out,\"Infinite\");\n } else {\n writeln!(out,\"Finite\");\n writeln!(out,\"{}\",tot);\n }\n}", "lang": "Rust", "bug_code_uid": "962a92e650004f4d49437c1bb5265e6e", "src_uid": "6c8f028f655cc77b05ed89a668273702", "apr_id": "2e0668a8a96cf82794d289d527a83c22", "difficulty": 1400, "tags": ["geometry"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9637352674524026, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::io::{ BufWriter, stdin, stdout, Write, Stdout };\n \n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nconst DIG: [&'static str; 10] = [\n \"O-|-OOOO\",\n \"O-|O-OOO\",\n \"O-|OO-OO\",\n \"O-|OOO-O\",\n \"O-|OOOO-\",\n \"-O|-OOOO\",\n \"-O|O-OOO\",\n \"-O|OO-OO\",\n \"-O|OOO-O\",\n \"-O|OOOO-\",\n];\n\nfn main() {\n let out = &mut BufWriter::new(stdout());\n let mut n: usize = (Scanner::default()).next();\n let mut nums = vec![];\n while n != 0 {\n nums.push(n % 10);\n n = n/10;\n }\n nums.iter().for_each(|d| {\n writeln!(out, \"{}\", DIG[*d]).ok();\n });\n}\n", "lang": "Rust", "bug_code_uid": "8a686b07f730718cdef866e04d782c70", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "apr_id": "205934ecf3a970e0f1261eb16e27d0f8", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9654218533886584, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::*;\nuse std::str::FromStr;\n\nfn main() {\n let stdin = stdin();\n let mut sc = Scanner::new(stdin.lock());\n let n = sc.next::();\n let s = sc.next::();\n let zeros = s.chars().filter(|&c| c == '0').count() as u32;\n let result = std::iter::repeat(\"0\")\n .take(zeros as usize)\n .collect::();\n println!(\"1{}\", result);\n}\n\npub struct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Self {\n Self {\n reader,\n buffer: Vec::new(),\n }\n }\n\n pub fn next(&mut self) -> T\n where\n T::Err: ::std::fmt::Debug,\n {\n if let Some(front) = self.buffer.pop() {\n front.parse::().expect(&front)\n } else {\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Line not read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n self.next()\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "3134ce9dd68b9cd05a6323fcb25346a4", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "apr_id": "f0aa2bd00dc95760291743f9f649a8f4", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9925705794947994, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn getline() -> String{\n let mut __ret = String::new();\n std::io::stdin().read_line(&mut __ret).ok();\n return __ret;\n}\n\nfn main() {\n let s = getline();\n let inp:Vec<_> = s.trim().split(' ').collect();\n let mut n: i32 = inp[0].parse().unwrap();\n let k: usize = inp[1].parse().unwrap();\n let mut ans = vec![];\n for i in 2..n-1 {\n while n%i == 0 {\n if ans.len() == k-1 {\n break;\n }\n ans.push(i);\n n /= i;\n }\n }\n if ans.len() == k-1 {\n for e in &ans {\n print!(\"{} \",e);\n }\n println!(\"{}\",n);\n }else{\n println!(\"-1\");\n }\n}", "lang": "Rust", "bug_code_uid": "6679642dff5a410afcf828008cb27aa8", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "apr_id": "7ead057b223c49d4880a26685f3c5796", "difficulty": 1100, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9904988123515439, "equal_cnt": 7, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\nuse std::io::prelude::*;\n\nconst PRIMES: [u128; 8] = [2, 3, 5, 7, 11, 13, 17, 19];\nconst WEIGHTS: [u128; 9] = [\n 2 * 7 * 17,\n 2 * 11,\n 2 * 13 * 19,\n 7 * 3,\n 11 * 3 * 19 * 17,\n 3 * 13,\n 5 * 7 * 19,\n 5 * 11,\n 5 * 13 * 17,\n];\n\nfn count_powers_of(x: u128, y: u128) -> u128 {\n let mut x = x;\n let mut n = 0;\n while x != 0 && x % y == 0 {\n n += 1;\n x /= y;\n }\n n\n}\n\nfn ix(c: char) -> usize {\n match c {\n 'X' => 1,\n _ => 0,\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n let lines = stdin.lock().lines();\n let board = lines.map(|r| r.unwrap()).take(3).collect::();\n let mut count = vec![0, 0];\n let mut prod = vec![1u128, 1];\n let mut wins = vec![0, 0];\n for (i, c) in board.chars().enumerate().filter(|p| p.1 != '.') {\n count[ix(c)] += 1;\n prod[ix(c)] *= WEIGHTS[i];\n }\n for i in 0..2 {\n for p in PRIMES.iter() {\n if count_powers_of(prod[i], *p) == 3 {\n wins[i] += 1;\n }\n }\n }\n if count[0] != count[1] && count[0] != count[1] - 1\n || wins[0] > 1\n || wins[1] > 1\n || wins[0] * wins[1] != 0\n || wins[0] == 1 && count[0] != count[1]\n || wins[1] == 1 && count[0] != count[1] - 1\n {\n println!(\"illegal\");\n } else if count[0] == 4 && count[1] == 5 && wins[0] + wins[1] == 0 {\n println!(\"draw\");\n } else if wins[0] == 1 {\n println!(\"the second player won\");\n } else if wins[1] == 1 {\n println!(\"the first player won\");\n } else if count[0] == count[1] {\n println!(\"first\");\n } else {\n println!(\"second\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "8743e8822959f702e3d09f7ee82891de", "src_uid": "892680e26369325fb00d15543a96192c", "apr_id": "b39d86de3c524d1713ecbf918138be6b", "difficulty": 1800, "tags": ["games", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9354422207876049, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 5, "bug_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; $n:expr]) => ((0..$n).map(|_| read!($tt)));\n ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap());\n );\n\n let board = read!([String; 3])\n .map(|x| x.as_bytes().to_vec())\n .collect::>();\n let p1 = b'X';\n let p2 = b'0';\n let p1_count = count(&board, p1);\n let p2_count = count(&board, p2);\n let p1_win = win(&board, p1);\n let p2_win = win(&board, p2);\n if p1_count < p2_count || p1_count > p2_count + 1 || p1_win && p2_win {\n println!(\"illegal\");\n } else if p1_win {\n println!(\"the first player won\");\n } else if p2_win {\n println!(\"the second player won\");\n } else if count(&board, b'.') == 0 {\n println!(\"draw\");\n } else if p1_count == p2_count {\n println!(\"first\");\n } else {\n println!(\"second\");\n }\n}\n\nfn count(board: &Vec>, c: u8) -> usize {\n board\n .iter()\n .map(|xs| xs.iter().filter(|&&x| x == c).count())\n .sum()\n}\n\nfn win(board: &Vec>, c: u8) -> bool {\n (0..3).any(|i| (0..3).all(|j| board[i][j] == c))\n || (0..3).any(|j| (0..3).all(|i| board[i][j] == c))\n || (0..3).all(|i| board[i][i] == c)\n || (0..3).all(|i| board[i][2 - i] == c)\n}\n", "lang": "Rust", "bug_code_uid": "82b3ed6a97aa31aa9573ed67cfa2b49d", "src_uid": "892680e26369325fb00d15543a96192c", "apr_id": "ca63d76e86ccd73b32f2d943f00acc94", "difficulty": 1800, "tags": ["games", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9736842105263158, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn solve() {\n let field = [\n parse_line!(String).bytes().collect::>(),\n parse_line!(String).bytes().collect::>(),\n parse_line!(String).bytes().collect::>(),\n ];\n let mut xs = 0;\n let mut os = 0;\n for i in 0..3 {\n for j in 0..3 {\n if field[i][j] == b'X' {\n xs += 1;\n }\n if field[i][j] == b'0' {\n os += 1;\n }\n }\n }\n let ok = xs == os || xs == os + 1;\n if !ok {\n return println!(\"illegal\");\n }\n let mut xts = false;\n let mut ots = false;\n for i in 0..3 {\n let mut xcol = true;\n let mut xrow = true;\n let mut ocol = true;\n let mut orow = true;\n for j in 0..3 {\n xcol &= field[j][i] == b'X';\n xrow &= field[i][j] == b'X';\n ocol &= field[j][i] == b'0';\n orow &= field[i][j] == b'0';\n }\n xts |= xcol | xrow;\n ots |= ocol | orow;\n }\n let mut xd1 = true;\n let mut xd2 = true;\n let mut od1 = true;\n let mut od2 = true;\n for i in 0..3 {\n xd1 &= field[i][i] == b'X';\n xd2 &= field[i][2 - i] == b'X';\n od1 &= field[i][i] == b'0';\n od2 &= field[i][2 - i] == b'0';\n }\n xts |= xd1 | xd2;\n ots |= od1 | od2;\n if xts && ots {\n return println!(\"illegal\");\n }\n if xts {\n return println!(\"the first player won\");\n }\n if ots {\n return println!(\"the second player won\");\n }\n if xs + os == 9 {\n return println!(\"draw\");\n }\n if xs == os {\n return println!(\"first\");\n }\n println!(\"second\");\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang": "Rust", "bug_code_uid": "27f98f6f54ac11c59ca528d17017b4e0", "src_uid": "892680e26369325fb00d15543a96192c", "apr_id": "c6321d4ffa910357a0a3d3dd6fb5fe88", "difficulty": 1800, "tags": ["games", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.928377153218495, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::io::Stdin;\n\nconst DIMENSION : usize = 3;\nconst NUM_SQUARES : usize = DIMENSION * DIMENSION;\nconst BLANK : u64 = 0;\nconst X : u64 = 1;\nconst O : u64 = 10;\n\nfn read_line(stdin : &Stdin, line : &mut String) {\n match stdin.read_line(line) {\n Ok(_) => return,\n Err(msg) => panic!(\"Could not read line! Message: {}.\", msg),\n }\n}\n\nfn read_board(stdin : &Stdin, board : &mut [[u64; DIMENSION]; DIMENSION]) {\n for i in 0 .. DIMENSION {\n let mut row = String::new();\n read_line(stdin, &mut row);\n let mut j = 0;\n for c in row.trim().chars() {\n if c == '.' {\n board[i][j] = BLANK;\n } else if c == 'X' {\n board[i][j] = X;\n } else if c == '0' {\n board[i][j] = O;\n } else {\n panic!(\"Unknown square on board: {}\", c);\n }\n j = j + 1;\n }\n }\n}\n\nfn has_player_won(board: &[[u64; DIMENSION]; DIMENSION], player : u64) -> bool {\n let three_p = 3 * player;\n let row_0 = (board[0][0] + board[0][1] + board[0][2]) == three_p;\n let row_1 = (board[1][0] + board[1][1] + board[1][2]) == three_p;\n let row_2 = (board[2][0] + board[2][1] + board[2][2]) == three_p;\n let col_0 = (board[0][0] + board[1][0] + board[2][0]) == three_p;\n let col_1 = (board[0][1] + board[1][1] + board[2][1]) == three_p;\n let col_2 = (board[0][2] + board[1][2] + board[2][2]) == three_p;\n let dia_1 = (board[0][0] + board[1][1] + board[2][2]) == three_p;\n let dia_2 = (board[0][2] + board[1][1] + board[2][0]) == three_p;\n row_0 || row_1 || row_2 || col_0 || col_1 || col_2 || dia_1 || dia_2\n}\n\nfn has_first_player_won(board : &[[u64; DIMENSION]; DIMENSION]) -> bool {\n has_player_won(board, X)\n}\n\nfn has_second_player_won(board : &[[u64; DIMENSION]; DIMENSION]) -> bool {\n has_player_won(board, O)\n}\n\nfn print_board_state(board : &[[u64; DIMENSION]; DIMENSION]) {\n let mut num_x : i64 = 0;\n let mut num_o : i64 = 0;\n for i in 0 .. DIMENSION {\n for j in 0 .. DIMENSION {\n if board[i][j] == X {\n num_x = num_x + 1;\n } else if board[i][j] == O {\n num_o = num_o + 1;\n } else {\n // Do nothing ...\n }\n }\n }\n let sum = (num_x + num_o) as usize;\n let diff = num_x - num_o;\n let first_player_won = has_first_player_won(&board);\n let second_player_won = has_second_player_won(&board);\n if diff == 0 {\n if first_player_won {\n println!(\"illegal\");\n } else if second_player_won {\n println!(\"the second player won\");\n } else {\n if sum == NUM_SQUARES {\n println!(\"draw\");\n } else {\n println!(\"first\");\n }\n }\n } else if diff == 1 {\n if second_player_won {\n println!(\"illegal\");\n } else if first_player_won {\n println!(\"the first player won\");\n } else {\n println!(\"second\");\n }\n } else {\n println!(\"illegal\");\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut board = [[BLANK; DIMENSION]; DIMENSION];\n read_board(&stdin, &mut board);\n print_board_state(&board);\n // println!(\"{:?}\", board);\n}\n", "lang": "Rust", "bug_code_uid": "bb0f04e49f05607fa5dc379b8320de3f", "src_uid": "892680e26369325fb00d15543a96192c", "apr_id": "0e4cbdb8db802fd3382996b96a6e66f2", "difficulty": 1800, "tags": ["games", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9784193642461358, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "// use std::collections::BTreeSet;\n// use std::collections::BTreeMap;\n// use std::collections::HashSet;\n// use std::collections::HashMap;\nuse std::convert::TryInto;\nuse std::io::Write;\n\nstruct Scanner {\n reader: R,\n buf_str: Vec,\n buf_iter: std::str::SplitAsciiWhitespace<'static>,\n}\n\nimpl Scanner {\n fn new(reader: R) -> Self {\n Self {\n reader,\n buf_str: Vec::new(),\n buf_iter: \"\".split_ascii_whitespace(),\n }\n }\n fn next(&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 = std::str::from_utf8_unchecked(&self.buf_str);\n std::mem::transmute(slice.split_ascii_whitespace())\n }\n }\n }\n}\n\nenum Answer {\n Illegal,\n First,\n Second,\n FirstWon,\n SecondWon,\n Draw,\n}\n\nfn solve(b: [[u8; 3]; 3]) -> Answer {\n let mut cnt1 = 0;\n let mut cnt2 = 0;\n for i in 0..3 {\n for j in 0..3 {\n if b[i][j] == 'X' as u8 {\n cnt1 += 1;\n } else if b[i][j] == '0' as u8 {\n cnt2 += 1;\n }\n }\n }\n\n if !(cnt1 == cnt2 || cnt1 == cnt2 + 1) {\n return Answer::Illegal;\n }\n\n let win_check = |p: u8| {\n for i in 0..3 {\n if b[i][0] == p && b[i][1] == p && b[i][2] == p {\n return true;\n }\n if b[0][i] == p && b[1][i] == p && b[2][i] == p {\n return true;\n }\n }\n return b[1][1] == p && ((b[0][0] == p && b[2][2] == p) || (b[0][2] == p && b[2][0] == p));\n };\n let first_won = win_check('X' as u8);\n let second_won = win_check('0' as u8);\n if first_won && second_won {\n return Answer::Illegal;\n }\n if first_won {\n return Answer::FirstWon;\n }\n if second_won {\n return Answer::SecondWon;\n }\n\n let mut is_finished = true;\n for i in 0..3 {\n for j in 0..3 {\n if b[i][j] == '.' as u8 {\n is_finished = false;\n }\n }\n }\n\n if is_finished {\n return Answer::Draw;\n }\n\n if cnt1 == cnt2 {\n Answer::First\n } else {\n Answer::Second\n }\n}\n\nfn main() -> Result<(), Box> {\n let (stdin, stdout) = (std::io::stdin(), std::io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = std::io::BufWriter::new(stdout.lock());\n\n let mut a: Vec = vec![];\n a.push(scan.next());\n a.push(scan.next());\n a.push(scan.next());\n\n let mut b: [[u8; 3]; 3] = [[0; 3]; 3];\n for i in 0..3 {\n b[i] = a[i].as_bytes().try_into().unwrap();\n }\n\n writeln!(\n out,\n \"{}\",\n match solve(b) {\n Answer::Illegal => \"illegal\",\n Answer::First => \"first\",\n Answer::Second => \"second\",\n Answer::FirstWon => \"the first player won\",\n Answer::SecondWon => \"the second player won\",\n Answer::Draw => \"draw\",\n }\n )?;\n\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "4550c2f304cbee16f7f532d112a36135", "src_uid": "892680e26369325fb00d15543a96192c", "apr_id": "f5390fc558cb0debe3802ef8728861c1", "difficulty": 1800, "tags": ["games", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.5455668829162805, "equal_cnt": 9, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let mut r: u64 = scan.next();\n let mut g: u64 = scan.next();\n let mut b: u64 = scan.next();\n let mut result = r.min(g).min(b);\n r -= result;\n g -= result;\n b -= result;\n result += r / 3 + g / 3 + b / 3;\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "2112114844c970350b57a4a953d927c9", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "apr_id": "cef39e9a35e0ef2a0ef73d406484fd0c", "difficulty": 1600, "tags": ["math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9757785467128027, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{self, Write};\nuse std::vec::Vec;\nuse std::string::String;\n\nfn get_input() -> String {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"Failed\");\n return buffer.trim().to_string();\n}\n\nfn main() {\n let input: String = get_input();\n let numbers: Vec = input.split_whitespace().map(\n |n| n.parse().unwrap()\n ).collect();\n\n let mut result: i8 = 1;\n for i in 0..(numbers.len()) {\n result *= numbers[i];\n }\n result >>= 1;\n print!(\"{}\", result);\n io::stdout().flush().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "deeb2a13e408e15f2fd23eab74a9b0fe", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "12a3815a7cd4e656daf5378ad02b0fc3", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9982332155477032, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn readline() -> Vec{\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).unwrap();\n buffer.split_whitespace().map(|x| x.parse::().unwrap()).collect()\n}\n\nfn main() {\n let input = readline();\n println!(\"{:?}\", input);\n let rowcount = input[0];\n let columncount = input[1];\n let mut dominoarray = vec![vec![0; columncount]; rowcount];\n\n let mut numberofpossibilities = 0;\n for col in 0..columncount{\n for row in 0..rowcount{\n if dominoarray[row][col] == 0 && col + 1 < columncount && dominoarray[row][col+1] == 0 {\n dominoarray[row][col] = 1;\n dominoarray[row][col+1] = 1;\n numberofpossibilities = numberofpossibilities + 1;\n } else if dominoarray[row][col] == 0 && row + 1 < rowcount && dominoarray[row+1][col] == 0 {\n dominoarray[row][col] = 1;\n dominoarray[row+1][col] = 1;\n numberofpossibilities = numberofpossibilities + 1;\n }\n }\n }\n println!(\"{:?}\", dominoarray);\n println!(\"{}\", numberofpossibilities);\n}", "lang": "Rust", "bug_code_uid": "a75cd8c9acdcce11c104f76567224b99", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "f1e8300fde4cf25822a928d680788be8", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.98005698005698, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n let (m, n) = {\n let split: Vec = input\n .split_whitespace()\n .take(2)\n .map(|num| num.parse().unwrap())\n .collect();\n (split[0], split[1])\n };\n println!(\"{}\", m * n / 2);\n}", "lang": "Rust", "bug_code_uid": "cbe565a9035e79edcdc17072c5b92a7a", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "e778c98eb6ffff86e20393c02b7e8ef5", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9557458957887224, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nuse std::io::{Read, Write};\n\nfn solve(input: &mut Read, output: &mut Write) {\n let mut sin = String::new();\n input.read_to_string(&mut sin).unwrap();\n let mut s = sin.lines();\n let l1 = s.next().unwrap().trim().split(' ').map(|x| x.parse().unwrap()).collect::>();\n\n let mut m = l1[0];\n let mut n = l1[1];\n\n let mut res = 0;\n while m > 1 && n > 1 {\n res += m + n - 2;\n m -= 2;\n n -= 2;\n }\n if m > 0 && n > 0 {\n res += std::cmp::min(m, n) / 2;\n }\n\n output.write(res.to_string().trim().as_bytes()).unwrap();\n}\n\nfn main() {\n solve(&mut io::stdin(), &mut io::stdout());\n}\n\n#[cfg(test)]\nmod tests {\n use std::fs::File;\n use std::io::Read;\n use solve;\n\n #[test]\n fn test() {\n (1..2 + 1).map(|x| {\n println!(\"test #{}\", x);\n let mut fin = File::open(\"./src/in\".to_string() + &x.to_string() + \".txt\").unwrap();\n let mut buf: Vec = Vec::new();\n solve(&mut fin, &mut buf);\n let res = String::from_utf8(buf).unwrap();\n\n let mut fout = File::open(\"./src/out\".to_string() + &x.to_string() + \".txt\").unwrap();\n let mut sout = String::new();\n fout.read_to_string(&mut sout).unwrap();\n assert_eq!(res, sout.trim());\n\n }).count();\n\n }\n}", "lang": "Rust", "bug_code_uid": "8b128a694011eee91ef6dc52ebc3056d", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "a28e70ac2d2f5c8e80e8f17e8d3ce116", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8838495575221239, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "use std::io::*;\n\nfn reads(i: &mut StdinLock) -> Vec {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let inputs: Vec = reads(sin);\n let m = inputs[0];\n let n = inputs[1];\n\n let case1 = (m / 2.).floor() as u64 * n as u64;\n let case2 = (n / 2.).floor() as u64 * m as u64;\n let mut other = 0;\n\n let ans = if case1 < case2 {\n other = m as u64;\n case2\n } else {\n other = n as u64;\n case1\n };\n\n if m as u64 % 2 == 0 && n as u64 % 2 == 0 {\n println!(\"{}\", ans);\n return;\n }\n\n let remain = (other as f64 / 2.).floor() as u64;\n\n println!(\"{}\", ans + remain);\n}\n", "lang": "Rust", "bug_code_uid": "de8617ba279d3d5fea78699f44559423", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "7000689a67b603f120f78875807b045b", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9808823529411764, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\n\nfn read() -> String{\n let mut inp=String::new();\n io::stdin().read_line(&mut inp).expect(\"failed to read from stdin\");\n inp\n}\n\nfn main() {\n let inp=read().trim().parse::().unwrap();\n let list: Vec<&str>=inp.split_whitespace().collect();\n let first=&list[0].parse::().unwrap();\n let second=&list[1].parse::().unwrap();\n println!(\"{}\",first/2*second + second%2*first/2);\n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//fn input1() {\n// let mut x = String::new();\n// io::stdin().read_line(&mut x).expect(\"Error reading input\");\n// let x: f32 = x.trim().parse().expect(\"Error parsing number\");\n// println!(\"{}\",x)\n//}", "lang": "Rust", "bug_code_uid": "0bff28648f1247b59b49202987ec51dd", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "4d4b28f283df972fb8b42bebc5a426b4", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9532710280373832, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "fn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_vec() -> Vec {\n read_str()\n .split_whitespace()\n .map(|value| value.parse::().expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n let m: u8; \n let n: u8;\n {\n let mn: Vec = read_vec();\n m = mn[0];\n n = mn[1];\n }\n println!(\"{}\", (m * n) / 2);\n}", "lang": "Rust", "bug_code_uid": "2f9e8c89303854568bfcaac0b5e440c1", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "02018054be05882bd3b141a64b50cfde", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9903155263980006, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "use std::cmp::{max, min};\nuse std::io::{Read, Write, stdin, stdout};\n\npub struct Scanner {\n pub buffer: Vec,\n pub reader: U,\n}\nimpl Scanner {\n pub fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_to_string(&mut input).expect(\"Failed read\");\n self.buffer = input.lines().rev().map(String::from).collect();\n }\n }\n\n pub fn new(reader: U) -> Self {\n return Scanner {\n buffer: vec![],\n reader,\n };\n }\n}\n\n// the maxium ways to cover a mxn rectangle using 1x2 bricks\npub fn get_cover_num(m: usize, n: usize) -> usize {\n let smaller = min(m, n);\n let bigger = max(m, n);\n if smaller == 0 {\n return 0;\n } else if smaller == 1 {\n return bigger / 2;\n } else if smaller == 2 {\n return bigger;\n }\n let q = smaller / 2;\n return q * bigger + bigger / 2;\n}\npub fn solution_of_p50a(input: &mut Read, out: &mut Write) {\n let mut scanner = Scanner::new(input);\n let arr: Vec = scanner\n .next::()\n .split(' ')\n .map(|e| {\n return e.parse::().unwrap();\n })\n .collect();\n let m = arr[0];\n let n = arr[1];\n\n let res = get_cover_num(m, n);\n writeln!(out, \"{}\\n\", res).ok();\n}\n\nfn main() {\n solution_of_p50a(&mut stdin(), &mut stdout());\n}\n", "lang": "Rust", "bug_code_uid": "bab0a3bfbca9bb629fe874dd98369365", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "c4971e026dd7d21bb0a97e299c3d60e6", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8836772983114447, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "#![allow(unused)]\n\nuse std::io::{self, prelude::*};\n\nfn main() {\n let mut lines = io::BufReader::new(io::stdin()).lines();\n\n let mut line = lines.next().unwrap().unwrap();\n let mut iter = line.split(' ');\n let m: u8 = iter.next().unwrap().parse().unwrap();\n let n: u8 = iter.next().unwrap().parse().unwrap();\n\n if m % 2 == 0 {\n let x = m / 2;\n println!(\"{}\", x * n);\n } else {\n let x = n / 2;\n println!(\"{}\", x * m);\n }\n}\n", "lang": "Rust", "bug_code_uid": "2074f089cd457f633a041b6c656d71d1", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "36771b36b11f9ac2ac60c9e7157f88aa", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9994648590795576, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "#![allow(unused_macros, unused_variables, dead_code, clippy::many_single_char_names)]\nuse std::io::{stdin, stdout, StdinLock, StdoutLock, BufWriter, prelude::*};\n\nmacro_rules! read {\n ($s: ident) => {\n {\n $s.read()\n }\n };\n ($s: ident, $t: ty) => {\n {\n let mut v: $t = 0;\n let num = $s.read();\n let l = num.len();\n \n if num[0] == b'-' {\n for d in &num[1..l] {\n v = v*10 - (*d as $t) + (b'0' as $t);\n }\n } else {\n for d in &num[..l] {\n v = v*10 + (*d as $t) - (b'0' as $t);\n }\n }\n v\n }\n }\n}\n\nmacro_rules! to_str {\n ($v: expr) => {\n {\n let mut s = String::new();\n for x in $v {\n s.push(*x as char);\n }\n s\n }\n };\n ($v: expr, $l: expr) => {\n {\n let mut s = String::with_capacity($l);\n for x in $v {\n s.push(*x as char);\n }\n s\n }\n }\n}\n\nmacro_rules! read_vec {\n ($s: ident, $l: expr) => {\n {\n let mut v = Vec::with_capacity($l);\n for _ in 0..$l {\n v.push(to_str!(read!($s)));\n }\n v\n }\n };\n ($s: ident, $t: ty, $l: expr) => { // for ints\n {\n let mut v = Vec::with_capacity($l);\n for _ in 0..$l {\n v.push(read!($s, $t));\n }\n v\n }\n };\n}\n\nmacro_rules! void {\n ($s: ident, $l: expr) => {\n if $l > 0 {\n let mut n = 0;\n let mut first = true;\n\n while n < $l {\n if $s.pos != 0 {\n $s.stdin.consume($s.pos);\n }\n\n let buf = $s.stdin.fill_buf().unwrap();\n\n let mut resume = true;\n\n for (i, x) in buf.iter().enumerate() {\n if x == &b' ' || x == &b'\\n' {\n if i == 0 && first {\n continue;\n }\n\n n += 1;\n\n if n == $l {\n $s.pos = i+1;\n resume = false;\n break;\n }\n }\n }\n\n if resume {\n $s.pos = buf.len();\n first = false;\n }\n }\n }\n };\n}\n\nmacro_rules! pipe {\n ($s: ident, $t: ty, $($x: ident),*) => {\n $(\n $x = read!($s, $t);\n )*\n };\n ($s: ident, $( ($x: ident, $t: ty) ),*) => {\n $(\n $x = read!($s, $t);\n )*\n };\n ($s: ident, $($x: ident),*) => {\n $(\n $x = read!($s);\n )*\n };\n}\n\nstruct Reader<'a> {\n stdin: StdinLock<'a>,\n pos: usize,\n v_temp: Vec\n}\n\nimpl<'a> Reader<'a> {\n fn new(stdin: StdinLock<'a>)/*'*/ -> Self {\n Reader {stdin, pos: 0, v_temp: vec![]}\n }\n \n fn read(&mut self) -> &[u8] {\n if self.pos != 0 {\n self.stdin.consume(self.pos);\n }\n let mut s = 0;\n let mut i = 0;\n \n let buf = self.stdin.fill_buf().unwrap();\n \n loop {\n if unsafe {buf.get_unchecked(i)} < &33 {\n if i > buf.len() {\n let b_len = buf.len();\n let mut idx_char = 0;\n \n loop {\n if unsafe {buf.get_unchecked(idx_char)} > &33 || idx_char == b_len {\n break;\n }\n idx_char += 1;\n }\n let mut v1;\n if b_len != idx_char {\n v1 = vec![0; b_len-idx_char];\n v1[..].copy_from_slice(&buf[idx_char..]);\n } else {\n v1 = vec![];\n }\n\n let new_buf = {\n self.stdin.consume(b_len);\n let buf = self.stdin.fill_buf().unwrap();\n let mut i = 0;\n\n loop {\n if unsafe {buf.get_unchecked(i)} < &33 {\n break if i == 0 {\n &[]\n } else {\n &buf[..=i]\n }\n }\n i += 1;\n }\n };\n if !new_buf.is_empty() {\n self.pos = new_buf.len();\n v1.extend(new_buf.iter());\n } else {\n self.pos = 0;\n }\n\n self.v_temp = v1;\n\n return &self.v_temp[..];\n } else if s == i {\n s += 1;\n } else {\n break;\n }\n }\n i += 1;\n }\n self.pos = i+1;\n\n if s == i {\n self.read()\n } else {\n &self.stdin.fill_buf().unwrap()[s..i]\n }\n }\n}\n\nfn main() {\n let stdin = stdin();\n let stdout = stdout();\n solve(&mut Reader::new(stdin.lock()), &mut BufWriter::new(stdout.lock()));\n}\n\nfn solve(r: &mut Reader, w: &mut BufWriter) {\n writeln!(w, \"{}\", (read!(r, u8)*read!(r, u8))>>1);\n}", "lang": "Rust", "bug_code_uid": "ef58dc1d9d7a126a1144d61b82e3b36d", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "1877efb9b2533be1692d1fca3141646a", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8626053143227479, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "fn sieve_of_eratosthene(n: usize) -> Vec {\n let mut is_prime = vec![true; std::cmp::max(n, 2)];\n\n is_prime[0] = false;\n is_prime[1] = false;\n \n\n let mut i = 2;\n loop {\n while i < n && !is_prime[i] {\n i += 1;\n }\n\n let cur_prime = i;\n\n let mut q = 2;\n while q * cur_prime < n {\n is_prime[q * cur_prime] = false;\n q += 1;\n }\n\n i += 1;\n if i >= n {\n return is_prime;\n }\n }\n}\n\nfn primes(is_prime: &Vec) -> Vec {\n let mut primes = Vec::new();\n for i in 0..is_prime.len() {\n if is_prime[i] {\n primes.push(i);\n }\n }\n \n primes\n}\n\nfn is_number_good(prime: &Vec, n: usize) -> bool {\n let mut firstmultiplier = 0;\n\n for i in 0..prime.len() {\n if n % prime[i] == 0 {\n firstmultiplier = prime[i];\n }\n }\n\n for i in 0..prime.len() {\n if n % prime[i] == 0 && prime[i] != firstmultiplier {\n return true;\n }\n }\n\n false\n}\n\nfn main() {\n let mut str = String::new();\n\n std::io::stdin().read_line(&mut str).unwrap();\n\n let n = str.trim().parse::().unwrap();\n\n let is_prime = sieve_of_eratosthene(n);\n\n let mut c = 0;\n for i in 2..=n {\n if is_number_good(&primes(&is_prime), i) {\n c += 1;\n }\n }\n\n println!(\"{}\", c);\n}\n\n", "lang": "Rust", "bug_code_uid": "cec2449975d9bc2e2fb96708f5173acf", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "apr_id": "4602cc98944462e6b12f4936e2a60d0a", "difficulty": 900, "tags": ["number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9908536585365854, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "//spnauti-rust\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::*;\n#[allow(unused_imports)] use std::collections::*;\n\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\n#[allow(dead_code)]\nfn build_counting_hashmap(i: T) -> HashMap\n where T: Iterator {\n let mut m = HashMap::new();\n for k in i {\n let n = 1 + if let Some(&n) = m.get(&k) { n } else { 0 };\n m.insert(k, n);\n }\n m\n}\n\nfn gcd(a: i32, b: i32) -> i32 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let a = input.i();\n let b = input.i();\n let c = input.i();\n println!(\"{}\", c / gcd(a,b));\n}\n\n", "lang": "Rust", "bug_code_uid": "ab2e8eb0e5666b786bfc1cc2dc78e6ac", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "apr_id": "09890fda2c75ed4d8b1a028f163ab63f", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.987794245858762, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 4, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min,Ordering};\n#[allow(unused_imports)]\nuse std::collections::{HashMap,HashSet,VecDeque};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let (n,m,z) = readln!(i32,i32,i32);\n let mut res = 0;\n for i in 1..((z+n+n-1)/n) {\n if (i*n)%m == 0 {\n res += 1;\n }\n }\n println!(\"{}\",res);\n}\n", "lang": "Rust", "bug_code_uid": "4ee390b3bf6557c388f96bf4331199b8", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "apr_id": "4d2dde13e9cbf49951f1255960717f46", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9972640218878249, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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 = cnt + k - kk - 1;\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": "Rust", "bug_code_uid": "fdb732f9465fed20256af71070145080", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "apr_id": "77c0d9bce4ba0a62733c89782ee7cb1d", "difficulty": 1100, "tags": ["brute force", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.4067022086824067, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 5, "bug_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 let mut it = input.split_whitespace();\n\n let n: u64 = it.next().unwrap().parse().unwrap();\n\n let mut max_nine_count = 0;\n let mut k = 2 * n;\n while k >= 10 {\n max_nine_count += 1;\n k /= 10;\n }\n\n let mut ans = 0;\n\n for mut i in 1..k + 1 {\n for _ in 0..max_nine_count {\n i *= 10;\n }\n let j = i / 2;\n let p = std::cmp::min(i - 2, n) - j + 1;\n ans += p;\n }\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "2296010995e9e20e641d3d28c8393448", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "apr_id": "7e6b632fc8d44a4e87f31786a67aecb9", "difficulty": 1800, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7984258854394403, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "#![allow(unused_imports)]\nuse std::io;\nuse std::cmp::*;\nuse std::collections::*;\n#[allow(dead_code)]\nconst M: i64 = 1e9 as i64 + 7;\n\nfn read_line() -> String {\n let stdin = io::stdin();\n let mut buf = String::new();\n stdin.read_line(&mut buf).unwrap();\n buf\n}\n#[allow(dead_code)]\nfn read() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {\n read_line().trim().parse().unwrap()\n}\n#[allow(dead_code)]\nfn readv() -> Vec where T: std::str::FromStr, T::Err : std::fmt::Debug {\n read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()\n}\n\nfn main() {\n let input = readv::();\n let (n, s) = (input[0], input[1]);\n let mut num = n;\n let mut diff = n;\n for i in 0..19 {\n diff -= num / 10i64.pow(i) % 10;\n }\n if diff < s {\n println!(\"{}\", 0);\n return;\n }\n for i in (1..19).rev() {\n let p = 10i64.pow(i);\n while diff - (p - 1) >= s {\n diff -= p - 1;\n num -= p;\n }\n }\n num = num / 10 * 10;\n #[cfg(local)] println!(\"{}: {:?}\", \"(num, diff)\", (num, diff));\n println!(\"{}\", n - num + 1);\n}\n", "lang": "Rust", "bug_code_uid": "7cec2dd3d8880a52c9f1c8be84b7f037", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "apr_id": "d00b69e7d9e3b62d78721cc06dbebc55", "difficulty": 1600, "tags": ["dp", "math", "brute force", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9347929557353641, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "/**\n * https://codeforces.com/contest/1154/problem/B\n */\nmacro_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 mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\npub fn main() {\n let _ = parse_line!(i32);\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"n not esist\");\n let mut nums: Vec = buffer.split_whitespace().map(|x| x.parse().expect(\"error\")).collect();\n nums.sort();\n nums.dedup();\n let res = match nums.len() {\n 1 => 0,\n 2 => nums[1] - nums[0],\n 3 => {\n if nums[2] - nums[1] == nums[1] - nums[0] {\n nums[2] - nums[1]\n } else {\n -1\n }\n }\n _ => -1,\n };\n println!(\"{}\", res);\n}", "lang": "Rust", "bug_code_uid": "f5c954076d8772dec7cab59263bce196", "src_uid": "d486a88939c132848a7efdf257b9b066", "apr_id": "8bb6915389c00ddfc2e97b6948231c24", "difficulty": 1200, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9982190560997328, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::cmp;\n\n\nfn main() {\n let _ = read_one::();\n let mut an = read::();\n an.sort();\n an.dedup();\n\n if an.len() > 3 { println!(\"-1\"); return; }\n if an.len() == 1 { println!(\"{}\", an[0]); return; }\n if an.len() == 2 {\n if (an[1] - an[0]) % 2 == 0 {\n println!(\"{}\", cmp::min((an[1] - an[0]) / 2, an[1] - an[0]));\n } else {\n println!(\"{}\", an[1] - an[0]);\n }\n return;\n }\n if an.len() == 3 {\n if an[2] - an[1] == an[1] - an[0] {\n println!(\"{}\", an[1] - an[0]);\n } else {\n println!(\"-1\");\n }\n }\n}\n\n\n#[allow(dead_code)]\nfn read() -> Vec\nwhere T:\nstd::str::FromStr,\nT::Err: std::fmt::Debug {\n\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.split_whitespace()\n .map(|s| s.trim().parse().unwrap())\n .collect()\n}\n\n#[allow(dead_code)]\nfn read_one() -> T\nwhere T:\nstd::str::FromStr,\nT::Err: std::fmt::Debug {\n\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n}", "lang": "Rust", "bug_code_uid": "4185b85dd42602366751cc1c38ccfb3c", "src_uid": "d486a88939c132848a7efdf257b9b066", "apr_id": "a6cf15555811ac0c5cf13ed28927a19f", "difficulty": 1200, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9807531380753138, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(dead_code)]\n#![allow(unused_labels)]\n\nuse std::char::*;\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse std::str::FromStr;\n\nmacro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);}}\nmacro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }\nmacro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }\nmacro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\n\n\nfn read() -> T {\n let stdin = stdin();\n let stdin = stdin.lock();\n let token: String = stdin\n .bytes()\n .map(|c| c.expect(\"failed to read char\") as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect();\n token.parse().ok().expect(\"failed to parse token\")\n}\n\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:usize = 30;\nconst INF:i64 = std::i64::MAX;\nconst MOD:i64 = 1e9 as i64 + 7;\n\n\nfn main() {\n //let t:usize = read();\n\n //'outer: for _ in 0..t {\n let n:usize = read();\n let a:Vec = (0..n).map(|_| read()).collect();\n\n let mut ans = 10000;\n for e in -1000..1000 {\n let d = (a[0]-e).abs();\n let mut f = true;\n for i in 1..n {\n if (a[i]-e).abs() == 0 { continue; }\n if d != (a[i]-e).abs() {\n f = false;\n }\n }\n if f {\n ans = min(ans, d);\n }\n }\n println!(\"{}\", if ans==10000 {-1} else {ans});\n //}\n}\n\n/*\n\n\n*/\n", "lang": "Rust", "bug_code_uid": "59faa973e131facef8fb9d0388a5a25c", "src_uid": "d486a88939c132848a7efdf257b9b066", "apr_id": "4f6e417d24791f2260f067d55de688ee", "difficulty": 1200, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9998913515862669, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "#![allow(dead_code, unused_imports, unused_macros)]\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 partial_max(v: impl Iterator) -> impl Iterator\nwhere\n T: Default + Ord + Copy,\n{\n v.scan(T::default(), |state, x| {\n *state = max(*state, x);\n Some(*state)\n })\n}\n\nfn partial_min(v: impl Iterator) -> impl Iterator {\n v.scan(std::u64::MAX, |state, x| {\n *state = min(*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\nmacro_rules! max_with {\n ($x: expr, $y: expr) => {\n $x = max($x, $y)\n };\n}\n\nmacro_rules! min_with {\n ($x: expr, $y: expr) => {\n $x = max($x, $y)\n };\n}\n\nfn is_prime(n: u64) -> bool {\n factorize(n).len() == 1\n}\n\nfn combination(n: u64, k: u64, m: u64) -> u64 {\n if n == 0 {\n return 1;\n }\n if k == 0 || k == n {\n return 1;\n }\n let new_k = if n - k < k { n - k } else { k };\n let mut res = 1;\n for i in ((n - new_k) + 1)..=n {\n res *= i;\n res %= m;\n }\n let mut den = 1;\n for i in 1..=(new_k) {\n den *= i;\n den %= m;\n }\n let (_one, inverse, _c) = egcd(den as i64, m as i64);\n let inverse = if inverse < 0 {\n m as i64 + inverse\n } else {\n inverse\n } as u64;\n //println!(\"inv: {} {}\", den, inverse);\n res *= inverse;\n res %= m;\n res\n}\n\nuse std::collections::HashSet;\nuse std::iter::FromIterator;\n\nfn n_to_vec(n: u64, l: usize) -> Vec {\n let mut res = vec![0; l];\n let mut n = n;\n for i in (0..l).rev() {\n if n % 2 == 1 {\n res[i] = 1;\n }\n n /= 2;\n }\n res\n}\n\nfn vec_to_n(v: Vec) -> u64 {\n let mut res = 0;\n for i in 0..v.len() {\n res *= 2;\n if v[i] == 1 {\n res += 1;\n }\n }\n res\n}\n\nfn main() -> Result<(), Box> {\n let _n = read_usize();\n let a_vec = read_multiple::();\n let mut v = Vec::new();\n let mut flag = false;\n 'f: for a in a_vec {\n if !v.contains(&a) {\n v.push(a)\n }\n if v.len() > 3 {\n flag = true;\n break 'f;\n }\n }\n if flag {\n println!(\"-1\")\n } else {\n v.sort_unstable();\n if v.len() == 1 {\n println!(\"0\")\n } else if v.len() == 2 {\n if (v[1] - v[0] % 2) == 0 {\n println!(\"{}\", (v[1] - v[0]) / 2)\n } else {\n println!(\"{}\", v[1] - v[0])\n }\n } else {\n //v.len() == 3\n if v[2] - v[1] != v[1] - v[0] {\n println!(\"-1\")\n } else {\n println!(\"{}\", v[2] - v[1])\n }\n }\n }\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "cca0e393f222b960786b93656860a9df", "src_uid": "d486a88939c132848a7efdf257b9b066", "apr_id": "faae50caacd6e79e7ac4fedbcb9355cb", "difficulty": 1200, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9995217599234816, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_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::prelude::BufRead;\n#[allow(unused_imports)]\nuse std::io::{stdin, stdout, BufReader, BufWriter, Write};\n#[allow(unused_imports)]\nuse std::mem::swap;\n#[allow(unused_imports)]\nuse std::str::FromStr;\n\nfn main() {\n\tlet _n = read::();\n\tlet arr = read_vector::();\n\tfor i in 1..101 {\n\t\tfor &x in [arr[0], arr[0] + i, arr[0] - i].iter() {\n\t\t\tlet mut possible = true;\n\t\t\tfor &val in arr.iter() {\n\t\t\t\tif val != x && val + i != x && val - i != x {\n\t\t\t\t\tpossible = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif possible {\n\t\t\t\tprintln!(\"{}\", i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tprintln!(\"{}\", -1);\n}\n\n#[allow(dead_code)]\nfn read() -> T\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n let mut buf = String::new();\n stdin().read_line(&mut buf).unwrap();\n return buf.trim().parse().unwrap();\n}\n\n#[allow(dead_code)]\nfn read_vector() -> Vec\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n let mut buf = String::with_capacity(100);\n stdin().read_line(&mut buf).unwrap();\n return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();\n}\n\n#[allow(dead_code)]\nfn read_matrix() -> Vec>\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n use std::io::prelude::*;\n let stdin = stdin();\n let mut reader = BufReader::with_capacity(100 * 1024, stdin);\n let mut line = String::with_capacity(100);\n let mut matrix: Vec> = Vec::new();\n\n while reader.read_line(&mut line).unwrap() > 0 {\n matrix.push(\n line.trim()\n .split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect(),\n );\n line.clear();\n }\n\n return matrix;\n}\n\n#[allow(dead_code)]\nfn read_chars() -> Vec {\n let stdin = stdin();\n let mut buf = String::new();\n let _bytes = stdin.read_line(&mut buf).unwrap();\n return buf.trim().chars().collect();\n}\n", "lang": "Rust", "bug_code_uid": "f11c9be1d22a0d29abe4bd95a4fd89fa", "src_uid": "d486a88939c132848a7efdf257b9b066", "apr_id": "1c08baf0f8e3fa457d8f98c5e09cd24e", "difficulty": 1200, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9902083856389656, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{min,max};\nuse std::collections::HashMap;\nuse std::io::{BufWriter, stdin, stdout, Write};\nconst BITS: usize = 19;\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solvea () -> () {\n let mut scan = Scanner::default();\n let mut arr = [0; 4];\n arr[0] = scan.next:: ();\n arr[1] = scan.next:: ();\n arr[2] = scan.next:: ();\n arr[3] = scan.next:: ();\n arr.sort ();\n //a+b\n //b+c\n //c+a\n //a+b+c\n println! (\"{} {} {}\", arr[3]-arr[0], arr[3]-arr[1], arr[3]-arr[2]);\n}\nfn solve () {\n let mut scan = Scanner::default();\n let n = scan.next:: ();\n let mut arr: Vec = Vec::new ();\n for i in 0..n {\n let x = scan.next:: ();\n arr.push (x);\n }\n let mut ds: Vec = Vec::new ();\n for ss in 1..300 {\n let prevd = if arr[0] > ss {arr[0]-ss} else {ss-arr[0]};\n let mut not_possible = false;\n for i in 1..n {\n if arr[i] == ss {continue;}\n if ss + prevd == arr[i] || ss - prevd == arr[i] {\n continue;\n } else {\n not_possible=true;\n break;\n }\n }\n if !not_possible {\n ds.push (prevd);\n }\n }\n if ds.is_empty () {\n println! (\"-1\");\n } else {\n ds.sort ();\n println! (\"{}\", ds[0]);\n }\n}\nfn main () {\n let mut scan = Scanner::default();\n // let t = scan.next:: ();\n let t = 1;\n for _ in 0..t {\n solve ();\n }\n}\n", "lang": "Rust", "bug_code_uid": "6a25f546d66016b146bbc1083994bec0", "src_uid": "d486a88939c132848a7efdf257b9b066", "apr_id": "fe01306f038aa37e6ab84a54e76f3508", "difficulty": 1200, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9504707327056897, "equal_cnt": 10, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 9, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn gcd(a: u64, b: u64) -> u64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn lcm(a: u64, b: u64) -> u64 {\n if a == 0 || b == 0 {\n a + b\n } else {\n a / gcd(a, b) * b\n }\n}\n\nfn run() {\n input! {\n w: u64,\n c: [u64; 8],\n }\n let m = (1..=8).fold(0, |s, a| lcm(s, a));\n let mut ans = 0;\n let mut w = w;\n let mut c = c;\n for (i, c) in c.iter_mut().enumerate() {\n let k = (i + 1) as u64;\n let v = m / k;\n let q = *c / v;\n *c %= v;\n let d = std::cmp::min(w / m * m, q * v * k);\n ans += d;\n w -= d;\n }\n if w >= 8 * m {\n ans += c.iter().enumerate().fold(0, |s, (i, c)| s + (i + 1) as u64 * c);\n } else {\n let w = w as usize;\n let mut dp = vec![false; w + 1];\n dp[0] = true;\n for (i, &c) in c.iter().enumerate() {\n let k = i + 1;\n for _ in 0..c {\n for j in (k..=w).rev() {\n dp[j] |= dp[j - k];\n }\n }\n }\n ans += dp.iter().rposition(|p| *p).unwrap() as u64;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "d1f248c30fc1ea9369fb3677000dd19f", "src_uid": "8097e10157320524c0faed56f2bc4880", "apr_id": "86f72f02f572bde3a134668de40d8e48", "difficulty": 2300, "tags": ["dp", "dfs and similar", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999609375, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\n#[allow(unused_macros)]\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nuse std::io::Write;\n\nfn solve(writer: &mut std::io::BufWriter) {\n let n = parse_line!(usize);\n let a = parse_line_to_vec!(u32);\n let mut dp = vec![vec![[n, n]; n + 1]; n + 1];\n dp[0][0][0] = 0;\n dp[0][0][1] = 0;\n for i in 0..n {\n if a[i] != 0 {\n if a[i] % 2 == 0 {\n for i in (1..=n).rev() {\n for j in 0..=n {\n dp[i][j][0] = std::cmp::min(dp[i][j][0],\n std::cmp::min(dp[i - 1][j][0], dp[i - 1][j][1] + 1));\n }\n }\n }else{\n for i in 0..=n {\n for j in (1..=n).rev() {\n dp[i][j][1] = std::cmp::min(dp[i][j][1],\n std::cmp::min(dp[i][j - 1][1], dp[i][j - 1][0] + 1));\n }\n }\n }\n continue;\n }\n for i in (0..=n).rev() {\n for j in (0..=n).rev() {\n if i > 0 {\n dp[i][j][0] = std::cmp::min(dp[i][j][0],\n std::cmp::min(dp[i - 1][j][0], dp[i - 1][j][1] + 1));\n }\n if j > 0 {\n dp[i][j][1] = std::cmp::min(dp[i][j][0],\n std::cmp::min(dp[i][j - 1][1], dp[i][j - 1][0] + 1));\n }\n }\n }\n }\n writeln!(writer, \"{}\", dp[n / 2][n - n / 2].iter().min().unwrap()).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": "Rust", "bug_code_uid": "f00a6b44025b4c176116d536ff3743c2", "src_uid": "90db6b6548512acfc3da162144169dba", "apr_id": "24b03a58562e39b6e9753ec5710ea221", "difficulty": 1800, "tags": ["dp", "greedy", "sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9823615874571289, "equal_cnt": 7, "replace_cnt": 2, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "// ---------- begin ModInt ----------\nconst MOD: u32 = 1_000_000_007;\n\n#[derive(Clone, Copy)]\nstruct ModInt(u32);\n\nimpl std::ops::Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::AddAssign for ModInt {\n fn add_assign(&mut self, rhs: ModInt) {\n *self = *self + rhs;\n }\n}\n\nimpl std::ops::Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: ModInt) -> Self::Output {\n let mut d = self.0 + MOD - rhs.0;\n if d >= MOD {\n d -= MOD;\n }\n ModInt(d)\n }\n}\n\nimpl std::ops::SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: ModInt) {\n *self = *self - rhs;\n }\n}\n\nimpl std::ops::Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: ModInt) -> Self::Output {\n ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)\n }\n}\n\nimpl std::ops::MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n}\n\nimpl std::ops::Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n ModInt(if self.0 == 0 {0} else {MOD - self.0})\n }\n}\n\nimpl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n}\n\nimpl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n}\n\nimpl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt((val % MOD as usize) as u32)\n }\n}\n\n#[allow(dead_code)]\nimpl ModInt {\n pub fn new(n: u32) -> ModInt {\n ModInt(n % MOD)\n }\n pub fn zero() -> ModInt {\n ModInt(0)\n }\n pub fn one() -> ModInt {\n ModInt(1)\n }\n pub fn pow(self, mut n: u32) -> ModInt {\n let mut t = ModInt::one();\n let mut s = self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(self) -> ModInt {\n assert!(self.0 > 0);\n self.pow(MOD - 2)\n }\n}\n// ---------- end ModInt ----------\n\nfn run() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut it = s.trim().split_whitespace();\n let n: u32 = it.next().unwrap().parse().unwrap();\n let k: usize = it.next().unwrap().parse().unwrap();\n let mut is_prime = vec![true; k + 1];\n for i in 2.. {\n if i * i > k {\n break;\n }\n if is_prime[i] {\n let mut j = i * i;\n while let Some(p) = is_prime.get_mut(j) {\n *p = false;\n j += i;\n }\n }\n }\n let mut mobius = vec![ModInt::one(); k + 1];\n for (i, p) in is_prime.into_iter().enumerate().skip(2) {\n if !p {\n continue;\n }\n let mut j = i;\n while let Some(x) = mobius.get_mut(j) {\n *x = -*x;\n j += i;\n }\n let k = i.saturating_mul(i);\n let mut j = k;\n while let Some(x) = mobius.get_mut(j) {\n *x = ModInt::zero();\n j += k;\n }\n }\n let mut imos = vec![ModInt::zero(); 2 * k + 1];\n for (i, v) in mobius.into_iter().enumerate().skip(2) {\n if v.0 == 0 {\n continue;\n }\n for x in 1.. {\n if x * i > k {\n break;\n }\n let v = v * ModInt::from(x).pow(n);\n let l = x * i;\n let r = (x + 1) * i;\n imos[l] += v;\n imos[r] -= v;\n }\n }\n let mut ans = ModInt::zero();\n for i in 1..=k {\n imos[i] = imos[i] + imos[i - 1];\n let way = ModInt::from(i).pow(n) + imos[i];\n ans += ModInt::new(way.0 ^ i as u32);\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "35eef60f4011f920d810f65cf0b65f11", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "apr_id": "f1a0368b9be401954dd5dd52fabc942f", "difficulty": 2300, "tags": ["math", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.710917664127675, "equal_cnt": 21, "replace_cnt": 12, "delete_cnt": 4, "insert_cnt": 5, "fix_ops_cnt": 21, "bug_source_code": "use std::str::FromStr;\nuse std::io::stdin;\n\nfn get_vals(count: usize) -> Vec where\n T: FromStr,\n ::Err: std::fmt::Debug {\n let mut val = String::new();\n stdin().read_line(&mut val).expect(\"Failed to read line\");\n val.split_whitespace()\n .map(|x|\n x.parse::().expect(\"Failed to parse value\"))\n .take(count).collect()\n}\n\npub fn mashmokh() {\n let mut ins = get_vals::(2);\n let (n, k) = (ins.remove(0), ins.remove(0));\n let mut dp = vec![vec![0 as u32; k]; n];\n for x in dp[0].iter_mut() {\n *x = 1;\n }\n for i in dp.iter_mut() {\n i[0] = 1;\n }\n for i in 1..dp.len() {\n for j in 1..dp[i].len() {\n dp[i][j] = factor(i as i64 + 1)\n .into_iter()\n .map(|x| dp[x as usize - 1][j - 1])\n .sum()\n }\n }\n let ans: u32 = dp.iter_mut().map(|x| x[(k - 1) as usize]).sum();\n for i in dp {\n for j in i {\n print!(\"{0: <2}\", j);\n }\n println!();\n }\n println!(\"{}\", ans % 1000000007)\n}\n\npub fn factor(input: i64) -> Vec {\n let mut vector = vec![];\n\n for count in 1..(input + 1) {\n if input % count == 0 {\n vector.push(count);\n }\n }\n\n return vector;\n}", "lang": "Rust", "bug_code_uid": "17eb6a1834ab0eca3a4942d3bf44a94e", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "apr_id": "907bb23c405d1a6f354e11b5cb9bf864", "difficulty": 1400, "tags": ["dp", "combinatorics", "number theory"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7069027827972534, "equal_cnt": 21, "replace_cnt": 11, "delete_cnt": 4, "insert_cnt": 6, "fix_ops_cnt": 21, "bug_source_code": "use std::str::FromStr;\nuse std::io::stdin;\n\nfn get_vals(count: usize) -> Vec where\n T: FromStr,\n ::Err: std::fmt::Debug {\n let mut val = String::new();\n stdin().read_line(&mut val).expect(\"Failed to read line\");\n val.split_whitespace()\n .map(|x|\n x.parse::().expect(\"Failed to parse value\"))\n .take(count).collect()\n}\n\nfn main() {\n let mut ins = get_vals::(2);\n let (n, k) = (ins.remove(0), ins.remove(0));\n let mut dp = vec![vec![0 as u32; k]; n];\n for x in dp[0].iter_mut() {\n *x = 1;\n }\n for i in dp.iter_mut() {\n i[0] = 1;\n }\n for i in 1..dp.len() {\n for j in 1..dp[i].len() {\n dp[i][j] = factor(i as i64 + 1)\n .into_iter()\n .map(|x| dp[x as usize - 1][j - 1])\n .sum()\n }\n }\n let ans: u32 = dp.iter_mut().map(|x| x[(k - 1) as usize]).sum();\n // for i in dp {\n // for j in i {\n // print!(\"{0: <2}\", j);\n // }\n // println!();\n // }\n println!(\"{}\", ans % 1000000007)\n}\n\npub fn factor(input: i64) -> Vec {\n let mut vector = vec![];\n\n for count in 1..(input + 1) {\n if input % count == 0 {\n vector.push(count);\n }\n }\n\n return vector;\n}", "lang": "Rust", "bug_code_uid": "31305f1b4bdbf4caa457fcf723488c0d", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "apr_id": "907bb23c405d1a6f354e11b5cb9bf864", "difficulty": 1400, "tags": ["dp", "combinatorics", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7357043235704324, "equal_cnt": 12, "replace_cnt": 5, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 11, "bug_source_code": "use std::str::FromStr;\nuse std::io::stdin;\n\nfn get_vals(count: usize) -> Vec where\n T: FromStr,\n ::Err: std::fmt::Debug {\n let mut val = String::new();\n stdin().read_line(&mut val).expect(\"Failed to read line\");\n val.split_whitespace()\n .map(|x|\n x.parse::().expect(\"Failed to parse value\"))\n .take(count).collect()\n}\n\nfn main() {\n let mut ins = get_vals::(2);\n let (n, k) = (ins.remove(0), ins.remove(0));\n let mut dp = vec![vec![0 as u64; k]; n];\n for x in dp[0].iter_mut() {\n *x = 1;\n }\n for i in dp.iter_mut() {\n i[0] = 1;\n }\n for i in 1..dp.len() {\n for j in 1..dp[i].len() {\n dp[i][j] = factor((i as u64) + 1)\n .into_iter()\n .map(|x| dp[(x as usize) - 1][j - 1])\n .sum()\n }\n }\n let ans: u64 = dp.iter_mut().map(|x| x[k - 1] as u64).sum();\n println!(\"{}\", ans % 1000000007)\n}\n\npub fn factor(input: u64) -> Vec {\n let mut vector = vec![];\n\n // for count in 1..(input + 1) {\n // if input % count == 0 {\n // vector.push(count);\n // }\n // }\n\n let mut i = 1;\n while i * i <= input {\n if input % i == 0 {\n vector.push(i);\n if i != input / i {\n vector.push(input / i);\n }\n }\n i += 1;\n }\n\n vector\n}", "lang": "Rust", "bug_code_uid": "19ae469f7d8e52946a6ae63dff44310e", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "apr_id": "907bb23c405d1a6f354e11b5cb9bf864", "difficulty": 1400, "tags": ["dp", "combinatorics", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9911894273127754, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\n\nfn read_line() -> String {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n return String::from(input_line.trim());\n}\n\nfn read_line_vec() -> Vec {\n return read_line().split(' ')\n .map(|s| s.parse().unwrap())\n .collect();\n}\n\nfn resolve(n: u32) -> String {\n let s = match n {\n 0 => \"zero\",\n 10 => \"ten\",\n 1 => \"one\",\t\n 11 => \"eleven\",\t \t \n 2 => \"two\",\t\n 12 => \"twelve\",\n 20 => \"twenty\",\n 3 => \"three\",\n 13 => \"thirteen\",\n 30 => \"thirty\",\n 4 => \"four\",\n 14 => \"fourteen\",\n 40 => \"forty\",\n 5 => \"five\",\n 15 => \"fifteen\", \n 50 => \"fifty\",\n 6 => \"six\",\n 16 => \"sixteen\",\n 60 => \"sixty\",\n 7 => \"seven\",\n 17 => \"seventeen\",\t\n 70 => \"seventy\",\n 8 => \"eight\",\n 18 => \"eighteen\",\n 80 => \"eighty\",\n 9 => \"nine\",\n 19 => \"nineteen\",\n 90 => \"ninety\",\n _ => panic!(\"WHAAAAT\")\n };\n return String::from(s);\n}\n\nfn main() {\n let n: u32 = read_line().parse().unwrap();\n if n <= 20 {\n let s = resolve(n);\n println!(\"{}\", s);\n } else {\n let s2 = resolve(n % 10);\n let s1 = resolve(10 * (n / 10));\n println!(\"{}-{}\", s1, s2);\n }\n}", "lang": "Rust", "bug_code_uid": "870fb45598e18ffff13b46669710a4b8", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "apr_id": "0405485dd2a939a2bed546bd714bf53b", "difficulty": 1000, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9940119760479041, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::cmp;\n\nfn solution(input: String) {\n let max_fits = input.len() / 11;\n let possible_fits = input.chars().filter_map(|x| {\n if x == '8' {\n Some(1)\n } else {\n None\n }\n }).sum();\n println!(\"{:?}\", cmp::min(possible_fits, max_fits));\n}\n\npub fn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input);\n input.clear();\n match io::stdin().read_line(&mut input) {\n Ok(n) => {\n solution(input)\n }\n Err(error) => println!(\"error: {}\", error),\n }\n}\n", "lang": "Rust", "bug_code_uid": "7b37fd6cce8ad53d51bfb269fc81a8e1", "src_uid": "259d01b81bef5536b969247ff2c2d776", "apr_id": "bd240422e46e8cc5543533bcdde5cb19", "difficulty": 800, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9435600578871202, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{self, Read};\nuse std::cmp;\n \nfn main() {\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n handle.read_to_string(&mut buffer).unwrap();\n\n let arr : Vec<&str> = buffer.split_whitespace().collect();\n let mut num_8 = 0;\n let mut tot = 0;\n for i in arr[1].chars() {\n let d = i as u8 - '0' as u8;\n if d == 8 {\n num_8 += 1;\n }\n tot += 1;\n }\n\n let mut ans = -1;\n for i in 1..num_8+1 {\n let m = (tot-i)/10;\n use std::cmp;\n let h = cmp::min(m,i);\n if ans == -1 {\n ans = h;\n } else {\n ans = cmp::max(h,ans);\n }\n }\n\n println!(\"{}\",ans);\n}\n", "lang": "Rust", "bug_code_uid": "5f451c8f88aee34d54d50e02035533a8", "src_uid": "259d01b81bef5536b969247ff2c2d776", "apr_id": "48ea437da2c8278174e5a7e9f3d0dd5b", "difficulty": 800, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9541895718807263, "equal_cnt": 13, "replace_cnt": 6, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 12, "bug_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": "Rust", "bug_code_uid": "8725b21e2132af063975d77f48486908", "src_uid": "76659c0b7134416452585c391daadb16", "apr_id": "1fd82b85938af20db184ff5ef1a95aaa", "difficulty": 1500, "tags": ["greedy", "brute force", "sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7819782496116002, "equal_cnt": 16, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 10, "fix_ops_cnt": 15, "bug_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\n where 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 mut w: Vec = get_vec();\n\n w.sort();\n\n let ans = (0..3).map(|i| {\n w.iter().cloned().skip(i).take(2 * (n - 1)).fold((0, false), |acc, x| {\n (if acc.1 {\n acc.0 + x\n } else {\n acc.0 - x\n }, !acc.1)\n }).0\n }).min().unwrap();\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "37247b181a9024b1b696dfceaaa7198c", "src_uid": "76659c0b7134416452585c391daadb16", "apr_id": "73889e0e4752402294dededbf652a3f0", "difficulty": 1500, "tags": ["greedy", "brute force", "sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9908256880733946, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n\tlet mut players = String::new();\n\tio::stdin().read_line(&mut players).unwrap();\n\n\tlet mut same_player_count = 0;\n\tlet mut prev_player = 'a';\n\tlet mut out = \"NO\";\n\tfor player in players.trim().chars() {\n\t\tif player == prev_player {\n\t\t\tsame_player_count += 1;\n\t\t} else {\n\t\t\tsame_player_count = 0;\n\t\t}\n\t\tif same_player_count == 7 {\n\t\t\tout = \"YES\";\n\t\t\tbreak\n\t\t}\n\t\tprev_player = player;\n\t}\n\tprintln!(\"{}\", out);\n}\n", "lang": "Rust", "bug_code_uid": "918038fbbba1a7fb352c345ba274b0ed", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "6c2eef3318fe8361414adff2b11a3436", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9956427015250545, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n\n let line = buf.trim_end();\n\n if line.len() < 7 {\n println!(\"NO\");\n return;\n }\n\n for index in 0..(line.len() - 7) {\n let substr: String = line.chars().skip(index).take(7).collect();\n\n if substr == \"0000000\" || substr == \"1111111\" {\n println!(\"YES\");\n return;\n }\n }\n\n println!(\"NO\");\n}\n", "lang": "Rust", "bug_code_uid": "f1df1637e9f51f44af24411038097cc6", "src_uid": "ed9a763362abc6ed40356731f1036b38", "apr_id": "11b4826ecb8a2eda28b7a5c0de1afe20", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.994556516170349, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn can_be_splitted(slice : &[i32], sum : i32) -> bool {\n let mut curr_sum = 0;\n let mut index = 0;\n let mut at_least_one = false;\n loop {\n if index >= slice.len() {\n return at_least_one;\n }\n\n curr_sum += slice[index];\n if curr_sum == sum {\n curr_sum = 0;\n at_least_one = true;\n } else if curr_sum > sum {\n return false;\n }\n index += 1;\n }\n\n true\n}\n\nfn solve(length : usize, digits : Vec) -> (bool, i32) {\n let mut curr_sum = 0;\n for index in 0..(length - 1) {\n curr_sum += digits[index];\n if can_be_splitted(&digits[(index + 1)..], curr_sum) {\n return (true, curr_sum);\n }\n }\n (false, 0)\n}\n\nfn main() {\n let length = readln!(usize);\n \n let digits = readln!();\n let digits : Vec = digits.chars().map(|ch| ch.to_digit(10).unwrap() as i32).collect();\n\n let (result, sum) = solve(length, digits);\n\n println!(\"{}\", if result { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "963aa5effa2f1a5e61047429f23efbf0", "src_uid": "410296a01b97a0a39b6683569c84d56c", "apr_id": "36264101189fbdbfe0a03caba170d30d", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.46370829033367733, "equal_cnt": 18, "replace_cnt": 9, "delete_cnt": 6, "insert_cnt": 3, "fix_ops_cnt": 18, "bug_source_code": "use std::io;\n\nfn main() {\n let n = {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).unwrap();\n buffer.trim().parse().unwrap()\n };\n let nums : Vec = {\n let mut buffer = String::with_capacity(n);\n let mut char_str = String::from(\"0\");\n io::stdin().read_line(&mut buffer).unwrap();\n buffer\n .trim()\n .chars()\n .map(|x| {\n char_str.pop();\n char_str.push(x);\n char_str.trim().parse().unwrap()\n })\n .collect()\n };\n let mut iter = nums.iter();\n let mut sum = 0;\n {\n let mut sum_rest : u64 = nums.iter().fold(0, |acc, x| acc + x);\n while let Some(x) = iter.next() {\n sum_rest -= x;\n sum += x;\n if sum_rest % sum == 0 {\n break\n }\n }\n if sum_rest == 0 {\n println!(\"NO\");\n return \n }\n }\n let mut sum2 = 0;\n while let Some(x) = iter.next() {\n sum2 += x;\n if sum2 == sum {\n sum2 = 0;\n }\n }\n if sum2 == 0 {\n println!(\"YES\")\n } else {\n println!(\"NO\")\n }\n}", "lang": "Rust", "bug_code_uid": "b0d37dd1c80f8cc1c9a34330b68e8924", "src_uid": "410296a01b97a0a39b6683569c84d56c", "apr_id": "6911da2e86f99a2fba44677124900edf", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7724642095644227, "equal_cnt": 11, "replace_cnt": 5, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\nuse std::slice::Iter;\n\nfn check_step(iter : &mut Iter, check_sum : u64) -> Option {\n if iter.as_slice().len() == 0 { return None }\n let mut sum = 0;\n while let Some(x) = iter.next() {\n sum += x;\n if sum == check_sum {\n return Some(true)\n }\n }\n Some(false)\n}\n\nfn check(mut iter : Iter, check_sum : u64) -> bool {\n if iter.as_slice().len() == 0 { return false }\n while let Some(flag) = check_step(&mut iter, check_sum) {\n if !flag { \n return false \n }\n }\n true\n}\n\nfn main() {\n let n = {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).unwrap();\n buffer.trim().parse().unwrap()\n };\n let nums : Vec = {\n let mut buffer = String::with_capacity(n);\n let mut char_str = String::from(\"0\");\n io::stdin().read_line(&mut buffer).unwrap();\n buffer\n .trim()\n .chars()\n .map(|x| {\n char_str.pop();\n char_str.push(x);\n char_str.trim().parse().unwrap()\n })\n .collect()\n };\n let mut iter = nums.iter();\n let mut sum = 0;\n let mut sum_rest : u64 = nums.iter().fold(0, |acc, x| acc + x);\n while let Some(x) = iter.next() {\n sum_rest -= x;\n sum += x;\n if sum_rest.checked_rem(sum).map(|x| x == 0).unwrap_or_else(|| sum == sum_rest) {\n if check(iter.clone(), sum) {\n println!(\"YES\");\n return\n }\n }\n }\n println!(\"NO\");\n}", "lang": "Rust", "bug_code_uid": "71a82ee304540ff4e633c8c886360e71", "src_uid": "410296a01b97a0a39b6683569c84d56c", "apr_id": "6911da2e86f99a2fba44677124900edf", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.990188679245283, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 w: i64,\n h: i64,\n u1: i64,\n d1: i64,\n u2: i64,\n d2: i64,\n }\n let mut ans = w;\n let mut height = h;\n while height > 0 {\n ans += height;\n if d1 == height {\n ans -= u1;\n }\n if d2 == height {\n ans -= u2;\n }\n height -= 1;\n }\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "36a02776596d9729dcdbd553ecf98b74", "src_uid": "084a12eb3a708b43b880734f3ee51374", "apr_id": "61a61ee3d8a679b8997fc7917bd6ffd7", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7664399092970522, "equal_cnt": 9, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\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(s: String) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n s.split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn main() {\n let n: u32 = get_line().trim().parse().unwrap();\n\n let (a, b) = if n % 2 == 0 {\n (n / 2 - 1, n / 2 + 1)\n } else {\n (n / 2, n / 2 + 1)\n };\n\n println!(\"{} {}\", a, b);\n}\n", "lang": "Rust", "bug_code_uid": "d46eb4d285eaaaf6902c9fcc51de6bb3", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "apr_id": "e5c9b596a4b97cca10ee686de0bee624", "difficulty": 800, "tags": ["brute force", "math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.55198973042362, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut line: String = String::new();\n io::stdin().read_line(&mut line).unwrap();\n let n: u32 = line.trim().parse().unwrap();\n let a = n / 2;\n println!(\"{} {}\", a - (1 - n % 2), a + 1);\n}\n", "lang": "Rust", "bug_code_uid": "3ee558e4a8e45f29da4103972f268138", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "apr_id": "ffae97d894ff7c362b0b4d3dc0e01cf0", "difficulty": 800, "tags": ["brute force", "math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8423153692614771, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{ self, BufRead };\nuse std::collections::*;\n\nmacro_rules! scan_line {\n () => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n buffer\n });\n ( $($t:ty)+ ) => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n let mut chunks = buffer.split_whitespace();\n\n ($(\n {\n chunks.next()\n .expect(\"scan_line: failed at `next`, # of space separated strings not equal to requested #\")\n .parse::<$t>()\n .expect(\"scan_line: failed at `parse::<$t>`.\")\n },\n )+)\n })\n}\n\nfn main() {\n let (mut n, ) = scan_line!(i64);\n\n n -= 3;\n let mut numerator = 1;\n let mut denominator = 2;\n\n while n >= 1 {\n if numerator + 1 < denominator {\n numerator += 1;\n } else {\n denominator += 1;\n }\n n -= 1;\n }\n\n println!(\"{} {}\", numerator, denominator);\n}", "lang": "Rust", "bug_code_uid": "377b8bd4078298c4d40ba0f18c64bd33", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "apr_id": "354e5eaedb965281de9be8b416313392", "difficulty": 800, "tags": ["brute force", "math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9914184755174155, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\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(s: String) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n s.split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn gcd(a: u32, b: u32) -> u32 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn main() {\n let (n, k): (u32, u32) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (it.next().unwrap(),\n it.next().unwrap())\n };\n\n let min_val = if k == 0 || k == n {\n 0\n } else {\n 1\n };\n\n let q = n / 3;\n let r = n % 3;\n\n let max_val = if k <= q {\n 2 * k\n } else if k <= q + r {\n 2 * q + if r > 1 {1} else {0}\n } else {\n n - k\n };\n\n println!(\"{} {}\", min_val, max_val);\n}\n", "lang": "Rust", "bug_code_uid": "55750e4bb71ed57d3b24b132c0551c3e", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "apr_id": "eadc0240fc07b740e1cf3bec6eb62884", "difficulty": 1200, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8807969769838544, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 4, "bug_source_code": "use std::io::{ self, BufRead };\nuse std::collections::*;\n\nmacro_rules! scan_line {\n () => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n buffer\n });\n ( $($t:ty)+ ) => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n let mut chunks = buffer.split_whitespace();\n\n ($(\n {\n chunks.next()\n .expect(\"scan_line: failed at `next`, # of space separated strings not equal to requested #\")\n .parse::<$t>()\n .expect(\"scan_line: failed at `parse::<$t>`.\")\n },\n )+)\n })\n}\n\nfn main() {\n let (n, k) = scan_line!(i64 i64);\n\n let m = if n == k || k == 0 { 0 } else { 1 };\n let M = if k == 0 {\n 0\n } else if k == n/2 {\n if n % 2 == 0 {\n k\n } else {\n k + 1\n }\n } else if k > n/2 {\n n - k\n } else {\n k + 1\n };\n\n println!(\"{} {}\", m, M);\n \n}", "lang": "Rust", "bug_code_uid": "181cbd420427910e78a8e70b2c3d1db1", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "apr_id": "a95400112b79c4740452eb4e4a30124a", "difficulty": 1200, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9661164205039097, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n use std::io;\n use std::str::FromStr;\n use std::cmp::min;\n use std::cmp::max;\n \n let stdin = io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).ok();\n let s_line : Vec<&str> = line.split(' ').collect();\n let n : i64 = i64::from_str(s_line[0].trim()).unwrap();\n let k : i64 = i64::from_str(s_line[1].trim()).unwrap();\n let ans_min = min(1, n-k);\n let mut ans_max = 2*min(n/3, k) - max((k-min(n/3, k)) - n%3, 0);\n if (k-min(n/3, k))==1 && n%3==2{\n ans_max += 1;\n }\n println!(\"{0} {1}\", ans_min, ans_max);\n}", "lang": "Rust", "bug_code_uid": "eb96b84ea12ca186fe96b67873a1586e", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "apr_id": "c0628b3bd7e1bae2f67abe5d048b2891", "difficulty": 1200, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9218500797448166, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "/*\n *\n * Author : fcbruce \n *\n * Time : Sat 10 Feb 2018 18:51:25\n *\n */\n// n - c, m - o\n// \n// 6 3\n// \n// 2x + y = n\n// 1 + y = m\n// \n// y = 2\n\nfn check(copy: i32, origin: i32) -> bool {\n let y = origin - 1;\n let x = copy - y;\n\n return x >= 0 && y >= 0 && x % 2 == 0;\n}\n\nfn main() {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).unwrap();\n\n let mut numbers = buffer.split_whitespace();\n\n\n let copy:i32 = numbers.next().unwrap().parse().unwrap();\n let origin:i32 = numbers.next().unwrap().parse().unwrap();\n\n if check(copy, origin) {\n println!(\"Yes\");\n } else {\n println!(\"No\");\n }\n\n}\n\n", "lang": "Rust", "bug_code_uid": "d9801cd96cf2f7e69280825433effef9", "src_uid": "1527171297a0b9c5adf356a549f313b9", "apr_id": "85f468a690e956d7963d674c4df44f43", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9961538461538462, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n\n let mut str = String::new();\n\n io::stdin().read_line(&mut str).expect(\"You are failure\");\n\n let mut vals = [0; 2];\n\n let str = str.trim().split(\" \");\n\n let mut f = 0;\n for i in str{\n vals[f] = i.parse().expect(\"err\");\n f+=1;\n }\n\n let mut printable = true;\n\n if vals[1] == 0 || (vals[0]%2 == vals[1]%2) || (vals[1]==1 && vals[0] != 0) || vals[0] > vals[1] + 1{\n printable = false;\n }\n\n println!(\"{}\", if printable {\"YES\"} else {\"NO\"});\n\n}\n", "lang": "Rust", "bug_code_uid": "5f1a89de573a260d97346846275f30a8", "src_uid": "1527171297a0b9c5adf356a549f313b9", "apr_id": "a01a9f08d7419a6a70be0a96fcea2d5a", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9984496124031008, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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": "Rust", "bug_code_uid": "2a425a34cfb01d935171266b1c3db02a", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "apr_id": "2e83af6101627e602c77f93f15f6189d", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9867899603698811, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n\n let mut input_text = String::new();\n io::stdin().read_line(&mut input_text).expect(\"fail\");\n let n = input_text.trim().parse::().expect(\"parse error\");\n\n let mut string = String::new();\n io::stdin().read_line(&mut string).expect(\"fail\");\n\n let string = string.chars();\n\n let mut vec = Vec::new();\n for c in string {\n vec.push(c);\n }\n\n for d in 1..n+1 {\n if n % d == 0 {\n for i in 0..d/2+1 {\n let t = vec[i as usize];\n vec[i as usize] = vec[d as usize - i as usize - 1usize];\n vec[d as usize - i as usize - 1usize] = t;\n }\n }\n }\n for i in 0..n {\n print!(\"{}\", vec[i as usize]);\n }\n}\n", "lang": "Rust", "bug_code_uid": "6c7819d97320d02abcb295028b460eb9", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "apr_id": "b02ee870b24750bf32aca1a41d9bd946", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.4255677039529016, "equal_cnt": 18, "replace_cnt": 9, "delete_cnt": 8, "insert_cnt": 1, "fix_ops_cnt": 18, "bug_source_code": "fn main() {\n let (n, k) = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let buf: Vec = buf\n .trim()\n .split_whitespace()\n .map(|a| a.parse::().unwrap())\n .collect();\n (buf[0], buf[1])\n };\n\n let time_left = 240u16 - k;\n let nums: Vec = (1u16..=n).collect();\n let mut result = nums[n as usize-1];\n for i in 0..nums.len() {\n let a = nums[i];\n if 5u16 * a * (a - 1u16) / 2u16 > time_left {\n result = i as u16 - 1;\n break;\n }\n }\n println!(\"{}\", result);\n}", "lang": "Rust", "bug_code_uid": "5321cd2aed8db40c17a5729f9bd5ab31", "src_uid": "41e554bc323857be7b8483ee358a35e2", "apr_id": "df3177b6a5c41ef32fc95067dd19e976", "difficulty": 800, "tags": ["math", "brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8545636910732196, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "macro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let (n,m,a,b) = readln!(i32,i32,i32,i32);\n let r1 = n*a;\n let r2 = b*((n+m-1)/m);\n let r3 = b*(n/m) + a*(n%m);\n println!(\"{}\", std::cmp::min(r1,std::cmp::min(r2,r3)));\n}\n", "lang": "Rust", "bug_code_uid": "cecaaa30ab0c8aa43e720e17fa1f4934", "src_uid": "41e554bc323857be7b8483ee358a35e2", "apr_id": "51f211e5b840149debb9e27c2f0f6f77", "difficulty": 800, "tags": ["math", "brute force", "implementation", "binary search"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9970937912813739, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "#[allow(dead_code)]\nuse std::cmp::min;\nuse std::collections::HashMap;\nuse std::io;\nuse std::str::FromStr;\nuse std::io::Read;\n\nstruct Input {\n tokens: as IntoIterator>::IntoIter,\n read_all: bool,\n}\n\nimpl Input {\n pub fn new(read_all: bool) -> Input {\n if read_all {\n let mut all = String::new();\n io::stdin().read_to_string(&mut all).unwrap();\n let tokens: Vec = all.split_whitespace().map(|s| s.to_string()).collect();\n Input {\n tokens: tokens.into_iter(),\n read_all: true,\n }\n } else {\n Input {\n tokens: vec!().into_iter(),\n read_all: false,\n }\n }\n }\n\n fn refresh_next_line(&mut self) {\n if self.read_all {\n panic!();\n }\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let tokens: Vec = buf.split_whitespace().map(|s| s.to_string()).collect();\n self.tokens = tokens.into_iter();\n }\n\n fn next_impl(&mut self) -> String {\n loop {\n if let Some(next) = self.tokens.next() {\n return next.to_string();\n }\n self.refresh_next_line();\n }\n }\n\n pub fn next(&mut self) -> T where ::Err: std::fmt::Debug {\n let next_str = self.next_impl();\n next_str.parse().unwrap()\n }\n\n pub fn next_vec(&mut self, len: usize) -> Vec where ::Err: std::fmt::Debug {\n (0..len).map(|_i| self.next()).collect()\n }\n\n pub fn next_vec_read_len(&mut self) -> Vec where ::Err: std::fmt::Debug {\n let len = self.next();\n self.next_vec(len)\n }\n}\n\nfn main() {\n let mut input = Input::new(false);\n let n: i64 = input.next();\n let k: i64 = input.next();\n let mut time = 240 - k;\n let mut i = 1;\n while time > i * 5 {\n time -= i * 5;\n i += 1\n }\n println!(\"{}\", i - 1);\n\n}\n", "lang": "Rust", "bug_code_uid": "bb19006a4076b019b9bbd67f9a337d0a", "src_uid": "41e554bc323857be7b8483ee358a35e2", "apr_id": "4755837e9234c4ec1e5724b3e38c42ab", "difficulty": 800, "tags": ["math", "brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9289617486338798, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() -> std::io::Result<()> {\n let stdin = io::stdin();\n let mut input = String::new();\n stdin.read_line(&mut input)?;\n let problems_travel: Vec = input.trim().split(\" \").map(|x| x.parse::().unwrap()).collect();\n let minutes_left: i16 = 240 - problems_travel[1];\n for p in 1..=problems_travel[0] {\n if minutes_left - p * 5 < 0 {\n print!(\"{}\", p-1); \n break;\n } else if p == problems_travel[0] {print!(\"{}\",p);}\n }\n \n Ok(())\n}", "lang": "Rust", "bug_code_uid": "add1e78c16e53033c61c80688680deab", "src_uid": "41e554bc323857be7b8483ee358a35e2", "apr_id": "177800081eba3d708ca88b276be5824a", "difficulty": 800, "tags": ["math", "brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9916387959866221, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "macro_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 ($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\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 main() {\n input! {\n n : i32,\n k : i32,\n };\n let mut time = k;\n for i in 0..n {\n time += (i + 1) * 5;\n println!(\"{}\", time);\n if time > 240 {\n println!(\"{}\", i);\n return;\n }\n }\n println!(\"{}\", n);\n}\n", "lang": "Rust", "bug_code_uid": "48c05e5b20d003e492645e2ee530583b", "src_uid": "41e554bc323857be7b8483ee358a35e2", "apr_id": "4d3db02faf04ee1b127137e7f4f2ed54", "difficulty": 800, "tags": ["math", "brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9837362637362638, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn is_prime(num : i128) -> bool {\n if num == 1 || num != 2 && num % 2 == 0 {\n return false;\n }\n let limit = (num as f64).sqrt() as i128 + 1;\n let mut div = 3;\n while div <= limit {\n if num % div == 0 {\n return true;\n }\n div += 1;\n }\n return true;\n}\n\nfn main() {\n let tests = readln!(u8);\n for _ in 0..tests {\n let (size1, size2) = readln!(i128, i128);\n\n if size1 - size2 == 1 {\n println!(\"{}\", if is_prime(size1 + size2) { \"YES\" } else { \"NO\" });\n } else {\n println!(\"NO\");\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "10dd397b2664bffafc22a3029947884c", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "apr_id": "57120c31f212c9b276f4655b57f3dd46", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9283223556760946, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let t: u32 = scan.token();\n for _ in 0..t {\n let a: i64 = scan.token();\n let b: i64 = scan.token();\n if a - b == 1 {\n writeln!(out, \"YES\").ok();\n } else {\n writeln!(out, \"NO\").ok();\n }\n }\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "19dc538e7ba66b07b58350b9a113a702", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "apr_id": "4c76dafbc3deb97c640530e0d87d9343", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9990319457889641, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self, Read};\nuse std::cmp;\n\n\nfn main() {\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n handle.read_to_string(&mut buffer).unwrap();\n\n let arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n let t = arr[0] as usize;\n let mut index = 1;\n for _ in 0..t {\n let (a,b) = (arr[index],arr[index+1]);\n if b == a-1 {\n let h = 2*b+1; // = a+b\n let mut j = 3; //just check all odd numbers since 2b + 1 is odd\n let mut divisible = false;\n while j <= (h as f64).sqrt() as u64 + 1{\n if h % j == 0 {\n divisible = true;\n }\n j += 2;\n }\n println!(\"{},{}: {}\",a,b,divisible);\n if !divisible {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n } else {\n println!(\"NO\");\n }\n index += 2;\n }\n}\n", "lang": "Rust", "bug_code_uid": "1fa7dc437aadf51f644946497bdc78f9", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "apr_id": "5886a99e41fc79761cb2c73fe493c95f", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8047520661157025, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 6, "bug_source_code": "use std::io::{self, Read};\nuse std::cmp;\n\n\nfn main() {\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n handle.read_to_string(&mut buffer).unwrap();\n\n let arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n let t = arr[0] as usize;\n let mut index = 1;\n for _ in 0..t {\n let (a,b) = (arr[index],arr[index+1]);\n if b == a-1 {\n let h = 2*b+1;\n let mut j = 3;\n let mut divisible = false;\n while j < h/2+1 {\n if h % j == 0 {\n divisible = true;\n }\n j += 2;\n }\n if !divisible {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n } else {\n println!(\"NO\");\n }\n index += 2;\n }\n}\n", "lang": "Rust", "bug_code_uid": "575fa1354db462367c8c12ac747cee9f", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "apr_id": "5886a99e41fc79761cb2c73fe493c95f", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4143222506393862, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nfn main() {\n\n let mut string = String::new();\n io::stdin().read_line(&mut string);\n\n let vector: Vec<&str> = string.split(\"\\n\").collect();\n\n if vector[1].chars().eq(vector[0].chars().rev()) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "2d63e1b437081371db5689686e1b0a1a", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "apr_id": "4a30ca05a07b3d7290f23954585b46bb", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.3813847900113507, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input);\n\n let vector: Vec<&str> = input.split(\" \").collect();\n let first_vector = vector[0].to_string();\n let second_vector: String = vector[1].trim().chars().rev().collect();\n\n if first_vector.eq(&second_vector) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang": "Rust", "bug_code_uid": "f3b466cbd0da3bb5b221cf319c6ec4f8", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "apr_id": "4a30ca05a07b3d7290f23954585b46bb", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8318318318318318, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 7, "bug_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": "Rust", "bug_code_uid": "bf160e03fccc92d0719e4cfb5d92d04e", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "apr_id": "ef1b124b3eaa13a6e70fa11894a4a53f", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999054820415879, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nfn main(){\n let mut s:String=String::new();\n io::stdin().read_line(&mut s).unwrap();\n let mut c:usize=0;\n let mut n:usize=0;\n let mut a:Vec=Vec::new();\n while c=Vec::new();\n while c().expect(\"parse error\"))\n .collect::>();\n io::stdin().read_line(&mut a_str).expect(\"\");\n let mut v = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n\n let n = num[0];\n let k = num[1];\n\n let mut res = 0;\n v.sort();\n v.reverse();\n for i in &v {\n if k % i == 0 {\n res = k / i;\n break;\n }\n }\n println!(\"{}\", res);\n\n\n}\n", "lang": "Rust", "bug_code_uid": "9259a9cd49d6af1295d569c09ba93ada", "src_uid": "80520be9916045aca3a7de7bc925af1f", "apr_id": "6fd5cdb776daf6dedc4aa9d101f97534", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9660377358490566, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"\");\n let mut num = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n io::stdin().read_line(&mut a_str).expect(\"\");\n let mut v = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n\n let n = num[0];\n let k = num[1];\n\n let mut res = 0;\n v.sort().reverse();\n for i in &v {\n if k % i == 0 {\n res = k / i;\n break;\n }\n }\n println!(\"{}\", res);\n\n\n}\n", "lang": "Rust", "bug_code_uid": "71deb50048af65854a8d0536a3c36d9d", "src_uid": "80520be9916045aca3a7de7bc925af1f", "apr_id": "6fd5cdb776daf6dedc4aa9d101f97534", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9827768014059753, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::fs::File;\n\nfn main() {\n let stdin = io::stdin();\n let buf :Box = if cfg!(feature = \"intxt\") {\n eprintln!(\"file mode\");\n let file = File::open(\"in.txt\").unwrap();\n Box::new(io::BufReader::new(file))\n } else {\n eprintln!(\"stdin mode\");\n Box::new(stdin.lock())\n };\n let mut sc = Scanner::new(buf);\n\n let n :i32 = sc.next();\n let mut vec = Vec::new();\n for _ in 0..n {\n let a :i32 = sc.next();\n vec.push(a);\n }\n vec.sort();\n let mut a = vec[0];\n let mut cnt = 1;\n for x in vec {\n if x != a {\n a = x;\n if x > 0 { cnt += 1}\n }\n }\n println!(\"{}\", cnt);\n}\n\n\nstruct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n fn new(reader: B) -> Self {\n Self {\n reader,\n buffer: Vec::new(),\n }\n }\n\n fn next(&mut self) -> T\n where\n T::Err: std::fmt::Debug,\n {\n if let Some(s) = self.buffer.pop() {\n T::from_str(&s).unwrap()\n } else {\n let mut s = String::new();\n let r = self.reader.read_line(&mut s).unwrap();\n assert!(r > 0);\n self.buffer = s.split_whitespace().rev().map(String::from).collect();\n return self.next();\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "c9150acc4473ffa4421cb139d946c8fe", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "apr_id": "0d098c080cae3dbdf6cef842a6b4aaee", "difficulty": 800, "tags": ["sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.997907949790795, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut input = String::new();\n use std::io;\n use std::io::prelude::*;\n io::stdin().read_to_string(&mut input).unwrap();\n\n let mut it = input.split_whitespace();\n\n let n: usize = it.next().unwrap().parse().unwrap();\n\n let a: Vec = it.map(|x| x.parse().unwrap()).collect();\n\n let mut set = [false; 600];\n\n for a in a {\n set[a] = true;\n }\n\n let ans = set[1..].iter().filter(|&&x| x).count();\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "964f44f7184c291f89e080773f54da79", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "apr_id": "846108f52b9ca9657a73bcea330c542a", "difficulty": 800, "tags": ["sortings", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9964726631393298, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "\nmacro_rules! parse {\n () => {{\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap(); // don't do this\n s.trim().parse().unwrap() // don't do this\n }};\n}\n\nfn main() {\n let s: String = parse!();\n let input: Vec = s.split_whitespace().map(|f| f.trim()).map(|s| s.parse().unwrap()).collect();\n let participants = input[0];\n let pens = input[1];\n let notebooks = input[2];\n if participants < pens || participants < notebooks{\n println!(\"No\");\n }else {\n println!(\"Yes\");\n }\n}\n\n\n\n\n", "lang": "Rust", "bug_code_uid": "8287cbefad415027e08962bdb959a322", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "apr_id": "680079178fe8c307450f168daf8299db", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9982847341337907, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "/*\n Implementation, strings - https://codeforces.com/problemset/problem/281/A\n Completed: 4/7/20 3:43\n*/\n\nuse std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n\n let vector: Vec<&str> = input.trim().split(\" \").collect();\n\n let participants = vector[0].parse::().unwrap();\n let pens = vector[1].parse::().unwrap();\n let notebooks = vector[2].parse::().unwrap();\n\n if (participants < pens) & (participants < notebooks) {\n println!(\"Yes\");\n } else {\n println!(\"No\");\n }\n\n}", "lang": "Rust", "bug_code_uid": "4d83da8e74832ea6f70694c5e103e53e", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "apr_id": "66b1e159b8dffcaa5a119a244ca79cf3", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9981308411214953, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut i = String::new();\n io::stdin().read_line(&mut i).unwrap();\n let h: Vec = i.split(\" \").map(|s| s.trim()).map(|s| s.parse().unwrap()).collect();\n println!(\"{}\", if (h[0] <= h[1]) && (h[0] < h[2]) { \"Yes\" } else { \"No \"});\n}", "lang": "Rust", "bug_code_uid": "b9b48de4bffd95b8ea8bfd02e8925f75", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "apr_id": "0dd1651e38346a0ff4035161b28294b7", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.39095315024232635, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "fn main() {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"???\");\n let arbuz: u32 = input.trim().parse().expect(\"???\");\n if (arbuz > 2) && (arbuz % 2 == 0) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang": "Rust", "bug_code_uid": "70fb5d2c576aa492876cd9d6c0c9e3c2", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "53b24d6cfe917c31b751faae8fff4d52", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9894736842105263, "equal_cnt": 9, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 8, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\n\nfn main() {\n let (x,y,z) = parse_line!(i128, i128, i128);\n let a = (x+z-1)/z*(y+z-1)/z;\n println!(\"{}\", a);\n}\n", "lang": "Rust", "bug_code_uid": "abc33706c7b6ec3c4dbc675d1eb74acc", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "ed9d00162a77800b0dfe5f7e3209f949", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9589403973509933, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 5, "bug_source_code": "fn main() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n\n let mut ws = s.split_whitespace();\n let n: i64 = ws.next().unwrap().parse().unwrap();\n let m: i64 = ws.next().unwrap().parse().unwrap();\n let a: i64 = ws.next().unwrap().parse().unwrap();\n\n // ceil(n/a) * ceil(m/a)\n println!(\"{}\", (n+a-1)/a * (m+a-1)/a);\n}\n\n/* vim: set ts=2 sts=2 sw=2 et: */\n", "lang": "Rust", "bug_code_uid": "1b5e96f060056a535ec190a5d82446e8", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "41b71ce645b058934c618460f99ad72d", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.2940251572327044, "equal_cnt": 9, "replace_cnt": 9, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 9, "bug_source_code": "fn main(){\n let mut line=String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut line:Vec=line.trim().chars().collect();\n let mut s:usize=0;\n let mut e:usize=line.len()-1;\n while s'2'{e-=2}\n if s=line.trim().chars().collect();\n let mut s:i32=0;\n let mut e:i32=line.len() as i32-1;\n while s'2'{e-=2}\n if s std::io::Result<()> {\n let stdin = io::stdin();\n let mut input = String::new();\n stdin.read_line(&mut input)?;\n print!(\"{}\", helpfulmath(input));\n Ok(())\n}\n\nfn helpfulmath(input: String) -> String {\n let mut sequence : Vec<&str> = input.as_str()\n .split('+')\n .collect();\n sequence.sort();\n sequence.join(&\"+\")\n}\n#[cfg(test)]\nmod tests {\n use super::*;\n #[test]\n fn test() {\n assert_eq!(helpfulmath(\"1+1+3+1+3\".to_string()), \"1+1+1+3+3\".to_string());\n assert_eq!(helpfulmath(\"2\".to_string()), \"2\".to_string());\n assert_eq!(helpfulmath(\"3+2+1\".to_string()), \"1+2+3\".to_string());\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "562f578c4011af6ef37ce22d3175765a", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "apr_id": "30ad591cef6c1e49598c92e9e677de47", "difficulty": 800, "tags": ["greedy", "strings", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9720812182741116, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "\npub fn main(){\n let mut inputs = input();\n inputs.sort_unstable();\n inputs.reverse();\n print!(\"{}\", inputs[0]);\n for i in 1..inputs.len() {\n print!(\"+{}\", inputs[i]);\n }\n println!(\"\");\n}\n\nfn input() -> Vec {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input);\n input.trim().split('+').map(|s| s.parse::().unwrap())\n .collect()\n}\n", "lang": "Rust", "bug_code_uid": "916f1ea01d75cf6572054a6e0b23d8ac", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "apr_id": "bc24a69cda099edf6aa42b26abc363bd", "difficulty": 800, "tags": ["greedy", "strings", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.0031512605042016808, "equal_cnt": 2, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "fn main() {}\n", "lang": "Rust", "bug_code_uid": "4473e4c2e72c719217543694b5cf4f8d", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "apr_id": "f94f141a3a990c3ac0aecb65e188ac46", "difficulty": 800, "tags": ["greedy", "strings", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.998868351565447, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() { \nlet mut ques = String::new();\n std::io::stdin()\n .read_line(&mut ques)\n .expect(\"Values not found\");\n\nlet ques = ques.replace( \"\\n\", \"\" );\nlet ques = ques.replace(\"+\", \" \");\nlet mut ques_each: Vec = ques.split_whitespace()\n .map(|s| s.parse()\n .expect(\"value not found\"))\n .collect();\n // ques_each.sort();\n// println!(\"{:?}\", ques_each);\n sort(ques_each.as_mut_slice());\n println!(\"{:?}\", ques_each);\n\n let mut first = true;\n for i in ques_each {\n if !first {\n print!(\"+\");\n }\n print!(\"{}\",i);\n first = false;\n }\n println!(\"\");\n\n// let in1 = ques_each[0];\n// let in2 = ques_each[1];\n// let in3 = ques_each[2];\n // let test1 = in1 + in2;\n// println!(\"{}+{}+{} \", in1, in2, in3);\n}\n\nfn sort(vec: &mut [usize]) {\n // let (mut i, mut j, mut small, mut temp): (usize, usize, usize, usize) = (0, 0, 0, 0);\n\n for i in 0..vec.len() - 1 {\n let mut small = i;\n for j in (i+1)..vec.len() {\n if vec[j] < vec[small] {\n small = j;\n }\n }\n let temp = vec[i];\n vec[i] = vec[small];\n vec[small] = temp;\n } \n}", "lang": "Rust", "bug_code_uid": "9d8f2bb09b1130b0e447be76c549db3a", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "apr_id": "5c78e61c8e6cc3299288534fe2d9642d", "difficulty": 800, "tags": ["greedy", "strings", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9835047545119348, "equal_cnt": 3, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_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::*;\nfn getline() -> String {\n let mut res = String::new();\n std::io::stdin().read_line(&mut res).ok();\n res\n}\nmacro_rules ! readl { ( $ t : ty ) => { { let s = getline ( ) ; s . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,+ ) => { { let s = getline ( ) ; let mut iter = s . trim ( ) . split ( ' ' ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; }\nmacro_rules ! readlvec { ( $ t : ty ) => { { let s = getline ( ) ; let iter = s . trim ( ) . split ( ' ' ) ; iter . map ( | x | x . parse ( ) . unwrap ( ) ) . collect ::< Vec <$ t >> ( ) } } }\nmacro_rules ! mvec { ( $ v : expr , $ s : expr ) => { vec ! [ $ v ; $ s ] } ; ( $ v : expr , $ s : expr , $ ( $ t : expr ) ,* ) => { vec ! [ mvec ! ( $ v , $ ( $ t ) ,* ) ; $ s ] } ; }\nmacro_rules ! debug { ( $ x : expr ) => { println ! ( \"{}: {:?}\" , stringify ! ( $ x ) , $ x ) } }\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{\n for (i, e) in v.into_iter().enumerate() {\n if i != 0 {\n print!(\" \");\n }\n print!(\"{}\", e);\n }\n println!(\"\");\n}\nstruct ContestPrinter {\n s: String,\n}\nimpl ContestPrinter {\n fn new() -> ContestPrinter {\n ContestPrinter { s: String::new() }\n }\n fn print(&mut self, x: T)\n where\n T: std::fmt::Display,\n {\n self.s.push_str(format!(\"{}\", x).as_str());\n }\n fn println(&mut self, x: T)\n where\n T: std::fmt::Display,\n {\n self.s.push_str(format!(\"{}\\n\", x).as_str());\n }\n}\nimpl std::ops::Drop for ContestPrinter {\n fn drop(&mut self) {\n print!(\"{}\", self.s);\n }\n}\nstatic MOD: i64 = 1e9 as i64 + 7;\nfn is_max_i64(num: i64) -> bool {\n if num == i64::max_value() {\n true\n } else {\n false\n }\n}\nfn main() {\n let mut pr = ContestPrinter::new();\n let N = readl!(usize);\n let s = readl!(String);\n let sc = s.chars().collect::>();\n let mut idx = 1;\n let mut ans = 1;\n if N == 1 {\n pr.println(1);\n return;\n }\n while idx < N {\n if ((sc[idx - 1] == 'R') & (sc[idx] == 'U')) |\n ((sc[idx - 1] == 'U') & (sc[idx] == 'R')) {\n idx += 1;\n }\n ans += 1;\n idx += 1;\n }\n pr.println(ans);\n}", "lang": "Rust", "bug_code_uid": "2eca057ce73bce579410bcf6d30d1eaa", "src_uid": "986ae418ce82435badadb0bd5588f45b", "apr_id": "298cef3741a41dde328af891f049862d", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.955871353777113, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn read_int_line () -> i32 {\n let mut num = String::new();\n io::stdin().read_line(&mut num)\n .expect(\"Failed to read line\");\n \n num.trim().parse()\n .expect(\"Not an integer\")\n}\n\nfn main() {\n\n\tread_int_line();\n\n\tlet mut string = String::new();\n\tio::stdin().read_line(&mut string)\n\t\t.expect(\"Failed to read line\");\n\n\n\tlet v: Vec<&str> = string.split(char::is_uppercase).collect();\n\tlet mut maximum: i32 = 0;\n\n\tfor s in v {\n\t\tlet mut vi: Vec = s.trim().chars().collect();\n\t\tvi.dedup();\n\t\tlet temp: i32 = vi.len() as i32;\n\t\tif maximum < temp {\n\t\t\tmaximum = temp;\n\t\t}\n\t}\n\tprintln!(\"{}\", maximum);\n}\n", "lang": "Rust", "bug_code_uid": "568c7da0ed2f4d985ebb3a7d1d615d02", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "apr_id": "ce9b8159342d83eb0dfe533c041fad52", "difficulty": 1000, "tags": ["strings", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.5686900958466453, "equal_cnt": 9, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 9, "bug_source_code": "use std::collections::HashMap;\nuse std::io::stdin;\nfn main() {\n let mut text = String::new();\n stdin().read_line(&mut text).unwrap();\n text.clear();\n stdin().read_line(&mut text).unwrap();\n let text = text.trim();\n println!(\"{}\", find_distinct_lc(text))\n}\n\nfn find_distinct_lc(text: &str) -> u8 {\n let mut hash: HashMap = HashMap::new();\n let mut counter = 0;\n for i in text.chars() {\n match i {\n 'a'..='z' => match hash.get(&i) {\n Some(_) => (),\n _ => {\n hash.insert(i, true);\n counter += 1;\n ()\n }\n },\n _ => (),\n };\n }\n counter\n}\n", "lang": "Rust", "bug_code_uid": "82dac4e5caa403e7009d13fd1c60db85", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "apr_id": "1306c7aab5bf042bc100fb9382ebf9c7", "difficulty": 1000, "tags": ["strings", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9321100917431193, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn can_eat_row(r: &Vec) -> bool {\n for i in 0..r.len() {\n if !r[i] { return false }\n }\n true\n}\n\nfn can_eat_col(m: &Vec>, j: usize) -> bool {\n for r in m {\n if !r[j] { return false }\n }\n true\n}\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let a: Vec = s.split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let r = a[0];\n let c = a[1];\n\n let mut v: Vec> = vec![];\n\n for _ in 0..r {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n v.push(s.trim().chars()\n .map(|x| x == '.')\n .collect()\n );\n }\n\n let mut eatable_rows = vec![];\n for i in 0..r as usize {\n if can_eat_row(&v[i]) { eatable_rows.push(i); }\n }\n\n let mut eatable_cols = vec![];\n for j in 0..c as usize {\n if can_eat_col(&v, j) { eatable_cols.push(j); }\n }\n\n let er = eatable_rows.len() as i32;\n let ec = eatable_cols.len() as i32;\n\n if er == 0 || ec == 0 {\n println!(\"0\");\n return;\n }\n\n println!(\"{}\", er*c + ec*(r-er));\n}\n", "lang": "Rust", "bug_code_uid": "d419510900b4f8026b0e2256477de74a", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "apr_id": "0394a290755e61a40beafe7088ee26ea", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9963159106608335, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "#![allow(unused_parens)]\n#![allow(unused_imports)]\n#![allow(non_upper_case_globals)]\n#![allow(non_snake_case)]\n#![allow(unused_mut)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\ntype Vec2 = Vec>;\ntype Vec3 = Vec>>;\n\n#[allow(unused_macros)]\nmacro_rules! invec {\n ( $ t : ty ) => {{\n let mut s = String::new();\n match std::io::stdin().read_line(&mut s) {\n Ok(0) => Vec::<$t>::new(),\n Ok(n) => s\n .trim()\n .split_whitespace()\n .map(|s| s.parse::<$t>().unwrap())\n .collect::>(),\n Err(_) => Vec::<$t>::new(),\n }\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n ($t:ty ;; $n:expr) => {\n (0..$n).map(|_| get!($t ;;)).collect::>()\n };\n}\n\n#[allow(unused_macros)]\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 mut 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\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($next:expr, [$t:tt]) => {\n {\n let len = read_value!($next, usize);\n (0..len).map(|_| read_value!($next, $t)).collect::>()\n }\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\n#[cfg(debug_assertions)]\nmacro_rules! mydbg {\n //($arg:expr) => (dbg!($arg))\n //($arg:expr) => (println!(\"{:?}\",$arg));\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n#[cfg(not(debug_assertions))]\nmacro_rules! mydbg {\n ($($arg:expr),*) => {};\n}\n\nmacro_rules! echo {\n ($($a:expr),*) => {\n $(println!(\"{}\",$a))*\n }\n}\n\nuse std::cmp::*;\nuse std::collections::*;\nuse std::ops::{Add, Div, Mul, Sub};\n\n#[allow(dead_code)]\nstatic INF_I64: i64 = i64::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_I32: i32 = i32::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_USIZE: usize = usize::max_value() / 2;\n#[allow(dead_code)]\nstatic M_O_D: usize = 1000000007;\n#[allow(dead_code)]\nstatic PAI: f64 = 3.1415926535897932;\n\ntrait IteratorExt: Iterator {\n fn toVec(self) -> Vec;\n}\n\nimpl IteratorExt for T {\n fn toVec(self) -> Vec {\n self.collect()\n }\n}\n\ntrait CharExt {\n fn toNum(&self) -> usize;\n fn toAlphabetIndex(&self) -> usize;\n fn toNumIndex(&self) -> usize;\n}\nimpl CharExt for char {\n fn toNum(&self) -> usize {\n return *self as usize;\n }\n fn toAlphabetIndex(&self) -> usize {\n return self.toNum() - 'a' as usize;\n }\n fn toNumIndex(&self) -> usize {\n return self.toNum() - '0' as usize;\n }\n}\n\ntrait VectorExt {\n fn joinToString(&self, s: &str) -> String;\n}\nimpl VectorExt for Vec {\n fn joinToString(&self, s: &str) -> String {\n return self\n .iter()\n .map(|x| x.to_string())\n .collect::>()\n .join(s);\n }\n}\n\ntrait StringExt {\n fn get_reverse(&self) -> String;\n}\nimpl StringExt for String {\n fn get_reverse(&self) -> String {\n self.chars().rev().collect::()\n }\n}\n\ntrait UsizeExt {\n fn pow(&self, n: usize) -> usize;\n}\nimpl UsizeExt for usize {\n fn pow(&self, n: usize) -> usize {\n return ((*self as u64).pow(n as u32)) as usize;\n }\n}\n\n#[derive(Debug, Copy, Clone)]\npub struct ModInt {\n x: i64,\n global_mod: i64,\n}\nimpl ModInt {\n pub fn new(p: i64) -> Self {\n let gm = 998244353;\n let a = (p % gm + gm) % gm;\n return ModInt {\n x: a,\n global_mod: gm,\n };\n }\n pub fn inv(self) -> Self {\n return self.pow(self.global_mod - 2);\n }\n pub fn pow(self, t: i64) -> Self {\n if (t == 0) {\n return ModInt::new(1);\n };\n let mut a = self.pow(t >> 1);\n a = a * a;\n if (t & 1 != 0) {\n a = a * self\n };\n return a;\n }\n}\nimpl Add for ModInt {\n type Output = ModInt;\n fn add(self, other: ModInt) -> ModInt {\n let ret = self.x + other.x;\n return ModInt::new(ret);\n }\n}\nimpl Sub for ModInt {\n type Output = ModInt;\n fn sub(self, other: ModInt) -> ModInt {\n let ret = self.x - other.x;\n return ModInt::new(ret);\n }\n}\nimpl Mul for ModInt {\n type Output = ModInt;\n fn mul(self, other: ModInt) -> ModInt {\n let ret = self.x * other.x;\n return ModInt::new(ret);\n }\n}\nimpl Div for ModInt {\n type Output = ModInt;\n fn div(self, other: ModInt) -> ModInt {\n let ret = self.x * other.inv().x;\n return ModInt::new(ret);\n }\n}\nimpl std::string::ToString for ModInt {\n fn to_string(&self) -> String {\n return self.x.to_string();\n }\n}\npub struct Combination {\n fact: Vec,\n ifact: Vec,\n}\nimpl Combination {\n pub fn new(n: i32) -> Self {\n if n > 3000000 {\n panic!(\"error\");\n }\n let mut fact = vec![ModInt::new(0); (n + 1) as usize];\n let mut ifact = vec![ModInt::new(0); (n + 1) as usize];\n fact[0] = ModInt::new(1);\n for i in 1..n + 1 {\n fact[i as usize] = fact[(i - 1) as usize] * ModInt::new(i as i64)\n }\n ifact[n as usize] = fact[n as usize].inv();\n for i in (1..n + 1).rev() {\n ifact[(i - 1) as usize] = ifact[i as usize] * ModInt::new(i as i64)\n }\n let a = Combination {\n fact: fact,\n ifact: ifact,\n };\n return a;\n }\n #[macro_use]\n pub fn gen(&mut self, n: i32, k: i32) -> ModInt {\n if (k < 0 || k > n) {\n return ModInt::new(0 as i64);\n };\n return self.fact[n as usize] * self.ifact[k as usize] * self.ifact[(n - k) as usize];\n }\n pub fn P(&mut self, n: i32, k: i32) -> ModInt {\n self.fact[n as usize] * self.ifact[(n - k) as usize]\n }\n}\n\nfn main() {\n let N = get!(usize);\n\n let mut dp = vec![ModInt::new(1); N + 10];\n\n dp[0] = ModInt::new(0);\n let mut e = vec![ModInt::new(0); N + 1];\n let mut o = vec![ModInt::new(0); N + 1];\n for i in 0..N {\n if i % 2 == 0 {\n dp[i] = dp[i] + o[i];\n e[i + 1] = e[i] + dp[i];\n o[i + 1] = o[i];\n } else {\n dp[i] = dp[i] + e[i];\n o[i + 1] = o[i] + dp[i];\n e[i + 1] = e[i];\n }\n }\n\n mydbg!(dp[N - 1]);\n let mut ans = ModInt::new(1) / ModInt::new(2).pow(N as i64);\n ans = ans * dp[N - 1];\n echo!(ans.to_string());\n}\n", "lang": "Rust", "bug_code_uid": "0686f14ccf3c9e1e0be5f33b56c2232f", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "apr_id": "028bb92786443ee3b305e022d33e342c", "difficulty": 1600, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9567886932344764, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "#![allow(dead_code, unused_imports, unused_macros)]\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 partial_max(v: impl Iterator) -> impl Iterator\nwhere\n T: Default + Ord + Copy,\n{\n v.scan(T::default(), |state, x| {\n *state = max(*state, x);\n Some(*state)\n })\n}\n\nfn partial_min(v: impl Iterator) -> impl Iterator {\n v.scan(std::u64::MAX, |state, x| {\n *state = min(*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\nmacro_rules! max_with {\n ($x: expr, $y: expr) => {\n $x = max($x, $y)\n };\n}\n\nmacro_rules! min_with {\n ($x: expr, $y: expr) => {\n $x = max($x, $y)\n };\n}\n\nfn is_prime(n: u64) -> bool {\n factorize(n).len() == 1\n}\n\nfn combination(n: u64, k: u64, m: u64) -> u64 {\n if n == 0 {\n return 1;\n }\n if k == 0 || k == n {\n return 1;\n }\n let new_k = if n - k < k { n - k } else { k };\n let mut res = 1;\n for i in ((n - new_k) + 1)..=n {\n res *= i;\n res %= m;\n }\n let mut den = 1;\n for i in 1..=(new_k) {\n den *= i;\n den %= m;\n }\n let (_one, inverse, _c) = egcd(den as i64, m as i64);\n let inverse = if inverse < 0 {\n m as i64 + inverse\n } else {\n inverse\n } as u64;\n //println!(\"inv: {} {}\", den, inverse);\n res *= inverse;\n res %= m;\n res\n}\n\nuse std::collections::HashSet;\nuse std::iter::FromIterator;\n\nfn main() -> Result<(), Box> {\n let modulo = 998244353;\n let n = read_usize();\n let mut state = vec![0; n + 1];\n state[0] = 1;\n state[1] = 1;\n state[2] = 1;\n let mut denom = 4;\n for i in 3..=n {\n /*for j in (0..i).rev().step_by(2) {\n state[i] += state[j];\n }*/\n state[i] = state[i - 1] + state[i - 2];\n //println!(\"{:?}\", state);\n state[i] %= modulo;\n denom *= 2;\n denom %= modulo;\n //let (g, _denom_inv, _y) = egcd(denom, state[i]);\n //println!(\"{} {}\", state[i] / g, denom / g);\n }\n //println!(\"{} {}\", state[n], denom);\n if n == 1 {\n denom = 2;\n }\n let (_g, mut denom_inv, _y) = egcd(denom, modulo);\n if denom_inv < 0 {\n denom_inv += modulo;\n }\n println!(\"{}\", (state[n] * denom_inv) % modulo);\n\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "40966ecf4b6d15d78207abb4cd4f554a", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "apr_id": "89988f22417f280995469fc9c476cd91", "difficulty": 1600, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9957918050941307, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "// vim: foldmethod=marker\n// vim: foldmarker={{{,}}}\n\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet};\n#[allow(unused_imports)]\nuse std::io;\n#[allow(unused_imports)]\nuse std::io::Write;\n\n// {{{\n#[allow(unused_macros)]\nmacro_rules! read_non_empty_line {\n () => {{\n let mut inner = String::new();\n while true {\n io::stdin().read_line(&mut inner).unwrap();\n if inner.trim() != \"\" {\n break;\n }\n inner.clear();\n }\n inner\n .trim_end_matches(|c| c == '\\r' || c == '\\n')\n .to_string()\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_multi {\n ($($t: ty),+) => ({\n let line = read_non_empty_line!();\n let mut i = line.trim().split_whitespace();\n (\n $(\n i.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n })\n}\n\n#[allow(unused_macros)]\nmacro_rules! read {\n () => {\n read_non_empty_line!().trim().parse::<_>().unwrap()\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_vec {\n () => {\n read_non_empty_line!()\n .trim()\n .split_whitespace()\n .map(|s| s.parse::<_>().unwrap())\n .collect::>();\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! fmt_vec {\n ($v:ident) => {\n $v.iter()\n .map(|v| format!(\"{}\", v))\n .collect::>()\n .join(\" \")\n };\n}\n\n// }}}\n\nstatic MOD: i64 = 998244353;\n\nfn pow(n: i64, x: i64) -> i64 {\n if x == 0 {\n return 1;\n }\n if n == 1 {\n return 1;\n }\n let h = pow(n, x / 2);\n let mut v = (h * h) % MOD;\n if x % 2 == 1 {\n v = (v * n) % MOD;\n }\n v\n}\n\nfn inv(x: i64) -> i64 {\n pow(x, MOD - 2)\n}\n\nfn solve(writer: &mut io::BufWriter) {\n let n: usize = read!();\n let mut r: Vec = vec![0; n + 1 as usize];\n\n r[0] = 1;\n r[1] = 1;\n r[2] = 1;\n for i in 3..n + 1 {\n r[i] = (r[i - 1] + r[i - 2]) % MOD;\n }\n writeln!(writer, \"{}\", (r[n] * inv(pow(2, n as i64))) % MOD).unwrap();\n}\n\nfn main() {\n let mut writer = io::BufWriter::new(io::stdout());\n // let t: usize = read!();\n // for _ in 0..t {\n solve(&mut writer);\n // }\n}\n", "lang": "Rust", "bug_code_uid": "a24576df4e1bb40ef25d34c7c64cdf62", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "apr_id": "6d4eba03295df76eba2395b2d98d18f0", "difficulty": 1600, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.999790838736666, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "/*\n date : 2020 / 5 / 5\n author : quickn (quickn.ga)\n email : quickwshell@gmail.com\n*/\n\nuse std::io::{self, BufWriter, Write};\n\nmod scanner {\n use std::{io, str};\n /* https://github.com/EbTech/rust-algorithms */\n\n /// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts\n /// **REQUIRES** Rust 1.34 or higher\n pub struct UnsafeScanner {\n reader: R,\n buf_str: Vec,\n buf_iter: str::SplitAsciiWhitespace<'static>,\n }\n\n impl UnsafeScanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buf_str: Vec::new(),\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}\n\nconst MOD: i64 = 998244353;\n\nfn pow_mod(a: i64, x: i64) -> i64 {\n let (mut r, mut a_t, mut x_t) = (1, a, x);\n while x_t != 0 {\n if (x_t & 1) == 1 {\n r *= a_t;\n r %= MOD;\n }\n a_t *= a_t;\n a_t %= MOD;\n x_t >>= 1;\n }\n r\n}\n\nfn mod_inv(a: i64) -> i64 {\n pow_mod(a, MOD-2)\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let (mut scan, mut sout) = (\n scanner::UnsafeScanner::new(stdin.lock()),\n BufWriter::new(stdout.lock()),\n );\n let n: i64 = scan.token();\n let mut dp: Vec = vec![0;(n+1) as usize];\n let mut inv2 = mod_inv(2);\n dp[0] = 1;\n dp[1] = inv2;\n dp[2] = (dp[1]*inv2)%MOD;\n for i in 3..=(n as usize) {\n dp[i] = (((dp[i-1]*inv2)%MOD) + ((dp[i-2]*pow_mod(inv2, 2))%MOD))%MOD;\n }\n writeln!(sout, \"{}\", dp[n as usize]).ok();\n}\n", "lang": "Rust", "bug_code_uid": "0b588ec882d0776b51b7cbb3017fac62", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "apr_id": "54e47bd790c5150ab35fc5685150a760", "difficulty": 1600, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9959700633275763, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "// 2018-10-14 22:34\nfn main() {\n let v1: Vec = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim()\n .split(\" \")\n .map(|s| s.parse::().unwrap())\n .collect()\n };\n let v2: Vec = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim()\n .split(\" \")\n .map(|s| s.parse::().unwrap())\n .collect()\n };\n let n: i32 = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().parse().unwrap()\n };\n\n let n1 = (v1.iter().sum::() as f32 / 5.0).ceil() as i32;\n let n2 = (v2.iter().sum::() as f32 / 5.0).ceil() as i32;\n println!(\"{}\", if n1 + n1 <= n { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "6a348b1314cbc431ba38a85869f6e47a", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "apr_id": "d476896d2b21371705409cce03115464", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8788927335640139, "equal_cnt": 7, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n\n}\nfn _main() {\n let mut scan = Scan::new();\n let sum1: usize = scan.next_n(3).iter().sum();\n let sum2: usize = scan.next_n(3).iter().sum();\n let minsum = sum1.min(sum2);\n let n: usize = scan.next();\n let valid = sum1+sum2 == 0 || n>=2 || minsum==0 && n==1;\n println!(\"{}\", if valid {\"YES\"} else {\"NO\"});\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "557ab3df333e5d4ddb399c598fac110d", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "apr_id": "45095f5cdbd428c44dda0383d78d208d", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8990291262135922, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let mut arr: [i16; 101] = [0; 101];\n let mut inp = String::with_capacity(300);\n for _ in 1..3 {\n stdin().read_line(&mut inp).unwrap();\n }\n let mut i: usize;\n for num in inp.split_whitespace() {\n i = num.parse().unwrap();\n arr[i] += 1;\n }\n let mut max = arr[0];\n i = 1;\n while i < arr.len() {\n if arr[i] > max {\n max = arr[i];\n }\n i += 1;\n }\n println!(\"{}\",max);\n}\n", "lang": "Rust", "bug_code_uid": "372a904b82393530adcdbddc966b19aa", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "apr_id": "f7455ccf27db9a5f3cadf6db3caf84b2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9907407407407407, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut kbd = String::new();\n\n io::stdin().read_line(&mut kbd).expect(\"WHY!\");\n\n let kbd:u32 = kbd.trim().parse().expect(\"WHY!\");\n\n if kbd > 0 {\n println!(\"25\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "97aee341502963c630a75192ee7a3d1d", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "apr_id": "0a67ba3f6a18070e42d82171e08c4a8a", "difficulty": 800, "tags": ["number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.09553158705701079, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn read_integer_line() -> u32 {\n let mut n = String::new();\n io::stdin()\n .read_line(&mut n)\n .expect(\"failed to read input.\");\n let n: u32 = n.trim().parse().expect(\"invalid input\");\n n\n}\n\nfn modpow(base: u32, expo: u32, modulo: u32) -> u32 {\n if expo == 0 {\n return 1;\n }\n let partial = modpow(base, expo / 2, modulo);\n let ans = (partial * partial) % modulo;\n if expo % 2 == 0 {\n ans\n }\n else {\n (ans * base) % modulo\n }\n}\n\nfn main() {\n let n = read_integer_line();\n let ans = modpow(5, n, 100);\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "9c025b149d8b08274810cc53c77f4308", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "apr_id": "dc65ccfc4925bde8cadf4b6d80fe5e59", "difficulty": 800, "tags": ["number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.5213082259663032, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "/*\n Geometry, math - https://codeforces.com/problemset/problem/1369/A\n Completed: 4/7/20 14:06\n*/\n\nuse std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n\n let input = input.trim().parse::().unwrap();\n\n // This is so retarded\n if input > 55 {\n println!(\"25\");\n }\n\n let power: u128 = 5_u128.pow(input);\n let power_to_string = power.to_string();\n let mut power_to_string_len = power_to_string.len();\n\n let mut output = String::from(\"\");\n\n for char in power_to_string.chars() {\n if power_to_string_len != 2 {\n power_to_string_len -= 1;\n } else {\n output.push(char);\n }\n }\n\n println!(\"{}\", output);\n\n}", "lang": "Rust", "bug_code_uid": "8dd8368c2559f9d75a847d475737fdb5", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "apr_id": "3c0aedd74d7cf54987c0ec0b02911621", "difficulty": 800, "tags": ["number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.7343460540941089, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n#[allow(unused_imports)]\nuse std::collections::{HashMap,HashSet,VecDeque};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let n = readln!(i32);\n if n < 10 {\n println!(\"{}\",(0..n).fold(1,|x,_|(x*5)%100));\n } else {\n let mut a : Vec = Vec::new();\n a.push(1);\n let mut start : i32 = -1;\n let mut length : i32 = -1;\n let mut i = 1;\n while start < 0 {\n let z = a.len();\n let zz = (a[z-1]*5)%100;\n a.push(zz);\n for j in 0..z {\n if a[j] == a[z] {\n start = j as i32;\n length = ((z+1) as i32 - start) as i32;\n break;\n }\n }\n }\n println!(\"{:?}\",a);\n println!(\"{}\",a[(n-start) as usize % length as usize]);\n }\n}\n", "lang": "Rust", "bug_code_uid": "cde34ccf6431cfa74d8d0650a811729f", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "apr_id": "90b541f93dfbd6ca22d4e34466083100", "difficulty": 800, "tags": ["number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5610738255033557, "equal_cnt": 15, "replace_cnt": 10, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 14, "bug_source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let (mut x, mut y, mut z) = readln!(i32, i32, i32);\n let (mut a, mut b, mut c) = readln!(i32, i32, i32);\n\n let result = if a < x {\n false\n } else {\n a -= x;\n x = 0;\n\n if c >= z {\n c -= z;\n z = 0;\n\n y <= a + b + c\n } else {\n z -= c;\n c = 0;\n y + z <= a + b\n }\n };\n\n println!(\"{}\", if result { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "a8f4132ca047c2f03fac9150e760becd", "src_uid": "d54201591f7284da5e9ce18984439f4e", "apr_id": "68fc5ce6035a9ab37347e86b8f9f5da5", "difficulty": 800, "tags": ["greedy", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8276677505172924, "equal_cnt": 25, "replace_cnt": 11, "delete_cnt": 5, "insert_cnt": 9, "fix_ops_cnt": 25, "bug_source_code": " #[allow(unused_imports)]\nuse std::cmp::{min,max};\n//const INF: i32 = 0x3f3f3f3f;\n\nstruct Scanner {\n buffer: std::collections::VecDeque\n}\n\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n buffer: std::collections::VecDeque::new()\n }\n }\n\n fn next(&mut self) -> T {\n while self.buffer.is_empty() {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).ok();\n self.buffer = input.split_whitespace()\n .map(ToString::to_string).collect();\n }\n let front = self.buffer.pop_front().unwrap();\n front.parse::().ok().unwrap()\n }\n}\n\nfn gcd(mut a: i64, mut b: i64) -> i64 {\n while b > 0 {\n a %= b;\n let tmp = a;\n a = b;\n b = tmp;\n }\n a\n}\n\nfn lcm(a: i64, b: i64) -> i64 {\n a / gcd(a, b) * b\n}\n\nfn solution() {\n let mut scanner = Scanner::new();\n let n: i64 = scanner.next();\n let k: i64 = scanner.next();\n let a: i64 = scanner.next();\n let b: i64 = scanner.next();\n\n let mut x = std::i64::MAX;\n let mut y = 0;\n for s in [-a, a].iter() {\n for i in 0..n {\n let p = i * k;\n for s2 in [p - b, p + b].iter() {\n let mut l = s2 - s;\n if l <= 0 {\n l += n * k;\n }\n let m = lcm(l, n * k);\n x = std::cmp::min(x, m / l);\n y = std::cmp::max(y, m / l);\n }\n }\n }\n println!(\"{} {}\", x, y);\n}\n\nfn main() {\n std::thread::Builder::new().stack_size(50 << 20)\n .spawn(solution).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "46a8a37c0215606ad7254f7e5bf47bf2", "src_uid": "5bb4adff1b332f43144047955eefba0c", "apr_id": "831e65ff4bfa19544318cd4ab46f8b3a", "difficulty": 1700, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9382022471910112, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn ok(x: u64) -> bool {\n let test = x | (x - 1);\n test & (test + 1) == 0\n}\n\nfn solve() {\n let n = parse_line!(u64);\n let mut result = n - 1;\n while n % result != 0 || !ok(result) {\n result -= 1;\n }\n println!(\"{}\", result)\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang": "Rust", "bug_code_uid": "4436e149b0e2fed4c4ab066c66ebe038", "src_uid": "339246a1be81aefe19290de0d1aead84", "apr_id": "c260a52b674d065bdc74523c8453dac6", "difficulty": 1000, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9968354430379747, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n let mut x = 0;\n\n io::stdin().read_line(&mut s).unwrap;\n\n for ch in s.chars() {\n if ch == '4' || ch == '7' {\n x += 1;\n }\n }\n\n if x == 4 || x == 7 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "cf4bcaff48a37694077f208c942e772c", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "apr_id": "1ff1b3d3e830efc7b3a207ece15c47ba", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.4294478527607362, "equal_cnt": 8, "replace_cnt": 6, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 8, "bug_source_code": "use std::io::*;\n\nfn read(i: &mut StdinLock) -> T {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let inputs: String = read(sin);\n\n for c in inputs.as_str().chars() {\n match c {\n '4' | '7' => (),\n _ => {\n println!(\"NO\");\n return;\n }\n }\n }\n\n println!(\"YES\");\n}\n", "lang": "Rust", "bug_code_uid": "b9aa4aff499f4101e5778d41793da6e0", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "apr_id": "4b00ceec04e88c59c480c43bb544fcb1", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5742806811509101, "equal_cnt": 15, "replace_cnt": 10, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 15, "bug_source_code": "use std::io;\n\nfn main() {\n let (len,num)=input();\n let mut sum=0;\n for i in 1..len+1{\n if part(num,i)==7 || part(num,i)==4{\n sum+=1\n }\n }\n let mut con=false;\n while sum>0{\n let x=sum%10;\n if x!=7 && x!=4{\n con=true;\n }sum/=10\n }if con==false{\n println!(\"YES\");\n }else{\n println!(\"NO\");\n }\n \n}\n\nfn read() -> String{\n let mut input=String::new();\n io::stdin().read_line(&mut input).expect(\"unable to read\");\n input.trim().to_string()\n}\n\nfn input() -> (i32,i32){\n let inp=read();\n (inp.len() as i32,inp.parse::().expect(\"Failed to parse\"))\n /*let list: Vec<_>=inp.split_whitespace().collect();\n let qu: Vec<_>=read().chars().collect();\n (list[0].parse::().expect(\"Failed to parse\"),\n list[1].parse::().expect(\"Failed to parse\"),qu)*/\n}\nfn part(n:i32,i: i32) -> i32{\n n%10_i32.pow(i as u32)/10_i32.pow((i-1) as u32)\n}", "lang": "Rust", "bug_code_uid": "1b9c4edc9728821712ad5c112af44875", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "apr_id": "2df66d6bda8099d706fa479113c0df6d", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6411149825783972, "equal_cnt": 10, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 10, "bug_source_code": "use std::collections::HashSet;\n\nfn main() {\n let set: HashSet = read_line().chars().collect();\n match set.iter().find(|c| \"01235689\".find(**c) != None) {\n Some(_) => {println!(\"NO\")},\n None => {println!(\"YES\")}\n }\n\n}\n\nfn read_line() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Ошибка чтения\");\n\n input.trim().to_string()\n}", "lang": "Rust", "bug_code_uid": "2d47c45707a4ff039c197d216fe9b850", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "apr_id": "4bfda47ec879dbab8a7b348ab02fbed8", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.2938530734632684, "equal_cnt": 8, "replace_cnt": 6, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 9, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_int() -> T{\n read_str().parse::().ok().expect(\"Error\")\n}\n\nfn read_vec(split_char: char) -> Vec {\n read_str()\n .split(split_char)\n .map(|value| value.parse::().ok().expect(\"Error\"))\n .collect()\n}\n\nfn read_tuple() -> (T, T) {\n let buffer: Vec = read_vec(' ');\n (buffer[0], buffer[1])\n}\n\nfn main() {\n let mut minimum_capacity: u32 = 0;\n let mut current_capacity: u32 = 0;\n for _ in 0..read_int::() {\n let (a, b): (u32, u32) = read_tuple();\n current_capacity = current_capacity - a + b;\n minimum_capacity = std::cmp::max(minimum_capacity, current_capacity);\n }\n println!(\"{}\", minimum_capacity);\n}", "lang": "Rust", "bug_code_uid": "d093804418aea4294901447ea8a491c9", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "apr_id": "bb14e1f6e4ac341665919de83fa703a0", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8692699490662139, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 5, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let mut buf = String::new();\n let _ = stdin().read_line(&mut buf);\n let mut ans = true;\n for i in buf.trim_end().chars() {\n ans = ans && i == '4' || ans && i == '7';\n }\n println!(\"{}\", if ans { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "a6b5d82fbb7d458a92d97d5c800101bd", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "apr_id": "5292b4fc39532cedcefd9fd3c17e4ade", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4086146682188591, "equal_cnt": 21, "replace_cnt": 14, "delete_cnt": 3, "insert_cnt": 4, "fix_ops_cnt": 21, "bug_source_code": "use std::process::Command;\nfn main() {\n let mut x: i32 = fetch_user_input(\"X: \".to_string());\n let y: i32 = fetch_user_input(\"Y: \".to_string());\n x = calculate_number(x, y);\n println!(\"{}\", x);\n let _ = Command::new(\"cmd.exe\").arg(\"/c\").arg(\"pause\").status();\n}\nfn calculate_number(mut x: i32, y: i32) -> i32 {\n for _i in 0..y {\n if x % 10 == 0 {\n x = x / 10;\n } else {\n x -= 1;\n }\n }\n x\n}\nfn fetch_user_input(input_text: String) -> i32 {\n println!(\"{}\", input_text);\n use std::io::stdin;\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"input error\");\n input.trim().parse().unwrap()\n}\n", "lang": "Rust", "bug_code_uid": "431e0a9a0498211eee9fbfa013cfb43c", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "aebfbd815c4f95f554b5fd907dd6c782", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9912195121951219, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input).expect(\"Bad reading\");\n\n let v: Vec<&str> = input.split(\" \").collect();\n \n let mut num: i16 = match v[0].trim().parse() {\n Ok(i) => i,\n Err(_) => 0\n };\n\n let mut times: i16 = match v[1].trim().parse() {\n Ok(i) => i,\n Err(_) => 0\n };\n\n while times > 0 {\n let last = num % 10;\n\n num = match last {\n 0 => num / 10,\n _ => num - 1,\n };\n\n times -= 1;\n };\n\n\n println!(\"{}\", num);\n}", "lang": "Rust", "bug_code_uid": "53ff37b7494156ad40d2471e38a48891", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "df84010180d347171a79cf83446de3a1", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.2628398791540785, "equal_cnt": 11, "replace_cnt": 9, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 11, "bug_source_code": "use std::io;\nuse std::boxed::Box;\n\nfn input() -> Result> {\n let mut ret = String::new();\n io::stdin().read_line(&mut ret)?;\n Ok(ret)\n}\n\nfn main() {\n let mut n: i32 = input().unwrap().trim().parse().unwrap();\n let k: i32 = input().unwrap().trim().parse().unwrap();\n\n for _ in 0..k {\n if n % 10 == 0 {\n n /= 10;\n } else {\n n -= 1;\n }\n }\n\n println!(\"{}\", n);\n}", "lang": "Rust", "bug_code_uid": "17c7b8de80685fb5a88cee5ce4351c59", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "19bfa5acda9365def5d4806719f3fb96", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.17102473498233214, "equal_cnt": 13, "replace_cnt": 10, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 14, "bug_source_code": "fn main() {\n println!(\"4\");\n}\n\n// use std::io;\n// use std::boxed::Box;\n\n// fn input() -> Result> {\n// let mut ret = String::new();\n// io::stdin().read_line(&mut ret)?;\n// Ok(ret)\n// }\n\n// fn main() {\n// let mut n: i32 = input().unwrap().trim().parse().unwrap();\n// let k: i32 = input().unwrap().trim().parse().unwrap();\n\n// for _ in 0..k {\n// if n % 10 == 0 {\n// n /= 10;\n// } else {\n// n -= 1;\n// }\n// }\n\n// println!(\"{}\", n);\n// }", "lang": "Rust", "bug_code_uid": "53601e2ffdc19969da561e54ae72ed2c", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "19bfa5acda9365def5d4806719f3fb96", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9981515711645101, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nfn main() {\n let mut i = String::new();\n\n io::stdin().read_line(&mut i)\n .expect(\"Oh no N\");\n\n let s: Vec<&str> = i.split(\" \").collect();\n let mut n: u32 = match s[0].trim().parse() {\n Ok(num) => num,\n Err(_) => panic!(\"Oh no\"),\n };\n let k: u32 = match s[1].trim().parse() {\n Ok(num) => num,\n Err(_) => panic!(\"Oh no\"),\n };\n\n\n for _ in 0..k {\n if n % 10 == 0 {\n n /= 10;\n } else {\n n -= k;\n }\n }\n println!(\"{}\", n );\n}\n", "lang": "Rust", "bug_code_uid": "7abee532eea69798dc85b8e6d9002786", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "4ddb38d4bd858042a821f6665cc65a3a", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9813160032493907, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_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": "Rust", "bug_code_uid": "6bc2546da3669ea525a501c251bbd5b8", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "0f238e8d0bd1923e9181c1ecd9f279a2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9929639401934917, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::io::prelude::*;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut input).expect(\"fail read!\");\n let words: Vec<&str> = input.split_whitespace().collect();\n let mut n: usize = words[0].trim().parse().unwrap();\n let k: usize = words[1].trim().parse().unwrap();\n\n println!(\"{}\", div(n, k));\n}\n\nfn div(mut n: usize, mut k: usize) -> usize {\n while k > 0 {\n let rem = n % 10;\n if rem < k {\n k = k - rem - 1;\n n = n / 10;\n } else {\n n = n - k;\n k = 0;\n }\n }\n n\n}\n\nmacro_rules! decl_error{\n ($($error:ident)*) => {\n #[derive(Debug)]\n pub enum Error {\n $($error($error),)*\n }\n\n $(\n impl From<$error> for Error {\n fn from(e: $error) -> Self {\n Error::$error(e)\n }\n }\n )*\n\n pub type Result = std::result::Result;\n }\n\n}\n\nmod error {\n use std::io::Error as StdError;\n use std::num::ParseIntError;\n decl_error!(StdError ParseIntError);\n}\n\nuse error::Result;\n", "lang": "Rust", "bug_code_uid": "900464248bece430414a1e01b94aa940", "src_uid": "064162604284ce252b88050b4174ba55", "apr_id": "0f238e8d0bd1923e9181c1ecd9f279a2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5894080996884735, "equal_cnt": 16, "replace_cnt": 9, "delete_cnt": 0, "insert_cnt": 6, "fix_ops_cnt": 15, "bug_source_code": "use std::io;\n\nfn main() {\n let n: usize = {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input.trim().parse().unwrap()\n };\n\n let a: Vec = {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input.split_whitespace().map(|k| k.parse().unwrap()).collect()\n };\n\n let a: Vec<_> = a.into_iter().skip_while(|&k| k == 0).collect();\n\n let a: Vec<_> = a.into_iter().rev().skip_while(|&k| k == 1).collect();\n\n let ans = a.iter().filter(|&&k| k == 0).count();\n\n let ans = std::cmp::min(ans, a.len() - ans);\n\n println!(\"{}\", n - ans);\n}\n", "lang": "Rust", "bug_code_uid": "bf59a9d9e4bf6ee53a2817af5d48723c", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "apr_id": "2ad13c31f1b5361616599c1dd1fb92f9", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8989113530326595, "equal_cnt": 24, "replace_cnt": 15, "delete_cnt": 2, "insert_cnt": 7, "fix_ops_cnt": 24, "bug_source_code": "// ____ _ _ _ _\n// | _ \\ _ _ ___| |_ ___ _ __ | |_ ___ _ __ ___ _ __ | | __ _| |_ ___\n// | |_) | | | / __| __| / __| '_ \\ | __/ _ \\ '_ ` _ \\| '_ \\| |/ _` | __/ _ \\\n// | _ <| |_| \\__ \\ |_ | (__| |_) | | || __/ | | | | | |_) | | (_| | || __/\n// |_| \\_\\\\__,_|___/\\__| \\___| .__/___\\__\\___|_| |_| |_| .__/|_|\\__,_|\\__\\___|\n// |_| |_____| |_|\n\n//https://github.com/manta1130/Competitive_Programming_Template_Rust\n\n#[macro_use]\nmod input {\n\n use std;\n use std::io;\n\n const SPLIT_DELIMITER: char = ' ';\n\n #[macro_export]\n #[allow(unused_macros)]\n macro_rules! input {\n ( $($x:expr ),*) => {\n {\n let temp_str = input_line_str();\n let mut split_result_iter = temp_str.split_whitespace();\n $(\n let buf_split_result = split_result_iter.next();\n let buf_split_result = buf_split_result.unwrap();\n ($x) = buf_split_result.parse().unwrap();\n )*\n }\n };\n}\n\n #[allow(dead_code)]\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(dead_code)]\n pub fn p(t: T)\n where\n T: std::fmt::Display,\n {\n println!(\"{}\", t);\n }\n\n #[allow(dead_code)]\n pub fn input_vector2d(line: usize) -> Vec>\n where\n T: std::str::FromStr,\n {\n let mut v: Vec> = Vec::new();\n\n for _ in 0..line {\n let vec_line = input_vector();\n v.push(vec_line);\n }\n v\n }\n\n #[allow(dead_code)]\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(dead_code)]\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\nuse input::*;\n#[allow(unused_imports)]\nuse std::io::{stdout, BufWriter, Write};\n\nfn main() {\n let (a, b, c, d): (u64, u64, u64, u64);\n input!(a, b, c, d);\n\n let mut ans = 0_u64;\n for y in b..=c {\n let t = std::cmp::min(d, b + y - 1);\n let f = std::cmp::min(std::cmp::max(c, a + y - 1), t);\n ans += ((t - f + 1) * (t - f + 2)) / 2;\n //dbg!(t, f, t, ((t - f + 1) * (t - f + 2)) / 2);\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "3b0d4f9e0112039757d0f30a743e5e44", "src_uid": "4f92791b9ec658829f667fcea1faee01", "apr_id": "4d773e2acee40f10d04c043505faf4c9", "difficulty": 1800, "tags": ["binary search", "math", "implementation", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5783027121609798, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\n#[allow(unused_macros)]\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nuse std::io::Write;\n\nfn solve(writer: &mut std::io::BufWriter) {\n let (a, b, c, d) = parse_line!(u64, u64, u64, u64);\n let mut result = 0;\n for x in a..=b {\n if c - b + 1 >= x {\n if d - c + 1 >= x {\n result += x * (x + 1) / 2;\n }else{\n let grow = d - c + 1;\n let fix = x - grow;\n result += grow * (grow + 1) / 2 + fix * grow;\n }\n }else{\n if d - c + 1 >= x {\n let min = c - b + 1;\n result += (x - min + 1 + x) * min / 2;\n }else{\n if d - b + 1 >= x {\n let grow = d - b + 1 - x;\n result += (d - c + 1 - grow + d - c) * grow / 2 +\n (d - c + 1 - grow) * (d - c + 1);\n }else{\n result += (c - b + 1) * (d - c + 1);\n }\n let min = c - b + 1;\n let grow = d - c + 1 - min;\n let fix = min - grow;\n result += grow * (grow + 1) / 2 + fix * grow;\n }\n }\n }\n writeln!(writer, \"{}\", result).unwrap();\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n let mut writer = std::io::BufWriter::new(std::io::stdout());\n for _ in 0..tests {\n solve(&mut writer);\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "fa0eff7ead25eab8d74d1f2f336a7527", "src_uid": "4f92791b9ec658829f667fcea1faee01", "apr_id": "b2494e12644b0efa3086e8b882c323cb", "difficulty": 1800, "tags": ["binary search", "math", "implementation", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999951580884133, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "const SEQ: &str = \"0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627\";\n\nfn user_input(mut r: R) -> usize {\n let mut input = String::new();\n r.read_to_string(&mut input).unwrap();\n input.split_whitespace().nth(0).unwrap().parse::().unwrap()\n}\n\nfn main() {\n let idx = user_input(std::io::stdin());\n println!(\"{}\", SEQ.chars().nth(idx).unwrap());\n}", "lang": "Rust", "bug_code_uid": "119d6e678688440c382887c57ca11954", "src_uid": "1503d761dd4e129fb7c423da390544ff", "apr_id": "7a93896883f1cc5678808dbea1a7f316", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9070034443168772, "equal_cnt": 10, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 6, "fix_ops_cnt": 9, "bug_source_code": "use std::io::{self, BufRead};\nuse std::collections::VecDeque;\n\nstruct DigitSequenceIterator {\n inner: usize,\n state: VecDeque,\n}\n\nimpl Iterator for DigitSequenceIterator {\n type Item = char;\n\n fn next(&mut self) -> Option {\n if self.state.len() == 0 {\n self.state.extend(self.inner.to_string().chars());;\n\n self.inner += 1;\n }\n\n self.state.pop_front()\n }\n}\n\nimpl DigitSequenceIterator {\n pub fn new() -> Self {\n DigitSequenceIterator {\n inner: 0,\n state: VecDeque::new(),\n }\n }\n\n pub fn skip(mut to_skip: usize) -> impl Iterator {\n let mut inner = 0;\n\n if to_skip >= 10 {\n inner = 10;\n to_skip -= 10;\n }\n\n let mut can_jump = 90;\n while to_skip > can_jump {\n to_skip -= can_jump;\n inner *= 10;\n\n can_jump *= 10;\n }\n\n DigitSequenceIterator {\n inner,\n state: VecDeque::new(),\n }.skip(to_skip)\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n let line = stdin.lock().lines().next().expect(\"input\").expect(\"UTF-8\");\n let index: usize = line.parse().expect(\"Numeric value\");\n\n println!(\"{}\", DigitSequenceIterator::skip(index).next().unwrap());\n}\n\n#[test]\nfn vectors() {\n let in_out = [(7, '7'), (21, '5'), (192, '0'), (417, '5')];\n\n for (i, o) in &in_out {\n let test = DigitSequenceIterator::skip(*i).next().unwrap();\n assert_eq!(test, *o,\n \"{}th should be {}, but got {}\", i, *o, test);\n }\n}\n", "lang": "Rust", "bug_code_uid": "9e60e50efde7690981fec27f226da1f5", "src_uid": "1503d761dd4e129fb7c423da390544ff", "apr_id": "756fb4f018b556c8384e66cacff5cccd", "difficulty": 1800, "tags": ["divide and conquer", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9264166901606992, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 5, "bug_source_code": "use std::io::{self, BufRead};\nuse std::collections::VecDeque;\n\nstruct DigitSequenceIterator {\n inner: usize,\n state: VecDeque,\n}\n\nimpl Iterator for DigitSequenceIterator {\n type Item = char;\n\n fn next(&mut self) -> Option {\n if self.state.len() == 0 {\n self.state.extend(self.inner.to_string().chars());;\n\n self.inner += 1;\n }\n\n self.state.pop_front()\n }\n}\n\nimpl DigitSequenceIterator {\n pub fn new() -> Self {\n DigitSequenceIterator {\n inner: 0,\n state: VecDeque::new(),\n }\n }\n\n pub fn skip(mut to_skip: usize) -> impl Iterator {\n let mut inner = 0;\n\n if to_skip >= 10 {\n inner = 10;\n to_skip -= 10;\n }\n\n let mut can_jump = 90;\n let mut i = 2;\n while to_skip > can_jump * i {\n to_skip -= can_jump * i;\n inner *= 10;\n\n can_jump *= 10;\n i += 1;\n }\n\n DigitSequenceIterator {\n inner,\n state: VecDeque::new(),\n }.skip(to_skip)\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n let line = stdin.lock().lines().next().expect(\"input\").expect(\"UTF-8\");\n let index: usize = line.parse().expect(\"Numeric value\");\n\n println!(\"{}\", DigitSequenceIterator::skip(index).next().unwrap());\n}\n\n#[test]\nfn vectors() {\n let in_out = [(7, '7'), (21, '5'), (188, '9'), (192, '0'), (417, '5')];\n\n for (i, o) in &in_out {\n let test = DigitSequenceIterator::skip(*i).next().unwrap();\n assert_eq!(test, *o,\n \"{}th should be {}, but got {}\", i, *o, test);\n }\n}\n", "lang": "Rust", "bug_code_uid": "a823fca7bf416abb7e946c2ac3b9f0a9", "src_uid": "1503d761dd4e129fb7c423da390544ff", "apr_id": "756fb4f018b556c8384e66cacff5cccd", "difficulty": 1800, "tags": ["divide and conquer", "implementation", "binary search"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4513715710723192, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 8, "bug_source_code": "type Res = u64;\n\nfn main() {\n let k = {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n input.trim().parse::().unwrap()\n };\n\n // counter for digits\n let mut n: Res = 0;\n // Potential number of the digit we search\n let mut d: Res = 1;\n while n Res {\n let mut res = 0;\n let mut temp = 1;\n while temp <= inp {\n res += 1;\n temp *= 10\n }\n res\n}", "lang": "Rust", "bug_code_uid": "0caf6c14c19a86a6f20311548b1952ec", "src_uid": "1503d761dd4e129fb7c423da390544ff", "apr_id": "d55fe9dfe78c6f3f5aa9c71bb1fd9e27", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.08185789836744078, "equal_cnt": 49, "replace_cnt": 8, "delete_cnt": 16, "insert_cnt": 25, "fix_ops_cnt": 49, "bug_source_code": "type Res = u64;\n\nfn main() {\n let k = {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n input.trim().parse::().unwrap()\n };\n\n let result = solve(k);\n\n println!(\"{}\", result);\n\n}\n\nfn int_len(inp: Res) -> Res {\n match inp {\n 0..=9 => 1,\n 10..=99 => 2,\n 100..=999 => 3,\n 1000..=9999 => 4,\n 10000..=99999 => 5,\n 100000..=999999 => 6,\n 1000000..=9999999 => 7,\n 10000000..=99999999 => 8,\n 100000000..=999999999 => 9,\n 1000000000..=9999999999 => 10,\n 10000000000..=99999999999 => 11,\n 100000000000..=999999999999 => 12,\n 1000000000000..=9999999999999 => 13,\n _ => unreachable!()\n }\n}\n\nfn solve(k: Res) -> char {\n // counter for digits\n let mut n: Res = 1;\n // Potential number of the digit we search\n let mut d: Res = 1;\n while n().unwrap()\n };\n let result = solve(k);\n println!(\"{}\", result);\n\n\n}\n\nfn int_len_0(inp: Res) -> Res {\n debug_assert!(inp > 0);\n (inp as f32).log10() as Res + 1\n}\n\nfn int_len_(inp: Res) -> Res {\n if inp == 0 {\n return 1;\n }\n\n let mut res = 0;\n let mut temp = 1;\n while temp <= inp {\n res += 1;\n temp *= 10\n }\n res\n}\n\nfn int_len(inp: Res) -> Res {\n //debug_assert!(0 <= inp);\n //debug_assert!(inp <= MAX_INP);\n \n match inp {\n 1000000000000..=9999999999999 => 13,\n 100000000000..=999999999999 => 12,\n 10000000000..=99999999999 => 11,\n 1000000000..=9999999999 => 10,\n 100000000..=999999999 => 9,\n 10000000..=99999999 => 8,\n 1000000..=9999999 => 7,\n 100000..=999999 => 6,\n 10000..=99999 => 5,\n 1000..=9999 => 4,\n 100..=999 => 3,\n 10..=99 => 2,\n 0..=9 => 1,\n _ => unreachable!()\n }\n}\n\nfn solve(k: Res) -> char {\n let lookup = [(1,1),(1000000008,123456790),(2000000007,234567901),(3000000006,345679012),(4000000005,456790123),(5000000004,567901234),(6000000003,679012345),(7000000002,790123456),(8000000001,901234567),(9000000009,1011111111),(10000000009,1111111111),(11000000009,1211111111),(12000000009,1311111111),(13000000009,1411111111),(14000000009,1511111111),(15000000009,1611111111),(16000000009,1711111111),(17000000009,1811111111),(18000000009,1911111111),(19000000009,2011111111),(20000000009,2111111111),(21000000009,2211111111),(22000000009,2311111111),(23000000009,2411111111),(24000000009,2511111111),(25000000009,2611111111),(26000000009,2711111111),(27000000009,2811111111),(28000000009,2911111111),(29000000009,3011111111),(30000000009,3111111111),(31000000009,3211111111),(32000000009,3311111111),(33000000009,3411111111),(34000000009,3511111111),(35000000009,3611111111),(36000000009,3711111111),(37000000009,3811111111),(38000000009,3911111111),(39000000009,4011111111),(40000000009,4111111111),(41000000009,4211111111),(42000000009,4311111111),(43000000009,4411111111),(44000000009,4511111111),(45000000009,4611111111),(46000000009,4711111111),(47000000009,4811111111),(48000000009,4911111111),(49000000009,5011111111),(50000000009,5111111111),(51000000009,5211111111),(52000000009,5311111111),(53000000009,5411111111),(54000000009,5511111111),(55000000009,5611111111),(56000000009,5711111111),(57000000009,5811111111),(58000000009,5911111111),(59000000009,6011111111),(60000000009,6111111111),(61000000009,6211111111),(62000000009,6311111111),(63000000009,6411111111),(64000000009,6511111111),(65000000009,6611111111),(66000000009,6711111111),(67000000009,6811111111),(68000000009,6911111111),(69000000009,7011111111),(70000000009,7111111111),(71000000009,7211111111),(72000000009,7311111111),(73000000009,7411111111),(74000000009,7511111111),(75000000009,7611111111),(76000000009,7711111111),(77000000009,7811111111),(78000000009,7911111111),(79000000009,8011111111),(80000000009,8111111111),(81000000009,8211111111),(82000000009,8311111111),(83000000009,8411111111),(84000000009,8511111111),(85000000009,8611111111),(86000000009,8711111111),(87000000009,8811111111),(88000000009,8911111111),(89000000009,9011111111),(90000000009,9111111111),(91000000009,9211111111),(92000000009,9311111111),(93000000009,9411111111),(94000000009,9511111111),(95000000009,9611111111),(96000000009,9711111111),(97000000009,9811111111),(98000000009,9911111111),(99000000010,10010101010),(100000000000,10101010100),(101000000001,10191919191),(102000000002,10282828282),(103000000003,10373737373),(104000000004,10464646464),(105000000005,10555555555),(106000000006,10646464646),(107000000007,10737373737),(108000000008,10828282828),(109000000009,10919191919),(110000000010,11010101010),(111000000000,11101010100),(112000000001,11191919191),(113000000002,11282828282),(114000000003,11373737373),(115000000004,11464646464),(116000000005,11555555555),(117000000006,11646464646),(118000000007,11737373737),(119000000008,11828282828),(120000000009,11919191919),(121000000010,12010101010),(122000000000,12101010100),(123000000001,12191919191),(124000000002,12282828282),(125000000003,12373737373),(126000000004,12464646464),(127000000005,12555555555),(128000000006,12646464646),(129000000007,12737373737),(130000000008,12828282828),(131000000009,12919191919),(132000000010,13010101010),(133000000000,13101010100),(134000000001,13191919191),(135000000002,13282828282),(136000000003,13373737373),(137000000004,13464646464),(138000000005,13555555555),(139000000006,13646464646),(140000000007,13737373737),(141000000008,13828282828),(142000000009,13919191919),(143000000010,14010101010),(144000000000,14101010100),(145000000001,14191919191),(146000000002,14282828282),(147000000003,14373737373),(148000000004,14464646464),(149000000005,14555555555),(150000000006,14646464646),(151000000007,14737373737),(152000000008,14828282828),(153000000009,14919191919),(154000000010,15010101010),(155000000000,15101010100),(156000000001,15191919191),(157000000002,15282828282),(158000000003,15373737373),(159000000004,15464646464),(160000000005,15555555555),(161000000006,15646464646),(162000000007,15737373737),(163000000008,15828282828),(164000000009,15919191919),(165000000010,16010101010),(166000000000,16101010100),(167000000001,16191919191),(168000000002,16282828282),(169000000003,16373737373),(170000000004,16464646464),(171000000005,16555555555),(172000000006,16646464646),(173000000007,16737373737),(174000000008,16828282828),(175000000009,16919191919),(176000000010,17010101010),(177000000000,17101010100),(178000000001,17191919191),(179000000002,17282828282),(180000000003,17373737373),(181000000004,17464646464),(182000000005,17555555555),(183000000006,17646464646),(184000000007,17737373737),(185000000008,17828282828),(186000000009,17919191919),(187000000010,18010101010),(188000000000,18101010100),(189000000001,18191919191),(190000000002,18282828282),(191000000003,18373737373),(192000000004,18464646464),(193000000005,18555555555),(194000000006,18646464646),(195000000007,18737373737),(196000000008,18828282828),(197000000009,18919191919),(198000000010,19010101010),(199000000000,19101010100),(200000000001,19191919191),(201000000002,19282828282),(202000000003,19373737373),(203000000004,19464646464),(204000000005,19555555555),(205000000006,19646464646),(206000000007,19737373737),(207000000008,19828282828),(208000000009,19919191919),(209000000010,20010101010),(210000000000,20101010100),(211000000001,20191919191),(212000000002,20282828282),(213000000003,20373737373),(214000000004,20464646464),(215000000005,20555555555),(216000000006,20646464646),(217000000007,20737373737),(218000000008,20828282828),(219000000009,20919191919),(220000000010,21010101010),(221000000000,21101010100),(222000000001,21191919191),(223000000002,21282828282),(224000000003,21373737373),(225000000004,21464646464),(226000000005,21555555555),(227000000006,21646464646),(228000000007,21737373737),(229000000008,21828282828),(230000000009,21919191919),(231000000010,22010101010),(232000000000,22101010100),(233000000001,22191919191),(234000000002,22282828282),(235000000003,22373737373),(236000000004,22464646464),(237000000005,22555555555),(238000000006,22646464646),(239000000007,22737373737),(240000000008,22828282828),(241000000009,22919191919),(242000000010,23010101010),(243000000000,23101010100),(244000000001,23191919191),(245000000002,23282828282),(246000000003,23373737373),(247000000004,23464646464),(248000000005,23555555555),(249000000006,23646464646),(250000000007,23737373737),(251000000008,23828282828),(252000000009,23919191919),(253000000010,24010101010),(254000000000,24101010100),(255000000001,24191919191),(256000000002,24282828282),(257000000003,24373737373),(258000000004,24464646464),(259000000005,24555555555),(260000000006,24646464646),(261000000007,24737373737),(262000000008,24828282828),(263000000009,24919191919),(264000000010,25010101010),(265000000000,25101010100),(266000000001,25191919191),(267000000002,25282828282),(268000000003,25373737373),(269000000004,25464646464),(270000000005,25555555555),(271000000006,25646464646),(272000000007,25737373737),(273000000008,25828282828),(274000000009,25919191919),(275000000010,26010101010),(276000000000,26101010100),(277000000001,26191919191),(278000000002,26282828282),(279000000003,26373737373),(280000000004,26464646464),(281000000005,26555555555),(282000000006,26646464646),(283000000007,26737373737),(284000000008,26828282828),(285000000009,26919191919),(286000000010,27010101010),(287000000000,27101010100),(288000000001,27191919191),(289000000002,27282828282),(290000000003,27373737373),(291000000004,27464646464),(292000000005,27555555555),(293000000006,27646464646),(294000000007,27737373737),(295000000008,27828282828),(296000000009,27919191919),(297000000010,28010101010),(298000000000,28101010100),(299000000001,28191919191),(300000000002,28282828282),(301000000003,28373737373),(302000000004,28464646464),(303000000005,28555555555),(304000000006,28646464646),(305000000007,28737373737),(306000000008,28828282828),(307000000009,28919191919),(308000000010,29010101010),(309000000000,29101010100),(310000000001,29191919191),(311000000002,29282828282),(312000000003,29373737373),(313000000004,29464646464),(314000000005,29555555555),(315000000006,29646464646),(316000000007,29737373737),(317000000008,29828282828),(318000000009,29919191919),(319000000010,30010101010),(320000000000,30101010100),(321000000001,30191919191),(322000000002,30282828282),(323000000003,30373737373),(324000000004,30464646464),(325000000005,30555555555),(326000000006,30646464646),(327000000007,30737373737),(328000000008,30828282828),(329000000009,30919191919),(330000000010,31010101010),(331000000000,31101010100),(332000000001,31191919191),(333000000002,31282828282),(334000000003,31373737373),(335000000004,31464646464),(336000000005,31555555555),(337000000006,31646464646),(338000000007,31737373737),(339000000008,31828282828),(340000000009,31919191919),(341000000010,32010101010),(342000000000,32101010100),(343000000001,32191919191),(344000000002,32282828282),(345000000003,32373737373),(346000000004,32464646464),(347000000005,32555555555),(348000000006,32646464646),(349000000007,32737373737),(350000000008,32828282828),(351000000009,32919191919),(352000000010,33010101010),(353000000000,33101010100),(354000000001,33191919191),(355000000002,33282828282),(356000000003,33373737373),(357000000004,33464646464),(358000000005,33555555555),(359000000006,33646464646),(360000000007,33737373737),(361000000008,33828282828),(362000000009,33919191919),(363000000010,34010101010),(364000000000,34101010100),(365000000001,34191919191),(366000000002,34282828282),(367000000003,34373737373),(368000000004,34464646464),(369000000005,34555555555),(370000000006,34646464646),(371000000007,34737373737),(372000000008,34828282828),(373000000009,34919191919),(374000000010,35010101010),(375000000000,35101010100),(376000000001,35191919191),(377000000002,35282828282),(378000000003,35373737373),(379000000004,35464646464),(380000000005,35555555555),(381000000006,35646464646),(382000000007,35737373737),(383000000008,35828282828),(384000000009,35919191919),(385000000010,36010101010),(386000000000,36101010100),(387000000001,36191919191),(388000000002,36282828282),(389000000003,36373737373),(390000000004,36464646464),(391000000005,36555555555),(392000000006,36646464646),(393000000007,36737373737),(394000000008,36828282828),(395000000009,36919191919),(396000000010,37010101010),(397000000000,37101010100),(398000000001,37191919191),(399000000002,37282828282),(400000000003,37373737373),(401000000004,37464646464),(402000000005,37555555555),(403000000006,37646464646),(404000000007,37737373737),(405000000008,37828282828),(406000000009,37919191919),(407000000010,38010101010),(408000000000,38101010100),(409000000001,38191919191),(410000000002,38282828282),(411000000003,38373737373),(412000000004,38464646464),(413000000005,38555555555),(414000000006,38646464646),(415000000007,38737373737),(416000000008,38828282828),(417000000009,38919191919),(418000000010,39010101010),(419000000000,39101010100),(420000000001,39191919191),(421000000002,39282828282),(422000000003,39373737373),(423000000004,39464646464),(424000000005,39555555555),(425000000006,39646464646),(426000000007,39737373737),(427000000008,39828282828),(428000000009,39919191919),(429000000010,40010101010),(430000000000,40101010100),(431000000001,40191919191),(432000000002,40282828282),(433000000003,40373737373),(434000000004,40464646464),(435000000005,40555555555),(436000000006,40646464646),(437000000007,40737373737),(438000000008,40828282828),(439000000009,40919191919),(440000000010,41010101010),(441000000000,41101010100),(442000000001,41191919191),(443000000002,41282828282),(444000000003,41373737373),(445000000004,41464646464),(446000000005,41555555555),(447000000006,41646464646),(448000000007,41737373737),(449000000008,41828282828),(450000000009,41919191919),(451000000010,42010101010),(452000000000,42101010100),(453000000001,42191919191),(454000000002,42282828282),(455000000003,42373737373),(456000000004,42464646464),(457000000005,42555555555),(458000000006,42646464646),(459000000007,42737373737),(460000000008,42828282828),(461000000009,42919191919),(462000000010,43010101010),(463000000000,43101010100),(464000000001,43191919191),(465000000002,43282828282),(466000000003,43373737373),(467000000004,43464646464),(468000000005,43555555555),(469000000006,43646464646),(470000000007,43737373737),(471000000008,43828282828),(472000000009,43919191919),(473000000010,44010101010),(474000000000,44101010100),(475000000001,44191919191),(476000000002,44282828282),(477000000003,44373737373),(478000000004,44464646464),(479000000005,44555555555),(480000000006,44646464646),(481000000007,44737373737),(482000000008,44828282828),(483000000009,44919191919),(484000000010,45010101010),(485000000000,45101010100),(486000000001,45191919191),(487000000002,45282828282),(488000000003,45373737373),(489000000004,45464646464),(490000000005,45555555555),(491000000006,45646464646),(492000000007,45737373737),(493000000008,45828282828),(494000000009,45919191919),(495000000010,46010101010),(496000000000,46101010100),(497000000001,46191919191),(498000000002,46282828282),(499000000003,46373737373),(500000000004,46464646464),(501000000005,46555555555),(502000000006,46646464646),(503000000007,46737373737),(504000000008,46828282828),(505000000009,46919191919),(506000000010,47010101010),(507000000000,47101010100),(508000000001,47191919191),(509000000002,47282828282),(510000000003,47373737373),(511000000004,47464646464),(512000000005,47555555555),(513000000006,47646464646),(514000000007,47737373737),(515000000008,47828282828),(516000000009,47919191919),(517000000010,48010101010),(518000000000,48101010100),(519000000001,48191919191),(520000000002,48282828282),(521000000003,48373737373),(522000000004,48464646464),(523000000005,48555555555),(524000000006,48646464646),(525000000007,48737373737),(526000000008,48828282828),(527000000009,48919191919),(528000000010,49010101010),(529000000000,49101010100),(530000000001,49191919191),(531000000002,49282828282),(532000000003,49373737373),(533000000004,49464646464),(534000000005,49555555555),(535000000006,49646464646),(536000000007,49737373737),(537000000008,49828282828),(538000000009,49919191919),(539000000010,50010101010),(540000000000,50101010100),(541000000001,50191919191),(542000000002,50282828282),(543000000003,50373737373),(544000000004,50464646464),(545000000005,50555555555),(546000000006,50646464646),(547000000007,50737373737),(548000000008,50828282828),(549000000009,50919191919),(550000000010,51010101010),(551000000000,51101010100),(552000000001,51191919191),(553000000002,51282828282),(554000000003,51373737373),(555000000004,51464646464),(556000000005,51555555555),(557000000006,51646464646),(558000000007,51737373737),(559000000008,51828282828),(560000000009,51919191919),(561000000010,52010101010),(562000000000,52101010100),(563000000001,52191919191),(564000000002,52282828282),(565000000003,52373737373),(566000000004,52464646464),(567000000005,52555555555),(568000000006,52646464646),(569000000007,52737373737),(570000000008,52828282828),(571000000009,52919191919),(572000000010,53010101010),(573000000000,53101010100),(574000000001,53191919191),(575000000002,53282828282),(576000000003,53373737373),(577000000004,53464646464),(578000000005,53555555555),(579000000006,53646464646),(580000000007,53737373737),(581000000008,53828282828),(582000000009,53919191919),(583000000010,54010101010),(584000000000,54101010100),(585000000001,54191919191),(586000000002,54282828282),(587000000003,54373737373),(588000000004,54464646464),(589000000005,54555555555),(590000000006,54646464646),(591000000007,54737373737),(592000000008,54828282828),(593000000009,54919191919),(594000000010,55010101010),(595000000000,55101010100),(596000000001,55191919191),(597000000002,55282828282),(598000000003,55373737373),(599000000004,55464646464),(600000000005,55555555555),(601000000006,55646464646),(602000000007,55737373737),(603000000008,55828282828),(604000000009,55919191919),(605000000010,56010101010),(606000000000,56101010100),(607000000001,56191919191),(608000000002,56282828282),(609000000003,56373737373),(610000000004,56464646464),(611000000005,56555555555),(612000000006,56646464646),(613000000007,56737373737),(614000000008,56828282828),(615000000009,56919191919),(616000000010,57010101010),(617000000000,57101010100),(618000000001,57191919191),(619000000002,57282828282),(620000000003,57373737373),(621000000004,57464646464),(622000000005,57555555555),(623000000006,57646464646),(624000000007,57737373737),(625000000008,57828282828),(626000000009,57919191919),(627000000010,58010101010),(628000000000,58101010100),(629000000001,58191919191),(630000000002,58282828282),(631000000003,58373737373),(632000000004,58464646464),(633000000005,58555555555),(634000000006,58646464646),(635000000007,58737373737),(636000000008,58828282828),(637000000009,58919191919),(638000000010,59010101010),(639000000000,59101010100),(640000000001,59191919191),(641000000002,59282828282),(642000000003,59373737373),(643000000004,59464646464),(644000000005,59555555555),(645000000006,59646464646),(646000000007,59737373737),(647000000008,59828282828),(648000000009,59919191919),(649000000010,60010101010),(650000000000,60101010100),(651000000001,60191919191),(652000000002,60282828282),(653000000003,60373737373),(654000000004,60464646464),(655000000005,60555555555),(656000000006,60646464646),(657000000007,60737373737),(658000000008,60828282828),(659000000009,60919191919),(660000000010,61010101010),(661000000000,61101010100),(662000000001,61191919191),(663000000002,61282828282),(664000000003,61373737373),(665000000004,61464646464),(666000000005,61555555555),(667000000006,61646464646),(668000000007,61737373737),(669000000008,61828282828),(670000000009,61919191919),(671000000010,62010101010),(672000000000,62101010100),(673000000001,62191919191),(674000000002,62282828282),(675000000003,62373737373),(676000000004,62464646464),(677000000005,62555555555),(678000000006,62646464646),(679000000007,62737373737),(680000000008,62828282828),(681000000009,62919191919),(682000000010,63010101010),(683000000000,63101010100),(684000000001,63191919191),(685000000002,63282828282),(686000000003,63373737373),(687000000004,63464646464),(688000000005,63555555555),(689000000006,63646464646),(690000000007,63737373737),(691000000008,63828282828),(692000000009,63919191919),(693000000010,64010101010),(694000000000,64101010100),(695000000001,64191919191),(696000000002,64282828282),(697000000003,64373737373),(698000000004,64464646464),(699000000005,64555555555),(700000000006,64646464646),(701000000007,64737373737),(702000000008,64828282828),(703000000009,64919191919),(704000000010,65010101010),(705000000000,65101010100),(706000000001,65191919191),(707000000002,65282828282),(708000000003,65373737373),(709000000004,65464646464),(710000000005,65555555555),(711000000006,65646464646),(712000000007,65737373737),(713000000008,65828282828),(714000000009,65919191919),(715000000010,66010101010),(716000000000,66101010100),(717000000001,66191919191),(718000000002,66282828282),(719000000003,66373737373),(720000000004,66464646464),(721000000005,66555555555),(722000000006,66646464646),(723000000007,66737373737),(724000000008,66828282828),(725000000009,66919191919),(726000000010,67010101010),(727000000000,67101010100),(728000000001,67191919191),(729000000002,67282828282),(730000000003,67373737373),(731000000004,67464646464),(732000000005,67555555555),(733000000006,67646464646),(734000000007,67737373737),(735000000008,67828282828),(736000000009,67919191919),(737000000010,68010101010),(738000000000,68101010100),(739000000001,68191919191),(740000000002,68282828282),(741000000003,68373737373),(742000000004,68464646464),(743000000005,68555555555),(744000000006,68646464646),(745000000007,68737373737),(746000000008,68828282828),(747000000009,68919191919),(748000000010,69010101010),(749000000000,69101010100),(750000000001,69191919191),(751000000002,69282828282),(752000000003,69373737373),(753000000004,69464646464),(754000000005,69555555555),(755000000006,69646464646),(756000000007,69737373737),(757000000008,69828282828),(758000000009,69919191919),(759000000010,70010101010),(760000000000,70101010100),(761000000001,70191919191),(762000000002,70282828282),(763000000003,70373737373),(764000000004,70464646464),(765000000005,70555555555),(766000000006,70646464646),(767000000007,70737373737),(768000000008,70828282828),(769000000009,70919191919),(770000000010,71010101010),(771000000000,71101010100),(772000000001,71191919191),(773000000002,71282828282),(774000000003,71373737373),(775000000004,71464646464),(776000000005,71555555555),(777000000006,71646464646),(778000000007,71737373737),(779000000008,71828282828),(780000000009,71919191919),(781000000010,72010101010),(782000000000,72101010100),(783000000001,72191919191),(784000000002,72282828282),(785000000003,72373737373),(786000000004,72464646464),(787000000005,72555555555),(788000000006,72646464646),(789000000007,72737373737),(790000000008,72828282828),(791000000009,72919191919),(792000000010,73010101010),(793000000000,73101010100),(794000000001,73191919191),(795000000002,73282828282),(796000000003,73373737373),(797000000004,73464646464),(798000000005,73555555555),(799000000006,73646464646),(800000000007,73737373737),(801000000008,73828282828),(802000000009,73919191919),(803000000010,74010101010),(804000000000,74101010100),(805000000001,74191919191),(806000000002,74282828282),(807000000003,74373737373),(808000000004,74464646464),(809000000005,74555555555),(810000000006,74646464646),(811000000007,74737373737),(812000000008,74828282828),(813000000009,74919191919),(814000000010,75010101010),(815000000000,75101010100),(816000000001,75191919191),(817000000002,75282828282),(818000000003,75373737373),(819000000004,75464646464),(820000000005,75555555555),(821000000006,75646464646),(822000000007,75737373737),(823000000008,75828282828),(824000000009,75919191919),(825000000010,76010101010),(826000000000,76101010100),(827000000001,76191919191),(828000000002,76282828282),(829000000003,76373737373),(830000000004,76464646464),(831000000005,76555555555),(832000000006,76646464646),(833000000007,76737373737),(834000000008,76828282828),(835000000009,76919191919),(836000000010,77010101010),(837000000000,77101010100),(838000000001,77191919191),(839000000002,77282828282),(840000000003,77373737373),(841000000004,77464646464),(842000000005,77555555555),(843000000006,77646464646),(844000000007,77737373737),(845000000008,77828282828),(846000000009,77919191919),(847000000010,78010101010),(848000000000,78101010100),(849000000001,78191919191),(850000000002,78282828282),(851000000003,78373737373),(852000000004,78464646464),(853000000005,78555555555),(854000000006,78646464646),(855000000007,78737373737),(856000000008,78828282828),(857000000009,78919191919),(858000000010,79010101010),(859000000000,79101010100),(860000000001,79191919191),(861000000002,79282828282),(862000000003,79373737373),(863000000004,79464646464),(864000000005,79555555555),(865000000006,79646464646),(866000000007,79737373737),(867000000008,79828282828),(868000000009,79919191919),(869000000010,80010101010),(870000000000,80101010100),(871000000001,80191919191),(872000000002,80282828282),(873000000003,80373737373),(874000000004,80464646464),(875000000005,80555555555),(876000000006,80646464646),(877000000007,80737373737),(878000000008,80828282828),(879000000009,80919191919),(880000000010,81010101010),(881000000000,81101010100),(882000000001,81191919191),(883000000002,81282828282),(884000000003,81373737373),(885000000004,81464646464),(886000000005,81555555555),(887000000006,81646464646),(888000000007,81737373737),(889000000008,81828282828),(890000000009,81919191919),(891000000010,82010101010),(892000000000,82101010100),(893000000001,82191919191),(894000000002,82282828282),(895000000003,82373737373),(896000000004,82464646464),(897000000005,82555555555),(898000000006,82646464646),(899000000007,82737373737),(900000000008,82828282828),(901000000009,82919191919),(902000000010,83010101010),(903000000000,83101010100),(904000000001,83191919191),(905000000002,83282828282),(906000000003,83373737373),(907000000004,83464646464),(908000000005,83555555555),(909000000006,83646464646),(910000000007,83737373737),(911000000008,83828282828),(912000000009,83919191919),(913000000010,84010101010),(914000000000,84101010100),(915000000001,84191919191),(916000000002,84282828282),(917000000003,84373737373),(918000000004,84464646464),(919000000005,84555555555),(920000000006,84646464646),(921000000007,84737373737),(922000000008,84828282828),(923000000009,84919191919),(924000000010,85010101010),(925000000000,85101010100),(926000000001,85191919191),(927000000002,85282828282),(928000000003,85373737373),(929000000004,85464646464),(930000000005,85555555555),(931000000006,85646464646),(932000000007,85737373737),(933000000008,85828282828),(934000000009,85919191919),(935000000010,86010101010),(936000000000,86101010100),(937000000001,86191919191),(938000000002,86282828282),(939000000003,86373737373),(940000000004,86464646464),(941000000005,86555555555),(942000000006,86646464646),(943000000007,86737373737),(944000000008,86828282828),(945000000009,86919191919),(946000000010,87010101010),(947000000000,87101010100),(948000000001,87191919191),(949000000002,87282828282),(950000000003,87373737373),(951000000004,87464646464),(952000000005,87555555555),(953000000006,87646464646),(954000000007,87737373737),(955000000008,87828282828),(956000000009,87919191919),(957000000010,88010101010),(958000000000,88101010100),(959000000001,88191919191),(960000000002,88282828282),(961000000003,88373737373),(962000000004,88464646464),(963000000005,88555555555),(964000000006,88646464646),(965000000007,88737373737),(966000000008,88828282828),(967000000009,88919191919),(968000000010,89010101010),(969000000000,89101010100),(970000000001,89191919191),(971000000002,89282828282),(972000000003,89373737373),(973000000004,89464646464),(974000000005,89555555555),(975000000006,89646464646),(976000000007,89737373737),(977000000008,89828282828),(978000000009,89919191919),(979000000010,90010101010),(980000000000,90101010100),(981000000001,90191919191),(982000000002,90282828282),(983000000003,90373737373),(984000000004,90464646464),(985000000005,90555555555),(986000000006,90646464646),(987000000007,90737373737),(988000000008,90828282828),(989000000009,90919191919),(990000000010,91010101010),(991000000000,91101010100),(992000000001,91191919191),(993000000002,91282828282),(994000000003,91373737373),(995000000004,91464646464),(996000000005,91555555555),(997000000006,91646464646),(998000000007,91737373737),(999000000008,91828282828),];\n\n let idx = k / STEP_SIZE;\n let starts = lookup[idx as usize];\n let result = solve_internal(k, starts.0, starts.1);\n result.0\n}\n\nfn solve_internal(k: Res, n: Res, d: Res) -> (char, Res, Res) {\n // counter for digits\n let mut n: Res = n;//1;\n // Potential number of the digit we search\n let mut d: Res = d;//1;\n while n {{\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 input.sk(1);\n if input.bs()[0] == b'm' {\n println!(\"{}\", if n <= 29 {12} else if n <= 30 {11} else {8});\n } else {\n println!(\"{}\", if n == 5 || n == 6 {53} else {52});\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "47082fd4e539942f07b91e8852c1918f", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "apr_id": "ef0abd567d7caa2d086d7fbb8824ef0d", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9958088851634534, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self, Stdin};\nuse std::str::{self, FromStr};\nuse std::error::Error;\n\nfn exec() {\n let mut sc = Scanner::new();\n let n: usize = sc.ne();\n let _: String = sc.ne();\n let hoge: String = sc.ne();\n if hoge == \"week\" {\n let ans = match n {\n val if val <= 2 => 53,\n _ => 52,\n };\n println!(\"{}\", ans);\n } else {\n let ans = match n {\n val if val <= 29 => 12,\n val if val == 30 => 11,\n _ => 7,\n };\n println!(\"{}\", ans);\n }\n}\n\nfn main() {\n const STACK: usize = 16 * 1024 * 1024;\n let _ = std::thread::Builder::new()\n .stack_size(STACK)\n .spawn(|| { exec(); })\n .unwrap()\n .join()\n .unwrap();\n}\n\n#[allow(dead_code)]\nstruct Scanner {\n stdin: Stdin,\n id: usize,\n buf: Vec,\n}\n\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n stdin: io::stdin(),\n id: 0,\n buf: Vec::new(),\n }\n }\n fn next_line(&mut self) -> Option {\n let mut res = String::new();\n match self.stdin.read_line(&mut res) {\n Ok(0) => None,\n Ok(_) => Some(res),\n Err(why) => panic!(\"error in read_line: {}\", why.description()),\n }\n }\n fn next(&mut self) -> Option {\n while self.buf.len() == 0 {\n self.buf = match self.next_line() {\n Some(r) => {\n self.id = 0;\n r.trim().as_bytes().to_owned()\n }\n None => return None,\n };\n }\n let l = self.id;\n assert!(self.buf[l] != b' ');\n let n = self.buf.len();\n let mut r = l;\n while r < n && self.buf[r] != b' ' {\n r += 1;\n }\n let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() {\n Ok(s) => Some(s),\n Err(_) => {\n panic!(\"parse error, {:?}\",\n String::from_utf8(self.buf[l..r].to_owned()))\n }\n };\n while r < n && self.buf[r] == b' ' {\n r += 1;\n }\n if r == n {\n self.buf.clear();\n } else {\n self.id = r;\n }\n res\n }\n fn ne(&mut self) -> T {\n self.next::().unwrap()\n }\n}\n", "lang": "Rust", "bug_code_uid": "c2c185d73d06cc60c289377a6fadd38b", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "apr_id": "41e7d2f1d591397f3078d426890bbd2b", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6823379923761118, "equal_cnt": 17, "replace_cnt": 12, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 16, "bug_source_code": "use std::io::stdin;\nuse std::collections::HashSet;\n\nmacro_rules! readln {\n () => {{ let mut line = String::new(); stdin().read_line(&mut line).unwrap(); line }};\n ($type:ty) => {{ readln!().split_whitespace().next().unwrap().parse::<$type>().unwrap() }};\n (|$type_vec:ty|) => {{ readln!().split_whitespace().map(|it| it.parse().unwrap()).collect::>() }};\n ($($type:ty),*) => {{ let line = readln!(); let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};\n ($($type:ty),*, |$type_vec:ty|) => {{ let line = readln!(); let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse().unwrap()).collect::>(),)}};\n}\n\nfn division(mut n: u64) -> HashSet {\n let mut res = HashSet::new();\n\n if n % 2 == 0 {\n res.insert(2);\n res.insert(n / 2);\n }\n let mut i = 3;\n while i * i <= n {\n if n % i == 0 {\n res.push(i);\n }\n i += 2;\n }\n res\n}\n\nfn main() {\n let n = readln!(u64);\n let divisions = division(n);\n\n if divisions.is_empty() {\n println!(\"{}\", n);\n } else if divisions.len() == 1 {\n println!(\"{}\", divisions[0])\n } else {\n println!(\"1\")\n }\n}", "lang": "Rust", "bug_code_uid": "8685f3f063acbc306acaab6858fad97c", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "apr_id": "d6d31c3c34e283def9f8afc2470116c5", "difficulty": 1500, "tags": ["number theory"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7433406455656534, "equal_cnt": 12, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 6, "fix_ops_cnt": 11, "bug_source_code": "use std::io::stdin;\nuse std::collections::HashSet;\n\nmacro_rules! readln {\n () => {{ let mut line = String::new(); stdin().read_line(&mut line).unwrap(); line }};\n ($type:ty) => {{ readln!().split_whitespace().next().unwrap().parse::<$type>().unwrap() }};\n (|$type_vec:ty|) => {{ readln!().split_whitespace().map(|it| it.parse().unwrap()).collect::>() }};\n ($($type:ty),*) => {{ let line = readln!(); let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};\n ($($type:ty),*, |$type_vec:ty|) => {{ let line = readln!(); let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse().unwrap()).collect::>(),)}};\n}\n\nfn main() {\n let mut n = readln!(u64);\n\n let mut res = HashSet::new();\n\n let copy = n;\n let mut i = 2;\n while n != 1 && i * i <= copy {\n if n % i == 0 {\n n /= i;\n res.insert(i);\n res.insert(copy / i);\n if res.len() == 2 {\n break;\n }\n } else {\n i += 1;\n }\n }\n res.remove(&1);\n\n if res.is_empty() {\n println!(\"{}\", n);\n } else if res.len() == 1 {\n println!(\"{}\", res.iter().next().unwrap());\n } else {\n println!(\"1\")\n }\n}", "lang": "Rust", "bug_code_uid": "1baa8fcafb21cea40141260647e09904", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "apr_id": "d6d31c3c34e283def9f8afc2470116c5", "difficulty": 1500, "tags": ["number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7760152284263959, "equal_cnt": 16, "replace_cnt": 9, "delete_cnt": 0, "insert_cnt": 6, "fix_ops_cnt": 15, "bug_source_code": "use std::io::stdin;\nuse std::collections::HashSet;\n\nmacro_rules! readln {\n () => {{ let mut line = String::new(); stdin().read_line(&mut line).unwrap(); line }};\n ($type:ty) => {{ readln!().split_whitespace().next().unwrap().parse::<$type>().unwrap() }};\n (|$type_vec:ty|) => {{ readln!().split_whitespace().map(|it| it.parse().unwrap()).collect::>() }};\n ($($type:ty),*) => {{ let line = readln!(); let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};\n ($($type:ty),*, |$type_vec:ty|) => {{ let line = readln!(); let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse().unwrap()).collect::>(),)}};\n}\n\nfn division(mut n: u64) -> HashSet {\n let mut res = HashSet::new();\n\n let mut i = 2;\n while n != 1 {\n if n % i == 0 {\n n /= i;\n res.insert(i);\n } else {\n i += 1;\n }\n }\n res.remove(&1);\n res\n}\n\nfn main() {\n let n = readln!(u64);\n let divisions = division(n);\n\n if divisions.is_empty() {\n println!(\"{}\", n);\n } else if divisions.len() == 1 {\n println!(\"{}\", divisions.iter().next().unwrap());\n } else {\n println!(\"1\")\n }\n}", "lang": "Rust", "bug_code_uid": "44b0190b5c2e02aa89b4c7d143a6fe83", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "apr_id": "d6d31c3c34e283def9f8afc2470116c5", "difficulty": 1500, "tags": ["number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999782182531039, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_imports)]\n#![allow(non_snake_case, unused)]\n\nuse std::cmp::*;\nuse std::collections::*;\nuse std::ops::*;\n\nmacro_rules! eprint {\n\t($($t:tt)*) => {{\n\t\tuse ::std::io::Write;\n\t\tlet _ = write!(::std::io::stderr(), $($t)*);\n\t}};\n}\nmacro_rules! eprintln {\n\t() => { eprintln!(\"\"); };\n\t($($t:tt)*) => {{\n\t\tuse ::std::io::Write;\n\t\tlet _ = writeln!(::std::io::stderr(), $($t)*);\n\t}};\n}\nmacro_rules! dbg {\n\t($v:expr) => {{\n\t\tlet val = $v;\n\t\teprintln!(\"[{}:{}] {} = {:?}\", file!(), line!(), stringify!($v), val);\n\t\tval\n\t}}\n}\n\nmacro_rules! mat {\n\t($($e:expr),*) => { Vec::from(vec![$($e),*]) };\n\t($($e:expr,)*) => { Vec::from(vec![$($e),*]) };\n\t($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };\n\t($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };\n}\n\nmacro_rules! ok {\n\t($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {\n\t\t$a$([$i])*.$f($($t),*)\n\t};\n\t($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {\n\t\tlet t = $e;\n\t\tok!($a$([$i])*.$f($($es),*)$(@$t)*@t)\n\t} };\n}\n\npub fn readln() -> String {\n\tlet mut line = String::new();\n\t::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!(\"{}\", e));\n\tline\n}\n\nmacro_rules! read {\n\t($($t:tt),*; $n:expr) => {{\n\t\tlet stdin = ::std::io::stdin();\n\t\tlet ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {\n\t\t\tlet line = line.unwrap();\n\t\t\tlet mut it = line.split_whitespace();\n\t\t\t_read!(it; $($t),*)\n\t\t}).collect::>();\n\t\tret\n\t}};\n\t($($t:tt),*) => {{\n\t\tlet line = readln();\n\t\tlet mut it = line.split_whitespace();\n\t\t_read!(it; $($t),*)\n\t}};\n}\n\nmacro_rules! _read {\n\t($it:ident; [char]) => {\n\t\t_read!($it; String).chars().collect::>()\n\t};\n\t($it:ident; [u8]) => {\n\t\tVec::from(_read!($it; String).into_bytes())\n\t};\n\t($it:ident; usize1) => {\n\t\t$it.next().unwrap_or_else(|| panic!(\"input mismatch\")).parse::().unwrap_or_else(|e| panic!(\"{}\", e)) - 1\n\t};\n\t($it:ident; [usize1]) => {\n\t\t$it.map(|s| s.parse::().unwrap_or_else(|e| panic!(\"{}\", e)) - 1).collect::>()\n\t};\n\t($it:ident; [$t:ty]) => {\n\t\t$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!(\"{}\", e))).collect::>()\n\t};\n\t($it:ident; $t:ty) => {\n\t\t$it.next().unwrap_or_else(|| panic!(\"input mismatch\")).parse::<$t>().unwrap_or_else(|e| panic!(\"{}\", e))\n\t};\n\t($it:ident; $($t:tt),+) => {\n\t\t($(_read!($it; $t)),*)\n\t};\n}\n\npub fn main() {\n\tlet _ = ::std::thread::Builder::new().name(\"run\".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();\n}\n\nconst MOD: u32 = 1_000_000_007;\nconst INF: i64 = std::i64::MAX;\n\npub trait SetMinMax {\n\tfn setmin(&mut self, v: Self) -> bool;\n\tfn setmax(&mut self, v: Self) -> bool;\n}\nimpl SetMinMax for T where T: PartialOrd {\n\tfn setmin(&mut self, v: T) -> bool {\n\t\t*self > v && { *self = v; true }\n\t}\n\tfn setmax(&mut self, v: T) -> bool {\n\t\t*self < v && { *self = v; true }\n\t}\n}\n\nuse std::cmp::Ordering;\n\n/// Equivalent to std::lowerbound and std::upperbound in c++\npub trait BinarySearch {\n fn lower_bound(&self, x: &T) -> usize;\n fn upper_bound(&self, x: &T) -> usize;\n}\n\nimpl BinarySearch for [T] {\n // 配列a内のv以上の最小のindex\n fn lower_bound(&self, x: &T) -> usize {\n let mut low = 0;\n let mut high = self.len();\n\n while low != high {\n let mid = (low + high) / 2;\n match self[mid].cmp(x) {\n Ordering::Less => {\n low = mid + 1;\n }\n Ordering::Equal | Ordering::Greater => {\n high = mid;\n }\n }\n }\n low\n }\n // 配列a内のvより大きいの最小のindex\n fn upper_bound(&self, x: &T) -> usize {\n let mut low = 0;\n let mut high = self.len();\n\n while low != high {\n let mid = (low + high) / 2;\n match self[mid].cmp(x) {\n Ordering::Less | Ordering::Equal => {\n low = mid + 1;\n }\n Ordering::Greater => {\n high = mid;\n }\n }\n }\n low\n }\n}\n\nfn swap(a: usize, b: usize, sv: &mut [char], tv: &mut [char]) {\n\tlet tmp = sv[a];\n\tsv[a] = tv[b];\n\ttv[b] = tmp;\n}\n\nfn solve() {\n\tlet n = read!(i64);\n\tlet mut sum = 0;\n\tlet mut v = vec![];\n\tif n==1 {\n\t\tprintln!(\"{}\", 1);\n\t\treturn;\n\t}\n\tfor i in 2..((n as f64).sqrt() as i64+1) {\n\t\tif n%i==0 {\n\t\t\tsum+=2;\n\t\t\tv.push(i);\n\t\t\tv.push(n%i);\n\t\t}\n\t}\n\tif sum==0 {\n\t\tprintln!(\"{}\", n);\n\t\treturn;\n\t}\n\tlet mi = v[0];\n\tlet mut flag = true;\n\tfor &i in &v {\n\t\tif i%mi!=0 {flag=false;}\n\t}\n\tif !flag {println!(\"{}\", 1);}\n\telse{ println!(\"{}\", mi);}\n\n}\n\nfn run() {\n solve();\n}", "lang": "Rust", "bug_code_uid": "981c3219ebef0048f32f8341a2d4ba7c", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "apr_id": "aeba9ed4878afe9c11792ecfc7538cc5", "difficulty": 1500, "tags": ["number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9890424011434016, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "#![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, 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// -----------------------------------------------\n// Framework \n// -----------------------------------------------\n\n#[allow(unused_macros)]\nmacro_rules! read {\n ([$t:ty] ; $n:expr) =>\n ((0..$n).map(|_| read!([$t])).collect::>());\n ($($t:ty),+ ; $n:expr) =>\n ((0..$n).map(|_| read!($($t),+)).collect::>());\n ([$t:ty]) =>\n (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>());\n ($t:ty) =>\n (rl().parse::<$t>().unwrap());\n ($($t:ty),*) => {{\n let buf = rl();\n let mut w = buf.split_whitespace();\n ($(w.next().unwrap().parse::<$t>().unwrap()),*)\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($arg:expr),*) => {\n #[cfg(debug_assertions)]\n $(writeln!(stderr(), \"{} = {:?}\", stringify!($arg), $arg).unwrap());*\n };\n}\n\n#[allow(dead_code)]\nfn rl() -> String {\n let mut buf = String::new();\n stdin().read_line(&mut buf).unwrap();\n buf.trim_right().to_owned()\n}\n\ntrait IteratorExt: Iterator + Sized {\n fn vec(self) -> Vec {\n self.collect()\n }\n}\n\nimpl IteratorExt for T {}\n\n// -----------------------------------------------\n// Solution\n// -----------------------------------------------\n\nfn solve(N: i64, K: i64) -> i64 {\n let r = min(N + 1, K);\n let l = min(r, K / 2 + 1);\n r - l\n}\n\nfn main() {\n println!(\"{}\", 0)\n}\n\n#[cfg(test)]\nmod tests {\n use super::solve;\n\n #[test]\n fn tests() {\n assert_eq!(solve(8, 5), 2);\n assert_eq!(solve(8, 15), 1);\n assert_eq!(solve(7, 20), 0);\n assert_eq!(solve(1000000000000, 1000000000001), 500000000000);\n\n assert_eq!(solve(1, 1), 0);\n assert_eq!(solve(2, 3), 1);\n }\n}\n", "lang": "Rust", "bug_code_uid": "539815d5019278c44ff56532f1c94182", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "apr_id": "4c4c252635d80a13075b99aace4bae25", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9870801033591732, "equal_cnt": 1, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_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": "Rust", "bug_code_uid": "a81c4bfa3363e1bfbe0c445d0fbfa5f6", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "apr_id": "fb72ced3f639110808333dd8a305021c", "difficulty": 2000, "tags": ["dp"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.7046037116784579, "equal_cnt": 126, "replace_cnt": 115, "delete_cnt": 2, "insert_cnt": 8, "fix_ops_cnt": 125, "bug_source_code": "// This code is licensed under the terms of Apache-2.0 or MIT License , at your choice.\n\nuse crate::comprog_lib::scanner::Scanner;\nuse std::cmp::min;\nuse std::io::{self, Read, Write};\npub fn solve(read: R, out: &mut W) -> io::Result<()> {\n\tlet mut sc = Scanner::from(read);\n\tlet n = sc.usize();\n\tlet s = sc.token();\n\tlet mut next = vec![[n; 26]; n + 1];\n\tfor i in (0..n).rev() {\n\t\tnext[i] = next[i + 1].clone();\n\t\tnext[i][(s[i] - b'a') as usize] = i;\n\t}\n\tlet mut dp = vec![vec![std::i32::MAX; n + 1]; n + 1];\n\tfor i in 0..=n {\n\t\tdp[i][i] = 0;\n\t}\n\tfor len in 1..=n {\n\t\tfor l in 0..=n - len {\n\t\t\tlet r = l + len;\n\t\t\tdp[l][r] = (0..26)\n\t\t\t\t.map(|a| {\n\t\t\t\t\tlet mut sum = 0;\n\t\t\t\t\tlet mut k = l as isize - 1;\n\t\t\t\t\twhile k < r as isize {\n\t\t\t\t\t\tlet nk = min(next[(k + 1) as usize][a], r);\n\t\t\t\t\t\tsum += dp[(k + 1) as usize][nk];\n\t\t\t\t\t\tk = nk as isize;\n\t\t\t\t\t}\n\t\t\t\t\tsum\n\t\t\t\t})\n\t\t\t\t.min()\n\t\t\t\t.unwrap() + 1;\n\t\t}\n\t}\n\tlet ans = dp[0][n];\n\twriteln!(out, \"{}\", ans)?;\n\tOk(())\n}\nfn main() {\n\tlet stdin = io::stdin();\n\tlet mut stdout = io::BufWriter::new(io::stdout());\n\tsolve(stdin.lock(), &mut stdout).unwrap_or_else(|e| {\n\t\tdrop(stdout);\n\t\twriteln!(io::stderr(), \"{}\", e).ok();\n\t\tstd::process::exit(1);\n\t});\n}\nmod comprog_lib {\n\t// comprog_lib-0.1.0\n\tpub mod scan_buf {\n\t\tuse std::io::{self, Read};\n\t\t#[derive(Debug, Clone)]\n\t\tpub struct ScanBuf {\n\t\t\tbuf: Vec,\n\t\t\tpos: usize,\n\t\t\tend: usize,\n\t\t}\n\t\t#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]\n\t\tpub struct ScanRange(pub usize, pub usize);\n\t\timpl ScanRange {\n\t\t\tpub fn slice(self, buf: &ScanBuf) -> &[u8] {\n\t\t\t\t&buf.buf[self.0..self.1]\n\t\t\t}\n\t\t}\n\t\timpl ScanBuf {\n\t\t\tpub fn new(initial_capacity: usize) -> Self {\n\t\t\t\tScanBuf { buf: vec![0; initial_capacity], pos: 0, end: 0 }\n\t\t\t}\n\t\t\tpub fn scan bool>(\n\t\t\t\t&mut self,\n\t\t\t\tmut reader: R,\n\t\t\t\tmut pred: P,\n\t\t\t) -> io::Result {\n\t\t\t\tlet start = self.pos;\n\t\t\t\tloop {\n\t\t\t\t\tif self.pos >= self.end {\n\t\t\t\t\t\tif self.pos >= self.buf.len() {\n\t\t\t\t\t\t\tlet new_len = std::cmp::max(self.buf.len(), 1) * 2;\n\t\t\t\t\t\t\tself.buf.resize(new_len, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tself.end += match reader.read(&mut self.buf[self.pos..]) {\n\t\t\t\t\t\t\tOk(0) => return Ok(ScanRange(start, self.pos)),\n\t\t\t\t\t\t\tOk(n) => n,\n\t\t\t\t\t\t\tErr(ref e) if e.kind() == io::ErrorKind::Interrupted => 0,\n\t\t\t\t\t\t\tErr(e) => return Err(e),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tassert!(self.end <= self.buf.len());\n\t\t\t\t\twhile self.pos < self.end {\n\t\t\t\t\t\tif pred(self.buf[self.pos]) {\n\t\t\t\t\t\t\treturn Ok(ScanRange(start, self.pos));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tself.pos += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpub mod scanner {\n\t\tuse crate::comprog_lib::scan_buf::{ScanBuf, ScanRange};\n\t\tuse std::io::Read;\n\t\t#[derive(Debug, Clone)]\n\t\tpub struct Scanner {\n\t\t\tpub reader: R,\n\t\t\tpub buf: ScanBuf,\n\t\t}\n\t\timpl From for Scanner {\n\t\t\tfn from(r: R) -> Self {\n\t\t\t\tScanner { reader: r, buf: ScanBuf::new(8192) }\n\t\t\t}\n\t\t}\n\t\timpl Scanner {\n\t\t\tpub fn scan bool>(&mut self, pred: P) -> ScanRange {\n\t\t\t\tself.buf.scan(&mut self.reader, pred).unwrap()\n\t\t\t}\n\t\t\tfn digits(&mut self) -> (bool, &[u8]) {\n\t\t\t\tself.scan(|b| b' ' < b);\n\t\t\t\tlet mut negative = false;\n\t\t\t\tself.scan(|b| b != b'-' || std::mem::replace(&mut negative, true));\n\t\t\t\tlet digits = self.scan(|b| b < b'0' || b'9' < b);\n\t\t\t\t(negative, digits.slice(&self.buf))\n\t\t\t}\n\t\t\tpub fn token_range(&mut self) -> ScanRange {\n\t\t\t\tself.scan(|b| b' ' < b);\n\t\t\t\tself.scan(|b| b <= b' ')\n\t\t\t}\n\t\t\tpub fn token(&mut self) -> Vec {\n\t\t\t\tself.token_range().slice(&self.buf).to_owned()\n\t\t\t}\n\t\t}\n\t\tmacro_rules! impl_scan_int { ($($name:ident),*) => { impl Scanner { $( #[allow(unused)] pub fn $name(&mut self) -> $name { let (neg, digits) = self.digits(); if !neg { digits.iter().fold($name::default(), |x, b| x * 10 + $name::from(b - b'0')) } else { digits.iter().fold($name::default(), |x, b| x * 10 - $name::from(b - b'0')) } } )* } } }\n\t\timpl_scan_int!(u32, i32, u64, i64, usize);\n\t}\n}\n// Module comprog_lib contains code from comprog_lib licensed under Apache-2.0 OR MIT\n// Built by comprog-0.1.0 \n", "lang": "Rust", "bug_code_uid": "94297998a8b95d068e9da5be1b41c08e", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "apr_id": "cc8c61c16f022cdfb483084f2c3a6970", "difficulty": 2000, "tags": ["dp"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7827116637063352, "equal_cnt": 11, "replace_cnt": 4, "delete_cnt": 5, "insert_cnt": 1, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\nuse std::cmp;\n\n\nfn main() {\n let n = read_one::();\n let an = read::();\n let mut ans = 100_000_000;\n\n for i in 0..n { // i + 1 : x_th\n let mut tmp = 0;\n for j in 0..n { // a_th\n tmp += (an[j] as isize) * ((i as isize - j as isize).abs()) * 2; // x -> a\n tmp += (an[j] * j * 2) as isize; // a -> ground\n tmp += (2 * i) as isize; // g -> x\n }\n ans = cmp::min(ans, tmp);\n }\n println!(\"{}\", ans);\n}\n\n\n#[allow(dead_code)]\nfn read() -> Vec\nwhere T:\n std::str::FromStr,\n T::Err: std::fmt::Debug {\n\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.split_whitespace()\n .map(|s| s.trim().parse().unwrap())\n .collect()\n}\n\n#[allow(dead_code)]\nfn read_one() -> T\nwhere T:\n std::str::FromStr,\n T::Err: std::fmt::Debug {\n\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n}", "lang": "Rust", "bug_code_uid": "fd1329c4e02f3dcb717087d465cda092", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "apr_id": "13b3dcd3218629974def5b63e9437feb", "difficulty": 1000, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8257956448911222, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer)\n .expect(\"Failed to read line\");\n\n let num_letters = buffer.trim().parse::().expect(\"parse error\");\n if num_letters == 0 {\n println!(\"0\");\n return;\n }\n\n buffer.clear();\n io::stdin().read_line(&mut buffer)\n .expect(\"Failed to read line\");\n let splitted: Vec<&str> = buffer.trim().split('W').collect();\n\n for sub in &splitted {\n if sub.len() != 0 {\n print!(\"{} \", sub.len());\n }\n }\n println!();\n}\n", "lang": "Rust", "bug_code_uid": "9e686f15e86560408a5145bf6dbc152e", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "apr_id": "4e70cd2fe4a1f7fed547892bd7d8140b", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9993485342019544, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut v = s.split_whitespace().map(|x| x.parse::().unwrap()).collect::>();\n v.sort_unstable();\n let (_legs,headbody) : (&[i32], [i32;2]) = {\n if v[0] == v[1] && v[1] == v[2] && v[2] == v[3] \n {(&v[0..4],[v[4],v[5]])}\n else if v[1] == v[2] && v[2] == v[3] && v[3] == v[4] \n {(&v[1..5], [v[0],v[5]])}\n else if v[2] == v[3] && v[3] == v[4] && v[4] == v[5] \n {(&v[2..6], [v[0],v[1]])}\n else \n {(&v[0..0],[-1,-1])}\n };\n println!(\n \"{}\",\n if headbody == [-1,-1] {\"Aliens\"}\n else if headbody[0]().unwrap()).collect::>();\n v.sort_unstable();\n let (_legs,headbody) : (&[i32], [i32;2]) = {\n if v[0] == v[1] && v[1] == v[2] && v[2] == v[3] \n {(&v[0..4],[v[4],v[5]])}\n else if v[1] == v[2] && v[2] == v[3] && v[3] == v[4] \n {(&v[1..5], [v[0],v[6]])}\n else if v[2] == v[3] && v[3] == v[4] && v[4] == v[5] \n {(&v[2..6], [v[0],v[1]])}\n else \n {(&v[0..0],[-1,-1])}\n };\n println!(\n \"{}\",\n if headbody == [-1,-1] {\"Aliens\"}\n else if headbody[0] {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nfn run() {\n input! {\n n: u64,\n a: u64,\n b: u64,\n p: u64,\n q: u64,\n }\n let z = n / (a * b);\n let x = n / a - z;\n let y = n / b - z;\n let ans = p * x + q * y + std::cmp::max(p, q) * z;\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "fef3c66e01546e9e22c48a76230104d6", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "apr_id": "f8ae652e083bc0f6eff55371c04a2b6d", "difficulty": 1600, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9973251815055407, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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!(month; usize, start_weekday; usize);\n let days = match month {\n 1 | 3 | 5 | 7 | 8 | 10 | 12 => 31,\n 4 | 6 | 9 | 11 => 30,\n 2 => 28, // Assume that the year is non-leap.\n _ => 0\n };\n let days_first_column = 7 - start_weekday + 1;\n let days_remaining = days - days_first_column;\n let columns = (days_remaining as f64 / 7.0) as usize + 1;\n println!(\"{}\", columns);\n}", "lang": "Rust", "bug_code_uid": "15e9e6b3e93a832185005b66dc9ef5f0", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "apr_id": "8fc59b854b1f728228356a4778ee9a52", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9871323529411765, "equal_cnt": 1, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": " let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n\n let mut num = buffer.trim().parse::().unwrap();\n let mut bills = 0;\n\n while num > 0 {\n if num >= 100 {\n num -= 100;\n bills += 1;\n }\n else if num >= 20 {\n num -= 20;\n bills += 1;\n }\n else if num >= 10 {\n num -= 10;\n bills += 1;\n }\n else if num >= 5 {\n num -= 5;\n bills += 1;\n }\n else if num >= 1 {\n num -= 1;\n bills += 1;\n }\n }\n\n println!(\"{}\", bills);", "lang": "Rust", "bug_code_uid": "46efe6345f899b3ab4ca6ab59bca05c3", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "apr_id": "7d06386b7e74b5a43c30020f0a24afec", "difficulty": 800, "tags": ["dp", "greedy"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8870523415977961, "equal_cnt": 4, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "fn main() {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Err\");\n\n let summ: u64 = buffer.trim().parse().unwrap();\n\n println!(\"{}\", foo(summ));\n\n}\n\nfn foo(summ: u64) -> u64 {\n if summ < 5 {return summ;}\n else if summ < 10 {return summ/5 + foo(summ - 5*(summ/5));}\n else if summ < 20 {return summ/10 + foo(summ - 10*(summ/10));}\n else if summ < 50 {return summ/20 + foo(summ - 20*(summ/20));}\n else if summ < 100 {return summ/50 + foo(summ - 50*(summ/50));}\n else {return summ/100 + foo(summ - 100*(summ/100));}\n}", "lang": "Rust", "bug_code_uid": "9c050216cc9de65b76cea76534e2ed27", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "apr_id": "ae738ef4e87bba4d5622bc44b93ba262", "difficulty": 800, "tags": ["dp", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9987373737373737, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let mut n: i32 = input.trim().parse().unwrap();\n\n // 1, 5, 10, 20, 100\n let mut counter = 0;\n while n > 1 {\n if n < 5 {\n counter = counter + n;\n n = 0;\n } else {\n if n >= 100 {\n counter = counter + n / 100;\n n = n % 100;\n } else if n >= 20 {\n counter = counter + n / 20;\n n = n % 20;\n } else if n >= 10 {\n counter = counter + n / 10;\n n = n % 10;\n } else if n >= 5 {\n counter = counter + n / 5;\n n = n % 5;\n }\n }\n }\n\n println!(\"{}\", counter);\n}\n", "lang": "Rust", "bug_code_uid": "71e9798dc67a143c53ef36d4bcd3e01e", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "apr_id": "59b0ee688c989874a090b71cf09e826b", "difficulty": 800, "tags": ["dp", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9988465974625144, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let ints:Vec = s.split_whitespace().map(|x| x.parse().unwrap()).collect();\n let (n,m)=(ints[0], ints[1]);\n if n < m {\n println!(\"-1\");\n } else {\n for i in (0..n/2).rev() {\n let j = n-i*2;\n if (i+j)%m == 0 {\n println!(\"{}\", i+j);\n break;\n }\n }\n }\n}\n \n\n\n", "lang": "Rust", "bug_code_uid": "81227f3c36c85e176afeb7225c87c141", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "apr_id": "757cac73af0e24a00d5c50718be49990", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9702293801854563, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n}\n\nfn _main() {\n let mut scan = Scan::new();\n // e.g: 3 -> 3 + (2*(2-1)+1) + 1\n // e.g: 4 -> 4 + 3 + 2 + 1 =\n let n: isize = scan.next();\n let mut result: isize = n + 1; \n let mut i = n-1;\n while i >= 2 {\n result += i*(n-i) + 1;\n i -= 1;\n }\n println!(\"{}\", result);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "811ddf2445da50d6d8515c55952cd7ec", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "apr_id": "985e48b0594630058e588eef47eae736", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9123783031988874, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "use std::io::*;\nuse std::str::FromStr;\n\nfn main() {\n let stdin = stdin();\n let mut sc = Scanner::new(stdin.lock());\n let k = sc.next::();\n let n = sc.next::();\n let s = sc.next::();\n let p = sc.next::();\n\n for i in 0..10000 + 1 {\n if n <= s * ((i * p) / k) {\n println!(\"{}\", i);\n break;\n }\n }\n}\n\npub struct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Self {\n Self {\n reader,\n buffer: Vec::new(),\n }\n }\n\n pub fn next(&mut self) -> T\n where\n T::Err: ::std::fmt::Debug,\n {\n if let Some(front) = self.buffer.pop() {\n front.parse::().expect(&front)\n } else {\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Line not read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n self.next()\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "2fd20cf0811acdb66d19c5a6a116bdac", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "apr_id": "238190a7db3b55d44aa3c1b93d89e566", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.933879925945517, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_source_code": "use std::io::{self, BufRead};\n\ntype Point = (i32, i32);\ntype Seg = (Point, Point);\n\nfn cm(base: &Point, a: &Point, b: &Point) -> i32 {\n let debug = false;\n if debug { println!(\"base {:?}, a {:?}, b {:?}\", base, a, b) }\n return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);\n}\n\nfn intersect(a: &Seg, b: &Seg) -> bool {\n let b0 = cm(&a.0, &a.1, &b.0);\n let b1 = cm(&a.0, &a.1, &b.1);\n if b0 == 0 || b1 == 0 { return true }\n let a0 = cm(&b.0, &b.1, &a.0);\n let a1 = cm(&b.0, &b.1, &a.1);\n if a0 == 0 || a1 == 0 { return true }\n return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))\n && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));\n}\n\nfn main() {\n let debug = false;\n let stdin: io::Stdin = io::stdin();\n let mut lines: io::Lines = stdin.lock().lines();\n\n let next_line = lines.next()\n .unwrap() // Option { Some(Result), None }\n .unwrap(); // Result { Ok(String), Err(io::Error) }\n\n let square_a: Vec<_> = next_line\n .trim()\n .split(' ')\n .map(|n| {\n n.parse::().unwrap()\n })\n .collect();\n\n let next_line = lines.next()\n .unwrap() // Option { Some(Result), None }\n .unwrap(); // Result { Ok(String), Err(io::Error) }\n\n let square_b: Vec<_> = next_line\n .trim()\n .split(' ')\n .map(|n| {\n n.parse::().unwrap()\n })\n .collect();\n \n // any a inside b\n if debug { println!(\"\\n\\n a inside b ?? \\n\\n\") }\n for a_i in 0..4 {\n let a = (square_a[2*a_i], square_a[2*a_i+1]);\n let mut left = false;\n let mut right = false;\n if debug { println!(\"POINT a choosen\") }\n for i in 0..4 {\n let base = (square_b[2*i], square_b[2*i+1]);\n let j = (i+1) % 4;\n let b = (square_b[2*j], square_b[2*j+1]);\n if debug { println!(\"-------------------\") }\n let cmv = cm(&base, &b, &a);\n if debug { println!(\"cmv {}\", cmv) }\n if cmv > 0 { left = true; }\n if cmv < 0 { right = true; }\n }\n if !left || !right {\n println!(\"YES\");\n return;\n }\n }\n\n // any b inside a\n if debug { println!(\"\\n\\n b inside a ?? \\n\\n\") }\n for b_i in 0..4 {\n let b = (square_b[2*b_i], square_b[2*b_i+1]);\n let mut left = false;\n let mut right = false;\n if debug { println!(\"POINT b choosen\") }\n for i in 0..4 {\n let base = (square_a[2*i], square_a[2*i+1]);\n let j = (i+1) % 4;\n let a = (square_a[2*j], square_a[2*j+1]);\n if debug { println!(\"-------------------\") }\n let cmv = cm(&base, &a, &b);\n if debug { println!(\"cmv {}\", cmv) }\n if cmv > 0 { left = true; }\n if cmv < 0 { right = true; }\n }\n if !left || !right {\n println!(\"YES\");\n return;\n }\n }\n\n // check intersect\n for a_i in 0..4 {\n let a_a = (square_a[2*a_i], square_a[2*a_i+1]);\n let a_j = (a_i + 1) % 4;\n let a_b = (square_a[2*a_j], square_a[2*a_j+1]);\n let seg_a = (a_a, a_b);\n\n for i in 0..4 {\n let b_a = (square_b[2*i], square_b[2*i+1]);\n let j = (i+1) % 4;\n let b_b = (square_b[2*j], square_b[2*j+1]);\n let seg_b = (b_a, b_b);\n if intersect(&seg_a, &seg_b) {\n println!(\"YES\");\n return;\n }\n }\n }\n\n println!(\"NO\");\n}", "lang": "Rust", "bug_code_uid": "be5121178cf93929fda5d7e4d49dd5cb", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "apr_id": "d37012cd51524086e86eacb7ae57ee99", "difficulty": 1600, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.922943972346248, "equal_cnt": 10, "replace_cnt": 3, "delete_cnt": 5, "insert_cnt": 2, "fix_ops_cnt": 10, "bug_source_code": "se std::io::{self, BufRead};\n\ntype Point = (i32, i32);\ntype Seg = (Point, Point);\n\nfn cm(base: &Point, a: &Point, b: &Point) -> i32 {\n let debug = false;\n if debug { println!(\"base {:?}, a {:?}, b {:?}\", base, a, b) }\n return (a.0 - base.0)*(b.1 - base.1) - (a.1 - base.1)*(b.0 - base.0);\n}\n\nfn inx(a: i32, b: i32, x: i32) -> bool {\n return (b >= a && x >= a && x <= b) || (b <= a && x <= a && x >= b);\n}\n\nfn ins(pa: &Point, pb: &Point, px: &Point) -> bool {\n return inx(pa.0, pb.0, px.0) && inx(pa.1, pb.1, px.1);\n}\n\nfn intersect(a: &Seg, b: &Seg) -> bool {\n let b0 = cm(&a.0, &a.1, &b.0);\n if b0 == 0 && ins(&a.0, &a.1, &b.0) { return true; }\n let b1 = cm(&a.0, &a.1, &b.1);\n if b1 == 0 && ins(&a.0, &a.1, &b.1) { return true; }\n let a0 = cm(&b.0, &b.1, &a.0);\n if a0 == 0 && ins(&b.0, &b.1, &a.0) { return true; }\n let a1 = cm(&b.0, &b.1, &a.1);\n if a1 == 0 && ins(&b.0, &b.1, &a.1) { return true; }\n return ((a0 > 0 && a1 < 0) || (a0 < 0 && a1 > 0))\n && ((b0 > 0 && b1 < 0) || (b0 < 0 && b1 > 0));\n}\n\nfn main() {\n let debug = false;\n let stdin: io::Stdin = io::stdin();\n let mut lines: io::Lines = stdin.lock().lines();\n\n let next_line = lines.next()\n .unwrap() // Option { Some(Result), None }\n .unwrap(); // Result { Ok(String), Err(io::Error) }\n\n let square_a: Vec<_> = next_line\n .trim()\n .split(' ')\n .map(|n| {\n n.parse::().unwrap()\n })\n .collect();\n\n let next_line = lines.next()\n .unwrap() // Option { Some(Result), None }\n .unwrap(); // Result { Ok(String), Err(io::Error) }\n\n let square_b: Vec<_> = next_line\n .trim()\n .split(' ')\n .map(|n| {\n n.parse::().unwrap()\n })\n .collect();\n \n // any a inside b\n for a_i in 0..4 {\n let a = (square_a[2*a_i], square_a[2*a_i+1]);\n let mut left = false;\n let mut right = false;\n for i in 0..4 {\n let base = (square_b[2*i], square_b[2*i+1]);\n let j = (i+1) % 4;\n let b = (square_b[2*j], square_b[2*j+1]);\n let cmv = cm(&base, &b, &a);\n if cmv > 0 { left = true; }\n if cmv < 0 { right = true; }\n }\n if !left || !right {\n println!(\"YES\");\n return;\n }\n }\n\n // any b inside a\n for b_i in 0..4 {\n let b = (square_b[2*b_i], square_b[2*b_i+1]);\n let mut left = false;\n let mut right = false;\n for i in 0..4 {\n let base = (square_a[2*i], square_a[2*i+1]);\n let j = (i+1) % 4;\n let a = (square_a[2*j], square_a[2*j+1]);\n let cmv = cm(&base, &a, &b);\n if cmv > 0 { left = true; }\n if cmv < 0 { right = true; }\n }\n if !left || !right {\n println!(\"YES\");\n return;\n }\n }\n\n // check intersect\n for a_i in 0..4 {\n let a_a = (square_a[2*a_i], square_a[2*a_i+1]);\n let a_j = (a_i + 1) % 4;\n let a_b = (square_a[2*a_j], square_a[2*a_j+1]);\n let seg_a = (a_a, a_b);\n\n for i in 0..4 {\n let b_a = (square_b[2*i], square_b[2*i+1]);\n let j = (i+1) % 4;\n let b_b = (square_b[2*j], square_b[2*j+1]);\n let seg_b = (b_a, b_b);\n if intersect(&seg_a, &seg_b) {\n println!(\"YES\");\n return;\n }\n }\n }\n\n println!(\"NO\");\n}", "lang": "Rust", "bug_code_uid": "3b79a8d54600a88cef153b366b9bbd95", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "apr_id": "d37012cd51524086e86eacb7ae57ee99", "difficulty": 1600, "tags": ["brute force"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9903536977491961, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() -> std::io::Result<()> {\n let stdin = io::stdin();\n let mut input = String::new();\n stdin.read_line(&mut input)?;\n print!(\"{}\", match hq9plus(input) {\n true => \"YES\",\n false => \"NO\"\n }.to_string());\n Ok(())\n}\n\nfn hq9plus(input: String) -> bool {\n input.trim().chars().filter(|&c|\n c == 'H' || c == 'Q' || c == '9' || c == '+'\n ).collect::().len() > 0\n}\n#[cfg(test)]\nmod tests {\n use super::*;\n #[test]\n fn test() {\n assert_eq!(hq9plus(\"Hi!\".to_string()), true);\n assert_eq!(hq9plus(\"Codeforces\".to_string()), false);\n\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "192eec15f821fda7278e524cf27877b9", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "apr_id": "fdfdf95171bfec5d3d1df08c34e9a2b6", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.984936268829664, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nfn main() {\n let data = read();\n let mut c = 0;\n for val in data.chars(){\n if val == 'H' || val == 'Q' || val == '9' || val == '+'{\n println!(\"YES\");\n c = 1;\n break;\n }\n }\n if c==0{\n println!(\"NO\");\n }\n}\nfn read() -> String{\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input.trim().parse::().unwrap()\n}", "lang": "Rust", "bug_code_uid": "cf6a813776b9a7c1228b46cd255ba949", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "apr_id": "35a61b0cc2c7623ef2f196b78f48b3e4", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9110320284697508, "equal_cnt": 16, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 13, "fix_ops_cnt": 16, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn main() {\n for instruction in read_str().chars() {\n if \"HQ9+\".contains(instruction) {\n println!(\"YES\");\n std::process::exit(0);\n }\n }\n println!(\"NO\");\n}", "lang": "Rust", "bug_code_uid": "2c7026ead621ca9c88bc1352dafc68ec", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "apr_id": "fff785f66ca53ea681453956c346e95a", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8785923753665689, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let num = readln!(i64);\n\n println!(\"{}\", if num % 2 != 0 {\n let mut div = 3;\n while num % div != 0 {\n div += 1;\n }\n 1 + (num - div) / 2\n } else {\n num / 2\n });\n}\n", "lang": "Rust", "bug_code_uid": "11f3e4bddbc877c5c44d947c309a7a2a", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "eaf4bd7162aad3f0bba386d5e20dae9a", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8954211418880723, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let num = readln!(i64);\n\n println!(\"{}\", if num % 2 != 0 {\n let mut div = 3;\n let end = (num as f64).sqrt() as i64 + 1;\n while div <= end && num % div != 0 {\n div += 1;\n }\n 1 + (num - div) / 2\n } else {\n num / 2\n });\n}\n", "lang": "Rust", "bug_code_uid": "241980fb4a260cc9b52951f6ea38c08d", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "eaf4bd7162aad3f0bba386d5e20dae9a", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4289855072463768, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"err\");\n let n:i32 = buffer.trim().parse().unwrap();\n for i in 2..= n {\n if n%i==0 {\n println!(\"{}\", n/i); break;\n }\n }\n}", "lang": "Rust", "bug_code_uid": "e711b9e9bf118ac8867c14fae25a1603", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "8e7c4a0978ed7e5690cb5f404b629804", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6231884057971014, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"err\");\n let n:i64 = buffer.trim().parse().unwrap();\n for i in 2..= n {\n if n%i==0 {\n println!(\"{}\", n/i); break;\n }\n }\n}", "lang": "Rust", "bug_code_uid": "000771d1eec815b3eece0932b0a9ba4e", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "8e7c4a0978ed7e5690cb5f404b629804", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.5146067415730337, "equal_cnt": 6, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"err\");\n let mut n:i64 = buffer.trim().parse().unwrap();\n let mut counter:i64 = 0;\n while n != 0 {\n for i in 2..= n {\n if n%i==0 {\n if i == 2 {\n counter+=n/i; n = 0; break;\n }\n n -= i; counter+=1; break;\n }\n }\n }\n println!(\"{}\", counter);\n}", "lang": "Rust", "bug_code_uid": "210b123399be04fb857e57d5951ff171", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "8e7c4a0978ed7e5690cb5f404b629804", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9022966134682756, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn get_mpf(n: u64) -> u64 {\n for d in 2..=n {\n if n % d == 0 {\n return d;\n }\n }\n n\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let mpf = get_mpf(n);\n let ans = n / mpf;\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "5b33e25845fc3d830670bb8e62bab97f", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "6d0093304e94e111757f8066e7a0e85c", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9785063752276867, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn get_mpf(n: u64) -> u64 {\n for d in 2..=n {\n if n % d == 0 {\n return d;\n }\n }\n n\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let mpf = get_mpf(n);\n let ans;\n if mpf % 2 != 0 {\n if n == mpf {\n ans = 1;\n } else {\n ans = 1 + (n - mpf) / get_mpf(n - mpf);\n }\n } else {\n ans = n / mpf;\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "1bf27d32371ebe9d3a8c27ea725b386e", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "6d0093304e94e111757f8066e7a0e85c", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.966804979253112, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 12, "bug_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 から最小の素数の約数を引いていく、何回操作ができるか。\n\n34, 32, 30, 28, .., 2, 0\n31, 0\n6, 4, 2, 0\n10, 8, 6, 4,\n\n約数列挙、最小の素数見つける、それで割る?\n\n*", "lang": "Rust", "bug_code_uid": "147229c5a420f1d5d603d372a1c79f2a", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "c08646e9bd1bc132564df7af477c3e13", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.966991341991342, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 11, "bug_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 から最小の素数の約数を引いていく、何回操作ができるか。\n\n34, 32, 30, 28, .., 2, 0\n31, 0\n6, 4, 2, 0\n10, 8, 6, 4,\n\n約数列挙、最小の素数見つける、それで割る?\n\n*/\n", "lang": "Rust", "bug_code_uid": "10a7b0c21735063198a588366b8164b5", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "apr_id": "c08646e9bd1bc132564df7af477c3e13", "difficulty": 1200, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9205479452054794, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut guess = String::new();\n\n io::stdin()\n .read_line(&mut guess)\n .expect(\"Failed to read line\");\n\n let mut bills:u32 = 0;\n let mut n= guess.trim().parse::().unwrap();\n\n while n > 0 {\n if (n % 100) == 0 {\n n = n - 100;\n bills+=1;\n }\n else if (n % 20) == 0\n {\n n = n - 20;\n bills+=1;\n }\n else if (n % 10) == 0\n {\n n = n - 5;\n bills+=1;\n }\n else if (n % 100) == 0\n {\n n = n - 5;\n bills+=1;\n }\n else\n {\n n = n - 1;\n bills+=1;\n }\n }\n print!(\"{}\",bills);\n}", "lang": "Rust", "bug_code_uid": "e475b925a20b2e1391bb9918a929e3e9", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "apr_id": "cbd8171506c7db2820865152fac7b943", "difficulty": 800, "tags": ["dp", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9277251184834123, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 7, "bug_source_code": "fn main() {\n let mut reader = scanner::TokenReader::new();\n let (a, b) = (reader.next::(), reader.next::());\n let prob = (6 - std::cmp::max(a, b)) + 1;\n let (a, b) = if 6 % prob == 0 {\n (1, 6 / prob)\n } else {\n (prob, 6)\n };\n println!(\"{}/{}\", a, b);\n}\n\n// ---------- Begin Scanner ----------\n#[allow(dead_code)]\nmod scanner {\n use std::fmt::Debug;\n use std::str::FromStr;\n\n pub struct TokenReader {\n reader: std::io::Stdin,\n tokens: Vec,\n index: usize,\n }\n\n impl TokenReader {\n pub fn new() -> Self {\n Self {\n reader: std::io::stdin(),\n tokens: Vec::new(),\n index: 0,\n }\n }\n\n pub fn next(&mut self) -> T\n where\n T: FromStr,\n T::Err: Debug,\n {\n if self.index >= self.tokens.len() {\n self.load_next_line();\n }\n self.index += 1;\n self.tokens[self.index - 1].parse().unwrap()\n }\n\n pub fn vector(&mut self) -> Vec\n where\n T: FromStr,\n T::Err: Debug,\n {\n if self.index >= self.tokens.len() {\n self.load_next_line();\n }\n self.index = self.tokens.len();\n self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()\n }\n\n pub fn load_next_line(&mut self) {\n let mut line = String::new();\n self.reader.read_line(&mut line).unwrap();\n\n self.tokens = line.split_whitespace().map(String::from).collect();\n self.index = 0;\n }\n }\n}\n// ---------- End Scanner ----------\n", "lang": "Rust", "bug_code_uid": "d2538cdc114266ac4f9550472d0e3ffb", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "apr_id": "c73e235789176e4292575f2f1f866e54", "difficulty": 800, "tags": ["probabilities", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9769585253456221, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 read_line_vec() -> Vec {\n return read_line().split(' ')\n .map(|s| s.parse().unwrap())\n .collect();\n}\n\nfn read_line_pair() -> (u8, u8) {\n let vec = read_line_vec();\n return (vec[0], vec[1]);\n}\n\nfn main() {\n let (a, b) = read_line_pair();\n let c = 6 - std::cmp::max(a, b) + 1;\n match c {\n 2 => println!(\"1/3\"),\n 3 => println!(\"1/2\"),\n 4 => println!(\"2/3\"),\n _ => println!(\"{}/6\", c)\n }\n}", "lang": "Rust", "bug_code_uid": "1296b1b329b698afff7e758ab9c8e4ff", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "apr_id": "4f19d12d6b0a77c6e48d76babb23f67c", "difficulty": 800, "tags": ["probabilities", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9410618606916707, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "macro_rules! input {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input!{$next $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, bytes) => {\n read_value!($next, String).into_bytes()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\nconst MOD: i64 = 1000000007;\n\n// assume a, b positive\nfn gcd(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n (1, 0, a)\n }\n else {\n let (x, y, d) = gcd(b, a%b); // xb + y(a-qb) = d where q = a/b\n (y, x-y*(a/b), d)\n }\n}\n\nfn factorial_mod(a: i64) -> i64 {\n if a == 0 {\n 1\n }\n else {\n a * factorial_mod(a-1) % MOD\n }\n}\n\nfn binomial_mod(n: i64, k: i64) -> i64 {\n let a = factorial_mod(k);\n let b = factorial_mod(n-k);\n let (inv_a, _, _) = gcd(a, MOD);\n let (inv_b, _, _) = gcd(b, MOD);\n let result = factorial_mod(n) * inv_a % MOD * inv_b % MOD;\n if result < 0 { result + MOD } else { result }\n}\n\nfn main() {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input! {next,\n n: i64,\n m: i64,\n k: i64,\n }\n println!(\"{}\", binomial_mod(n-1,2*k)*binomial_mod(m-1,2*k) % MOD);\n // println!(\"{:?}\", matches);\n\n // println!(\"{}\", result);\n}\n", "lang": "Rust", "bug_code_uid": "5ebff11fdb609af7f64643f537a6d87f", "src_uid": "309d2d46086d526d160292717dfef308", "apr_id": "a99f39c0ccd3aa3ea407e1740565eaac", "difficulty": 2000, "tags": ["dp", "combinatorics"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9312865497076024, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "// Vicfred\n// https://codeforces.com/problemset/problem/546/C\n\nuse std::io;\nuse std::collections::HashSet;\nuse std::collections::VecDeque;\n\n#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]\nstruct Pair(i64, i64);\n\nfn main() {\n let mut n = String::new();\n\n io::stdin()\n .read_line(&mut n)\n .unwrap();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut a: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n a.pop_front();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut b: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n b.pop_front();\n\n let mut ans = 0;\n\n while !a.is_empty() && !b.is_empty() {\n ans += 1;\n\n println!(\"{:?}\", a);\n println!(\"{:?}\", b);\n\n let x = a.pop_front().unwrap();\n let y = b.pop_front().unwrap();\n\n states.insert(Pair(x,y));\n\n if x > y {\n a.push_back(y);\n a.push_back(x);\n } else {\n b.push_back(x);\n b.push_back(y);\n }\n if ans > 1000 {\n println!(\"-1\");\n return;\n }\n }\n\n let winner = if a.is_empty() {2} else {1};\n\n println!(\"{} {}\", ans, winner);\n}\n", "lang": "Rust", "bug_code_uid": "d5fbbfcb7e570ceab043de09517da3c9", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "apr_id": "8d6b3b41c728ec64699bd1b9bccbe9f5", "difficulty": 1400, "tags": ["brute force", "games", "dfs and similar"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.978156238430211, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "// Vicfred\n// https://codeforces.com/problemset/problem/546/C\n\nuse std::io;\nuse std::collections::HashSet;\nuse std::collections::VecDeque;\n\n#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]\nstruct Pair(i64, i64);\n\nfn main() {\n let mut n = String::new();\n\n io::stdin()\n .read_line(&mut n)\n .unwrap();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut a: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n a.pop_front();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut b: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n b.pop_front();\n\n let mut ans = 0;\n\n while !a.is_empty() && !b.is_empty() {\n ans += 1;\n\n println!(\"{:?}\", a);\n println!(\"{:?}\", b);\n\n let x = a.pop_front().unwrap();\n let y = b.pop_front().unwrap();\n\n if x > y {\n a.push_back(y);\n a.push_back(x);\n } else {\n b.push_back(x);\n b.push_back(y);\n }\n if ans > 1000 {\n println!(\"-1\");\n return;\n }\n }\n\n let winner = if a.is_empty() {2} else {1};\n\n println!(\"{} {}\", ans, winner);\n}\n", "lang": "Rust", "bug_code_uid": "2085688e0b71df0e738fb8bf3f7ebc89", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "apr_id": "8d6b3b41c728ec64699bd1b9bccbe9f5", "difficulty": 1400, "tags": ["brute force", "games", "dfs and similar"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8061600267827251, "equal_cnt": 8, "replace_cnt": 5, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 7, "bug_source_code": "// Vicfred\n// https://codeforces.com/problemset/problem/546/C\n\nuse std::io;\nuse std::collections::HashSet;\nuse std::collections::VecDeque;\n\n#[derive(Debug,PartialEq,Eq,PartialOrd,Ord,Hash)]\nstruct Pair(i64, i64);\n\nfn main() {\n let mut n = String::new();\n\n io::stdin()\n .read_line(&mut n)\n .unwrap();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut a: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n a.pop_front();\n\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let mut b: VecDeque =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n b.pop_front();\n\n let mut ans = 0;\n let mut impossible = false;\n\n let mut states = HashSet::new();\n\n states.insert(Pair(1,2));\n\n while !a.is_empty() && !b.is_empty() {\n ans += 1;\n\n let x = a.pop_front().unwrap();\n let y = b.pop_front().unwrap();\n\n match states.get(&Pair(x,y)) {\n None => states.insert(Pair(x,y)),\n _ => {\n impossible = true;\n break;\n }\n };\n\n if x > y {\n a.push_back(y);\n a.push_back(x);\n } else {\n b.push_back(x);\n b.push_back(y);\n }\n }\n\n if impossible {\n println!(\"-1\");\n return;\n }\n\n let winner = if a.is_empty() {2} else {1};\n\n println!(\"{} {}\", ans, winner);\n}\n\n", "lang": "Rust", "bug_code_uid": "50eb876dc5cafd0617c0417bf1f366eb", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "apr_id": "35a7f008d0ce875a27163120302a2407", "difficulty": 1400, "tags": ["brute force", "games", "dfs and similar"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8356744704570791, "equal_cnt": 13, "replace_cnt": 5, "delete_cnt": 2, "insert_cnt": 5, "fix_ops_cnt": 12, "bug_source_code": "use std::collections::HashSet;\nuse std::collections::VecDeque;\n\nstruct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: VecDeque::new(),\n }\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> VecDeque {\n (0..n).map(|_| self.next::()).collect()\n }\n}\n\nfn get_state(card1: &VecDeque, card2: &VecDeque) -> (usize, usize) {\n let mut r1 = 0usize;\n let mut r2 = 0usize;\n for item in card1.iter() {\n r1 |= 1 << *item;\n }\n for item in card2.iter() {\n r2 |= 1 << *item;\n }\n return (r1, r2);\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let mut visited: HashSet<(usize, usize)> = HashSet::new();\n let _n: usize = scan.next();\n let k1: usize = scan.next();\n let mut card1: VecDeque = scan.next_n(k1);\n let k2: usize = scan.next();\n let mut card2: VecDeque = scan.next_n(k2);\n let mut wars = 0usize;\n while !card1.is_empty() && !card2.is_empty() {\n let state = get_state(&card1, &card2);\n if visited.contains(&state) {\n break;\n }\n visited.insert(state);\n let first = card1.pop_front().unwrap();\n let second = card2.pop_front().unwrap();\n if first > second {\n card1.push_back(second);\n card1.push_back(first);\n } else {\n card2.push_back(first);\n card2.push_back(second);\n }\n wars += 1;\n }\n if !card1.is_empty() && !card2.is_empty() {\n println!(\"-1\");\n } else {\n println!(\"{} {}\", wars, if card1.is_empty() { 2 } else { 1 });\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": "Rust", "bug_code_uid": "e160fd1bab39f607f936cc0ca176803d", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "apr_id": "de3f5386c26ccdb60132d0d535536205", "difficulty": 1400, "tags": ["brute force", "games", "dfs and similar"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9896694214876033, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn solve(n: u16, ln: &[u16]) -> &str {\n let mut i = 0;\n while ln[i] <= n {\n if n % ln[i] == 0 {\n return \"YES\";\n }\n i += 1;\n }\n \"NO\"\n}\n\nfn main() {\n let n: u16 = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n };\n\n let lucky_numbers = [4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777];\n print!(\"{}\", solve(n, &lucky_numbers));\n}", "lang": "Rust", "bug_code_uid": "3a5c94638086718f60e1ef8cbaa1b956", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "apr_id": "d815ddf98a82e63abb227c6fa931f6d9", "difficulty": 1000, "tags": ["brute force", "number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6768425643262101, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 11, "bug_source_code": "use std::io::*;\n\nfn read(i: &mut StdinLock) -> T {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn string_lucky(s: &String) -> bool {\n for c in s.as_str().chars() {\n match c {\n '4' | '7' => (),\n _ => return false,\n }\n }\n\n true\n}\n\nfn is_lucky_number_with_4(val: u64) -> bool {\n let mut remain: u64 = val;\n loop {\n if remain % 4 != 0 {\n return false;\n }\n\n remain = remain / 4;\n if remain != 1 {\n break;\n }\n }\n\n true\n}\n\nfn is_lucky_number_with_7(val: u64) -> bool {\n let mut remain: u64 = val;\n loop {\n if remain % 7 != 0 {\n return false;\n }\n\n remain = remain / 7;\n if remain != 1 {\n break;\n }\n }\n\n true\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let input: String = read(sin);\n\n if string_lucky(&input) {\n println!(\"YES\");\n return;\n }\n\n let val: u64 = input.parse().unwrap();\n\n if is_lucky_number_with_4(val) {\n println!(\"YES\");\n return;\n }\n\n if is_lucky_number_with_7(val) {\n println!(\"YES\");\n return;\n }\n\n println!(\"NO\");\n}\n", "lang": "Rust", "bug_code_uid": "e475bf30bf86f797f36aed6ed0b54f71", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "apr_id": "adeac5c556b4768d35ff812f8cccb9a5", "difficulty": 1000, "tags": ["brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5240174672489083, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s = s.trim().to_string();\n let mut ans = String::from(\"YES\");\n for c in s.chars() {\n if c != '4' && c != '7' {\n ans = String::from(\"NO\");\n }\n }\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "fd630b3789c864ddf81cc6bbcee826d4", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "apr_id": "e299d489b897fc68707a3d806ea88c16", "difficulty": 1000, "tags": ["brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9982020855807263, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{Read, Write, stdin, stdout};\npub struct Scanner {\n pub buffer: Vec,\n pub reader: U,\n}\nimpl Scanner {\n pub fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_to_string(&mut input).expect(\"Failed read\");\n self.buffer = input.lines().rev().map(String::from).collect();\n }\n }\n\n pub fn new(reader: U) -> Self {\n return Scanner {\n buffer: vec![],\n reader,\n };\n }\n}\n\npub fn solution_of_p122a(input: &mut Read, out: &mut Write) {\n let mut scanner = Scanner::new(input);\n let num = scanner.next::().parse::().unwrap();\n let lucky_nums = vec![4, 7, 44, 47, 74, 77, 444, 447, 474, 744, 747, 774, 777];\n if is_almose_lucky(num, lucky_nums) {\n write!(out, \"YES\").ok();\n } else {\n write!(out, \"NO\").ok();\n }\n}\n\nfn is_almose_lucky(num: usize, arr: Vec) -> bool {\n if arr.contains(&num) {\n return true;\n }\n for item in &arr {\n if num % (*item) == 0 {\n return true;\n }\n }\n return false;\n}\n\nfn main() {\n solution_of_p122a(&mut stdin(), &mut stdout());\n}\n", "lang": "Rust", "bug_code_uid": "71757dc350674854a43f199366186f66", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "apr_id": "ef4eaa8016f9f5d2e36b8ed98e1370ee", "difficulty": 1000, "tags": ["brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9994619316653215, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tlet mut c0 = vec![1; 10];\n\tfor x in rin.vb() {\n\t\tc0[(x - b'0') as usize] += 1;\n\t}\n\tlet m = rin.u();\n\tlet mut ns = 1;\n\tfor &c in c0.iter() {\n\t\tns *= c;\n\t}\n\tlet encode = |a: &[usize]| -> usize {\n\t\tlet mut res = 0;\n\t\tfor i in 0..10 {\n\t\t\tres = res * c0[i] + a[i];\n\t\t}\n\t\tres\n\t};\n\tlet decode = |a: &mut [usize], mut x: usize| {\n\t\tfor i in (0..10).rev() {\n\t\t\ta[i] = x % c0[i];\n\t\t\tx /= c0[i];\n\t\t}\n\t};\n\tlet mut dp = vec![vec![0; m]; ns];\n\tdp[0][0] = 1;\n\tfor s in 0..ns {\n\t\tlet mut a = vec![0; 10];\n\t\tdecode(&mut a, s);\n\t\tlet st = if s == 0 {1} else {0};\n\t\tfor r in 0..m {\n\t\t\tlet v = dp[s][r];\n\t\t\tif v == 0 { continue; }\n\t\t\tfor i in st..10 {\n\t\t\t\tif a[i]+1 < c0[i] {\n\t\t\t\t\ta[i] += 1;\n\t\t\t\t\tlet ss = encode(&a);\n\t\t\t\t\tdp[ss][(r * 10 + i) % m] += v;\n\t\t\t\t\ta[i] -= 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tlet sol = dp[ns-1][0];\n\twriteln!(rout, \"{}\", sol).ok();\n}\n\n", "lang": "Rust", "bug_code_uid": "e3de3f96e46494e77b10ce662504021e", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "apr_id": "043a444c602d2860a268f795550a5fbc", "difficulty": 2000, "tags": ["dp", "combinatorics", "bitmasks", "number theory", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8435774751564226, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 7, "bug_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 mut cnt = vec![0; 10];\n let mut len = 0;\n while n > 0 {\n let k = (n % 10) as usize;\n cnt[k] += 1;\n len += 1;\n n /= 10;\n }\n let mut now = std::collections::BTreeMap::new();\n now.insert((cnt, 0), 1u64);\n for p in 0..len {\n let mut next = std::collections::BTreeMap::new();\n for (k, v) in now.iter() {\n let (a, rem) = k.clone();\n for d in 0..10 {\n if a[d] > 0 && !(p == 0 && d == 0) {\n let mut b = a.clone();\n b[d] -= 1;\n let r = (10 * rem + d) % m;\n *next.entry((b, r)).or_insert(0u64) += *v;\n }\n }\n }\n now = next;\n }\n let mut ans = 0;\n for (k, v) in now.iter() {\n if k.1 == 0 {\n ans += *v;\n }\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "267f3d145a2359e52139b30f2f6167c1", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "apr_id": "38cd24695ae3f4e6d1f5577f52612c76", "difficulty": 2000, "tags": ["dp", "combinatorics", "bitmasks", "number theory", "brute force"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9959349593495935, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_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 i32 { 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": "Rust", "bug_code_uid": "0f0997f5eb30d3d26b8caaa67d7f4263", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "apr_id": "3a51498205baf185d675a743b575eecd", "difficulty": 1100, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9883428571428572, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::str::FromStr;\nuse std::num::ParseIntError;\nuse std::ops::Index;\n\nstruct RevBinary {\n data: Vec,\n}\n\nimpl FromStr for RevBinary {\n type Err = ParseIntError;\n\n fn from_str(s: &str) -> Result {\n let i = s.parse::()?;\n\n Ok(RevBinary::new(i))\n }\n}\n\nimpl Index for RevBinary {\n type Output = bool;\n\n fn index(&self, i: usize) -> &Self::Output {\n &self.data[self.data.len() - i - 1]\n }\n}\n\nimpl RevBinary {\n fn new(x : u32) -> RevBinary {\n let mut y = x;\n let mut bin : Vec = Vec::new();\n while y != 0 {\n bin.push(if y % 2 == 1 { true } else { false }); \n y /= 2;\n }\n RevBinary {\n data: bin,\n }\n }\n\n fn size(&self) -> usize {\n self.data.len()\n }\n}\n\nfn process_node(all: &Vec, ind: Vec, depth: usize, k: u32) -> u32 {\n let mut result : u32 = ind.iter().take(k as usize).map(|&x| all[x].size() - depth).sum::() as u32;\n\n let mut new_ind0 : Vec = Vec::new();\n let mut new_ind1 : Vec = Vec::new();\n for i in ind.iter().filter(|&&x| all[x].size() > depth) {\n if all[*i][depth] {\n new_ind1.push(*i);\n } else {\n new_ind0.push(*i);\n } \n }\n if new_ind0.len() >= k as usize {\n result = result.min(process_node(&all, new_ind0, depth + 1, k));\n }\n if new_ind1.len() >= k as usize {\n result = result.min(process_node(&all, new_ind1, depth + 1, k));\n }\n result\n}\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).expect(\"failed to read input\");\n let mut input_iter = input.split_whitespace();\n let n = input_iter.next().unwrap().parse::().unwrap();\n let k = input_iter.next().unwrap().parse::().unwrap();\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"failed to read input\");\n let a = buffer.split_whitespace().map(|x| x.parse::().unwrap()).collect::>();\n \n println!(\"{}\", process_node(&a, (0..n).collect::>(), 0, k));\n}", "lang": "Rust", "bug_code_uid": "f8b3cb35aca4b8e7719d0724b0da634e", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "apr_id": "34f7faf222790b245bc520ab43391d0b", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9742421587524093, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_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 input!{\n n: usize,\n k: usize,\n mut aa: [usize; n],\n }\n aa.sort();\n\n let mut ans: u64 = 1 << 60;\n for t in 0..n+1 {\n let mut temp = 0;\n let mut ok = 0;\n\n for i in 0..n {\n let mut a = aa[i];\n let mut cnt = 0;\n if a < t {\n continue;\n }\n\n while a > t {\n a/=2;\n cnt += 1;\n }\n if t == a {\n temp += cnt;\n ok += 1;\n if ok == k {\n break;\n }\n }\n }\n\n if ok == k {\n ans = min(ans, temp);\n }\n }\n puts!(\"{}\\n\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "662b406641dd8031bd54aa54611ab28a", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "apr_id": "7461b36e461e70262f5ddafc0bd26a03", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.2062754212667054, "equal_cnt": 33, "replace_cnt": 21, "delete_cnt": 2, "insert_cnt": 10, "fix_ops_cnt": 33, "bug_source_code": "use std::io;\n\nfn shift_count(mut from: i32, to: i32) -> i32 {\n let mut cnt = 0;\n while from > to {\n cnt += 1;\n from /= 2;\n }\n cnt\n}\n\nfn normalize(id: usize, input: &Vec) -> Vec {\n let norm_val = input[id];\n let mut normalized: Vec = input\n .iter()\n .map(|x| {\n if x < &norm_val {\n 20000000\n } else {\n shift_count(*x, norm_val)\n }\n })\n .collect();\n\n normalized.sort_unstable();\n normalized\n}\n\nfn cost(normalized: &Vec, cnt: u8) -> i32 {\n normalized\n .iter()\n .take(cnt as usize)\n .fold(0, |acc, x| acc + x)\n}\n\nfn main() {\n let mut inp = String::new();\n io::stdin().read_line(&mut inp).unwrap();\n let line: Vec = inp\n .split_whitespace()\n .map(|x| x.trim().parse().unwrap())\n .collect();\n let (n, k) = (line[0], line[1]);\n\n inp.clear();\n io::stdin().read_line(&mut inp).unwrap();\n\n let input: Vec = inp\n .split_whitespace()\n .map(|x| x.trim().parse::().unwrap())\n .collect();\n\n let mut norm_matrix: Vec> = Vec::with_capacity(input.len());\n\n let mut min_cost = std::i32::MAX;\n for i in 0..n {\n let norm = normalize(i as usize, &input);\n let c = cost(&norm, k);\n if c < min_cost {\n min_cost = c;\n }\n\n norm_matrix.push(norm);\n }\n\n println!(\"{}\", min_cost);\n}\n", "lang": "Rust", "bug_code_uid": "a81977fbe231995b3bed4d79dcbc2124", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "apr_id": "c561d9ee85d88657346ecb1c98de4adb", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9136420525657072, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(dead_code)]\n\nuse std::char::*;\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse std::str::FromStr;\n\nmacro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);}}\nmacro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }\nmacro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }\nmacro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\n\n\nfn read() -> T {\n let stdin = stdin();\n let stdin = stdin.lock();\n let token: String = stdin\n .bytes()\n .map(|c| c.expect(\"failed to read char\") as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect();\n token.parse().ok().expect(\"failed to parse token\")\n}\n\nuse std::f64;\n\nfn min(a:T, b:T) -> T {\n if a < b { a }\n else { b }\n}\n\nfn max(a:T, b:T) -> T {\n if a < b { b }\n else { a }\n}\n\nuse std::hash::Hash;\nfn inc(map:&mut BTreeMap, key:T) {\n let count = map.entry(key).or_insert(0);\n *count += 1;\n}\n\nfn digit(ch: char) -> i64 {\n return (ch as u8 - b'0') as i64\n}\n\nconst MAX:usize = 30;\nconst INF:i64 = std::i64::MAX;\nconst MOD:i64 = 1e9 as i64 + 7;\n\nfn gcd(x:i64, y:i64) -> i64 {\n if y==0 { return x; }\n gcd(y, x%y)\n}\n\nfn main() {\n //let t:usize = read();\n\n //'outer: for _ in 0..t {\n let n:usize = read();\n let k:usize = read();\n let a:Vec = (0..n).map(|_| read()).collect();\n\n let mut map = HashMap::new();\n for i in 0..n {\n let mut b = a[i];\n let mut j = 0;\n while b != 0 {\n let v = map.entry(b).or_insert(vec![]);\n v.push(j);\n j += 1;\n b /= 2;\n }\n }\n //debug!(map);\n\n let mut ans = INF;\n let mut m = 1i64;\n while m < 1000000 {\n let v = map.entry(m).or_insert(vec![]);\n v.sort();\n if v.len() < k { m*=2; continue; }\n let mut cnt = 0i64;\n for i in 0..k {\n cnt += v[i];\n }\n ans = min(ans, cnt);\n m *= 2;\n }\n for i in 0..n {\n let v = map.entry(a[i]).or_insert(vec![]);\n v.sort();\n if v.len() < k { continue; }\n let mut cnt = 0i64;\n for j in 0..k {\n cnt += v[j];\n }\n ans = min(ans, cnt);\n }\n\n println!(\"{}\", ans);\n\n //}\n}\n\n/*\n\n\n*/\n", "lang": "Rust", "bug_code_uid": "ef10406c9ad4bdacfc612d30526d2a73", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "apr_id": "64b98f6a89dd120bf58d6fb915fd0800", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.969661610268378, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "\nfn main() {\n let n: u32 = get_input().parse().unwrap();\n let days: Vec = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();\n let total: u32 = days.iter().sum();\n //println!(\"total is {}\", total);\n let m = {\n if total > n {\n n\n } else if total == n {\n n\n } else {\n n % total\n }\n };\n\n let mut c = 0;\n\n //println!(\"mod is {}\", m);\n for i in 0..days.len() {\n //println!(\"c is {}\", c);\n c += days[i];\n\n if c >= m {\n println!(\"{}\", i+1);\n break;\n }\n }\n}\n\nfn get_input() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n buffer.trim().to_owned()\n}\n\nfn get_input_usize() -> usize {\n get_input().parse().unwrap()\n}\n", "lang": "Rust", "bug_code_uid": "83b3cad2035ee9b01b12d5cc9abc20c2", "src_uid": "007a779d966e2e9219789d6d9da7002c", "apr_id": "f0add05df3bdf1922614970765c72580", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9995658780117213, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "//spnauti-rusT {{{\nuse std::io::*; use std::str::{self,*}; use std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)] macro_rules! min {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! max {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};\n\t($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};\n\t(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};\n}\n#[allow(unused_macros)] macro_rules! v {\n\t([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};\n\t([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: v!([]), pos: 0 }\n\t}\n\tfn next_line(&mut self) -> bool {\n\t\tself.buf.clear(); self.pos = 0;\n\t\tself.q.read_until(b'\\n', &mut self.buf).unwrap_or(0) > 0\n\t}\n\tfn is_ws(c: u8) -> bool {\n\t\tc == b' ' || c == b'\\r' || c == b'\\n' || c == b'\\t'\n\t}\n\tfn byte(&mut self) -> Option {\n\t\tif self.pos == self.buf.len() { if !self.next_line() { return None; } }\n\t\tself.pos += 1; Some(self.buf[self.pos - 1])\n\t}\n\tfn vb(&mut self) -> Vec {\n\t\tlet mut s = v!([8]);\n\t\tlet mut f = false;\n\t\tloop {\n\t\t\tif let Some(c) = self.byte() {\n\t\t\t\tif !Self::is_ws(c) {\n\t\t\t\t\ts.push(c);\n\t\t\t\t\tf = true;\n\t\t\t\t} else if f { break; }\n\t\t\t} else { break; }\n\t\t}\n\t\ts\n\t}\n\tfn board(&mut self, r: usize, c: Option) -> Vec> {\n\t\tlet mut res = v!([r]);\n\t\tlet c = c.unwrap_or(0);\n\t\trep!{[r]\n\t\t\tlet t = self.vb();\n\t\t\tassert!(c == 0 || t.len() == c);\n\t\t\tres.push(t);\n\t\t}\n\t\tres\n\t}\n\tfn framed_board(&mut self, r: usize, c: usize, f: u8) -> Vec> {\n\t\tlet mut res = v!([r+2]);\n\t\tres.push( v!([c+2] = f) );\n\t\trep!{[r]\n\t\t\tlet mut t = self.vb();\n\t\t\tassert!(t.len() == c);\n\t\t\tt.reserve(2);\n\t\t\tt.insert(0,f);\n\t\t\tt.push(f);\n\t\t\tres.push(t);\n\t\t}\n\t\tres.push( v!([c+2] = f) );\n\t\tres\n\t}\n\tfn s(&mut self) -> String { String::from_utf8(self.vb()).expect(\"invalid utf8\") }\n\tfn i(&mut self) -> i32 { self.p() }\n\tfn l(&mut self) -> i64 { self.p() }\n\tfn u(&mut self) -> usize { self.p() }\n\tfn f(&mut self) -> f64 { self.p() }\n\tfn vi(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vl(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vu(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn ii(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn iu(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn p(&mut self) -> T where T::Err: Debug {\n\t\tlet w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::().unwrap()\n\t}\n\tfn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n\t\t(0..n).map(|_|self.p()).collect()\n\t}\n\tfn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n\t\tself.vp(n).into_iter()\n\t}\n\tfn graph(&mut self, n: usize, m: usize) -> Vec> {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); e[a].push(b); e[b].push(a); } e\n\t}\n\tfn graph_w(&mut self, n: usize, m: usize) -> Vec> where T::Err: Debug {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); let c: T = self.p(); e[a].push((b,c)); e[b].push((a,c)); } e\n\t}\n}\n//------------------- End rusT }}}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tl!(n,m,i,j,a,b = rin.i());\n\tlet mut sol = None;\n\tfor &(x,y) in [(1,1), (1,m), (n,1), (n,m)].iter() {\n\t\tif (x - i) % a == 0 && (y - j) % b == 0 {\n\t\t\tlet xx = (x - i).abs() / a;\n\t\t\tlet yy = (y - j).abs() / b;\n\t\t\tlet mx = xx > 0 || a < m;\n\t\t\tlet my = yy > 0 || b < n;\n\t\t\tif (xx == 0 && yy == 0) || (mx && my && (xx ^ yy) & 1 == 0) {\n\t\t\t\tlet res = xx.max(yy).min(sol.unwrap_or(1000000000));\n\t\t\t\tsol.replace(res);\n\t\t\t}\n\t\t}\n\t}\n\tif let Some(ans) = sol {\n\t\twriteln!(rout, \"{}\", ans).ok();\n\t} else {\n\t\twriteln!(rout, \"Poor Inna and pony!\").ok();\n\t}\n}\n", "lang": "Rust", "bug_code_uid": "419ca28b47fdcce31fa5f0e58986ccb8", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "apr_id": "6eebeb821beeda3f1dbb2e94b7950423", "difficulty": 2000, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9653733833959116, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 5, "bug_source_code": "#[allow(unused)] use std::io::*;\n#[allow(unused)] use std::collections::*;\n#[allow(unused)] use std::mem::*;\n#[allow(unused)] use std::num::*;\n#[allow(unused)] use std::cmp::*;\n#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{\n let mut inp = String::new(); stdin().read_line(&mut inp).ok();\n let s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).collect();\n let mut cnt : usize = 0;\n fn next(cnt: &mut usize, p: &Vec<&str>) -> T where T:std::str::FromStr\n { *cnt += 1; p[*cnt-1].parse().ok().unwrap() }\n ($(next::<$x>(&mut cnt, &s)), +)\n }}; }\n#[allow(unused)] macro_rules! arr { ($n:expr, $T:ty) => {{\n let mut inp = String::new(); stdin().read_line(&mut inp).ok();\n let mut s = inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0);\n let mut v = Vec::new(); v.reserve(($n) as usize);\n for st in s { v.push(st.parse::<$T>().unwrap()); } v\n }}; }\n\n///////////////////////////////////////////////////////////////////////////////\nfn main()\n{\n let a = scan!(i32);\n let b = scan!(i32);\n let c = scan!(i32);\n println!(\"{}\", max(max(max(a + b + c, a * b * c), (a + b) * c), a + b * c));\n}\n", "lang": "Rust", "bug_code_uid": "f11bb03bb7bdb15f1b95bab864c35022", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "3efa61160567f92d83f0da0a2c1fdd62", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9966329966329966, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn input() -> u8 {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n}\n\nfn main() {\n let (a, b, c) = (input(), input(), input());\n println!(\n \"{}\",\n [\n a + b + c,\n a + b * c,\n a * b + c,\n a * b * c,\n (a + b) * c,\n a * (b + c)\n ]\n .iter()\n .max()\n .unwrap()\n );\n}", "lang": "Rust", "bug_code_uid": "bc00d5615e6fb31716e0456b77c13bdf", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "132861559d567d7557a232f7c06b33cc", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7215295095594347, "equal_cnt": 12, "replace_cnt": 7, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 12, "bug_source_code": "use std::io;\nuse std::cmp::{min, max};\n\nfn main() {\n let stdin = io::stdin();\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let a: i32 = s.trim().parse().unwrap();\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let b: i32 = s.trim().parse().unwrap();\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let c: i32 = s.trim().parse().unwrap();\n\n let x = min(a, min(b, c));\n let z = max(a, max(b, c));\n let y = a + b + c - x - z;\n\n if x == 1 && y == 1 && z == 1 {\n println!(\"3\");\n } else if x == 1 && y == 1 {\n println!(\"{}\", 2*z);\n } else if x == 1 {\n println!(\"{}\", (y+1)*z);\n } else {\n println!(\"{}\", x*y*z);\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "a3833bf230972b18d62ab5c9e49961bd", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "122b5e65268b03097f844ba87a18f738", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9508571428571428, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::*;\n\nfn read(i: &mut StdinLock) -> T {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let a: i64 = read(sin);\n let b: i64 = read(sin);\n let c: i64 = read(sin);\n\n if b == 1 {\n let ans = if a <= c {\n if c == 1 {\n // a == b == c == 1\n a + b + c\n } else {\n (a + b) * c\n }\n } else {\n a * (b + c)\n };\n println!(\"{}\", ans);\n return;\n }\n\n let pre_val = if a == 1 { a + b } else { a * b };\n let ans = if c == 1 { pre_val + c } else { pre_val * c };\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "c5da89e9d9eb292bbfd7495a5e668540", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "97eeb5b447556ac32e44803bb844154c", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9991967871485944, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut a = String::new();\n let mut b = String::new();\n let mut c = String::new();\n\n io::stdin()\n .read_line(&mut a)\n .unwrap();\n\n io::stdin()\n .read_line(&mut b)\n .unwrap();\n\n io::stdin()\n .read_line(&mut c)\n .unwrap();\n\n let a: i64 = a.trim().parse().unwrap();\n let b: i64 = b.trim().parse().unwrap();\n let c: i64 = c.trim().parse().unwrap();\n\n println!(\"{}\",\n [\n (a+b)*c,\n a*b+c,\n a+b*c,\n a+b+c,\n a*b*c,\n a*(b+c)\n ]\n .iter()\n .max()\n .unwrap();\n );\n}\n\n", "lang": "Rust", "bug_code_uid": "ff7e52b6f83bc7e8e758c1df7bc549a9", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "79d00422b3852e5063983d46bd68e1be", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.875270367700072, "equal_cnt": 7, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 6, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_int() -> T{\n read_str().parse::().ok().expect(\"Error\")\n}\n\nfn main() {\n let (a, b, c): (u8, u8, u8) = (read_int(), read_int(), read_int());\n\n if a == 1 {\n if c == 1 { println!(\"{}\", a + b + c); }\n else { println!(\"{}\", (a + b) * c); }\n }\n else if b == 1 {\n if a > c { println!(\"{}\", a * (b + c)); }\n else { println!(\"{}\", (a + b) * c); }\n }\n else if c == 1 { println!(\"{}\", a * (b + c)); }\n else { println!(\"{}\", a * b * c); }\n}", "lang": "Rust", "bug_code_uid": "6a9aba9805fb3d92c7ca446045e0d4f3", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "5fc2620fafd79e6cc3d081bd04d30570", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9847457627118644, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 7, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_int() -> T{\n read_str().parse::().ok().expect(\"Error\")\n}\n\nfn main() {\n let (a, b, c): (u16, u16, u16) = (read_int(), read_int(), read_int());\n\n if a + c == 2 { println!(\"{}\", a + b + c); }\n else if b == 1 || c == 1 {\n if a < c { println!(\"{}\", (a + b) * c); }\n else { println!(\"{}\", a * (b + c)); }\n }\n else { println!(\"{}\", a * b * c); }\n}", "lang": "Rust", "bug_code_uid": "67ae407f1e3ef36e37cdcdfb7a1b0a0b", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "5fc2620fafd79e6cc3d081bd04d30570", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9951489951489951, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n\tlet mut k = String::new();\n\tio::stdin().read_line(&mut k).unwrap();\n\tlet k: i32 = k.trim().parse().unwrap();\n\n\tlet mut l = String::new();\n\tio::stdin().read_line(&mut l).unwrap();\n\tlet l: i32 = l.trim().parse().unwrap();\n\n\tlet mut m = String::new();\n\tio::stdin().read_line(&mut m).unwrap();\n\tlet m: i32 = m.trim().parse().unwrap();\n\n\tlet mut n = String::new();\n\tio::stdin().read_line(&mut n).unwrap();\n\tlet n: i32 = n.trim().parse().unwrap();\n\n\tlet mut d = String::new();\n\tio::stdin().read_line(&mut d).unwrap();\n\tlet d: i32 = d.trim().parse().unwrap();\n\n\tlet mut ans = 0;\n\tfor i in 0..d {\n\t\tif i % k == 0 || i % l == 0 || i % m == 0 || i % n == 0 {\n\t\t\tans += 1;\n\t\t}\n\t}\n\n\tprintln!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "d5d97473cccdd11fd0d1cc27b5436ba1", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "apr_id": "558169ec5985173f8d49177088b5b427", "difficulty": 800, "tags": ["math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9883923389437028, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n\n let mut d = String::new(); \n let mut klmn: [String;4] = [String::new(), String::new(),String::new(),String::new()];\n\n io::stdin().read_line(&mut klmn[0]).unwrap();\n io::stdin().read_line(&mut klmn[1]).unwrap();\n io::stdin().read_line(&mut klmn[2]).unwrap();\n io::stdin().read_line(&mut klmn[3]).unwrap();\n io::stdin().read_line(&mut d).unwrap();\n \n let nd: i32 = d.trim().parse().unwrap();\n let mut k: [i32; 4] = [0,0,0,0];\n k[0] = klmn[0].trim().parse().unwrap();\n k[1] = klmn[1].trim().parse().unwrap();\n k[2] = klmn[2].trim().parse().unwrap();\n k[3] = klmn[3].trim().parse().unwrap();\n if k[0] == 1 || k[1] == 1 || k[2] == 1 ||k[3] == 1 {println!(\"{}\",nd);return;}\n let mut count = 1;\n for i in 1..nd {\n if i % k[0] == 0 || i % k[1] == 0 || i % k[2] == 0 || i % k[3] == 0 {\n count = count + 1;\n }\n }\n println!(\"{}\",count);\n}\n\n// fn count_primes(n: i32) -> i32 {\n// let mut count = 0\n// if n <= 1 { return 0; }\n// else if n == 2 { count++; }\n// else if n % 2 == 0{ return false; }\n// else {\n// let mut i = 1;\n// while i < sqrt(n){\n// i = i + 2;\n// if n % i == 0 {\n// return false;\n// }\n// }\n// return true;\n// }\n// }\n\n// fn is_prime(n: i32) -> bool {\n// if n <= 1 { return false; }\n// else if n == 2 { return true; }\n// else if n % 2 == 0{ return false; }\n// else {\n// let mut i = 1;\n// while i < sqrt(n){\n// i = i + 2;\n// if n % i == 0 {\n// return false;\n// }\n// }\n// return true;\n// }\n// }\n", "lang": "Rust", "bug_code_uid": "d090aa700f97777a999211669e3c6294", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "apr_id": "899447b9453bc0ccbae63da8e9fd83c3", "difficulty": 800, "tags": ["math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9964448958862366, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{min,max};\nuse std::io::{BufWriter, stdin, stdout, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let out = &mut BufWriter::new(stdout());\n\n\tlet k = scan.next::();\n\tlet l = scan.next::();\n\tlet m = scan.next::();\n\tlet n = scan.next::();\n\tlet d = scan.next::();\n\n let res = (0..d).filter(|x| x % k == 0 || x % l == 0 || x % m == 0 || x % n == 0).count();\n writeln!(out, \"{}\", res).expect(\"fail\");\n}\n", "lang": "Rust", "bug_code_uid": "44109d90c8e6acb42d4f0426cfc91e33", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "apr_id": "065600179bb20ba7afca2d619706ba70", "difficulty": 800, "tags": ["math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9723349317594984, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "#[warn(unused_variables)]\nfn main() {\n let v = input_vec::(\" \");\n let n = v[0];\n let d = v[1];\n\n let mut count = 0;\n let mut pu = true;\n let p = input_str();\n for n in p.split(\"1\") {\n if n.chars().count() >= d {\n pu = false;\n }\n }\n\n if !pu {\n println!(\"-1\")\n } else {\n let mut ci = 0;\n let mut cs = d;\n 'a: loop {\n if ci + d >= n-1 {\n println!(\"{}\", count+1);\n break 'a;\n }\n \n if p.chars().collect::>()[ci + cs] != '0' {\n count += 1;\n ci += cs;\n cs = d;\n } else {\n cs -= 1;\n }\n }\n }\n\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": "Rust", "bug_code_uid": "d03862cd12a22a456b4ca7681c862e8d", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "apr_id": "d3d4813722b7863c3a5fd5a20ec4179d", "difficulty": 800, "tags": ["dp", "greedy", "dfs and similar", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9922265408106608, "equal_cnt": 8, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn gcd(mut u: u32, mut v: u32) -> u32 {\n if u == 0 {\n return v;\n }\n if v == 0 {\n return u;\n }\n\n let mut shift = 0;\n let mut aux : [u32; 2] = [(u | v), 1];\n while aux[0] & aux[1] == 0 {\n shift += 1;\n aux[1] <<= 1;\n }\n u >>= shift;\n v >>= shift;\n\n while u & 1 == 0 {\n u >>= 1;\n }\n\n loop {\n while v & 1 == 0 {\n v >>= 1;\n }\n \n if u > v {\n aux[0] = v;\n v = u;\n u = aux[0];\n }\n v -= u;\n\n if v == 0 {\n break;\n }\n }\n u << shift\n}\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).expect(\"failed to read input\");\n let mut input_iter = input.split_whitespace();\n let a = input_iter.next().unwrap().parse::().unwrap();\n let b = input_iter.next().unwrap().parse::().unwrap();\n\n let md = if a > b { a - b } else { b - a };\n let sqrt_md = (md as f64).sqrt() as u32 + 1;\n let mut lcm_min = 4 * a * b;\n let mut min_k = 0;\n let mut vec = Vec::new();\n for i in (1..=sqrt_md).filter(|x| md % x == 0) {\n vec.push(md / i);\n\n let mut k = a % i;\n if k != 0 {\n k = i - k;\n }\n\n let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));\n if lcm < lcm_min {\n lcm_min = lcm;\n min_k = k;\n }\n }\n if md != 0 {\n for i in vec {\n let mut k = a % i;\n if k != 0 {\n k = i - k;\n }\n\n let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));\n if lcm < lcm_min {\n lcm_min = lcm;\n min_k = k;\n }\n }\n }\n\n println!(\"{}\", min_k);\n}", "lang": "Rust", "bug_code_uid": "ed4c6705481037ebc0ffdba964fea8dc", "src_uid": "414149fadebe25ab6097fc67663177c3", "apr_id": "a9fb3a88d895678ed2eda11c1787524e", "difficulty": 1800, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9714285714285714, "equal_cnt": 17, "replace_cnt": 8, "delete_cnt": 0, "insert_cnt": 8, "fix_ops_cnt": 16, "bug_source_code": "use std::io;\n\nfn gcd(mut u: u32, mut v: u32) -> u32 {\n if u == 0 {\n return v;\n }\n if v == 0 {\n return u;\n }\n\n let mut shift = 0;\n let mut aux : [u32; 2] = [(u | v), 1];\n while aux[0] & aux[1] == 0 {\n shift += 1;\n aux[1] <<= 1;\n }\n u >>= shift;\n v >>= shift;\n\n while u & 1 == 0 {\n u >>= 1;\n }\n\n loop {\n while v & 1 == 0 {\n v >>= 1;\n }\n \n if u > v {\n aux[0] = v;\n v = u;\n u = aux[0];\n }\n v -= u;\n\n if v == 0 {\n break;\n }\n }\n u << shift\n}\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).expect(\"failed to read input\");\n let mut input_iter = input.split_whitespace();\n let a = input_iter.next().unwrap().parse::().unwrap();\n let b = input_iter.next().unwrap().parse::().unwrap();\n\n let md = if a > b { a - b } else { b - a };\n let sqrt_md = (md as f64).sqrt() as u32 + 1;\n let mut lcm_min = 4 * a * b;\n let mut min_k = 0;\n let mut vec = Vec::new();\n for i in (1..=sqrt_md).filter(|x| md % x == 0) {\n vec.push(md / i);\n\n let mut k = a % i;\n if k != 0 {\n k = i - k;\n }\n\n let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));\n if lcm < lcm_min {\n lcm_min = lcm;\n min_k = k;\n }\n }\n for i in vec {\n let mut k = a % i;\n if k != 0 {\n k = i - k;\n }\n\n let lcm = (a + k) * (b + k) / (i * gcd((a + k) / i, (b + k) / i));\n if lcm < lcm_min {\n lcm_min = lcm;\n min_k = k;\n }\n }\n\n println!(\"{}\", min_k);\n}", "lang": "Rust", "bug_code_uid": "0eaada259668c74a19dc88c2d397dbfe", "src_uid": "414149fadebe25ab6097fc67663177c3", "apr_id": "a9fb3a88d895678ed2eda11c1787524e", "difficulty": 1800, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8275641025641025, "equal_cnt": 16, "replace_cnt": 12, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 15, "bug_source_code": "use std::io;\nuse std::fs::File;\nuse std::cmp;\n\nfn main() {\n let stdin = io::stdin();\n let buf :Box = if cfg!(feature = \"intxt\") {\n eprintln!(\"file mode\");\n let file = File::open(\"in.txt\").unwrap();\n Box::new(io::BufReader::new(file))\n } else {\n eprintln!(\"stdin mode\");\n Box::new(stdin.lock())\n };\n let mut sc = Scanner::new(buf);\n\n let (p, y) :(usize, usize) = (sc.next(), sc.next());\n let mut a = vec![false; y+1];\n let mp = cmp::min(p, (y as f32).sqrt() as usize) + 1;\n\n for x in 2..mp {\n if a[x] {\n continue;\n }\n let mut n = 2*x;\n while n < a.len() {\n a[n] = true;\n n += x;\n }\n }\n for (i, &b) in a.iter().enumerate().rev() {\n if i <= p {\n break;\n }\n if !b {\n println!(\"{}\", i);\n return;\n }\n }\n println!(\"{}\", -1);\n}\n\n\nstruct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n fn new(reader: B) -> Self {\n Self {\n reader,\n buffer: Vec::new(),\n }\n }\n\n fn next(&mut self) -> T\n where\n T::Err: std::fmt::Debug,\n {\n if let Some(s) = self.buffer.pop() {\n T::from_str(&s).unwrap()\n } else {\n let mut s = String::new();\n let r = self.reader.read_line(&mut s).unwrap();\n assert!(r > 0);\n self.buffer = s.split_whitespace().rev().map(String::from).collect();\n return self.next();\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "7ad5719ffb6dd72b50ad1f51ffcf491c", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "apr_id": "532a16171aa0d1dbc76e23a46ef26844", "difficulty": 1400, "tags": ["math", "brute force", "number theory"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6716981132075471, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "fn fix(balance: i64) -> i64 {\n if balance >= 0 {\n return balance;\n }\n\n let temp = balance * -1;\n let last_dig = temp % 10;\n let seclast_dig = (temp / 10) % 10;\n\n if last_dig > seclast_dig {\n balance / 10\n } else {\n (balance / 100) * 10 + last_dig\n }\n}\n\nfn main() {\n let balance: i64 = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n };\n\n let balance = fix(balance);\n println!(\"{}\", balance);\n}", "lang": "Rust", "bug_code_uid": "38bf470a17b8107591804c3fca417e60", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "apr_id": "bdbe2850215fa5f6a381fb0e1ddf4921", "difficulty": 900, "tags": ["number theory", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8330914368650217, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nfn get_num() -> isize {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input).expect(\"\");\n\n isize::from_str(input.trim()).unwrap()\n}\n\nfn main() {\n let n = get_num();\n\n println!(\n \"{}\",\n std::cmp::max(n, std::cmp::max(n / 10, n % 10 * 10 + n / 100 * 10))\n );\n}\n", "lang": "Rust", "bug_code_uid": "1990220ee5534628719656f943b11748", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "apr_id": "2f3e68a25943eba4e5d72c1d0dca15d5", "difficulty": 900, "tags": ["number theory", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9034248688676334, "equal_cnt": 11, "replace_cnt": 5, "delete_cnt": 4, "insert_cnt": 1, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn gcd(a: u64, b: u64) -> u64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let mut ans: u64;\n if n == 1 {\n ans = 1;\n } else if n == 2 {\n ans = 2;\n } else if n == 3 {\n ans = 6;\n } else {\n // pick n and n - 1, find another number coprime to both\n ans = n * (n - 1);\n for p in (1..(n - 1)).rev() {\n if gcd(n, p) == 1 && gcd(n - 1, p) == 1 {\n ans *= p;\n break;\n }\n }\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "9792c7ad4587c4be4110b09f0f21ecf7", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "apr_id": "8aa823d9f738d70960a114ab04fe5aff", "difficulty": 1600, "tags": ["greedy", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9922151450813871, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::stdin;\nuse std::process::exit;\n\n#[allow(dead_code)]\nfn input_strs() -> Vec {\n let mut st = String::new();\n match stdin().read_line(&mut st) {\n Ok(_) => st.chars().collect(),\n Err(_) => panic!(\"err\"),\n }\n}\n\n#[allow(dead_code)]\nfn input_ints() -> Vec {\n let mut st = String::new();\n match stdin().read_line(&mut st) {\n Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),\n Err(_) => panic!(\"err\"),\n }\n}\n\nfn solve() {\n let l = input_ints();\n let n = l[0] as u32;\n if n % 2 == 0 {\n println!(\"{}\", (n / 2).pow(n / 2));\n } else {\n println!(\"{}\", 0);\n }\n}\n\nfn main() {\n solve();\n exit(0);\n}", "lang": "Rust", "bug_code_uid": "2da71502eb2c324c19d028693108b2ce", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "apr_id": "81a553e300d32c93eb01603df3586408", "difficulty": 1000, "tags": ["dp", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9852631578947368, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "#[warn(unused_variables)]\n\nfn main() {\n let n = input_::();\n println!(\"{}\", if n % 2 == 0 {n} else {0})\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": "Rust", "bug_code_uid": "561cb75a005e6345dde62e326c6b48b7", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "apr_id": "d79739e5229b80ff2c89f47033b456c5", "difficulty": 1000, "tags": ["dp", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9924731182795699, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 n: u32 = scan.next();\n if n < 2 {\n println!(\"0\");\n } else {\n println!(\"{}\", 2u64.pow(n / 2));\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": "Rust", "bug_code_uid": "39791a260a1dc4e2f06f8243af33d3e0", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "apr_id": "163ca00c49401d8ade528fe7efd376d1", "difficulty": 1000, "tags": ["dp", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.49406688241639696, "equal_cnt": 13, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 13, "bug_source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn next_index(len: usize, curr: usize, go_left: bool) -> Option {\n if len % 2 == 0 {\n if go_left {\n if len >= curr + 1 {\n Some(len - curr - 1)\n } else {\n None\n }\n } else {\n if len >= curr + 2 {\n Some(len - curr - 2)\n } else {\n None\n }\n }\n } else {\n if go_left {\n if len >= curr + 1 {\n Some(len - curr - 1)\n } else {\n None\n }\n } else {\n if len >= curr {\n Some(len - curr)\n } else {\n None\n }\n }\n }\n}\n\nfn main() {\n let message = readln!();\n let message = message.chars().collect::>();\n\n if message.len() == 1 {\n println!(\"z\");\n return;\n }\n\n let mut index = (message.len() - 1) / 2;\n let mut go_left = true;\n loop {\n print!(\"{}\", message[index]);\n\n match next_index(message.len(), index, go_left) {\n None => break,\n Some(new_index) => index = new_index\n };\n go_left = !go_left;\n }\n println!();\n}\n", "lang": "Rust", "bug_code_uid": "67d035379a30b951742920ff101efcae", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "apr_id": "fcf32e7f2c1bca5b434548d11cb01711", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4905390931810068, "equal_cnt": 13, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 13, "bug_source_code": "use std::io;\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn next_index(len: usize, curr: usize, go_left: bool) -> Option {\n if len % 2 == 0 {\n if go_left {\n if len >= curr + 1 {\n Some(len - curr - 1)\n } else {\n None\n }\n } else {\n if len >= curr + 2 {\n Some(len - curr - 2)\n } else {\n None\n }\n }\n } else {\n if go_left {\n if len >= curr + 1 {\n Some(len - curr - 1)\n } else {\n None\n }\n } else {\n if len >= curr && len - curr < len {\n Some(len - curr)\n } else {\n None\n }\n }\n }\n}\n\nfn main() {\n let message = readln!();\n let message = message.chars().collect::>();\n\n if message.len() == 1 {\n println!(\"z\");\n return;\n }\n\n let mut index = (message.len() - 1) / 2;\n let mut go_left = true;\n loop {\n print!(\"{}\", message[index]);\n\n match next_index(message.len(), index, go_left) {\n None => break,\n Some(new_index) => index = new_index\n };\n go_left = !go_left;\n }\n println!();\n}\n", "lang": "Rust", "bug_code_uid": "f5506fead145eac291f0f99a88fa9ea9", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "apr_id": "fcf32e7f2c1bca5b434548d11cb01711", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9977637335926106, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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::iter::FromIterator;\n#[allow(unused_imports)]\nuse std::io::stdin;\n\nmod util {\n use std::io::stdin;\n use std::str::FromStr;\n use std::fmt::Debug;\n\n #[allow(dead_code)]\n pub fn line() -> String {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().to_string()\n }\n\n #[allow(dead_code)]\n pub fn gets() -> Vec\n where\n ::Err: Debug,\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse().unwrap())\n .collect()\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\n// https://github.com/bluss/permutohedron\npub trait LexicalPermutation {\n /// Return `true` if the slice was permuted, `false` if it is already\n /// at the last ordered permutation.\n fn next_permutation(&mut self) -> bool;\n /// Return `true` if the slice was permuted, `false` if it is already\n /// at the first ordered permutation.\n fn prev_permutation(&mut self) -> bool;\n}\n\nimpl LexicalPermutation for [T]\nwhere\n T: Ord,\n{\n /// Original author in Rust: Thomas Backman \n fn next_permutation(&mut self) -> bool {\n // These cases only have 1 permutation each, so we can't do anything.\n if self.len() < 2 {\n return false;\n }\n\n // Step 1: Identify the longest, rightmost weakly decreasing part of the vector\n let mut i = self.len() - 1;\n while i > 0 && self[i - 1] >= self[i] {\n i -= 1;\n }\n\n // If that is the entire vector, this is the last-ordered permutation.\n if i == 0 {\n return false;\n }\n\n // Step 2: Find the rightmost element larger than the pivot (i-1)\n let mut j = self.len() - 1;\n while j >= i && self[j] <= self[i - 1] {\n j -= 1;\n }\n\n // Step 3: Swap that element with the pivot\n self.swap(j, i - 1);\n\n // Step 4: Reverse the (previously) weakly decreasing part\n self[i..].reverse();\n\n true\n }\n\n fn prev_permutation(&mut self) -> bool {\n // These cases only have 1 permutation each, so we can't do anything.\n if self.len() < 2 {\n return false;\n }\n\n // Step 1: Identify the longest, rightmost weakly increasing part of the vector\n let mut i = self.len() - 1;\n while i > 0 && self[i - 1] <= self[i] {\n i -= 1;\n }\n\n // If that is the entire vector, this is the first-ordered permutation.\n if i == 0 {\n return false;\n }\n\n // Step 2: Reverse the weakly increasing part\n self[i..].reverse();\n\n // Step 3: Find the rightmost element equal to or bigger than the pivot (i-1)\n let mut j = self.len() - 1;\n while j >= i && self[j - 1] < self[i - 1] {\n j -= 1;\n }\n\n // Step 4: Swap that element with the pivot\n self.swap(i - 1, j);\n\n true\n }\n}\n\nfn main() {\n let mut v = get!(usize;;);\n\n v.sort();\n\n if v[0] == 1 {\n println!(\"YES\");\n return;\n }\n\n while {\n let a = v[0];\n let b = v[1];\n let c = v[2];\n\n let t0 = 0;\n let t1 = 1;\n\n let mut t2 = 0;\n\n for t in 2..2000 {\n if !((t - t0) % a == 0 || (t - t1) % b == 0) {\n t2 = t;\n }\n }\n\n if (0..2000).all(|t| {\n (t >= t0 && (t - t0) % a == 0) || (t >= t1 && (t - t1) % b == 0)\n || (t >= t2 && (t - t2) % c == 0)\n }) {\n println!(\"YES\");\n return;\n }\n\n v.next_permutation()\n } {}\n\n println!(\"NO\");\n}\n", "lang": "Rust", "bug_code_uid": "96f5411bd4d14bbc7a239d832fa23f5c", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "apr_id": "a895b4e702c070d7a2e881feae47b30a", "difficulty": 1400, "tags": ["brute force", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9871175523349437, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let ios = io::stdin(); // create stdin instance\n let mut inp : String = String::new(); // initialize mutable temporary variable >.<\n ios.read_line(&mut inp); // pass mutable reference to readline\n\n // read multiple numbers\n let inps : Vec = inp.trim().split(\" \").map(|x| x.parse().expect(\"wo\")).collect(); // this is ruby like syntax\n\n let n = inps[0];\n let m = inps[1];\n let a = inps[2];\n\n // need string literals to print numbers\n println!(\"{}\", ceil(n, a) * ceil(m, a));\n}\n\nfn ceil(x: i32, y: i32) -> i32 {\n if x % y == 0 { x / y } else { x / y + 1 }\n}\n", "lang": "Rust", "bug_code_uid": "003abd40ee748a538b08332aa4ae0df8", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "188d40d4cde980b32d10f1b403a83fd4", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9616568709767702, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "#![allow(dead_code)]\n#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(overflowing_literals)]\n#![allow(unused_must_use)]\n#![allow(non_camel_case_types)]\n\nuse std::collections::*;\nuse std::io::*;\nuse std::cmp::{max, min, Ordering};\nuse std::f64::consts::*;\nuse std::mem::{swap, size_of_val, size_of};\nuse std::fs::File;\nuse std::rc::*;\nuse std::ascii::*;\nuse std::ops::*;\nuse std::num::*;\nuse std::process::*;\n//use std::ptr::*;\nuse std::iter::{once, repeat};\n\nconst INF: i32 = std::i32::MAX;\nconst LINF: i64 = std::i64::MAX;\nconst MOD: usize = 1000000007;\n\nstruct Input {\n\tbuffer: Buf,\n}\n\nimpl Input {\n\tfn read_char(&mut self) -> char {\n\t\tlet mut x = [255u8];\n\t\tself.buffer.read(&mut x).expect(\"EOF\");\n\t\tx[0] as char\n\t}\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}\n\nmacro_rules! read {\n () => {};\n\t($inf:ident, $t:ty) => ($inf.read_word().parse::<$t>().expect(\"Parsing error\"));\n\t($inf:ident, $($t:ty),*) => (($($inf.read_word().parse::<$t>().expect(\"Parsing error\")),*));\n}\nfn gcd(mut a: T, mut b: T) -> T\n\twhere T: ShrAssign + BitAnd + Ord + From + Clone + SubAssign + ShlAssign + Copy\n{\n\tlet one = T::from(1);\n\tlet zero = T::from(0);\n\tlet mut ans = 0;\n\tif a < b {\n\t\tswap(&mut a, &mut b);\n\t}\n\twhile b > zero {\n\t\tif (a & one > zero) && (b & one > zero) {\n\t\t\ta -= b;\n\t\t} else if a & one > zero {\n\t\t\tb >>= one;\n\t\t} else if b & one > zero {\n\t\t\ta >>= one;\n\t\t} else {\n\t\t\tans += 1;\n\t\t\ta >>= one;\n\t\t\tb >>= one;\n\t\t}\n\t\tif a < b {\n\t\t\tswap(&mut a, &mut b);\n\t\t}\n\t}\n\ta <<= ans;\n\ta\n}\n\nfn powmod(mut base: X, mut exp: Y, mm: X) -> X\n\twhere X: Copy + Clone + Mul + Rem + From,\n\t Y: ShrAssign + Copy + Clone + BitAnd + From + Ord\n{\n\tlet mut res = X::from(1);\n\twhile exp > Y::from(0) {\n\t\tif exp & Y::from(1) > Y::from(0) {\n\t\t\tres = res * base % mm;\n\t\t}\n\t\tbase = base * base % mm;\n\t\texp >>= Y::from(1);\n\t}\n\tres\n}\n\nfn main() {\n\tmatch std::env::var(\"home\") {\n\t\tOk(_x) => {\n\t\t\tlet mut inf = Input { buffer: BufReader::new(File::open(\"input.txt\").expect(\"File not found\")) };\n\t\t\tlet stdout = stdout();\n\t\t\tlet ostr = stdout.lock();\n\t\t\tlet mut ouf = BufWriter::new(ostr);\n\t\t\tsolve(&mut inf, &mut ouf);\n\t\t}\n\t\tErr(_e) => {\n\t\t\tlet stdin = stdin();\n\t\t\tlet istr = stdin.lock();\n\t\t\tlet mut inf = Input { buffer: BufReader::new(istr) };\n\t\t\tlet stdout = stdout();\n\t\t\tlet ostr = stdout.lock();\n\t\t\tlet mut ouf = BufWriter::new(ostr);\n\t\t\tsolve(&mut inf, &mut ouf);\n\t\t}\n\t}\n}\n\n\nfn solve(inf: &mut Input, ouf: &mut Output) {\n\tlet (n, d) = read!(inf,usize,i32);\n\tlet mut a = vec![0; n];\n\tfor i in 0..n {\n\t\ta[i] = read!(inf,i32);\n\t}\n\ta.sort_unstable();\n\tlet (mut p1, mut p2) = (0, n - 1);\n\twhile p2 > 0 && a[p2] - a[0] > d {\n\t\tp2 -= 1;\n\t}\n\twhile p1 < n - 1 && a[n - 1] - a[p1] > d {\n\t\tp1 += 1;\n\t}\n\twriteln!(ouf, \"{}\", min(p1, n - 1 - p2));\n}\n", "lang": "Rust", "bug_code_uid": "e128d3f4d51e59b7de824271b912948b", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "apr_id": "629c588f9eebadba878dba68af7b9fbd", "difficulty": 1200, "tags": ["greedy", "brute force", "sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.983083306734759, "equal_cnt": 8, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 6, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn read_line() -> io::Result {\n let mut input_str = String::new();\n\n try!(io::stdin().read_line(&mut input_str));\n\n Ok(input_str)\n}\n\nfn a_to_b(a: u32, b: u32) -> Vec {\n let mut result = Vec::new();\n let mut current_state = b;\n\n loop {\n match current_state {\n x if x < a || x % 2 != 0 && x % 10 != 1 => {\n result.clear();\n break;\n }\n x => {\n result.push(x);\n match x {\n x if x == a => break, \n x if x % 2 == 0 => current_state /= 2,\n _ => current_state /= 10, \n }\n } \n }\n }\n\n result.reverse();\n result\n}\n\nfn main() {\n let input_line = read_line().expect(\"Failed to read line.\");\n let mut input_line_iter = input_line.split_whitespace();\n\n let given_number = input_line_iter.next()\n .expect(\"First number is not given.\")\n .parse::()\n .expect(\"First number is invalid.\");\n let result_number = input_line_iter.next()\n .expect(\"Second number is not given.\")\n .parse::()\n .expect(\"Second number is invalid\");\n\n let answer_sequence = a_to_b(given_number, result_number);\n\n match answer_sequence.len() {\n 0 => println!(\"NO\"),\n len => {\n println!(\"YES\\n{}\", len);\n for number in answer_sequence {\n print!(\"{} \", number);\n }\n } \n }\n}\n", "lang": "Rust", "bug_code_uid": "480c1dee6aea565a586b11b678e350f5", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "apr_id": "df161c40c25bbb01a85e9a593378b0a7", "difficulty": 1000, "tags": ["brute force", "math", "dfs and similar"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6764346764346765, "equal_cnt": 16, "replace_cnt": 7, "delete_cnt": 4, "insert_cnt": 4, "fix_ops_cnt": 15, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next()).collect()\n }\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let mut c = [0usize; 3];\n for s in scan.next::().chars() {\n match s {\n 'B' => {\n c[0] += 1;\n }\n 'S' => {\n c[1] += 1;\n }\n 'C' => {\n c[2] += 1;\n }\n _ => {}\n }\n }\n let mut n: Vec = scan.next_n(3);\n let p: Vec = scan.next_n(3);\n let mut r: u64 = scan.next();\n let unit_price = (c[0] * p[0] + c[1] * p[1] + c[2] * p[2]) as u64;\n let mut result = 0u64;\n loop {\n if !n.iter().all(|x| *x == 0) {\n for i in 0..3 {\n if c[i] > n[i] && r >= ((c[i] - n[i]) * p[i]) as u64 {\n r -= ((c[i] - n[i]) * p[i]) as u64;\n n[i] = c[i];\n }\n }\n } else {\n break;\n }\n let mut buying = std::usize::MAX;\n for i in 0..3 {\n if c[i] != 0 {\n buying = buying.min(n[i] / c[i]);\n }\n }\n if buying == 0 {\n break;\n }\n for i in 0..3 {\n n[i] -= buying * c[i];\n }\n result += buying as u64;\n }\n result += r / unit_price;\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "bd8fe05607fb845f8fd0b5afb56445c0", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "apr_id": "9b218a0d8866f56c4b2ee5d250794e34", "difficulty": 1600, "tags": ["brute force", "binary search"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9994609164420485, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next()).collect()\n }\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let mut c = [0u64; 3];\n for s in scan.next::().chars() {\n match s {\n 'B' => {\n c[0] += 1;\n }\n 'S' => {\n c[1] += 1;\n }\n 'C' => {\n c[2] += 1;\n }\n _ => {}\n }\n }\n let n: Vec = scan.next_n(3);\n let p: Vec = scan.next_n(3);\n let r: u64 = scan.next();\n let mut low = 0u64;\n let mut high = 1000000000000u64;\n while low <= high {\n let middle = (low + high) / 2;\n let mut f = 0u64;\n for i in 0..3 {\n if c[i] * middle > n[i] {\n f += (c[i] * middle - n[i]) * p[i];\n }\n }\n if f <= r {\n low = middle + 1;\n } else {\n high = middle - 1;\n }\n }\n println!(\"{}\", low - 1);\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": "Rust", "bug_code_uid": "512ea54b08913418acdba3cb874444bb", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "apr_id": "9b218a0d8866f56c4b2ee5d250794e34", "difficulty": 1600, "tags": ["brute force", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9997439180537772, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\n#[allow(unused_macros)]\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nuse std::io::Write;\n\nfn solve(writer: &mut std::io::BufWriter) {\n let ss: Vec = parse_line!(String).bytes().collect();\n let b = ss.iter().filter(|c| **c == b'B').count() as u64;\n let s = ss.iter().filter(|c| **c == b'S').count() as u64;\n let c = ss.iter().filter(|c| **c == b'C').count() as u64;\n let (nb, ns, nc) = parse_line!(u64, u64, u64);\n let (pb, ps, pc) = parse_line!(u64, u64, u64);\n let r = parse_line!(u64);\n let mut l = 0;\n let mut u = 1000000000000;\n while u - l > 1 {\n let m = (l + u) / 2;\n let need =\n if b * m <= nb {0} else {pb * (b * m - nb)} +\n if s * m <= ns {0} else {ps * (s * m - ns)} +\n if c * m <= nc {0} else {pc * (c * m - nc)};\n if need <= r {\n l = m;\n }else{\n u = m;\n }\n }\n writeln!(writer, \"{}\", l).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": "Rust", "bug_code_uid": "231ac228b09aa410f1891f65d691e02b", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "apr_id": "e014d068f095f9ac704d3b01ec620c94", "difficulty": 1600, "tags": ["brute force", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8206724782067247, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "fn input() -> u8 {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().parse().unwrap()\n}\n\nfn input_split() -> Vec {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect()\n}\n\nfn main() {\n let mut k = input();\n let mut months = input_split();\n months.sort_unstable_by(|a, b| b.cmp(&a));\n\n let mut count = 0;\n\n if k != 0 {\n for month in months {\n count += 1;\n if month >= k {\n break;\n } else {\n k -= month;\n }\n }\n }\n\n if count == 12 && k != 0 {\n print!(\"-1\")\n } else {\n print!(\"{}\", count)\n }\n}", "lang": "Rust", "bug_code_uid": "2bb1bf100f2627f3f43d2154ae2e4a78", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "apr_id": "91fca4c8659cdca0ca36f68977f7f285", "difficulty": 900, "tags": ["greedy", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.3791469194312796, "equal_cnt": 9, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 9, "bug_source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(\n &mut std::io::stdin(),\n &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n ($t:ty) => (get().parse::<$t>().unwrap());\n () => (get!(i64));\n }\n \n let n = get!();\n let m = get!();\n let k = get!();\n \n if k < n {\n println!(\"1 {}\", k);\n return;\n }\n \n let e = k - n;\n let r = e / (m - 1);\n let c = e % (m - 1);\n \n let y = n - r;\n let x = if r % 2 == 0 { c + 1 } else { m - c }; \n \n // println!(\"{} {} {}\", e, r, c);\n println!(\"{} {}\", y, x);\n \n}\n", "lang": "Rust", "bug_code_uid": "57bd77f5450e2626fb545f36d0e31536", "src_uid": "e88bb7621c7124c54e75109a00f96301", "apr_id": "dc4f374c50f8bdcdd44bb9edf703ab3b", "difficulty": 1300, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9918657854600915, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 5, "fix_ops_cnt": 6, "bug_source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\n\n\nfn solve(n: i64, m: i64, k: i64) -> (i64, i64) {\n \n if k < n {\n return (k + 1, 1);\n }\n \n let e = k - n;\n let r = e / (m - 1);\n let c = e % (m - 1);\n \n let y = n - r;\n let x = if r % 2 == 0 { c + 2 } else { m - c }; \n \n return (y, x);\n}\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(\n &mut std::io::stdin(),\n &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n ($t:ty) => (get().parse::<$t>().unwrap());\n () => (get!(i64));\n }\n \n let n = get!();\n let m = get!();\n let k = get!();\n \n if n * m < 20 {\n for e in 0..n*m {\n let (row, col) = solve(n, m, e);\n let (r, c) = brute_force(n, m, e);\n if row != r || col != c {\n println!(\"error {} {} {}\", n, m, e);\n println!(\"solve {} {}\", row, col);\n println!(\"bf {} {}\", r, c);\n panic!();\n }\n }\n }\n \n let (row, col) = solve(n, m, k);\n \n println!(\"{} {}\", row, col);\n \n}\n\nfn brute_force(n: i64, m: i64, k: i64) -> (i64, i64) {\n let mut row = 1;\n let mut col = 1;\n let mut rem = k;\n \n if rem == 0 {\n return (row, col);\n }\n \n for _ in 0..n-1 {\n row += 1;\n rem -= 1;\n if rem == 0 {\n return (row, col);\n }\n }\n \n let mut state = 0;\n for _ in 0..rem {\n match state {\n 0 => {\n col += 1;\n if col == m {\n state += 1;\n }\n },\n 2 => {\n col -= 1;\n if col == 2 {\n state += 1;\n }\n },\n _ => {\n row -= 1;\n state = (state + 1) % 4;\n },\n }\n }\n return (row, col);\n}\n", "lang": "Rust", "bug_code_uid": "b2fef114cd6f7c39dc4d6da28498e986", "src_uid": "e88bb7621c7124c54e75109a00f96301", "apr_id": "dc4f374c50f8bdcdd44bb9edf703ab3b", "difficulty": 1300, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.889344262295082, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 4, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\nfn main() {\n let mut n = String::new();\n io::stdin().read_line(&mut n).expect(\"failed to read\");\n let n :usize = n.trim().parse().expect(\"failed to parse\");\n let counter = 0;\n if n/2520 >= 1 {\n let counter = counter + 1;\n println!(\"{}\", counter);\n }\n}\n", "lang": "Rust", "bug_code_uid": "0bb6cb1921da3525c44fb3ea2fcbfbf6", "src_uid": "8551308e5ff435e0fc507b89a912408a", "apr_id": "45f1566a971021b569afc610b5e40a74", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9820627802690582, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\nfn main() {\n let mut n = String::new();\n io::stdin().read_line(&mut n).expect(\"failed to read\");\n let n :i16 = n.trim().parse().expect(\"failed to parse\");\n let counter:i16 = n/2520;\n println!(\"{}\", counter);\n}\n", "lang": "Rust", "bug_code_uid": "40a8e7a03ce4bb799d7a0cc680240aa4", "src_uid": "8551308e5ff435e0fc507b89a912408a", "apr_id": "45f1566a971021b569afc610b5e40a74", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6967213114754098, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn min(a: u32, b: u32, c: u32) -> u32 {\n if a <= b {\n if a <= c {\n a\n } else {\n c\n }\n } else {\n if b <= c {\n b\n } else {\n c\n }\n }\n}\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"failed to read input\");\n io::stdin().read_line(&mut buffer).expect(\"failed to read input\");\n io::stdin().read_line(&mut buffer).expect(\"failed to read input\");\n let mut buffer_iter = buffer.split_whitespace().map(|n| n.parse::().unwrap());\n let b = buffer_iter.next().unwrap();\n let g = buffer_iter.next().unwrap();\n let n = buffer_iter.next().unwrap();\n\n println!(\"{}\", min(b, g, n) + 1);\n}", "lang": "Rust", "bug_code_uid": "607277b53ec46f212ded30ffad138b98", "src_uid": "9266a69e767df299569986151852e7b1", "apr_id": "73140fa545b25ef9c073276b1f996a95", "difficulty": 1100, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8346235045742435, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "use std::io::*;\n\nfn reads(i: &mut StdinLock) -> Vec {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let input: Vec = reads(sin);\n\n let initial_socks = input[0];\n let supply = input[1];\n\n let mut day_alive = initial_socks + (initial_socks / supply);\n\n if day_alive % supply == 0 {\n day_alive += 1;\n }\n\n // Does not he wash it?\n println!(\"{}\", day_alive);\n}\n", "lang": "Rust", "bug_code_uid": "940e344e34fe99b4cffa24b8054834e6", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "apr_id": "10b34a422720ef050c8a4741bc3871ba", "difficulty": 900, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.907942238267148, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nuse std::io::Stdin;\nuse std::str::FromStr;\n\nfn read_line(stdin : &Stdin, line : &mut String) {\n match stdin.read_line(line) {\n Ok(_) => return,\n Err(msg) => panic!(\"Could not read line! Message: {}.\", msg),\n }\n}\n\nfn parse_t(s : &str) -> T {\n match s.trim().parse() {\n Ok(y) => y,\n Err(_) => panic!(\"Could not read from string!\"),\n }\n}\n\nfn read_ts(stdin : &Stdin, ts : &mut Vec) {\n let mut line = String::new();\n read_line(stdin, &mut line);\n let word_iter = line.split_whitespace();\n for word in word_iter {\n let x = parse_t(word);\n ts.push(x);\n }\n}\n\nfn num_days(n : u64, m : u64) -> u64 {\n let mut s = 0;\n let mut p = 1;\n loop {\n if p > n {\n break;\n } else {\n s = s + (n / p);\n p = p * m;\n }\n }\n s\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut n_m : Vec = vec![];\n read_ts(&stdin, &mut n_m);\n let n = n_m[0];\n let m = n_m[1];\n println!(\"{}\", num_days(n, m));\n}\n", "lang": "Rust", "bug_code_uid": "c8eb4e8021fe76703b247390741f0b92", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "apr_id": "d8b133223aa8a1d3e23f2ee73b8a5edc", "difficulty": 900, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9142857142857143, "equal_cnt": 8, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 7, "bug_source_code": "use std::mem;\nuse std::io;\nuse std::string;\nuse std::cmp::*;\n\nfn load() -> Vec {\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"Failed to read line\");\n let vec: Vec<&str> = line.split(\" \").collect();\n let mut data : Vec = Vec::new();\n for i in vec {\n let el : i32 = i.trim().parse().unwrap();\n data.push(el);\n }\n data\n}\n\nfn main() {\n let ar = load();\n let (q,b) = (ar[0],ar[1]);\n let mut a = q;\n let mut res = a;\n while a > 0 {\n res += a/b;\n a/=b;\n }\n println!(\"{}\", res);\n}\n", "lang": "Rust", "bug_code_uid": "6331418c7e3549f8bd22fdbf72b3575e", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "apr_id": "8bd6e88e63309c25e42ec18fbc8b8636", "difficulty": 900, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9879262305957277, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet, BinaryHeap};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n\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#[allow(unused_macros)]\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {:?}\", stringify!($x), $x)\n }\n}\n\nfn main() {\n let n: usize = util::get();\n let ss: Vec> = (0..n)\n .map(|_| {\n let mut v: Vec = util::gets();\n v.sort();\n v\n })\n .collect();\n\n let ans = (1..)\n .take_while(|&x| if x < 10 {\n ss.iter().any(|v| v.binary_search(&x).is_ok())\n } else if x < 100 {\n let a1 = x % 10;\n let a2 = x / 10;\n\n let h1 = (0..ss.len())\n .filter(|&i| ss[i].binary_search(&a1).is_ok())\n .collect::>();\n let h2 = (0..ss.len())\n .filter(|&i| ss[i].binary_search(&a2).is_ok())\n .collect::>();\n\n (h1.len() > 1 && h2.len() > 1) || h1.difference(&h2).count() != 0 ||\n h2.difference(&h1).count() != 0\n\n } else {\n let perm = vec![\n vec![0, 1, 2],\n vec![0, 2, 1],\n vec![1, 0, 2],\n vec![1, 2, 0],\n vec![2, 0, 1],\n vec![2, 1, 0],\n ];\n\n let a1 = x % 10;\n let a2 = x / 10 % 10;\n let a3 = x / 100;\n let a = vec![a1, a2, a3];\n\n if n < 3 {\n false\n } else {\n perm.iter().any(|p| {\n p.iter().zip(a.iter()).all(|(&i, &k)| {\n ss[i].binary_search(&k).is_ok()\n })\n })\n }\n\n })\n .last();\n\n if let Some(a) = ans {\n println!(\"{}\", a);\n } else {\n println!(\"0\");\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "8a0ba3b6d0c6e28b2c312079cc06bbe4", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "apr_id": "cd7625174d96346e4790f7fe182f46ed", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9410819496518479, "equal_cnt": 10, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 8, "fix_ops_cnt": 9, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::cmp::{max, min};\n\nfn get_line() -> String {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input\n}\n\nfn get_vec() -> Vec\nwhere T: FromStr,\n ::Err: std::fmt::Debug,\n{\n get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn extended_euclid(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n (a, 1, 0)\n } else {\n let (d0, x0, y0) = extended_euclid(b, a % b);\n (d0, y0, x0 - a / b * y0)\n }\n}\n\nfn main() {\n let n: usize = get_line().trim().parse().unwrap();\n\n let cubes: Vec<_> = BufReader::new(io::stdin()).lines()\n .map(|s| {\n let s = s.unwrap();\n let mut cube = [false; 10];\n for s in s.split_whitespace() {\n let d = s.bytes().last().unwrap();\n let d = (d - b'0') as usize;\n cube[d] = true;\n }\n cube\n }).collect();\n\n let perms = [\n [0, 1, 2],\n [0, 2, 1],\n [1, 0, 2],\n [1, 2, 0],\n [2, 0, 1],\n [2, 1, 0],\n ];\n\n let fact = |n| {\n let mut ret_val = 1;\n for i in 0..n {\n ret_val *= i + 1;\n }\n ret_val\n };\n\n let check = |x| {\n let x = format!(\"{}\", x);\n for perm in perms.iter().take(fact(n)) {\n let p = x.bytes().map(|b| (b - b'0') as usize)\n .zip(perm.iter()).all(|(d, &i)| cubes[i][d]);\n if p {\n return true;\n }\n }\n false\n };\n\n for i in 1.. {\n if !check(i) {\n println!(\"{}\", i - 1);\n return;\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "1fe940f77aababef8056ebe456edd481", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "apr_id": "2b3bd04d96bbde391e8a69ee813b6bb1", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9994939271255061, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::cmp::{max, min};\n\nfn get_line() -> String {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input\n}\n\nfn get_vec() -> Vec\nwhere T: FromStr,\n ::Err: std::fmt::Debug,\n{\n get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn extended_euclid(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n (a, 1, 0)\n } else {\n let (d0, x0, y0) = extended_euclid(b, a % b);\n (d0, y0, x0 - a / b * y0)\n }\n}\n\nfn main() {\n let n: usize = get_line().trim().parse().unwrap();\n\n let cubes: Vec<_> = BufReader::new(io::stdin()).lines()\n .map(|s| {\n let s = s.unwrap();\n let mut cube = [false; 10];\n for s in s.split_whitespace() {\n let d = s.bytes().last().unwrap();\n let d = (d - b'0') as usize;\n cube[d] = true;\n }\n cube\n }).collect();\n\n let perms = match n {\n 3 => vec![\n vec![0, 1, 2],\n vec![0, 2, 1],\n vec![1, 0, 2],\n vec![1, 2, 0],\n vec![2, 0, 1],\n vec![2, 1, 0],\n ],\n 2 => vec![\n vec![0, 1],\n vec![1, 0],\n ],\n 1 => vec![vec![1]],\n _ => panic!(\"\"),\n };\n\n\n let fact = |n| {\n let mut ret_val = 1;\n for i in 0..n {\n ret_val *= i + 1;\n }\n ret_val\n };\n\n let check = |x| {\n let x = format!(\"{}\", x);\n for perm in perms.iter().take(fact(n)) {\n let p = x.bytes().map(|b| (b - b'0') as usize)\n .zip(perm.iter()).all(|(d, &i)| cubes[i][d]);\n if p {\n return true;\n }\n }\n false\n };\n\n for i in 1.. {\n if !check(i) {\n println!(\"{}\", i - 1);\n return;\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "c6a6d9f7f1866ce97c9a33f401204480", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "apr_id": "2b3bd04d96bbde391e8a69ee813b6bb1", "difficulty": 1300, "tags": ["brute force", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8233463035019455, "equal_cnt": 12, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 11, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n}\n\nstatic BIG: i64 = 1e9 as i64 + 7;\nfn _main() {\n let mut scan = Scan::new();\n let mut x: i64 = scan.next();\n let mut y: i64 = scan.next();\n if x < 0 {\n x += BIG;\n }\n if y < 0 {\n y += BIG;\n }\n let n: i64 = scan.next();\n for _ in 3..=n {\n let tmp = y;\n y = (y - x) % BIG;\n if y < 0 {\n y += BIG;\n }\n x = tmp;\n }\n println!(\"{}\", y);\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": "Rust", "bug_code_uid": "ef1926158bd4f61f02f9ef2fcb927025", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "apr_id": "b8f586edc9ca1392cffda65c6b6b1e68", "difficulty": 1300, "tags": ["math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9540918163672655, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next_line(&self) -> String {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n line\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let line = self.next_line();\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n}\n\nstatic BIG: i64 = 1e9 as i64 + 7;\nfn _main() {\n let mut scan = Scan::new();\n let mut x: i64 = scan.next();\n let mut y: i64 = scan.next();\n let mut n: i64 = scan.next();\n let mut i = 2i64;\n n = n % 6;\n while i < n + 6 {\n let tmp = y;\n y = y - x;\n x = tmp;\n i += 1;\n }\n println!(\"{}\", (y + BIG) % BIG);\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": "Rust", "bug_code_uid": "733c306b7ebbed3ec51e374f3a5a5cdb", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "apr_id": "b8f586edc9ca1392cffda65c6b6b1e68", "difficulty": 1300, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.49236298292902064, "equal_cnt": 10, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 9, "bug_source_code": "use std::io;\n\n\n\n\nfn read_line() -> String {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n return String::from(input_line.trim());\n}\n\nfn main() {\n let n: u32 = read_line().parse().unwrap();\n\n let count: u64 = (1..n+1).map(|x| x.to_string().len() as u64).sum();\n \n println!(\"{}\", count);\n \n \n}\n", "lang": "Rust", "bug_code_uid": "add7749cf4a3d0ff1ef88fcc502e4e91", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "apr_id": "03ee1bdaac9d0c080f190921a6bb1558", "difficulty": 1200, "tags": ["math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9952127659574468, "equal_cnt": 7, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 6, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\nuse std::collections::BTreeSet;\n\nfn max(x: &BTreeSet, y: &BTreeSet) -> (BTreeSet, BTreeSet) {\n let mut r: BTreeSet = BTreeSet::new();\n let mut rx: BTreeSet = BTreeSet::new();\n let mut xiter = x.iter();\n let mut yiter = y.iter();\n let mut i: i32 = *xiter.next().unwrap();\n let mut j: i32 = *yiter.next().unwrap();\n if i < j {\n while i < j { match xiter.next() {\n Some(x) => i = *x,\n None => { i = -1; break }\n } }\n } else {\n if j < i {\n while j < i { match yiter.next() {\n Some(x) => j = *x,\n None => { j = -1; break }\n } }\n }\n }\n if i != -1 { r.insert(i); }\n if j != -1 { r.insert(j); rx.insert(j); }\n for x in xiter { r.insert(*x); }\n for y in yiter { r.insert(*y); rx.insert(*y); }\n (r, rx)\n}\n\nfn main() {\n let mut l = String::new();\n io::stdin().read_line(&mut l).unwrap();\n let x: Vec = l.split_whitespace().map(|x| x.parse().unwrap()).collect();\n let (_, k) = (x[0], x[1]);\n let mut xs = String::new();\n io::stdin().read_line(&mut xs).unwrap();\n let mut r: BTreeSet = BTreeSet::new();\n r.insert(-1);\n for x in xs.split('Y') {\n let mut rr: BTreeSet = BTreeSet::new();\n let mut rc: BTreeSet = BTreeSet::new();\n rr.insert(-1);\n rc.insert(-1);\n for g in x.split('?') {\n let mut rs: BTreeSet = BTreeSet::new();\n let gl = g.len() as i32;\n rs.insert(gl);\n let (u, ux) = max(&rr, &rs);\n rr = &u | &(rc.iter().map(|x| x + gl + 1).collect());\n rc = &ux | &(rc.iter().map(|x| x + gl + 1).collect());\n }\n r = max(&r, &rr).0;\n }\n if r.contains(&k) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}", "lang": "Rust", "bug_code_uid": "887cde8ae8d7d8929eaaa2b626651e5a", "src_uid": "5bd578d3da5837c259b222336a194d12", "apr_id": "0af46b6001a06b207ac9a6d65f6a6ee2", "difficulty": 2000, "tags": ["dp"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.661787767903816, "equal_cnt": 12, "replace_cnt": 6, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nuse std::cmp::max;\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(s: String) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n s.split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn main() {\n let (l, r, x, y, k) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse::().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let l2 = k * x;\n let r2 = k * y;\n\n let q = l / k;\n \n let ans = (l > r2 || r < l2) || (k * q < l && k * (q + 1) < r);\n let ans = !ans;\n\n if ans {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "44ad94b81f1b8e311f95f1c50c5edd5f", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "apr_id": "664ac8ff2051cab332bde300f7802775", "difficulty": 1200, "tags": ["brute force", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.2956366874443455, "equal_cnt": 14, "replace_cnt": 10, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 14, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n\n io::stdin().read_line(&mut s).unwrap();\n\n let mut uppercases = 0;\n\n for ch in s.chars() {\n if ch.is_uppercase() {\n uppercases += 1;\n }\n }\n\n let mut first = 1;\n\n if uppercases > 1 {\n for ch in s.chars() {\n if first == 1 {\n print!(\"{}\", ch.to_uppercase());\n first = 0;\n } else {\n print!(\"{}\", ch.to_lowercase());\n }\n }\n } else {\n println!(\"{}\", s);\n }\n}\n1", "lang": "Rust", "bug_code_uid": "474b05497823ae06c7ea9ac62b160949", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "4c9b69668d8f2ae51b164352e7740cdf", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9604130808950087, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let mut line = String::new();\n stdin().read_line(&mut line).unwrap();\n let line = line.trim().to_string();\n \n let line_chars: Vec = line.chars().collect();\n let n: usize = line.len();\n if line == line.to_uppercase() {\n println!(\"{}{}\", &line[0..1].to_uppercase(), &line[1..n].to_lowercase());\n } else if line_chars[0].is_lowercase() &&\n &line[1..n] == &line[1..n].to_uppercase() { \n println!(\"{}{}\", &line[0..1].to_uppercase(), &line[1..n].to_lowercase());\n } else {\n println!(\"{}\", line);\n }\n}\n", "lang": "Rust", "bug_code_uid": "b2cb11c4d0ee624a782a7e25df3f1fc1", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "4c9b69668d8f2ae51b164352e7740cdf", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.999409681227863, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nfn main(){\n println!(\"{}\",operation());\n}\nfn operation() -> String {\n let (simple,word)=input();\n if word[0].is_lowercase(){\n if word.len()==1{\n return (simple.to_uppercase()).to_string()\n }\n if word[1].is_lowercase(){\n return simple\n }\n let mut n=0;\n for i in 1..word.len(){\n if word[i].is_uppercase(){\n n+=1;\n }\n }\n if n+1==word.len(){\n let mut sum=(word[0].to_uppercase()).to_string();\n for i in 1..word.len(){\n sum+=&((word[i].to_lowercase()).to_string());\n }\n return sum;\n }\n }\n else{\n if word.len()==1{\n return (simple.to_lowercase()).to_string()\n }\n let mut n=0;\n for i in 1..word.len(){\n if word[i].is_uppercase(){\n n+=1;\n }\n }\n if n==word.len(){\n return (simple.to_lowercase()).to_string()\n }\n }\n return simple\n}\nfn read() -> String{\n let mut input=String::new();\n io::stdin().read_line(&mut input).expect(\"unable to read\");\n input.trim().to_string()\n}\n\nfn input() -> (String,Vec){\n let inp=read();\n let l:Vec=inp.chars().collect();\n (inp,l)\n}\n/* let n=read().parse::().expect(\"Failed to parse\");\n let inp=read();\n (n,inp.split_whitespace().map(|x| x.parse::().expect(\"Failed to parse\")).collect())\n let list: Vec<_>=inp.split_whitespace().collect();\n let qu: Vec<_>=read().chars().collect();\n (list[0].parse::().expect(\"Failed to parse\"),\n list[1].parse::().expect(\"Failed to parse\"),qu)\n*/\n\n", "lang": "Rust", "bug_code_uid": "33409b02e751cc4ccd733a1b7bcbc344", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "263f394efb1378782c49c9ea6cb298fb", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9094988780852655, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut word = String::new();\n\n io::stdin()\n .read_line(&mut word)\n .unwrap();\n\n let mut uppercase = 0;\n\n for ch in word.chars() {\n if ch.is_uppercase() {\n uppercase += 1;\n }\n }\n\n let word = word.trim();\n\n if uppercase == word.len() || uppercase == word.len()-1 {\n for ch in word.chars() {\n if ch.is_uppercase() {\n print!(\"{}\",ch.to_lowercase());\n } else {\n print!(\"{}\",ch.to_uppercase());\n }\n }\n println!();\n } else {\n println!(\"{}\", word);\n }\n}\n", "lang": "Rust", "bug_code_uid": "71714ce926551b382a73b7a6292e1ebd", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "4bdd178db12d0a725e5c13f2e09fa0c4", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9034907597535934, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nfn main() {\n let data = read();\n let mut ans = String::new();\n let mut count = 0;\n let mut lower = 0;\n for val in data.chars(){\n if count != 0 {\n if val.is_lowercase(){\n lower = 1;\n }\n }\n count += 1;\n }\n count = 0;\n if lower == 0 {\n for val in data.chars(){\n if count == 0{\n let d : Vec = val.to_uppercase().collect();\n ans.push(d[0]);\n }\n else{\n let d : Vec = val.to_lowercase().collect();\n ans.push(d[0]);\n }\n count += 1;\n }\n }\n else{\n ans = data;\n }\n println!(\"{}\",ans);\n}\nfn read() -> String{\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input.trim().parse::().unwrap()\n}", "lang": "Rust", "bug_code_uid": "1791c810772168d4cd38e79c61084d7d", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "85286a1d03823c93f4226c265c612022", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8944980147475894, "equal_cnt": 16, "replace_cnt": 6, "delete_cnt": 9, "insert_cnt": 0, "fix_ops_cnt": 15, "bug_source_code": "use std::io::{self, Write};\n\n/// Checks if all chars in a given Vec match a given expression\nfn strmbexpr bool>(expr: E, chars: Vec) -> bool {\n for c in chars {\n if !expr(c) {\n return false;\n }\n }\n\n true\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n\n let mut word = scan.next();\n\n if word.len() == 0 {\n return;\n }\n\n if word.len() == 1 {\n writeln!(out, \"{}\", word.to_uppercase()).ok();\n } else {\n if strmbexpr(\n |c| c.is_uppercase() || c.is_whitespace(),\n word.chars().skip(1).collect::>(),\n ) {\n // invert the caps\n // this is by far the most evil code I've ever written in Rust\n unsafe {\n let ptr = word.as_mut_ptr();\n for i in 1..word.len() {\n std::ptr::write(\n ptr.offset(i as isize),\n word.as_bytes()[i] + ('a' as u8 - 'A' as u8),\n );\n }\n if *ptr >= 'a' as u8 {\n std::ptr::write(ptr, word.as_bytes()[0] - 32)\n } else {\n std::ptr::write(ptr, word.as_bytes()[0] + ('a' as u8 - 'A' as u8))\n }\n }\n\n writeln!(out, \"{}\", word).ok();\n } else {\n writeln!(out, \"{}\", word).ok();\n }\n }\n}\n\npub struct Scanner {\n reader: T,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self { reader }\n }\n\n pub fn next(&mut self) -> String {\n loop {\n let mut input = String::new();\n self.reader.read_line(&mut input).unwrap();\n\n return input.trim().to_owned();\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "884dc235b8d1edfe32510292300ec174", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "89fee4539a3dd6d8e4e26887ba96da82", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8758452799567217, "equal_cnt": 14, "replace_cnt": 8, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 13, "bug_source_code": "use std::io::{self, Write};\n\n#[macro_use]\nmacro_rules! flush {\n () => {\n io::stdout().flush().unwrap();\n };\n}\n\n/// Checks if all chars in a given Vec match a given expression\nfn strmbexpr bool>(expr: E, chars: Vec) -> bool {\n for c in chars {\n if !expr(c) {\n return false;\n }\n }\n\n true\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n\n let mut word = scan.next();\n\n match word.len() {\n 0 => return,\n 1 => {\n writeln!(out, \"{}\", word.to_uppercase()).ok();\n return;\n }\n _ => (),\n }\n\n if strmbexpr(\n |c| c.is_uppercase() || c.is_whitespace(),\n word.chars().skip(1).collect::>(),\n ) {\n // invert the caps\n unsafe {\n let ptr = word.as_mut_ptr();\n for i in 1..word.len() {\n std::ptr::write(ptr.add(i), *ptr.add(i) + 32);\n }\n\n if *ptr >= 'a' as u8 {\n std::ptr::write(ptr, *ptr - 32)\n } else {\n std::ptr::write(ptr, *ptr + 32)\n }\n }\n }\n\n writeln!(out, \"{}\", word).ok();\n flush!();\n}\n\npub struct Scanner {\n reader: T,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self { reader }\n }\n\n pub fn next(&mut self) -> String {\n loop {\n let mut input = String::new();\n self.reader.read_line(&mut input).unwrap();\n\n return input.trim().to_owned();\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "27e418cd51925e83f5cd69ee76f28e49", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "89fee4539a3dd6d8e4e26887ba96da82", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.472596585804133, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "fn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn main() {\n let word: String = read_str();\n let mut result: String = String::new();\n\n result.push(word.chars().nth(0).expect(\"Error\").to_ascii_uppercase());\n result.push_str(&word[1..].to_lowercase());\n\n println!(\"{}{}\",\n word.chars().nth(0).expect(\"Error\").to_uppercase(),\n &word[1..].to_lowercase());\n}", "lang": "Rust", "bug_code_uid": "8a32ebee36a9ff6191d08196f8d1f70a", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "4f98c14f9157e096ce38e01abe3669aa", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.653169014084507, "equal_cnt": 14, "replace_cnt": 9, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 13, "bug_source_code": "use std::ascii::AsciiExt;\nuse std::io;\nuse std::str;\n\npub fn main() {\n let mut line = String::new();\n io::stdin().read_line(&mut line).unwrap();\n let line = line.trim_right();\n\n print!(\"{}\", fix_case(line));\n}\n\npub fn fix_case(s: &str) -> String {\n let s = s.to_owned();\n\n if is_mistyped(&s) {\n let mut s = s.into_bytes();\n s.make_ascii_lowercase();\n s[0] = s[0].to_ascii_uppercase();\n String::from_utf8(s).unwrap()\n } else {\n s\n }\n}\n\npub fn is_mistyped(s: &str) -> bool {\n let mut iter = s.bytes();\n iter.next();\n iter.all(|c| c >= b'A' && c <= b'Z')\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn it_works() {\n assert_eq!(\"Hello\", fix_case(\"hELLO\"));\n assert_eq!(\"Http\", fix_case(\"HTTP\"));\n assert_eq!(\"Z\", fix_case(\"z\"));\n assert_eq!(\"Caps\", fix_case(\"cAPS\"));\n assert_eq!(\"Lock\", fix_case(\"Lock\"));\n }\n}\n", "lang": "Rust", "bug_code_uid": "a5ad36d09e7f54a6b73835b2b91771a0", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "1866da57c408398244c6ecb2c5c79a16", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9560264297106402, "equal_cnt": 6, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "#![allow(non_snake_case, unused_imports, deprecated, dead_code)]\n\n// Input macros\nmacro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }\nmacro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\nmacro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect(\"Parse error\") }; }\n\n// Module\nuse std::cmp::{min,max};\nuse std::collections::{VecDeque,HashSet,HashMap,BinaryHeap};\n// Module for v1.15.1\nuse std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead\n\n// Functions\n\n// Main\nfn main() {\n\n input! {\n mut W: chars,\n }\n\n let mut f = true;\n for i in 1..W.len(){\n if W[i].is_ascii_lowercase() {\n f = false;\n break;\n }\n }\n\n if f {\n for i in 0..W.len() {\n if i==0 {\n W[i] = W[i].to_ascii_uppercase();\n } else {\n W[i] = W[i].to_ascii_lowercase();\n }\n }\n }\n\n println!(\"{}\", W.into_iter().collect::());\n}", "lang": "Rust", "bug_code_uid": "eee8cd5bca53870904d6e28514dd5a59", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "361f7a0d79cc7c715dc2ce6855930280", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5919439579684763, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_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 caps = true;\n\n for (i, c) in s.chars().enumerate() {\n if i != 0 {\n if c.is_lowercase() {\n caps = false;\n }\n } \n }\n\n if caps {\n s.make_ascii_lowercase();\n let mut iter = s.chars().enumerate();\n let c = iter.next().unwrap();\n s = s.replace(c.1, &c.1.to_ascii_uppercase().to_string());\n }\n\n print!(\"{}\", s);\n}\n\n\n", "lang": "Rust", "bug_code_uid": "dba93c47aef83fccc2723bd81464903e", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "094a29215f93e8cecfdc4e36625f36d8", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9607201309328969, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{BufWriter, stdin, stdout, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let out = &mut BufWriter::new(stdout());\n\n\tlet s = scan.next::();\n let uppercase = s.chars().skip(1).all(char::is_uppercase);\n if uppercase {\n write!(out, \"{}\", s.chars().take(1)\n .map(|c| c.to_ascii_uppercase())\n .collect::()).expect(\"fail\");\n writeln!(out, \"{}\", s.chars().skip(1)\n .map(|c| c.to_ascii_lowercase())\n .collect::()).expect(\"fail\");\n } else {\n writeln!(out, \"{}\", s).expect(\"fail\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "14a48ee4cb68ca7acf0602a98eedbbed", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "apr_id": "a0ef405316ca2be1a9b7d67460a77b3f", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9938949938949939, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() -> io::Result<()> {\n let mut input = String::new();\n\n io::stdin().read_line(&mut input)?;\n\n input = input.trim().to_lowercase().to_string();\n \n let decomposed = input.chars().filter(|x| ['a', 'e', 'i', 'o', 'u'].iter().all(|y| y != x));\n let result = decomposed.fold(String::new(), |a, b| format!(\"{}.{}\", a, b));\n\n println!(\"{}\", result);\n\n return Ok(());\n}\n", "lang": "Rust", "bug_code_uid": "95367ae74d40c33e1e602a8ea7067d6e", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "4a3a102417db2a6193c941e5a3697afc", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9925, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let input = input.trim();\n\n let mut ans = String::new();\n\n for c in input.to_lowercase().chars() {\n match c {\n 'a' | 'e' | 'i' | 'o' | 'u' => continue,\n _ => (),\n }\n ans.push('.');\n ans.push(c);\n }\n\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "4fe54a5a413285548c79a21d7e8c35a3", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "4dd17e167842839d2d6b823bb178502d", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.99, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n let ret = line.trim().to_lowercase().chars().fold(String::new(), |ret, c| match c {\n 'a' | 'e' | 'i' | 'o' | 'u' => ret,\n _ => ret + \".\" + &c.to_string(),\n });\n println!(\"{}\", ret);\n}\n", "lang": "Rust", "bug_code_uid": "6f159d755e9c7903af487971205b7bd4", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "c78231dce5b14ccd1b1fc623d6f4aef9", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9988751406074241, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input)\n .expect(\"NAN\");\n let input = input.trim().to_string().to_lowercase();\n\n let vowel_string = String::from(\"aeiou\");\n let mut final_str = String::new();\n \n for c in input.chars() {\n if !vowel_string.contains(c) {\n final_str = format!(\"{}.{}\", final_str, c);\n }\n }\n println!(\"{}\", final_str);\n}\n", "lang": "Rust", "bug_code_uid": "ea04a621b204ccf42a98842fce9c04ad", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "5e2de42c1ab9997fc5d99bc1cd53ff52", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9895678092399404, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n const vowels: [char; 6] = ['a', 'o', 'y', 'e', 'u', 'i'];\n \n let mut input = String::new();\n io::stdin().read_line(&mut input);\n\n for letter in input.to_ascii_lowercase().chars() {\n if vowels.contains(&letter) { continue; }\n print!(\".\");\n print!(\"{}\", letter);\n }\n}\n", "lang": "Rust", "bug_code_uid": "79eed57ad6d3ced70df24ad6bc0460e3", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "5d7219adc113909ef08195a67bb7cfbf", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9983739837398374, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let inp = read_string();\n let inp: String = inp.chars().filter(|c| {\n c.to_lowercase().to_string() != \"a\" &&\n c.to_lowercase().to_string() != \"i\" &&\n c.to_lowercase().to_string() != \"u\" &&\n c.to_lowercase().to_string() != \"b\" &&\n c.to_lowercase().to_string() != \"o\" &&\n c.to_lowercase().to_string() != \"y\"\n }).collect();\n for i in inp.chars() {\n print!(\".{}\", i.to_lowercase());\n }\n}\n\nfn read_string() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"x\");\n buffer.trim().to_string()\n}", "lang": "Rust", "bug_code_uid": "85571996a975390b95f612dcb1680c0a", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "ae5d21966af035ce6e9984487ab4bead", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9924324324324324, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main(){\n let mut input = String::new();\n io::stdin().read_line(&mut input).expect(\"Error reading the input\");\n\n let mut output = String::new();\n for c in input.trim().chars(){\n if !\"aoyeui\".find(c).is_none(){\n continue;\n } else {\n output.push('.');\n for c_lower in c.to_lowercase(){\n output.push(c_lower);\n }\n }\n } \n\n println!(\"{}\", output);\n}\n\n", "lang": "Rust", "bug_code_uid": "712e3cb72bb16c14690392b31589e0f7", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "c766fc7c1de967b3f8aca28536a4d3cd", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9821428571428571, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{stdin, stdout, BufWriter, Write};\n\nfn main() {\n let mut s = String::new();\n stdin().read_line(&mut s).unwrap();\n let t: String = s\n .chars()\n .filter_map(|x| {\n let lx = x.to_ascii_lowercase();\n match lx {\n 'a' | 'o' | 'y' | 'e' | 'u' | 'i' => None,\n _ => Some(format!(\".{}\", lx)),\n }\n })\n .collect();\n println!(\"{}\", t)\n}\n", "lang": "Rust", "bug_code_uid": "410158563871ece64759d60803e46c18", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "df13ca8d7709413bff0a3cfd39cba8b8", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.98989898989899, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s = s.to_lowercase();\n for i in 0..s.len() {\n let c = s.chars().nth(i).unwrap();\n if c == 'a' || c == 'o' || c == 'y' || c == 'e' || c == 'u' || c == 'i' {\n continue;\n }\n print!(\".{}\", c);\n }\n}", "lang": "Rust", "bug_code_uid": "cbe390862da9bd910d6550b681758efc", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "b64325292de638e856a0c1788970623d", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9869513641755635, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nfn main(){\n let mut input =String::new();\n io::stdin().read_line(&mut input).unwrap();\n let input = input.trim().parse::().unwrap();\n let input = input.to_lowercase();\n let mut z = String::new();\n for d in input.chars(){\n if d != 'a' && d != 'e' && d != 'i' && d != 'o' && d != 'u'{\n z.push('.');\n z.push(d);\n }\n }\n println!(\"{}\",z);\n}", "lang": "Rust", "bug_code_uid": "94bd9d61ad30edd6e21f6fe58cc6af57", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "601876c1e4cf6ead561321b19af0bc58", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9195922989807475, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "\npub fn main(){\n let input = input().to_lowercase();\n let chars = input.chars();\n for c in chars {\n match c {\n 'a' | 'e' | 'i' | 'o' | 'u' | 'y' => {}\n _ => {\n print!(\".\");\n print!(\"{}\", c);\n }\n }\n }\n}\n\nfn input() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input);\n input\n}\n", "lang": "Rust", "bug_code_uid": "139af13cf02c9dd1f5caef3ec106aed1", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "d8c48166bb14348a7a30ceb0f7b32a56", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8768472906403941, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "fn main() {\n let v: Vec = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().split(\" \").map(|s| s.parse::().unwrap()).collect()\n };\n\n let (mut a, b) = (v[0], v[1]);\n let mut ret = 0;\n while a != 0 {\n ret += a;\n a = a / b;\n }\n println!(\"{:?}\", ret);\n}\n", "lang": "Rust", "bug_code_uid": "6a3d8bf5ad336416289bd28c7f118936", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "apr_id": "364964172728f84c421e60e0cef602de", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9122388059701493, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n}\n\nfn main() {\n let mut scan = Scan::new();\n let mut a = scan.next::();\n let b = scan.next::();\n let mut result = a;\n while a>0 {\n a /= b;\n result += a;\n }\n println!(\"{}\", result);\n}\n", "lang": "Rust", "bug_code_uid": "47e95b3fc1f823446a205f41b5f562d4", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "apr_id": "8cb17eac64ea9da827305e2b9b5ba177", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9953665849005179, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_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": "Rust", "bug_code_uid": "2eb2a415f61358bdded9e3d0585e2861", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "apr_id": "492da7f4fa2431be7cb64d06e240537c", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9926470588235294, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let n:i32 = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().parse().unwrap()\n };\n\n if n % 2 == 0 {\n println!(\"{:?}\", n / 2);\n } else {\n println!(\"{:?}\", n / 2 - n); \n }\n}\n", "lang": "Rust", "bug_code_uid": "1805581eaa0a3d1862f74a2b0d1a8849", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "27d08374c9de333ce912d608874436a5", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9926739926739927, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let s = buf.trim().parse::().unwrap();\n let r = match s {\n s if s % 2 == 0 => s - s / 2,\n _ => -(s / 2 + 1),\n };\n\n println!(\"{}\", r);\n}\n", "lang": "Rust", "bug_code_uid": "e4d447dca1924717022efa39e515cf31", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "7e44f2175fba30e55cfce69d59a00441", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.12461059190031153, "equal_cnt": 7, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "use std::io::stdin;\nfn recursiva(arg: i64) -> i64 {\n if arg == 1 {\n return -1;\n } else if arg % 2 == 0 {\n return recursiva(arg - 1) + arg;\n } else {\n return recursiva(arg - 1) - arg;\n }\n}\n\nfn main() {\n let mut n = String::new();\n stdin().read_line(&mut n).unwrap();\n let n: i64 = n.trim().parse().unwrap();\n println!(\"{}\", recursiva(n));\n}\n", "lang": "Rust", "bug_code_uid": "4b28b0b35c960ae690365e8d8a790e01", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "f916e8b58b7e586e0b1b192559c4c82b", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8126361655773421, "equal_cnt": 6, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 6, "bug_source_code": "use std::io::*;\n\nfn read(i: &mut StdinLock) -> T {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let n: i64 = read(sin);\n\n let ans = (1..n + 1)\n .map(|x| if x % 2 != 0 { -1 * x } else { x })\n .fold(0, |acc, x| acc + x);\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "e38f2489f39b52eae2ae7905bdb8af87", "src_uid": "689e7876048ee4eb7479e838c981f068", "apr_id": "c85b1234ce7aa9efc8805d38d017e2bd", "difficulty": 800, "tags": ["math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6879535558780842, "equal_cnt": 8, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nfn read_line() -> (i64) {\n let mut input = String::new();\n \n io::stdin().read_line(&mut input).unwrap();\n \n let n: i64 = input.trim().parse().unwrap();\n\n n\n}\n\nfn main(){\n \n let n = read_line();\n\n if n % 2 == 0 {\n println!(\"1\");\n } else {\n println!(\"2\");\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "16b99eb88e253f250088d161e086845f", "src_uid": "03e4482d53a059134676f431be4c16d2", "apr_id": "02317fb94cd661b48af0068a848bbd37", "difficulty": 1000, "tags": ["bitmasks"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9998138842359948, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n// use proconio::input;\nuse std::cmp::{Ordering::*, Reverse};\nuse std::collections::{BTreeMap, BTreeSet};\nuse std::io::{self, BufWriter, Write};\nuse std::str::{self, SplitAsciiWhitespace};\n\n// I have no idea what I'm doing\n\nmacro_rules! answer {\n ($out:ident, $ans:expr) => {\n writeln!($out, \"{}\", $ans)\n };\n}\n\nfn 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, m) = scan.pair::();\n\n if n == 1 {\n return answer!(out, 1);\n }\n \n answer!(out, if m-1 <= n-m {\n m+1 \n } else {\n m-1\n })\n}\n\n///////////////////////////////////////////////////////////////////////////////////////////////////\n\n/// Mostly 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 [Scanner]\");\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\n// aka #![feature(bool_to_option)]\ntrait BoolThen {\n fn then_(self, f: impl FnOnce() -> T) -> Option;\n}\n\nimpl BoolThen for bool {\n fn then_(self, f: impl FnOnce() -> T) -> Option {\n if self {\n Some(f())\n } else {\n None\n }\n }\n}\n\ntrait BoolToYes {\n fn yes(self) -> &'static str;\n}\n\nimpl BoolToYes for bool {\n fn yes(self) -> &'static str {\n match self {\n true => \"YES\",\n false => \"NO\",\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "cb65129fd564236ff8c4d49625802d9b", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "apr_id": "6bdb714aef4fbe281ba0ceae6e19e9c2", "difficulty": 1300, "tags": ["games", "greedy", "math", "implementation", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9927583936800527, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n l!(n,m = input.i());\n let sol = if m - 1 >= n - m {\n m - 1\n } else {\n m + 1\n };\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "1152d2b1b27f08b22d368f3ce134a853", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "apr_id": "7744edf7ad551b46a02c03da30d72202", "difficulty": 1300, "tags": ["games", "greedy", "math", "implementation", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.966931216931217, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_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 read_line_vec() -> Vec {\n return read_line().split(' ')\n .map(|s| s.parse().unwrap())\n .collect();\n}\n\nfn read_line_pair() -> (u64, u64) {\n let vec = read_line_vec();\n return (vec[0], vec[1]);\n}\n\n\nfn get_bp(n: u64, m: u64) -> u64 {\n assert!(m > 0);\n let left = m - 1;\n let right = n - m;\n if left == right {\n return m;\n }\n if left < right {\n return m + 1;\n }\n return left;\n}\n\nfn main() {\n let (n, m) = read_line_pair();\n let res = get_bp(n, m);\n \n println!(\"{}\", res);\n}\n", "lang": "Rust", "bug_code_uid": "3655518f6f9ce7315f134e380dab351f", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "apr_id": "335c01d9ad461f07e8ae25cc4d74b205", "difficulty": 1300, "tags": ["games", "greedy", "math", "implementation", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7352640545144804, "equal_cnt": 16, "replace_cnt": 9, "delete_cnt": 1, "insert_cnt": 5, "fix_ops_cnt": 15, "bug_source_code": "use std::cmp;\n\nfn calcu_size(ix: i32, iy: i32, n: i32, second: i32) -> i32 {\n let mut total = 0;\n // middle\n let lefty: i32 = cmp::max(iy - second, 1);\n let righty: i32 = cmp::min(iy + second, n);\n\n total += righty - lefty + 1;\n\n // upper\n for i in 0..cmp::min(second, ix - 1) {\n let _row = ix - i - 1;\n let lefty = cmp::max(iy - second + i + 1, 1);\n let righty = cmp::min(iy + second - i - 1, n);\n total += righty - lefty + 1;\n }\n\n // lower\n for i in 0..cmp::min(second, n - ix) {\n let _row = ix + i + 1;\n let lefty = cmp::max(iy - second + i + 1, 1);\n let righty = cmp::min(iy + second - i - 1, n);\n total += righty - lefty + 1;\n }\n\n return total;\n}\n\nfn main() {\n let mut input_str = String::new();\n std::io::stdin().read_line(&mut input_str).expect(\"read error\");\n let mut iter = input_str.split_whitespace();\n let n: i32 = iter.next().unwrap().parse().unwrap();\n let x: i32 = iter.next().unwrap().parse().unwrap();\n let y: i32 = iter.next().unwrap().parse().unwrap();\n let c: i32 = iter.next().unwrap().parse().unwrap();\n\n let mut left = -1;\n let mut right = 2 * (((2.0 * (c as f64)).sqrt() as i32) + 1);\n while left != right - 1 {\n let mid = (left + right) >> 1;\n if calcu_size(x, y, n, mid) < c {\n left = mid;\n } else {\n right = mid;\n }\n }\n println!(\"{}\", right);\n}", "lang": "Rust", "bug_code_uid": "90e2050c323966f8b70197ddfdbb173d", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "apr_id": "87dc4bb86f5baba2c8de8fddb9a43be5", "difficulty": 1800, "tags": ["math", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9748369058713886, "equal_cnt": 10, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 7, "fix_ops_cnt": 9, "bug_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": "Rust", "bug_code_uid": "b4445a2ed0b03cc44e7627efb9eff7aa", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "apr_id": "991d30452f0adf06d7375d8f100c1794", "difficulty": 1000, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9973873285434357, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(isize);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\n// -----------------------------------------------------------------------------\n\nfn main() {\n scanln!(n: u32, k: u32);\n if (n / k) % 2 == 0 {\n println!(\"NO\");\n } else {\n println!(\"YES\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "db968eae09d4c1f8b9fb8439fe6876e8", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "apr_id": "4f71b13a118f3aa2ffadb57c5ff1aeed", "difficulty": 800, "tags": ["math", "games"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9825581395348837, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::stdin;\n\nfn main() { \n let stdin = stdin();\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let vec = s.split_whitespace().map(|x| x.parse::().expect(\"number parse error\")).collect::>();\n if (vec[0] / vec[1])&1 > 0 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "4cde7bfc0cf11adf0eb803143654ae17", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "apr_id": "4d1e492b75b240326b739cfff0795df1", "difficulty": 800, "tags": ["math", "games"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9912790697674418, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::stdin;\n\nfn main() { \n let stdin = stdin();\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let vec = s.split_whitespace().map(|x| x.parse::().expect(\"number parse error\")).collect::>();\n if (vec[0] / vec[1])&1 > 0 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "641b70d5baa991303bf2a04a6e37713a", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "apr_id": "4d1e492b75b240326b739cfff0795df1", "difficulty": 800, "tags": ["math", "games"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9891696750902527, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s)\n .expect(\"failed to read l2\");\n\n let values = s\n .split_whitespace()\n .map(|x| x.parse::())\n .collect::, _>>()\n .unwrap();\n\n assert!(values.len() == 2);\n let n = values[0];\n let k = values[1];\n\n if n <= k {\n println!(\"YES\");\n } else {\n let plays = n / k;\n if plays % 2 == 1{\n println!(\"YES\");\n } else {\n println!(\"NO\")\n }\n }\n\n\n}\n", "lang": "Rust", "bug_code_uid": "11732d786eff91c954fe871f07867fc1", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "apr_id": "a5b2231fe6351b80cf20c803f0b951b1", "difficulty": 800, "tags": ["math", "games"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6940443752432853, "equal_cnt": 29, "replace_cnt": 12, "delete_cnt": 11, "insert_cnt": 6, "fix_ops_cnt": 29, "bug_source_code": "use std::io::prelude::*;\nuse std::io;\nuse std::str::FromStr;\n#[cfg(local)]\nuse std::fs::File;\n#[cfg(local)]\nuse std::io::BufReader;\n\n#[cfg(local)]\nfn buf_read() -> io::Result<(Vec)> {\n let f = try!(File::open(\"input.txt\"));\n let input_lines: Vec<_> = BufReader::new(f).lines().collect();\n let lines: Vec = input_lines.into_iter().map(|e| e.unwrap()).collect();\n Ok((lines))\n}\n\n#[cfg(not(local))]\nfn buf_read() -> io::Result<(Vec)> {\n let stdin = io::stdin();\n let input_lines: Vec<_> = stdin.lock().lines().collect();\n let lines: Vec = input_lines.into_iter().map(|e| e.unwrap()).collect();\n Ok((lines))\n}\n\nfn main() {\n type Element = String;\n let input = buf_read().unwrap();\n let mut input_vectors: Vec> = vec![];\n for input_line in input {\n let input_str: Vec = input_line.split(' ').map(String::from).collect();\n let mut input_vector: Vec = vec![];\n for input_elem_str in input_str {\n let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();\n input_vector.push(elem);\n }\n input_vectors.push(input_vector);\n }\n let mut k = i64::from_str(&input_vectors[0][1]).unwrap();\n let mut str = input_vectors[1][0].char_indices();\n let mut str2 = str.clone();\n let mut str3 = str.clone();\n let g_position = str2.position(|(u, c)| c == 'G').unwrap() as i64;\n let t_position = str3.position(|(u, c)| c == 'T').unwrap() as i64;\n let mut ii = 0;\n let mut i = 0;\n let mut flag = 0;\n for c in str {\n ii += 1;\n if (ii - 1 <= g_position) && (ii - 1 <= t_position) {\n // println!(\"g: {:?}\", g_position);\n // println!(\"t: {:?}\", t_position);\n // println!(\"ii: {:?}\", ii - 1);\n // println!(\"hoge\");\n continue;\n }\n i += 1;\n if i % k != 0 || (i - 1) == 0 {\n // println!(\"hoge2\");\n // println!(\"{:?}\", i - 1);\n // println!(\"{:?}\", c);\n continue;\n }\n // println!(\"{:?}\", 0 % k);\n // println!(\"{:?}\", k);\n // println!(\"{:?}\", c);\n match c {\n (n, c) => {\n if c == '#' {\n // println!(\"No\");\n break;\n } else if c == 'G' || c == 'T' {\n // println!(\"Yes\");\n flag = 1;\n break;\n }\n }\n }\n // println!{\"{:?}\", c};\n }\n if flag == 0 {\n println!(\"No\");\n } else {\n println!(\"Yes\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "044759ef4d69bb03fe2788483d024868", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "apr_id": "91138ce32c62e58787963976dca45bf8", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9871640593662254, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, Stdin};\nuse std::str::{self, FromStr};\nuse std::error::Error;\nuse std::thread;\nuse std::cmp::*;\nfn exec() {\n let mut sc = Scanner::new();\n let _: usize = sc.ne();\n let k: usize = sc.ne();\n let a = sc.ne::().into_bytes();\n let start = a.iter().position(|&x| x == b'G').unwrap();\n let goal = a.iter().position(|&x| x == b'T').unwrap();\n let s = min(start, goal);\n let g = max(start, goal);\n if (g - s) % k != 0 {\n println!(\"NO\");\n std::process::exit(1);\n }\n let mut ok = true;\n let mut cur = s;\n while cur != g {\n if a[cur] == b'#' {\n ok = false;\n }\n cur += k;\n }\n println!(\"{}\", if ok { \"YES\" } else { \"NO\" });\n}\n\n\nfn main() {\n const DEFAULT_STACK: usize = 16 * 1024 * 1024;\n let builder = thread::Builder::new();\n let th = builder.stack_size(DEFAULT_STACK);\n let handle = th.spawn(|| { exec(); }).unwrap();\n let _ = handle.join();\n}\n\n#[allow(dead_code)]\nstruct Scanner {\n stdin: Stdin,\n id: usize,\n buf: Vec,\n}\n\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n stdin: io::stdin(),\n id: 0,\n buf: Vec::new(),\n }\n }\n fn next_line(&mut self) -> Option {\n let mut res = String::new();\n match self.stdin.read_line(&mut res) {\n Ok(0) => return None,\n Ok(_) => Some(res),\n Err(why) => panic!(\"error in read_line: {}\", why.description()),\n }\n }\n fn next(&mut self) -> Option {\n while self.buf.len() == 0 {\n self.buf = match self.next_line() {\n Some(r) => {\n self.id = 0;\n r.trim().as_bytes().to_owned()\n }\n None => return None,\n };\n }\n let l = self.id;\n assert!(self.buf[l] != b' ');\n let n = self.buf.len();\n let mut r = l;\n while r < n && self.buf[r] != b' ' {\n r += 1;\n }\n let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() {\n Ok(s) => Some(s),\n Err(_) => panic!(\"parse error\"),\n };\n while r < n && self.buf[r] == b' ' {\n r += 1;\n }\n if r == n {\n self.buf.clear();\n } else {\n self.id = r;\n }\n res\n }\n fn ne(&mut self) -> T {\n self.next::().unwrap()\n }\n}\n", "lang": "Rust", "bug_code_uid": "b3d1859a331f2875b0e8a7962e234f24", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "apr_id": "fe173c36ea170ab090204cff67d211fa", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9888911331044233, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self, Stdin};\nuse std::str::{self, FromStr};\nuse std::error::Error;\nuse std::thread;\nuse std::cmp::*;\nfn exec() {\n let mut sc = Scanner::new();\n let _: usize = sc.ne();\n let k: usize = sc.ne();\n let a = sc.ne::().into_bytes();\n let start = a.iter().position(|&x| x == b'G').unwrap();\n let goal = a.iter().position(|&x| x == b'T').unwrap();\n let s = min(start, goal);\n let g = max(start, goal);\n let mut ok = true;\n if (g - s) % k != 0 {\n ok = false;\n }\n let mut cur = s;\n while cur != g {\n if a[cur] == b'#' {\n ok = false;\n }\n cur += k;\n }\n println!(\"{}\", if ok { \"YES\" } else { \"NO\" });\n}\n\n\nfn main() {\n const DEFAULT_STACK: usize = 16 * 1024 * 1024;\n let builder = thread::Builder::new();\n let th = builder.stack_size(DEFAULT_STACK);\n let handle = th.spawn(|| { exec(); }).unwrap();\n let _ = handle.join();\n}\n\n#[allow(dead_code)]\nstruct Scanner {\n stdin: Stdin,\n id: usize,\n buf: Vec,\n}\n\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n stdin: io::stdin(),\n id: 0,\n buf: Vec::new(),\n }\n }\n fn next_line(&mut self) -> Option {\n let mut res = String::new();\n match self.stdin.read_line(&mut res) {\n Ok(0) => return None,\n Ok(_) => Some(res),\n Err(why) => panic!(\"error in read_line: {}\", why.description()),\n }\n }\n fn next(&mut self) -> Option {\n while self.buf.len() == 0 {\n self.buf = match self.next_line() {\n Some(r) => {\n self.id = 0;\n r.trim().as_bytes().to_owned()\n }\n None => return None,\n };\n }\n let l = self.id;\n assert!(self.buf[l] != b' ');\n let n = self.buf.len();\n let mut r = l;\n while r < n && self.buf[r] != b' ' {\n r += 1;\n }\n let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() {\n Ok(s) => Some(s),\n Err(_) => panic!(\"parse error\"),\n };\n while r < n && self.buf[r] == b' ' {\n r += 1;\n }\n if r == n {\n self.buf.clear();\n } else {\n self.id = r;\n }\n res\n }\n fn ne(&mut self) -> T {\n self.next::().unwrap()\n }\n}\n", "lang": "Rust", "bug_code_uid": "302a2c925100ce3b2456edb0895b3644", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "apr_id": "fe173c36ea170ab090204cff67d211fa", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8670157068062827, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "fn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n let line = line.trim();\n let v: Vec = line.trim().split(\" \").map(|s| s.parse::().unwrap()).collect();\n\n let n = v[0];\n let k = v[1];\n // 1 2 3 4 5 6 7 8 9 10 11\n // |\n // 1 3 5 7 9 11 2 4 6 8 10\n if k * 2 - 1 <= n {\n println!(\"{:?}\", k * 2 - 1);\n } else {\n println!(\"{:?}\", k * 2 - 1 - n);\n }\n}\n", "lang": "Rust", "bug_code_uid": "b211e9562de6414138d58ee96e64a21a", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "f658ccc70fb31ac45c5a5ea8ad120a6c", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9921259842519685, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n let line = line.trim();\n let v: Vec = line.trim().split(\" \").map(|s| s.parse::().unwrap()).collect();\n\n let n = v[0];\n let k = v[1];\n // 1 2 3 4 5 6 7 8\n // |\n // 1 3 5 7 2 4 6 8\n if k * 2 - 1 <= n {\n println!(\"{:?}\", k * 2 - 1);\n } else {\n let mut x = k * 2 - 1 - n;\n if x % 2 == 1 {\n x += 1;\n }\n println!(\"{:?}\", x);\n }\n}\n", "lang": "Rust", "bug_code_uid": "b0b773e3df9107ca7e4e2d8a0a26a931", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "f658ccc70fb31ac45c5a5ea8ad120a6c", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7608695652173914, "equal_cnt": 7, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 7, "bug_source_code": "use std::io::stdin;\n \nfn main() {\n let mut line = String::new();\n stdin().read_line(&mut line).unwrap();\n \n let words: Vec = line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n \n let n = words[0];\n let k = words[1];\n \n if k <= n / 2 + 1 {\n println!(\"{}\", k * 2 - 1);\n } else if k != n {\n println!(\"{}\", n - 2 * (n - k) - 1);\n } else {\n println!(\"{}\", n - 1);\n }\n}\n", "lang": "Rust", "bug_code_uid": "4025f3de22e84be23e1b6b1cd255bba4", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "2cfe63e2aa72ecae7b71c3b045bbf8ca", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.618905472636816, "equal_cnt": 10, "replace_cnt": 4, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 9, "bug_source_code": "use std::io::*;\n\nfn reads(i: &mut StdinLock) -> Vec {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n\nfn operate(n: i64, k: i64) -> (bool, usize) {\n let n = n as f64;\n let k = k as f64;\n let boarder = (n / 2.).ceil();\n let is_even = boarder <= k;\n let idx = if is_even { k - boarder } else { k };\n (is_even, idx as usize)\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let inputs: Vec = reads(sin);\n let n = inputs[0];\n let k = inputs[1];\n\n let (is_even, idx) = operate(n, k);\n\n let ans = if is_even {\n (1..n + 1).filter(|x| *x % 2 == 0).nth(idx - 1).unwrap()\n } else {\n (1..n + 1).filter(|x| *x % 2 != 0).nth(idx - 1).unwrap()\n };\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "4bfe695cbed63ec4a4fe7c6379be1895", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "3b15c30159ab04ed61e5592bb8dd327f", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5992292870905588, "equal_cnt": 10, "replace_cnt": 4, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 9, "bug_source_code": "use std::io::*;\n\nfn reads(i: &mut StdinLock) -> Vec {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n\nfn operate(n: i64, k: i64) -> (bool, usize) {\n let n = n as f64;\n let k = k as f64;\n let boarder = (n / 2.).ceil();\n let is_even = boarder <= k;\n let idx = if is_even {\n k - boarder + if n as i64 % 2 == 0 { 1. } else { 0. }\n } else {\n k\n };\n (is_even, idx as usize)\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let inputs: Vec = reads(sin);\n let n = inputs[0];\n let k = inputs[1];\n\n let (is_even, idx) = operate(n, k);\n\n let ans = if is_even {\n (1..n + 1).filter(|x| *x % 2 == 0).nth(idx - 1).unwrap()\n } else {\n (1..n + 1).filter(|x| *x % 2 != 0).nth(idx - 1).unwrap()\n };\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "90186588081d0470883f5343575ff2ea", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "3b15c30159ab04ed61e5592bb8dd327f", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9214986619090099, "equal_cnt": 8, "replace_cnt": 4, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "use std::io::*;\n\nfn reads(i: &mut StdinLock) -> Vec {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n\nfn operate(n: i64, k: i64) -> (bool, usize) {\n // 0 1 2 3 4 5 6 7\n // 1\n // 1 2\n // 1 3 2\n // 1 3 2 4\n // 1 3 5 2 4\n // 1 3 5 2 4 6\n // 1 3 5 7 2 4 6\n // 1 3 5 7 2 4 6 8\n\n if n == 1 {\n return (false, 1);\n }\n\n let nf = n as f64;\n\n let start_of_even = (nf / 2.).ceil() as i64 + 1;\n\n let offset = if start_of_even <= k {\n k - start_of_even + 1\n } else {\n k\n };\n\n (start_of_even <= k, offset as usize)\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let inputs: Vec = reads(sin);\n let n = inputs[0];\n let k = inputs[1];\n\n let (is_even, idx) = operate(n, k);\n\n let ans = if is_even {\n (1..n + 1).filter(|x| *x % 2 == 0).nth(idx - 1).unwrap()\n } else {\n (1..n + 1).filter(|x| *x % 2 != 0).nth(idx - 1).unwrap()\n };\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "871fd972226beb147c0beb4265cd7870", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "3b15c30159ab04ed61e5592bb8dd327f", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9331651954602774, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let vec: Vec = get_input().split_ascii_whitespace().map(|v| v.parse().unwrap()).collect();\n let n = vec[0];\n let index = vec[1];\n\n if n / 2 >= index {\n // ODD NUMBER\n let res = index * 2 - 1;\n println!(\"{}\", res);\n } else {\n // EVEN NUMBER\n let res = (index - n / 2) * 2;\n let res = {\n if n % 2 == 0 {\n res\n } else {\n res - 2\n }\n };\n println!(\"{}\", res);\n }\n}\n\nfn get_input() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n buffer.trim().to_owned()\n}\n\nfn get_input_usize() -> usize {\n get_input().parse().unwrap()\n}\n", "lang": "Rust", "bug_code_uid": "b31421cda88ee753eee31937788c084c", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "93a4ab94cc94c1f74acfe0e4e408f988", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.998914223669924, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "// https://codeforces.com/problemset/problem/318/A\nuse std::io;\n\nfn main() {\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let words: Vec =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let n = words[0];\n let k = words[1];\n\n if k < (n+1)/2 {\n println!(\"{}\", 2*k-1);\n } else {\n println!(\"{}\", 2*(k-(n+1)/2));\n }\n}\n", "lang": "Rust", "bug_code_uid": "fa5d8fd1815baa5ba53e2f585a46a0e1", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "2b0d4fe25de810e27e2130aba8781164", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9910044977511244, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_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 read_line_vec() -> Vec {\n return read_line().split(' ')\n .map(|s| s.parse().unwrap())\n .collect();\n}\n\nfn read_line_pair() -> (i32, i32) {\n let vec = read_line_vec();\n return (vec[0], vec[1]);\n}\n\nfn main() {\n let (n, k) = read_line_pair();\n\n let even_count = (n + 1) / 2;\n\n if k <= even_count {\n let res = k * 2 - 1;\n println!(\"{}\", res);\n } else {\n let res = (k - even_count) * 2;\n println!(\"{}\", res);\n }\n \n}", "lang": "Rust", "bug_code_uid": "dd0e41d4ccd2999e92e4b518e2ecf3cf", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "apr_id": "d3557679747ec4a0a86963d2d6d79426", "difficulty": 900, "tags": ["math"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9767011834319527, "equal_cnt": 23, "replace_cnt": 21, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 22, "bug_source_code": "use std::io;\nuse std::str;\n\nconst MOD: i64 = 1_000_000_007;\n\nfn modpow(a: i64, b: i64) -> i64 {\n let mut a = a;\n let mut b = b;\n let mut ans = 1;\n while b > 0 {\n if b % 2 != 0 {\n ans = (ans * a) % MOD;\n }\n a = (a * a) % MOD;\n b /= 2;\n }\n ans\n}\n\nfn modinv(a: i64) -> i64 {\n modpow(a, MOD - 2) % MOD\n}\n\nfn modadd(a: i64, b: i64) -> i64 {\n let mut ans = (a + b) % MOD;\n if ans < 0 {\n ans += MOD;\n }\n ans\n}\n\nfn modmult(a: i64, b: i64) -> i64 {\n let mut ans = (a * b) % MOD;\n if ans < 0 {\n ans += MOD;\n }\n ans\n}\n\nfn moddiv(a: i64, b: i64) -> i64 {\n (a * modinv(b)) % MOD\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let a: i64 = scan.token();\n let b: i64 = scan.token();\n let n: i64 = scan.token();\n let x: i64 = scan.token();\n let mut ans;\n if n == 0 {\n ans = x % MOD;\n } else if n == 1 {\n ans = (a * x + b) % MOD;\n } else if a == 1 {\n ans = modadd(x, modmult(b, n));\n } else {\n ans = modpow(a, n);\n ans = modmult(ans, x);\n let mut quotient = modpow(a, n);\n quotient = modadd(quotient, -1);\n quotient = moddiv(quotient, a - 1);\n let mut part = b % MOD;\n part = modmult(part, quotient);\n ans = modadd(ans, part);\n // ans = ((modpow(a, n) * x) % MOD + ((b * (modpow(a, n) - 1).rem_euclid(MOD)) % MOD * modinv(a - 1)) % MOD) % MOD;\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n\n pub fn tokens(&mut self) -> Vec {\n assert!(self.buffer.is_empty());\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n input\n .split_whitespace()\n .map(|x| x.parse().ok().expect(\"Failed parse\"))\n .collect()\n }\n}\n", "lang": "Rust", "bug_code_uid": "aecb97357a1f4aafe91934f21ccc20cc", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "apr_id": "8604c668ce6de36c8dcb1badc8cbf3a9", "difficulty": 1700, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6985425722321656, "equal_cnt": 11, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn factorize(n: u64) -> Vec<(u64, u64)> {\n let mut n = n;\n let mut p = 2;\n let mut ans = Vec::new();\n while p * p <= n && n > 1 {\n let mut expo = 0;\n while n % p == 0 {\n expo += 1;\n n /= p;\n }\n if expo > 1 {\n ans.push((p, expo));\n }\n p += 1;\n }\n if n > 1{\n ans.push((n, 1));\n }\n ans\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let factors = factorize(n);\n let mut min_n = 1;\n let mut max_expo = 0;\n for (p, expo) in factors {\n min_n *= p;\n max_expo = max_expo.max(expo);\n }\n let power_of_two = factorize(max_expo.next_power_of_two());\n let (_, min_ops) = power_of_two[0];\n writeln!(out, \"{} {}\", min_n, min_ops + 1).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "3d1683f1f07a72625b55f3dd3ab01be1", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "apr_id": "884ecb2e573b42afedfd0fee0b4953ff", "difficulty": 1500, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9995477159656264, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn factorize(n: u64) -> Vec<(u64, u64)> {\n let mut n = n;\n let mut p = 2;\n let mut ans = Vec::new();\n while p * p <= n && n > 1 {\n let mut expo = 0;\n while n % p == 0 {\n expo += 1;\n n /= p;\n }\n if expo > 0 {\n ans.push((p, expo));\n }\n p += 1;\n }\n if n > 1{\n ans.push((n, 1));\n }\n ans\n}\n\n// fn is_power_of_two(n: u64) -> bool {\n// let expo = (n as f64).log2() as u32;\n// 2u64.pow(expo) == n\n// }\n\nfn log2(n: u64) -> u64 {\n (n as f64).log2() as u64\n}\n\nfn find_min_ops(max_expo: u64, factors: &[(u64, u64)]) -> u64 {\n let m = max_expo.next_power_of_two();\n if m == max_expo {\n for (_, expo) in factors {\n if *expo < m {\n return 1 + log2(m);\n }\n }\n return log2(m);\n }\n 1 + log2(m)\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let factors = factorize(n);\n let mut min_n = 1;\n let mut max_expo = 0u64;\n for (p, expo) in &factors {\n min_n *= p;\n max_expo = max_expo.max(*expo);\n }\n if max_expo == 1 {\n writeln!(out, \"{} 0\", min_n).ok();\n return;\n }\n let min_ops = find_min_ops(max_expo, &factors);\n writeln!(out, \"{} {}\", min_n, min_ops).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "932d2905e9c3892e2d9df8b8247549f5", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "apr_id": "884ecb2e573b42afedfd0fee0b4953ff", "difficulty": 1500, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9656499038197307, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "macro_rules! parse_line {\n ($t: ty) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let a_str = a_str.trim();\n a_str.parse::<$t>().expect(\"parse error\")\n });\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nmacro_rules! parse_line_to_vec {\n ($t: ty) => {{\n let mut a_str = String::new();\n std::io::stdin().read_line(&mut a_str).expect(\"read error\");\n (a_str\n .split_whitespace()\n .map(|x| x.parse::<$t>().unwrap())\n .collect::>())\n }};\n}\n\nfn solve() {\n let mut n = parse_line!(u32);\n let mut max: u32 = 0;\n let mut min = std::u32::MAX;\n let mut val: u32 = 1;\n for i in 2..n {\n if i * i > n {\n break;\n }\n if n % i != 0 {\n continue;\n }\n val *= i;\n let mut cnt = 0;\n while n % i == 0 {\n n /= i;\n cnt += 1;\n }\n max = std::cmp::max(max, cnt);\n min = std::cmp::min(min, cnt);\n }\n if n != 1 {\n max = std::cmp::max(max, 1);\n min = std::cmp::min(min, 1);\n val *= n;\n }\n let mult = if max != min || max & (max - 1) != 0 {1} else {0};\n if max & (max - 1) != 0 {\n max <<= 1;\n }\n while max & (max - 1) != 0 {\n max &= max - 1;\n }\n println!(\"{} {}\", val, mult + max.trailing_zeros());\n}\n\nfn main() {\n let tests = 1; // parse_line!(usize);\n for _ in 0..tests {\n solve();\n }\n}\n", "lang": "Rust", "bug_code_uid": "eaa27f55b5aa994cae47234996d26381", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "apr_id": "0ba0246844fc5209d56facb368391cee", "difficulty": 1500, "tags": ["greedy", "math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.991695163654128, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "#![allow(unused_imports)]\n#![allow(non_snake_case)]\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::Write;\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($e:expr),*) => {\n #[cfg(debug_assertions)]\n $({\n let (e, mut err) = (stringify!($e), std::io::stderr());\n writeln!(err, \"{} = {:?}\", e, $e).unwrap()\n })*\n };\n}\n\nfn fibonacchi(n: usize) -> Vec {\n let mut f = vec![0; n + 1];\n f[0] = 1;\n f[1] = 1;\n for i in 2..n + 1 {\n f[i] = (f[i - 1] + f[i - 2]) % 1000_000_007;\n }\n f\n}\n\nfn main() {\n let v = read_vec::();\n let f = fibonacchi(max(v[0], v[1]));\n println!(\"{}\", 2 * (f[v[0]] + f[v[1]] - 1));\n}\n\nfn read() -> T {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n\nfn read_vec() -> Vec {\n read::()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n", "lang": "Rust", "bug_code_uid": "726f36ce40e23c93f9682e489ba98001", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "apr_id": "7b7b38b2221b78c4c2cbb467e9aa840c", "difficulty": 1700, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9960596678862933, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "//! http://codeforces.com/problemset/problem/837/A\n\n#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(isize);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\npub trait CharExt: Copy {\n fn is_digit(self, radix: u32) -> bool;\n fn to_digit(self, radix: u32) -> Option;\n fn is_alphabetic(self) -> bool;\n fn is_lowercase(self) -> bool;\n fn is_uppercase(self) -> bool;\n fn is_whitespace(self) -> bool;\n fn is_alphanumeric(self) -> bool;\n fn to_lowercase(self) -> Self;\n fn to_uppercase(self) -> Self;\n}\n\nmacro_rules! impl_u8 {\n ($meth:ident($($arg:ident : $ty:ty),*) -> $ret:ty) => {\n fn $meth(self, $($arg : $ty),*) -> $ret {\n let c = self as char;\n c.$meth($($arg),*)\n }\n }\n}\n\nimpl CharExt for u8 {\n impl_u8!(is_digit(radix: u32) -> bool);\n impl_u8!(to_digit(radix: u32) -> Option);\n impl_u8!(is_alphabetic() -> bool);\n impl_u8!(is_lowercase() -> bool);\n impl_u8!(is_uppercase() -> bool);\n impl_u8!(is_whitespace() -> bool);\n impl_u8!(is_alphanumeric() -> bool);\n fn to_lowercase(self) -> Self {\n let c = self as char;\n c.to_lowercase()\n .next()\n .map(|c| c as u8)\n .unwrap_or(self)\n }\n fn to_uppercase(self) -> Self {\n let c = self as char;\n c.to_uppercase()\n .next()\n .map(|c| c as u8)\n .unwrap_or(self)\n }\n}\n\n// -----------------------------------------------------------------------------\n\nfn volume(word: &[u8]) -> u32 {\n word.iter()\n .filter_map(|&c| if c.is_uppercase() { Some(()) } else { None })\n .count()\n as u32\n}\n\nfn main() {\n use std::io::{self, Write, BufWriter};\n let __stdout = io::stdout();\n let mut __out = BufWriter::with_capacity(4096, __stdout.lock());\n\n macro_rules! put {\n ($fmt:expr) => { write!(__out, $fmt).unwrap(); };\n ($fmt:expr, $($arg:expr),+) => { write!(__out, $fmt, $($arg),+).unwrap(); }\n }\n macro_rules! putln {\n () => { writeln!(__out, \"\").unwrap(); };\n ($fmt:expr) => { writeln!(__out, $fmt).unwrap(); };\n ($fmt:expr, $($arg:expr),+) => { writeln!(__out, $fmt, $($arg),+).unwrap(); }\n }\n macro_rules! fflush {\n () => { __out.flush().unwrap(); }\n }\n\n scanln!(_n: u32);\n scanln!(s: String);\n let mut max_volume = 0;\n for word in s.split_whitespace() {\n let vol = volume(word.as_bytes());\n max_volume = std::cmp::max(vol, max_volume);\n }\n putln!(\"{}\", max_volume);\n}\n", "lang": "Rust", "bug_code_uid": "7dbbee8f1adf03460755ae5a8e3138c1", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "apr_id": "0a5fa39f6c219911af93339d5be5cbef", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.2229070364663585, "equal_cnt": 9, "replace_cnt": 9, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 9, "bug_source_code": "macro_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\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\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\nfn volume_of(word: &str) -> usize {\n word.chars().filter(|x| x.is_uppercase()).count()\n}\n\nfn main() {\n input! {\n _a: usize,\n s: String,\n }\n println!(\"{}\", s.split(\" \").map(|x| volume_of(x)).max().unwrap_or(0));\n}\n", "lang": "Rust", "bug_code_uid": "0da18da0d7ff1227d274eb6a5dada2f8", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "apr_id": "23557b570014cb5b486d5517028c55f7", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9990147783251232, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "\n\nfn read_string() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n input\n}\n\nfn read_int() -> u64 {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n let x = input.trim().parse::().unwrap();\n input.clear();\n x\n}\n\n\nfn main(){\n let i = read_int() + 2;\n let s = read_string().replace(\"\\n\", \"\").replace(\"\\r\", \"\");\n let vec: Vec<&str> = s.split(\"\").collect();\n let caps = vec![\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"G\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"];\n let mut max = 0;\n let mut tmp = 0;\n for x in 0..i{\n for cap in 0..caps.len(){\n if vec[x as usize] == caps[cap as usize]{\n tmp = tmp + 1;\n } \n }\n if (vec[x as usize] == \" \") || (vec[x as usize] == \"\"){\n if max < tmp{\n max = tmp;\n }\n tmp = 0;\n }\n }\n println!(\"{:?}\", max);\n}", "lang": "Rust", "bug_code_uid": "54e1ed2d84ba7d63a47ee5d08973910d", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "apr_id": "c8596c555d47870385e47fb730e22d37", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6902812388750444, "equal_cnt": 24, "replace_cnt": 17, "delete_cnt": 5, "insert_cnt": 1, "fix_ops_cnt": 23, "bug_source_code": "use std::io::{self, prelude::*};\nuse std::str;\nuse std::string::String;\nuse std::collections::LinkedList;\nuse std::vec::Vec;\nuse std::cmp;\n\nfn bfs(initial_length: i32, abc_list: Vec) -> i32 {\n let mut answer: i32 = 0;\n\n //TODO: BFS, but do not return after the count is 0\n let mut queue: LinkedList = LinkedList::new();\n queue.push_back(initial_length);\n\n let mut step: i32 = 0;\n loop {\n if queue.len() == 0 {\n break;\n }\n\n let size: usize = queue.len();\n for _ in 0..size {\n let current: i32 = queue.pop_front().unwrap();\n\n if current < 0 {\n continue;\n }\n\n if current == 0 {\n answer = cmp::max(answer, step);\n }\n\n //subtract\n for i in 0..abc_list.len() {\n let next_result: i32 = current - abc_list[i];\n queue.push_back(next_result);\n }\n }\n\n step += 1;\n }\n\n return answer;\n}\n\n#[allow(unused_must_use)]\nfn run(mut reader: Scanner, mut writer: W) {\n let initial_length: i32 = reader.next();\n\n let mut list: Vec = Vec::new();\n for _ in 0..3 {\n list.push(reader.next());\n }\n writeln!(writer, \"{}\", bfs(initial_length, list));\n}\n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n\n let reader = Scanner::new(stdin.lock());\n let writer = io::BufWriter::new(stdout.lock());\n run(reader, writer);\n}\n\npub struct Scanner {\n reader: B,\n buffer_string: Vec,\n buffer_iterator: str::SplitWhitespace<'static>,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Self {\n return Self {\n reader,\n buffer_string: Vec::new(),\n buffer_iterator: \"\".split_whitespace()\n };\n }\n\n pub fn next(&mut self) -> T {\n loop {\n //if buffer already exists, just use existing buffer\n if let Some(token) = self.buffer_iterator.next() {\n return token.parse().ok().expect(\"Fail to parse token\");\n }\n\n //get new line\n self.buffer_string.clear();\n self.reader.read_until(b'\\n', &mut self.buffer_string).expect(\"Failed to read\");\n\n //split by white space\n self.buffer_iterator = unsafe {\n let slice = str::from_utf8_unchecked(&self.buffer_string);\n std::mem::transmute(slice.split_whitespace())\n };\n }\n }\n\n pub fn next_line(&mut self) -> String {\n //reset buffer\n self.buffer_iterator = \"\".split_whitespace();\n self.buffer_string.clear();\n\n let mut input: String = String::new();\n self.reader.read_line(&mut input).expect(\"Failed to read line\");\n return input.trim().to_string();\n }\n}", "lang": "Rust", "bug_code_uid": "3cfc28281279b1d770050fd67d1fe0c6", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "apr_id": "5fced3210dd24d66aaf8463c18bf0fb4", "difficulty": 1300, "tags": ["dp", "brute force"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.44589450788471996, "equal_cnt": 15, "replace_cnt": 13, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 15, "bug_source_code": "use std::cmp::max;\n\nfn main() {\n let inp = read_input();\n let (n, a, b, c) = (inp[0], inp[1], inp[2], inp[3]);\n let mut ans = 0;\n\n ans = max(ans, compute(n, a, b, c));\n ans = max(ans, compute(n, a, c, b));\n ans = max(ans, compute(n, b, a, c));\n ans = max(ans, compute(n, b, c, a));\n ans = max(ans, compute(n, c, a, b));\n ans = max(ans, compute(n, c, b, a));\n\n println!(\"{}\", ans);\n}\n\nfn compute(mut n: usize, x: usize, y: usize, z: usize) -> usize {\n match n % x % y % z {\n 0 => {\n let mut ans = n / x;\n n %= x;\n ans += n / y;\n n %= y;\n ans += n / z;\n ans\n }\n _ => 0,\n }\n}\n\nfn read_input() -> Vec {\n let mut buffer = String::new();\n\n std::io::stdin()\n .read_line(&mut buffer)\n .expect(\"Failed to get input\");\n\n buffer\n .trim()\n .split_whitespace()\n .map(|x| x.parse().expect(\"Failed to parse number\"))\n .collect()\n}\n", "lang": "Rust", "bug_code_uid": "b5169d6f156f26bf52b026eef174e84c", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "apr_id": "84a0c7adeaef772845e6d2f8c8741de7", "difficulty": 1300, "tags": ["dp", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9998419971559488, "equal_cnt": 1, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(dead_code)]\n\nuse std::char::*;\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse std::str::FromStr;\n\nmacro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);}}\nmacro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }\nmacro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }\nmacro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\n\n\nfn read() -> T {\n let stdin = stdin();\n let stdin = stdin.lock();\n let token: String = stdin\n .bytes()\n .map(|c| c.expect(\"failed to read char\") as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect();\n token.parse().ok().expect(\"failed to parse token\")\n}\n\nfn read_vec() -> Vec {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim().split_whitespace()\n .map(|e| e.parse().ok().unwrap()).collect()\n}\n\n\nuse std::f64;\n\nfn min(a:T, b:T) -> T {\n if a < b { a }\n else { b }\n}\n\nfn max(a:T, b:T) -> T {\n if a < b { b }\n else { a }\n}\n\nuse std::hash::Hash;\nfn inc(map:&mut BTreeMap, key:T) {\n let count = map.entry(key).or_insert(0);\n *count += 1;\n}\n\nfn int(ch: char) -> i64 {\n return (ch as u8 - b'0') as i64\n}\n\nconst MAX:usize = 100006;\nconst INF:i64 = std::i64::MAX;\nconst MOD:i64 = 1e9 as i64 + 7;\n\n\nfn main() {\n input!{n:usize, a:[usize;3]};\n\n let mut dp = vec![-1;n+1];\n dp[0] = 0;\n\n for i in 0..n+1 {\n for j in 0..3 {\n if i < a[j] { continue; }\n if dp[i-a[j]] == -1 { continue; }\n dp[i] = max(dp[i], dp[i-a[j]]+1);\n }\n }\n //debug!(dp);\n\n println!(\"{}\", dp[n]);\n}\n\n/*\n\n長さ n のリボンを a,b,c のいずれかの長さにする。\nこのとき、最大のリボンの数を求める。\n\ndp[i] := 長さ i のリボンを切れる最大の数\ndp[i] = max(dp[i-a[j]]+1, j=0,1,2)\n\n\n\n*", "lang": "Rust", "bug_code_uid": "9e1a41a01814621e601ececf1d694f76", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "apr_id": "598794fe00765c9ba7ef883f07a9581c", "difficulty": 1300, "tags": ["dp", "brute force"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9971440228478172, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "fn minimun_cuts(n: i32, options: &[i32]) -> i32 {\n let mut table = vec![vec![-1; options.len()]; n as usize + 1];\n\n fn traverse(mut n: i32, options: &[i32], table: &mut Vec>) -> i32 {\n for (i, option) in options.iter().enumerate() {\n if table[n as usize][i] == -1 {\n let mut push_value = -900;\n let conditional = n - option;\n if conditional == 0 {\n push_value = 1;\n } else if conditional > 0 {\n n -= option;\n push_value = 1 + traverse(n, options, table);\n n += option;\n }\n table[n as usize][i] = push_value;\n }\n }\n *table[n as usize].iter().max().unwrap()\n }\n \n traverse(n, options, &mut table)\n}\n\nfn main() {\n let mut variables = String::new();\n std::io::stdin().read_line(&mut variables).unwrap();\n let variables: Vec = variables\n .split_whitespace()\n .map(|string| string.trim().parse().ok().unwrap())\n .collect();\n let n = variables[0];\n let (a, b, c) = (variables[1], variables[2], variables[3]);\n println!(\"{}\", minimun_cuts(n, &[a, b, c]));\n}\n", "lang": "Rust", "bug_code_uid": "ff58c4e5b2f409d7bd7a6ca2ca0bc6d8", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "apr_id": "764816ea6ebe5d97ba47e288e929df2d", "difficulty": 1300, "tags": ["dp", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.898691226369365, "equal_cnt": 11, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 10, "bug_source_code": "// 992C\nuse std::io;\n\nfn main() {\n let (x, k) = read_2::(&io::stdin());\n let modulo = 1000000007;\n if x == 0 {\n println!(\"{}\", x);\n return;\n }\n let a = (mod_exp(2, k + 1, modulo) * x) % modulo;\n let b = mod_exp(2, k, modulo);\n if a >= b {\n println!(\"{}\", (a - b + 1) % modulo);\n } else {\n println!(\"{}\", (modulo + (a - b) + 1) % modulo);\n }\n}\n\nfn mod_exp(mut a: u64, mut k: u64, n: u64) -> u64 {\n let mut multiplier = 1;\n a = a % n;\n while k != 0 {\n if k % 2 == 0 {\n a = (a * a) % n;\n } else {\n multiplier = (multiplier * a) % n;\n a = (a * a) % n;\n }\n k = k / 2;\n }\n multiplier as u64\n}\n\nfn read_2(stdin: &io::Stdin) -> (T, T)\nwhere\n T: std::str::FromStr,\n ::Err: std::fmt::Debug,\n{\n let mut s = String::new();\n stdin.read_line(&mut s).unwrap();\n let mut iter = s.trim().split_whitespace().map(|x| x.parse().unwrap());\n (iter.next().unwrap(), iter.next().unwrap())\n}\n", "lang": "Rust", "bug_code_uid": "6c3dbe8ba95c22a929ada56eb2397b52", "src_uid": "e0e017e8c8872fc1957242ace739464d", "apr_id": "e7272202c1bc3b5eeae75edcdf7d4019", "difficulty": 1600, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9977064220183486, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "//! http://codeforces.com/contest/732/problem/A\n\nfn main() {\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let mut ns = buf.split(\" \")\n .map(|str| str.trim().parse::().unwrap());\n let k = ns.next().unwrap();\n let r = ns.next().unwrap();\n let mut i = 1;\n loop {\n if ((i * k) - r) % 10 == 0 { break; }\n if (i * k) % 10 == 0 { break; }\n i += 1;\n }\n println!(\"{}\", i);\n}\n", "lang": "Rust", "bug_code_uid": "e0f36358b9d56bde342c0ad6766d5823", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "apr_id": "c0776fab1d7aadf6c4081975781d5f87", "difficulty": 800, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9779507133592736, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_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": "Rust", "bug_code_uid": "f3dd29db8c83cdb17ff88933e6e16a71", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "apr_id": "9e873675b0a1f5f0c5a69abb868add44", "difficulty": 800, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9913544668587896, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\npub struct Scanner {\n reader: B,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Scanner {\n Scanner {\n reader: reader,\n buffer: Vec::new(),\n }\n }\n\n /// Use \"turbofish\" syntax next::() to select data type of next token.\n pub fn next(&mut self) -> T\n where\n T::Err: ::std::fmt::Debug,\n {\n if let Some(front) = self.buffer.pop() {\n front.parse::().expect(&front)\n } else {\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Line not read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n self.next()\n }\n }\n}\n\nfn main1() {\n let stdin = io::stdin();\n let mut input = Scanner::new(stdin.lock());\n let k = input.next::();\n let r = input.next::();\n for i in 1..10 {\n if (i * k % 10) == r {\n println!{\"{}\", i};\n return;\n }\n }\n println![\"10\"];\n}\n\nfn main() {\n std::thread::Builder::new().stack_size(50 << 20)\n .spawn(main1).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "5a340a934a68ddd3c102e66569b3cb4f", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "apr_id": "0b1c17f0be10cc094b0214d0e2bc4e49", "difficulty": 800, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.960082944530845, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "\n#![allow(unused_imports)]\nuse std::io;\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::str::FromStr;\nuse std::collections::{VecDeque, HashMap};\n\nfn main() {\n let stdin = io::stdin();\n let mut input = stdin.lock();\n let mut line = String::new();\n input.read_line(&mut line).unwrap();\n let nums = get_numbers(&line);\n let shovel_price: u32 = nums[0];\n let change = nums[1];\n\n for i in 1..11 {\n let total = i * shovel_price;\n if total % 10 == 0 || (total - change) % 10 == 0 {\n println!(\"{}\", i);\n return;\n }\n }\n\n println!(\"-1\");\n}\n\n/*\n * Utility Functions\n */\n\n// get numbers from line seperated by spaces\nfn get_numbers(line: &str) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n line.split_whitespace()\n .map(|chunk| chunk.parse::().expect(\"failed to parse\"))\n .collect()\n}\n\n", "lang": "Rust", "bug_code_uid": "9c1d640993fbe0e5da3f64fe8fdcbd23", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "apr_id": "a15680390bbd7c805d4bf99a02dc6576", "difficulty": 800, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9942528735632183, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::stdin;\nfn main() {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n let distance: i32 = input.trim().parse().unwrap();\n\n if distance <= 5 {\n println!(\"1\");\n } else if distance % 5 == 0 {\n println!(\"{}\", distance % 5);\n } else {\n println!(\"{}\", distance % 5 + 1);\n }\n}\n", "lang": "Rust", "bug_code_uid": "5ad43eefe1e22ea6273be5b3f2983938", "src_uid": "4b3d65b1b593829e92c852be213922b6", "apr_id": "e62458ffa0d83335b1f189a3f4317301", "difficulty": 800, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9984025559105432, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::stdin;\nuse std::cmp::min;\n\nfn main() {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n let nposlr = input.split_whitespace().map(|x| x.parse::().unwrap()).collect::>();\n let (n, pos, l, r) = (nposlr[0], nposlr[1], nposlr[2], nposlr[3]);\n\n if l == 1 && r == n {\n println!(\"0\");\n } else if l == 1 {\n println!(\"{}\", (pos - r).abs() + 1);\n } else if r == 1 {\n println!(\"{}\", (pos - l).abs() + 1);\n } else {\n let min_dist = min((pos - l).abs(), (pos - r).abs());\n println!(\"{}\", min_dist + (r - l).abs() + 2);\n }\n\n\n\n}\n", "lang": "Rust", "bug_code_uid": "97c76d3e8c2ed28d55767d79b7f6b541", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "apr_id": "9ddbc3299a2af6f90d8f32169429d4c0", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8634538152610441, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\n\nfn main() {\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut numbers = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n let n = numbers[0];\n let pos = numbers[1];\n let l = numbers[2];\n let r = numbers[3];\n\n let mut res = 0;\n\n if l != 1 && r == n {\n res += (pos - l).abs() + 1;\n } else if r != n && l == 1 {\n res += (r - pos).abs() + 1;\n } else if r == n && l == 1{\n res = 0;\n } else {\n if (pos - l).abs() < (r - pos).abs() {\n if l != r {\n res += r - l - 1 + 2 * (pos - l).abs() + 2;\n } else {\n res += (pos - l).abs() + 2;\n }\n } else {\n if l != r {\n res += r - l - 1 + 2 * (r - pos).abs() + 2;\n } else {\n res += (r - pos).abs() + 2;\n }\n }\n }\n println!(\"{}\", res);\n}\n", "lang": "Rust", "bug_code_uid": "df993201679ef1474ee1c79f440859c1", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "apr_id": "aabf1e5c36f4b678f503362c5799efdc", "difficulty": 1300, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9187613843351549, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::io::Stdin;\nuse std::str::FromStr;\n\nconst DECIMAL_RADIX : u64 = 10;\n\nfn read_line(stdin : &Stdin, line : &mut String) {\n match stdin.read_line(line) {\n Ok(_) => return,\n Err(msg) => panic!(\"Could not read line! Message: {}.\", msg),\n }\n}\n\nfn parse_t(s : &str) -> T {\n match s.trim().parse() {\n Ok(y) => y,\n Err(_) => panic!(\"Could not read from string!\"),\n }\n}\n\nfn read_t(stdin : &Stdin) -> T {\n let mut line = String::new();\n read_line(stdin, &mut line);\n parse_t(&line)\n}\n\nfn little_endian_digits(n : u64, ds : &mut Vec) {\n let mut x = n;\n loop {\n let d = x % 10;\n x = x / 10;\n ds.push(d);\n if x == 0 {\n break;\n }\n }\n}\n\nfn big_endian_digits(n : u64, ds : &mut Vec) {\n little_endian_digits(n, ds);\n ds.reverse();\n}\n\nfn big_endian_digits_to_number(ds : &Vec) -> u64 {\n let mut x = 0;\n for d in ds {\n x = (x * 10) + d;\n }\n x\n}\n\nfn contains(y : u64, xs : &Vec) -> bool {\n for &x in xs {\n if y == x {\n return true;\n }\n }\n false\n}\n\nfn find_replacement_digit(d : &Option, digits : &Vec) -> Option {\n let mut s = 0;\n match *d {\n None => (),\n Some(y) => {\n s = y + 1;\n },\n }\n for i in s .. DECIMAL_RADIX {\n if contains(i, digits) {\n // Do nothing ...\n } else {\n return Some(i);\n }\n }\n None\n}\n\nfn next_with_distinct_digits(n : u64) -> u64 {\n let mut b_e_digits = vec![];\n big_endian_digits(n, &mut b_e_digits);\n let orig_level = b_e_digits.len() - 1;\n let mut level = orig_level;\n let mut c_d_o = Some(b_e_digits[level]);\n loop {\n let r_d_o = find_replacement_digit(&c_d_o, &b_e_digits);\n match r_d_o {\n None => {\n b_e_digits.pop();\n level = level - 1;\n c_d_o = Some(b_e_digits[level]);\n },\n Some(r_d) => {\n b_e_digits[level] = r_d;\n if level < orig_level {\n b_e_digits.push(DECIMAL_RADIX);\n }\n level = level + 1;\n c_d_o = None;\n }\n }\n if level > orig_level {\n break;\n }\n }\n big_endian_digits_to_number(&b_e_digits)\n}\n\nfn main() {\n let stdin = io::stdin();\n let n = read_t(&stdin);\n println!(\"{}\", next_with_distinct_digits(n));\n}\n", "lang": "Rust", "bug_code_uid": "67348a07d8a3aea9c3901c8116e2eef2", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "apr_id": "bf210e4e594425da73707085ab4f9730", "difficulty": 800, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9968207385668868, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rust\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::*;\n#[allow(unused_imports)] use std::collections::*;\n\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($i:ident . $e:tt : $t:ty, $($a:ident),*) => {\n $( let $a: $t = $i.$e(); )*\n };\n ($i:ident . $e:tt, $($a:ident),*) => {\n $( let $a = $i.$e(); )*\n };\n}\n\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl std::iter::Iterator where T::Err: Debug {\n //(0..n).map(|_| self.p())\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n l!(input.i, a, b);\n if (a - b).abs() <= 1 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "5657fd446e9f840741b7c6cfb5da6329", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "apr_id": "e7316ce09af6156b38a9fbd04d01aa06", "difficulty": 1000, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9243542435424354, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_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": "Rust", "bug_code_uid": "8c64102881700a907cbda283a937380c", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "apr_id": "4522e8b336fc5a54b6b65169aba661e1", "difficulty": 1000, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9889722099691222, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 4, "bug_source_code": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var, $t:ty, $($v:ident), *) => {\n read_line!(input_line);\n let mut iter = parse_token!($t, input_line);\n $(\n let $v = iter.next().unwrap();\n )*\n };\n (vec, $t:ty, $v:ident) => {\n read_line!(input_line);\n let iter = parse_token!($t, input_line);\n let $v: Vec<$t> = iter.collect();\n };\n ($($v:ident; $t:ty), *) => {\n read_line!(input_line);\n let mut iter = input_line.split_whitespace();\n $(\n let $v: $t = iter.next().unwrap().parse().unwrap();\n )*\n };\n}\n\nmacro_rules! parse_token {\n ($t:ty, $e:expr) => {\n $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());\n };\n}\n\nfn main() {\n read_line!(even;i64, odd;i64);\n if odd == 0 && even == 0{\n println!(\"NO\") // There must be one staircase\n }\n if (odd - even).abs() <= 1 { // Valid count\n println!(\"YES\")\n } else {\n println!(\"NO\")\n }\n}", "lang": "Rust", "bug_code_uid": "11b13c3e60961c15c986523624f01531", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "apr_id": "4522e8b336fc5a54b6b65169aba661e1", "difficulty": 1000, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9920153305653145, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_imports)]\nuse std::io::{ self, Write };\nuse std::str::FromStr;\nuse std::cmp::{ min, max };\nuse std::collections::{ BinaryHeap, VecDeque };\n\nmacro_rules! trace {\n ($var:expr) => ({\n let _ = writeln!(&mut std::io::stderr(), \">>> {} = {:?}\", stringify!($var), $var);\n })\n}\nmacro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }\n\nfn main() {\n let mut sc = Scanner::new();\n let a: i32 = sc.cin();\n let b: i32 = sc.cin();\n\n let k = if a == b || a + 1 == b { \"YES\" } else { \"NO\" };\n println!(\"{}\", k);\n\n}\n\n#[allow(dead_code)]\nstruct Scanner { stdin: io::Stdin, buffer: VecDeque, }\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }\n fn reserve(&mut self) {\n while self.buffer.len() == 0 {\n let mut line = String::new();\n let _ = self.stdin.read_line(&mut line);\n for w in line.split_whitespace() {\n self.buffer.push_back(String::from(w));\n }\n }\n }\n fn cin(&mut self) -> T {\n self.reserve();\n match self.buffer.pop_front().unwrap().parse::() {\n Ok(a) => a,\n Err(_) => panic!(\"parse err\")\n }\n }\n fn get_char(&mut self) -> char {\n self.reserve();\n let head = self.buffer[0].chars().nth(0).unwrap();\n let tail = String::from( &self.buffer[0][1..] );\n if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }\n head\n }\n}\n", "lang": "Rust", "bug_code_uid": "d5d625569d0061bc39bd60a671b97741", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "apr_id": "50091f1b555f91049b0c6767a701c1f0", "difficulty": 1000, "tags": ["brute force", "math", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9787234042553191, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#[derive(Debug)]\nstruct RhombusIterator{\n current: isize,\n count: isize,\n total: isize,\n}\n\nimpl RhombusIterator{\n pub fn new() ->Self{\n RhombusIterator{\n current: 1,\n count: 0,\n total: 1,\n }\n }\n}\n\nimpl Iterator for RhombusIterator{\n type Item = isize;\n\n fn next(&mut self) -> Option {\n match self.current{\n 1 => {},\n _ => {\n self.total += 2* self.current + (2* self.count);\n self.count += 1;\n },\n }\n self.current +=1;\n Some(self.total)\n }\n}\n\nfn main() -> Result<(), Box> {\n\n //parse\n let mut input = String::new();\n std::io::stdin().read_line(&mut input)?;\n let input: usize = input.trim().parse().expect(\"Invalid input parameter\");\n\n //solve\n let result = solve(input);\n\n //print\n println!(\"{}\", result);\n\n Ok(())\n}\n\n\nfn solve(input: usize) -> isize{\n let iter = RhombusIterator::new();\n iter.skip(input-1).inspect(|s| println!(\"Input: {}, Current: {}\", input, s)).next().expect(\"Could not calc rhombus\")\n}\n\n\n#[cfg(test)]\nmod test{\n use super::solve;\n\n\n #[test]\n fn test1() {\n\n assert_eq!(1, solve(1));\n assert_eq!(5, solve(2));\n assert_eq!(solve(3), 13);\n assert_eq!(25, solve(4));\n assert_eq!(41, solve(5));\n }\n}", "lang": "Rust", "bug_code_uid": "a77c0a10832fd6ec2e1ebdadcd126ac9", "src_uid": "758d342c1badde6d0b4db81285be780c", "apr_id": "74ec60183c22c9c471f9046fad3f1e63", "difficulty": 800, "tags": ["dp", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9878127004490058, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::cmp::{max, min};\nuse std::io::{stdin, stdout, BufWriter, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec,\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scanner = Scanner::default();\n\n let n = scanner.next::();\n\n let mut dp = vec![1];\n\n for i in 1..n {\n dp.push(dp[i - 1] + i * 4);\n }\n\n println!(\"{:?}\", dp);\n}\n", "lang": "Rust", "bug_code_uid": "91688cac483b4ccc0c893bf879f76aa9", "src_uid": "758d342c1badde6d0b4db81285be780c", "apr_id": "33041843e39e88c66b79c9377bcd992f", "difficulty": 800, "tags": ["dp", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.07243460764587525, "equal_cnt": 17, "replace_cnt": 10, "delete_cnt": 6, "insert_cnt": 1, "fix_ops_cnt": 17, "bug_source_code": "fn main() {\n let str = \"010\";\n let trimmed = str.trim();\n let mut negative = false;\n let mut lookup = &trimmed[..];\n if trimmed.starts_with('-') {\n negative = true;\n lookup = &trimmed[1..];\n }\n if trimmed.starts_with('+') {\n negative = false;\n lookup = &trimmed[1..];\n }\n \n let digits = lookup.chars().take_while(|c| c.is_digit(10)).collect::>();\n let mut answer: i64 = 0;\n\n for d in digits.iter().map(|c| c.to_digit(10).unwrap()) {\n answer *= 10;\n\n answer += match negative {\n true => -1 * d as i64,\n false => d as i64,\n };\n\n if answer >= i32::max_value().into() {\n answer = i32::max_value() as i64;\n break;\n }\n if answer <= i32::min_value().into() {\n answer = i32::min_value() as i64;\n break;\n }\n }\n \n println!(\"{}\", answer);\n}\n", "lang": "Rust", "bug_code_uid": "a11fe434f6f98ea642a49c8e6a53dcc7", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "apr_id": "6686482f60e7ba4c26bf709ad6ae2a72", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9991928974979822, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::stdin;\n\nfn main()\n{\n //handle input / output\n let mut s = String::new();\n stdin().read_line(&mut s).unwrap();\n let card: Vec<_> = s.split_whitespace().collect();\n let card = card[0].clone().chars().collect::>();\n let mut s = String::new();\n stdin().read_line(&mut s).unwrap();\n let deck: Vec<_> = s.split_whitespace().collect();\n let deck = deck.iter().map( |c| c.chars().collect::>()).collect::>();\n\n for dc in deck {\n if dc[0] == card[0] || dc[1] == card[1] {\n println!(\"YES\");\n return;\n }\n }\n\n println!(\"N\");\n}", "lang": "Rust", "bug_code_uid": "c67acb166c6b5c3493f2a5ea88c82510", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "apr_id": "f326dc14e6a54799969efed795b671db", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9362017804154302, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nfn get_nums() -> Vec {\n\tlet mut input = String::new();\n\n\tio::stdin().read_line(&mut input)\n\t\t.expect(\"\");\n\n\tinput.trim()\n\t\t.split_whitespace()\n\t\t.map(|d| i32::from_str(d).unwrap())\n\t\t.collect::>()\n}\n\nfn get_quad() -> (i32, i32, i32, i32) {\n\tlet v = get_nums();\n\n\t(v[0], v[1], v[2], v[3])\n}\n\nfn main() {\n \tlet (n, t, mut k, d) = get_quad();\n\n \tlet mut t1 = 0;\n \tlet mut c = 0;\n\n \twhile c < n {\n \t\tt1 += t;\n \t\tc += k;\n\t}\n\n\tlet mut t2 = 0;\n\tc = 0;\n\t\n\tif d > k {\n\t\tt2 += d;\n\t\t\n\t\tfor _ in 0..d/t {\n\t\t\tc += k;\n\t\t}\n\t\tk *= 2;\n\t} else {\n\t\tt2 += t;\n\t\tc += k;\n\t}\n\n\twhile c < n {\n\t\tt2 += t;\n\t\tc += k;\n\t}\n\n\tif t1 > t2 {\n\t\tprintln!(\"YES\");\n\t} else {\n\t\tprintln!(\"NO\");\n\t}\n}", "lang": "Rust", "bug_code_uid": "852f851eb58c8ff8ed575e03c6ed4293", "src_uid": "32c866d3d394e269724b4930df5e4407", "apr_id": "5c5c5c46a4b281e92a9617765df3a626", "difficulty": 1100, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.7875354107648725, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\nuse std::io::prelude::*;\n\nfn get_line() -> String {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input\n}\n\nfn main() {\n let (n, t, k, d) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse::().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n // n + r = k * x;\n // n = k * x - r ; k < -r <= 0\n // n = k * x + r ; k < r <= 0\n // n + k - 1 = k * x + r ; 0 <= r < k\n // n - 1 = k * (x - 1) + r\n\n let t1 = (n - 1) / k + 1;\n\n let ta = d / t;\n let tb = t1 - ta;\n\n if tb > 1 {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "59275630bc4f31cff499d5d8b99e8cc3", "src_uid": "32c866d3d394e269724b4930df5e4407", "apr_id": "c76ddfe5d5768d7005559093ece8d3e4", "difficulty": 1100, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9958847736625515, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn input_split() -> Vec {\n let mut buf = String::with_capacity(7);\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect()\n}\n\nfn main() {\n let mut shoes = input_split();\n shoes.sort_unstable();\n shoes.dedup();\n println!(\"{}\", 4 - shoes.len());\n}", "lang": "Rust", "bug_code_uid": "9ad44f9f6faa55013b805a803a296823", "src_uid": "38c4864937e57b35d3cce272f655e20f", "apr_id": "6d3277d8bc480f3ea282df49f36510d7", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9832847722741911, "equal_cnt": 11, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 10, "bug_source_code": "#[allow(unused_imports)] use std::{*, io::*, cmp::*, char::* };\n#[allow(unused)] macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }\n#[allow(unused)] macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\n#[allow(unused)] macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1}; ($next:expr, [ $t:tt ]) => {{ let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect(\"Parse error\")};}\n#[allow(unused)] macro_rules! debug { ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap()); }\n#[allow(unused)] macro_rules! debugln { ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap()); }\n\nfn solve() {\n let out = std::io::stdout();\n let mut out = BufWriter::new(out.lock());\n #[allow(unused)] macro_rules! puts { ($($format:tt)*) => (let _ = write!(out,$($format)*);); }\n\n let s1: Vec = get_word().chars().collect();\n let s2: Vec = get_word().chars().collect();\n\n let mut sum1 = 0;\n let mut sum2 = 0;\n \n for c in s1 {\n\tsum1 += match c {\n\t '+' => 1,\n\t '-' => -1,\n\t _ => 0,\n\t}\n }\n\n for c in &s2 {\n\tsum2 += match *c {\n\t '+' => 1,\n\t '-' => -1,\n\t _ => 0,\n\t}\n }\n\n let mut q = 0;\n \n for c in &s2 {\n\tif *c == '?' {\n\t q += 1;\n\t}\n }\n\n\n let d: i64 = sum1 - sum2;\n let d = d.abs();\n\n let mut num = 1;\n\n if d > q || d * q % 2 != 0 { puts!(\"{}\", 0.0); } else {\n \n\tlet m = d + (q - d) / 2;\n\tfor i in (q - m + 1)..(q + 1) {\n\t num *= i;\n\t}\n\n\tputs!(\"{}\", num as f64 / (1 << q) as f64);\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\n#[allow(dead_code)]\nfn get_word() -> String {\n let stdin = std::io::stdin();\n let mut stdin=stdin.lock();\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#[allow(dead_code)]\nfn get() -> T { get_word().parse().ok().unwrap() }\n\n// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\n", "lang": "Rust", "bug_code_uid": "a275ac7263563112a6025056beb131e8", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "apr_id": "8f0b43a6fb9991874ee6e800063baab6", "difficulty": 1300, "tags": ["dp", "probabilities", "combinatorics", "bitmasks", "math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9982886480319453, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_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 sent: String = scan.next();\n let received: String = scan.next();\n let mut pos: isize = 0;\n for mov in sent.chars() {\n if mov == '+' {\n pos += 1;\n } else if mov == '-' {\n pos -= 1;\n }\n }\n let mut new_pos: isize = 0;\n let mut unknown: isize = 0;\n for mov in received.chars() {\n if mov == '+' {\n new_pos += 1;\n } else if mov == '-' {\n new_pos -= 1;\n } else {\n unknown += 1;\n }\n }\n let needed = pos - new_pos;\n if needed > unknown {\n println!(\"{:.5}\", 0.0f64);\n } else {\n let total: usize = 2usize.pow(unknown as u32);\n let mut valid = 0isize;\n for i in 0..total {\n if (2 * i.count_ones() as isize - unknown as isize) == needed {\n valid += 1;\n }\n }\n let result = (valid as f64) / (total as f64);\n println!(\"{:.5}\", result);\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": "Rust", "bug_code_uid": "8d5ed2a70f29968d6f8efeeeb8ec8433", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "apr_id": "d1f1c17e4d6303b26761d8800ab77488", "difficulty": 1300, "tags": ["dp", "probabilities", "combinatorics", "bitmasks", "math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9265442404006677, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin()\n .read_line(& mut s)\n .expect(\"Deu Ruim\");\n \n let s = s.trim();\n let n = s.len();\n\n let mut res = true;\n\n for i in 0..n-1 {\n\n match (&s[i..i+1], &s[i+1..i+2]) {\n\n (\"a\",_)|(\"e\",_)|(\"i\",_)|(\"o\",_)|(\"u\", _) => (),\n (\"n\", _) => (),\n (_,\"a\")|(_,\"e\")|(_,\"i\")|(_,\"o\")|(_,\"u\") => (),\n (_, _) => res = false,\n }\n }\n\n match res {\n true => println!(\"YES\", ),\n _ => println!(\"NO\", )\n }\n}\n", "lang": "Rust", "bug_code_uid": "525e24ebe3848de7eac62ff40e6783d3", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "apr_id": "202fa7e2a791309bc400d60165b9fc92", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.992432297204328, "equal_cnt": 17, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 13, "fix_ops_cnt": 16, "bug_source_code": "//spnauti-rusT {{{\nuse std::io::*; use std::str::{self,*}; use std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)] macro_rules! min {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! max {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};\n\t($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};\n\t(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};\n}\n#[allow(unused_macros)] macro_rules! v {\n\t([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};\n\t([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: v!([]), pos: 0 }\n\t}\n\tfn next_line(&mut self) -> bool {\n\t\tself.buf.clear(); self.pos = 0;\n\t\tself.q.read_until(b'\\n', &mut self.buf).unwrap_or(0) > 0\n\t}\n\tfn is_ws(c: u8) -> bool {\n\t\tc == b' ' || c == b'\\r' || c == b'\\n' || c == b'\\t'\n\t}\n\tfn byte(&mut self) -> Option {\n\t\tif self.pos == self.buf.len() { if !self.next_line() { return None; } }\n\t\tself.pos += 1; Some(self.buf[self.pos - 1])\n\t}\n\tfn vb(&mut self) -> Vec {\n\t\tlet mut s = v!([8]);\n\t\tlet mut f = false;\n\t\tloop {\n\t\t\tif let Some(c) = self.byte() {\n\t\t\t\tif !Self::is_ws(c) {\n\t\t\t\t\ts.push(c);\n\t\t\t\t\tf = true;\n\t\t\t\t} else if f { break; }\n\t\t\t} else { break; }\n\t\t}\n\t\ts\n\t}\n\tfn vvb(&mut self, r: usize, c: Option) -> Vec> {\n\t\tlet mut res = v!([r]);\n\t\tlet c = c.unwrap_or(0);\n\t\trep!{[r]\n\t\t\tlet t = self.vb();\n\t\t\tassert!(c == 0 || t.len() == c);\n\t\t\tres.push(t);\n\t\t}\n\t\tres\n\t}\n\tfn s(&mut self) -> String { String::from_utf8(self.vb()).expect(\"invalid utf8\") }\n\tfn i(&mut self) -> i32 { self.p() }\n\tfn l(&mut self) -> i64 { self.p() }\n\tfn u(&mut self) -> usize { self.p() }\n\tfn f(&mut self) -> f64 { self.p() }\n\tfn vi(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vl(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vu(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn ii(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn iu(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn p(&mut self) -> T where T::Err: Debug {\n\t\tlet w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::().unwrap()\n\t}\n\tfn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n\t\t(0..n).map(|_|self.p()).collect()\n\t}\n\tfn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n\t\tself.vp(n).into_iter()\n\t}\n\tfn graph(&mut self, n: usize, m: usize) -> Vec> {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); e[a].push(b); e[b].push(a); } e\n\t}\n\tfn graph_w(&mut self, n: usize, m: usize) -> Vec> where T::Err: Debug {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); let c: T = self.p(); e[a].push((b,c)); e[b].push((a,c)); } e\n\t}\n}\n//------------------- End rusT }}}\n\n// Field (mod prime) {{{\nmod field {\n\tuse std::ops::*;\n\t#[allow(dead_code)] pub const Z0: Field = Field(0);\n\t#[allow(dead_code)] pub const Z1: Field = Field(1);\n\tconst P5: i32 = 1_000_000_007;\n\tconst P6: i64 = P5 as i64;\n\t#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Default)] pub struct Field(i32);\n\t#[allow(dead_code)] impl Field {\n\t\tpub fn new>(a: T) -> Self { Self(Self::cv(a)) }\n\t\tpub fn new_unchecked(a: i32) -> Self { Self(a) }\n\t\tfn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }\n\t\tfn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }\n\t\tfn cv>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }\n\t\tpub fn inv(self) -> Self { self.pow(P5-2) }\n\t\tpub fn pow>(self, b: T) -> Self {\n\t\t\tlet b = b.into(); if b == 0 { Self(1) } else {\n\t\t\t\tlet mut res = self.pow(b/2); res *= res; if b % 2 == 1 {res *= self;} res\n\t\t\t}\n\t\t}\n\t}\n\timpl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}\n\timpl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}\n\timpl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}\n\timpl Div for Field { type Output = Self; fn div(self, a: Self) -> Self::Output { self * a.inv() }}\n\timpl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}\n\timpl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }\n\timpl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }\n\timpl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }\n\timpl DivAssign for Field { fn div_assign(&mut self, a: Self) { *self = *self / a; } }\n\tuse std::fmt::{Display, Formatter, Result};\n\timpl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, \"{}\", self.0) } }\n}\n#[allow(unused_imports)] use field::{Field, Field as Z, Z0, Z1};\n//}}}\n// Square Matrix (Field) {{{\ntype MatT = Field;\nconst MAT_T_0: MatT = Z0;\nconst MAT_T_1: MatT = Z1;\n#[derive(Debug,Clone)] struct Mat { n: usize, a: Vec }\n#[allow(dead_code)] impl Mat {\n\tfn new(n:usize)->Self{Self{n,a:vec![MAT_T_0;n*n]}}\n\tfn diag(n:usize,v:MatT)->Self{let mut m=Self::new(n);let mut p=0;for _ in 0..n{m.a[p]=v;p+=n+1;}m}\n\tfn pow(&self,n:u64)->Self{if n==0{Self::diag(self.n,MAT_T_1)}else{let mut t=self.pow(n/2);t*=t.clone();if n%2==1{t*=self.clone();}t}}\n\tfn range(&self,r:Range,c:Range)->Vec>{if r.startMatT{self.a[r*self.n+c]}\n\tfn at_mut<'a>(&'a mut self,r:usize,c:usize)->&'a mut MatT{&mut self.a[r*self.n+c]}//'\n}\nimpl Mul for Mat{type Output=Self;fn mul(self,o:Self)->Self::Output{assert!(self.n==o.n);let n=self.n;let mut res=Self::new(n);\n\tfor ii in(0..n).map(|i|i*n){for j in 0..n{let mut t=MAT_T_0;let mut kk=j;for k in 0..n{t+=self.a[ii+k]*o.a[kk];kk+=n;}res.a[ii+j]=t;}}res}}\nimpl Add for Mat{type Output=Self;fn add(mut self,o:Self)->Self{self+=o;self}}\nimpl Sub for Mat{type Output=Self;fn sub(mut self,o:Self)->Self{self-=o;self}}\nimpl MulAssign for Mat{fn mul_assign(&mut self,a:Self){*self=self.clone()*a;}}\nimpl AddAssign for Mat{fn add_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x+=y;}} }\nimpl SubAssign for Mat{fn sub_assign(&mut self,o:Self){assert!(self.n==o.n);for(x,y)in self.a.iter_mut().zip(o.a.into_iter()){*x-=y;}} }\nimpl PartialEq for Mat{fn eq(&self,o:&Self)->bool{self.n==o.n&&self.a==o.a}}impl Eq for Mat{}\n// }}}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tl!(n,m,l,r = rin.l());\n\tlet b = (n*m+1)/2;\n\tlet w = n*m/2;\n\tlet o = Z::new((r+1)/2 - l/2);\n\tlet e = Z::new(r/2 - (l-1)/2);\n\tlet mut mat = Mat::new(2);\n\t*mat.at_mut(0,0) = e;\n\t*mat.at_mut(0,1) = o;\n\t*mat.at_mut(1,0) = o;\n\t*mat.at_mut(1,1) = e;\n\tlet bm = mat.pow(b as u64);\n\tlet bw = mat.pow(w as u64);\n\tlet sol = bm.at(0,1) * bw.at(0,1) + bm.at(1,1) * bw.at(1,1);\n\twriteln!(rout, \"{}\", sol).ok();\n}\n", "lang": "Rust", "bug_code_uid": "6a038d9e41ea2aa4ee3cb547de445192", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "apr_id": "bdec621c21939763b3b24a49cf58fc48", "difficulty": 2100, "tags": ["matrices", "math", "combinatorics", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9992917847025495, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut ss: String = String::new();\n io::stdin().read_line(&mut ss).unwrap();\n let n: isize = ss.trim().parse().unwrap();\n\n let mut s: String = String::new();\n io::stdin().read_line(&mut s).unwrap();\n io::stdin().read_line(&mut s).unwrap();\n let v: Vec = s.trim()\n .split(' ')\n .map(|n| n.parse().unwrap())\n .collect();\n\n let mut g = vec![0.0; 4];\n\n for a in v.iter() {\n g[a - 2] += 1.0;\n }\n\n let cg = ((g[0]*2.0 + g[1]*3.0 + g[2]*4.0 + g[3]*5.0) / n as f32) + 0.5;\n\n let agg = vec![\n 3.0/n as f32,\n 2.0/n as f32,\n 1.0/n as f32,\n ];\n\n // println!(\"{}\", cg);\n // println!(\"{:?}\", agg);\n\n let mut sol = 5.0 - cg;\n if sol <= 0.0 {\n println!(\"0\");\n return;\n } else {\n let mut nn = (sol / agg[0] - 0.00001).ceil();\n // println!(\"{} {} {}\", sol, agg[0], sol / agg[0]);\n if nn <= g[0] {\n println!(\"{}\", nn);\n return;\n }\n sol -= g[0] * agg[0];\n\n nn = (sol / agg[1] - 0.0001).ceil();\n if nn <= g[1] {\n println!(\"{}\", nn + g[0]);\n return;\n }\n sol -= g[1] * agg[1];\n\n nn = (sol / agg[2] - 0.00001).ceil();\n if nn <= g[2] {\n println!(\"{}\", nn + g[0] + g[1]);\n return;\n }\n\n println!(\"{}\", g[0] + g[1] + g[2]);\n }\n}\n", "lang": "Rust", "bug_code_uid": "e778651735fb2a7fee76950aa464c2f8", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "apr_id": "02d92307ed6c98b18f392bebdcb6a431", "difficulty": 900, "tags": ["greedy", "sortings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9996397694524496, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_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\n//------------------- Start Field\nconst P5: i32 = 1_000_000_007;\nconst P6: i64 = P5 as i64;\n#[derive(Debug,Clone,Copy)]\nstruct Field(i32);\n#[allow(dead_code)]\nimpl Field {\n fn new>(a: T) -> Self { Self(Self::cv(a)) }\n fn new_unchecked(a: i32) -> Self { Self(a) }\n fn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }\n fn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }\n fn cv>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }\n}\nimpl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}\nimpl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}\nimpl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}\nimpl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}\nimpl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }\nimpl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }\nimpl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }\nuse std::fmt::{Display, Formatter, Result};\nimpl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, \"{}\", self.0) } }\n// impl Default for Field { fn default() -> Self { Field(0) }}\nimpl Default for &Field { fn default() -> Self { &Field(0) }}\nimpl PartialEq for Field { fn eq(&self, a: &Self) -> bool { self.0 == a.0 } }\nimpl PartialOrd for Field { fn partial_cmp(&self, a: &Self) -> Option { Some(self.0.cmp(&a.0)) } }\nimpl Eq for Field {}\nimpl Ord for Field { fn cmp(&self, a: &Self) -> Ordering { self.0.cmp(&a.0) } }\nimpl Sum for Field {\n fn sum(i: I) -> Self where I: Iterator {\n i.fold(Field(0), |a,b| a + b) } }\nimpl<'a> Sum<&'a Self> for Field {\n fn sum(i: I) -> Self where I: Iterator {\n i.fold(Field(0), |a,&b| a + b) } }\nimpl Product for Field {\n fn product(i: I) -> Self where I: Iterator {\n i.fold(Field(1), |a,b| a * b) } }\nimpl<'a> Product<&'a Self> for Field {\n fn product(i: I) -> Self where I: Iterator {\n i.fold(Field(1), |a,&b| a * b) }\n}\n//------------------- End Field\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n const MAX_N: usize = 104;\n const MAX_K: usize = 12;\n\n let id = |n1, n2, w, k| {\n ((n1 * MAX_N + n2) * 2 + w) * MAX_K + k\n };\n let mut dp = vec![Field::new_unchecked(0); MAX_N * MAX_N * 2 * MAX_K];\n\n l!(n1,n2,k1,k2 = input.u());\n let k = [k1, k2];\n dp[id(0,0,0,0)] = Field::new_unchecked(1);\n\n for i in 0..=n1 {\n for j in 0..=n2 {\n for w in 0..=1 {\n let wk = k[w];\n for l in 0..=wk {\n let val = dp[id(i, j, w, l)];\n if val.0 == 0 {\n continue;\n }\n for a in 0..=1 {\n let ii = i + 1 - a;\n let jj = j + a;\n let ll = if a == w {l + 1} else {1};\n dp[id(ii, jj, a, ll)] += val;\n }\n }\n }\n }\n }\n\n let mut sol = Field::new_unchecked(0);\n for w in 0..=1 {\n for l in 0..=k[w] {\n sol += dp[id(n1, n2, w, l)];\n }\n }\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "816ca731f310c11e531a7dbc8f999385", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "apr_id": "2a9b59eb8e1cabc75420858c183b7236", "difficulty": 1700, "tags": ["dp"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8904259191845649, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_source_code": "use std::io::*;\n\nfn main() {\n let days: &[usize] = &[\n 31,\n 28,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 28,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 29,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 28,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 30,\n 31,\n 30,\n 31,\n 31,\n 28,\n 31,\n 30,\n 31,\n ];\n let cin = stdin();\n let n = {\n let mut s = String::new();\n cin.lock().read_line(&mut s).unwrap();\n s.trim().parse::().unwrap()\n };\n\n let d: Vec = {\n let mut s = String::new();\n cin.lock().read_line(&mut s).unwrap();\n s.split_whitespace()\n .map(|s| s.parse::().unwrap())\n .take(n)\n .collect()\n };\n for i in 0..(days.len() - n) {\n if &days[i..i + n] == &d[..] {\n println!(\"Yes\");\n return;\n }\n }\n println!(\"No\");\n}\n", "lang": "Rust", "bug_code_uid": "889f72fee1fad724c055fa7c7de76f82", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "apr_id": "50e9f9222d369b7e7da60f68d562c175", "difficulty": 1200, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9983922829581994, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let mut first_input = String::new();\n std::io::stdin()\n .read_line(&mut first_input)\n .expect(\"Value not found\");\n\n let inputs: Vec = first_input\n .split_whitespace()\n .map(|s| s.parse()\n .expect(\"Value not found\"))\n .collect();\n\n let m: usize = inputs[0];\n let n: usize = inputs[1];\n\n if (n > m) || (m >16) || (n < 1) || (m < 1) {\n return()\n }\n let boxes = n * m;\n println!(\"{}\", boxes / 2);\n}", "lang": "Rust", "bug_code_uid": "8374db204daed2d060a8f573e50761db", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "apr_id": "8bac4c074a2933a220c2a49a3f56364e", "difficulty": 800, "tags": ["math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9972233240777469, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::str::FromStr;\nuse std::io::prelude::*;\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 (k, p): (usize, usize) = {\n let input = get_line();\n let mut it = input.split_whitespace()\n .map(|x| x.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let p = p as u64;\n\n let mul = |a, b| {\n (a * b) % p\n };\n\n let pow10 = |k| {\n let mut ret_val = 1;\n for _ in 0..k {\n ret_val = mul(ret_val, 10);\n }\n ret_val\n };\n\n let mut ans = 0;\n\n for i in (1..).take(k) {\n let s = format!(\"{}\", i);\n let n = s.len() as u64;\n for (ind, d) in s.bytes().rev().enumerate() {\n let d = ( d - b'0') as u64;\n let ind = ind as u64;\n ans = (ans + d * pow10(ind)) % p;\n ans = (ans + d * pow10(2 * n - 1 - ind)) % p;\n }\n }\n\n println!(\"{}\", ans);\n}\n\nstruct Solver {\n}\n\nimpl Solver {\n}\n", "lang": "Rust", "bug_code_uid": "dec29458b320c5da8518ae997ac7322c", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "apr_id": "8a5059c0718bf5b7af2b1a73f76330bb", "difficulty": 1300, "tags": ["brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9271047227926078, "equal_cnt": 12, "replace_cnt": 2, "delete_cnt": 5, "insert_cnt": 4, "fix_ops_cnt": 11, "bug_source_code": "use std::cmp::Ordering;\n\nfn main() {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let (n, k) = {\n let temp: Vec = buf\n .trim()\n .split_whitespace()\n .map(|a| a.parse().unwrap())\n .collect();\n (temp[0], temp[1])\n };\n\n let (mut index, mut jump) = (n / 2, n / 2);\n loop {\n let sum_n = index * (index + 1) / 2;\n let eaten = n - index;\n\n if eaten > sum_n {\n if jump == 0 {\n index = 1;\n break;\n }\n index += jump;\n jump /= 2;\n continue;\n }\n\n match k.cmp(&(sum_n - eaten)) {\n Ordering::Equal => break,\n Ordering::Greater => {\n jump /= 2;\n index += jump;\n }\n Ordering::Less => {\n jump /= 2;\n index -= jump;\n }\n }\n }\n\n println!(\"{}\", n - index);\n}", "lang": "Rust", "bug_code_uid": "0ecbdbf0f31965fd79091346d7d3e038", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "apr_id": "9b22597913fdf870ea615e46d66805c5", "difficulty": 1000, "tags": ["math", "brute force", "binary search"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.43948126801152737, "equal_cnt": 10, "replace_cnt": 3, "delete_cnt": 5, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "fn main() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let n : i32 = s.trim().parse().unwrap();\n s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let m : i32 = s.trim().parse().unwrap();\n if m == n {\n println!(\"YES\\n0\");\n } else {\n let l = ((m as f64).log(n as f64)) as i32;\n if ((n as f32).powi(l)) as i32 == m {\n println!(\"YES\\n{}\",l-1);\n } else {\n println!(\"NO\");\n }\n }\n\n }\n", "lang": "Rust", "bug_code_uid": "0009a1824dd8b449659af1105e2c23d1", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "apr_id": "dbf4b4aa5758b3fe98cf97333aeeb4dd", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9893238434163701, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn input_split() -> Vec {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect()\n}\n\nfn determine_b(v: &[u16]) -> Option {\n let sum: u16 = v.iter().sum();\n if sum % 5 == 0 {\n Some(sum / 5)\n } else {\n None\n }\n}\n\nfn print(res: Option) {\n match res {\n Some(val) => print!(\"{}\", val),\n None => print!(\"-1\"),\n }\n}\n\nfn main() {\n print(determine_b(&input_split()))\n}", "lang": "Rust", "bug_code_uid": "b2cb9a4cac17e84bc4a843d432b48d1d", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "apr_id": "eaec9af12f9fa64f7ea17cf75ca780df", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9959543949981611, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, std::io::stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut buffer = String::new();\n let mut input = WordReader::from_stdin(&mut buffer);\n\n let sum = (0..5).map(|_| input.i()).sum::();\n let sol = if sum % 5 == 0 {\n sum / 5\n } else {\n -1\n };\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "50eb6b3b00e279ac1d868a0e753068b2", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "apr_id": "d7c2dbe210dd758b49c5f43ce7a28ad4", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9957285239677266, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let a = readvec!(i32);\n let b = a.iter().fold(0,|x,y| x+y);\n println!(\"{}\",if b%a.len() as i32 == 0 { b/a.len() as i32 } else { -1 });\n}\n", "lang": "Rust", "bug_code_uid": "e6fa94460ae27792b149a037e49a6b2e", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "apr_id": "db93f677c5d38a9011aaeb60d97b8c37", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7949308755760369, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_source_code": "fn main() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let size = s.split_whitespace().map(|x| x.parse::().unwrap()).collect::>();\n let mut b = false;\n let mut c = -1;\n for i in 0..=100 {\n if size.iter().map(|x| x-i).sum::() == 0 {\n b = true;\n c = i;\n break;\n }\n }\n println!(\"{}\",c );\n}\n", "lang": "Rust", "bug_code_uid": "dc6963bdd5d3fa7895f305154df33750", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "apr_id": "43cc407bbaa2fee5a1b812c60586673a", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9959623149394348, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "// {{{ by shik\n\nuse std::io;\n\n#[allow(dead_code)]\nfn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\n#[allow(unused_macros)]\nmacro_rules! R {\n ( $ty:ty, ... ) => {\n gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap()).collect::>()\n };\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! W {\n ( $x:expr ) => {{\n println!(\"{}\", $x);\n }};\n ( $x:expr, $($xs:expr),* ) => {{\n print!(\"{} \", $x);\n W!($($xs),*);\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! join {\n ($x:expr, $($xs:expr),*; $sep:expr) => { concat!($x, $($sep, $xs),*) }\n}\n\n#[allow(unused_macros)]\nmacro_rules! dump {\n ($($x:expr),*) => {\n eprintln!(join!($(concat!(stringify!($x), \" = {:?}\")),*; \", \"), $($x),*);\n }\n}\n\n// }}}\n\nfn main() {\n let s: i32 = R!(i32, ...).into_iter().sum();\n println!(\"{}\", if s % 5 == 0 { s / 5 } else { -1 });\n}\n", "lang": "Rust", "bug_code_uid": "36d9a2b95b38555767354b2b04a5b98c", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "apr_id": "2bc34d72c7d1f0b5d99eb4db46d9eae5", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9945054945054945, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let bets: Vec = scan.next_n(5);\n let total: usize = bets.iter().sum();\n let (valid, result) = (total%5==0, total/5);\n if valid {\n println!(\"{}\", result);\n } else {\n println!(\"-1\");\n }\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "af7fe364cd04e7cb4d61ba16cf47de07", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "apr_id": "b53325d7a33c1d1403f96ecb4df220c9", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9704194260485651, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io::stdin;\nfn main() {\n let (mut h, m) = parse();\n let e = h;\n while reverse_number(h) > 59 || (reverse_number(h) <= m && h == e) {\n h += 1;\n }\n print_it(h, reverse_number(h));\n}\n\nfn parse() -> (usize, usize) {\n let mut entry = String::new();\n let mut hours = String::new();\n let mut minutes = String::new();\n let mut b = false;\n stdin().read_line(&mut entry).unwrap();\n\n for i in entry.trim().chars() {\n if i == ':' {\n b = true;\n } else if b {\n minutes.push(i);\n } else {\n hours.push(i);\n };\n }\n (hours.parse().unwrap(), minutes.parse().unwrap())\n}\n\nfn reverse_number(val: usize) -> usize {\n ((val % 10) * 10) + ((val - (val % 10)) / 10)\n}\n\nfn print_it(a: usize, b: usize) {\n let hours: String;\n let minutes: String;\n\n if a < 10 {\n hours = format!(\"0{}\", a);\n } else {\n hours = format!(\"{}\", a);\n };\n if b < 10 {\n minutes = format!(\"0{}\", b);\n } else {\n minutes = format!(\"{}\", b);\n };\n println!(\"{}:{}\", hours, minutes);\n}\n", "lang": "Rust", "bug_code_uid": "de9fc2cd0c90c1b1f0523f669d2c7158", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "apr_id": "0d6c6275c1f2e1aebfee45aa9dc6b2b3", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.996011964107677, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str;\n\nfn count_bits(n: u64) -> u64 {\n let mut n = n;\n let mut ans = 0;\n while n > 0 {\n ans += 1;\n n >>= 1;\n }\n ans\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: u64 = scan.token();\n let k: u64 = scan.token();\n // Maximize the xor-sum of at most k numbers from 1 to n\n // For any bit pattern that represents a positive number, its negation is always less than the number itself.\n // For example, n = 6 = 110 -> neg(n) = 001\n // n ^ neg(n) = 111\n // The answer is num_bits(n) ones, if k >= 2\n if k == 1 {\n writeln!(out, \"{}\", n).ok();\n }\n let num_bits = count_bits(n);\n let mut ans = 0u64;\n for i in 0..(num_bits) {\n ans = ans | (1 << i);\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n\n pub fn tokens(&mut self) -> Vec {\n assert!(self.buffer.is_empty());\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n input\n .split_whitespace()\n .map(|x| x.parse().ok().expect(\"Failed parse\"))\n .collect()\n }\n}\n", "lang": "Rust", "bug_code_uid": "3bb4a0e5ade9c22fb4fcae74c46095fb", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "apr_id": "2108364d0790b4ddd6f44889b3e1bfea", "difficulty": 1300, "tags": ["bitmasks", "constructive algorithms", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9379562043795621, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "fn dir(c: char) -> i32 {\n match c {\n 'v' => 0,\n '<' => 1,\n '^' => 2,\n '>' => 3,\n _ => panic!(\"Invalid character\"),\n }\n}\n\nfn main() {\n let mut input = String::new();\n\n std::io::stdin().read_line(&mut input).unwrap();\n\n let mut iter = input.chars();\n\n let start = iter.next().unwrap();\n iter.next().unwrap();\n let end = iter.next().unwrap();\n\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n\n let mut it = input.split_whitespace().map(|x| x.parse::().unwrap());\n\n let n = it.next().unwrap();\n\n if n % 2 == 0 {\n println!(\"undefined\");\n } else if n % 4 == (dir(end) - dir(start)) % 4 {\n println!(\"cw\");\n } else {\n println!(\"ccw\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "b1ecb6c3895f634fc36fe25154500688", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "apr_id": "3023123c3f25c39f9b749a4cf0cd6474", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6140065146579805, "equal_cnt": 10, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 9, "bug_source_code": "use std::io;\n\nfn main() {\n\tlet mut input = String::new();\n\tio::stdin().read_line(&mut input).unwrap();\n\t\n\tlet mut iter = input.split_whitespace();\n\tlet n: u16 = iter.next().unwrap().parse().unwrap();\n\tlet a: u16 = iter.next().unwrap().parse().unwrap();\n\tlet b: u16 = iter.next().unwrap().parse().unwrap();\n\n\tlet mut max: u16 = (a + b) / n;\n\tlet mut min: u16 = 1;\n\tlet mut prev: u16 = 1;\n\n\tloop {\n\t\tlet cur: u16 = (max - min) / 2 + min;\n\t\t\n\t\tif cur == prev {\n\t\t\tbreak;\n\t\t}\n\n\t\tif a / cur + b / cur >= n {\n\t\t\tmin = cur;\n\t\t} else {\n\t\t\tmax = cur;\n\t\t}\n\n\t\tprev = cur;\n\t}\n\n\tprintln!(\"{}\", prev);\n}\n", "lang": "Rust", "bug_code_uid": "973276ed58e82904d41717d63d51496a", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "apr_id": "166cd9f2b1470e896393f519bd8708e8", "difficulty": 1200, "tags": ["brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6213235294117647, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "fn read_line() -> String {\n let stdin = std::io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).unwrap();\n line.trim().into()\n}\n\nmacro_rules! scan_line {\n ($($ty: ty),*) => {{\n let line = read_line();\n let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$ty>().unwrap()),*)\n }}\n}\n\nfn main() {\n let (n, a, b) = scan_line!(i32, i32, i32);\n let mut l = 1;\n let mut r = n;\n while r - l > 1 {\n let m = l + (r - l) / 2;\n let ap = a / m;\n let bp = b / (n - m);\n if ap == bp {\n l = m;\n break;\n } else if ap < bp {\n r = m;\n } else {\n l = m;\n }\n }\n println!(\"{}\", std::cmp::min(a / l, b / (n - l)));\n}\n", "lang": "Rust", "bug_code_uid": "f1017ced42996901a406b4f110137f6e", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "apr_id": "d7ec910dfd9e40b93622b53f3143055d", "difficulty": 1200, "tags": ["brute force", "implementation", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9943217665615142, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn modpow(base: u64, expo: u64, modulo: u64) -> u64 {\n let mut ans = 1;\n let mut base = base;\n let mut expo = expo;\n while expo > 0 {\n if expo % 2 != 0 {\n ans *= base;\n }\n base = (base * base) % modulo;\n expo /= 2;\n }\n ans\n}\n\nfn is_primitive(x: u64, p: u64) -> bool {\n for i in 1..p - 1 {\n if modpow(x, i, p) == 1 {\n return false;\n }\n }\n modpow(x, p - 1, p) == 1\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let p: u64 = scan.token();\n let mut ans = 0;\n for x in 1..p {\n if is_primitive(x, p) {\n ans += 1;\n }\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "1e3e16b28d8b8363e5c17e0cb061b510", "src_uid": "3bed682b6813f1ddb54410218c233cff", "apr_id": "a4815b11e9816b80c891e9cbdac2f524", "difficulty": 1400, "tags": ["number theory", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9914129586260734, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let mut splits = input.split_whitespace();\n let _n = splits.next().unwrap().parse::().unwrap();\n let k = splits.next().unwrap().parse().unwrap();\n\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let a_k = input.split_whitespace().by_ref()\n .nth(k).unwrap().parse::().unwrap();\n let c = input.split_whitespace().by_ref()\n .map(|e| e.parse::().unwrap())\n .filter(|&elem| elem > 0 && elem >= a_k)\n .count();\n println!(\"{:?}\", c);\n}", "lang": "Rust", "bug_code_uid": "e83ae86d26034352fa83cefb90cd6e6c", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "026998510058457d715943f77228e4d8", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9969040247678018, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut fi = String::new();\n io::stdin().read_line(&mut fi).unwrap();\n\n let mut si = String::new();\n io::stdin().read_line(&mut si).unwrap();\n\n let mut nk = fi.trim().split(\" \");\n let _n = nk.next().unwrap().parse::().unwrap();\n let k = nk.next().unwrap().parse::().unwrap();\n\n\n let places = si.trim().split(\" \").into_iter().\n map(|d| d.parse::().unwrap()).collect::>();\n\n let low = places[k as usize];\n let accepted = places.iter().filter(|d| d > &&0 && d >= &&low).\n map(|d| d.clone()).collect::>();\n println!(\"{}\", accepted.len());\n}\n", "lang": "Rust", "bug_code_uid": "2e52c649181794147dae7b5ddbc9fa64", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "efbe9f6182140bfe3316e21b7800eaa1", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9161176987263944, "equal_cnt": 9, "replace_cnt": 5, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 8, "bug_source_code": "//use std::str::FromStr;\n\n\nuse std::str::FromStr;\n\n\n#[cfg(test)]\nmod tests {\n use crate::quest;\n\n #[test]\n fn test1() {\n assert_eq!(quest(2,2,1,1),2)\n }\n #[test]\n fn test2() {\n assert_eq!(quest(4,4,2,1),3)\n }\n #[test]\n fn test3() {\n assert_eq!(quest(6,10,4,2),6)\n }\n\n}\n\n#[inline]\npub fn input_in_two_var() -> (T, T)\nwhere T: Copy,\n{\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let numbers: Vec = line.split_whitespace().filter_map(\n |s| s.parse().ok()\n )\n .collect();\n (*numbers.get(0).unwrap(),*numbers.get(1).unwrap())\n}\n\n\n\n\n\nfn main() {\n let (_n,k) = input_in_two_var::();\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let numbers: Vec = line.split_whitespace().filter_map(\n |s| s.parse().ok()\n )\n .collect();\n let mut count: i64 = 0;\n let max: i64 = *numbers.get(k as usize).unwrap();\n if max >0 {\n for i in numbers {\n if i >= max {\n count += 1;\n }\n }\n }\n println!(\"{}\",count)\n}", "lang": "Rust", "bug_code_uid": "faaaf99f957478d7a6ffd22b849cb007", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "74c5c2aeb2124b9aad447d01c996bdc2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.24987506246876562, "equal_cnt": 23, "replace_cnt": 16, "delete_cnt": 1, "insert_cnt": 5, "fix_ops_cnt": 22, "bug_source_code": "macro_rules! input {\n ($var:ident) => {\n let mut $var = String::new();\n std::io::stdin().read_line(&mut $var).unwrap();\n };\n ($var:ident, $type: ty) => {\n let mut temp = String::new();\n #[allow(unused_mut)]\n let mut $var : $type;\n std::io::stdin().read_line(&mut temp).unwrap();\n $var = temp.trim().parse::<$type>().unwrap();\n };\n}\n\n#[allow(dead_code)]\nfn input(var: &mut String) {\n var.clear();\n std::io::stdin().read_line(var).unwrap();\n}\n\nfn main() {\n input!(problems, i32);\n let mut opinions = String::new();\n let mut decided_to_solve = 0;\n\n for _ in 0..problems {\n input(&mut opinions);\n let points: Vec<&str> = opinions.split(' ').collect();\n let sum: i32 = points.iter()\n .map( |c|\n c.trim().parse::().unwrap()\n )\n .sum();\n if sum > 1 {\n decided_to_solve += 1;\n }\n }\n\n println!(\"{}\", decided_to_solve);\n}\n", "lang": "Rust", "bug_code_uid": "28548b394880dc7c4ad40d4f0b3dc0ec", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "e99bc581fb69d46d64018c61034dc208", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9946018893387314, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let _vec = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n \n let _n = _vec[0];\n let _k = _vec[1] as usize;\n \n let mut b_str = String::new();\n io::stdin().read_line(&mut b_str).expect(\"READ ERROR\");\n let _vec2 = b_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error!\"))\n .collect::>();\n \n let score_last_hope = _vec2[_k];\n\n let mut count = 0;\n for num in &_vec2 {\n if (*num <= 0) {\n break;\n }\n if *num >= score_last_hope {\n count += 1;\n } else {\n break;\n }\n }\n\n println!(\"{}\", count);\n}", "lang": "Rust", "bug_code_uid": "3cbc0b18cabea48c07f03b4e2ef567a0", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "25519dd91b5a1f730d86866a25ce49db", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8156966490299824, "equal_cnt": 12, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 5, "fix_ops_cnt": 11, "bug_source_code": "use std::io::stdin;\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec,\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\n\nfn main() {\n let mut scan = Scanner::default();\n\n let n: u32 = scan.next();\n let k: usize = scan.next();\n\n let scores: Vec = (0..n).map(|_| scan.next()).collect();\n\n let mut index = scores.len();\n for (idx, score) in (&scores[k + 1..]).iter().enumerate() {\n if *score < scores[k] {\n index = idx + k + 1;\n break;\n }\n }\n\n println!(\"{:?}\", &scores[..index as usize].iter().filter(|score| **score != 0).count())\n}\n", "lang": "Rust", "bug_code_uid": "aa799d1611e1d7e20a7042694f5bfab9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "ef847f2916089373a29556aaa48e6e34", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9961340206185567, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nfn parse_array() -> Vec {\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n a_str\n .split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect()\n}\n\nfn main() {\n let (_, k) = parse_line!(usize, usize);\n let arr = parse_array();\n let x = arr[k];\n println!(\"{}\", arr.iter().take_while(|n| **n >= x && x > 0).count());\n}\n", "lang": "Rust", "bug_code_uid": "efd0496d9ce87702b80c7a29f8cd70e8", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "93d2b496976c1174bf043a630a4831b2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.995085995085995, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "fn read()->Vec{\n let mut line=String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace().map(|x|x.parse::().unwrap()).collect()\n}\nfn main(){\n let options=read();\n let n=options[0] as usize;\n let k=options[1] as usize;\n let vec=read();\n let mut d=0;\n for c in 0..n{\n if vec[c]>=vec[k] && vec[c]>0{d+=1}\n }\n println!(\"{}\",d);\n}", "lang": "Rust", "bug_code_uid": "7a6da366ed9b8fc8ae32c168c68775fa", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "f61ad961db4c27d8b3df00380f697306", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9982046678635548, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let k = (read_numbers())[1];\n\n let scores = read_numbers();\n let limit = scores[k];\n let mut count = 0;\n\n\n for score in scores {\n if score >= limit && score > 0 {\n count += 1;\n } else {\n break;\n }\n }\n\n println!(\"{}\", count);\n}\n\nfn read_numbers() -> std::vec::Vec {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).unwrap();\n\n buffer.trim().split_whitespace().map(|x| x.parse::().unwrap()).collect::>()\n}", "lang": "Rust", "bug_code_uid": "1ef451ceb42299894d34427fe69f32d4", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "399dbc4703f072f4d2f662bf721cfd4e", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6221161495624503, "equal_cnt": 18, "replace_cnt": 13, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 18, "bug_source_code": "use std::io; \n\nfn main (){\n let s1 = String::new(); \n io::stdin().read_line(&mut s1).expect(\"e\"); \n\n let mut v1 :Vec = s1.trim()\n .split(\" \")\n .map(|x|{x.parse::().expect(\"e\")})\n .collect(); \n\n let mut s2 = String::new(); \n io::stdin().read_line(&mut s2).expect(\"e\"); \n let mut v2 :Vec = s2.trim()\n .split(\" \")\n .map(|x|{x.parse::().expect(\"e\")})\n .filter(|x|{x>&v1[1]})\n .collect(); \n \n println!(\"{}\",v2.iter().count());\n \n}", "lang": "Rust", "bug_code_uid": "8face3a9654e7b8f6723fbc2e74affc3", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "c7181b00dbb6669aeae31b6ca4fa06e4", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9897330595482546, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "use std::io; \n\nfn main() {\n let mut s = String::new(); \n io::stdin().read_line(&mut s).expect(\"e\");\n\n let mut v : Vec = s.trim()\n .split(\" \")\n .map(|x| {x.parse::().expect(\"e\")})\n .collect();\n \n let mut s1 = String::new(); \n io::stdin().read_line(&mut s1).expect(\"e\");\n\n let mut v1 : Vec = s1.trim()\n .split(\" \")\n .map(|x| {x.parse::().expect(\"e\")})\n .collect();\n\n let mut res =0; \n if v1[0] == 0{\n println!(\"0\"); \n }else{ \n let mut k = v1[v[1]as usize]; \n\n for (ix,i) in v1.iter().enumerate() {\n if (k==*i){\n res = ix+1; \n }\n }\n println!(\"{}\",res); \n }\n }", "lang": "Rust", "bug_code_uid": "ab36409028194cf9b1ba02f83d97f852", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "c7181b00dbb6669aeae31b6ca4fa06e4", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9645856151880249, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut scan = Scanner::new(stdin.lock());\n\n let n = scan.token::();\n let k = scan.token::();\n\n let mut a: Vec = Vec::new();\n\n for _i in 0..n {\n let point = scan.token::();\n a.push(point);\n }\n\n let mut i: usize = 0;\n let mut needle: u8 = 0;\n\n loop {\n if a[i] < 1 {\n println!(\"{}\", i);\n break;\n } else {\n if needle > a[i] {\n println!(\"{}\", i);\n break;\n }\n if i == (k as usize - 1) {\n needle = a[i];\n }\n }\n i += 1;\n }\n}\n", "lang": "Rust", "bug_code_uid": "72577291e058ac8f60ad6bb9df9ebad6", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "d6306ae4e02330e919c3fb61fb26494e", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8619354838709677, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() -> std::io::Result<()> {\n let stdin = io::stdin();\n let mut parameters = String::new();\n let mut scores = String::new();\n stdin.read_line(&mut parameters)?;\n stdin.read_line(&mut scores)?;\n let pos = parameters.split(\" \").next().unwrap().parse::().unwrap();\n let scores =\n scores\n .split_ascii_whitespace()\n .map(|x| x.parse::().unwrap())\n .collect::>();\n\n print!(\"{}\", n_moves_on(scores, pos));\n Ok(())\n}\nfn n_moves_on(scores: Vec, pos: usize) -> usize {\n let nth_score = scores[pos];\n scores.iter().filter(|&&x| x >= nth_score && x > 0).count()\n}", "lang": "Rust", "bug_code_uid": "4d4a5eb4cfc1eb6fdb1619ec64c463ef", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "316573d9d5ce56e7f39319136a14abbd", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9971870604781997, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn input() -> String {\n let mut input = String::new();\n std::io::stdin()\n .read_line(&mut input)\n .ok()\n .expect(\"Read Error\");\n\n input.trim().to_string()\n}\n\nfn main() {\n let n_k = input().split_ascii_whitespace().map(|x| { x.parse::().unwrap_or(0) }).collect::>();\n let (_, k) = (n_k[0], n_k[1]);\n let mut scores = input().split_ascii_whitespace().map(|x| { x.parse::().unwrap_or(0) }).collect::>();\n scores.sort_by(|a, b| b.cmp(a));\n\n let mut participants = 0;\n for score in &scores {\n if score >= &scores[k] && score > &0 {\n participants += 1;\n } else { break; }\n }\n\n\n println!(\"{}\", participants);\n}\n", "lang": "Rust", "bug_code_uid": "7c35e2318a4cad9f07199d169fe0613d", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "b6e1d545ffacf32c36a487cfe10f9c92", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9976162097735399, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#[allow(dead_code)]\nfn read() -> T {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim().parse().ok().unwrap()\n}\n#[allow(dead_code)]\nfn read_vec() -> Vec {\n read::()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n#[allow(dead_code)]\nfn read_vec2(n: u32) -> Vec> {\n (0..n).map(|_| read_vec()).collect()\n}\n#[allow(dead_code)]\nfn yn(result: bool) {\n if result {\n println!(\"Yes\");\n } else {\n println!(\"No\");\n }\n}\n\nfn main() {\n let v = read_vec::();\n let _n = v[0];\n let k = v[1];\n\n let av = read_vec::();\n let ak = av[k];\n let ans = av.into_iter().filter(|&ai| ai > 0 && ai >= ak).count();\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "aae2137adcad9e062f213dc5391c338f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "7c70862898166c1e9fa6fe0f6f75fea8", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9988009592326139, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n \tlet mut input = String::new(); \n let stdin = io::stdin();\n \tstdin.read_line(&mut input).unwrap();\n \tlet n = input.trim().parse::().unwrap();\n\tlet mut v: Vec = Vec::new();\ninput.clear();\n \tstdin.read_line(&mut input)\n .expect(\"correct input\");\n\tfor u in input.trim().split(' ') {\n let cur_txt = u.trim();\n if cur_txt.len() > 0 {\n let cur_num: i32 = cur_txt.parse().unwrap();\n v.push(cur_num);\n }\n }\n if n == 1 {\n \tif v[0] == 15 {\n\t\t\tprintln!(\"DOWN\");\n\t\t} else if v[0] == 0 {\n\t\t\tprintln!(\"UP\");\n\t\t} else {\n\t\t\tprintln!(\"-1\");\n\t\t}\n } else {\n \tif v[n-1] == 15 {\n\t\t\tprintln!(\"DOWN\");\n\t\t} else if v[n-2] == 0 {\n\t\t\tprintln!(\"UP\");\n\t\t} else if v[n-2] > v[n-1] {\n\t\t\tprintln!(\"DOWN\");\n\t\t} else {\n\t\t\tprintln!(\"UP\");\n\t\t}\n }\n}", "lang": "Rust", "bug_code_uid": "fbf112ba846c52a207630ed4b24e6160", "src_uid": "8330d9fea8d50a79741507b878da0a75", "apr_id": "c5e1ab3a8a066119399ddfd58c481530", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9890652557319224, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let n: usize = scan.next();\n let arr: Vec = scan.next_n(n);\n if arr.len() == 1 {\n if arr[0] == 0 {\n println!(\"UP\");\n } else if arr[0] == 15 {\n println!(\"DOWN\");\n } else {\n println!(\"-1\");\n }\n return;\n }\n let last = arr[arr.len() - 1];\n let last2 = arr[arr.len() - 2];\n if last > last2 || last == 0 && last2 == 1 {\n println!(\"UP\");\n } else {\n println!(\"DOWN\");\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": "Rust", "bug_code_uid": "9d698b6ce9ed8b75c03c3bffbe3f6748", "src_uid": "8330d9fea8d50a79741507b878da0a75", "apr_id": "b7f51ee935059652380663b42dc21c6d", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8780487804878049, "equal_cnt": 9, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 5, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nfn main()\n{\n\tlet mut s = String::new();\n\tlet mut n = String::new();\n\tio::stdin().read_line(&mut n).unwrap();\n\tlet n = n.trim().parse::().unwrap();\n\tio::stdin().read_line(&mut s).unwrap();\n\ts = s.trim().to_string();\n\tlet val: Vec = s.split(\" \").map(|x: &str| x.parse::().unwrap()).collect();\n\n\tif n < 2 {\n\t\tprint!(\"{}\", -1);\n\t\treturn;\n\t}\n\tif let Ok(res) = match val[val.len()-1] {\n\t\t0 => Ok(\"UP\"),\n\t\t15 => Ok(\"DOWN\"),\n\t\t_ => match val[val.len()-1] - val[val.len()-2] {\n\t\t\t1 => Ok(\"UP\"),\n\t\t\t-1 => Ok(\"DOWN\"),\n\t\t\t_ => Err(\"invalid input\"),\n\t\t}\n\t} {\n\t\tprint!(\"{}\", res);\n\t}\n\telse {\n\t\tprint!(\"{}\", \"invalid input\");\n\t}\n\n}", "lang": "Rust", "bug_code_uid": "57e2127bb200f970fa08679176c7fbb0", "src_uid": "8330d9fea8d50a79741507b878da0a75", "apr_id": "762e1da63c35b3bdb96836376d606df0", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9818365287588294, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self, Read};\nuse std::cmp;\n \nfn main() {\n let mut buffer = String::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n handle.read_to_string(&mut buffer).unwrap();\n\n let arr : Vec<_> = buffer.split_whitespace().map(|x| x.parse::().unwrap() ).collect();\n let n = arr[0];\n let mut d = 0;\n let mut h = n;\n while h > 0 {\n d += 1;\n h = h / 10;\n }\n use std::cmp;\n let mut a = 0;\n 'outer: for i in 0..d {\n // println!(\"{}\",a);\n let mut r = 0;\n for j in 0..10 {\n let y = j * 10u64.pow(i);\n if a + y <= n {\n r = cmp::max(a + y, r);\n // println!(\"{}\",r);\n }\n a = r;\n }\n }\n let mut b = n - a;\n // println!(\"{} {}\", a, b);\n let mut ans = 0;\n while a > 0 {\n ans += a % 10;\n a = a / 10;\n }\n while b > 0 {\n ans += b % 10;\n b = b / 10;\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "f31c25a4208c9640dfbad0705c8b591a", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "apr_id": "89b5a58632cf5ca43b34a38cdbb3e715", "difficulty": 1100, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9183246073298429, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io::{stdin, stdout, BufWriter, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec,\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n\n let info: Vec = (0..2).map(|_| scan.next()).collect();\n let mut cost = 0;\n let mut tank = 0;\n\n for i in 0..info[0] - 1 {\n if tank < (info[0] - 1 - i) {\n cost += (info[1] - tank) * (i + 1);\n tank = info[1];\n }\n tank -= 1;\n }\n\n println!(\"{}\", cost);\n}\n", "lang": "Rust", "bug_code_uid": "49ced4f4156e9f32113e7f9730884d34", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "apr_id": "ec610a82536eb3b61253ce3d1827a289", "difficulty": 900, "tags": ["dp", "math", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9954699886749717, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::{Write, BufWriter};\n// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n let mut next = || { iter.next().unwrap() };\n input_inner!{next, $($r)*}\n };\n ($($r:tt)*) => {\n let stdin = std::io::stdin();\n let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));\n let mut next = move || -> String{\n bytes\n .by_ref()\n .map(|r|r.unwrap() as char)\n .skip_while(|c|c.is_whitespace())\n .take_while(|c|!c.is_whitespace())\n .collect()\n };\n input_inner!{next, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($next:expr) => {};\n ($next:expr, ) => {};\n\n ($next:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($next, $t);\n input_inner!{$next $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($next:expr, ( $($t:tt),* )) => {\n ( $(read_value!($next, $t)),* )\n };\n\n ($next:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($next, $t)).collect::>()\n };\n\n ($next:expr, chars) => {\n read_value!($next, String).chars().collect::>()\n };\n\n ($next:expr, usize1) => {\n read_value!($next, usize) - 1\n };\n\n ($next:expr, $t:ty) => {\n $next().parse::<$t>().expect(\"Parse error\")\n };\n}\n\nconst LINF: i64 = 1 << 58;\n\nfn solve() {\n let out = std::io::stdout();\n let mut out = BufWriter::new(out.lock());\n macro_rules! puts {\n ($format:expr) => (write!(out,$format).unwrap());\n ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())\n }\n input!{\n n: usize,\n a: [[i32; n]; n],\n }\n let ni = n as i32;\n let mut pos = vec![0; n * n];\n for i in 0 .. n {\n for j in 0 .. n {\n pos[a[i][j] as usize - 1] = i * n + j;\n }\n }\n let mut kn = vec![vec![LINF >> 32; n * n]; n * n];\n let mut rk = vec![vec![LINF >> 32; n * n]; n * n];\n let mut bs = vec![vec![LINF >> 32; n * n]; n * n];\n for i in 0 .. n {\n for j in 0 .. n {\n for &(dx, dy)\n in &[(-2, -1), (-2, 1), (2, -1), (2, 1),\n (1, 2), (-1, 2), (1, -2), (-1, -2)] {\n let nx = i as i32 + dx;\n let ny = j as i32 + dy;\n if nx < 0 || nx >= ni || ny < 0 || ny >= ni { continue; }\n let v = (nx * ni + ny) as usize;\n kn[i * n + j][v] = 1;\n }\n for dx in -ni .. ni {\n let dy = dx;\n let nx = i as i32 + dx;\n let ny = j as i32 + dy;\n if nx < 0 || nx >= ni || ny < 0 || ny >= ni { continue; }\n let v = (nx * ni + ny) as usize;\n bs[i * n + j][v] = 1;\n let dy = -dx;\n let nx = i as i32 + dx;\n let ny = j as i32 + dy;\n if nx < 0 || nx >= ni || ny < 0 || ny >= ni { continue; }\n let v = (nx * ni + ny) as usize;\n bs[i * n + j][v] = 1;\n }\n for u in 0 .. n {\n rk[i * n + j][u * n + j] = 1;\n rk[i * n + j][i * n + u] = 1;\n }\n kn[i * n + j][i * n + j] = 0;\n rk[i * n + j][i * n + j] = 0;\n bs[i * n + j][i * n + j] = 0;\n }\n }\n let mut dist = vec![vec![LINF; 3 * n * n]; 3 * n * n];\n for i in 0 .. n * n {\n for j in 0 .. n * n {\n dist[i][j] = kn[i][j] << 32;\n dist[n * n + i][n * n + j] = rk[i][j] << 32;\n dist[2 * n * n + i][2 * n * n + j] = bs[i][j] << 32;\n }\n for j in 0 .. 3 {\n for k in 0 .. 3 {\n if j != k {\n dist[j * n * n + i][k * n * n + i] = 1 << 32 | 1;\n }\n }\n }\n }\n for k in 0 .. 3 * n * n {\n for i in 0 .. 3 * n * n {\n for j in 0 .. 3 * n * n {\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);\n }\n }\n }\n // eprintln!(\"dist = {:?}\", dist);\n let mut dp = vec![[LINF; 3]; n * n];\n dp[0] = [0; 3];\n for i in 0 .. n * n - 1 {\n let src = pos[i];\n let dst = pos[i + 1];\n for j in 0 .. 3 {\n for k in 0 .. 3 {\n let cost: i64 = dist[j * n * n + src][k * n * n + dst];\n //eprintln!(\"{} -> {}\", j * n * n + src, k * n * n + dst);\n //eprintln!(\"src = {}, dst = {}, cost = {}\", src, dst, cost);\n dp[i + 1][k] = min(dp[i + 1][k], cost + dp[i][j]);\n }\n }\n //eprintln!(\"dp[{}] = {:?}\", i + 1, dp[i + 1]);\n }\n let mut mi = LINF;\n for i in 0 .. 3 { mi = min(mi, dp[n * n - 1][i]); }\n puts!(\"{} {}\\n\", mi >> 32, mi as i32);\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": "Rust", "bug_code_uid": "799ee59fd03b0eb92dde21a6db574332", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "apr_id": "d99de3bc948c8f1fc269feb8c1e20a61", "difficulty": 2200, "tags": ["dp", "dfs and similar", "shortest paths"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9871705155120131, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{self, BufRead}; // (a)\nuse std::cmp::{max, min};\n\nmacro_rules! numsin {\n () => (\n io::stdin().lock() // (0)\n .lines().next().unwrap().unwrap() // (1)\n .split(' ').map(|s| s.trim()) // (2)\n .filter(|s| !s.is_empty()) // (3)\n .map(|s| s.parse().unwrap()) // (4)\n .collect()\n )\n}\n\nfn main() {\n let nk: Vec = numsin!();\n let mut s = String::new();\n let mut t = String::new();\n io::stdin().read_line(&mut s).expect(\"\");\n io::stdin().read_line(&mut t).expect(\"\");\n let s = s.as_bytes();\n let t = t.as_bytes();\n if t[0] == t[1] {\n let mut tc: i32 = 0;\n for i in 0..nk[0] {\n if s[i] == t[0] {\n tc += 1;\n }\n }\n if (tc as usize) + nk[1] >= nk[0] {\n tc = nk[0] as i32;\n }\n else {\n tc += nk[1] as i32;\n }\n println!(\"{}\", tc * (tc - 1) / 2);\n return;\n }\n let mut dp = vec![vec![vec![-200000i32;nk[0]+1];nk[1] + 1];nk[0] + 1];\n dp[0][0][0] = 0;\n for i in 0..nk[0] {\n for j in 0..nk[1] {\n for k in 0..nk[0] {\n if s[i] == t[1] {\n dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k] + (k as i32));\n dp[i+1][j+1][k+1] = max(dp[i+1][j+1][k+1], dp[i][j][k]);\n }\n else if s[i] == t[0] {\n dp[i+1][j][k+1] = max(dp[i+1][j][k+1], dp[i][j][k]);\n dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i][j][k] + (k as i32));\n }\n else {\n dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);\n dp[i+1][j+1][k+1] = max(dp[i+1][j+1][k+1], dp[i][j][k]);\n dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i][j][k] + (k as i32));\n }\n }\n }\n }\n let mut ans: i32 = -1;\n for j in 0..nk[1]+1 {\n for k in 0..nk[0]+1 {\n ans = max(dp[nk[0]][j][k], ans);\n }\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "8d96b7ad69903de094453625dedaae19", "src_uid": "9c700390ac13942cbde7c3428965b18a", "apr_id": "cefd4e587040178fd3f816b018027ae3", "difficulty": 2100, "tags": ["dp", "strings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9978478288390935, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}\nmacro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}\nmacro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect (\"Parse error\" ) } ;}\ntrait Monoid {\n fn id() -> Self;\n fn f(a: Self, b: Self) -> Self;\n}\n#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]\nenum MaxInt {\n Minimal,\n Val(i64),\n}\nimpl std::ops::Mul for MaxInt {\n type Output = Self;\n fn mul(self, other: Self) -> Self {\n if self > other {\n self\n } else {\n other\n }\n }\n}\nimpl MaxInt {\n fn unwrap(self) -> i64 {\n if let Self::Val(x) = self {\n x\n } else {\n panic!();\n }\n }\n fn map(self, f: F) -> Self\n where\n F: Fn(i64) -> i64,\n {\n if let Self::Val(x) = self {\n Self::Val(f(x))\n } else {\n Self::Minimal\n }\n }\n}\nimpl Monoid for MaxInt {\n fn id() -> Self {\n MaxInt::Minimal\n }\n fn f(a: Self, b: Self) -> Self {\n a * b\n }\n}\nuse MaxInt::*;\n\nfn main() {\n input! {\n n: usize,\n k: usize,\n s: String,\n t: String,\n }\n let s = s.chars().map(|c| c as u8).collect::>();\n let t = t.chars().map(|c| c as u8).collect::>();\n if t[0] == t[1] {\n let mut ans = 0;\n let mut c = 0;\n let mut k = k;\n for i in 0..n {\n if k != 0 && s[i] != t[0] {\n ans += c;\n c += 1;\n k -= 1;\n }\n if s[i] == t[0] {\n ans += c;\n c += 1;\n }\n }\n println!(\"{}\", ans);\n return;\n }\n if k == 0 {\n let mut ans = 0;\n let mut c = 0;\n for i in 0..n {\n if s[i] == t[0] {\n c += 1;\n }\n if s[i] == t[1] {\n ans += c;\n }\n }\n println!(\"{}\", ans);\n return;\n }\n\n let mut dp = vec![vec![vec![Minimal; n + 1]; k + 1]; n + 1];\n dp[0][0][0] = Val(0);\n for i in 0..n {\n for k in 0..k {\n for c in 0..=i {\n if s[i] == t[0] {\n dp[i + 1][k][c + 1] = dp[i + 1][k][c + 1] * dp[i][k][c];\n } else {\n dp[i + 1][k + 1][c + 1] = dp[i + 1][k + 1][c + 1] * dp[i][k][c];\n }\n if s[i] == t[1] {\n dp[i + 1][k][c] = dp[i + 1][k][c] * dp[i][k][c].map(|v| v + c as i64);\n } else {\n dp[i + 1][k + 1][c] = dp[i + 1][k + 1][c] * dp[i][k][c].map(|v| v + c as i64);\n }\n if s[i] != t[0] && s[i] != t[1] {\n dp[i + 1][k][c] = dp[i + 1][k][c] * dp[i][k][c];\n }\n }\n }\n }\n let mut ans = Minimal;\n for k in 0..=k {\n for c in 0..=n {\n ans = ans * dp[n][k][c];\n }\n }\n println!(\"{}\", ans.unwrap());\n}\n", "lang": "Rust", "bug_code_uid": "c2a62b0d232e808272f5f92542012b25", "src_uid": "9c700390ac13942cbde7c3428965b18a", "apr_id": "d56a1218dd0906e5fbc35d9984651bdc", "difficulty": 2100, "tags": ["dp", "strings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9619022595901209, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}\nmacro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}\nmacro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect (\"Parse error\" ) } ;}\ntrait Monoid {\n fn id() -> Self;\n fn f(a: Self, b: Self) -> Self;\n}\n#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]\nenum MaxInt {\n Minimal,\n Val(i64),\n}\nimpl std::ops::Mul for MaxInt {\n type Output = Self;\n fn mul(self, other: Self) -> Self {\n if self > other {\n self\n } else {\n other\n }\n }\n}\nimpl MaxInt {\n fn unwrap(self) -> i64 {\n if let Self::Val(x) = self {\n x\n } else {\n panic!();\n }\n }\n fn map(self, f: F) -> Self\n where\n F: Fn(i64) -> i64,\n {\n if let Self::Val(x) = self {\n Self::Val(f(x))\n } else {\n Self::Minimal\n }\n }\n}\nimpl Monoid for MaxInt {\n fn id() -> Self {\n MaxInt::Minimal\n }\n fn f(a: Self, b: Self) -> Self {\n a * b\n }\n}\nuse MaxInt::*;\n\nfn main() {\n input! {\n n: usize,\n k: usize,\n s: String,\n t: String,\n }\n let s = s.chars().map(|c| c as u8).collect::>();\n let t = t.chars().map(|c| c as u8).collect::>();\n if t[0] == t[1] {\n let mut ans = 0;\n let mut c = 0;\n let mut k = k;\n for i in 0..n {\n if k != 0 && s[i] != t[0] {\n ans += c;\n c += 1;\n k -= 1;\n }\n if s[i] == t[0] {\n ans += c;\n c += 1;\n }\n }\n println!(\"{}\", ans);\n return;\n }\n\n let mut dp = vec![vec![vec![Minimal; n + 1]; k + 2]; n + 1];\n dp[0][0][0] = Val(0);\n for i in 0..n {\n for k in 0..k {\n for c in 0..=i {\n if s[i] == t[0] {\n dp[i + 1][k][c + 1] = dp[i + 1][k][c + 1] * dp[i][k][c];\n } else {\n dp[i + 1][k + 1][c + 1] = dp[i + 1][k + 1][c + 1] * dp[i][k][c];\n }\n if s[i] == t[1] {\n dp[i + 1][k][c] = dp[i + 1][k][c] * dp[i][k][c].map(|v| v + c as i64);\n } else {\n dp[i + 1][k + 1][c] = dp[i + 1][k + 1][c] * dp[i][k][c].map(|v| v + c as i64);\n }\n if s[i] != t[0] && s[i] != t[1] {\n dp[i + 1][k][c] = dp[i + 1][k][c] * dp[i][k][c];\n }\n }\n }\n }\n let mut ans = Minimal;\n for k in 0..=k {\n for c in 0..=n {\n ans = ans * dp[n][k][c];\n }\n }\n println!(\"{}\", ans.unwrap());\n}\n", "lang": "Rust", "bug_code_uid": "5d48cf83c708dda922869a872e600639", "src_uid": "9c700390ac13942cbde7c3428965b18a", "apr_id": "d56a1218dd0906e5fbc35d9984651bdc", "difficulty": 2100, "tags": ["dp", "strings"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9978137297770004, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 4, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_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 x: String= v_b.iter().map(|y| y.to_string()).collect();\n let n_b: i64 = x.parse().unwrap();\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.clone();\n t.swap(i, j);\n let x: String= t.iter().map(|y| y.to_string()).collect();\n let n_t: i64 = x.parse().unwrap();\n let x: String= v_a.iter().map(|y| y.to_string()).collect();\n let n_a: i64 = x.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": "Rust", "bug_code_uid": "745c1111ff1d7cba27a4eced2d7a44e6", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "apr_id": "867dfcb9e380a8e978dfccd66ac586d9", "difficulty": 1700, "tags": ["dp", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.7060478199718706, "equal_cnt": 15, "replace_cnt": 8, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 14, "bug_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": "Rust", "bug_code_uid": "d3ad78f39e406c550be3eb91c17e5740", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "apr_id": "867dfcb9e380a8e978dfccd66ac586d9", "difficulty": 1700, "tags": ["dp", "greedy"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.2698191933240612, "equal_cnt": 25, "replace_cnt": 17, "delete_cnt": 4, "insert_cnt": 4, "fix_ops_cnt": 25, "bug_source_code": "type Pair = (u32, u32);\nfn input_pair() -> Pair {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let buf: Vec = buf\n .trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect();\n (buf[0], buf[1])\n}\n\ntype Trio = (u32, u32, u32);\nfn input_trio() -> Trio {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let buf: Vec = buf\n .trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect();\n (buf[0], buf[1], buf[2])\n}\n\nfn main() {\n let (y_chr, b_chr) = input_pair();\n let (y, g, b) = input_trio();\n\n let mut req_chr = 0;\n req_chr += (2 * y + g).max(y_chr) - y_chr;\n req_chr += (3 * b + g).max(b_chr) - b_chr;\n println!(\"{}\", req_chr);\n}", "lang": "Rust", "bug_code_uid": "3203d173ddc8865887f9786771147f49", "src_uid": "35202a4601a03d25e18dda1539c5beba", "apr_id": "12e5bdb8aeca706c98acecd2077ede6b", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9718969555035128, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nconst BALLS_SIZE: usize = 3;\nconst CRYST_SIZE: usize = 2;\n\nenum ColorsB{\n Yell,\n Green,\n Blue\n}\n\ntype CrystalsArray = [i64; CRYST_SIZE];\ntype BallsArray = [i64; BALLS_SIZE];\n\nfn count_crystals(balls :BallsArray) -> CrystalsArray{\n fn count_yellow(num: i64 ) -> CrystalsArray {\n [2*num, 0]\n }\n fn count_green(num: i64 ) -> CrystalsArray {\n [num, num]\n }\n fn count_blue(num: i64 ) -> CrystalsArray {\n [0,3*num]\n }\n println!(\"\");\n let mut res: CrystalsArray = [0; CRYST_SIZE];\n for (ind,i) in count_yellow(balls[ColorsB::Yell as usize]).iter().enumerate(){\n res[ind] += *i;\n }\n for (ind,i) in count_green(balls[ColorsB::Green as usize]).iter().enumerate(){\n res[ind] += *i;\n }\n\n for (ind,i) in count_blue(balls[ColorsB::Blue as usize]).iter().enumerate(){\n res[ind] += *i;\n }\n return res ;\n}\n\nfn main() {\n let mut input: String = String::new();\n io::stdin().read_line(&mut input).expect(\"some error\");\n let mut cryst_inp: CrystalsArray = [0; CRYST_SIZE];\n let mut balls_inp: BallsArray = [0; BALLS_SIZE];\n for (ind,i) in input.trim().split(char::is_whitespace).enumerate(){\n cryst_inp[ind] = i.trim().parse().expect(\"failed to parse\");\n }\n input.clear();\n io::stdin().read_line(&mut input).expect(\"some error\");\n for (ind,i) in input.trim().split(char::is_whitespace).enumerate(){\n balls_inp[ind] = i.trim().parse().expect(\"failed to parse\");\n }\n let have_to = count_crystals(balls_inp);\n let mut sum = 0;\n for (ind,i) in cryst_inp.iter().enumerate(){\n sum += have_to[ind] - i;\n }\n print!(\"{}\", sum);\n}", "lang": "Rust", "bug_code_uid": "18255b0629a906c711226e7f88afa238", "src_uid": "35202a4601a03d25e18dda1539c5beba", "apr_id": "615f9547ecc2c23ca065b3b5bd1a9936", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.991595051468505, "equal_cnt": 14, "replace_cnt": 13, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 13, "bug_source_code": "// https://codeforces.com/contest/1293/problem/D\n//\n#![allow(unused_imports)]\nuse std::io::*;\nuse std::io::Write;\nuse std::fmt::*;\nuse std::str::*;\nuse std::cmp::*;\nuse std::collections::*;\n\n// Input macros.\n// Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\n#[allow(unused_macros)]\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\n#[allow(unused_macros)]\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, [ next / $t:tt ]) => {\n {\n let len = read_value!($iter, usize);\n (0..len).map(|_| read_value!($iter, $t)).collect::>()\n }\n };\n\n ($iter:expr, switch) => {\n {\n let ty = read_value!($iter, i32);\n if ty == 1 {\n vec![ty, read_value!($iter, i32), read_value!($iter, i32)]\n } else if ty == 2 {\n vec![ty, read_value!($iter, i32)]\n } else {\n vec![ty, read_value!($iter, i32)]\n }\n }\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_line {\n ($t:tt) => {\n {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n s.trim_right().parse::<$t>().unwrap()\n }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! dvec {\n ($t:expr ; $len:expr) => {\n vec![$t; $len]\n };\n\n ($t:expr ; $len:expr, $($rest:expr),*) => {\n vec![dvec!($t; $($rest),*); $len]\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! ifv {\n ($t:expr, $a:expr, $b: expr) => {\n if $t { $a } else { $b }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! fill {\n ($t:expr, $v:expr) => {\n for i in 0..$t.len() {\n $t[i] = $v;\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! join {\n ($t:expr, $glue:expr) => {\n $t.into_iter().map(|w| w.to_string()).collect::>().join($glue)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\n// ===\n\nconst MAX_CORD: i64 = 1e18 as i64;\n\nfn solve(mut limit: i64, start: usize, p1: usize, p2: usize, p3: usize, cost: &Vec>) -> i64 {\n if limit < 0 {\n return -10000;\n }\n let mut count = 1;\n let mut now = start;\n while now != p1 {\n let t = ifv!(now < p1, now+1, now-1);\n if limit < cost[now][t] {\n return count;\n }\n count += 1;\n limit -= cost[now][t];\n now = t;\n }\n assert_eq!(now, p1);\n assert_ne!(now, p2);\n if limit < cost[now][p2] {\n return count;\n }\n limit -= cost[now][p2];\n count += 1;\n now = p2;\n\n while now != p3 {\n let t = ifv!(now < p3, now+1, now-1);\n if limit < cost[now][t] {\n return count;\n }\n count += 1;\n limit -= cost[now][t];\n now = t;\n }\n count\n}\n\nfn main() {\n input! {\n x0: i64, y0: i64, ax: i64, ay: i64, bx: i64, by: i64,\n sx: i64, sy: i64, limit: i64\n };\n\n let mut points = vec![(x0, y0)];\n loop {\n let (lx, ly) = *points.last().unwrap();\n if lx > MAX_CORD || ly > MAX_CORD {\n break;\n }\n points.push((lx*ax+bx, ly*ay+by));\n }\n let n = points.len();\n\n let mut first_cost = vec![];\n for i in 0..n {\n first_cost.push((sx-points[i].0).abs() + (sy-points[i].1).abs());\n }\n let mut pp_cost = dvec!(0; n, n);\n for i in 0..n {\n for j in 0..n {\n pp_cost[i][j] = (points[i].0-points[j].0).abs() + (points[i].1-points[j].1).abs();\n }\n }\n\n // debug!(points);\n // debug!(first_cost);\n\n assert!(n >= 2);\n\n let mut best = 0;\n for s in 0..n {\n if s < n-1 {\n for l in 0..=s {\n best = max(best, solve(limit - first_cost[s], s, l, s+1, n-1, &pp_cost));\n }\n }\n if s >= 1 {\n for l in s..n {\n best = max(best, solve(limit - first_cost[s], s, l, s-1, 0, &pp_cost));\n }\n }\n }\n\n println!(\"{}\", best);\n}\n", "lang": "Rust", "bug_code_uid": "1e4424607040e66ae2ab94ed3d3ad852", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "apr_id": "c21bd20a3c424d7376edbbf6196c0727", "difficulty": 1700, "tags": ["brute force", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9329758713136729, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let v: Vec = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line);\n line.trim().split(\" \").map(|s| s.parse::().unwrap()).collect()\n };\n\n let (first, total, n) = (v[0], v[1], v[2]);\n println!(\"{:?}\",\n (0..n).fold(0, |total, i| total + first * (i + 1)) - total);\n}\n", "lang": "Rust", "bug_code_uid": "9e4fa05769a3c82fd9dad5cabf63dbe7", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "ae033324f73ab7d347797e960739a0ca", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.936005171299289, "equal_cnt": 7, "replace_cnt": 2, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 7, "bug_source_code": "/*\n Brute force - http://codeforces.com/problemset/problem/271/A\n Completed: 2/7/20 16:30\n*/\n\nuse std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input);\n\n let vector: Vec<&str> = input.trim().split(\" \").collect();\n\n let bananas = &vector[2].parse::().unwrap();\n let dollars = &vector[1].parse::().unwrap();\n let initial_cost = &vector[0].parse::().unwrap();\n let mut current_banana = 0;\n let mut final_cost = 0;\n let mut borrow;\n\n for _ in 0..*bananas {\n current_banana += 1;\n final_cost += initial_cost * current_banana;\n }\n\n borrow = final_cost - *dollars;\n\n if borrow < 0 {\n borrow = -borrow;\n }\n\n println!(\"{}\", borrow);\n\n}", "lang": "Rust", "bug_code_uid": "4b602090c7d202b2eefd5a46a7fa799f", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "99ca6bd918baf99f16e84db6a04771ff", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9862068965517241, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let read_in = buf.split_whitespace().map(|c| c.trim().parse::().unwrap()).collect::>();\n let (k, n, w) = (read_in[0], read_in[1], read_in[2]);\n let cost = w * (w + 1) / 2 * k;\n let ret: usize;\n if cost >= n {\n ret = 0;\n } else {\n ret = n - cost;\n }\n println!(\"{}\", ret);\n}\n", "lang": "Rust", "bug_code_uid": "f7b0158a3980251143ebca181c221e52", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "9be921f8ec6006aa5626a79ed9bbaa6d", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9954853273137697, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n // (unit_price, money, count)\n let v: Vec<_> = buf\n .trim()\n .split_whitespace()\n .map(|x| x.parse::().unwrap())\n .collect();\n let total_price = (v[2] + 1) * v[2] / 2 * v[0];\n if v[1] >= total_price {\n println!(\"{}\", 0);\n } else {\n println!(\"{}\", total_price - v[1]);\n }\n}\n", "lang": "Rust", "bug_code_uid": "c80949e1c551745f3d5e5542d0b38ed4", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "d8b5b62c2a9423524649976bd5b78ac2", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9855072463768116, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "fn read()->Vec{\n let mut line=String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace().map(|x|x.parse::().unwrap()).collect()\n}\nfn main(){\n let a=read();\n let money=(2*a[0]+a[0]*(a[2]-1))/2*a[2];\n let owe=money-a[1];\n if owe>0{\n print!(\"{}\",owe)\n }\n else{print!(\"0\")}\n}", "lang": "Rust", "bug_code_uid": "6a0449b45a92d8b161fb96571d1acdbc", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "7fac259dec8adfa0abf165c9aa0059ec", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.921875, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn read() -> String{\n let mut input=String::new();\n io::stdin().read_line(&mut input).expect(\"unable to read\");\n input.trim().to_string()\n}\nfn main() {\n let inp=read();\n let list: Vec<_>=inp.split_whitespace().collect();\n let price=list[0].parse::().expect(\"Failed to parse\");\n let money=list[1].parse::().expect(\"Failed to parse\");\n let total=list[2].parse::().expect(\"Failed to parse\");\n let mut sum=0;\n for i in 1..total+1{\n sum+=price*i;\n }println!(\"{}\",sum-money);\n}\n", "lang": "Rust", "bug_code_uid": "0b039bf62c5021d56f5e62974e40d26a", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "32c189da90597ff564c855b42c05ea9c", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8586080586080586, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "use std::io::stdin;\nfn main() {\n let (banana_price, dolar_amount, banana_wanted) = parse_param();\n println!(\"{}\", fact_add(banana_wanted, banana_price) - dolar_amount)\n}\n\nfn parse_param() -> (usize, usize, usize) {\n let mut entry_text = String::new();\n stdin().read_line(&mut entry_text).expect(\"msg: &str\");\n let a: Vec<&str> = entry_text.trim().split_whitespace().collect();\n (\n a[0].parse().expect(\"\"),\n a[1].parse().expect(\"\"),\n a[2].parse().expect(\"\"),\n )\n}\nfn fact_add(x: usize, y: usize) -> usize {\n if x <= 1 {\n return y;\n }\n (x * y) + fact_add(x - 1, y)\n}\n", "lang": "Rust", "bug_code_uid": "cc565264661ee43b213ff061dfee4d78", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "0eb23dc104574466486fdd9bedf3afd7", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9635157545605307, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "fn read_int_line() -> Vec {\n // Read vector of integers\n let cin = std::io::stdin();\n let mut line = String::new();\n cin.read_line(&mut line).unwrap();\n let values: Vec = line\n .split_whitespace()\n .map(|x| x.parse::().unwrap())\n .collect();\n values\n}\n\n\nfn main() {\n\tlet values: Vec = read_int_line();\n\tlet k: i64 = values[0];\n\tlet n: i64 = values[1];\n\tlet w: i64 = values[2];\n\n\tlet sum: i64 = w * (w + 1) / 2 * k;\n\tlet ans: i64 = sum - n;\n\n\tprint!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "457c456c7cef24845190f9ab6b00cd4c", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "236f431927bc6c0ca5dc77e2ce7c7788", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6966292134831461, "equal_cnt": 8, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_source_code": "use std::io::{self, BufRead};\n\nfn main() {\n let stdin = io::stdin();\n let vector:Vec = stdin.lock().lines().next().unwrap().unwrap().trim().split(' ').map(|s| s.parse().unwrap()).collect();\n let mut sum = 0;\n for i in 1..(vector[2] + 1) {\n sum = sum + (i * vector[0]);\n }\n println!(\"{}\", sum - vector[1]);\n}", "lang": "Rust", "bug_code_uid": "340085ad2e3fa1221f1bd459a241e763", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "8af34b4b3e838104acba933a5758fe36", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9258861439312567, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "fn main(){\n let mut a = Vec::with_capacity(3);\n let mut val = String::new();\n std::io::stdin().read_line(&mut val).unwrap();\n let val = val.trim().parse::().unwrap();\n for j in val.split_whitespace(){\n let k = j.trim().parse::().unwrap();\n a.push(k);\n }\n let mut ans : i32 = 0;\n for p in 1..a[2]+1{\n ans += a[0]*p;\n }\n let last = ans - a[1];\n println!(\"{}\",last);\n}", "lang": "Rust", "bug_code_uid": "ba9ba4cca4a14d130229bd5282f97b30", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "577c9a6dec0227c63d48a7e581beda42", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9842931937172775, "equal_cnt": 8, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 7, "bug_source_code": "fn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_vec() -> Vec {\n read_str().trim()\n .split_whitespace()\n .map(|value| value\n .parse::()\n .expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n let mut total: u8 = 0;\n let (k, n, w): (u8, u8, u8) = {\n let values: Vec = read_vec();\n (values[0], values[1], values[2])\n };\n\n for index in 1..w + 1 {\n total += index * k;\n }\n\n if total >= n { total -= n; }\n else { total = 0; }\n\n println!(\"{}\", total);\n}", "lang": "Rust", "bug_code_uid": "a2768e422939597394ffe91075bf6e5d", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "2a34ea8151015c89aebef72858eab1e3", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.961139896373057, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::io::prelude::*;\n\n\nfn main(){\n let mut s= String::new();\n io::stdin().read_line(& mut s);\n\n let mut it= s.split_whitespace();\n let k= it.next().unwrap().parse::().unwrap();\n let n=it.next().unwrap().parse::().unwrap();\n let w=it.next().unwrap().parse::().unwrap();\n let r =(w*(w+1))/2 *k -n;\n print!(\"{}\",r);\n\n}", "lang": "Rust", "bug_code_uid": "bf2bfd6a674752968f9171f5933b1298", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "bd03c9ee72b4214cbc3df87bf468ff04", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9926108374384236, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::string;\nuse std::cmp::*;\n\nfn main() {\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"Failed to read line\");\n\n let vec: Vec<&str> = line.split(\" \").collect();\n let a: u64 = vec[0].trim().parse().unwrap();\n let b: u64 = vec[1].trim().parse().unwrap();\n let c: u64 = vec[2].trim().parse().unwrap();\n println!(\"{}\", max(0,a*(c+1)*c/2-b));\n}\n", "lang": "Rust", "bug_code_uid": "22d9da971e1051cbc12037318f941e0e", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "06b2ab74ad79d5e691ec9d42435ee44b", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9397849462365592, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n\tlet mut inp = String::new();\n\tio::stdin().read_line(&mut inp).unwrap();\n\tlet inp = inp.trim();\n\tlet k: i32 = inp.split_whitespace().nth(0).unwrap().parse().unwrap();\n\tlet n: i32 = inp.split_whitespace().nth(1).unwrap().parse().unwrap();\n\tlet w: i32 = inp.split_whitespace().nth(2).unwrap().parse().unwrap();\n\tlet mut all_money = 0;\n\tfor i in 1..(w+1) {\n\t\tall_money += i*k;\n\t}\n\tprintln!(\"{}\", all_money - n);\n}\n", "lang": "Rust", "bug_code_uid": "ba299638b5bd0470979b4cfec45a04c8", "src_uid": "e87d9798107734a885fd8263e1431347", "apr_id": "200f17549ca209403a2a45d4a7196d62", "difficulty": 800, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9909652876842606, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\nuse std::cmp::{\n min,\n max\n};\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let (nodes, edges) = readln!(i32, i32);\n\n let (min_isolated, max_isolated) = if edges == 0 {\n (nodes, nodes)\n } else {\n (\n if nodes % 2 == 0 {\n max(0, ((nodes + 1) / 2 - edges) * 2)\n } else {\n max(0, ((nodes + 1) / 2 - edges) * 2 - 1)\n },\n nodes - ((1.0 + (8.0 * edges as f64 + 1.0).sqrt()) / 2.0).ceil() as i32\n )\n };\n\n\n println!(\"{} {}\", min_isolated, max_isolated);\n}\n", "lang": "Rust", "bug_code_uid": "3bd8815f220e451c8b2f46cf85572107", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "apr_id": "0f7162d0540b713a1f8fda55cc7b768e", "difficulty": 1300, "tags": ["graphs", "constructive algorithms"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9980970504281637, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::cmp::{\n min,\n max\n};\n\nmacro_rules! readln {\n () => {{\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\nfn main() {\n let (nodes, edges) = readln!(i64, i64);\n\n let (min_isolated, max_isolated) = if edges == 0 {\n (nodes, nodes)\n } else {\n (\n if nodes % 2 == 0 {\n max(0, ((nodes + 1) / 2 - edges) * 2)\n } else {\n max(0, ((nodes + 1) / 2 - edges) * 2 - 1)\n },\n nodes - ((1.0 + (8.0 * edges as f64 + 1.0).sqrt()) / 2.0).ceil() as i32\n )\n };\n\n\n println!(\"{} {}\", min_isolated, max_isolated);\n}", "lang": "Rust", "bug_code_uid": "ee51068f3373f04de7fe188097059faa", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "apr_id": "0f7162d0540b713a1f8fda55cc7b768e", "difficulty": 1300, "tags": ["graphs", "constructive algorithms"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9953524399690162, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::cmp::max;\nuse std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: i64 = scan.token();\n let m: i64 = scan.token();\n if m == 0 {\n writeln!(out, \"{} {}\", 100, 100).ok();\n return;\n }\n let min_ans = max(n - 2 * m, 0);\n let k = ((1.0 + ((1 + 8 * m) as f64).sqrt()) / 2.0).ceil() as i64;\n let max_ans = n - k;\n writeln!(out, \"{} {}\", min_ans, max_ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "62c88d2841512024860c3e8f6e380adf", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "apr_id": "3f9befaf5c4d1562adab38ef6822f328", "difficulty": 1300, "tags": ["graphs", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9917771438160765, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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, Write};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\nmod util {\n use std::fmt::Debug;\n use std::io::{stdin, stdout, BufWriter, StdoutLock};\n use std::str::FromStr;\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 #[allow(dead_code)]\n pub fn chars() -> Vec {\n line().chars().collect()\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 #[allow(dead_code)]\n pub fn with_bufwriter) -> ()>(f: F) {\n let out = stdout();\n let writer = BufWriter::new(out.lock());\n f(writer)\n }\n}\n#[allow(unused_macros)]\nmacro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }\n#[allow(unused_macros)]\nmacro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , \" = {:?}, \" ) ,* ) , $ ( $ a ) ,* ) ; } }\nconst BIG_STACK_SIZE: bool = true;\n#[allow(dead_code)]\nfn main() {\n use std::thread;\n if BIG_STACK_SIZE {\n thread::Builder::new()\n .stack_size(32 * 1024 * 1024)\n .name(\"solve\".into())\n .spawn(solve)\n .unwrap()\n .join()\n .unwrap();\n } else {\n solve();\n }\n}\nfn solve() {\n let (n, m) = get!(i64, i64);\n\n let mini = max(0, n - 2 * m);\n let k = (1..).find(|&x| x * (x - 1) / 2 >= m).unwrap();\n\n println!(\"{} {}\", mini, n - k);\n}\n", "lang": "Rust", "bug_code_uid": "cfa944993f93b50f22b9f02d7682be46", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "apr_id": "cf7750fabb07b0b40733aca08e618b47", "difficulty": 1300, "tags": ["graphs", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9551656920077972, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "// Try Codeforces\n// author: Leonardone @ NEETSDKASU\n\nfn main() {\n let mut stdin = String::new();\n std::io::Read::read_to_string(\n &mut std::io::stdin(),\n &mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n ($t:ty) => (get().parse::<$t>().unwrap());\n () => (get!(i64));\n }\n \n let n = get!();\n let m = get!();\n \n if m == 0 {\n println!(\"{} {}\", n, n);\n return;\n }\n \n let min = std::cmp::max(0, (n + 1) / 2 - m);\n let mut max = 0;\n for i in 1..n+1 {\n let v = i * (i - 1) / 2;\n if v >= m {\n max = n - i;\n break;\n }\n }\n \n println!(\"{} {}\", min, max);\n}", "lang": "Rust", "bug_code_uid": "456ce02c858c07f01e23c64aa28cdae4", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "apr_id": "8c4e6a4f41c56167359be2cd3a1937fa", "difficulty": 1300, "tags": ["graphs", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9972640218878249, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "/// https://github.com/akiradeveloper/rust-comp-snippets\n\n#[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::iter::FromIterator;\n\n#[macro_export]\nmacro_rules! chmax {\n ($x:expr, $($v:expr),+) => {\n $(\n $x = std::cmp::max($x,$v);\n )+\n };\n}\n\n#[macro_export]\nmacro_rules! chmin {\n ($x:expr, $($v:expr),+) => {\n $(\n $x = std::cmp::min($x,$v);\n )+\n };\n}\n\n#[macro_export]\nmacro_rules! max {\n ($x:expr) => ( $x );\n ($x:expr, $($xs:expr),+) => {\n std::cmp::max($x, max!( $($xs),+ ))\n };\n}\n\n#[macro_export]\nmacro_rules! min {\n ($x:expr) => ( $x );\n ($x:expr, $($xs:expr),+) => {\n std::cmp::min($x, min!( $($xs),+ ))\n };\n}\n\n#[macro_export]\nmacro_rules! dvec {\n ($t:expr ; $len:expr) => {\n vec![$t; $len]\n };\n \n ($t:expr ; $len:expr, $($rest:expr),*) => {\n vec![dvec!($t; $($rest),*); $len]\n };\n}\n\n#[macro_export]\nmacro_rules! cfor {\n // for (; ...; ...) { ... }\n (; $($rest: tt)*) => {\n cfor!((); $($rest)*)\n };\n // for ($init; ; ...) { ... }\n ($($init: stmt),+; ; $($rest: tt)*) => {\n // avoid the `while true` lint\n cfor!($($init),+; !false; $($rest)*)\n };\n\n // for ($init; $cond; ) { ... }\n ($($init: stmt),+; $cond: expr; ; $body: block) => {\n cfor!{$($init),+; $cond; (); $body}\n };\n\n // for ($init; $cond; $step) { $body }\n ($($init: stmt),+; $cond: expr; $($step: expr),+; $body: block) => {\n {\n $($init;)+\n while $cond {\n let mut _first = true;\n let mut _continue = false;\n // this loop runs once, allowing us to use `break` and\n // `continue` as `goto` to skip forward to the\n // condition.\n //\n // the booleans above are very transparent to the\n // optimiser, since they are modified exactly once,\n // with nice control flow, and this this optimises to\n // be similar to C for loop.\n loop {\n // if we *don't* hit this, there was a `break` in\n // the body (otherwise the loop fell-through or\n // was `continue`d.)\n if !_first { _continue = true; break }\n _first = false;\n\n $body\n }\n if !_continue {\n // the `if` wasn't hit, so we should propagate the\n // `break`.\n break\n }\n\n $($step;)+\n }\n }\n };\n}\n\n/// main\n\n#[allow(unused_imports)]\nuse std::io::{stdin, stdout, BufWriter, Write};\n\n// ref: tanakh \n// diff: using Parser\n#[macro_export]\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut parser = Parser::from_str($s);\n input_inner!{parser, $($r)*}\n };\n (parser = $parser:ident, $($r:tt)*) => {\n input_inner!{$parser, $($r)*}\n };\n (new_stdin_parser = $parser:ident, $($r:tt)*) => {\n let stdin = std::io::stdin();\n let reader = std::io::BufReader::new(stdin.lock());\n let mut $parser = Parser::new(reader);\n input_inner!{$parser, $($r)*}\n };\n ($($r:tt)*) => {\n input!{new_stdin_parser = parser, $($r)*}\n };\n}\n\n#[macro_export]\nmacro_rules! input_inner {\n ($parser:ident) => {};\n ($parser:ident, ) => {};\n ($parser:ident, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($parser, $t);\n input_inner!{$parser $($r)*}\n };\n}\n\n#[macro_export]\nmacro_rules! read_value {\n ($parser:ident, ( $($t:tt),* )) => {\n ( $(read_value!($parser, $t)),* )\n };\n ($parser:ident, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($parser, $t)).collect::>()\n };\n ($parser:ident, chars) => {\n read_value!($parser, String).chars().collect::>()\n };\n ($parser:ident, usize1) => {\n read_value!($parser, usize) - 1\n };\n ($parser:ident, $t:ty) => {\n $parser.next::<$t>().expect(\"Parse error\")\n };\n}\n\nuse std::io::BufRead;\nuse std::io;\nuse std::str;\n\n// ref: tatsuya6502 \n// ref: wariuni \n// diff: using std::io::BufRead::fill_buf()\npub struct Parser {\n reader: R,\n buf: Vec,\n pos: usize,\n}\n\nimpl Parser {\n pub fn from_str(s: &str) -> Parser {\n Parser {\n reader: io::empty(),\n buf: s.as_bytes().to_vec(),\n pos: 0,\n }\n }\n}\n\nimpl Parser {\n pub fn new(reader: R) -> Parser {\n Parser {\n reader: reader,\n buf: vec![],\n pos: 0,\n }\n }\n pub fn update_buf(&mut self) {\n self.buf.clear();\n self.pos = 0;\n loop {\n let (len,complete) = {\n let buf2 = self.reader.fill_buf().unwrap();\n self.buf.extend_from_slice(buf2);\n let len = buf2.len();\n // diff: care when there is no empty space or line at the end\n if len == 0 {\n break;\n }\n (len, buf2[len-1] <= 0x20)\n };\n self.reader.consume(len);\n if complete {\n break;\n }\n }\n }\n pub fn next(&mut self) -> Result {\n loop {\n let mut begin = self.pos;\n while begin < self.buf.len() && (self.buf[begin] <= 0x20) {\n begin += 1;\n }\n let mut end = begin;\n while end < self.buf.len() && (self.buf[end] > 0x20) {\n end += 1;\n }\n if begin != self.buf.len() {\n self.pos = end;\n return str::from_utf8(&self.buf[begin..end]).unwrap().parse::();\n }\n else {\n self.update_buf();\n }\n }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , \" = {:?}, \" ) ,* ) , $ ( $ a ) ,* ) ; } }\n#[doc = \" https://github.com/hatoo/competitive-rust-snippets\"]\nconst BIG_STACK_SIZE: bool = true;\n#[allow(dead_code)]\nfn main() {\n use std::thread;\n if BIG_STACK_SIZE {\n thread::Builder::new()\n .stack_size(32 * 1024 * 1024)\n .name(\"solve\".into())\n .spawn(solve)\n .unwrap()\n .join()\n .unwrap();\n } else {\n solve();\n }\n}\n\nfn solve() {\n let out = stdout();\n let mut out = BufWriter::new(out.lock());\n input!{\n n:i64,m:i64,\n }\n let mi = max(0, n-2*m);\n let fullconn = n*(n-1)/2;\n let ma = if m >= fullconn {\n 0\n } else if m==0 {\n n\n } else {\n let mut i=1;\n loop {\n if i*(i-1)/2 >= m {\n break;\n }\n i += 1;\n }\n n-i\n };\n writeln!(out,\"{} {}\", mi,ma);\n}", "lang": "Rust", "bug_code_uid": "886414264c324f6968f4d43f8d6c6f92", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "apr_id": "6ecadd5e4710027ddc97f434ccf8ab9f", "difficulty": 1300, "tags": ["graphs", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9816882536846807, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "const MODULO: u64 = 1000000007;\n\nfn main() {\n let mut scan = Scanner::default();\n let n: u64 = scan.next();\n count_cyclic(n);\n}\n\nfn count_cyclic(n: u64) {\n let nb_perm = count_permutations(n);\n let nb_acyc = count_acyclic(n);\n println!(\"{} {}\", nb_perm, nb_acyc);\n println!(\"{}\", (nb_perm as i64 - nb_acyc as i64).rem_euclid(MODULO as i64));\n}\n\nfn count_permutations(n: u64) -> u64 {\n let mut fac = 1;\n for i in 1..=n {\n fac = (fac * i) % MODULO;\n }\n fac\n}\n\nfn count_acyclic(n: u64) -> u64 {\n let mut pred = 2;\n for _ in 3..=n {\n pred = (2 * pred) % MODULO;\n }\n pred\n}\n\n// TEMPLATE\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "ba41a12054d7d838be1ca6ada33f6c31", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "apr_id": "73bcb62225c0312e81096236a7f9b687", "difficulty": 1500, "tags": ["graphs", "dp", "math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9731993299832495, "equal_cnt": 7, "replace_cnt": 2, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let n: u32 = input.trim().parse().unwrap();\n let mut pow = 1u32;\n let p = 1000000007u32;\n for _i in 0..(n-1) {\n pow = (pow as u64 * 2u64 % p as u64) as u32;\n }\n //println!(\"{}\", pow);\n let mut fact = 1u32;\n for i in 2..(n+1) {\n fact = (fact as u64 * i as u64 % p as u64) as u32;\n }\n //println!(\"{}\", fact);\n let ans;\n if fact < pow {\n ans = pow + p - fact;\n } else {\n ans = fact - pow;\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "141836781da5fb4f7a024d989a6ef63d", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "apr_id": "7268bab772843a49d8b1ca6e212f6439", "difficulty": 1500, "tags": ["graphs", "dp", "math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9848181036952163, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "//! http://codeforces.com/contest/514/problem/A\n\n#[macro_export]\nmacro_rules! scanln {\n ($($var:ident : $ty:path),+) => {\n $(let $var: $ty;)+\n {\n use std::io;\n let mut __buf = String::new();\n io::stdin().read_line(&mut __buf).unwrap();\n let mut eles = __buf.split_whitespace();\n $($var = Scan::scan(&mut eles);)+\n }\n }\n}\n\npub trait Scan {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator;\n}\n\nmacro_rules! impl_scan_single {\n ($ty:ty) => {\n impl Scan for $ty {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n let next = eles.next().unwrap();\n match next.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }\n }\n }\n }\n}\n\nimpl_scan_single!(u8);\nimpl_scan_single!(u16);\nimpl_scan_single!(u32);\nimpl_scan_single!(u64);\nimpl_scan_single!(usize);\nimpl_scan_single!(i8);\nimpl_scan_single!(i16);\nimpl_scan_single!(i32);\nimpl_scan_single!(i64);\nimpl_scan_single!(f32);\nimpl_scan_single!(f64);\nimpl_scan_single!(isize);\nimpl_scan_single!(String);\n\nconst __IMPL_SCAN_FOR_VEC: () = {\n use std::str::FromStr;\n impl Scan for Vec where T: FromStr {\n fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator {\n eles.map(|str| match str.parse() {\n Ok(res) => res,\n Err(_) => panic!()\n }).collect()\n }\n }\n};\n\n// -----------------------------------------------------------------------------\n\nfn min_possible_invert(n: u64) -> u64 {\n if n == 0 { return 0; }\n let (top, bot) = (n / 10, n % 10);\n let inv = 9 - bot;\n min_possible_invert(top) * 10 + std::cmp::min(bot, inv)\n}\n\nfn main() {\n scanln!(x: u64);\n println!(\"{}\", min_possible_invert(x));\n}\n", "lang": "Rust", "bug_code_uid": "c1ac578d89e7de39926e7f17629d4c55", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "apr_id": "43519a17e10d7cbcbb40ac1c6eaa4700", "difficulty": 1200, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.959375, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n#[allow(unused_imports)]\nuse std::collections::{HashMap,HashSet,VecDeque};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let s = readln!();\n let z = s.chars().map(|c|min(c,((9u8 - (c as u8 - '0' as u8)) + ('0' as u8)) as char)).collect::().chars().skip_while(|&c|c=='0').collect::();\n println!(\"{}\",if z.is_empty() { \"9\" } else { z.as_ref() });\n}\n", "lang": "Rust", "bug_code_uid": "d49797a3198c161f0233c417a92fd31b", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "apr_id": "91d4fa62a4dd4aa36c4bce0a5e0573e6", "difficulty": 1200, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9846827133479212, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\n\nfn get_line() -> String {\n\tlet mut input = String::new();\n\n\tio::stdin().read_line(&mut input)\n\t\t.expect(\"\");\n\n\tString::from(input.trim())\n}\n\nfn main() {\n\tlet s = get_line();\n\n\tlet mut r = String::new();\n\tfor (i, c) in s.chars().enumerate() {\n\t\tlet d = c.to_digit(10).unwrap();\n\n\t\tif i == 0 && d < 9 || i != 0 && d >= 5 {\n\t\t\tr.push(std::char::from_digit((9-d) as u32, 10).unwrap());\n\t\t} else {\n\t\t\tr.push(c);\n\t\t}\n\t}\n\n\tprintln!(\"{}\", r);\n}", "lang": "Rust", "bug_code_uid": "f44cf4a83165d4c162138b44980cafe6", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "apr_id": "f9718d74c7cb68fc594d754c042f06d4", "difficulty": 1200, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9076012744651798, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let mut num: u64 = scan.next();\n if num == 9 {\n println!(\"9\");\n return;\n }\n let mut result: u64 = 0;\n let mut position: u64 = 1;\n while num > 0 {\n let dig = num%10;\n result += dig.min(9-dig)*position;\n position *= 10;\n num /= 10;\n }\n println!(\"{}\", result);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "fa377cd54c70c351ad7154c7fa25273d", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "apr_id": "190cef2d4d4e0a2ae44fae3b27e8269a", "difficulty": 1200, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9919137466307277, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "fn solve() {\n let v: Vec = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim_end().chars().collect()\n };\n\n let mut ans = vec!['0'; v.len()];\n for (i, c) in v.iter().enumerate() {\n if *c == '9' || *c == '8' || *c == '7' || *c == '6' || *c == '5' {\n ans[i] = ('9' as u8 - (*c as u8) + '0' as u8) as char;\n } else {\n ans[i] = *c;\n }\n }\n\n let mut i = 0;\n while i < ans.len() && ans[i] == '0' {\n i += 1;\n }\n\n if i == ans.len() {\n println!(\"9\");\n } else {\n for x in i..ans.len() {\n print!(\"{}\", ans[x]);\n }\n println!();\n }\n}\n\nfn main() {\n solve();\n}\n", "lang": "Rust", "bug_code_uid": "d45de3ba5440977fde4dd61bdc4b2b3b", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "apr_id": "fb238770c6f3bcac81c947caa963f350", "difficulty": 1200, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9326980345443716, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::collections::{HashMap, HashSet, BinaryHeap};\n#[allow(unused_imports)]\nuse std::iter::FromIterator;\n\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#[allow(unused_macros)]\nmacro_rules! debug {\n ($x: expr) => {\n println!(\"{}: {:?}\", stringify!($x), $x)\n }\n}\n\nfn check(s: &[usize]) -> bool {\n (0..6).all(|i| {\n s[4 * i] == s[4 * i + 1] && s[4 * i] == s[4 * i + 2] && s[4 * i] == s[4 * i + 3]\n })\n}\n\nfn main() {\n let seq: Vec = util::gets();\n\n let mut ss = seq.clone();\n let mut s1 = seq.clone();\n for i in 0..3 {\n s1[20] = ss[3];\n s1[22] = ss[1];\n\n s1[9] = ss[22];\n s1[11] = ss[20];\n\n s1[5] = ss[9];\n s1[7] = ss[11];\n\n s1[1] = ss[5];\n s1[3] = ss[7];\n\n ss = s1.clone();\n\n if check(&s1) && i != 1 {\n println!(\"YES\");\n return;\n }\n }\n\n let mut ss = seq.clone();\n let mut s1 = seq.clone();\n for i in 0..3 {\n s1[20] = ss[16];\n s1[21] = ss[17];\n\n s1[17] = ss[5];\n s1[16] = ss[4];\n\n s1[5] = ss[13];\n s1[4] = ss[12];\n\n s1[13] = ss[20];\n s1[12] = ss[21];\n\n ss = s1.clone();\n\n if check(&s1) && i != 1 {\n println!(\"YES\");\n return;\n }\n }\n\n println!(\"NO\");\n\n}\n", "lang": "Rust", "bug_code_uid": "991dfe0fe1c5b3af89bfa2ec5e760786", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "apr_id": "7ac08c5a2aca8ac63e10e014d85a31e6", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8035350101971448, "equal_cnt": 23, "replace_cnt": 13, "delete_cnt": 3, "insert_cnt": 6, "fix_ops_cnt": 22, "bug_source_code": "static PERMS: [[usize; 8]; 3] = [\n [2, 4, 6, 8, 10, 12, 23, 21],\n [13, 14, 5, 6, 17, 18, 21, 22],\n [3, 4, 17, 19, 10, 9, 16, 14]\n];\n\n\nfn shiftmod(i: usize, dir: i32) -> usize {\n let res = i as i32 + 2 * dir;\n (if res < 0 { 8 + res } else if res > 8 { res - 8 } else { res }) as usize\n}\n\nfn shift(perm: &[usize; 8], dir: i32, state: &mut Vec) {\n for i in 0..6 {\n state.swap(perm[i] - 1, perm[shiftmod(i, dir)] - 1)\n }\n}\n\nfn is_correct(state: &Vec) -> bool {\n (0..6).all(|i|\n ((i * 4)..(i * 4 + 3))\n .all(|k| state[k] == state[k + 1]))\n}\n\nfn single_move(state: &mut Vec) -> bool {\n PERMS.iter().any(|perm| {\n shift(perm, 1, state);\n is_correct(state) || {\n shift(perm, -1, state);\n shift(perm, -1, state);\n is_correct(state)\n }\n })\n}\n\nfn main() {\n let mut sin = ReadIn::new();\n let mut colors = sin.intvec();\n println!(\"{}\", if single_move(&mut colors) { \"YES\" } else { \"NO\" });\n}\n\n\nuse std::iter::*;\nuse std::str::SplitWhitespace;\nuse std::io::stdin;\nuse std::mem::forget;\n\npub struct ReadIn(pub String);\n\nimpl ReadIn {\n pub fn new() -> ReadIn { ReadIn(String::new()) }\n fn read_i32(s: &str) -> i32 { s.parse().unwrap() }\n pub fn read_line(&mut self) {\n self.0.clear();\n forget(stdin().read_line(&mut self.0));\n }\n pub fn ints(&mut self) -> Map i32> {\n self.read_line();\n self.0.split_whitespace().map(ReadIn::read_i32)\n }\n pub fn intvec(&mut self) -> Vec { self.ints().collect() }\n pub fn int(&mut self) -> i32 { self.ints().next().unwrap() }\n pub fn int2(&mut self) -> (i32, i32) {\n let mut it = self.ints();\n (it.next().unwrap(), it.next().unwrap())\n }\n\n pub fn int3(&mut self) -> (i32, i32, i32) {\n let mut it = self.ints();\n (it.next().unwrap(), it.next().unwrap(), it.next().unwrap())\n }\n pub fn int4(&mut self) -> (i32, i32, i32, i32) {\n let mut it = self.ints();\n (it.next().unwrap(), it.next().unwrap(), it.next().unwrap(), it.next().unwrap())\n }\n}", "lang": "Rust", "bug_code_uid": "03854a3c5b2f56edadd5005f738d389a", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "apr_id": "71495b20cfd127a8618ecacfd93aa5a4", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.3478462251042149, "equal_cnt": 17, "replace_cnt": 10, "delete_cnt": 2, "insert_cnt": 5, "fix_ops_cnt": 17, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::cmp::{max, min};\n\nfn get_line() -> String {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n input\n}\n\nfn get_vec() -> Vec\nwhere T: FromStr,\n ::Err: std::fmt::Debug,\n{\n get_line().split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn extended_euclid(a: i64, b: i64) -> (i64, i64, i64) {\n if b == 0 {\n (a, 1, 0)\n } else {\n let (d0, x0, y0) = extended_euclid(b, a % b);\n (d0, y0, x0 - a / b * y0)\n }\n}\n\nfn main() {\n let colors: Vec = get_vec();\n\n let check_face = |i| {\n colors[4 * i..4 * (i + 1)].iter().all(|&x| x == colors[4usize * i])\n };\n\n let i = (0..6).find(|&x| check_face(x));\n if let None = i {\n println!(\"NO\");\n return;\n }\n\n let i = i.unwrap();\n\n let opp = |i| {\n match i {\n 0 => 2,\n 1 => 5,\n 2 => 0,\n 3 => 4,\n 4 => 3,\n 5 => 1,\n _ => panic!(\"\"),\n }\n };\n\n if !check_face(opp(i)) {\n println!(\"NO\");\n return;\n }\n\n let to_check = |i| {\n match i {\n 0 => (4, 14, 18),\n 1 => (0, 13, 16),\n 2 => (4, 14, 18),\n 3 => (4, 1, 9),\n 4 => (4, 1, 9),\n 5 => (0, 13, 16),\n _ => panic!(\"\"),\n }\n };\n\n let tc = to_check(i);\n let ans = colors[tc.0] == colors[tc.1] || colors[tc.0] == colors[tc.2];\n\n if ans {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "e3c8b2e8f827cd7602ce7c565954ea22", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "apr_id": "d734472306cf9f02e5b1fd1f322d2c00", "difficulty": 1500, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7611677805135421, "equal_cnt": 16, "replace_cnt": 10, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 15, "bug_source_code": "use std::io::*;\nuse std::ops::*;\n\n#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]\nstruct Clock {\n hh: i32,\n mm: i32,\n}\n\nimpl Clock {\n pub fn new (hh: i32, mm: i32) -> Self {\n Self {\n hh, mm\n }\n }\n}\n\nimpl Sub for Clock {\n type Output = Clock;\n fn sub(self, m: i32) -> Clock {\n let mut c = self;\n let h = m / 60;\n c.hh -= h;\n c.mm -= m;\n if c.mm < 0 {\n c.hh -= 1;\n c.mm = 60 + self.mm;\n }\n c\n }\n}\n\nfn find_lucky(c: &Clock) -> bool {\n if c.hh / 10 == 7 || c.hh % 10 == 7 || c.mm / 10 == 7 || c.mm % 10 == 7 {\n true\n } else {\n false\n }\n}\n\nfn main() {\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Can't read input\");\n let x: i32 = input.trim().parse().expect(\"Can't parse input\");\n input.clear();\n stdin().read_line(&mut input).expect(\"Cant' read input\");\n let mut hm = input.split_whitespace().map(|s| s.parse().expect(\"Can't parse intput\"));\n let hh: i32 = hm.next().unwrap();\n let mm = hm.next().unwrap();\n let mut c = Clock::new(hh, mm);\n let mut n = 0;\n loop {\n if find_lucky(&c) {\n println!(\"{}\", n);\n break;\n }\n c = c - x;\n n += 1;\n }\n\n}", "lang": "Rust", "bug_code_uid": "561856064d91d0b15b45420f35ee5b1b", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "apr_id": "27af78ba3918f4f866cc8ade9c3b05da", "difficulty": 900, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9760900140646976, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "\n#![allow(unused_imports)]\nuse std::io;\nuse std::io::prelude::*;\nuse std::io::BufReader;\nuse std::str::FromStr;\nuse std::collections::{VecDeque, HashMap};\nuse std::ops::Sub;\n\nfn main() {\n let stdin = io::stdin();\n let mut input = stdin.lock();\n let mut line = String::new();\n input.read_line(&mut line).unwrap();\n let x = get_numbers(&line)[0];\n line.clear(); input.read_line(&mut line).unwrap();\n let nums = get_numbers(&line);\n\n let get_up = Time::new(nums[0], nums[1]);\n\n let mut snoozed = 0;\n let mut cur_time = get_up;\n while cur_time.lucky() == false {\n cur_time = cur_time - x;\n snoozed += 1;\n }\n\n println!(\"{}\", snoozed);\n}\n\n#[derive(Debug, Clone, Copy)]\nstruct Time {\n hh: u8,\n mm: u8,\n}\n\nimpl Time {\n fn new(hour: u8, min: u8) -> Time {\n Time {\n hh: hour,\n mm: min,\n }\n }\n\n fn lucky(&self) -> bool {\n // 7 cannot be appear in the 10s spot so we only have to check ones\n self.mm % 10 == 7 || self.hh % 10 == 7\n }\n}\n\nimpl Sub for Time {\n type Output = Time;\n\n fn sub(self, mins: u8) -> Time {\n if mins < self.mm {\n Time { hh: self.hh, mm: self.mm - mins }\n } else if self.hh >= 1 {\n Time { hh: self.hh - 1, mm: self.mm + 60 - mins }\n } else {\n // going back a day\n Time { hh: 23, mm: self.mm + 60 - mins }\n }\n }\n}\n\n/*\n * Utility Functions\n */\n\n// get numbers from line seperated by spaces\nfn get_numbers(line: &str) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n line.split_whitespace()\n .map(|chunk| chunk.parse::().expect(\"failed to parse\"))\n .collect()\n}\n\n", "lang": "Rust", "bug_code_uid": "89e98e6b0134e3159906f980662e3b7e", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "apr_id": "867d4744006811dd8925852a5d216acf", "difficulty": 900, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9924812030075187, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let s = std::io::stdin();\n let mut sc = Scanner { stdin: s.lock() };\n let x: usize = sc.read();\n let mut hh: usize = sc.read();\n let mut mm: usize = sc.read();\n let mut result = 24 * 60;\n for h in 0..24 {\n for m in 0..60 {\n if h == 7 || m == 7 || m == 17 || m == 27 || m == 37 || m == 47 || m == 57 {\n let mut cnt = 0;\n let mut tmp_h = h;\n let mut tmp_m = m;\n while tmp_h != hh || tmp_m != mm {\n tmp_m += x;\n if tmp_m >= 60 {\n tmp_h += 1;\n tmp_m %= 60;\n }\n if tmp_h >= 24 {\n tmp_h = 0;\n }\n cnt += 1;\n if cnt > 24 * 60 {\n break;\n }\n }\n result = std::cmp::min(result, cnt);\n }\n }\n }\n println!(\"{}\", result);\n}\n\n//snippet from kenkoooo\npub struct Scanner {\n stdin: R,\n}\n\nimpl Scanner {\n pub fn read(&mut self) -> T {\n use std::io::Read;\n let buf = self\n .stdin\n .by_ref()\n .bytes()\n .map(|b| b.unwrap())\n .skip_while(|&b| b == b' ' || b == b'\\n' || b == b'\\r')\n .take_while(|&b| b != b' ' && b != b'\\n' && b != b'\\r')\n .collect::>();\n unsafe { std::str::from_utf8_unchecked(&buf) }\n .parse()\n .ok()\n .expect(\"Parse error.\")\n }\n pub fn vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read()).collect()\n }\n pub fn chars(&mut self) -> Vec {\n self.read::().chars().collect()\n }\n}\n", "lang": "Rust", "bug_code_uid": "b933742dec641fe028dd344dbf8bfa61", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "apr_id": "5c1567325082ddf917710a27a9e38551", "difficulty": 900, "tags": ["math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9964230965763924, "equal_cnt": 7, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 6, "bug_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\nfn main() {\n let input: Vec = util::gets();\n let h = input[0] % 12;\n let m = input[1];\n let s = input[2];\n let t1 = min(input[3], input[4]) % 12;\n let t2 = max(input[3], input[4]) % 12;\n\n let mut is_inside = Vec::new();\n\n is_inside.push(t1 * 5 < s && s < t2 * 5);\n let m_s = m * 60 + s;\n is_inside.push(t1 * 5 * 60 < m_s && m_s < t2 * 5 * 60);\n is_inside.push(t1 <= h && h < t2);\n\n\n if is_inside.iter().all(|&b| b) || is_inside.iter().all(|&b| !b) {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "dec1797aeb2bea976be264c9ab9f66a6", "src_uid": "912c8f557a976bdedda728ba9f916c95", "apr_id": "661acbb55df7ad587e53dce5a03911af", "difficulty": 1400, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7668269230769231, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut word = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n };\n\n let half = word.len() / 2;\n if word.chars().filter(|c| c.is_uppercase()).count() > half {\n word = word.chars().map(|c| c.to_ascii_uppercase()).collect();\n } else {\n word = word.chars().map(|c| c.to_ascii_lowercase()).collect();\n }\n\n println!(\"{:?}\", word);\n}", "lang": "Rust", "bug_code_uid": "727762c82165b117c7525b093e2959ce", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "apr_id": "cf6682490ba58e0b8d11f04079bbbf8d", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9999292035398231, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse utils::*;\n\npub fn main() {\n let i = stdin();\n let mut o = Vec::new();\n run(i.lock(), &mut o);\n stdout().write_all(&o).unwrap();\n}\n\n#[derive(PartialEq, Eq, Hash, Clone, Copy)]\nstruct Tile {\n num: usize,\n suit: char,\n}\nimpl CpIn for Tile {\n fn read_from(r: &mut CpReader) -> Self {\n let s = r.read_word_str();\n let num: usize = s[..1].parse().unwrap();\n Tile {\n num: num - 1,\n suit: s[1..].parse().unwrap(),\n }\n }\n}\n\npub fn run(i: R, o: &mut W) {\n let mut i = CpReader::new(i);\n let (t0, t1, t2) = i.read();\n writeln!(o, \"{}\", solve([t0, t1, t2])).unwrap();\n}\nfn solve(ts: [Tile; 3]) -> usize {\n let mut m = HashMap::new();\n for &t in &ts {\n *m.entry(t).or_insert(0) += 1;\n }\n let mut ans = 3 - *m.values().max().unwrap();\n\n for &suit in &['m', 'p', 's'] {\n let mut es = [false; 9];\n for &t in &ts {\n if t.suit == suit {\n es[t.num] = true;\n }\n }\n for i in 0..9 - 3 {\n let mut c = 0;\n for j in 0..3 {\n if es[i + j] {\n c += 1;\n }\n }\n ans = min(ans, 3 - c);\n }\n }\n ans\n}\n\npub mod utils {\n use super::*;\n\n pub struct CpReader {\n r: R,\n b: Vec,\n }\n impl CpReader {\n pub fn new(r: R) -> Self {\n CpReader {\n r: r,\n b: Vec::new(),\n }\n }\n pub fn read_word(&mut self) -> &[u8] {\n self.b.clear();\n let mut consume = 0;\n loop {\n self.r.consume(consume);\n let b = self.r.fill_buf().unwrap();\n assert!(b.len() != 0);\n if let Some(p) = b.iter().position(|&x| x.is_ascii_whitespace()) {\n self.b.extend_from_slice(&b[..p]);\n consume = p + 1;\n break;\n }\n self.b.extend_from_slice(b);\n consume = b.len();\n }\n self.r.consume(consume);\n consume_ws(&mut self.r);\n &self.b\n }\n pub fn read_word_str(&mut self) -> &str {\n unsafe { std::str::from_utf8_unchecked(self.read_word()) }\n }\n\n pub fn read_line(&mut self) -> &[u8] {\n self.b.clear();\n self.r.read_until(b'\\n', &mut self.b).unwrap();\n let end = self\n .b\n .iter()\n .rposition(|x| !x.is_ascii_whitespace())\n .map(|idx| idx + 1)\n .unwrap_or(0);\n &self.b[..end]\n }\n pub fn read_line_str(&mut self) -> &str {\n unsafe { std::str::from_utf8_unchecked(self.read_line()) }\n }\n\n pub fn read(&mut self) -> T {\n T::read_from(self)\n }\n\n pub fn read_vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read()).collect()\n }\n pub fn read_iter<'a, T: CpIn>(&'a mut self, n: usize) -> CpIter<'a, R, T> {\n CpIter {\n r: self,\n n: n,\n _pd: Default::default(),\n }\n }\n }\n pub struct CpIter<'a, R: BufRead + 'a, T> {\n r: &'a mut CpReader,\n n: usize,\n _pd: std::marker::PhantomData T>,\n }\n impl<'a, R: BufRead, T: CpIn> Iterator for CpIter<'a, R, T> {\n type Item = T;\n fn next(&mut self) -> Option {\n if self.n == 0 {\n None\n } else {\n self.n -= 1;\n Some(self.r.read())\n }\n }\n }\n\n pub trait CpIn {\n fn read_from(r: &mut CpReader) -> Self;\n }\n\n impl CpIn for u64 {\n fn read_from(r: &mut CpReader) -> Self {\n read_u64_fast(&mut r.r)\n }\n }\n impl CpIn for i64 {\n fn read_from(r: &mut CpReader) -> Self {\n read_i64_fast(&mut r.r)\n }\n }\n impl CpIn for char {\n fn read_from(r: &mut CpReader) -> Self {\n let b = r.r.fill_buf().unwrap()[0] as char;\n r.r.consume(1);\n let s = r.r.fill_buf().unwrap()[0];\n assert!(s == b' ' || s == b'\\n');\n r.r.consume(1);\n b\n }\n }\n\n macro_rules! cpin_tuple {\n ($($t:ident),*) => {\n impl<$($t: CpIn),*> CpIn for ($($t),*) {\n fn read_from(r: &mut CpReader) -> Self {\n ($($t::read_from(r)),*)\n }\n }\n };\n }\n\n macro_rules! cpin_cast {\n ($t_self:ty, $t_read:ty) => {\n impl CpIn for $t_self {\n fn read_from(r: &mut CpReader) -> Self {\n <$t_read>::read_from(r) as $t_self\n }\n }\n };\n }\n macro_rules! cpin_parse {\n ($t:ty) => {\n impl CpIn for $t {\n fn read_from(r: &mut CpReader) -> Self {\n r.read_word_str().parse().unwrap()\n }\n }\n };\n }\n cpin_cast!(usize, u64);\n cpin_cast!(u32, u64);\n cpin_cast!(u16, u64);\n cpin_cast!(i32, i64);\n cpin_cast!(i16, i64);\n cpin_cast!(i8, i64);\n\n cpin_parse!(f64);\n\n cpin_tuple!(T1, T2);\n cpin_tuple!(T1, T2, T3);\n cpin_tuple!(T1, T2, T3, T4);\n cpin_tuple!(T1, T2, T3, T4, T5);\n\n fn read_u64_fast(r: &mut R) -> u64 {\n let mut value = 0;\n loop {\n let mut idx = 0;\n let buf_len;\n {\n let buf = r.fill_buf().unwrap();\n buf_len = buf.len();\n assert!(buf_len != 0);\n while idx < buf_len && b'0' <= buf[idx] && buf[idx] <= b'9' {\n value = value * 10 + (buf[idx] - b'0') as u64;\n idx += 1;\n }\n }\n if idx < buf_len {\n r.consume(idx);\n consume_ws(r);\n return value;\n }\n r.consume(idx);\n }\n }\n fn read_i64_fast(r: &mut R) -> i64 {\n let (consume, sign) = match r.fill_buf().unwrap()[0] {\n b'+' => (true, 1),\n b'-' => (true, -1),\n _ => (false, 1),\n };\n if consume {\n r.consume(1);\n }\n read_u64_fast(r) as i64 * sign\n }\n fn consume_ws(r: &mut R) {\n let mut c = 0;\n loop {\n r.consume(c);\n let b = r.fill_buf().unwrap();\n if b.len() == 0 {\n return;\n }\n if let Some(p) = b.iter().position(|&x| !x.is_ascii_whitespace()) {\n c = p;\n break;\n }\n c = b.len();\n }\n r.consume(c);\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "f2cbacdd680aa0e1377250e02b3a8858", "src_uid": "7e42cebc670e76ace967e01021f752d3", "apr_id": "38a84dad01b7aa108b266d92d0c591ab", "difficulty": 1200, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9258698940998488, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 3, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "fn read_string() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n input\n}\n\nfn main(){\n \n let mut x = read_string();\n x = x.replace(\"\\r\", \"\");\n let vec: Vec<&str> = x.split(\"\").collect();\n let mut found: bool = false;\n println!(\"{:?}\", vec);\n for n in 2..(vec.len()-3){\n println!(\"{}\", vec[n]);\n if ((vec[n] != \".\") && (vec[n+1] != \".\") && (vec[n-1] != \".\")) &&\n ((vec[n] != vec[n+1]) && (vec[n-1] != vec[n+1]) && (vec[n] != vec[n-1]))\n {\n println!(\"=> {}\", vec[n]);\n found = true;\n break\n }\n }\n println!(\"{}\", if found {\"YES\"} else {\"NO\"});\n}\n", "lang": "Rust", "bug_code_uid": "ecb00a68e0df415b87d1d73568bb264f", "src_uid": "ba6ff507384570152118e2ab322dd11f", "apr_id": "aebdafaaeb5da0f6583328930d222141", "difficulty": 900, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9776482021379981, "equal_cnt": 6, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let mut a_iter = a_str.split_whitespace();\n (\n $(\n a_iter.next().unwrap().parse::<$t>().expect(\"parse error\"),\n )+\n )\n })\n}\n\nfn main() {\n let mut result:u128 = 0;\n let (m,n,a) = parse_line!(f32,f32,f32);\n result = ((m/a).ceil() * (n/a).ceil()) as usize;\n println!(\"{}\",result)\n}\n", "lang": "Rust", "bug_code_uid": "1d2c18f00938fc94b29ca2fd1700e928", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "069100f42f13fb08183b459806bba0b3", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.997229916897507, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut a_str = String::new();\n io::stdin().read_line(&mut a_str).expect(\"read error\");\n let vec = a_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect::>();\n\n let m = vec[0];\n let n = vec[1];\n let a = vec[2];\n\n let x: u128;\n if m % a != 0 {\n x = (m / a) + 1;\n } else {\n x = m / a;\n }\n\n let y: u128;\n if m % a != 0 {\n y = (n / a) + 1;\n } else {\n y = n / a;\n }\n\n println!(\"{}\", x*y)\n}\n", "lang": "Rust", "bug_code_uid": "1f1e2d04d918731d0d7233513b07e345", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "32596e385cd2af3553a3cd9b596515ef", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9948051948051948, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 4, "bug_source_code": "use std::io::{stdin, Read};\n\nfn get_integers() -> Vec {\n let mut buffer = String::new();\n stdin().read_line(&mut buffer).unwrap();\n buffer.split(' ').map(|x| x.trim().parse().unwrap()).collect()\n}\n\nfn main() {\n let inputs = get_integers();\n let n = inputs[0];\n let m = inputs[1];\n let a = inputs[2];\n\n println!(\"{}\", (n + a - 1) / a * (m + a - 1) / a);\n}", "lang": "Rust", "bug_code_uid": "4287288f1d0792af580659cc25a1cc9a", "src_uid": "ef971874d8c4da37581336284b688517", "apr_id": "030c4f55277a4e705739a0aca00d77d0", "difficulty": 1000, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8235294117647058, "equal_cnt": 12, "replace_cnt": 8, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 11, "bug_source_code": "use std::io;\nuse std::iter;\nuse std::cmp;\n\nfn main() {\n let (a, b): (f64, f64) = {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let delta = 1.0 + 4.0 * a;\n let n1 = (delta.sqrt() - 1.0) / 2.0;\n let n1 = n1.floor();\n\n let n2 = b.sqrt().floor() - 1.0;\n\n if n2 < n1 {\n println!(\"Valera\");\n } else {\n println!(\"Vladik\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "03b7f426626a40e9e70bd045dba3de81", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "apr_id": "b5b581812ec667fcf4f29513c5e0bbf2", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9916855631141346, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_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: i128 = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let a2: i128 = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let k1: i128 = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let k2: i128 = input.trim().parse().unwrap();\n\n input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let n: i128 = 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: i128 = 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 + (cards_left / k2) } else { n / k1 };\n } else {\n cards_left -= a2 * k2;\n maximum += if cards_left >= 0 { a2 + (cards_left / k1) } else { n / k2 };\n }\n\n println!(\"{} {}\", minimum, maximum);\n}\n", "lang": "Rust", "bug_code_uid": "de11fdaaf5fe6744c3eb33e66fb5b94f", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "apr_id": "1c6f89ba91feda1448d5889ef5d327f1", "difficulty": 1000, "tags": ["greedy", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8369829683698297, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, Write};\n\nfn main() {\n \n print!(\"Enter the weights of Limak and Bob: \");\n if let Err(err) = io::stdout().flush() {\n println!(\"Could not flush, {}\", err);\n }\n\n let mut input = String::new();\n io::stdin().read_line(&mut input).expect(\"Failed to read line\");\n\n let weights: Vec = input.split(\" \")\n .map( |x| x.trim_end().parse().expect(\"No an integer!\"))\n .collect();\n\n let mut limak_weight = weights[0];\n let mut bob_weight = weights[1];\n let mut years = 0;\n\n loop {\n if limak_weight > bob_weight { break; }\n limak_weight *= 3;\n bob_weight *= 2;\n years += 1;\n }\n\n println!(\"{}\", years);\n}\n", "lang": "Rust", "bug_code_uid": "3fd930fc5eee31e08f71e7d68230b32c", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "0629d9084756368e9106c18e8e8484c4", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6893732970027248, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "fn main() {\n let mut buf = String::new();\n\n std::io::stdin().read_line(&mut buf).unwrap();\n\n let bears_weight: Vec = buf\n .split_ascii_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n println!(\"{}\", (bears_weight[1] as f64 / bears_weight[0] as f64).log(1.5).ceil());\n}\n", "lang": "Rust", "bug_code_uid": "c1cfe38b9361af073c548504e77dab9f", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "485b2df9a9998bc28f30d15fa34d2048", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9351969504447268, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 5, "bug_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": "Rust", "bug_code_uid": "c626c5822b9e58c01a69fb6a2168365b", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "4bd941699ea72ef89c39b51499f47128", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.951188986232791, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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 mut a = words[0];\n let mut b = words[1];\n let mut years = 0;\n\n loop {\n if a > b {\n println!(\"{}\", years);\n }\n a *= 3;\n b *= 2;\n }\n}\n", "lang": "Rust", "bug_code_uid": "be85f81c2663a5ebb958b2776e6506a5", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "4bd941699ea72ef89c39b51499f47128", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9095744680851063, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io::BufRead;\n\nfn main() {\n let i: Vec = std::io::stdin()\n .lock()\n .lines()\n .next()\n .expect(\"stdin not work\")\n .expect(\"stdin not work\")\n .trim()\n .split(' ')\n .map(|s| s.parse::().expect(\"not number\"))\n .collect();\n println!(\"{}\", \n std::cmp::max(\n ((i[1]/i[0]).log2()/(3.0/2.0 as f32).log2()).ceil() as i64,\n 1\n ));\n}", "lang": "Rust", "bug_code_uid": "d1e22ca7d8ae591e42691cca0666b827", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "f7d8b08673b9e5e8e09dc2549c870d91", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8249075215782984, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\nuse std::str::FromStr;\n\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(s: String) -> Vec\n where T: FromStr,\n ::Err: std::fmt::Debug,\n{\n s.split_whitespace().map(|k| k.parse().unwrap()).collect()\n}\n\nfn main() {\n let (a, b): (u32, u32) = {\n let input = get_line();\n let mut it = input.split_whitespace().map(|k| k.parse().unwrap());\n (\n it.next().unwrap(),\n it.next().unwrap(),\n )\n };\n\n let wa = |n: u32| {\n (3u32.pow(n + 1) - 1) / 2 * a\n };\n\n let wb = |n: u32| {\n (2u32.pow(n + 1) - 1) * b\n };\n\n let ans = (0..).skip_while(|&n| wa(n) <= wb(n)).nth(0).unwrap();\n\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "f48ca51765cd08378c451ddcb32db133", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "d3283e7a5d4dfc86dc997f7be5129da1", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.997946611909651, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input)\n .expect(\"Failed to read line\");\n\n let split_input : Vec<&str> = input.as_str().split(' ').collect();\n let mut a : i32 = split_input[0].trim().parse().expect(\"en\"); \n let mut b : i32 = split_input[1].trim().parse().expect(\"en\"); \n let mut counter = 0;\n while a <= b {\n counter += 1;\n a += 3 * a;\n b += 2 * b;\n }\n println!(\"{}\", counter);\n}\n", "lang": "Rust", "bug_code_uid": "1dbca4e09d304bfbaf599c40c2b22b7a", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "68a7fae8bf85f14578951fcfe1f6fbb2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9535160905840286, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut nums = String::new();\n std::io::stdin().read_line(&mut nums).unwrap();\n let nums = nums.split_whitespace().collect::>();\n let mut a: u8 = nums[0].parse().unwrap();\n let mut b: u8 = nums[1].parse().unwrap();\n let mut i = 1;\n loop {\n a *= 3;\n b *= 2;\n if a > b {\n println!(\"{}\", i);\n break;\n }\n i += 1;\n }\n}\n", "lang": "Rust", "bug_code_uid": "5fd4e052110f6991efda1b76e14db782", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "73bd6aeb4cc17db6509c79f22d45442b", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7108307045215563, "equal_cnt": 9, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 9, "bug_source_code": "use std::io::{self, Write};\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n\n let mut a = scan.next().parse::().unwrap();\n let mut b = scan.next().parse::().unwrap();\n\n let mut years = 0;\n while a <= b {\n years += 1;\n a *= 3;\n b *= 2;\n }\n\n writeln!(out, \"{}\", years).ok();\n}\n\npub struct Scanner {\n reader: T,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self { reader }\n }\n\n pub fn next(&mut self) -> String {\n loop {\n let mut input = String::new();\n self.reader.read_line(&mut input).unwrap();\n\n return input.trim().to_owned();\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "acd832bed0cef788020eadb41164a64c", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "27c4b452d8d4db2826c380ea4454f262", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9860724233983287, "equal_cnt": 6, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "fn read_vec() -> Vec {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer\n .split_whitespace()\n .map(|brother|\n brother.parse::().expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n let (mut a, mut b): (u8, u8) = {\n let brothers: Vec = read_vec();\n (brothers[0], brothers[1])\n };\n\n let mut years: u8 = 0;\n while a <= b {\n a *= 3;\n b *= 2;\n years += 1;\n }\n\n println!(\"{}\", years);\n}", "lang": "Rust", "bug_code_uid": "06030df5bd5a53511d59e6b4b3407a3c", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "89167843bf53383e62375cfae8fba111", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9738095238095238, "equal_cnt": 6, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nfn weight(mut a: i8, mut b: i8) -> i8 {\n let mut i = 0;\n while b >= a {\n a*=3;\n b*=2;\n i += 1;\n }\n i\n}\n\nfn main() -> io::Result<()> {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer)?;\n let mut res = buffer.split_whitespace().map(|s| s.parse::().unwrap());\n println!(\"{}\", weight(res.next().unwrap(), res.next().unwrap()));\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "c7f8b0b3eb54374cb3a17764154c57f1", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "9ad5081aeb550af3bae8ad8f06eceb70", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9953831948291783, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "#![allow(unused_imports)]\n\nuse std::cmp::{max, min};\nuse std::collections::{HashMap, HashSet};\nuse std::io::{stdin, stdout, BufWriter, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec,\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solve () {\n let mut scan = Scanner::default();\n let a: u8 = scan.next();\n let b: u8 = scan.next();\n let mut p3 = 1;\n let mut p2 = 1;\n for x in 1.. {\n p3 *= 3;\n p2 *= 2;\n if a*p3 > b*p2 {\n println! (\"{}\", x);\n return\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n // let t = scan.next::();\n let t = 1;\n for _ in 0..t {\n solve();\n }\n}\n", "lang": "Rust", "bug_code_uid": "57bd0873706d65673c58296337d31961", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "apr_id": "63f2ed151bd1a85118f8d540a7ec6c10", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9960612691466083, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rust\n#[allow(unused_imports)]\nuse std::io::{self,Read};\n\nstruct WordReader {\n it : std::vec::IntoIter,\n}\n#[allow(dead_code)]\nimpl WordReader {\n fn new(mut reader : T) -> WordReader {\n let mut s = String::new();\n reader.read_to_string(&mut s).unwrap();\n WordReader { it : s\n .split_ascii_whitespace()\n .map(String::from).collect::>()\n .into_iter()\n }\n }\n fn from_stdin() -> WordReader {\n WordReader::new(std::io::stdin())\n }\n fn s(&mut self) -> String {\n self.it.next().unwrap()\n }\n fn ab(&mut self) -> Vec {\n self.it.next().unwrap().into_bytes()\n }\n fn i(&mut self) -> i32 {\n self.it.next().unwrap().parse().unwrap()\n }\n}\n\nfn main() {\n let mut input = WordReader::from_stdin();\n let n = (input.i() - 1) as usize;\n let m = input.i();\n let mut a = Vec::with_capacity(m);\n for _ in 0..m {\n a.push(input.i());\n }\n a.sort();\n let mut sol = 1000;\n for i in n..m {\n sol = std::cmp::min(sol, a[i] - a[i - n]);\n }\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "e751d15071315a079a1af1ed2bdeffe4", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "760cfc9aef2be8f9d1db05b5aa6c2f38", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8039513677811551, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 7, "bug_source_code": "use std::io::{self, BufRead};\n\nfn main() {\n let stdin = io::stdin();\n let mut iterator = stdin.lock().lines();\n\n let first = iterator.next().unwrap().unwrap();\n let second = iterator.next().unwrap().unwrap();\n\n let nm: Vec = first\n .split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect();\n \n let mut sizes: Vec = second\n .split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect();\n \n sizes.sort();\n let min = sizes[nm[0]-1] - sizes[0];\n println!(\"{}\", min);\n}", "lang": "Rust", "bug_code_uid": "10472db45f655f7d38ae3e51c4d94d85", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "32c1fd1c45da3dcfb6158b81cc0208f8", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9986301369863013, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nmacro_rules! rt {\n ( $( $type:ty ),+ ) => ({\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let mut iter = s.split_whitespace();\n (\n $(\n iter.next().unwrap().parse::<$type>().unwrap(),\n )+\n )\n })\n}\n\nmacro_rules! rv {\n ( $type:ty ) => ({\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let v: Vec<$type> = s.split_whitespace().map(|x|\n x.parse::<$type>().unwrap()).collect();\n v\n })\n}\n\nfn main() {\n let (n, m) = rt!(usize, usize);\n let mut v = rv!(usize);\n\n v.sort();\n\n let mut d = v[n-1] - v[0];\n for i in 1..m-n {\n let diff = v[i+n-1] - v[i];\n if diff < d {\n d = diff;\n }\n }\n\n println!(\"{}\", d);\n}\n\n", "lang": "Rust", "bug_code_uid": "8fe192468a6f31b09e8b5a84fc0a332c", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "bf071963c9744e508078a6fedfa428d0", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9974779319041615, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::collections::HashSet;\nuse std::io::*;\n\nfn reads(i: &mut StdinLock) -> Vec {\n let mut s = String::new();\n i.by_ref().read_line(&mut s).ok();\n s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n\nfn main() {\n // initialize stdin\n let sin = std::io::stdin();\n let mut sin = sin.lock();\n let sin = &mut sin;\n\n let infos: Vec = reads(sin);\n let mut pieces: Vec = reads(sin);\n\n let children: usize = infos[0] as usize;\n let mut min_diff = 1000;\n\n pieces.sort();\n\n for i in 0..pieces.len() - children {\n let diff = pieces[i + children - 1] - pieces[i];\n if diff < min_diff {\n min_diff = diff;\n }\n }\n\n println!(\"{}\", min_diff);\n}\n", "lang": "Rust", "bug_code_uid": "b2793d9bad7391ba0c660eb3d3d280ce", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "af4b102c1aabc91bab35acbff34d733b", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6320109439124487, "equal_cnt": 9, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 8, "bug_source_code": "use std::io;\n\nfn main(){\n let mut input = String::new();\n\n io::stdin().read_line(&mut input)\n .expect(\"read_line error\");\n \n let n : Vec<_> = input.trim().split_ascii_whitespace()\n .map(|num| {\n num.parse::()\n .expect(\"Parsing error\")\n }).collect();\n\n io::stdin().read_line(&mut input)\n .expect(\"read_line error\");\n\n let mut v : Vec = input.trim().split_ascii_whitespace()\n .map(|num| {\n num.parse::()\n .expect(\"Parsing error\")\n }).collect();\n \n v.sort();\n \n println!(\"{}\", v[n[1] - 1] - v[n[1] - 1 - n[0]]);\n}\n", "lang": "Rust", "bug_code_uid": "86f8fec9d8bbf2f35797985f73dddad5", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "ef9215f693705bd583f8a624be733978", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9975216852540273, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main(){\n let mut input = String::new();\n\n io::stdin().read_line(&mut input)\n .expect(\"read_line error\");\n \n let n : Vec<_> = input.trim().split_ascii_whitespace()\n .map(|num| {\n num.parse::()\n .expect(\"Parsing error\")\n }).collect();\n\n input.clear();\n io::stdin().read_line(&mut input)\n .expect(\"read_line error\");\n\n let mut v : Vec<_> = input.trim().split_ascii_whitespace()\n .map(|num| {\n num.parse::()\n .expect(\"Parsing error\")\n }).collect();\n \n v.sort();\n let mut best = v[n[1] - 1] - v[0];\n for i in 0 .. n[1] - n[0]{\n best = if v[i + n[0] -1] - v[i] < best { v[i + n[0] -1] - v[i] } else { best};\n } \n \n println!(\"{}\", best);\n}\n", "lang": "Rust", "bug_code_uid": "d4b127fe2f300903fd60ee951e1c060c", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "ef9215f693705bd583f8a624be733978", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9982608695652174, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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, m) = (arr[0], arr[1]);\n s.clear();\n io::stdin().read_line(&mut s).unwrap();\n arr = s.split_whitespace().map(|s| s.parse().unwrap()).collect();\n arr.sort();\n let mut ans = -1;\n for i in 0..m-n {\n let tmp = arr[(i+n-1) as usize] - arr[i as usize];\n if ans == -1 || tmp < ans {\n ans = tmp;\n }\n }\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "b94e613936b799eeb28e06cc14952954", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "8ca1eadfbfb297c14df667d1fdcd4497", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9969230769230769, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 5, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_vec(split_char: char) -> Vec {\n read_str()\n .split(split_char)\n .map(|value| value.parse::().ok().expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n let students: usize = read_vec(' ')[0];\n let mut pieces: Vec = read_vec(' ');\n pieces.sort();\n let mut difference: u16 = u16::max_value();\n\n let mut index: usize = 0;\n let end: usize = pieces.len() - students;\n loop {\n difference = std::cmp::min(difference, pieces[index + students - 1] - pieces[index]);\n index += 1;\n if index >= end { break; }\n }\n print!(\"{}\", difference);\n}", "lang": "Rust", "bug_code_uid": "f78e0acd8748a62929fca0c552ce3769", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "c61b7600b94597a62edbd5ca2a1f8644", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9950617283950617, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 5, "fix_ops_cnt": 5, "bug_source_code": "std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_vec(split_char: char) -> Vec {\n read_str()\n .split(split_char)\n .map(|value| value.parse::().ok().expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n let students: usize = read_vec(' ')[0];\n let mut pieces: Vec = read_vec(' ');\n pieces.sort();\n let mut difference: u16 = u16::max_value();\n\n let mut index: usize = 0;\n let end: usize = pieces.len() - students;\n loop {\n difference = std::cmp::min(difference, pieces[index + students - 1] - pieces[index]);\n index += 1;\n if index > end { break; }\n }\n print!(\"{}\", difference);\n}", "lang": "Rust", "bug_code_uid": "d317bfce8fbb9fac3e3c2c58001514a7", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "c61b7600b94597a62edbd5ca2a1f8644", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9997485541865728, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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\nstruct xorrand {\n state: u64,\n}\n#[allow(dead_code)]\nimpl xorrand {\n fn rand(&mut self) -> u64 {\n let mut x = self.state;\n x ^= x << 13;\n x ^= x >> 7;\n x ^= x << 17;\n self.state = x;\n self.state.wrapping_mul(0x2545F4914F6CDD1Du64)\n }\n\n fn randint(&mut self, start: u64, end: u64) -> u64 {\n return (self.rand() % (end - start)) + start;\n }\n\n fn randfloat(&mut self) -> f64 {\n 1.0 / (self.rand() as f64)\n }\n\n fn new(seed: u64) -> xorrand {\n xorrand { state: seed }\n }\n\n fn newtime() -> xorrand {\n let start = std::time::SystemTime::now();\n let ms = start\n .duration_since(std::time::UNIX_EPOCH)\n .unwrap()\n .as_secs();\n xorrand { state: ms }\n }\n\n fn shuffle(&mut self, tgt: &mut Vec) {\n for i in 0..tgt.len() - 1 {\n let j = self.randint(i as u64, tgt.len() as u64) as usize;\n let c = tgt[j].clone();\n tgt[j] = tgt[i].clone();\n tgt[i] = c;\n }\n }\n}\n\nfn main() {\n let s1 = split_input!(usize);\n let mut s2 = split_input!(usize);\n s2.sort();\n let mut best = 10000;\n for i in 0..s2.len() - s1[0] {\n let v = s2[i + s1[0] - 1] - s2[i];\n best = std::cmp::min(v, best);\n }\n println!(\"{}\", best);\n}\n", "lang": "Rust", "bug_code_uid": "f61d5808cd1282bd77ef067b9bdc9cbc", "src_uid": "7830aabb0663e645d54004063746e47f", "apr_id": "a093c7d6de6918d90a30d34c1c4926f3", "difficulty": 900, "tags": ["greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6801602361374658, "equal_cnt": 15, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 7, "fix_ops_cnt": 14, "bug_source_code": "/// square root of an int\nfn sqrti(b: u64) -> u64 {\n let n = 2;\n if b < 2 {\n return b\n };\n let n1 = n - 1;\n let n2 = n;\n let n3 = n1;\n let mut c = 1;\n let mut d = (n3 + b) / n2;\n let mut e = (n3 * d + b / d.pow(n1 as u32)) / n2;\n while c != d && c != e {\n c = d;\n d = e;\n e = (n3 * e + b / e.pow(n1 as u32)) / n2;\n }\n if d < e { d }\n else { e }\n}\n\n/// iterator that returns `(w, h)` for rectangles of provided area\nstruct Rects {\n area: u64,\n w: u64,\n q: u64,\n}\n\nimpl Rects {\n pub fn new(area: u64) -> Rects {\n Rects { area, w: 0, q: sqrti(area) }\n }\n}\n\nimpl Iterator for Rects {\n type Item = (u64, u64);\n fn next(&mut self) -> Option<(u64, u64)> {\n while self.w <= self.q {\n self.w += 1;\n let h = self.area / self.w;\n if h * self.w != self.area {\n continue;\n }\n return Some((self.w, h));\n }\n None\n }\n}\n\nfn solve(a: u64, b: u64) -> Option {\n if a < 1 || b < 1 {\n return None;\n }\n let area = a + b;\n Rects::new(area).flat_map(|(ow, oh)| {\n let perimeter = (ow + oh) * 2;\n Rects::new(a).chain(Rects::new(b))\n .find(|&(iw, ih)| iw <= ow && ih <= oh)\n .and(Some(perimeter))\n }).min()\n}\n\nuse std::io::{stdin, BufRead};\nuse std::process::{exit};\nfn input() -> Result<(u64, u64), String> {\n let std = stdin();\n let mut row = String::new();\n std.lock().read_line(&mut row).map_err(|_|\"Cannot read stdin\")?;\n let words: Vec<&str> = row.trim().split(' ').collect();\n let a: u64 = words[0].parse().map_err(|_|\"Cannot parse input\")?;\n let b: u64 = words[1].parse().map_err(|_|\"Cannot parse input\")?;\n Ok((a, b))\n}\n\nfn main() {\n let rv = input().map(|(a,b)| solve(a, b));\n match rv {\n Ok(Some(perimeter)) => {\n println!(\"{}\", perimeter);\n }\n Ok(None) => {\n eprintln!(\"Error: solution not found\");\n exit(1);\n }\n Err(e) => {\n eprintln!(\"Error: {}\", e);\n exit(1);\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "9cd04fa5913c76aee3d4b19142a9b3ee", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "apr_id": "5aff8dfb28b320b4f86da2a9dea24f37", "difficulty": 2000, "tags": ["math", "brute force", "number theory", "binary search"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6329565734681737, "equal_cnt": 18, "replace_cnt": 12, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 17, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let rin = buf.split_whitespace().map(|c| c.parse::().unwrap()).collect::>();\n let n = rin[0] + rin[1];\n let m: u64;\n\n let ret1 = factors(n, None);\n let x = ret1.last().unwrap();\n let ret3 = factors(rin[0], Some(*x));\n let ret4 = factors(rin[1], Some(*x));\n// println!(\"{:?} {:?}\", ret3, ret4);\n\n let ret2 = if ret3.last().unwrap() > ret4.last().unwrap() {\n m = rin[0];\n ret3\n } else {\n m = rin[1];\n ret4\n };\n// println!(\"{:?}\", ret1);\n// println!(\"{:?}\", ret2);\n let mut p: u64 = 0;\n 'find: for i in ret1.iter().rev() {\n let x1 = i;\n let y1 = n / x1;\n for j in ret2.iter().rev() {\n let x2 = j;\n let y2 = m / x2;\n// println!(\"{} {}, {} {}\", x1, y1, x2, y2);\n if x2 <= x1 && y2 <= y1 {\n p = (x1 + y1) * 2;\n break 'find;\n }\n }\n }\n println!(\"{}\", p);\n}\n\nfn factors(n: u64, max: Option) -> Vec {\n let sqrt = (n as f64).sqrt() as u64;\n let mut ret = Vec::::new();\n for i in 1..=sqrt {\n match max {\n Some(x) if i > x => {\n// println!(\"{}, {}\", i, x);\n break;\n }\n _ => {}\n }\n if n % i == 0 {\n ret.push(i);\n }\n }\n// let ret = (1..=sqrt).rev().filter(|c| n % c == 0).collect::>();\n return ret;\n}", "lang": "Rust", "bug_code_uid": "f06614b7afb87541dc89302e06aa1204", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "apr_id": "20d36bbcb1dd6046b37bf0c69783c8ff", "difficulty": 2000, "tags": ["math", "brute force", "number theory", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9969439728353141, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 4, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused_imports)]\nuse std::io;\nuse std::mem::size_of_val;\nuse std::cmp::{max, min};\nuse std::rc::Rc;\nuse std::collections::btree_map::BTreeMap;\nuse std::io::{Write, BufRead};\nuse std::collections::HashMap;\nuse std::ptr::write_volatile;\n\n#[allow(dead_code)]\nfn gets() -> String {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n s.trim().to_string()\n}\n\n#[allow(unused)]\nfn read_strings() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n let mut v = Vec::new();\n for value in string.split_whitespace() {\n v.push(value.to_string());\n }\n v\n}\n\n#[allow(unused)]\nfn read_array_i32() -> Vec {\n let mut string: String = String::new();\n std::io::stdin().read_line(&mut string).unwrap();\n string.split_whitespace().map(|x| x.parse::().unwrap()).collect()\n}\n\n\n#[allow(unused_macros)]\nmacro_rules! read_array {\n ( $ty:ty, ... ) => {\n gets().split_whitespace().map(|x| x.parse::<$ty>().unwrap())\n };\n ( $($ty:ty),* ) => {{\n let line = gets();\n let mut it = line.split_whitespace();\n ( $(it.next().unwrap().parse::<$ty>().unwrap(),)* )\n }}\n}\n\n// mod math;\n// mod binary_search;\n// mod graph;\n// mod structure;\n// mod fibonacci;\n// mod string;\n// mod permutations;\n// mod patterns;\n\n\n#[allow(dead_code)]\nfn memory_properties(value: &T)\n where\n T: std::fmt::Display + ?Sized,\n{\n println!(\n \"Variable address in memory = {:p}, Allocated bytes for type = {}\",\n value,\n size_of_val(value)\n );\n}\n\n#[allow(unused_macros)]\nmacro_rules! sum {\n ($($x:expr), *) => {\n {\n let mut res = 0;\n $(res += $x;)*\n res\n }\n };\n}\n\nstatic mut array: [[u8;51];51] = [[0u8; 51]; 51];\n\nfn main() {\n use std::io::Write;\n let out = std::io::stdout();\n let mut out = std::io::BufWriter::new(out.lock());\n\n let arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];\n let s = gets();\n let mut res = 0;\n let mut idx = 26;\n for ch in s.bytes() {\n let mut l = idx;\n let mut r = idx;\n\n while l > 0 && arr[l as usize] as u8 != ch {\n l -= 1;\n }\n while r < arr.len() as u8 && arr[r as usize] as u8 != ch {\n r += 1;\n }\n if idx - l <= r - idx {\n res += idx - l;\n idx = l % 26 + 26;\n }else {\n res += r - idx;\n idx = r % 26 + 26;\n }\n }\n writeln!(out, \"{}\", res);\n\n // writeln!(out, \"{}\", \"Hello Rust\").unwrap();\n}", "lang": "Rust", "bug_code_uid": "394ba6f666ad23bed81be051bb2ab1c7", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "apr_id": "adfe913bdc6698f33367831b9f0975bd", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9952380952380953, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let mut line = String::new();\n stdin().read_line(&mut line).unwrap();\n\n let line: Vec = line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let ejemaximo = std::cmp::max(line[0], line[1]);\n\n println!(\n \"{}\",\n if ejemaximo % 2 == 0 {\n \"Malvika\"\n } else {\n \"Akshat\"\n }\n );\n}\n", "lang": "Rust", "bug_code_uid": "c5bf49d22d8adb89f5bfcf796f0ab7df", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "apr_id": "46649ff07ccc51ee7e998ccb2d8265df", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9743589743589743, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn read_line() -> Vec {\n let mut input = String::new();\n \n io::stdin().read_line(&mut input).unwrap();\n \n let v: Vec = input.trim().split_ascii_whitespace()\n .map(|number| {\n number.parse().unwrap()\n }).collect();\n\n v\n}\n\nfn main(){\n \n let m = read_line();\n\n if((m[0] + m[1]) / 2) % 2 == 0 {\n println!(\"Malvika\"); \n } else {\n println!(\"Akshat\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "ff2de97d50e9a28dde9af23855bc2ebb", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "apr_id": "66b42d58bd75dc4d0ad50e934322e69f", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9925062447960034, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::mem;\nuse std::io;\nuse std::string;\nuse std::cmp::*;\nuse std::collections::*;\n\nfn load() -> Vec {\n let mut line = String::new();\n io::stdin().read_line(&mut line).expect(\"Failed to read line\");\n let vec: Vec<&str> = line.split(\" \").collect();\n let mut data : Vec = Vec::new();\n for i in vec {\n let el : i64 = i.trim().parse().unwrap();\n data.push(el);\n }\n data\n}\n\nfn main() {\n let s = load();\n let (a,b)=(s[0],s[1]);\n println!(\"{}\", (if a*b%2==0 {\"Malvika\"}else{\"Akshat\"}));\n}\n// min, max\n// HashSet, insert, contains\n// Vec, len, sort\n", "lang": "Rust", "bug_code_uid": "65918483d6971e98870399c7be47bea3", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "apr_id": "d92cf6411022ed263810b68d00d68ce2", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7344632768361582, "equal_cnt": 14, "replace_cnt": 6, "delete_cnt": 4, "insert_cnt": 4, "fix_ops_cnt": 14, "bug_source_code": "use std::io;\n\nfn main() -> std::io::Result<()> {\n let stdin = io::stdin();\n let mut matrix = Vec::new();\n let mut input = String::new();\n for _ in 0..5 {\n stdin.read_line(&mut input)?;\n matrix.push(\n input.split_ascii_whitespace()\n .map(|x| x.parse::().unwrap())\n .collect::>()\n );\n input.clear();\n }\n print!(\"{}\", beautiful_matrix(matrix));\n Ok(())\n}\nfn beautiful_matrix(matrix: Vec>) -> i8 {\n let mut distance: i8 = 0;\n let mut count: i8 = 0;\n for v in matrix {\n count += 1;\n distance += {\n (2 - v.iter()\n .position(|&x| x == 1)\n .unwrap_or(0) as i8)\n .abs()\n };\n if distance != 0 {\n distance += {\n (2 - count).abs()\n };\n break;\n }\n }distance\n}\n#[cfg(test)]\nmod tests {\n use super::*;\n #[test]\n fn test() {\n assert_eq!(beautiful_matrix(vec!(\n vec!(0, 0, 0, 0, 0),\n vec!(0, 0, 0, 0, 1),\n vec!(0, 0, 0, 0, 0),\n vec!(0, 0, 0, 0, 0),\n vec!(0, 0, 0, 0, 0))), 3);\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "77ae072a234b9b2e54c2c7e8e62e3c84", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "ebd8799a7a9672de2d6b228b9a45f1f2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9831730769230769, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "fn readln() -> Vec {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n line.split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect()\n}\n\nfn main() {\n for i in 0..5 {\n let line = readln();\n for j in 0..5 {\n if line[j] == 1 {\n println!(\"{}\", (2 - i).abs() + (2 - j).abs());\n }\n }\n }\n}", "lang": "Rust", "bug_code_uid": "0e2528a3e4d32ef5803e14a91b47807f", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "apr_id": "ae1954a0fdb02cfbd4161dcc44ca720a", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9901328273244782, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rusT\nuse std::io::*;\nuse std::str::{self,*};\nuse std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_macros)]\nmacro_rules! m {\n ($c:tt, $x:expr, $y:expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\n#[allow(unused_macros)]\nmacro_rules! l {\n ($($v:ident),* = $i:ident.$f:ident $a:tt) => {\n $( let $v = $i.$f$a; )*\n };\n ($($v:ident),*:$t:ty = $i:ident.$f:ident $a:tt) => {\n $( let $v:$t = $i.$f$a; )*\n };\n}\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a> }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).ok();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn f(&mut self) -> f64 { self.p() }\n fn u(&mut self) -> usize { self.p() }\n fn sk(&mut self, n: usize) { self.it.nth(n - 1); }\n fn ii(&mut self, n: usize) -> impl Iterator {\n self.ip(n).into_iter()\n }\n fn vi(&mut self, n: usize) -> Vec {\n self.vp::(n)\n }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n self.vp(n).into_iter()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n//------------------- End rusT\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n l!(n,b: i64 = input.p());\n let mut sol = n;\n let mut b = b;\n let mut i = 2;\n while b > 1 {\n if b % i == 0 {\n let mut c = 0;\n while b % i == 0 {\n b /= i;\n c += 1;\n }\n let mut a = n;\n let mut b = 0;\n while a > 0 {\n a /= i;\n b += a;\n }\n m!(<, sol, b/c);\n }\n i += 1;\n }\n println!(\"{}\", sol);\n}\n\n", "lang": "Rust", "bug_code_uid": "4961e53cb87899881b4b326d7b457f4e", "src_uid": "491748694c1a53771be69c212a5e0e25", "apr_id": "04fd71b687e0e4e8262194e7a28d60ce", "difficulty": 1700, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9728898288790617, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_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\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\n#[allow(unused_imports)]\nuse std::io::Write;\n\nfn prime_factorization(mut n: u64) -> Vec<(u64, u64)> {\n let mut i = 2;\n let mut ans = vec![];\n while i*i <= n {\n let mut cnt = 0;\n while n%i == 0 {\n n /= i;\n cnt += 1;\n }\n if cnt > 0 {\n ans.push((i, cnt));\n }\n i += 1;\n }\n if n > 1 {\n ans.push((n, 1));\n }\n ans\n}\n\nfn fact_num(n: u64, v: u64) -> u64 {\n if n < v {\n return 0;\n }\n let div = n/v;\n div + fact_num(div, v)\n}\n\n\nfn main() {\n input!{\n n: u64,\n b: u64,\n }\n let facts = prime_factorization(b);\n let mut ans: u64 = 1 << 32;\n for i in 0..facts.len() {\n let (v, pow) = facts[i];\n let fnum = fact_num(n, v);\n ans = min(ans, fnum/pow);\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "d336aa300b8fee8d6f1df16fb0b03127", "src_uid": "491748694c1a53771be69c212a5e0e25", "apr_id": "2358ded6e8e0b1a3728578c20e742d29", "difficulty": 1700, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9588808817295464, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\nuse std::cmp::min;\n\nfn main() {\n let tmp = readline_ints();\n let n = tmp[0];\n let b = tmp[1];\n\n let fs = factor(b);\n let mut ans = std::i64::MAX;\n\n // println!(\"{:?}\", fs);\n\n for &(p, cnt) in fs.iter() {\n //println!(\"{}\", count(n, p) / cnt);\n ans = min(count(n, p) / cnt, ans);\n }\n \n println!(\"{}\", ans);\n}\n\nfn factor(mut n: i64) -> Vec<(i64, i64)> {\n let mut fs: Vec<(i64, i64)> = Vec::new();\n for i in 2..((n as f64).sqrt().ceil() as i64 + 1) {\n let mut cnt = 0i64;\n while n % i == 0 {\n n /= i;\n cnt += 1;\n }\n if cnt > 0 {\n fs.push((i as i64, cnt));\n }\n }\n if n > 1 {\n fs.push((n, 1));\n }\n fs\n}\n\nfn count(n: i64, p: i64) -> i64 {\n let mut c = 0i64;\n let mut b = p;\n while n >= b {\n c += n / b;\n //println!(\"n = {}, b = {}, n/b = {}\", n, b, n/b);\n b *= p;\n }\n c\n}\n\nfn readline_ints() -> Vec {\n let mut strs = String::new();\n let _ = io::stdin().read_line(&mut strs);\n strs.split_whitespace().map(|s| s.parse::().unwrap()).collect()\n}", "lang": "Rust", "bug_code_uid": "e27a72cb0833e3508f4008272fe1fe7b", "src_uid": "491748694c1a53771be69c212a5e0e25", "apr_id": "d2ab5b8af8b6ede082b0b99dd3b0c963", "difficulty": 1700, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8075240594925635, "equal_cnt": 11, "replace_cnt": 4, "delete_cnt": 3, "insert_cnt": 3, "fix_ops_cnt": 10, "bug_source_code": "use std::io;\nuse std::cmp::min;\n\nfn main() {\n let tmp = readline_ints();\n let n = tmp[0];\n let b = tmp[1];\n\n let fs = factor(b);\n let mut ans = std::i64::MAX;\n\n for &(p, cnt) in fs.iter() {\n ans = min(count(n, p) / cnt, ans);\n }\n \n println!(\"{}\", ans);\n //println!(\"{:?}\", fs);\n}\n\nfn factor(mut n: i64) -> Vec<(i64, i64)> {\n let mut fs: Vec<(i64, i64)> = Vec::new();\n for i in 2..((n as f64).sqrt().ceil() as i64 + 1) {\n let mut cnt = 0i64;\n while n % i == 0 {\n n /= i;\n cnt += 1;\n }\n if cnt > 0 {\n fs.push((i as i64, cnt));\n }\n }\n if n > 1 {\n fs.push((n, 1));\n }\n fs\n}\n\nfn count(n: i64, mut p: i64) -> i64 {\n let mut c = 0i64;\n while n >= p {\n c += n / p;\n p = p * p;\n // println!(\"n = {}, p = {}\", n, p);\n }\n c\n}\n\nfn readline_ints() -> Vec {\n let mut strs = String::new();\n let _ = io::stdin().read_line(&mut strs);\n strs.split_whitespace().map(|s| s.parse::().unwrap()).collect()\n}", "lang": "Rust", "bug_code_uid": "3178e652a233c01105b25cbbc1acebad", "src_uid": "491748694c1a53771be69c212a5e0e25", "apr_id": "d2ab5b8af8b6ede082b0b99dd3b0c963", "difficulty": 1700, "tags": ["number theory", "math", "brute force", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9660124461464815, "equal_cnt": 16, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 13, "fix_ops_cnt": 15, "bug_source_code": "#![allow(unused_imports)]\n#![allow(non_snake_case)]\n\nuse std::cmp::{max, min, Ordering};\nuse std::collections::*;\nuse std::fmt::{Debug, Formatter};\nuse std::io::*;\nuse std::ops::*;\nuse std::*;\n\n// -----------------------------------------------\n// Framework\n// -----------------------------------------------\n\n#[allow(unused_macros)]\nmacro_rules! read {\n ([$t:ty] ; $n:expr) =>\n ((0..$n).map(|_| read!([$t])).collect::>());\n ($($t:ty),+ ; $n:expr) =>\n ((0..$n).map(|_| read!($($t),+)).collect::>());\n ([$t:ty]) =>\n (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>());\n ($t:ty) =>\n (rl().parse::<$t>().unwrap());\n ($($t:ty),*) => {{\n let buf = rl();\n let mut w = buf.split_whitespace();\n ($(w.next().unwrap().parse::<$t>().unwrap()),*)\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($arg:expr),*) => {\n #[cfg(debug_assertions)]\n {\n let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];\n stderr().write_fmt(format_args!(\"{:#?}\\n\", entries)).unwrap();\n }\n };\n}\n\n#[allow(dead_code)]\nfn rl() -> String {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim_right().to_owned()\n}\n\ntrait IteratorExt: Iterator + Sized {\n fn vec(self) -> Vec {\n self.collect()\n }\n}\n\nimpl IteratorExt for T {}\n\n// -----------------------------------------------\n// Solution\n// -----------------------------------------------\n\npub fn main() {\n let n = read!(i64);\n let k = read!(i64);\n let A = read!(i64);\n let B = read!(i64);\n\n let mut x = n;\n let mut s = 0;\n while n > 1 {\n if x < k {\n s += (x - 1) * A;\n break;\n }\n\n let r = x % k;\n if r != 0 {\n x -= r;\n s += r * A;\n continue;\n }\n\n let q = x / k;\n s += min((x - q) * A, B);\n x = q;\n }\n\n println!(\"{}\", s);\n return;\n}\n", "lang": "Rust", "bug_code_uid": "ffe4c35e232d2cb30f9963991b136c71", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "apr_id": "33a1d8aa5ed65d180806360cb2bbeb2f", "difficulty": 1400, "tags": ["dp", "greedy"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9957507082152974, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let n = getint();\n let k = getint();\n let a = getint();\n let b = getint();\n\n println!(\"{}\",find_min_cost(n,k,a,b,0));\n}\n\nfn getint() -> i64 {\n let mut inpstr = String::new();\n io::stdin().read_line(&mut inpstr).expect(\"Could not read integer\");\n let number = inpstr.trim().parse::();\n\n number.unwrap()\n\n}\n\n\nfn find_min_cost(n : i64, k: i64, a : i64, b : i64, acc: i64) -> i64 {\n if n == 1 {\n return acc;\n }\n\n let rem = n%k;\n\n if rem != 0 {\n return find_min_cost(n - rem, k, a, b, acc+ a*rem);\n }\n\n let quo = n/k;\n\n if quo*a + b < n*a {\n return find_min_cost(quo, k, a, b, acc+ b);\n }\n\n (n-1)*a\n}", "lang": "Rust", "bug_code_uid": "ca64f353d4fdcc06dd1183e14dcdb919", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "apr_id": "81a4c26696755305d09903bbf1b0a88b", "difficulty": 1400, "tags": ["dp", "greedy"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6136485760343902, "equal_cnt": 10, "replace_cnt": 7, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 9, "bug_source_code": "fn main() {\n let mut input = String::new();\n use std::io::prelude::*;\n use std::io;\n io::stdin().read_to_string(&mut input).unwrap();\n\n let mut it = input.split_whitespace();\n\n let n: u64 = it.next().unwrap().parse().unwrap();\n let k: u64 = it.next().unwrap().parse().unwrap();\n let a: u64 = it.next().unwrap().parse().unwrap();\n let b: u64 = it.next().unwrap().parse().unwrap();\n\n let mut x = n;\n\n let mut ans = 0;\n\n loop {\n let rem = x % k;\n if rem > 0 {\n x -= rem;\n ans += rem * a;\n } else {\n let q = x / k;\n let y = std::cmp::min((k - 1) * q * a, b);\n\n ans += y;\n x = q;\n }\n if x == 1 {\n println!(\"{}\", ans);\n break;\n } else if x == 0 {\n println!(\"{}\", ans - a);\n break;\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "f76ba36f2126eb6b4cfdb37d8913f5e4", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "apr_id": "8343dfc76a42c1d7370648bb62bedd03", "difficulty": 1400, "tags": ["dp", "greedy"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9397460145906512, "equal_cnt": 21, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 16, "fix_ops_cnt": 20, "bug_source_code": "use std::io;\nuse std::io::Stdin;\nuse std::str::FromStr;\n\nfn read_line(stdin : &Stdin, line : &mut String) {\n match stdin.read_line(line) {\n Ok(_) => return,\n Err(msg) => panic!(\"Could not read line! Message: {}.\", msg),\n }\n}\n\nfn parse_t(s : &str) -> T {\n match s.trim().parse() {\n Ok(y) => y,\n Err(_) => panic!(\"Could not read from string!\"),\n }\n}\n\nfn read_t(stdin : &Stdin) -> T {\n let mut line = String::new();\n read_line(stdin, &mut line);\n parse_t(&line)\n}\n\nfn read_ts(stdin : &Stdin, ts : &mut Vec) {\n let mut line = String::new();\n read_line(stdin, &mut line);\n let word_iter = line.split_whitespace();\n for word in word_iter {\n let x = parse_t(word);\n ts.push(x);\n }\n}\n\nfn cost_to_one(n : u64, k : u64, a : u64, b : u64) -> u64 {\n let mut c = 0;\n let mut x = n;\n loop {\n if x < 1 {\n panic!(\"x is less than 1!\");\n } else if x == 1 {\n break;\n } else if x < k {\n c = c + (a * (x - 1));\n x = 1;\n } else {\n let q = x / k;\n let r = x % k;\n let cost_div = b;\n let cost_sub = a * ((q * k) - q);\n if r == 0 {\n if cost_div <= cost_sub {\n c = c + cost_div;\n } else {\n c = c + cost_sub;\n }\n x = q;\n } else {\n c = c + (r * a);\n x = x - r;\n }\n }\n }\n c\n}\n\nfn main() {\n let stdin = io::stdin();\n let n = read_t(&stdin);\n let k = read_t(&stdin);\n let a = read_t(&stdin);\n let b = read_t(&stdin);\n println!(\"{}\", cost_to_one(n, k, a, b));\n}\n", "lang": "Rust", "bug_code_uid": "ec15b20c5a56a4fc1817aa23d86af520", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "apr_id": "d956efa9d2821655df10cf531f66ea3d", "difficulty": 1400, "tags": ["dp", "greedy"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9551627906976744, "equal_cnt": 10, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 9, "bug_source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n// use proconio::input;\nuse std::cmp::Ordering::*;\nuse std::collections::{BTreeMap, BTreeSet};\nuse std::io::{self, BufWriter, Write};\nuse std::str::{self, SplitAsciiWhitespace};\n\n// I have no idea what I'm doing\n\nmacro_rules! answer {\n ($out:ident, $ans:expr) => {\n writeln!($out, \"{}\", $ans)\n };\n}\n\nfn 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: i64 = scan.token();\n let mut ans: i64 = n + 1;\n\n for d in (2..=n).take_while(|d| d * d <= n) {\n if n % d == 0 {\n let p = n / d;\n ans = ans.min(d + p);\n }\n }\n\n answer!(out, ans)\n}\n\n///////////////////////////////////////////////////////////////////////////////////////////////////\n\n/// Mostly 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 [Scanner]\");\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\n// aka #![feature(bool_to_option)]\ntrait BoolThen {\n fn then_(self, f: impl FnOnce() -> T) -> Option;\n}\n\nimpl BoolThen for bool {\n fn then_(self, f: impl FnOnce() -> T) -> Option {\n if self {\n Some(f())\n } else {\n None\n }\n }\n}\n\ntrait BoolToYes {\n fn yes(self) -> &'static str;\n}\n\nimpl BoolToYes for bool {\n fn yes(self) -> &'static str {\n if self {\n \"YES\"\n } else {\n \"NO\"\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "94ccb9e392c72d85d0beaaac1a3009bc", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "apr_id": "c618b1a650b52f165858b8ae94d644bd", "difficulty": 1100, "tags": ["math", "constructive algorithms", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8974261922785768, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 7, "bug_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 n: u64,\n }\n let mut i = 1;\n while i * i <= 1_000_000_000 {\n if i * i == n {\n println!(\"{}\", i * 2);\n return;\n }\n if i * i > n {\n if n <= i * (i - 1) {\n println!(\"{}\", i * 2 - 1);\n } else {\n println!(\"{}\", i * 2);\n }\n return;\n }\n i += 1;\n }\n}", "lang": "Rust", "bug_code_uid": "7729f5424cd516c1f4807fe4843b94d6", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "apr_id": "f251e351c4afe33644edc18f0d9803e0", "difficulty": 1100, "tags": ["math", "constructive algorithms", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7598566308243727, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 5, "bug_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 v = input.trim().chars().collect::>();\n\n if v.len() % 2 == 0 {\n println!(\"CHAT WITH HER!\");\n } else {\n println!(\"IGNORE HIM!\");\n }\n}", "lang": "Rust", "bug_code_uid": "da89aa77ca2451c5c918430ac9e120fe", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "apr_id": "89475667b3d211c5d301ff40e10b7c3a", "difficulty": 800, "tags": ["strings", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9988193624557261, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut name = String::new();\n io::stdin().read_line(&mut name).expect(\"Error\");\n let mut name_vector: Vec:: = name.trim().chars().collect();\n name_vector.sort();\n name_vector.dedup();\n let char_count = &name_vector.iter().count();\n let even = char_count % 2;\n if even == 0 {\n println!(\"CHAT WITH HERE!\");\n } else {\n println!(\"IGNORE HIM!\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "00d1b560e33c20a99daef42c290dbb72", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "apr_id": "593dde8909f9eb1bcccd4089c87e337e", "difficulty": 800, "tags": ["strings", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.988734835355286, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "//spnauti-rusT {{{\nuse std::io::*; use std::str::{self,*}; use std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)] macro_rules! min {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! max {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};\n\t($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};\n\t(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};\n}\n#[allow(unused_macros)] macro_rules! v {\n\t([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};\n\t([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: 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\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tlet n = rin.u();\n\tl!(x,y = rin.l());\n\tlet mut dp = v!([n+1]);\n\tdp.push(x);\n\tdp.push(x);\n\tfor i in 2..=n {\n\t\tlet z = dp[i-1] + x;\n\t\tdp.push(z);\n\t\tif i & 1 == 0 {\n\t\t\tmin!(dp[i], dp[i>>1] + y);\n\t\t}\n\t}\n\twriteln!(rout, \"{}\", dp[n]).ok();\n}\n", "lang": "Rust", "bug_code_uid": "533c8b025057a819c0b6860e80b877b2", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "apr_id": "e16a2c201947f2c60c9fc2e77050f3c8", "difficulty": 2000, "tags": ["dp", "dfs and similar"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.1763819095477387, "equal_cnt": 54, "replace_cnt": 40, "delete_cnt": 4, "insert_cnt": 9, "fix_ops_cnt": 53, "bug_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 solve(dp : &mut Vec, n : usize, x : u64, y : u64) -> u64 {\n if n == 0 {\n 0u64\n } else if n == 1 {\n x\n } else if dp[n] != 0 {\n dp[n]\n } else {\n let just_add = solve(dp, n-1, x, y) + x;\n let double_and_add = solve(dp, (n-1)/2, x, y) + x + y;\n let best = min(just_add, double_and_add);\n dp[n] = best;\n best\n }\n}\n\nfn main() {\n let mut s = Scanner::new();\n let n : usize = s.next();\n let x : u64 = s.next();\n let y : u64 = s.next();\n\n\n let mut dp : Vec = Vec::with_capacity(n + 1);\n dp.resize(n + 1, 0);\n\n println!(\"{}\", solve(&mut dp, n, x, y));\n}\n", "lang": "Rust", "bug_code_uid": "33ce11f7c4024a69aa985ae6ea3e342f", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "apr_id": "20b33c3b75daf62c96adc96a1ee0dcea", "difficulty": 2000, "tags": ["dp", "dfs and similar"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.1875, "equal_cnt": 59, "replace_cnt": 48, "delete_cnt": 3, "insert_cnt": 7, "fix_ops_cnt": 58, "bug_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 solve(dp : &mut Vec, n : usize, x : u64, y : u64) -> u64 {\n if n == 0 {\n 0u64\n } else if n == 1 {\n x\n } else if dp[n] != 0 {\n dp[n]\n } else {\n let just_add = solve(dp, n-1, x, y) + x;\n let just_double = solve(dp, n/2, x, y) + y;\n let double_and_add = solve(dp, (n-1)/2, x, y) + x + y;\n let double_and_delete = solve(dp, (n+1)/2, x, y) + x + y;\n let mut best = min(just_add, min(double_and_add, double_and_delete));\n if n % 2 == 0 {\n best = min(best, just_double);\n }\n dp[n] = best;\n best\n }\n}\n\nfn main() {\n let mut s = Scanner::new();\n let n : usize = s.next();\n let x : u64 = s.next();\n let y : u64 = s.next();\n\n\n let mut dp : Vec = Vec::with_capacity(n + 1);\n dp.resize(n + 1, 0);\n\n println!(\"{}\", solve(&mut dp, n, x, y));\n}\n", "lang": "Rust", "bug_code_uid": "c0ad5cd47e2ffa6c625a785e3ee7be29", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "apr_id": "20b33c3b75daf62c96adc96a1ee0dcea", "difficulty": 2000, "tags": ["dp", "dfs and similar"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8059053408597482, "equal_cnt": 4, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_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": "Rust", "bug_code_uid": "1c278f4f3c4b48829ee05456a91784f8", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "apr_id": "d6dd722f34759e82c392aeecdc317d82", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9942983262828766, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_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 n: usize,\n a: [i64; n],\n }\n let mut can = false;\n for bit in 0..1< {{\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 = parse_input!(usize);\n let b = parse_input!(usize);\n let c = parse_input!(usize);\n let mut m = vec![a, b, c];\n m.sort();\n m.reverse();\n while *m.last().unwrap() == 1 {\n let p = m.pop().unwrap();\n *m.last_mut().unwrap() += p;\n }\n let mut ans = 1;\n for p in m {\n ans *= p;\n }\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "dc7d9a9fe09e687cf63b8e50417909f4", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "bd4c96751fd784eeec542c345442373f", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9932038834951457, "equal_cnt": 5, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut a = String::new();\n let mut b = String::new();\n let mut c = String::new();\n\n io::stdin().read_line(&mut a).unwrap();\n io::stdin().read_line(&mut b).unwrap();\n io::stdin().read_line(&mut c).unwrap();\n\n let a: u8 = a.trim().parse().unwrap();\n let b: u8 = b.trim().parse().unwrap();\n let c: u8 = c.trim().parse().unwrap();\n\n let mut max_value = 0;\n\n if (a + b + c) > max_value {\n max_value = a + b + c;\n } \n if (a * b * c) > max_value {\n max_value = a * b * c;\n }\n if (a * b + c) > max_value {\n max_value = a * b + c;\n }\n if (a + b * c) > max_value {\n max_value = a + b * c;\n }\n\n if ((a + b) * c) > max_value {\n max_value = (a + b) * c;\n }\n if (a * (b + c)) > max_value {\n max_value = a * (b + c);\n }\n\n if (a + (b * c)) > max_value {\n max_value = a + (b * c);\n }\n if ((a * b) + c) > max_value {\n max_value = (a * b) + c;\n }\n\n println!(\"{}\", max_value);\n}\n\n\n", "lang": "Rust", "bug_code_uid": "f94fe139324e900dd961db8caa06e0ef", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "apr_id": "92bb05fcf05939a8b5be9604fc22f880", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9996809189534142, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use crate::mod_int::ModInt;\n\nconst MOD: u64 = 998244353;\n\nfn main() {\n let (r, w) = (std::io::stdin(), std::io::stdout());\n let mut sc = IO::new(r.lock(), w.lock());\n let n: u64 = sc.read();\n let m: u64 = sc.read();\n\n let comb = Combination::new(m, MOD);\n if n == 2 {\n println!(\"{}\", m);\n return;\n }\n let c = mint(comb.get(m, n - 1));\n let ans = c * (n - 2) * mint(2).pow(n - 3);\n println!(\"{}\", ans.value());\n}\n\nfn mint(v: u64) -> ModInt {\n ModInt::new(v, MOD)\n}\npub mod mod_int {\n use std::ops::{\n Add, AddAssign, BitAnd, Div, DivAssign, Mul, MulAssign, RemAssign, ShrAssign, Sub,\n SubAssign,\n };\n\n pub struct ModInt {\n v: T,\n m: T,\n }\n\n impl ModInt\n where\n T: Copy,\n {\n pub fn value(&self) -> T {\n self.v\n }\n pub fn modulo(&self) -> T {\n self.m\n }\n }\n\n impl ModInt {\n fn new_unchecked(v: T, modulo: T) -> Self {\n Self { v, m: modulo }\n }\n }\n\n impl ModInt\n where\n T: Copy + RemAssign + PartialOrd,\n {\n pub fn new(mut v: T, modulo: T) -> Self {\n if v >= modulo {\n v %= modulo;\n }\n Self::new_unchecked(v, modulo)\n }\n }\n\n impl ModInt\n where\n T: Copy\n + Sub\n + ShrAssign\n + BitAnd\n + PartialEq\n + PartialOrd\n + Div\n + RemAssign,\n ModInt: MulAssign,\n {\n pub fn pow(self, e: T) -> Self {\n let zero = self.modulo() - self.modulo();\n let one = self.modulo() / self.modulo();\n let mut e = e;\n let mut result = Self::new_unchecked(one, self.modulo());\n let mut cur = self;\n while e > zero {\n if e & one == one {\n result *= cur;\n }\n e >>= one;\n cur *= cur;\n }\n result\n }\n }\n\n impl Copy for ModInt where T: Copy {}\n impl Clone for ModInt\n where\n T: Copy,\n {\n fn clone(&self) -> Self {\n Self::new_unchecked(self.value(), self.modulo())\n }\n }\n\n impl Add for ModInt\n where\n T: AddAssign + SubAssign + RemAssign + Copy + PartialOrd,\n {\n type Output = Self;\n fn add(self, mut rhs: T) -> Self::Output {\n if rhs >= self.modulo() {\n rhs %= self.modulo();\n }\n rhs += self.value();\n if rhs >= self.modulo() {\n rhs -= self.modulo();\n }\n Self::new_unchecked(rhs, self.modulo())\n }\n }\n\n impl Sub for ModInt\n where\n T: AddAssign + SubAssign + RemAssign + Copy + PartialOrd,\n {\n type Output = Self;\n fn sub(self, mut rhs: T) -> Self::Output {\n if rhs >= self.modulo() {\n rhs %= self.modulo();\n }\n\n let mut result = self.value();\n result += self.modulo();\n result -= rhs;\n\n if result >= self.modulo() {\n result -= self.modulo();\n }\n Self::new_unchecked(result, self.modulo())\n }\n }\n\n impl Mul for ModInt\n where\n T: MulAssign + RemAssign + Copy + PartialOrd,\n {\n type Output = Self;\n fn mul(self, mut rhs: T) -> Self::Output {\n if rhs >= self.modulo() {\n rhs %= self.modulo();\n }\n rhs *= self.value();\n rhs %= self.modulo();\n Self::new_unchecked(rhs, self.modulo())\n }\n }\n\n impl Add> for ModInt\n where\n T: Copy,\n ModInt: Add>,\n {\n type Output = Self;\n fn add(self, rhs: ModInt) -> Self::Output {\n self + rhs.value()\n }\n }\n impl Sub> for ModInt\n where\n T: Copy,\n ModInt: Sub>,\n {\n type Output = Self;\n fn sub(self, rhs: ModInt) -> Self::Output {\n self - rhs.value()\n }\n }\n impl Mul> for ModInt\n where\n T: Copy,\n ModInt: Mul>,\n {\n type Output = Self;\n fn mul(self, rhs: ModInt) -> Self::Output {\n self * rhs.value()\n }\n }\n impl Div> for ModInt\n where\n T: Copy,\n ModInt: Div>,\n {\n type Output = Self;\n fn div(self, rhs: ModInt) -> Self::Output {\n self / rhs.value()\n }\n }\n\n impl AddAssign for ModInt\n where\n T: Copy,\n ModInt: Add>,\n {\n fn add_assign(&mut self, other: T) {\n *self = *self + other;\n }\n }\n impl AddAssign> for ModInt\n where\n T: Copy,\n ModInt: Add, Output = ModInt>,\n {\n fn add_assign(&mut self, other: ModInt) {\n *self = *self + other;\n }\n }\n\n impl SubAssign for ModInt\n where\n T: Copy,\n ModInt: Sub>,\n {\n fn sub_assign(&mut self, other: T) {\n *self = *self - other;\n }\n }\n\n impl SubAssign> for ModInt\n where\n T: Copy,\n ModInt: Sub, Output = ModInt>,\n {\n fn sub_assign(&mut self, other: ModInt) {\n *self = *self - other;\n }\n }\n\n impl DivAssign for ModInt\n where\n T: Copy,\n ModInt: Div>,\n {\n fn div_assign(&mut self, rhs: T) {\n *self = *self / rhs\n }\n }\n impl DivAssign> for ModInt\n where\n T: Copy,\n ModInt: Div, Output = ModInt>,\n {\n fn div_assign(&mut self, rhs: ModInt) {\n *self = *self / rhs\n }\n }\n\n impl MulAssign for ModInt\n where\n T: Copy,\n ModInt: Mul>,\n {\n fn mul_assign(&mut self, rhs: T) {\n *self = *self * rhs;\n }\n }\n\n impl MulAssign> for ModInt\n where\n T: Copy,\n ModInt: Mul, Output = ModInt>,\n {\n fn mul_assign(&mut self, rhs: ModInt) {\n *self = *self * rhs;\n }\n }\n\n impl Div for ModInt\n where\n T: Copy\n + Add\n + Sub\n + Div\n + BitAnd\n + PartialEq\n + PartialOrd\n + ShrAssign\n + RemAssign\n + MulAssign,\n {\n type Output = Self;\n fn div(self, mut rhs: T) -> Self::Output {\n if rhs >= self.modulo() {\n rhs %= self.modulo();\n }\n let one = self.modulo() / self.modulo();\n let two = one + one;\n self * Self::new_unchecked(rhs, self.modulo()).pow(self.modulo() - two)\n }\n }\n}\n\npub struct Combination {\n fact: Vec,\n inv_fact: Vec,\n modulo: u64,\n}\n\nimpl Combination {\n pub fn new(max: u64, modulo: u64) -> Self {\n let mut inv = vec![0; max as usize + 1];\n let mut fact = vec![0; max as usize + 1];\n let mut inv_fact = vec![0; max as usize + 1];\n inv[1] = 1;\n for i in 2..(max + 1) {\n inv[i as usize] = inv[(modulo % i) as usize] * (modulo - modulo / i) % modulo;\n }\n fact[0] = 1;\n inv_fact[0] = 1;\n for i in 0..max {\n fact[i as usize + 1] = fact[i as usize] * (i + 1) % modulo;\n }\n for i in 0..max {\n inv_fact[i as usize + 1] = inv_fact[i as usize] * inv[i as usize + 1] % modulo;\n }\n Self {\n fact,\n inv_fact,\n modulo,\n }\n }\n\n pub fn get(&self, x: u64, y: u64) -> u64 {\n assert!(x >= y);\n self.fact[x as usize] * self.inv_fact[y as usize] % self.modulo\n * self.inv_fact[x as usize - y as usize]\n % self.modulo\n }\n}\n\npub struct IO(R, std::io::BufWriter);\n\nimpl IO {\n pub fn new(r: R, w: W) -> Self {\n Self(r, std::io::BufWriter::new(w))\n }\n pub fn write(&mut self, s: S) {\n use std::io::Write;\n self.1.write_all(s.to_string().as_bytes()).unwrap();\n }\n pub fn read(&mut self) -> T {\n use std::io::Read;\n let buf = self\n .0\n .by_ref()\n .bytes()\n .map(|b| b.unwrap())\n .skip_while(|&b| b == b' ' || b == b'\\n' || b == b'\\r' || b == b'\\t')\n .take_while(|&b| b != b' ' && b != b'\\n' && b != b'\\r' && b != b'\\t')\n .collect::>();\n unsafe { std::str::from_utf8_unchecked(&buf) }\n .parse()\n .ok()\n .expect(\"Parse error.\")\n }\n pub fn vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read()).collect()\n }\n pub fn chars(&mut self) -> Vec {\n self.read::().chars().collect()\n }\n}\n", "lang": "Rust", "bug_code_uid": "c1ac4f4931aa20c73554c2caf08ed6cb", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "apr_id": "590d68a567575d2971cfab5ffe069c6e", "difficulty": 1700, "tags": ["math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9830729166666666, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 necklace: Vec<_> = input.trim().chars().map(|c| {\n match c {\n '-' => Elem::Link,\n 'o' => Elem::Pearl,\n _ => panic!(\"Invalid input\"),\n }\n }).collect();\n\n let link_pearl_sums = necklace.iter().fold((0, 0), |acc, &e| {\n match e {\n Elem::Link => (acc.0 + 1, acc.1),\n Elem::Pearl => (acc.0, acc.1 + 1),\n }\n });\n\n let ans = link_pearl_sums.0 % link_pearl_sums.1 == 0;\n\n if ans {\n println!(\"YES\");\n } else {\n println!(\"NO\");\n }\n}\n\n#[derive(Clone, Copy)]\nenum Elem {\n Link,\n Pearl\n}\n", "lang": "Rust", "bug_code_uid": "38f6c70a47e078d7b6ee4ecf0aa5ebe2", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "apr_id": "806c3038e7fa0ea01afc6c5a3624b772", "difficulty": 900, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8973384030418251, "equal_cnt": 7, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\n\n#[cfg(debug_assertions)]\nmacro_rules! debug_println {\n ($( $args:expr ),*) => { println!( $( $args ),* ); }\n}\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let (l, p) = buf.chars().fold((0, 0), |mut cnt, v| {\n match v {\n '-' => cnt.0 += 1,\n 'o' => cnt.1 += 1,\n _ => (),\n }\n cnt\n });\n debug_println!(\"{:?}\", (l, p));\n println!(\"{}\", if l % p == 0 { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "ed66af9d925651b1b4bf98d841217bd8", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "apr_id": "645337ac06a9d3c16e3211b3126cea93", "difficulty": 900, "tags": ["math", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9621212121212122, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nmacro_rules! debug_println {\n ($( $args:expr ),*) => { if cfg!(debug_assertions) { println!( $( $args ),* ); }}\n}\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let (l, p) = buf.chars().fold((0, 0), |mut cnt, v| {\n match v {\n '-' => cnt.0 += 1,\n 'o' => cnt.1 += 1,\n _ => (),\n }\n cnt\n });\n debug_println!(\"{:?}\", (l, p));\n println!(\"{}\", if l % p == 0 { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "8385b13fe0c1cc6ba2d2374f6d085dd7", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "apr_id": "645337ac06a9d3c16e3211b3126cea93", "difficulty": 900, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.995239174790297, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "//spnauti-rusT {{{\nuse std::io::*; use std::str::{self,*}; use std::fmt::Debug;\n#[allow(unused_imports)] use std::cmp::Ordering::{self,*};\n#[allow(unused_imports)] use std::ops::{self,*};\n#[allow(unused_imports)] use std::iter::{self,*};\n#[allow(unused_imports)] use std::collections::*;\n#[allow(unused_imports)] use std::cell::*;\n#[allow(unused_macros)] macro_rules! min {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b < *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! max {\n\t($x:expr,$y:expr) => {{ let b=$y; let a=&mut$x; if b > *a {*a=b; true} else {false} }};\n}\n#[allow(unused_macros)] macro_rules! l {\n\t($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};\n\t($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};\n\t(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};\n}\n#[allow(unused_macros)] macro_rules! v {\n\t([$d:expr]$($s:tt)+) => {vec![v!($($s)+);$d]};\n\t([]) => {Vec::new()}; ([$e:expr]) => {Vec::with_capacity($e)}; (=$e:expr) => {$e};\n}\n#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }\n#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }\n#[allow(dead_code)] fn writer() -> BufWriter { BufWriter::new(stdout()) }\nstruct WordReaderC {buf: Vec, pos: usize, q: std::io::StdinLock<'static>}//'\n#[allow(dead_code)] impl WordReaderC {\n\tfn new() -> Self {\n\t\tlet r = unsafe {&*Box::into_raw(Box::new(stdin()))};\n\t\tSelf { q: r.lock(), buf: v!([]), pos: 0 }\n\t}\n\tfn next_line(&mut self) -> bool {\n\t\tself.buf.clear(); self.pos = 0;\n\t\tself.q.read_until(b'\\n', &mut self.buf).unwrap_or(0) > 0\n\t}\n\tfn is_ws(c: u8) -> bool {\n\t\tc == b' ' || c == b'\\r' || c == b'\\n' || c == b'\\t'\n\t}\n\tfn byte(&mut self) -> Option {\n\t\tif self.pos == self.buf.len() { if !self.next_line() { return None; } }\n\t\tself.pos += 1; Some(self.buf[self.pos - 1])\n\t}\n\tfn vb(&mut self) -> Vec {\n\t\tlet mut s = v!([8]);\n\t\tlet mut f = false;\n\t\tloop {\n\t\t\tif let Some(c) = self.byte() {\n\t\t\t\tif !Self::is_ws(c) {\n\t\t\t\t\ts.push(c);\n\t\t\t\t\tf = true;\n\t\t\t\t} else if f { break; }\n\t\t\t} else { break; }\n\t\t}\n\t\ts\n\t}\n\tfn board(&mut self, r: usize, c: Option) -> Vec> {\n\t\tlet mut res = v!([r]);\n\t\tlet c = c.unwrap_or(0);\n\t\trep!{[r]\n\t\t\tlet t = self.vb();\n\t\t\tassert!(c == 0 || t.len() == c);\n\t\t\tres.push(t);\n\t\t}\n\t\tres\n\t}\n\tfn framed_board(&mut self, r: usize, c: usize, f: u8) -> Vec> {\n\t\tlet mut res = v!([r+2]);\n\t\tres.push( v!([c+2] = f) );\n\t\trep!{[r]\n\t\t\tlet mut t = self.vb();\n\t\t\tassert!(t.len() == c);\n\t\t\tt.reserve(2);\n\t\t\tt.insert(0,f);\n\t\t\tt.push(f);\n\t\t\tres.push(t);\n\t\t}\n\t\tres.push( v!([c+2] = f) );\n\t\tres\n\t}\n\tfn s(&mut self) -> String { String::from_utf8(self.vb()).expect(\"invalid utf8\") }\n\tfn i(&mut self) -> i32 { self.p() }\n\tfn l(&mut self) -> i64 { self.p() }\n\tfn u(&mut self) -> usize { self.p() }\n\tfn f(&mut self) -> f64 { self.p() }\n\tfn vi(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vl(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn vu(&mut self, n: usize) -> Vec { self.vp(n) }\n\tfn ii(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn iu(&mut self, n: usize) -> impl Iterator { self.ip(n).into_iter() }\n\tfn p(&mut self) -> T where T::Err: Debug {\n\t\tlet w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::().unwrap()\n\t}\n\tfn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n\t\t(0..n).map(|_|self.p()).collect()\n\t}\n\tfn ip(&mut self, n: usize) -> impl Iterator where T::Err: Debug {\n\t\tself.vp(n).into_iter()\n\t}\n\tfn graph(&mut self, n: usize, m: usize) -> Vec> {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); e[a].push(b); e[b].push(a); } e\n\t}\n\tfn graph_w(&mut self, n: usize, m: usize) -> Vec> where T::Err: Debug {\n\t\tlet mut e = v!([n][]); rep!{[m] l!(a,b = self.u()-1); let c: T = self.p(); e[a].push((b,c)); e[b].push((a,c)); } e\n\t}\n}\n//------------------- End rusT }}}\n\nfn main() {\n\tlet mut rin = reader();\n\tlet mut rout = writer();\n\n\tlet b = rin.l();\n\tlet s = rin.vb();\n\tlet n = s.len();\n\tlet mut dp = v!([n+1] = std::i64::MAX);\n\tdp[0] = 0;\n\tfor i in 0..n {\n\t\tlet mut x = 0;\n\t\tfor j in i..n {\n\t\t\tx = x * 10 + (s[j] - b'0') as i64;\n\t\t\tif (s[i] == b'0' && j > i) || x >= b {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmin!(dp[j+1], dp[i] * b + x);\n\t\t}\n\t}\n\twriteln!(rout, \"{}\", dp[n]).ok();\n}\n", "lang": "Rust", "bug_code_uid": "c181994b3ca16955762c33603822d35b", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "apr_id": "d803a729f9f38af151ecc18745b6342d", "difficulty": 2000, "tags": ["dp", "greedy", "math", "constructive algorithms", "strings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7906666666666666, "equal_cnt": 15, "replace_cnt": 7, "delete_cnt": 3, "insert_cnt": 4, "fix_ops_cnt": 14, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::*;\n#[allow(dead_code)]\nfn getline() -> String {\n let mut ret = String::new();\n std::io::stdin().read_line(&mut ret).ok();\n return 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.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {\n break;\n } else {\n buf.push(u8b[0]);\n }\n }\n if buf.len() >= 1 {\n let ret = std::string::String::from_utf8(buf).unwrap();\n return ret;\n }\n }\n}\nfn parse(s: &str) -> T { s.parse::().ok().unwrap() }\n\n#[allow(dead_code)]\nfn get() -> T { parse(&get_word()) }\n\nfn numero(v: &[i64], b: i64) -> i64 {\n let mut cur = 0;\n for &t in v.iter() {\n cur *= b;\n cur += t;\n }\n cur\n}\n\nfn main() {\n let b: i64 = get();\n let s: Vec<_> = get_word().bytes().map(|b| b as i64 - 0x30).collect();\n let n = s.len();\n if b <= 9 {\n // simply read b-base rep.\n let mut cur = 0;\n for v in s {\n cur *= b;\n cur += v;\n }\n println!(\"{}\", cur);\n return;\n }\n let mut dp = vec![-1i64; n + 1];\n const INF: i64 = 1i64 << 60;\n dp[0] = 0;\n for i in 1 .. n + 1 {\n let mut mi = INF;\n for j in 1 .. i + 1 {\n // s[i - j ..i] < b ?\n if j >= 10 || dp[i - j] < 0 || (j >= 2 && s[i - j] == 0) ||\n numero(&s[i - j .. i], 10) >= b {\n continue;\n }\n mi = min(mi, b * dp[i - j] + numero(&s[i - j .. i], 10));\n }\n if mi < INF {\n dp[i] = mi;\n }\n }\n println!(\"{}\", dp[n]);\n}\n", "lang": "Rust", "bug_code_uid": "f3efc6c5806e6697a566cb943978c16c", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "apr_id": "eae2aa0f83a387cfae799a8e4347bb80", "difficulty": 2000, "tags": ["dp", "greedy", "math", "constructive algorithms", "strings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9270774448841154, "equal_cnt": 12, "replace_cnt": 6, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "use std::io;\nuse std::mem::swap;\nuse std::str;\n\nfn has_valid_prime_factors(n: i64) -> bool {\n let mut n = n;\n while n % 2 == 0 {\n n /= 2;\n }\n while n % 3 == 0 {\n n /= 3;\n }\n while n % 5 == 0 {\n n /= 5;\n }\n n == 1\n}\n\nfn gcd(a: i64, b: i64) -> i64 {\n if b == 0 {\n a\n } else {\n gcd(b, a % b)\n }\n}\n\nfn factorize(n: i64) -> Vec<(i64, i64)> {\n let mut n = n;\n let mut p = 2;\n let mut ans = Vec::new();\n while p * p <= n && n > 1 {\n let mut expo = 0;\n while n % p == 0 {\n expo += 1;\n n /= p;\n }\n if expo > 0 {\n ans.push((p, expo));\n }\n p += 1;\n }\n if n > 1 {\n ans.push((n, 1));\n }\n ans\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let mut a: i64 = scan.token();\n let mut b: i64 = scan.token();\n if a > b {\n swap(&mut a, &mut b);\n }\n\n // The factorizations of a and b MUST contain only prime factors in {2, 3, 5}.\n if a == b || (has_valid_prime_factors(a) && has_valid_prime_factors(b)) {\n let g = gcd(a, b);\n let factors_without_gcd = factorize(a * b / (g * g));\n let ans = factors_without_gcd.iter().fold(0i64, |acc, val| acc + val.1);\n writeln!(out, \"{}\", ans).ok();\n } else {\n writeln!(out, \"-1\").ok();\n }\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n\n pub fn tokens(&mut self) -> Vec {\n assert!(self.buffer.is_empty());\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n input\n .split_whitespace()\n .map(|x| x.parse().ok().expect(\"Failed parse\"))\n .collect()\n }\n}\n", "lang": "Rust", "bug_code_uid": "b4502dbd8eb8791dc6b8a1097b25706a", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "apr_id": "e1a6735a4230948f326144467c7b5fc8", "difficulty": 1300, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9967377666248431, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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 mut x: i32 = scan.token();\n let m: i32 = scan.token();\n\n let mut seen = vec![false; m as usize];\n\n while x > 0 && !seen[x as usize] {\n seen[x as usize] = true;\n x += x;\n if x >= m {\n x -= m;\n }\n }\n\n writeln!(out, \"{}\", match x {\n 0 => \"Yes\",\n _ => \"No\",\n })?;\n\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "a7d7d69edbcd94ee4741116cfd3ebe2b", "src_uid": "f726133018e2149ec57e113860ec498a", "apr_id": "6ad4476592eb345d06fbda6d70e330ce", "difficulty": 1400, "tags": ["matrices", "math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9989297181591152, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "//spnauti-rust\n#[allow(unused_macros)]\nmacro_rules! a {\n ($c: tt, $x: expr, $y: expr) => {{\n let b = $y; let a = &mut $x;\n if b $c *a { *a = b; true } else { false }\n }};\n}\nuse std::io::*;\nuse std::str::*;\nuse std::fmt::Debug;\nstruct WordReader<'a> { it : SplitAsciiWhitespace<'a>, }\n#[allow(dead_code)]\nimpl<'a> WordReader<'a> {\n fn new(b: &mut String, mut r: T) -> WordReader {\n b.clear();\n r.read_to_string(b).unwrap();\n WordReader { it: b.split_ascii_whitespace() }\n }\n fn from_stdin(b: &mut String) -> WordReader {\n WordReader::new(b, stdin())\n }\n fn sl(&mut self) -> &str { self.it.next().unwrap() }\n fn bs(&mut self) -> &[u8] { self.sl().as_bytes() }\n fn s(&mut self) -> String { String::from(self.sl()) }\n fn i(&mut self) -> i32 { self.p() }\n fn p(&mut self) -> T where T::Err: Debug {\n self.sl().parse::().unwrap()\n }\n fn vp(&mut self, n: usize) -> Vec where T::Err: Debug {\n (0..n).map(|_| self.p()).collect()\n }\n}\n\nfn main() {\n let mut bin = String::new();\n let mut input = WordReader::from_stdin(&mut bin);\n\n let (n,d) = (input.i(), input.i());\n let sum = d - input.vp::(n as usize)\n .into_iter().sum::();\n println!(\"{}\", if sum >= 10 * (n - 1) {\n sum / 10\n } else {\n -1\n });\n}\n\n", "lang": "Rust", "bug_code_uid": "44828f5748ad4e679527b7079a215fad", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "apr_id": "2968cdd648551e44f560383610ada397", "difficulty": 900, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9314285714285714, "equal_cnt": 6, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 5, "bug_source_code": "use std::io;\nuse std::collections::HashMap;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).expect(\"enter value\");\n let charcount:usize = buf.trim().parse::().unwrap();\n buf.clear();\n io::stdin().read_line(&mut buf).expect(\"Enter value\");\n let chars:Vec<_> = buf.chars().collect();\n let mut count = 0;\n let mut keymap: HashMap = HashMap::new();\n for x in 0..charcount{\n if x < chars.len() && chars[x] == chars[x+1] {\n count = count + 1;\n } else {\n if let Some(val) = keymap.get_mut(&chars[x]){\n *val += count;\n } else {\n keymap.insert(chars[x], count);\n }\n count = 0;\n }\n }\n let highvalue = keymap.iter().max_by_key(|entry| entry.1).unwrap();\n println!(\"{:?}\", highvalue.1);\n}", "lang": "Rust", "bug_code_uid": "6639506ec74e475796077ac120c750c4", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "apr_id": "9d04e7c9ef12137d7e073051557749ad", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9862649534780682, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "#![allow(unused_macros)]\n#![allow(unused_mut)]\n\n#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io;\nuse std::io::Write;\nuse std::str;\n#[allow(unused_imports)]\nuse std::prelude::*;\n\n// credit tanakh input macro\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 mut 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\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\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// credit ebtech scanner\npub struct UnsafeScanner {\n reader: R,\n buf_str: Vec,\n buf_iter: str::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\n\nfn solve() {\n #[allow(unused_variables)]\n let (stdin, stdout) = (io::stdin(), io::stdout());\n //let mut scan = UnsafeScanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n\n input! {\n a: usize,\n s: String,\n }\n let mut v = Vec::new();\n for c in s.chars() {\n v.push(c);\n }\n\n if a == 1 { writeln!(out, \"{}\", 0).ok();}\n else {\n let mut op = 0;\n for i in 0..(v.len() - 1) {\n if v[i] != v[i+1] {\n writeln!(out, \"{}\", op).ok();\n return;\n } else {\n op += 1;\n }\n }\n writeln!(out, \"{}\", op).ok();\n }\n\n}\n\n\n// credit kobae964\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}", "lang": "Rust", "bug_code_uid": "194fe64df77967c21ffe155a6c14f191", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "apr_id": "e6cb29213ea4c2c3eff668a2393cc300", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9571150097465887, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let n : i32 = s.trim().parse().unwrap();\n s.clear();\n io::stdin().read_line(&mut s).unwrap();\n s = s.trim().to_string();\n let mut cnt = 0;\n let mut before : char = 'x';\n for (i, c) in s.chars().enumerate() {\n if i == 0 {\n before = c;\n } else if c == before {\n cnt += 1;\n }\n before = c;\n }\n if cnt == n-1 {\n cnt += 1;\n }\n println!(\"{}\", cnt);\n}", "lang": "Rust", "bug_code_uid": "fd8eca96000dbe6918400594fe5bcc55", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "apr_id": "2ac1f4800c90e85cc80ef23d6f9a504f", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9136960600375235, "equal_cnt": 19, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 16, "fix_ops_cnt": 19, "bug_source_code": "fn main() -> std::io::Result<()> {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer)?;\n let index: usize = buffer.trim().parse().unwrap();\n buffer.clear();\n\n std::io::stdin().read_line(&mut buffer)?;\n let mut count: i32 = 0;\n let mut ind: usize = 0;\n for i in 0..index-1 {\n if &buffer[ind..ind+1] == &buffer[i+1..i+2] {\n count += 1;\n continue;\n }\n ind += 1;\n }\n println!(\"{}\", count);\n Ok(())\n}", "lang": "Rust", "bug_code_uid": "2fdd18ea8216d1d2ff02d34aa2ca7351", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "apr_id": "d4d186995fb8b6f034c6368697dcda91", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9910634495084897, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut input = String::new();\n std::io::stdin()\n .read_line(&mut input)\n .expect(\"Value not found\");\n \n let input :usize = match input\n .trim()\n .parse() {\n Ok(num) => num,\n Err(_) => return,\n };\n \n let mut colors = String::new();\n std::io::stdin()\n .read_line(&mut colors)\n .expect(\"Value not found\");\n\n let length = colors.trim().len();\n\n if length != input {\n return ()\n }\n\n let mut count: usize = 0;\n let mut i: usize = 0;\n for _i in colors.chars() {\n if colors.chars().nth(i) == colors.chars().nth(i+1) {\n count += 1;\n i += 1;\n }\n }\n println!(\"{}\", count);\n\n // for i in 0usize..input {\n // }\n\n // for i in colors.chars().next() {\n // match i {\n // => count += 1,\n // _ => return,\n // };\n // }\n // println!(\"{}\", count);\n\n}", "lang": "Rust", "bug_code_uid": "3064e49938ec2e3d2911fb197ea98467", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "apr_id": "164afda9bc54757d19219b757ccf5a1a", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.975609756097561, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 5, "bug_source_code": "fn main() {\n let first_string = string_read();\n let second_string = string_read();\n \n let mut counter: i32 = 0;\n\n let mut first_chars = first_string.chars();\n let mut second_chars = second_string.chars();\n loop {\n match (first_chars.next(), second_chars.next()) {\n (Some(lchar), Some(rchar)) => {\n if lchar < rchar {counter -= 1}\n else if lchar > rchar {counter += 1}\n },\n (_, _) => {break;}\n }\n }\n println!(\"{}\", counter);\n\n\n}\n\nfn string_read() -> String {\n let mut string_buffer = String::new();\n\n std::io::stdin().read_line(&mut string_buffer).unwrap();\n string_buffer.to_uppercase()\n}", "lang": "Rust", "bug_code_uid": "ba918d4fdc24eb442168aa210390cc11", "src_uid": "ffeae332696a901813677bd1033cf01e", "apr_id": "ac51bf261d2af8839623269a8a0c7d4e", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9445005045408678, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::cmp::Ordering;\n\nfn main() {\n let mut line1 = String::new();\n let mut line2 = String::new();\n std::io::stdin().read_line(&mut line1).unwrap();\n std::io::stdin().read_line(&mut line2).unwrap();\n\n line1 = line1.trim().to_lowercase();\n line2 = line2.trim().to_lowercase();\n\n println!(\"{}\", line1);\n println!(\"{}\", line2);\n\n println!(\"{}\",\n match line1.cmp(&line2) {\n Ordering::Less => -1,\n Ordering::Equal => 0,\n Ordering::Greater => 1,\n });\n}", "lang": "Rust", "bug_code_uid": "649b8affe49515eb13d5018980c6cf84", "src_uid": "ffeae332696a901813677bd1033cf01e", "apr_id": "53fa4144db35cc3f38a38a9a68a4396a", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9924170616113744, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "fn main() {\n let mut first_string = String::from(\"\");\n std::io::stdin()\n .read_line(&mut first_string)\n .expect(\"String not found\");\n \n let mut second_string = String::from(\"\");\n std::io::stdin()\n .read_line(&mut second_string)\n .expect(\"String not found\");\n\n if (first_string.len() > 100) || (second_string.len() > 100) {\n return()\n }\n\n if first_string.len() != second_string.len() {\n return ()\n }\n\n let first_string = first_string.to_lowercase();\n let second_string = second_string.to_lowercase();\n\n // let comp1 = first_string.eq(&second_string);\n // let comp2 = second_string.eq(&first_string);\n\n if first_string == second_string { println!(\"0\"); }\n\n else if first_string > second_string { println!(\"1\"); }\n\n else if first_string < second_string { println!(\"-1\"); }\n\n else { return () }\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang": "Rust", "bug_code_uid": "e1a766bf976fc203158398abdcbb82ad", "src_uid": "ffeae332696a901813677bd1033cf01e", "apr_id": "61dc3187f6a327c6f06ea67f6c2e9f3e", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9700598802395209, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_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": "Rust", "bug_code_uid": "92778b5ec4e745eb5045cd3018206895", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "apr_id": "d3ae1b6745f7c260525575bf495c6e3a", "difficulty": 1000, "tags": ["math", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7761767531219981, "equal_cnt": 16, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 10, "fix_ops_cnt": 17, "bug_source_code": "fn c2 (x:i32) -> i64 { let y=x as i64; y * (y-1)/2 }\n\nfn main() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut ints = s.split_whitespace().map(|x| x.parse::().unwrap());\n let n = ints.next().unwrap();\n let t = ints.next().unwrap();\n if n == t {\n println!(\"0 0\");\n } else {\n let max = c2(n - t + 1);\n let mut min = 0;\n let mut m = n;\n for i in (2..=t).rev() {\n min += c2(m/i);\n m-=m/i; \n } \n min += c2(m);\n println!(\"{} {}\",min, max);\n }\n\n}\n\n", "lang": "Rust", "bug_code_uid": "147102dcd02f9dae6eeb31d630fe0152", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "apr_id": "5eee472f3cba0867c1ea0309a41f89ca", "difficulty": 1300, "tags": ["math", "combinatorics", "greedy", "constructive algorithms"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9676832043695949, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan { buffer: std::collections::VecDeque::new() }\n }\n\n fn next(&mut self)-> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let n: u64 = scan.next();\n let m: u64 = scan.next();\n if n == m {\n println!(\"{} {}\", m, m);\n return;\n }\n let maxcalc = (n-m+1) * (n-m) / 2;\n let minval1 = n/m + 1;\n let minval2 = n/m;\n let minn1 = n%m;\n let minn2 = m - minn1;\n let mincalc = (minval1*(minval1-1)/2)*minn1 \n + (minval2*(minval2-1)/2)*minn2;\n println!(\"{} {}\", mincalc, maxcalc);\n}\n\nfn main() {\n std::thread::Builder::new()\n .stack_size(1<<23).spawn(_main).unwrap().join().unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "79d377526b4f02ca0681dc595f36361c", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "apr_id": "2bf7e7106f4ec236878ecbd5378061ac", "difficulty": 1300, "tags": ["math", "combinatorics", "greedy", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9990964943982653, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "//---------- begin SegmentTree Point update Range query ----------\npub trait PURQ {\n type T: Clone;\n fn fold(l: &Self::T, r: &Self::T) -> Self::T;\n fn e() -> Self::T;\n}\n\nstruct SegmentTreePURQ {\n seg: Vec,\n size: usize,\n}\n\n#[allow(dead_code)]\nimpl SegmentTreePURQ {\n fn new(n: usize) -> SegmentTreePURQ {\n let size = n.next_power_of_two();\n SegmentTreePURQ {\n seg: vec![R::e(); 2 * size],\n size: size,\n }\n }\n fn build_by(a: &[R::T]) -> SegmentTreePURQ {\n let size = a.len().next_power_of_two();\n let mut b = vec![R::e(); 2 * size];\n for i in 0..a.len() {\n b[i + size] = a[i].clone();\n }\n let mut seg = SegmentTreePURQ { seg: b, size: size };\n seg.update_all();\n seg\n }\n fn update(&mut self, x: usize, v: R::T) {\n assert!(x < self.size);\n let mut x = x + self.size;\n let a = &mut self.seg;\n a[x] = v;\n x >>= 1;\n while x > 0 {\n a[x] = R::fold(&a[2 * x], &a[2 * x + 1]);\n x >>= 1;\n }\n }\n fn update_tmp(&mut self, x: usize, v: R::T) {\n self.seg[self.size + x] = v;\n }\n fn update_all(&mut self) {\n let a = &mut self.seg;\n for i in (1..self.size).rev() {\n a[i] = R::fold(&a[2 * i], &a[2 * i + 1]);\n }\n }\n fn find(&self, l: usize, r: usize) -> R::T {\n assert!(l <= r && r <= self.size);\n let mut x = R::e();\n let mut y = R::e();\n let mut l = l + self.size;\n let mut r = r + self.size;\n let a = &self.seg;\n while l < r {\n if l & 1 == 1 {\n x = R::fold(&x, &a[l]);\n l += 1;\n }\n if r & 1 == 1 {\n r -= 1;\n y = R::fold(&a[r], &y);\n }\n l >>= 1;\n r >>= 1;\n }\n R::fold(&x, &y)\n }\n}\n//---------- end SegmentTree Point update Range query ----------\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\n// C -> AB -> AAC -> AAAB -> B\n// C -> B としていい\n//\n// A -> BB\n// B -> AB\n// AAA -> empty\n//\n// 右端のAのmod 3?\n// 両方操作可能ならそうかも知れんが片方だけしか動かせない\n//\n// B -> AB -> AAB -> AAAB -> B\n// 操作可能な方は操作続けることで\n// B...BA..A みたいにできる\n// Bの数がT以下かつmod2で等しいかつ右端のAの数が一致\n// いや右端のAを操作してBにすること考えると?\n// 差分/2の分だけBに変換する余裕あり\n// AAA -> empty もある\n//\n// WA\n//\n// Bがない場合とか\n//\n// WA\n//\n//\n//\n\nstruct R;\nimpl PURQ for R {\n // B...BA...A\n // でBの数、Aの数\n type T = (usize, usize);\n fn fold(l: &Self::T, r: &Self::T) -> Self::T {\n if r.0 == 0 {\n (l.0, l.1 + r.1)\n } else {\n (l.0 + r.0, r.1)\n }\n }\n fn e() -> Self::T {\n (0, 0)\n }\n}\n\nfn run() {\n input! {\n s: bytes,\n t: bytes,\n q: usize,\n ask: [(usize1, usize, usize1, usize); q],\n }\n let mut seg_s = SegmentTreePURQ::::new(s.len());\n for (i, s) in s.iter().enumerate() {\n if *s == b'A' {\n seg_s.update_tmp(i, (0, 1));\n } else {\n seg_s.update_tmp(i, (1, 0));\n }\n }\n seg_s.update_all();\n let mut seg_t = SegmentTreePURQ::::new(t.len());\n for (i, s) in t.iter().enumerate() {\n if *s == b'A' {\n seg_t.update_tmp(i, (0, 1));\n } else {\n seg_t.update_tmp(i, (1, 0));\n }\n }\n seg_t.update_all();\n let mut out = String::new();\n for (a, b, c, d) in ask {\n let ans = || -> bool {\n let (x, y) = seg_s.find(a, b);\n let (z, w) = seg_t.find(c, d);\n let mut ans = false;\n if x == 0 {\n if z > 0 {\n ans |= y > w && z % 2 == 0;\n } else {\n ans |= (y - w) % 3 == 0;\n }\n return ans;\n }\n if z >= x && (z - x) % 2 == 0 && y >= w {\n let d = (z - x) / 2;\n let mut ok = false;\n ok |= (y - w) % 3 == 0;\n ok |= d > 0 && y > w;\n ans |= ok;\n }\n ans\n }();\n if ans {\n out.push('1');\n } else {\n out.push('0');\n }\n }\n println!(\"{}\", out);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "f02b0e78b2e52c92812145a58f0152b5", "src_uid": "98e3182f047a7e7b10be7f207b219267", "apr_id": "4fc40a6a3fb534c25bdbe5bbe297ad19", "difficulty": 2500, "tags": ["strings", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.831447963800905, "equal_cnt": 22, "replace_cnt": 7, "delete_cnt": 8, "insert_cnt": 6, "fix_ops_cnt": 21, "bug_source_code": "// ---------- begin input macro ----------\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n// ---------- end input macro ----------\n\n// 長さ3までしかなさそう\n// 1~3までをそれぞれ数えられればいい\n// 長さ1\n// gcd > 1 なペアの数\n// 長さ2\n// gcd = 1 で最小素因数の積がN 以下なもの\n// 長さ3\n// 最小素因数の積がNを超えるやつ\n// どう数える\n// 1\n// 包除原理でいけるはず\n// 2, 3\n// 最小素因数で分類すればなんとかなる?\n// 2 * p > N な素数は削除しておく\n// 互いに素の条件を扱えてなかった...\n// 最小素因数の積がNを超えてるなら互いに素になる\n// 超えないなら?\n// 事前にメモっておけばいい感じか?\n// ややこしい\n// 最小素因数が異なるかつ積がN以下かつ互いに素じゃないペアの数\n//\n\nfn run() {\n input! {\n n: usize,\n }\n let mut factor = (0..=n).collect::>();\n let mut mobius = vec![1i8; n + 1];\n let mut sub = 0;\n let mut prime = vec![];\n let mut cnt = vec![];\n for i in 2..=n {\n if i == factor[i] {\n prime.push(i);\n let mut c = 0;\n let mut d = 0;\n for j in 1..=(n / i) {\n let p = &mut factor[j * i];\n if i <= *p {\n *p = i;\n c += 1;\n } else {\n d += 1;\n }\n mobius[j * i] *= -1;\n }\n sub += c * d;\n cnt.push(c);\n let pp = i.saturating_mul(i);\n for j in 1..=(n / pp) {\n mobius[j * pp] = 0;\n }\n }\n }\n let mut ans = 0i64;\n for (i, mobius) in mobius.iter().enumerate().skip(2) {\n let s = *mobius as i64;\n if s != 0 {\n let cnt = (n / i) as i64;\n ans -= cnt * (cnt - 1) / 2 * s;\n }\n }\n while prime.last().map_or(false, |p| 2 * *p > n) {\n prime.pop();\n cnt.pop();\n }\n /*\n for (i, (a, x)) in cnt.iter().zip(prime.iter()).enumerate() {\n for (b, y) in cnt.iter().zip(prime.iter()).take(i) {\n if *x * *y <= n {\n ans += 2 * *a * *b;\n } else {\n ans += 3 * *a * *b;\n }\n }\n }\n */\n ans -= 2 * sub;\n let mut sum = 0;\n let mut x = 0;\n let mut two = 0;\n for (i, (c, p)) in cnt.iter().zip(prime.iter()).enumerate() {\n while x < i && *p * prime[x] <= n {\n two += cnt[x];\n x += 1;\n }\n while x > 0 && *p * prime[x - 1] > n {\n x -= 1;\n two -= cnt[x];\n }\n ans += two * *c * 2 + (sum - two) * *c * 3;\n sum += *c;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "6031055c5ac107acd34f7da726003685", "src_uid": "bb1bd5d8bab7d79e514281230d484996", "apr_id": "7f3cd5bd3c3711652c20299a5ba14022", "difficulty": 2700, "tags": ["sortings", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9243792325056434, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "use std::io::{stdin, BufRead, Stdin, StdinLock};\n\nfn regular_sequence_exist(num_ll: usize, _num_lr: usize, num_rl: usize, num_rr: usize) -> bool {\n return (num_rl <= 2 * num_ll) && (num_rl <= 2 * num_rr);\n}\n\n#[cfg(test)]\nmod test\n{\n use super::regular_sequence_exist;\n\n #[test]\n fn test1() {\n let (num_ll, num_lr, num_rl, num_rr): (usize, usize, usize, usize) = (3, 1, 4, 3);\n let result: bool = regular_sequence_exist(num_ll, num_lr, num_rl, num_rr);\n assert_eq!(result, true);\n }\n #[test]\n fn test2() {\n let (num_ll, num_lr, num_rl, num_rr): (usize, usize, usize, usize) = (0, 0, 0, 0);\n let result: bool = regular_sequence_exist(num_ll, num_lr, num_rl, num_rr);\n assert_eq!(result, true);\n }\n #[test]\n fn test3() {\n let (num_ll, num_lr, num_rl, num_rr): (usize, usize, usize, usize) = (1, 2, 3, 4);\n let result: bool = regular_sequence_exist(num_ll, num_lr, num_rl, num_rr);\n assert_eq!(result, false);\n }\n}\n\nfn read_data() -> (usize, usize, usize, usize) {\n let stdin_stream: Stdin = stdin();\n let mut stdin_handle: StdinLock = stdin_stream.lock();\n\n let mut data: Vec = Vec::with_capacity(4);\n\n for _ in 0..4 {\n let mut value_str: String = String::new();\n stdin_handle.read_line(&mut value_str).unwrap();\n data.push(value_str.trim().parse::().unwrap());\n }\n\n return (data[0], data[1], data[2], data[3]);\n}\n\nfn main() {\n let (num_ll, num_lr, num_rl, num_rr): (usize, usize, usize, usize) = read_data();\n\n if regular_sequence_exist(num_ll, num_lr, num_rl, num_rr) {\n println!(\"1\");\n } else {\n println!(\"0\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "be4e1fe37e243f142fb5e0bf4cb261bc", "src_uid": "b99578086043537297d374dc01eeb6f8", "apr_id": "c70939edab72e5ea850377e8ed9d2dde", "difficulty": 1100, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9994929006085193, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_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::prelude::BufRead;\n#[allow(unused_imports)]\nuse std::io::{stdin, stdout, BufReader, BufWriter, Write};\n#[allow(unused_imports)]\nuse std::mem::swap;\n#[allow(unused_imports)]\nuse std::str::FromStr;\n\nfn main() {\n let a = read::();\n let b = read::();\n let c = read::();\n let d = read::();\n\n if (c == 0 || (c > 0 && a > 0 && b > 0)) && (2 * a + c) == (2 * d + c) {\n println!(\"1\");\n } else {\n println!(\"0\");\n }\n}\n\n#[allow(dead_code)]\nfn read() -> T\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n let mut buf = String::new();\n stdin().read_line(&mut buf).unwrap();\n return buf.trim().parse().unwrap();\n}\n\n#[allow(dead_code)]\nfn read_vector() -> Vec\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n let mut buf = String::with_capacity(100);\n stdin().read_line(&mut buf).unwrap();\n return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();\n}\n\n#[allow(dead_code)]\nfn read_matrix() -> Vec>\nwhere\n T: std::str::FromStr,\n T::Err: std::fmt::Debug,\n{\n use std::io::prelude::*;\n let stdin = stdin();\n let mut reader = BufReader::with_capacity(100 * 1024, stdin);\n let mut line = String::with_capacity(100);\n let mut matrix: Vec> = Vec::new();\n\n while reader.read_line(&mut line).unwrap() > 0 {\n matrix.push(\n line.trim()\n .split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect(),\n );\n line.clear();\n }\n\n return matrix;\n}\n\n#[allow(dead_code)]\nfn read_chars() -> Vec {\n let stdin = stdin();\n let mut buf = String::new();\n let _bytes = stdin.read_line(&mut buf).unwrap();\n return buf.trim().chars().collect();\n}\n", "lang": "Rust", "bug_code_uid": "3408ace405838a4a09a0bd308cd0ff24", "src_uid": "b99578086043537297d374dc01eeb6f8", "apr_id": "03dc8575ffad287e4461cccb2d16f9d0", "difficulty": 1100, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9646464646464646, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() -> io::Result<()> {\n let mut input = String::new();\n\n let mut v: Vec = vec![];\n\n for _i in 0..4 {\n io::stdin().read_line(&mut input)?;\n v.push(input.trim().parse::().unwrap());\n input.clear();\n }\n\n let mut result = 1;\n if v[0] != v[3] {\n result = 0;\n }\n\n println!(\"{}\", result);\n\n Ok(())\n}", "lang": "Rust", "bug_code_uid": "c3fcce65f9fe7075008ae1e2042cd071", "src_uid": "b99578086043537297d374dc01eeb6f8", "apr_id": "7d08cec58f7802a9eacb1afcf73f7702", "difficulty": 1100, "tags": ["greedy", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.879535990481856, "equal_cnt": 32, "replace_cnt": 13, "delete_cnt": 6, "insert_cnt": 12, "fix_ops_cnt": 31, "bug_source_code": "#![allow(unused_imports)]\nuse std::cmp::Ordering::*;\nuse std::io::{self, BufWriter, Write};\nuse std::str::{self, SplitAsciiWhitespace};\nuse std::collections::{BTreeSet, BTreeMap};\n\n// I have no idea what I'm doing\n\nconst M: i64 = 1_000_000_007;\n\nfn fexp(mut x: i64, mut e: i64) -> i64 {\n let mut ans = 1;\n while e > 0 {\n if e & 1 != 0 {\n ans = ans * x % M;\n }\n\n x = x * x % M;\n\n e >>= 1;\n }\n ans\n}\n\nstruct DSU {\n p: Vec,\n s: Vec,\n}\n\nimpl DSU {\n fn new(n: usize) -> Self {\n Self {\n p: (0..n).collect(),\n s: vec![1; n],\n }\n }\n\n fn find(&mut self, mut i: usize) -> usize {\n while i != self.p[i] {\n self.p[i] = self.p[self.p[i]];\n i = self.p[i];\n }\n i\n }\n\n fn union(&mut self, mut i: usize, mut j: usize) -> usize {\n i = self.find(i);\n j = self.find(j);\n if i == j { return i; }\n let (i, j) = if self.s[i] < self.s[j] { (i, j) } else { (j, i) };\n self.p[i] = j;\n self.s[j] += self.s[j];\n j\n }\n\n fn classes(&self) -> usize {\n self.p.iter().collect::>().len()\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 p: usize = scan.token();\n let k: i64 = scan.token();\n\n let mut dsu = DSU::new(p);\n\n for x in 0..p {\n dsu.union(x, ((k * x as i64) % p as i64) as usize);\n }\n\n writeln!(out, \"{}\", fexp(p as i64, (dsu.classes() - 1) as i64))?;\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": "Rust", "bug_code_uid": "bf3d814ef50d23a0e1dbc46a3afe828b", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "apr_id": "17bab6acc027fb198f4e3887b2d12465", "difficulty": 1800, "tags": ["combinatorics", "dfs and similar", "number theory", "dsu", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9972157508949372, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "// ---------- begin ModInt ----------\nmod modint {\n\n #[allow(dead_code)]\n pub struct Mod;\n impl ConstantModulo for Mod {\n const MOD: u32 = 1_000_000_007;\n }\n\n #[allow(dead_code)]\n pub struct StaticMod;\n static mut STATIC_MOD: u32 = 0;\n impl Modulo for StaticMod {\n fn modulo() -> u32 {\n unsafe { STATIC_MOD }\n }\n }\n\n #[allow(dead_code)]\n impl StaticMod {\n pub fn set_modulo(p: u32) {\n unsafe {\n STATIC_MOD = p;\n }\n }\n }\n\n use std::marker::*;\n use std::ops::*;\n\n pub trait Modulo {\n fn modulo() -> u32;\n }\n\n pub trait ConstantModulo {\n const MOD: u32;\n }\n\n impl Modulo for T\n where\n T: ConstantModulo,\n {\n fn modulo() -> u32 {\n T::MOD\n }\n }\n\n pub struct ModInt(pub u32, PhantomData);\n\n impl Clone for ModInt {\n fn clone(&self) -> Self {\n ModInt::new_unchecked(self.0)\n }\n }\n\n impl Copy for ModInt {}\n\n impl Add for ModInt {\n type Output = ModInt;\n fn add(self, rhs: Self) -> Self::Output {\n let mut d = self.0 + rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n ModInt::new_unchecked(d)\n }\n }\n\n impl AddAssign for ModInt {\n fn add_assign(&mut self, rhs: Self) {\n *self = *self + rhs;\n }\n }\n\n impl Sub for ModInt {\n type Output = ModInt;\n fn sub(self, rhs: Self) -> Self::Output {\n let mut d = T::modulo() + self.0 - rhs.0;\n if d >= T::modulo() {\n d -= T::modulo();\n }\n ModInt::new_unchecked(d)\n }\n }\n\n impl SubAssign for ModInt {\n fn sub_assign(&mut self, rhs: Self) {\n *self = *self - rhs;\n }\n }\n\n impl Mul for ModInt {\n type Output = ModInt;\n fn mul(self, rhs: Self) -> Self::Output {\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\n ModInt::new_unchecked(v as u32)\n }\n }\n\n impl MulAssign for ModInt {\n fn mul_assign(&mut self, rhs: Self) {\n *self = *self * rhs;\n }\n }\n\n impl Neg for ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n if self.0 == 0 {\n Self::zero()\n } else {\n Self::new_unchecked(T::modulo() - self.0)\n }\n }\n }\n\n impl std::fmt::Display for ModInt {\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\n write!(f, \"{}\", self.0)\n }\n }\n\n impl std::str::FromStr for ModInt {\n type Err = std::num::ParseIntError;\n fn from_str(s: &str) -> Result {\n let val = s.parse::()?;\n Ok(ModInt::new(val))\n }\n }\n\n impl From for ModInt {\n fn from(val: usize) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: u64) -> ModInt {\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\n }\n }\n\n impl From for ModInt {\n fn from(val: i64) -> ModInt {\n let m = T::modulo() as i64;\n ModInt::new((val % m + m) as u32)\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n pub fn new_unchecked(d: u32) -> Self {\n ModInt(d, PhantomData)\n }\n pub fn zero() -> Self {\n ModInt::new_unchecked(0)\n }\n pub fn one() -> Self {\n ModInt::new_unchecked(1)\n }\n pub fn is_zero(&self) -> bool {\n self.0 == 0\n }\n }\n\n #[allow(dead_code)]\n impl ModInt {\n pub fn new(d: u32) -> Self {\n ModInt::new_unchecked(d % T::modulo())\n }\n pub fn pow(&self, mut n: u64) -> Self {\n let mut t = Self::one();\n let mut s = *self;\n while n > 0 {\n if n & 1 == 1 {\n t *= s;\n }\n s *= s;\n n >>= 1;\n }\n t\n }\n pub fn inv(&self) -> Self {\n assert!(self.0 != 0);\n self.pow(T::modulo() as u64 - 2)\n }\n }\n\n #[allow(dead_code)]\n pub fn mod_pow(r: u64, mut n: u64, m: u64) -> u64 {\n let mut t = 1 % m;\n let mut s = r % m;\n while n > 0 {\n if n & 1 == 1 {\n t = t * s % m;\n }\n s = s * s % m;\n n >>= 1;\n }\n t\n }\n}\n// ---------- end ModInt ----------\n// ---------- begin Precalc ----------\nmod precalc {\n use super::modint::*;\n #[allow(dead_code)]\n pub struct Precalc {\n inv: Vec>,\n fact: Vec>,\n ifact: Vec>,\n }\n #[allow(dead_code)]\n impl Precalc {\n pub fn new(n: usize) -> Precalc {\n let mut inv = vec![ModInt::one(); n + 1];\n let mut fact = vec![ModInt::one(); n + 1];\n let mut ifact = vec![ModInt::one(); n + 1];\n for i in 2..(n + 1) {\n fact[i] = fact[i - 1] * ModInt::new_unchecked(i as u32);\n }\n ifact[n] = fact[n].inv();\n if n > 0 {\n inv[n] = ifact[n] * fact[n - 1];\n }\n for i in (1..n).rev() {\n ifact[i] = ifact[i + 1] * ModInt::new_unchecked((i + 1) as u32);\n inv[i] = ifact[i] * fact[i - 1];\n }\n Precalc {\n inv: inv,\n fact: fact,\n ifact: ifact,\n }\n }\n pub fn inv(&self, n: usize) -> ModInt {\n assert!(n > 0);\n self.inv[n]\n }\n pub fn fact(&self, n: usize) -> ModInt {\n self.fact[n]\n }\n pub fn ifact(&self, n: usize) -> ModInt {\n self.ifact[n]\n }\n pub fn perm(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[n - k]\n }\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\n if k > n {\n return ModInt::zero();\n }\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\n }\n }\n}\n// ---------- end Precalc ----------\n//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\nuse modint::*;\nuse precalc::*;\n\ntype M = ModInt;\n\nfn run() {\n input! {\n p: u64,\n k: u64,\n }\n let ans = if k == 0 {\n M::from(p).pow(p - 1)\n } else {\n let mut phi = p - 1;\n let mut m = phi;\n for d in 2.. {\n if d * d > m {\n break;\n }\n if m % d == 0 {\n while m % d == 0 {\n m /= d;\n }\n while phi % d == 0 && mod_pow(k, phi / d, p) == 1 {\n phi /= d;\n }\n }\n }\n if m > 1 && mod_pow(k, phi / m, p) == 1 {\n phi /= m;\n }\n M::from(p).pow((p - 1) / phi)\n };\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "510a794319fd8376e143b1db4d65c770", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "apr_id": "720dc2c6dffb0ca7a2a561a628a3fb8c", "difficulty": 1800, "tags": ["combinatorics", "dfs and similar", "number theory", "dsu", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9548022598870056, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn zeros_fac(n : u32) -> u32 {\n let mut i = 5;\n let mut count = 0;\n while i <= n {\n count += n / i;\n i *= 5;\n }\n count\n}\n\nfn bsearch(mut pi : u32, mut pf : u32, n : u32) -> Option {\n while pf >= pi {\n let pm = (pf + pi) / 2;\n let zeros_pm = zeros_fac(5 * pm);\n if zeros_pm < n {\n pi = pm + 1;\n } else if zeros_pm == n {\n return Some(5 * pm);\n } else {\n pf = pm - 1;\n }\n }\n return None;\n}\n\nfn main() {\n let mut buffer = String::new();\n io::stdin().read_line(&mut buffer).expect(\"failed to read input\");\n let n: u32 = buffer.trim().parse().expect(\"invalid input\");\n\n match bsearch(4 * n / 5, n, n) {\n Some(x) => println!(\"{} {} {} {} {}\", x, x + 1, x + 2, x + 3, x + 4),\n None => println!(\"0\"),\n };\n}", "lang": "Rust", "bug_code_uid": "34af8c8043e7ad0e3f7bd8ae6003cb0c", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "apr_id": "7edb92332606279941588046c3193d3b", "difficulty": 1300, "tags": ["brute force", "math", "constructive algorithms", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7369308600337268, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 7, "bug_source_code": "use std::io;\n\nfn sum_digits(n : u16) -> u16 {\n let mut num = n;\n let mut sum = 0;\n while num != 0 {\n sum += num % 10;\n num /= 10;\n }\n sum\n}\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).expect(\"failed to read input\");\n\n let mut n: u16 = input.trim().parse().expect(\"invalid input\");\n let mut s = sum_digits(n) % 4;\n if n % 10 + s >= 10 {\n n = n + 10 - (n % 10);\n s = sum_digits(n) % 4;\n }\n println!(\"{}\", n + if s != 0 { 4 - s } else { 0 });\n}", "lang": "Rust", "bug_code_uid": "3744d2e4e9540a93a8834ee96c90121b", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "apr_id": "1b8971735eb9d35e356bc1977f28814d", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9966850828729282, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::io::{stdin, Read, StdinLock};\n#[allow(unused_imports)]\nuse std::cmp::{max, min, Ordering};\n#[allow(unused_imports)]\nuse std::str::FromStr;\n#[allow(unused_imports)]\nuse std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};\n#[allow(unused_imports)]\nuse std::vec::Vec;\n\n#[allow(dead_code)]\nconst INF: i32 = 1000_000_000;\n#[allow(dead_code)]\nconst INFLL: i64 = 1000_000_000_000_000_000;\n#[allow(dead_code)]\nconst EPS: f64 = 1.0e-10;\n#[allow(dead_code)]\nconst MOD: i32 = 1000_000_007;\n#[allow(dead_code)]\nconst MODLL: i64 = 1000_000_007;\n\nstruct Scanner<'a> {\n cin: StdinLock<'a>,\n}\n\n#[allow(dead_code)]\nimpl<'a> Scanner<'a> {\n fn new(cin: StdinLock<'a>) -> Scanner<'a> {\n Scanner {cin: cin}\n }\n fn read1(&mut self) -> Option {\n let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect::();\n token.parse::().ok()\n }\n fn read(&mut self) -> T {\n self.read1().unwrap()\n }\n}\n\nfn main() {\n let cin = stdin();\n let cin = cin.lock();\n let mut sc = Scanner::new(cin);\n\n let _n: usize = sc.read();\n let s: String = sc.read();\n let s: Vec = s.chars().collect();\n\n fn vowel(c: char) -> bool {\n return c == 'a' || c == 'i' || c == 'e' || c == 'o' || c == 'u';\n }\n\n let mut ans: String = String::new();\n let mut last = '0';\n for c in s {\n if ans.len() == 0 {\n ans.push(c);\n last = c;\n } else {\n if vowel(last) && vowel(c) {\n continue;\n }\n ans.push(c);\n last = c;\n }\n }\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "4af55f3cf9343144fa0cc98c7c8768f9", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "apr_id": "2b1bde8e6ada0875b0288a2275bc41c7", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9987357774968394, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_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": "Rust", "bug_code_uid": "547c1af8e7e249c47c8a5957514ee59d", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "apr_id": "29bef597330cf8cb11c11dafa8b43897", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9930015552099534, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{max,min};\n#[allow(unused_imports)]\nuse std::collections::{HashMap,HashSet,VecDeque};\n\n#[allow(unused_macros)]\nmacro_rules! readln {\n () => {{\n use std::io;\n \n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n buf.trim().to_string()\n }};\n ( $t:ty ) => {{\n let input = readln!();\n input.parse::<$t>().unwrap()\n }};\n ( $( $t:ty ),+ ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n (\n $(\n input.next().unwrap().parse::<$t>().unwrap(),\n )+\n )\n }}\n}\n\n#[allow(unused_macros)]\nmacro_rules! readvec {\n ( $t:ty ) => {{\n let input = readln!();\n let mut input = input.split_whitespace();\n let mut result = Vec::new();\n for elem in input {\n result.push(elem.parse::<$t>().unwrap());\n }\n result\n }}\n}\n\nfn main() {\n let (mut a, mut b) = readln!(i32,i32);\n let mut res = 0;\n while a>0 && b>0 {\n res += 1;\n if a >= b {\n a = max(0,a-2);\n b = min(100,b+1);\n } else {\n a = min(100,a+1);\n b = max(0,b-2);\n }\n }\n println!(\"{}\",res);\n}\n", "lang": "Rust", "bug_code_uid": "5e2a3645f23b5a37deff9362f68deb48", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "apr_id": "0533349cca0c8017c2ee2f766ad59ea0", "difficulty": 1100, "tags": ["dp", "greedy", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6445158985351911, "equal_cnt": 8, "replace_cnt": 3, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_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 mut a1: usize = scan.next();\n let mut a2: usize = scan.next();\n let mut result = 0usize;\n while a1 > 0 && a2 > 0 {\n if a1 < a2 {\n a1 += 1;\n a2 -= 2;\n } else {\n a2 += 1;\n a1 -= 2;\n }\n result += 1;\n }\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "7f1493c27b11cf106e06b58921c2764c", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "apr_id": "faaaa2a885993966d00c0d6ddd5a08de", "difficulty": 1100, "tags": ["dp", "greedy", "math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8610614192009541, "equal_cnt": 13, "replace_cnt": 9, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 12, "bug_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 minval(a1: usize, a2: usize, depth: usize, table: &mut [[usize; 128]; 128]) -> usize {\n if a1 == 0 || a2 == 0 {\n return depth;\n }\n if table[a1][a2] != 0 {\n return table[a1][a2];\n }\n let mut result = 0usize;\n if a1 >= 2 {\n let val = {\n let a1 = a1 - 2;\n let a2 = a2 + 1;\n minval(a1.max(a2), a1.min(a2), depth + 1, table)\n };\n result = result.max(val);\n }\n if a2 >= 2 {\n let val = {\n let a1 = a1 + 1;\n let a2 = a2 - 2;\n minval(a1.max(a2), a1.min(a2), depth + 1, table)\n };\n result = result.max(val);\n }\n table[a1][a2] = result;\n result\n}\n\nfn _main() {\n let mut table = [[0; 128]; 128];\n let mut scan = Scan::new();\n let a1: usize = scan.next();\n let a2: usize = scan.next();\n let result = minval(a1, a2, 0, &mut table);\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "5c49080c0aa96f66b21000d354e77726", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "apr_id": "faaaa2a885993966d00c0d6ddd5a08de", "difficulty": 1100, "tags": ["dp", "greedy", "math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9994065281899109, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_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 minval(a1: usize, a2: usize, depth: usize, table: &mut [[usize; 256]; 256]) -> usize {\n if a1 == 0 || a2 == 0 {\n return depth;\n }\n if table[a1][a2] != 0 {\n return table[a1][a2];\n }\n let mut result = 0usize;\n if a2 >= 2 {\n let val = {\n let a1 = a1 + 1;\n let a2 = a2 - 2;\n minval(a1.max(a2), a1.min(a2), depth + 1, table)\n };\n result = result.max(val);\n }\n if a1 >= 2 {\n let val = {\n let a1 = a1 - 2;\n let a2 = a2 + 1;\n minval(a1.max(a2), a1.min(a2), depth + 1, table)\n };\n result = result.max(val);\n }\n table[a1][a2] = result;\n result\n}\n\nfn _main() {\n let mut table = [[0; 256]; 256];\n let mut scan = Scan::new();\n let a1: usize = scan.next();\n let a2: usize = scan.next();\n let result = minval(a1.max(a2), a2.min(a2), 0, &mut table);\n println!(\"{}\", result);\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": "Rust", "bug_code_uid": "b7f1cf8c4b656a4c481f16be8a1b5eca", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "apr_id": "faaaa2a885993966d00c0d6ddd5a08de", "difficulty": 1100, "tags": ["dp", "greedy", "math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8141843971631205, "equal_cnt": 13, "replace_cnt": 8, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 12, "bug_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 n: usize = scan.next();\n let k: usize = scan.next();\n let d: usize = scan.next();\n let mut table = [[0usize; 2]; 128];\n table[0][1] = 1;\n for i in 1..=n {\n for j in 1..=k {\n if i >= j {\n table[i][0] = (table[i][0] + table[i - j][0]) % 1000000007;\n if j >= d {\n table[i][0] = (table[i][0] + table[i - j][1]) % 1000000007;\n } else {\n table[i][1] += (table[i][1] + table[i - j][1]) % 1000000007;\n }\n }\n }\n }\n println!(\"{}\", table[n][0]);\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": "Rust", "bug_code_uid": "070f6260dbd9df4bd80b49942c2775c9", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "apr_id": "0b70ef1e3989f475ab15110c98d35a4a", "difficulty": 1600, "tags": ["trees", "dp", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9857909693716451, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn get_divisors(n: i64) -> Vec {\n let mut ans = vec![1, n];\n let mut d = 2;\n while d * d <= n {\n if n % d == 0 {\n ans.push(d);\n if d * d < n {\n ans.push(n / d);\n }\n }\n d += 1;\n }\n ans.sort();\n ans\n}\n\nfn kth_smallest_divisor(n: i64, k: i64) -> i64 {\n let k = k as usize;\n let divisors = get_divisors(n);\n if k >= divisors.len() {\n return -1;\n }\n divisors[k]\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: i64 = scan.token();\n let k: i64 = scan.token();\n let ans = kth_smallest_divisor(n, k - 1); \n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "24e1535c1eca8f9f256f2901f581dfeb", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "apr_id": "e7a76f5cf97ad2817c1f25106d4c9db6", "difficulty": 1400, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.7308132875143184, "equal_cnt": 7, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 8, "bug_source_code": "macro_rules! read_line {\n ($v:ident) => {\n let mut temp = String::new();\n std::io::stdin().read_line(&mut temp).unwrap();\n let $v = temp;\n };\n (var, $t:ty, $($v:ident), *) => {\n read_line!(input_line);\n let mut iter = parse_token!($t, input_line);\n $(\n let $v = iter.next().unwrap();\n )*\n };\n (vec, $t:ty, $v:ident) => {\n read_line!(input_line);\n let iter = parse_token!($t, input_line);\n let $v: Vec<$t> = iter.collect();\n };\n ($($v:ident; $t:ty), *) => {\n read_line!(input_line);\n let mut iter = input_line.split_whitespace();\n $(\n let $v: $t = iter.next().unwrap().parse().unwrap();\n )*\n };\n}\n\nmacro_rules! parse_token {\n ($t:ty, $e:expr) => {\n $e.split_whitespace().map(|x| x.parse::<$t>().unwrap());\n };\n}\n\nfn main() {\n read_line!(k;u64, n;u64);\n let mut cnt = 0;\n for i in 1..(k + 1) {\n if k % i == 0 {\n cnt += 1;\n }\n if cnt == n {\n println!(\"{}\", i);\n return;\n }\n }\n\n println!(\"-1\");\n}", "lang": "Rust", "bug_code_uid": "1fae4c4a1d760a938e08377a98029adf", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "apr_id": "cf3dc868097025626a2996cc673a96d3", "difficulty": 1400, "tags": ["math", "number theory"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9335016835016835, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 5, "bug_source_code": "fn calculate_nth_divisor(n: i64, k: i64) -> Option {\n if k > n {\n return None;\n }\n\n let mut divisors = Vec::::with_capacity((k / 2) as usize);\n let max_small_divisor = (n as f64).sqrt().trunc() as i64;\n let mut count = k;\n\n for x in 1..=max_small_divisor {\n if n % x == 0 {\n count -= 1;\n }\n if count == 0 {\n return Some(x);\n } else {\n divisors.push(x);\n }\n }\n\n let size = divisors.len() as i64;\n let n_is_square = n == divisors.last().unwrap().pow(2);\n // dbg!(n, k, size, n_is_square, &divisors);\n if count > size || count == size && n_is_square {\n None\n } else {\n let mut idx = (size as i64 - count) as usize;\n if n_is_square {\n idx -= 1;\n }\n Some(n / divisors[idx])\n }\n}\n\nfn main() {\n let (n, k) = {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let mut iter = s.trim().split_ascii_whitespace();\n let n = iter.next().unwrap().parse::().unwrap();\n let k = iter.next().unwrap().parse::().unwrap();\n (n, k)\n };\n\n println!(\"{}\", calculate_nth_divisor(n, k).unwrap_or(-1));\n}\n", "lang": "Rust", "bug_code_uid": "2ef100ae7110659e5bb20b245eb4ffe5", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "apr_id": "c02c77ec85a65ab55ba58dfddf2aca9f", "difficulty": 1400, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.036887316826680144, "equal_cnt": 13, "replace_cnt": 9, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 14, "bug_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 let (n, k) = (sin.next(), sin.next::());\n\n let mut factors = Vec::new();\n\n let mut i = 1;\n\n while i*i <= n {\n if n % i == 0 {\n factors.push(i);\n }\n i += 1;\n }\n\n let num_of_factors = 2*factors.len() - 1;\n\n if k < factors.len() {\n println!(\"{}\", factors[k]);\n } else {\n if k > num_of_factors {\n println!(\"-1\");\n } else {\n let mut index = k - factors.len();\n if (i-1)*(i-1) == n {\n index += 1;\n }\n println!(\"{}\", n / factors[factors.len() - index]);\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "7a4b85047e33b0d0bb3c0d44d8c571d6", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "apr_id": "286b05b0151cb823702498407416a281", "difficulty": 1400, "tags": ["math", "number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9955080213903743, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{ self, BufRead };\n\nmacro_rules! scan_to_vec {\n ($count:expr, $t:ty) => ({\n let mut result = Vec::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n\n for _ in 0..$count {\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_to_vec: failed at `handle.read_line`.\");\n result.push(buffer.trim().parse::<$t>()\n .expect(\"scan_to_vec: failed at `parse::<$t>`.\"));\n }\n result\n })\n}\n\nmacro_rules! scan_line_to_vec {\n ($t:ty) => ({\n let mut result = Vec::new();\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n handle.read_line(&mut buffer)\n .expect(\"scan_line_to_vec: failed at `handle.read_line`.\");\n \n for s in chunks.split_whitespace() {\n result.push(s.parse::<$t>()\n .expect(\"scan_line_to_vec: failed at `parse::<$t>`.\"));\n }\n result\n })\n}\n\nmacro_rules! scan_line {\n () => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n buffer\n });\n ( $($t:ty)+ ) => ({\n let stdin = io::stdin();\n let mut handle = stdin.lock();\n let mut buffer = String::new();\n handle.read_line(&mut buffer)\n .expect(\"scan_line: failed at `handle.read_line`.\");\n let mut chunks = buffer.split_whitespace();\n\n ($(\n {\n chunks.next()\n .expect(\"scan_line: failed at `next`, # of space separated strings not equal to requested #\")\n .parse::<$t>()\n .expect(\"scan_line: failed at `parse::<$t>`.\")\n },\n )+)\n })\n}\n\nfn main() {\n let (n, k) = scan_line!(u64 usize);\n let mut factors = vec![];\n\n let mut i = 1;\n\n while i*i <= n {\n if n % i == 0 {\n factors.push(i);\n }\n i += 1;\n }\n\n for j in 0..factors.len() {\n let x = n / factors[j];\n factors.push(x);\n }\n factors.sort();\n\n if k - 1 >= factors.len() {\n println!(\"-1\");\n } else {\n println!(\"{}\", factors[k - 1]);\n }\n}\n", "lang": "Rust", "bug_code_uid": "7e9b3a718413347fe7bf5df93991dadc", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "apr_id": "286b05b0151cb823702498407416a281", "difficulty": 1400, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9972067039106145, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\n\nfn main() {\n let mut x = String::new();\n io::stdin().read_line(&mut x).expect(\"error\");\n let mut i = x.split_whitespace();\n let a:u64 = i.next().unwrap().parse().expect(\"error\");\n let b:usize = i.next().unwrap().parse().expect(\"error\");\n let mut v:Vec = Vec::new();\n for i in 1..(a as f64).sqrt() as u64+1 {\n if a % i == 0 {\n &v.push(i);\n }\n }\n let len = v.len();\n if b <= len {\n println!(\"{}\", v[b-1]);\n } else if v[len-1]*v[len-1] == a && b <= 2*len-2 {\n println!(\"{}\", a/v[2*len-2-b]);\n } else if v[len-1]*v[len-1] < a && b <= 2*len {\n println!(\"{}\", a/v[2*len-b]);\n } else {\n println!(\"-1\");\n }\n\n}\n", "lang": "Rust", "bug_code_uid": "a7fed19fc87769b0ffdef6adc7864f22", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "apr_id": "194a501cbd223a57355fd89213b608d0", "difficulty": 1400, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9542566709021602, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut input_str = String::new();\n io::stdin().read_line(&mut input_str).expect(\"read error\");\n \n let input: Vec = input_str.split_whitespace()\n .map(|x| x.parse::().expect(\"parse error\"))\n .collect();\n\n let n = input[0];\n let k = input[1];\n\n let mut divisors: Vec = vec![];\n for divisor in 1..n {\n if divisor * divisor > n { break; }\n if n % divisor == 0 { divisors.push(divisor); }\n }\n\n let another_divisors: Vec;\n {\n another_divisors = divisors.iter().map(|x| n / x).rev().collect()\n }\n\n divisors.extend(another_divisors);\n\n if (divisors.len() as i64) < k {\n println!(\"-1\");\n } else {\n println!(\"{}\", divisors[k as usize - 1]);\n }\n}\n", "lang": "Rust", "bug_code_uid": "b6c45cd1399c16c2d93554bca6636796", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "apr_id": "ba1009d5d7733214897b1870909dbedf", "difficulty": 1400, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4466352336048007, "equal_cnt": 12, "replace_cnt": 11, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 12, "bug_source_code": "use std::io::stdin;\nuse std::cmp::max;\n\nfn main() {\n let mut str = String::new();\n let _ = stdin().read_line(&mut str).unwrap();\n let mut iter = str.split_whitespace();\n let mut n:i64 = iter.next().unwrap().parse().unwrap();\n let mut k:i64 = iter.next().unwrap().parse().unwrap();\n let mut b_k = k + 2;\n let mut pow = 1;\n loop {\n if b_k > 1{\n pow *= 2;\n b_k /= 2;\n } else { break; }\n }\n pow /= 2;\n let mut res = n / pow;\n while (res + 1) * pow + (k - 2 * pow + 1) <= n { res +=1; }\n while res * pow + (k - 2 * pow + 1) > n { res -=1; }\n \n println!(\"{}\", res);\n //println!(\"{}\", pow);\n}\n//4 5 8 9 10 11\n//5 -> 3 -> \n//3 -> 1\n\n// k <= 2 + 4 + 8 + .. pow => k + 2 <= 2 * pow\n// 2 + 4 +8 + .. + pow = 2\n// 6 * 2 + (5 - 2)\n// 2 + 4 + 8 //+ 16 20 - 2,4,8 = 6 .. 2 * 8 = 16 + (20 - 2 - 4 - 8 - 1) = 21\n\n// 5 - 2,2 - 1, 4\n", "lang": "Rust", "bug_code_uid": "fcc4392863662597b5984ee63461d5bb", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "apr_id": "ef74bcadc4303a501b61bc59ae562bf0", "difficulty": 2100, "tags": ["dp", "math", "combinatorics", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9714904366654638, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "// https://codeforces.com/contest/1271/problem/E\n//\n#![allow(unused_imports)]\nuse std::io::*;\nuse std::fmt::*;\nuse std::str::*;\nuse std::cmp::*;\nuse std::collections::*;\n\n#[allow(unused_macros)]\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\n#[allow(unused_macros)]\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($iter:expr, [ next / $t:tt ]) => {\n {\n let len = read_value!($iter, usize);\n (0..len).map(|_| read_value!($iter, $t)).collect::>()\n }\n };\n\n ($iter:expr, switch) => {\n {\n let ty = read_value!($iter, i32);\n if ty == 1 {\n vec![ty, read_value!($iter, i32), read_value!($iter, i32)]\n } else if ty == 2 {\n vec![ty, read_value!($iter, i32)]\n } else {\n vec![ty, read_value!($iter, i32)]\n }\n }\n };\n\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! dvec {\n ($t:expr ; $len:expr) => {\n vec![$t; $len]\n };\n\n ($t:expr ; $len:expr, $($rest:expr),*) => {\n vec![dvec!($t; $($rest),*); $len]\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! ifv {\n ($t:expr, $a:expr, $b: expr) => {\n if $t { $a } else { $b }\n }\n}\n\n#[allow(unused_macros)]\nmacro_rules! fill {\n ($t:expr, $v:expr) => {\n for i in 0..$t.len() {\n $t[i] = $v;\n }\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! join {\n ($t:expr, $glue:expr) => {\n $t.into_iter().map(|w| w.to_string()).collect::>().join($glue)\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! debug {\n ($($a:expr),*) => {\n println!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n\nfn exp(upto: usize, k: usize) {\n let mut cnt = vec![0; upto];\n for w in 1..upto {\n let mut ww = w;\n loop {\n cnt[ww] += 1;\n if ww == 1 {\n break;\n }\n if ww % 2 == 0 {\n ww /= 2;\n } else {\n ww -= 1;\n }\n }\n }\n let mut up = 0;\n for w in (1..upto).rev() {\n if cnt[w] > up {\n up = cnt[w];\n // debug!(w, up);\n }\n }\n for w in (1..upto).rev() {\n if cnt[w] >= k {\n println!(\"{}\", w);\n break;\n }\n }\n}\n\nfn main() {\n input! {\n n: i64, k: i64\n };\n\n if n <= 100 {\n exp((n+1) as usize, k as usize);\n return;\n }\n\n let mut ans = -1;\n let mut tbl = vec![(n, 1), (n-1, ifv!(n % 2 == 0, 1, 2)), (n-2, ifv!(n % 2 == 0, 2, 1))];\n loop {\n // debug!(tbl);\n for &(f, l) in &tbl {\n if k <= l {\n ans = f;\n break;\n }\n }\n if tbl[0].0 <= 1 {\n break;\n }\n if ans != -1 {\n break;\n }\n\n let mut ntbl: Vec<(i64, i64)> = vec![];\n let tn = tbl.len();\n for nex in 0..4 {\n let to = tbl[0].0 / 2 - nex;\n let mut add = 1;\n\n // find 2*to\n {\n let mut f2 = false;\n for f in 0..tn {\n if tbl[f].0 == 2*to {\n add += tbl[f].1;\n f2 = true;\n break;\n }\n }\n if !f2 {\n for f in (0..tn).rev() {\n if tbl[f].0 % 2 == 0 {\n add += tbl[f].1;\n break;\n }\n }\n }\n }\n\n // find to+1\n if to % 2 == 0 {\n // we already have that one...\n if nex >= 1 {\n add += ntbl[(nex-1) as usize].1;\n } else {\n for f in (0..tn).rev() {\n if tbl[f].0 % 2 == 1 {\n add += tbl[f].1;\n break;\n }\n }\n }\n }\n ntbl.push((to, add));\n }\n tbl = ntbl;\n }\n\n // exp((n+1) as usize);\n println!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "a9e8fa22d03d151e42ea1f9e764bb7f1", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "apr_id": "16f4da680f8fe298d602feac7f994939", "difficulty": 2100, "tags": ["dp", "math", "combinatorics", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9974522292993631, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// ここまで\n\nfn run() {\n input! {\n n: u64,\n }\n if n <= 2 {\n println!(\"1\");\n return;\n }\n let mut m = 4;\n let mut d = 1;\n while m + 1 < n {\n m = 2 * m - d;\n d ^= 1;\n }\n if m == n || m + 1 == n {\n println!(\"1\");\n } else {\n println!(\"0\");\n }\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "e928b034d0fc0226a5e4a1195d8c53ef", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "apr_id": "0fa174faaf00d7aff598f9caab3a92f9", "difficulty": 2400, "tags": ["dp", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7100802854594113, "equal_cnt": 3, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "fn input_split() -> Vec {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect()\n}\n\nfn main() {\n let mut bags = input_split();\n bags.sort_unstable();\n print!(\n \"{}\",\n if bags[0] + bags[3] == bags[1] + bags[2] {\n \"YES\"\n } else {\n \"NO\"\n }\n );\n}", "lang": "Rust", "bug_code_uid": "4a92139215a4725ad2aa4c7eda589cd2", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "apr_id": "b65fd2fe2862f30a4707e1babeb8d48c", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9829596412556054, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "struct Scan {\n buffer: std::collections::VecDeque,\n}\n\nimpl Scan {\n fn new() -> Scan {\n Scan {\n buffer: std::collections::VecDeque::new(),\n }\n }\n\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop_front() {\n break token.parse::().ok().unwrap();\n }\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).expect(\"Fail to read\");\n self.buffer = line.split_whitespace().map(String::from).collect();\n }\n }\n\n fn next_n(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.next::()).collect()\n }\n}\n\nfn _main() {\n let mut scan = Scan::new();\n let mut arr: Vec = scan.next_n(4);\n arr.sort();\n if arr[0] + arr[3] == arr[1] + arr[2] {\n println!(\"YES\");\n } else {\n println!(\"NO\");\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": "Rust", "bug_code_uid": "8e261bd6dd0d9d3e67f13bac491bedc1", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "apr_id": "9addc64ac9eba28a5a4c169ba7497012", "difficulty": 800, "tags": ["brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9883393646964214, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_imports)]\nuse std::io::{self, BufWriter, Write};\nuse std::str::{self, SplitAsciiWhitespace};\nuse std::cmp::Ordering::{*};\n\n// I have no idea what I'm doing\n\nuse std::f64::consts::{PI};\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: i64 = scan.token();\n\n let is_in = |i, j| i*i + j*j <= n*n;\n // Uncomment for a cool circle in your screen\n // for i in -n..=n {\n // for j in -n..=n {\n // write!(out, \"{}\", if is_in(i.abs(), j.abs()) { '+' }\n // else { '-' })?;\n // write!(out, \" \")?;\n // }\n // writeln!(out)?;\n // }\n\n let mut ans = 0;\n let mut y = n;\n for x in 0..=n {\n if is_in(x, y) {\n ans += 1;\n }\n while !is_in(x, y) {\n y -= 1;\n ans += 1;\n }\n }\n\n writeln!(out, \"{}\", (ans - 1) * 4)?;\n\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": "Rust", "bug_code_uid": "ef5eaae1f3f4d268276790075fb12752", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "apr_id": "08d2ff493f23db360a67f91f6d562f9f", "difficulty": null, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9888042991491267, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "#![allow(unused_imports)]\nuse std::io::{ self, Write };\nuse std::str::FromStr;\nuse std::cmp::{ min, max };\nuse std::collections::{ BinaryHeap, VecDeque };\n\nmacro_rules! trace {\n ($var:expr) => ({\n let _ = writeln!(&mut std::io::stderr(), \">>> {} = {:?}\", stringify!($var), $var);\n })\n}\nmacro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }\n\nfn bi(x: i64, n: i64, l0: i64, r0: i64) -> i64 {\n let mut left = l0;\n let mut right = r0;\n\n while right - left > 1 {\n let y = (left + right) / 2;\n if x * x + y * y <= n * n {\n left = y;\n } else {\n right = y;\n }\n }\n return left;\n}\n\nfn main() {\n let mut sc = Scanner::new();\n\n let n: i64 = sc.cin();\n\n if n == 0 {\n println!(\"1\");\n return;\n }\n\n let mut a = 0;\n let mut b = 0;\n\n let mut l0 = 0;\n let mut r0 = n + 1;\n for x in 0..n {\n let y = bi(x, n, l0, r0);\n l0 = y - 10;\n r0 = y + 10;\n // trace!((x, y));\n if x < y {\n a += 1;\n } else if x == y {\n b += 1;\n break;\n } else {\n break;\n }\n }\n let ans = 4 * (a * 2 - 1 + b);\n println!(\"{}\", ans);\n}\n\n#[allow(dead_code)]\nstruct Scanner { stdin: io::Stdin, buffer: VecDeque, }\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }\n fn reserve(&mut self) {\n while self.buffer.len() == 0 {\n let mut line = String::new();\n let _ = self.stdin.read_line(&mut line);\n for w in line.split_whitespace() {\n self.buffer.push_back(String::from(w));\n }\n }\n }\n fn cin(&mut self) -> T {\n self.reserve();\n match self.buffer.pop_front().unwrap().parse::() {\n Ok(a) => a,\n Err(_) => panic!(\"parse err\")\n }\n }\n fn get_char(&mut self) -> char {\n self.reserve();\n let head = self.buffer[0].chars().nth(0).unwrap();\n let tail = String::from( &self.buffer[0][1..] );\n if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }\n head\n }\n}\n", "lang": "Rust", "bug_code_uid": "c53349452ed2308299b7c2f7549190c8", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "apr_id": "57a13241f2f3d32790bc61957956fc7d", "difficulty": null, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9916262670780079, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::cmp::*;\n\nconst INF: i64 = 1e12 as i64;\nfn main() {\n let (n, m, k) = {\n let r = getvec::();\n (r[0], r[1], r[2])\n };\n let num = m - n;\n let l_n = k;\n let r_n = n - k + 1;\n let mut lb = 0i64;\n let mut ub = INF;\n while ub - lb > 1i64 {\n let mid = (ub + lb) / 2;\n let r = calc(max(1i64, mid - r_n + 1), mid);\n let l = calc(max(1i64, mid - l_n + 1), mid);\n let res = r + l - mid;\n if res <= num {\n lb = mid;\n } else {\n ub = mid;\n }\n }\n println!(\"{}\", lb + 1);\n}\n\nfn calc(l: i64, r: i64) -> i64 {\n let n = r - l + 1;\n let res = n * (l + r);\n res / 2\n}\n\n#[allow(dead_code)]\nfn next_line() -> String {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).unwrap();\n input\n}\n\n#[allow(dead_code)]\nfn getnum() -> T {\n let res = next_line();\n res.trim().parse::().ok().unwrap()\n}\n\n#[allow(dead_code)]\nfn getvec() -> Vec {\n let res = next_line();\n res.split_whitespace().map(|x| x.parse::().ok().unwrap()).collect()\n}\n", "lang": "Rust", "bug_code_uid": "dcf2a30242015bd0a9f65107ee29c078", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "apr_id": "f1bf7476e744be9d2511fd2f83273576", "difficulty": 1500, "tags": ["greedy", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9680479281078382, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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 cost(x : i64, n : i64, k : i64) -> i64 {\n let left_limit = min(k, x - 1);\n let right_limit = min(n - k - 1, x - 1);\n\n let left_cost = left_limit*x - (left_limit*(left_limit+1)/2);\n let right_cost = right_limit*x - (right_limit*(right_limit+1)/2);\n\n let left_extra = max(k - left_limit, 0);\n let right_extra = max((n - k - 1) - right_limit, 0);\n\n x + left_cost + right_cost + left_extra + right_extra\n}\n\nfn search(n : i64, k : i64, m : i64) -> i64 {\n let mut upper = m;\n let mut lower = 1;\n let mut middle = 0;\n\n while lower <= upper {\n middle = (lower + upper)/2;\n let c = cost(middle, n, k);\n\n if c < m {\n lower = middle + 1;\n } else if c > m {\n upper = middle - 1;\n } else {\n break;\n }\n }\n\n middle\n}\n\nfn main() {\n let mut sin = Scanner::new();\n let (n, m, k) : (i64, i64, i64) = (sin.next(), sin.next(), sin.next());\n\n println!(\"{}\", search(n, k - 1, m));\n}\n", "lang": "Rust", "bug_code_uid": "4771084e6bc778e3228ae161fdc25688", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "apr_id": "139d29157399e8d09631c1a59242bff5", "difficulty": 1500, "tags": ["greedy", "binary search"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.999559277214632, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn readstring() -> String {\n read_string_from_buffer(&io::stdin())\n}\n\nfn readint() -> i32 {\n read_int_from_buffer(&io::stdin())\n}\n\nfn read_string_from_buffer(buf: &io::Stdin) -> String {\n let mut input_text = String::new();\n buf.read_line(&mut input_text)\n .expect(\"failed to read from stdin\");\n input_text.trim_right().to_string()\n}\n\nfn read_int_from_buffer(buf: &io::Stdin) -> i32 {\n read_string_from_buffer(buf)\n .parse::()\n .expect(\"couldn't parse data to an integer\")\n}\n\nfn read_line_of_integers() -> Vec {\n readstring()\n .split_whitespace()\n .map(|x| x.parse::().unwrap())\n .collect()\n}\n\nfn read_line_of_longs() -> Vec {\n readstring()\n .split_whitespace()\n .map(|x| x.parse::().unwrap())\n .collect()\n}\n\nfn main() {\n let v = read_line_of_integers();\n let (n, a, b) = (v[0], v[1] - 1, v[2] - 1);\n\n let mut m = 1;\n let mut ans = 0;\n while a / m != b / m {\n m *= 2;\n ans += 1;\n }\n\n if m == n {\n println!(\"Final !\")\n } else {\n println!(\"{}\", ans);\n }\n}\n", "lang": "Rust", "bug_code_uid": "05eeddb87124f7978ed86e951b05c494", "src_uid": "a753bfa7bde157e108f34a28240f441f", "apr_id": "d8fc56bfb95971dd352063145c6a5ee6", "difficulty": 1200, "tags": ["constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.6028636021100227, "equal_cnt": 9, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 8, "bug_source_code": "fn main() {\n let mut input = String::new();\n use std::io;\n use std::io::prelude::*;\n io::stdin().read_to_string(&mut input).unwrap();\n\n let mut it = input.split_whitespace();\n\n let n: usize = it.next().unwrap().parse().unwrap();\n let a: usize = it.next().unwrap().parse().unwrap();\n let b: usize = it.next().unwrap().parse().unwrap();\n\n let oa = a - 1;\n let ob = b - 1;\n\n let mut flag = n >> 1;\n let mut i = 0;\n\n while flag & oa == flag & ob {\n i += 1;\n flag = flag >> 1;\n }\n\n if i == 0 {\n println!(\"Final!\");\n } else {\n println!(\"{}\", n / 2usize.pow(i + 1));\n }\n}\n", "lang": "Rust", "bug_code_uid": "14a1ce1b848195ea1520f15daa8a80de", "src_uid": "a753bfa7bde157e108f34a28240f441f", "apr_id": "5a68d71cc1ff655a68a86e64c7b571fe", "difficulty": 1200, "tags": ["constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.921164540399084, "equal_cnt": 13, "replace_cnt": 3, "delete_cnt": 3, "insert_cnt": 6, "fix_ops_cnt": 12, "bug_source_code": "use std::io;\nuse std::io::Read;\n\nfn main() {\n let mut stdin = String::new();\n io::stdin().read_to_string(&mut stdin).unwrap();\n let mut stdin = stdin.split_whitespace();\n let mut get = || stdin.next().unwrap();\n macro_rules! get {\n ($t:ty) => (get().parse::<$t>().unwrap());\n }\n \n let n = get!(usize);\n let need = get!(u64);\n \n let mut costs = vec![0; n];\n \n for i in 0..n {\n costs[i] = get!(u64);\n }\n \n fn search(costs: &Vec, need: u64, payment: u64) -> u64 {\n let mut best_payment = 0;\n for i in 0..costs.len() {\n let liters = 1 << i;\n if liters < need {\n let bottles = need / liters;\n let remains = need-bottles*liters;\n let payment = payment+bottles*costs[i]; \n let payment = if remains > 0 {\n search(costs, remains, payment)\n } else {\n payment\n };\n if payment < best_payment || best_payment == 0 {\n best_payment = payment;\n }\n } else {\n let payment = payment+costs[i];\n if payment < best_payment || best_payment == 0 {\n best_payment = payment;\n }\n }\n }\n best_payment\n }\n \n let best_payment = search(&costs, need, 0);\n println!(\"{}\", best_payment);\n}", "lang": "Rust", "bug_code_uid": "933f0b5e96c0d8f0a5ad438df8b35d1a", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "apr_id": "39e96566260c6cb9724cc0dc6fed6156", "difficulty": 1600, "tags": ["dp", "greedy", "bitmasks"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9929939280709948, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::stdin;\n\nuse std::cmp::{min,max};\n\nfn main() {\n let a = {\n let mut input = String::new();\n stdin().read_line(&mut input).unwrap();\n input.trim().chars().map(|k| k.to_digit(10).unwrap()).collect::>()\n };\n\n let la: Vec<_> = a.iter().cloned().take(3).collect();\n let ra: Vec<_> = a.iter().cloned().skip(3).collect();\n\n let l: u32 = a.iter().cloned().take(3).sum();\n let r: u32 = a.iter().cloned().skip(3).sum();\n\n let diff = r as i32 - l as i32;\n\n if diff == 0 {\n println!(\"0\");\n std::process::exit(0);\n }\n\n let (mut up, mut down) = if diff > 0 {\n (ra, la)\n } else {\n (la, ra)\n };\n\n let mut v = Vec::new();\n v.append(&mut up);\n v.append(&mut down);\n\n for a in v.iter_mut().skip(3) {\n *a = 9 - *a;\n }\n\n let diff = diff.abs();\n\n let mut sum = 0u32;\n\n for (i, k) in v.into_iter().rev().enumerate() {\n if sum >= diff as u32 {\n println!(\"{}\", i);\n std::process::exit(0);\n }\n sum += k;\n }\n}\n", "lang": "Rust", "bug_code_uid": "66d0a1ee8a9189e883d9343c344c8b33", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "apr_id": "824b19d7cbedf91405eddaa4080863c8", "difficulty": 1600, "tags": ["greedy", "brute force", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9823948058434262, "equal_cnt": 9, "replace_cnt": 6, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 8, "bug_source_code": "/// ========== 入力用マクロ ====================================================\n/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\n/// FromStr型, Vec, Vec, に対応;\n/// \n/// 入力と平行して処理したいときには使えない -> 後述の read() を使用\n#[macro_export]\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#[macro_export]\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\n#[macro_export]\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\n// ========== 常用関数 =======================================================\npub use std::f64::consts::PI;\n\n// 10^9 + 7 で割ったあまりを出力してください\npub const MOD: u64 = 1_000_000_007;\n\n// atcoder文字列, 使うときは`main()`内にコピペ\n// let atcoder: Vec = vec!['a', 't', 'c', 'o', 'd', 'e', 'r'];\n\n/// 標準入力から\n/// 空白文字で囲まれた1つのトークンを\n/// 指定の型に変換する\npub fn read() -> T {\n use std::io::Read;\n let stdin = std::io::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\n/// 標準入力から1行読み取り\n/// 空白文字で区切って\n/// 指定の型の`Vec`に格納する\npub fn read_vec() -> Vec {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).ok();\n s.trim()\n .split_whitespace()\n .map(|e| e.parse().ok().unwrap())\n .collect()\n}\n\n/// ユークリッドの互除法より\n/// 2数の最大公約数を求める\npub fn gcd(arg1: usize, arg2: usize) -> usize {\n let mut u = if arg1 > arg2 { arg1 } else { arg2 };\n let mut v = if arg1 > arg2 { arg2 } else { arg1 };\n let mut r: usize;\n while v != 0 {\n r = u % v;\n u = v;\n v = r;\n }\n u\n}\n\n/// `Vec` に対して順に `gcd()` を適用して\n/// 配列全体の最大公約数を求める\npub fn gcd_vec(v: &[usize]) -> usize {\n let mut r = v[0];\n for i in &v[1..] {\n r = gcd(r, *i);\n }\n r\n}\n\n/// `gcd()` を利用して2数の最小公倍数を求める\npub fn lcm(arg1: usize, arg2: usize) -> usize {\n arg1 * arg2 / gcd(arg1, arg2)\n}\n\n/// `Vec` に対して順に`lcm()` を適用して\n/// 配列全体の最小公倍数を求める\npub fn lcm_vec(v: &[usize]) -> usize {\n let mut r = v[0];\n for i in &v[1..] {\n r = lcm(r, *i);\n }\n r\n}\n\n/// 与えられた `char` が母音であれば `true` を返す\npub fn is_vowel(c: char) -> bool {\n match c {\n 'a' | 'i' | 'u' | 'e' | 'o' => true,\n _ => false,\n }\n}\n\n/// プログラムを終了\npub fn exit() {\n std::process::exit(0)\n}\n\n// ========== main() ==========================================================\n\nfn main() {\n input! {\n s: chars\n }\n\n let a_count = s.iter().filter(|x| **x == 'a').count();\n let not_a = s.len() - a_count;\n let ans = if a_count > not_a {\n 0\n } else {\n not_a - a_count + 1\n };\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "3c51dfdcb012b89748b40481025ab860", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "apr_id": "5b77e68a91ebcfbcba53972749d0ca16", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7449392712550608, "equal_cnt": 4, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\n\nfn main() {\n let mut si = String::new();\n io::stdin().read_line(&mut si).unwrap();\n let sf = si.trim().matches(\"a\").collect::>().len(); \n println!(\"{}\", sf+1);\n}\n", "lang": "Rust", "bug_code_uid": "ca23d12723c232d567f98c62f8e86e98", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "apr_id": "5373e03bcd7ee1c07f6362ca29f85167", "difficulty": 800, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4692942254812099, "equal_cnt": 9, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_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": "Rust", "bug_code_uid": "cbb2d7c856d5a8fab06ed1019c75187c", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "0b69921cfed09943caf9b92dcd5ddc35", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9942159383033419, "equal_cnt": 6, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 5, "bug_source_code": "#![allow(non_snake_case)]\n#![allow(unused_must_use)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\npub fn main() {\n let nk = rus();\n let n = nk[0];\n let k = nk[1];\n let ss = rus();\n \n let t = ss[k as usize - 1];\n let mut c = 0;\n\n if t == 0 {\n for &s in &ss {\n if s == 0 {\n println!(\"{}\", c);\n return;\n } else {\n c += 1;\n }\n }\n } else {\n for i in k..n {\n if ss[i as usize] == t {\n c += 1;\n } else {\n println!(\"{}\", k + c);\n return;\n }\n }\n }\n println!(\"{}\", n);\n}\n\n\n//read u64\nfn ru() -> u64 {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.trim().parse::().unwrap()\n}\n\n//read u64 vec\nfn rus() -> Vec {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.split_whitespace().map(|x| x.parse::().unwrap())\n .collect::>()\n}\n\n//read i64\nfn ri() -> i64 {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.trim().parse::().unwrap()\n}\n\n//read i64 vec\nfn ris() -> Vec {\n let mut string = String::new();\n std::io::stdin().read_line(&mut string);\n string.split_whitespace().map(|x| x.parse::().unwrap())\n .collect::>()\n}\n\nuse std;\n\ntrait UU {\n fn uu(self) -> T;\n}\n\nimpl UU for Option {\n fn uu(self) -> T {\n self.unwrap()\n }\n}\n", "lang": "Rust", "bug_code_uid": "3871ad3e45e8ef6ce729b707ec97918d", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "b991523353298381b1fb9f3b305d1fdd", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9919883466860888, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let mut s = buf.split_whitespace();\n let n: usize = s.next().unwrap().trim().parse().unwrap();\n let k: usize = s.next().unwrap().trim().parse().unwrap();\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let mut s = buf.split_whitespace();\n let mut a = Vec::new();\n for _ in 0..n {\n let t: u32 = s.next().unwrap().trim().parse().unwrap();\n a.push(t);\n }\n let bound = if a[k - 1] > 0 { a[k - 1] } else { 1 };\n let mut res = 0;\n while a[res] >= bound {\n res += 1;\n }\n println!(\"{}\", res);\n}", "lang": "Rust", "bug_code_uid": "e03d18e337b3d1bd76245186c103fafc", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "2bbe7bda484a68ada383affdfd5511de", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9259036144578313, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 7, "bug_source_code": "use std::io::BufRead;\n\n\nfn read_player_count_and_last_good_index() -> (u64, u64) {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let mut iter = buf.split_whitespace().map(|x| x.parse::());\n (iter.next().unwrap().unwrap(), iter.next().unwrap().unwrap() - 1)\n}\n\n\nfn count_good_players(player_count: u64, last_good_index: u64) -> u64 {\n let mut count: u64 = 0;\n let stdin = std::io::stdin();\n let mut iter = stdin.lock().split(b' ');\n\n for _ in 0..last_good_index {\n let buf = iter.next().unwrap().unwrap();\n let score = std::str::from_utf8(buf.as_slice()).unwrap().trim().parse::().unwrap();\n if score == 0 {\n return count;\n }\n count += 1;\n }\n\n let buf = iter.next().unwrap().unwrap();\n let last_good_score = std::str::from_utf8(buf.as_slice()).unwrap().parse::().unwrap();\n if last_good_score == 0 {\n return count;\n }\n count += 1;\n \n if last_good_index + 1 == player_count {\n return count\n }\n\n loop {\n let buf = iter.next();\n if let None = buf {\n return count;\n }\n let score =\n std::str::from_utf8(buf.unwrap().unwrap().as_slice())\n .unwrap()\n .parse::()\n .unwrap();\n if score < last_good_score {\n break;\n }\n count += 1;\n }\n\n count\n}\n\n\nfn main() {\n let (player_count, last_good_index) = read_player_count_and_last_good_index();\n println!(\"{}\", count_good_players(player_count, last_good_index));\n}\n", "lang": "Rust", "bug_code_uid": "2883156004dea5a19ca14002d70a8445", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "3ff0d66373418d73f570033d3794dab2", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.999290780141844, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{Read, Write, stdin, stdout};\n\npub struct Scanner {\n pub buffer: Vec,\n pub reader: U,\n}\nimpl Scanner {\n pub fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_to_string(&mut input).expect(\"Failed read\");\n self.buffer = input.lines().rev().map(String::from).collect();\n }\n }\n\n pub fn new(reader: U) -> Self {\n return Scanner {\n buffer: vec![],\n reader,\n };\n }\n}\npub fn solution_of_p158a(input: &mut Read, out: &mut Write) {\n let mut scanner = Scanner::new(input);\n\n let line1 = scanner.next::();\n let line1_arr: Vec = line1.split(\" \").map(|s| {\n return s.parse::().unwrap();\n }).collect();\n let k = line1_arr[1];\n\n let line2 = scanner.next::();\n let line2_arr: Vec = line2.split(\" \").map(|s| {\n return s.parse::().unwrap();\n }).collect();\n\n let mut res = 0;\n for item in &line2_arr {\n if item >= &line2_arr[k] && item > &0 {\n res += 1;\n }\n }\n\n write!(out, \"{}\\n\", res).ok();\n}\n\nfn main() {\n solution_of_p158a(&mut stdin(), &mut stdout());\n}\n", "lang": "Rust", "bug_code_uid": "d54d48e3f1a34fbffac85129461e698e", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "d8be585cea9e611bf53379ad37208a35", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9844097995545658, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 3, "bug_source_code": "use std::io;\n\nfn main() {\n let mut nkstr = String::new();\n io::stdin().read_line(&mut nkstr).unwrap();\n let nk: Vec = nkstr\n .trim()\n .split_whitespace()\n .map(|val| val.parse().unwrap())\n .collect();\n let mut astr = String::new();\n io::stdin().read_line(&mut astr).unwrap();\n let mut a: Vec = astr\n .trim()\n .split_whitespace()\n .map(|val| val.parse().unwrap())\n .collect();\n a.sort_unstable();\n a.reverse();\n let mut answer = 0;\n let mut i = 0;\n while a[i] >= a[nk[1] as usize] && a[i] > 0 {\n answer += 1;\n i += 1\n }\n println!(\"{}\", answer);\n}\n", "lang": "Rust", "bug_code_uid": "37b671a857d518c20f32601f7c2671c0", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "a8d18d24db28df5d92112a04cc93069b", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8168724279835391, "equal_cnt": 10, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 9, "bug_source_code": "#[allow(unused_imports)]\nuse std::io::{BufWriter, stdin, stdout, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let n: (i32,i32) = (scan.next::(),scan.next::());\n let mut j : Vec = Vec::new();\n let mut result = 0i16;\n\n for _i in 0..n.0 {\n j.push(scan.next::());\n }\n\n for score in j {\n if score >= j(n.1) && score > 0 {\n result +=1;\n }\n }\n\n println!(\"{}\", result);\n}\n", "lang": "Rust", "bug_code_uid": "9e84e4451c9aa2d05d3e26bf22828210", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "eb0203e7162fa2901e38e08d5a09c2cd", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9969849246231156, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "#[allow(unused_imports)]\nuse std::io::{BufWriter, stdin, stdout, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let n: (i32,i32) = (scan.next::(),scan.next::());\n let mut j = vec![0; n.0 as usize];\n let mut result = 0i16;\n\n for _i in 0..n.0 {\n j[_i as usize] = scan.next::();\n }\n\n for score in 0..n.0 {\n if j[score as usize] >= j[n.1 as usize] && j[score as usize] > 0{\n result +=1;\n }\n }\n\n println!(\"{}\", result);\n}\n", "lang": "Rust", "bug_code_uid": "b065d343896b1887482534ef0f34246f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "eb0203e7162fa2901e38e08d5a09c2cd", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9962546816479401, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n\tlet mut inp = String::new();\n\tlet mut ans: i32 = 0;\n\tlet k: u32;\n\tio::stdin().read_line(&mut inp).unwrap();\n\tk = inp\n\t\t.trim()\n\t\t.split_whitespace()\n\t\t.nth(1)\n\t\t.unwrap()\n\t\t.parse()\n\t\t.unwrap();\n\tinp.clear();\n\tio::stdin().read_line(&mut inp).unwrap();\n\tlet mut balls: Vec = Vec::new();\n\tfor i in inp.split_whitespace() {\n\t\tballs.push(i.parse().unwrap());\n\t}\n\tfor i in 0..balls.len() {\n\t\tif balls[i as usize] >= balls[k as usize] && balls[i as usize] > 0 {\n\t\t\tans += 1;\n\t\t}\n\t}\n\tprintln!(\"{}\", ans);\n}\n", "lang": "Rust", "bug_code_uid": "2cc9a894013205ec2d232861fe6f8f37", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "b8d3a48d4f93d3a46a4141fb827328ee", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9973753280839895, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn readln() -> String {\n let stdin = std::io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).unwrap();\n String::from(line.trim())\n}\n\nmacro_rules! scanln {\n ($($ty: ty),*) => {{\n let line = readln();\n let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$ty>().unwrap()),*)\n }}\n}\n\nfn main() {\n let (n, mut k) = scanln!(i32, i32);\n let mut a: Vec = readln()\n .split_whitespace()\n .map(|e| e.parse().unwrap())\n .collect();\n a.sort();\n if k > n {\n k = n;\n }\n let a_k = a[a.len() - k as usize + 1];\n let make_it_through = a.iter()\n .filter(|&&a_i| a_i >= a_k && a_i > 0)\n .count();\n println!(\"{}\", make_it_through);\n}\n", "lang": "Rust", "bug_code_uid": "5c3423e6bef56348742a657e7c26aa5e", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "b69fe3b597d9ac98586e1ea6b36d4744", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8910396503278176, "equal_cnt": 19, "replace_cnt": 7, "delete_cnt": 2, "insert_cnt": 10, "fix_ops_cnt": 19, "bug_source_code": "use std::io::{self, BufRead, Write};\n\n// score >= kth = pass\n// n participants\n//\n// n = 8\n// k = 5\n\nfn main() -> io::Result<()> {\n let stdin = io::stdin();\n let mut lines = stdin.lock().lines();\n let stdout = io::stdout();\n let mut stdout = stdout.lock();\n\n let k = lines\n .next()\n .unwrap()\n .unwrap()\n .split_whitespace()\n .last()\n .unwrap()\n .parse::()\n .unwrap();\n\n writeln!(stdout, \"{}\", &calc(&lines.next().unwrap().unwrap(), k))?;\n\n Ok(())\n}\n\nfn calc(s: &str, k: usize) -> usize {\n let mut nums = s.split_whitespace().map(|s| s.parse().unwrap());\n for i in 0..k-1 {\n let n: usize = nums.next().unwrap();\n if n == 0 {\n return i;\n }\n }\n let n = nums.next().unwrap();\n if n == 0 {\n return k;\n }\n for i in 0.. {\n if nums.next().unwrap() != n {\n return k + i\n }\n }\n k\n}\n\n#[cfg(test)]\nmod tests {\n\n use super::*;\n\n #[test]\n fn zeros() {\n let input = \"0 0 0 0\";\n let left = calc(input, 2);\n let right = 0;\n assert_eq!(left, right);\n }\n\n #[test]\n fn input1() {\n let input = \"10 9 8 7 7 7 5 5\";\n let left = calc(input, 5);\n let right = 6;\n assert_eq!(left, right);\n }\n\n #[test]\n fn wrong() {\n let input = \"3 2 1 0 0\";\n let left = calc(input, 5);\n let right = 3;\n assert_eq!(left, right);\n }\n}", "lang": "Rust", "bug_code_uid": "dbca267637dd54182eaed1856cd4434f", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "7443fa38fbffa3bbcb8d5c9d1b8ff511", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9131684876365728, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\n\nfn main() {\n let mut intro = String::new();\n io::stdin().read_line(&mut intro).unwrap();\n\n let (n, k) = intro.split_at(1);\n let n: u8 = n.trim().parse().unwrap();\n let k: u8 = k.trim().parse().unwrap();\n\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n\n let mut iter = input.split_whitespace();\n \n let mut output: u8 = 0;\n let mut cut_off: u8 = 0;\n\n for i in 0..n {\n let num = iter.next().unwrap();\n let num: u8 = num.parse().unwrap();\n\n if num == 0 { break; }\n\n if i < k { output += 1; }\n else if i == k { \n cut_off = num;\n output += 1;\n }\n else if num >= cut_off {\n output += 1;\n }\n else { break; }\n }\n\n println!(\"{}\", output);\n}\n\n\n", "lang": "Rust", "bug_code_uid": "3173455b34b4f16fd2defdb5e5b9ddd2", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "ff32c548a70ac679e041089f05af1862", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9962746141564662, "equal_cnt": 7, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 6, "bug_source_code": "use std::io;\n\nfn main() {\n let mut limits = String::new();\n\n io::stdin().read_line(&mut limits).expect(\"unknown error\");\n\n let mut scores = String::new();\n\n io::stdin().read_line(&mut scores).expect(\"unknown error\");\n\n let n: usize = limits\n .split(\" \")\n .next()\n .unwrap()\n .trim()\n .parse()\n .expect(\"Not a number\");\n let k: usize = limits\n .split(\" \")\n .last()\n .unwrap()\n .trim()\n .parse()\n .expect(\"Not a number\");\n\n let scores: Vec = scores\n .trim()\n .split_whitespace()\n .map(|s| s.parse().expect(\"parse error\"))\n .collect();\n\n let mut answer: u32 = 0;\n\n for i in 0..n {\n if let (Some(val_1), Some(val_2)) = \n (&scores.get(i), &scores.get(k)){\n if val_1 >= val_2 && val_1 > 0{\n answer+=1;\n }\n }\n }\n\n println!(\"{}\", answer);\n}\n", "lang": "Rust", "bug_code_uid": "c70ebe9bed320eb7df92c00f534a58ff", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "63a21d941bb4184fac9011554411a4ee", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9996130030959752, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n\n let mut first_input = String::new();\n std::io::stdin()\n .read_line(&mut first_input)\n .expect(\"Value not found\");\n\n let inputs: Vec<&str> = first_input.split_whitespace().collect(); \n let num_contestant: i32 = inputs[0].parse().unwrap();\n let k_positon: i32 = inputs[1].parse().unwrap();\n // let num_contestant = num_contestant - 1;\n\n if (k_positon > num_contestant) || (num_contestant > 50) {\n return ()\n }\n\n // println!(\"n = {} k = {}\", num_contestant, k_positon);\n\n let mut second_input = String::new();\n std::io::stdin()\n .read_line(&mut second_input)\n .expect(\"Value not found\");\n\n let score_input: Vec = second_input.split_whitespace()\n .map(|s| s.parse()\n .expect(\"parse error\"))\n .collect();\n\n let count: usize = score_input.len();\n let contestant_input_count: usize = inputs[0].parse().unwrap();\n // println!(\"score_input = {:?} count = {} \", score_input, count);\n // println!(\"contestant_input_count = {}\", contestant_input_count);\n\n if (contestant_input_count != count) || (count > 100) {\n return ()\n }\n\n // println!(\"Score input at 0: {:?}\", score_input[0]);\n\n let mut i: usize = 0;\n for _i in 0..contestant_input_count-1 {\n if (score_input[i] > score_input[i+1]) || (score_input[i] == score_input[i+1]) {\n // println!(\"Check Sucess, {}\", i); // don't need to compare the last element of the vector\n // so therefore contestant_input_count - 1\n i = i + 1;\n }\n else {\n break;\n }\n }\n // let mut i: usize = 0;\n // while i < count-1 {\n // if ( score_input[i] > score_input[i+1] ) || (score_input[i] == score_input[i+1]) {\n // println!(\"check sucess, {}\",i);\n // }\n // else {\n // break;\n // }\n // i += 1;\n // }\n // let mut i: usize = 0;\n\n let mut final_count: usize = 0;\n let mut i: usize = 0;\n let k: usize = inputs[1].parse().unwrap();\n for _i in &score_input {\n if (score_input[k] <= score_input[i]) && (score_input[i] > 0) {\n final_count = final_count + 1;\n i += 1;\n }\n }\n println!(\"{}\", final_count);\n}", "lang": "Rust", "bug_code_uid": "8ab682f2c44effcbcd9966c3419f69bc", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "396917af971a913778573abd87bd4cbb", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9993493819128172, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{self, prelude::*};\nuse std::str;\n\nstruct Scanner {\n reader: R,\n buf_str: Vec,\n buf_iter: str::SplitWhitespace<'static>,\n}\nimpl Scanner {\n fn new(reader: R) -> Self {\n Self { reader, buf_str: Vec::new(), buf_iter: \"\".split_whitespace() }\n }\n fn next(&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.read_until(b'\\n', &mut self.buf_str).expect(\"Failed read\");\n self.buf_iter = unsafe {\n let slice = str::from_utf8_unchecked(&self.buf_str);\n std::mem::transmute(slice.split_whitespace())\n }\n }\n }\n}\n\nfn main() {\n\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n\n let (n,k,mut cnt) = (scan.next::(),scan.next::(),0);\n let v = (0..n).map(|_| scan.next::()).collect::>();\n if v[k]!=0 {\n for i in k..n {\n if v[i]!=v[k-1] {\n break;\n }\n cnt+=1;\n }\n writeln!(out,\"{}\",k+cnt).ok();\n } else {\n for i in (0..k-1).rev() {\n if v[i]!=v[k-1] {\n break;\n }\n cnt+=1;\n }\n writeln!(out,\"{}\",k-cnt-1).ok();\n } \n}\n\n\n", "lang": "Rust", "bug_code_uid": "72d8354dbd48e502519bd40ec1ba2af4", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "apr_id": "e908ebe09499927d2c9a368c0f2d4727", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.670076726342711, "equal_cnt": 22, "replace_cnt": 10, "delete_cnt": 6, "insert_cnt": 7, "fix_ops_cnt": 23, "bug_source_code": "fn main(){\n let mut input = 1; let mut whiteCount = 0; let mut blackCount = 0; \n while i <= 8{\n let mut input1 = String::new();\n let b1 = std::io::stdin().read_line(&mut input1).unwrap();\n \n for contC in input.chars(){ \n blackCount += calcular_black(contC); whiteCount += calcular_white(contC);\n \n }\n i += 1; \n }\n \n if whiteCount < blackCount\n println!(\"Black\");\n }\n else if whiteCount > blackCount{\n println!(\"White\");\n }\n else{\n println!(\"Draw\");\n }\n }\n\n\n\nfn calcular_white(c:char) -> i32{\n match c{ 'Q'=> 9, 'R'=> 5, 'B'=> 3,'N'=> 3,'P'=> 1, _ => 0,}\n \n}\nfn calcular_black(c:char) -> i32{\n match c{ 'q'=> 9, 'r'=> 5,'b'=> 3,'n'=> 3,'p'=> 1, _ => 0, }\n \n}\n\n\n", "lang": "Rust", "bug_code_uid": "ebe19b49606a83ff91f577a50a375ddf", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "a23c267a079adadb7a2a8e2e4a32771f", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9760923330585326, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "fn contar_negras (vector_c: &Vec) -> i32 {\n let mut negras: i32 = 0;\n\n for caracter in vector_c{\n match caracter{\n 'q' => negras +=9,\n 'r' => negras +=5,\n 'b' => negras +=3,\n 'n' => negras +=3,\n 'p' => negras +=1,\n _ => negras +=0,\n }\n }\n negras\n}\n\nfn contar_blancas (vector_c: &Vec) -> i32 {\n let mut blancas: i32 = 0;\n\n for caracter in vector_c{\n match caracter{\n 'Q' => blancas +=9,\n 'R' => blancas +=5,\n 'B' => blancas +=3,\n 'N' => blancas +=3,\n 'P' => blancas +=1,\n _ => blancas +=0,\n }\n }\n blancas\n}\n\n\n\nfn main() {\n use std::io::{stdin};\n let mut blanco :i32 = 0;\n let mut negro :i32 = 0;\n let mut s=String::new();\n for _ in 0..8{\n stdin().read_line(&mut s).expect(\"Error\");\n let char_vec: Vec = s.chars().collect();\n negro = contar_negras(&char_vec);\n blanco = contar_blancas(&char_vec);\n }\n if blanco > negro {\n println!(\"White\");\n } else {\n println!(\"Black\");\n }\n //println!(\"{}, {}\",negro, blanco);\n}\n", "lang": "Rust", "bug_code_uid": "9aa76c3d4cded8dc401991dfd08ed4bd", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "apr_id": "8fa6a1163aa82a05141b5bc8d16ca8f9", "difficulty": 900, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8944337811900192, "equal_cnt": 9, "replace_cnt": 2, "delete_cnt": 4, "insert_cnt": 3, "fix_ops_cnt": 9, "bug_source_code": "fn main() {\n let mut word = String::new();\n std::io::stdin().read_line(&mut word).unwrap();\n\n let word = word.trim();\n let len = word.len();\n let mut i: usize = 0;\n\n while i < len {\n if i <= len - 3 &&\n word.as_bytes()[i] == b'W' &&\n word.as_bytes()[i + 1] == b'U' &&\n word.as_bytes()[i + 2] == b'B' {\n i += 3;\n }\n else {\n print!(\"{}\", word.as_bytes()[i] as char);\n i += 1;\n }\n }\n\n println!();\n}", "lang": "Rust", "bug_code_uid": "cffd82b479c47db336051d26bcaeaf6d", "src_uid": "edede580da1395fe459a480f6a0a548d", "apr_id": "5e6211f035911f7ca96f8df1b140b5eb", "difficulty": 900, "tags": ["strings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.886052871467639, "equal_cnt": 12, "replace_cnt": 2, "delete_cnt": 7, "insert_cnt": 3, "fix_ops_cnt": 12, "bug_source_code": "fn main() {\n let mut word = String::new();\n std::io::stdin().read_line(&mut word).unwrap();\n\n let word = word.trim();\n let len = word.len();\n let mut i: usize = 0;\n\n while i < len {\n if i <= len - 3 {\n if word.as_bytes()[i] == b'W' &&\n word.as_bytes()[i + 1] == b'U' &&\n word.as_bytes()[i + 2] == b'B' {\n println!(\" \");\n i += 3;\n }\n }\n else {\n print!(\"{}\", word.as_bytes()[i] as char);\n i += 1;\n }\n }\n\n println!();\n}", "lang": "Rust", "bug_code_uid": "7387e6528a8303e78d821121949e64b2", "src_uid": "edede580da1395fe459a480f6a0a548d", "apr_id": "5e6211f035911f7ca96f8df1b140b5eb", "difficulty": 900, "tags": ["strings"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.8939430213071582, "equal_cnt": 11, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 11, "bug_source_code": "#![allow(unused_parens)]\n#![allow(unused_imports)]\n#![allow(non_upper_case_globals)]\n#![allow(non_snake_case)]\n#![allow(unused_mut)]\n#![allow(unused_variables)]\n#![allow(dead_code)]\n\n#[allow(unused_macros)]\nmacro_rules! invec {\n ( $ t : ty ) => {{\n let mut s = String::new();\n match std::io::stdin().read_line(&mut s) {\n Ok(0) => Vec::<$t>::new(),\n Ok(n) => s\n .trim()\n .split_whitespace()\n .map(|s| s.parse::<$t>().unwrap())\n .collect::>(),\n Err(_) => Vec::<$t>::new(),\n }\n }};\n}\n\n#[allow(unused_macros)]\nmacro_rules! get {\n ($t:ty) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().parse::<$t>().unwrap()\n }\n };\n ($($t:ty),*) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n (\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\n )\n }\n };\n ($t:ty; $n:expr) => {\n (0..$n).map(|_|\n get!($t)\n ).collect::>()\n };\n ($($t:ty),*; $n:expr) => {\n (0..$n).map(|_|\n get!($($t),*)\n ).collect::>()\n };\n ($t:ty ;;) => {\n {\n let mut line: String = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.split_whitespace()\n .map(|t| t.parse::<$t>().unwrap())\n .collect::>()\n }\n };\n ($t:ty ;; $n:expr) => {\n (0..$n).map(|_| get!($t ;;)).collect::>()\n };\n}\n\n#[allow(unused_macros)]\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 mut 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\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\n let mut $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\n#[allow(unused_macros)]\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n\n ($next:expr, [$t:tt]) => {\n {\n let len = read_value!($next, usize);\n (0..len).map(|_| read_value!($next, $t)).collect::>()\n }\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n#[allow(unused_macros)]\n#[cfg(debug_assertions)]\nmacro_rules! mydbg {\n //($arg:expr) => (dbg!($arg))\n //($arg:expr) => (println!(\"{:?}\",$arg));\n ($($a:expr),*) => {\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\n }\n}\n#[cfg(not(debug_assertions))]\nmacro_rules! mydbg {\n ($($arg:expr),*) => {};\n}\n\nmacro_rules! echo {\n ($($a:expr),*) => {\n $(println!(\"{}\",$a))*\n }\n}\n\nuse std::cmp::*;\nuse std::collections::*;\nuse std::ops::{Add, Div, Mul, Sub};\n\n#[allow(dead_code)]\nstatic INF_I64: i64 = i64::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_I32: i32 = i32::max_value() / 2;\n#[allow(dead_code)]\nstatic INF_USIZE: usize = usize::max_value() / 2;\n#[allow(dead_code)]\nstatic M_O_D: usize = 1000000007;\n#[allow(dead_code)]\nstatic PAI: f64 = 3.1415926535897932;\n\ntrait IteratorExt: Iterator {\n fn toVec(self) -> Vec;\n}\n\nimpl IteratorExt for T {\n fn toVec(self) -> Vec {\n self.collect()\n }\n}\n\ntrait CharExt {\n fn toNum(&self) -> usize;\n fn toAlphabetIndex(&self) -> usize;\n fn toNumIndex(&self) -> usize;\n}\nimpl CharExt for char {\n fn toNum(&self) -> usize {\n return *self as usize;\n }\n fn toAlphabetIndex(&self) -> usize {\n return self.toNum() - 'a' as usize;\n }\n fn toNumIndex(&self) -> usize {\n return self.toNum() - '0' as usize;\n }\n}\n\ntrait VectorExt {\n fn joinToString(&self, s: &str) -> String;\n}\nimpl VectorExt for Vec {\n fn joinToString(&self, s: &str) -> String {\n return self\n .iter()\n .map(|x| x.to_string())\n .collect::>()\n .join(s);\n }\n}\n\ntrait StringExt {\n fn get_reverse(&self) -> String;\n}\nimpl StringExt for String {\n fn get_reverse(&self) -> String {\n self.chars().rev().collect::()\n }\n}\n\ntrait UsizeExt {\n fn pow(&self, n: usize) -> usize;\n}\nimpl UsizeExt for usize {\n fn pow(&self, n: usize) -> usize {\n return ((*self as u64).pow(n as u32)) as usize;\n }\n}\n\nfn main() {\n let n = get!(usize);\n let a = invec!(usize);\n let mut ans = 0;\n let mut p = 0;\n for i in 0..n {\n mydbg!(p);\n let item = a[i];\n if item == 0 {\n p = item;\n ans += 1;\n } else if item != 3 && item != p {\n p = item;\n } else if item == 3 && p != 0 {\n p = if p == 1 { 2 } else { 1 };\n } else if item == 3 && p == 0 {\n if i + 1 != n {\n let next = a[i + 1];\n p = if next == 1 { 2 } else { 1 };\n } else {\n p = 1;\n }\n } else {\n p = 0;\n ans += 1;\n }\n }\n echo!(ans);\n}\n", "lang": "Rust", "bug_code_uid": "e25985c6405c1f9dc3c6ca37e1a6080e", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "apr_id": "96ff12ab2a4cae3bb2b7c2e67bace9a6", "difficulty": 1400, "tags": ["dp", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9421841541755889, "equal_cnt": 4, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "// 991E\nuse std::io;\n\nfn main() {\n let mut a = String::new();\n io::stdin().read_line(&mut a).unwrap();\n let a = a.trim();\n\n let mut counts = [0u64; 10];\n\n for c in a.chars() {\n counts[c.to_digit(10).unwrap() as usize] += 1;\n }\n\n let mut fa = [0u64; 30];\n\n let with_zero = count(&mut counts, 0, &mut fa);\n let mut correct = with_zero;\n if counts[0] > 0 {\n counts[0] = 0;\n correct -= count(&mut counts, 0, &mut fa);\n }\n println!(\"{}\", correct);\n}\n\nfn factorial(n: u64, fa: &mut [u64]) -> u64 {\n if n == 0 {\n fa[n as usize] = 1;\n } else if fa[n as usize] == 0 {\n fa[n as usize] = factorial(n - 1, fa) * n;\n }\n return fa[n as usize];\n}\n\nfn count(counts: &mut [u64], change_here: usize, fa: &mut [u64]) -> u64 {\n if change_here == 10 {\n // All numbers are fixed now\n let numerator = factorial(counts.iter().sum(), fa);\n let mut denominator = 1;\n for c in counts {\n denominator *= factorial(*c, fa);\n }\n return numerator / denominator;\n }\n\n if counts[change_here] == 0 {\n return count(counts, change_here + 1, fa);\n }\n\n let mut add = 0;\n for i in 1..(counts[change_here] + 1) {\n counts[change_here] = i;\n add += count(counts, change_here + 1, fa);\n }\n return add;\n}\n", "lang": "Rust", "bug_code_uid": "87ee62ba78efcfe07149879f3e3ef0c5", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "apr_id": "68501255bbaeddf75bbd06e7a5a2e06d", "difficulty": 1800, "tags": ["brute force", "math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9495202336253651, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_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 (A, B) = readl!(i64, i64);\n let (mut a, mut b) = (A, B);\n loop {\n if (a == 0) | (b == 0) { break; }\n else if a >= (2*b) {\n a -= 2*b;\n } else if b >= (2*a) {\n b -= 2*a;\n } else {\n break;\n }\n }\n println!(\"{} {}\", a, b);\n}", "lang": "Rust", "bug_code_uid": "864fb4710bd39f8b99722f571af2ff67", "src_uid": "1f505e430eb930ea2b495ab531274114", "apr_id": "b840c41a349ce844baeb9218ac472cf2", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9984756097560976, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::io::Stdin;\nuse std::str::FromStr;\n\nfn read_line(stdin : &Stdin, line : &mut String) {\n match stdin.read_line(line) {\n Ok(_) => return,\n Err(msg) => panic!(\"Could not read line! Message: {}.\", msg),\n }\n}\n\nfn parse_t(s : &str) -> T {\n match s.trim().parse() {\n Ok(y) => y,\n Err(_) => panic!(\"Could not read from string!\"),\n }\n}\n\nfn read_ts(stdin : &Stdin, ts : &mut Vec) {\n let mut line = String::new();\n read_line(stdin, &mut line);\n let word_iter = line.split_whitespace();\n for word in word_iter {\n let x = parse_t(word);\n ts.push(x);\n }\n}\n\nfn process(a : u64, b : u64) -> (u64, u64) {\n let mut m_a = a;\n let mut m_b = b;\n loop {\n if (m_a == 0) || (m_b == 0) {\n break;\n } else {\n let two_m_a = 2 * m_a;\n let two_m_b = 2 * m_b;\n if m_a >= two_m_b {\n m_a = m_a - two_m_b;\n } else if m_b >= two_m_a {\n m_b = m_b - two_m_a;\n } else {\n break;\n }\n }\n }\n (m_a, m_b)\n}\n\nfn main() {\n let stdin = io::stdin();\n let mut a_b = vec![];\n read_ts(&stdin, &mut a_b);\n let (c, d) = process(a_b[0], a_b[1]);\n println!(\"{} {}\", c, d);\n}\n", "lang": "Rust", "bug_code_uid": "0c7e329fc331203c4471036844ef955b", "src_uid": "1f505e430eb930ea2b495ab531274114", "apr_id": "65e7123ca3a27f4742ad9dff81447f0a", "difficulty": 1100, "tags": ["math", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.97875, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::ascii::AsciiExt;\n\npub fn main() {\n let stdin = io::stdin();\n let mut line = String::new();\n stdin.read_line(&mut line).unwrap();\n\n print!(\"{}\", modify(&line));\n}\n\npub fn modify(input: &str) -> String {\n let mut output = String::new();\n\n for c in input.bytes().map(|c| c.to_ascii_lowercase()) {\n match c {\n b'a' | b'o' | b'y' | b'e' | b'u' | b'i' => {}\n _ => {\n output.push('.');\n output.push(c as char);\n }\n }\n }\n\n output\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn it_works() {\n assert_eq!(\".t.r\", modify(\"tour\"));\n assert_eq!(\".c.d.f.r.c.s\", modify(\"Codeforces\"));\n assert_eq!(\".b.c.b\", modify(\"aBAcAba\"));\n }\n}\n", "lang": "Rust", "bug_code_uid": "d37aeb4c64c9dd3ea6505716f55f57df", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "fa7931d16e6c4e1dfaf077be8a20ae11", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9963160049119935, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io::Read;\n\nfn input(read_file: bool) -> String {\n if read_file {\n let mut file = std::fs::File::open(\"sample.txt\").unwrap();\n let mut buf = String::new();\n file.read_to_string(&mut buf).unwrap();\n buf\n } else {\n let mut buf = String::new();\n std::io::stdin().read_to_string(&mut buf).unwrap();\n buf.trim_end().to_owned()\n }\n}\n\nfn solve(ws: &mut std::str::SplitWhitespace) {\n let s: Vec = ws.next().unwrap().chars().collect();\n let set = \"aiueo\"\n .chars()\n .map(|c| c)\n .collect::>();\n let ans: Vec = s\n .iter()\n .map(|c| c.to_ascii_lowercase())\n .filter(|c| !set.contains(c))\n .collect();\n\n let ans: String = ['.']\n .iter()\n .cycle()\n .zip(ans)\n .fold(String::from(\"\"), |mut ss, (&c1, c2)| {\n ss.push(c1);\n ss.push(c2);\n ss\n });\n\n println!(\"{}\", ans);\n}\n\nfn main() {\n const READ_FROM_FILE: bool = false;\n\n let s = input(READ_FROM_FILE);\n let mut ws = s.split_whitespace();\n\n // let t = ws.next().unwrap().parse().unwrap();\n // for _ in 0..t {}\n solve(&mut ws);\n}\n", "lang": "Rust", "bug_code_uid": "3aa8f75dc7132778d514c5ef47dbb9df", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "264a19bb4f512f8eb888d20b93ca73a3", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9978448275862069, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, prelude::*};\n\n#[allow(unused_macros)]\nmacro_rules! spread {\n ($w: expr, $v: expr) => {\n for x in $v.iter() {\n write!($w, \"{} \", x).unwrap();\n }\n writeln!($w).unwrap();\n };\n}\n\n#[allow(dead_code)]\nfn parse(x: &str) -> T {\n match x.trim().parse::() {\n Ok(n) => n,\n _ => panic!(\"\")\n }\n}\n\n#[allow(dead_code)]\nfn input(r: &mut BufReader, cap: usize) -> String {\n let mut t = String::with_capacity(cap);\n r.read_line(&mut t).unwrap();\n \n if t.ends_with('\\n') {\n t.pop();\n if t.ends_with('\\r') {\n t.pop();\n }\n }\n\n t\n}\n\nfn main() {\n let stdin = stdin();\n let stdout = stdout();\n\n solve(&mut BufReader::new(stdin.lock()), &mut BufWriter::new(stdout.lock()));\n}\n\n#[allow(unused_variables)]\n#[allow(clippy::many_single_char_names)]\nfn solve(r: &mut BufReader, w: &mut BufWriter) {\n let s = input(r, 100);\n let mut v = String::with_capacity(s.len()<<1);\n\n for c in s.chars() {\n let c = if (c as u8) < 97 {((c as u8) + 32) as char} else {c};\n match c {\n 'a' | 'e' | 'i' | 'o' | 'u' => {},\n _ => {\n v.push('.');\n v.push(c);\n }\n }\n }\n write!(w, \"{}\", v);\n}", "lang": "Rust", "bug_code_uid": "25f87e3c67b343c38b1ac1671714fd22", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "51b88351079719aa02fb66f08165a1f7", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.573208722741433, "equal_cnt": 17, "replace_cnt": 10, "delete_cnt": 6, "insert_cnt": 1, "fix_ops_cnt": 17, "bug_source_code": "use std::io;\nuse regex::Regex;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n\n println!(\"{}\", Expr::new().calc(&s));\n}\n\nstruct Expr(Vec);\n\nimpl Expr {\n fn new() -> Expr {\n let r1 = Regex::new(r\"(?i)[aeiou]\").unwrap();\n let r2 = Regex::new(r\"(?i)([bcdfghjklmnpqrstvwxyz])\").unwrap();\n Expr(vec![r1, r2])\n }\n\n fn calc(&self, s: &str) -> String {\n self.0[1].replace_all(&*self.0[0].replace_all(s, \"\"), \".$1\").to_lowercase()\n }\n}\n\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test_vowels_removed() {\n assert_eq!(Expr::new().calc(\"aeiou\"), \"\");\n }\n\n #[test]\n fn test_vowels_removed_from_mix() {\n assert_eq!(Expr::new().calc(\"abcdefg\"), \".b.c.d.f.g\");\n }\n\n #[test]\n fn test_dot_only_consonants() {\n assert_eq!(Expr::new().calc(\"zxy\"), \".z.x.y\");\n }\n\n #[test]\n fn test_upper_consonants() {\n assert_eq!(Expr::new().calc(\"RZW\"), \".r.z.w\");\n }\n}", "lang": "Rust", "bug_code_uid": "e0fc4fcffa62c21d73527f45f17fd7f1", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "8dfd8b9ffe3aaaef9d41d5aefc692bc2", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9994574064026045, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n\n println!(\"{}\", calc(&s));\n}\n\nfn calc(s: &str) -> String {\n let mut res = String::with_capacity(110);\n for c in s.trim().chars() {\n match c.to_ascii_lowercase() {\n c if \"aeiou\".contains(c) => (),\n c => res.push_str(&format!(\".{}\", c))\n }\n }\n res\n}\n\n#[cfg(test)]\nmod tests {\n use super::*;\n\n #[test]\n fn test_vowels_removed() {\n assert_eq!(calc(\"aeiou\"), \"\");\n }\n\n #[test]\n fn test_vowels_removed_from_mix() {\n assert_eq!(calc(\"abcdefg\"), \".b.c.d.f.g\");\n }\n\n #[test]\n fn test_dot_only_consonants() {\n assert_eq!(calc(\"zxy\"), \".z.x.y\");\n }\n\n #[test]\n fn test_upper_consonants() {\n assert_eq!(calc(\"RZW\"), \".r.z.w\");\n }\n\n #[test]\n fn test_tour() {\n assert_eq!(calc(\"tour \"), \".t.r\");\n }\n}", "lang": "Rust", "bug_code_uid": "0d03da820384f52ee41d35d0a637c47e", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "apr_id": "8dfd8b9ffe3aaaef9d41d5aefc692bc2", "difficulty": 1000, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9392781316348195, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 3, "fix_ops_cnt": 4, "bug_source_code": "// extern crate rand;\n// #[macro_use]\n// extern crate scan_rules;\n\nuse std::io;\n// use rand::Rng;\n// use std::cmp::Ordering;\nfn main() {\n\t// let result=try_readln!{\n\t// \t(let a:u32,let b:u32) =>(a,b)\n\t// };\n\t// let mut n:u32=0;\n\t// let mut t:u32=0;\n\t// match result{\n\t// \tOk((a,b))=>{\n\t// \t\tn=a;\n\t// \t\tt=b;\n\t// \t},\n\t// \tErr(e)=>println!(\"some error occured\"),\n\t// };\n\tlet mut some=String::new();\n\tio::stdin().read_line(&mut some).expect(\"Some error occured\");\n\tlet option=some.trim().split(\" \").map(str::parse::).collect::>();\n\tlet n=match option[0]{\n\t\tOk(num)=>num,\n\t\tErr(_)=>0,\n\t};\n\tlet t=match option[1]{\n\t\tOk(num)=>num,\n\t\tErr(_)=>0,\n\t};\n\tlet mut queue=String::new();\n\tio::stdin().read_line(&mut queue)\n\t\t.expect(\"Error reading string\");\n\tlet queue=queue.trim();\n\tlet mut a=Vec::new();\n\tfor x in queue.chars(){\n\t\tif x=='G'{\n\t\t\ta.push(1);\n\t\t}\n\t\telse {\n\t\t\ta.push(0);\n\t\t}\n\t}\n\tfor _x in 0..t{\n\t\tfor i in (1..n).rev(){\n\t\t\tif a[i as usize]==1&&a[(i-1)as usize]==0{\n\t\t\t\ta[i as usize]=0;\n\t\t\t\ta[(i-1) as usize]=1;\n\t\t\t}\n\t\t}\n\t}\n\tfor x in a{\n\t\tif x==1{\n\t\t\tprint!(\"G\");\n\t\t}\n\t\telse {\n\t\t\tprint!(\"B\");\n\t\t}\n\t}\n\n}\n", "lang": "Rust", "bug_code_uid": "9f2c0487e6ebf06b0cb6257a4bae8927", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "c05e7abea6b31f6e1a10bc114e91c654", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9546555901696089, "equal_cnt": 5, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused)] use std::io::*;\n#[allow(unused)] use std::collections::*;\n#[allow(unused)] use std::mem::*;\n#[allow(unused)] use std::num::*;\n#[allow(unused)] use std::cmp::*;\n#[allow(unused)] fn strarr() -> Vec {\n let mut inp = String::new();\n stdin().read_line(&mut inp).ok();\n inp.split(' ').map(|x| x.trim()).filter(|x| x.len() != 0).map(|x| x.to_string()).collect() }\n#[allow(unused)] macro_rules! scan { ($($x:ty), +) => {{\n let s = strarr(); let mut cnt : usize = 0;\n fn next(cnt: &mut usize, p: &Vec) -> T\n where T:std::str::FromStr\n { *cnt += 1; p[*cnt-1].parse().ok().unwrap() }\n ($(next::<$x>(&mut cnt, &s)), +)\n }}; }\n#[allow(unused)] macro_rules! arr { ($n:expr, $T:ty) => {{\n let mut s = strarr(); let mut v = Vec::new();\n for i in 0..$n { v.push(s[i as usize].parse::<$T>().unwrap()); } v\n }}; }\n\n///////////////////////////////////////////////////////////////////////////////\n\nfn main()\n{\n let (n, t) = scan!(i32, i32);\n let mut s : Vec = scan!(String).chars().collect();\n for _ in 0..t {\n for i in (0..n-1).rev() {\n if s[i as usize] == 'B' && s[(i+1) as usize] == 'G' {\n let t = s[i as usize];\n s[i as usize] = s[(i + 1) as usize];\n s[(i + 1) as usize] = t;\n }\n }\n }\n for c in s { print!(\"{}\", c); } println!();\n}\n", "lang": "Rust", "bug_code_uid": "9e01ae6627aa2e124ef73b0afd1e79c9", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "2c9b25b893227dc5a05ee4e5e1f49ecf", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9465948064674179, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "fn read()->(T,P){\n let mut line=String::new();\n std::io::stdin().read_line(&mut line).expect(\"Ошибка в чтении\");\n let mut line=line.split_whitespace();\n (\n match line.next().unwrap().parse::(){\n Ok(n)=>n,\n Err(_)=>panic!(\"Ошибка в переводе\"),\n },\n match line.next().unwrap().parse::

(){\n Ok(n)=>n,\n Err(_)=>panic!(\"Ошибка в переводе\"),\n }\n )\n}\nfn main(){\n let (people,time)=read::();\n let mut line=String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut queue:Vec=line.trim().chars().collect();\n let mut girl:Vec=Vec::new();\n for i in 0..time{\n for c in (1..queue.len()).rev(){\n if queue[c-1]!='G'{\n let k=queue[c];\n queue[c]=queue[c-1];\n queue[c-1]=k\n }\n }\n }\n print!(\"{}\",queue.into_iter().collect::());\n}", "lang": "Rust", "bug_code_uid": "5bcc38c1ba0c74b952899e3797e69c6c", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "f7b5760adb606e710eb877bddb93db95", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9309600862998921, "equal_cnt": 13, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 10, "fix_ops_cnt": 12, "bug_source_code": "use std::io;\n\nfn main() {\n let (num,turns,mut list)=input();\n for _ in 1..turns{\n for i in 1..num{\n if &list[i as usize].to_string()==\"G\" && &list[(i-1) as usize].to_string()==\"B\"{\n let boy=list[(i-1) as usize];\n list[(i-1) as usize]=list[i as usize];\n list[i as usize]=boy;\n }\n }\n }let mut sum=String::from(\"\");\n for i in list{\n sum=sum+&i.to_string();\n }println!(\"{}\",sum);\n}\n\nfn read() -> String{\n let mut input=String::new();\n io::stdin().read_line(&mut input).expect(\"unable to read\");\n input.trim().to_string()\n}\n\nfn input() -> (i32,i32,Vec){\n let inp=read();\n let list: Vec<_>=inp.split_whitespace().collect();\n let qu: Vec<_>=read().chars().collect();\n (list[0].parse::().expect(\"Failed to parse\"),\n list[1].parse::().expect(\"Failed to parse\"),qu)\n}", "lang": "Rust", "bug_code_uid": "5bd4142105ed7d1669b2b199941f5bdc", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "48be66aa8d82c500a5b07512ed45ccb2", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9849663037843442, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "// https://codeforces.com/problemset/problem/266/B\n\nuse std::io;\n\nfn main() {\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let words: Vec =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let n = words[0];\n let t = words[1];\n\n let mut s = String::new();\n\n io::stdin()\n .read_line(&mut s)\n .unwrap();\n\n let mut s: Vec =\n s.chars().collect();\n\n let mut time = 0;\n\n while time < t {\n let mut idx: usize = 0;\n loop {\n if idx as i64 >= n {\n break;\n }\n if s[idx] == 'B' && s[idx+1] == 'G' {\n s[idx] = 'G';\n s[idx+1] = 'B';\n idx += 2;\n }\n idx += 1;\n }\n time += 1;\n }\n\n let answer: String = s.into_iter().collect();\n print!(\"{}\", answer);\n}\n\n", "lang": "Rust", "bug_code_uid": "5ad38b062f66eec23906783e87140caa", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "ddf5d8a6b1364715548f5853cfa77826", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8955996548748921, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_source_code": "fn main() {\n let (len, itt) = parse_arg();\n let mut v = parse_vec();\n for _ in 0..itt {\n swaper(&mut v, len);\n }\n println!(\"{:?}\", v);\n}\n\n#[derive(Debug, PartialEq)]\nenum Gender {\n B,\n G,\n}\nfn parse_line() -> String {\n let mut text = String::new();\n std::io::stdin().read_line(&mut text).expect(\"msg: &str\");\n String::from(text.trim())\n}\nfn parse_arg() -> (usize, usize) {\n let text = parse_line();\n let v: Vec<&str> = text.split_whitespace().collect();\n (v[0].parse().expect(\"\"), v[1].parse().expect(\"msg: &str\"))\n}\n\nfn parse_vec() -> Vec {\n let text = parse_line();\n text.chars()\n .map(|c| if c == 'B' { Gender::B } else { Gender::G })\n .collect()\n}\n//5 1\n//BGGBG\n\n//GBGGB\nfn swaper(v: &mut Vec, len: usize) {\n let mut to_swap: Vec<(usize, usize)> = vec![];\n for i in 0..(len - 1) {\n if v[i] == Gender::B && v[i + 1] == Gender::G {\n to_swap.push((i, i + 1))\n }\n }\n for (i, i2) in to_swap {\n v.swap(i, i2)\n }\n}\n", "lang": "Rust", "bug_code_uid": "a83329de85e15eb3f139c8af0ecc8b49", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "aecc804db3b0b07c520065976e5dcd1f", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.89238621863037, "equal_cnt": 35, "replace_cnt": 9, "delete_cnt": 0, "insert_cnt": 26, "fix_ops_cnt": 35, "bug_source_code": "use std::str::FromStr;\n\nfn read_str() -> String {\n let mut buffer: String = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Error\");\n buffer.trim().to_string()\n}\n\nfn read_vec(split_char: char) -> Vec {\n read_str()\n .split(split_char)\n .map(|value| value.parse::().ok().expect(\"Error\"))\n .collect()\n}\n\nfn main() {\n let times: u8 = read_vec(' ')[1];\n let mut queue: String = read_str();\n\n for _ in 0..times {\n let mut current: String = String::new();\n let mut flag: bool = false;\n let length: usize = queue.len();\n\n for pos in 0..length {\n if flag {\n flag = false;\n continue;\n }\n\n if pos + 2 < length {\n if &queue[pos..pos + 2] == \"BG\" {\n current.push_str(\"GB\");\n flag = true;\n continue;\n }\n }\n current.push_str(&queue[pos..pos + 1]);\n }\n queue = current.clone();\n }\n println!(\"{}\", queue);\n}", "lang": "Rust", "bug_code_uid": "8499f1c97761cf36d70bffa295782d29", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "d95ac1875eb8491fd8ff4e77e89b7ecc", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.7000575705238917, "equal_cnt": 13, "replace_cnt": 10, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 12, "bug_source_code": "fn main() {\n let (n, t) = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let mut ws = buf.split_whitespace();\n let n: usize = ws.next().unwrap().parse().unwrap();\n let t: usize = ws.next().unwrap().parse().unwrap();\n (n, t)\n };\n let s = {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n buf.trim_end().to_owned()\n };\n let v: Vec = s.chars().collect();\n let mut w: Vec<(char, bool)> = Vec::with_capacity(n);\n for i in 0..n {\n w.push((v[i], false));\n }\n\n for i in 0..n {\n if w[i] == ('B', false) {\n w.insert(std::cmp::min(i + t + 1, n), ('B', true));\n w.remove(i);\n }\n }\n\n let a = w.iter().map(|x| x.0).collect::();\n println!(\"{}\", a);\n}\n", "lang": "Rust", "bug_code_uid": "4a5f0285efb37e278b89094928d2a84e", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "2a6538c3cd5cf37f42eea83491bd1e3b", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8605527638190955, "equal_cnt": 9, "replace_cnt": 4, "delete_cnt": 3, "insert_cnt": 1, "fix_ops_cnt": 8, "bug_source_code": "fn readln() -> Vec {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n line.split_whitespace()\n .map(|s| s.parse().unwrap())\n .collect()\n}\n\n\nfn main() {\n let input = readln();\n\n let n = input[0];\n let t = input[1];\n\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n\n let mut chars: Vec = Vec::new();\n for ch in line.chars() {\n chars.push(ch);\n }\n\n for _ in (0..t).rev() {\n for i in 1..n {\n if chars[(i - 1) as usize] == 'B' && chars[i as usize] == 'G' {\n chars.swap((i - 1) as usize, i as usize);\n }\n }\n }\n\n for ch in chars {\n print!(\"{}\", ch);\n }\n}", "lang": "Rust", "bug_code_uid": "409147b815f9487e7a3d74bee85e91d1", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "4ed587919400b908a8ab11e18e403493", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9836612204068023, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::{min,max};\nuse std::io::{BufWriter, stdin, stdout, Write};\n\n#[derive(Default)]\nstruct Scanner {\n buffer: Vec\n}\nimpl Scanner {\n fn next(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n stdin().read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn main() {\n let mut scan = Scanner::default();\n let out = &mut BufWriter::new(stdout());\n \n // how to read \n let n = scan.next::()-1;\n let t = scan.next::();\n let mut s: Vec = scan.next::().chars().collect();\n let mut r = String::new();\n\n for _i in 0..t {\n let mut j:usize = 0;\n loop {\n println!(\"{:?} {:?} {:?}\", s, r, j);\n if j == n {\n r.push(s[j]);\n break;\n } else if j > n {\n break;\n } else if s[j] == 'B' && s[j+1] == 'G' {\n r.push('G');\n r.push('B');\n j += 2;\n } else {\n r.push(s[j]);\n j += 1;\n }\n }\n s = r.chars().collect();\n r = String::new();\n }\n // how to output\n let s : String = s.into_iter().collect();\n writeln!(out, \"{}\", s).ok();\n\n}", "lang": "Rust", "bug_code_uid": "a0367af8bb97260dd376362549e5c326", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "28a590c248eaff45d7a2a77e70c9e48f", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9558367152064932, "equal_cnt": 12, "replace_cnt": 4, "delete_cnt": 4, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "#![allow(non_snake_case, unused_imports, deprecated, dead_code)]\n\n// Input macros\nmacro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }\nmacro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\nmacro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect(\"Parse error\") }; }\n\n// Module\nuse std::cmp::{min,max};\nuse std::collections::{VecDeque,HashMap,HashSet,BTreeMap,BTreeSet,BinaryHeap};\n// Module for v1.15.1\nuse std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead\n\n// Functions\n\n// Main\nfn main() {\n\n input! {\n N: usize,\n T: usize,\n mut S: chars\n }\n\n for _ in 0..T {\n for i in 1..N {\n if S[N-1-i]=='B' && S[N-i]=='G' {\n S[N-1-i] = 'G';\n S[N-i] = 'B';\n }\n }\n }\n\n println!(\"{}\", S.iter().collect::());\n}", "lang": "Rust", "bug_code_uid": "9e2e9b4a21a75c01d19f4440a581d8e9", "src_uid": "964ed316c6e6715120039b0219cc653a", "apr_id": "1c200c1c707e16d84348c2178ad21acc", "difficulty": 800, "tags": ["shortest paths", "constructive algorithms", "implementation", "graph matchings"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8313953488372093, "equal_cnt": 2, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "fn main() {\n let mut text = String::new();\n std::io::stdin().read_line(&mut text).unwrap();\n let val: u64 = text.trim().parse().unwrap();\n let mut i = 1;\n let value = loop {\n if (i * (i + 1)) / 2 >= val {\n break i;\n }\n i += 1;\n };\n println!(\"{}\", value)\n}\n", "lang": "Rust", "bug_code_uid": "00cb4ba36c17d1660600c0de8b21d8ac", "src_uid": "1db5631847085815461c617854b08ee5", "apr_id": "ab4a58643092ef736221904382d0c8ac", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5012722646310432, "equal_cnt": 4, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "fn main() {\n let mut text = String::new();\n std::io::stdin().read_line(&mut text).unwrap();\n let val: u64 = text.trim().parse().unwrap();\n let mut i = 1;\n let mut step = 0;\n let mut last = 0;\n while step < val {\n for a in 1..i {\n if step < val {\n last = a;\n }\n step += 1;\n }\n i += 1;\n }\n println!(\"{}\", last)\n}\n", "lang": "Rust", "bug_code_uid": "00991d97c9a758013c3fc801070498c4", "src_uid": "1db5631847085815461c617854b08ee5", "apr_id": "ab4a58643092ef736221904382d0c8ac", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9827027027027027, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "\nfn main() {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"INPUT::Read line failed\");\n\n let number = input.trim().parse::().expect(\"NUMBER::Parse to i32 failed\");\n\n let mut vec = vec![];\n let mut fx = function(number);\n let mut is_repeats = is_repeat(&vec, fx);\n\n while !is_repeats {\n vec.push(fx);\n fx = function(fx);\n is_repeats = is_repeat(&vec, fx);\n\n\n }\n\n println!(\"{}\",vec.len() + 1 );\n\n}\n\nfn function(number : i32) -> i32 {\n let mut number = number + 1;\n\n let mut last_number = number % 10;\n\n while last_number == 0 {\n number /= 10;\n last_number = number % 10;\n }\n\n number\n\n\n}\n\nfn is_repeat(vec : &Vec, fx:i32) -> bool {\n let mut is_repeat = false;\n\n for i in 0..vec.len() {\n if fx == vec[i] {\n is_repeat = true;\n break;\n }\n\n\n }\n is_repeat\n}", "lang": "Rust", "bug_code_uid": "5c89369413dda7371dbb2a6590e7bbbf", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "apr_id": "266b789243da44f1052a3721eccc36c3", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9822251481237656, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "// http://codeforces.com/contest/1157/problem/A\n\nuse std::io;\n\nfn read_int32s() -> Vec {\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).ok().expect(\"\");\n let src:Vec<&str> = buf.trim().split(' ').collect();\n let mut result: Vec = Vec::new();\n for e in src {\n let n:Result = e.parse();\n result.push(n.unwrap());\n }\n result\n}\n\nfn f(x:i32) -> i32\n{\n let mut y = x + 1;\n while (y % 10) == 0\n {\n y = y / 10;\n }\n y\n}\n\nfn main()\n{\n let n = read_int32s()[0];\n let mut x = n;\n let mut cnt = 1;\n loop\n {\n x = f(x);\n cnt += 1;\n if x < 10\n {\n cnt += 8;\n break;\n }\n }\n println!(\"{}\", cnt);\n}", "lang": "Rust", "bug_code_uid": "c00b8c371affba69fa65b349d6a1115b", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "apr_id": "68c4b17681d188820696f01ca9c44f49", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9970115269674115, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "// ____ _ _ _ _\n// | _ \\ _ _ ___| |_ ___ _ __ | |_ ___ _ __ ___ _ __ | | __ _| |_ ___\n// | |_) | | | / __| __| / __| '_ \\ | __/ _ \\ '_ ` _ \\| '_ \\| |/ _` | __/ _ \\\n// | _ <| |_| \\__ \\ |_ | (__| |_) | | || __/ | | | | | |_) | | (_| | || __/\n// |_| \\_\\\\__,_|___/\\__| \\___| .__/___\\__\\___|_| |_| |_| .__/|_|\\__,_|\\__\\___|\n// |_| |_____| |_|\n\n// _ _ _ _____ ___\n// _ __ ___ __ _ _ __ | |_ __ _/ / |___ / / _ \\\n// | '_ ` _ \\ / _` | '_ \\| __/ _` | | | |_ \\| | | |\n// | | | | | | (_| | | | | || (_| | | |___) | |_| |\n// |_| |_| |_|\\__,_|_| |_|\\__\\__,_|_|_|____/ \\___/\n\n//https://github.com/manta1130/Competitive_Programming_Template_Rust\n\n#[macro_use]\nmod input {\n\n use std;\n use std::io;\n\n const SPLIT_DELIMITER: char = ' ';\n\n #[macro_export]\n #[allow(unused_macros)]\n macro_rules! input {\n ( $($x:expr ),*) => {\n {\n let temp_str = input_line_str();\n let mut split_result_iter = temp_str.split_whitespace();\n $(\n let buf_split_result = split_result_iter.next();\n let buf_split_result = buf_split_result.unwrap();\n ($x) = buf_split_result.parse().unwrap();\n )*\n }\n };\n}\n\n #[allow(dead_code)]\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(dead_code)]\n pub fn p(t: T)\n where\n T: std::fmt::Display,\n {\n println!(\"{}\", t);\n }\n\n #[allow(dead_code)]\n pub fn input_vector2d(line: usize) -> Vec>\n where\n T: std::str::FromStr,\n {\n let mut v: Vec> = Vec::new();\n\n for _ in 0..line {\n let vec_line = input_vector();\n v.push(vec_line);\n }\n v\n }\n\n #[allow(dead_code)]\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(dead_code)]\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\nuse input::*;\nuse std::collections::HashSet;\n\nfn main() {\n let mut n: usize;\n let mut set = HashSet::new();\n input!(n);\n while n > 0 {\n n += 1;\n while n % 10 == 0 {\n n /= 10;\n }\n if set.contains(&n) {\n break;\n }\n set.insert(n);\n }\n p(set.len()+1);\n}\n", "lang": "Rust", "bug_code_uid": "aa5fda919f6a7cf287049bb1f6949265", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "apr_id": "5ed4d008b9e425e835d6fab812fc46e2", "difficulty": 1100, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9942222222222222, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 3, "bug_source_code": "use std::cmp::min;\n\nfn get_max_days(a: u32, b: u32, c: u32) -> u32 {\n let full_week_num: u32 = min(a / 3, min(b / 2, c / 2));\n let a_rest: u32 = a - 3 * full_week_num;\n let b_rest: u32 = b - 2 * full_week_num;\n let c_rest: u32 = c - 2 * full_week_num;\n\n let mut extra_days_max: u32 = 0;\n for start_weekday in 0..6 {\n let mut weekday: u32 = start_weekday;\n let mut extra_days: u32 = 0;\n let mut a_rest1: u32 = a_rest;\n let mut b_rest1: u32 = b_rest;\n let mut c_rest1: u32 = c_rest;\n loop {\n if (weekday == 0) || (weekday == 3) || (weekday == 6) {\n if a_rest1 > 0 {\n a_rest1 -= 1;\n } else {\n break;\n }\n }\n else if (weekday == 1) || (weekday == 5) {\n if b_rest1 > 0 {\n b_rest1 -= 1;\n } else {\n break;\n }\n }\n else {\n if c_rest1 > 0 {\n c_rest1 -= 1;\n } else {\n break;\n }\n }\n\n extra_days += 1;\n weekday += 1;\n weekday %= 7;\n }\n\n if extra_days > extra_days_max {\n extra_days_max = extra_days;\n }\n }\n\n return 7 * full_week_num + extra_days_max;\n}\n\n#[cfg(test)]\nmod tests {\n use super::get_max_days;\n\n #[test]\n fn test1() {\n assert_eq!(get_max_days(2, 1, 1), 4);\n }\n #[test]\n fn test2() {\n assert_eq!(get_max_days(3, 2, 2), 7);\n }\n #[test]\n fn test3() {\n assert_eq!(get_max_days(1, 100, 1), 3);\n }\n #[test]\n fn test4() {\n assert_eq!(get_max_days(30, 20, 10), 39);\n }\n}\n\nfn read_data() -> (u32, u32, u32) {\n let mut data_str: String = String::new();\n std::io::stdin().read_line(&mut data_str).unwrap();\n\n let data_values: Vec = data_str\n .trim()\n .split(\" \")\n .map(|s| s.parse::().unwrap())\n .collect();\n\n return (data_values[0], data_values[1], data_values[2]);\n}\n\nfn main() {\n let (a, b, c): (u32, u32, u32) = read_data();\n\n let max_days: u32 = get_max_days(a, b, c);\n\n println!(\"{}\", max_days);\n}\n", "lang": "Rust", "bug_code_uid": "4369eceeb73ec9eba05a2c5fe2f3b7ff", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "apr_id": "30ef0058d6d03eed1fee09b93a643e9b", "difficulty": 1400, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9964260185847034, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::str;\n\npub struct Scanner {\n reader: R,\n buffer: Vec,\n}\n\nimpl Scanner {\n pub fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n pub fn token(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn solve(scan: &mut Scanner, out: &mut W) {\n let n: i64 = scan.token();\n let x: i64 = scan.token();\n // In how many ways we can express x as p * q, where 1 <= p, q <= n ?\n let mut ans = 0;\n let mut p = 1;\n while p * p <= x {\n if x % p == 0 {\n let q = x / p;\n if q <= n {\n ans += 1;\n }\n }\n p += 1;\n }\n ans *= 2;\n if (p - 1) * (p - 1) == x {\n ans -= 1;\n }\n writeln!(out, \"{}\", ans).ok();\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout.lock());\n solve(&mut scan, &mut out);\n}\n", "lang": "Rust", "bug_code_uid": "c4f8ecad3fbd2d50905c1926b82d5ea8", "src_uid": "c4b139eadca94201596f1305b2f76496", "apr_id": "0c205a98c8262c7eadd661eadaaac0e8", "difficulty": 1000, "tags": ["number theory", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.6332247557003258, "equal_cnt": 6, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "type Pair = (u32, u32);\nfn input_pair() -> Pair {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let buf: Vec = buf\n .trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect();\n (buf[0], buf[1])\n}\n\nfn main() {\n let (n, x) = input_pair();\n let mut occurance_count = 0;\n for i in n / 2..n {\n if x % i == 0 {\n occurance_count += 2;\n }\n }\n\n println!(\"{}\", occurance_count);\n}", "lang": "Rust", "bug_code_uid": "9ac0770cdea6baef0a948f878d1ff12e", "src_uid": "c4b139eadca94201596f1305b2f76496", "apr_id": "ec61387ba2ece4879effe48d0c6231da", "difficulty": 1000, "tags": ["number theory", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9766285430134262, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "type Pair = (u32, u32);\nfn input_pair() -> Pair {\n let mut buf = String::new();\n std::io::stdin().read_line(&mut buf).unwrap();\n let buf: Vec = buf\n .trim()\n .split_whitespace()\n .map(|elem| elem.parse().unwrap())\n .collect();\n (buf[0], buf[1])\n}\n\nfn main() {\n let (n, x) = input_pair();\n let mut occurance_count = 0;\n\n if n == 1 {\n if x == 1 {\n println!(\"1\");\n } else {\n println!(\"0\");\n }\n } else if n == 2 {\n if x == 1 || x == 4 {\n println!(\"1\");\n } else if x == 2 {\n println!(\"2\");\n } else {\n println!(\"0\");\n }\n } else {\n for i in 2..=n {\n if x % i == 0 && x / i <= n {\n if x == i {\n occurance_count += 2;\n } else {\n occurance_count += 1;\n }\n }\n }\n println!(\"{}\", occurance_count);\n }\n}", "lang": "Rust", "bug_code_uid": "999efb3dee1d09618920e4b6bcaae44d", "src_uid": "c4b139eadca94201596f1305b2f76496", "apr_id": "ec61387ba2ece4879effe48d0c6231da", "difficulty": 1000, "tags": ["number theory", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9910979228486647, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "// Vicfred\n// https://codeforces.com/problemset/problem/577/A\nuse std::io;\n\nfn main() {\n let mut line = String::new();\n\n io::stdin()\n .read_line(&mut line)\n .unwrap();\n\n let words: Vec =\n line\n .split_whitespace()\n .map(|x| x.parse().unwrap())\n .collect();\n\n let n = words[0];\n let x = words[1];\n\n let limit: i64 = f64::sqrt(x as f64) as i64;\n\n let mut ans = 0;\n\n for d in 1..=limit {\n if x%d == 0 && d <= n && x/d <= n {\n ans += 1;\n }\n }\n\n if x != 1 {\n ans *= 2;\n }\n\n if limit*limit == x && x != 1{\n ans -= 1;\n }\n\n println!(\"{}\", ans);\n}\n\n", "lang": "Rust", "bug_code_uid": "36749c7966c9b3a40cb948971f2cc4f4", "src_uid": "c4b139eadca94201596f1305b2f76496", "apr_id": "8d2721425f2d0daf467b06b1db27f8b4", "difficulty": 1000, "tags": ["number theory", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9799426934097422, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\nuse std::io::Read;\n\nfn main() {\n let mut text = String::new();\n io::stdin().read_to_string(&mut text).unwrap();\n let mut iter = text.split_whitespace().map(|x| x.parse::().unwrap());\n let n = iter.next().unwrap();\n let x = iter.next().unwrap();\n println!(\"{}\", (1..(n+1)).filter(|i| x % i == 0).count())\n}\n", "lang": "Rust", "bug_code_uid": "7f03bf9154866a4379dfc439dbc94030", "src_uid": "c4b139eadca94201596f1305b2f76496", "apr_id": "73a5f1eb053c57d5107897b1275bd102", "difficulty": 1000, "tags": ["number theory", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9917269906928645, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#![allow(non_snake_case, unused_imports, deprecated, dead_code)]\n\n// Input macros\nmacro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }\nmacro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\nmacro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect(\"Parse error\") }; }\n\n// Module\nuse std::cmp::{min,max};\nuse std::collections::{VecDeque,HashSet,HashMap,BinaryHeap};\n// Module for v1.15.1\nuse std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead\n\n// Functions\n\n// Main\nfn main() {\n\n input! {\n N: usize,\n X: usize\n }\n\n let mut ans = 0;\n let primes = get_primes(N);\n for i in 1..N+1{\n if X%i==0 && X/i<=N {\n ans += 1;\n }\n }\n\n println!(\"{}\", ans);\n}", "lang": "Rust", "bug_code_uid": "e91ef164c247af1ed5852e97934f4008", "src_uid": "c4b139eadca94201596f1305b2f76496", "apr_id": "92b71345492cf9f7c05ad06f5ec1c0ca", "difficulty": 1000, "tags": ["number theory", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9601694915254237, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "#[allow(unused_imports)]\nuse std::cmp::*;\n#[allow(unused_imports)]\nuse std::collections::*;\nuse std::io::*;\n#[allow(dead_code)]\nfn getline() -> String {\n let mut ret = String::new();\n std::io::stdin().read_line(&mut ret).ok();\n return 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 = std::string::String::from_utf8(buf).unwrap();\n return ret;\n }\n }\n}\nfn parse(s: &str) -> T { s.parse::().ok().unwrap() }\n\n#[allow(dead_code)]\nfn get() -> T { parse(&get_word()) }\n\nfn main() {\n let k: i64 = get();\n let a: i64 = get();\n let b: i64 = get();\n let res: i64 = if (a < k && b < k) && (0 < a && 0 < b) {\n -1\n } else {\n a / k + b / k\n };\n println!(\"{}\", res);\n}\n", "lang": "Rust", "bug_code_uid": "6684cfd4176296526f853909e55d540d", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "apr_id": "f050467f608b3cb4343167962c89833b", "difficulty": 1200, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9921212121212121, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::BufRead;\nuse std::io::Write;\n\n#[derive(Debug,Clone,Copy,Default)]\nstruct Problem {\n buf: [u8;9],\n len: u8,\n}\n\nimpl Problem {\n fn as_slice(&self) -> &[u8] {\n &self.buf[0..self.len as usize]\n }\n}\n\nfn loc(d: u8) -> (u8,u8) {\n assert!(d < 10);\n if d == 0 {\n (1,3)\n } else {\n ((d-1)%3,(d-1)/3)\n }\n}\n\nfn read_problem() -> Problem {\n let stdin = std::io::stdin();\n let mut lines = stdin.lock().lines();\n\n let ct = str::parse::(&lines.next().unwrap().unwrap()).unwrap();\n let mut ret = Problem::default();\n for (c,b) in lines.next().unwrap().unwrap().chars().zip(ret.buf.iter_mut()) {\n *b = c.to_digit(10).unwrap() as u8;\n ret.len += 1;\n }\n assert_eq!(ret.len, ct);\n assert!(lines.next().is_none());\n ret\n}\n\nfn solve(problem: Problem) -> bool {\n let mut min_x = u8::max_value();\n let mut min_y = u8::max_value();\n let mut max_x = 0;\n let mut max_y = 0;\n let mut max_side_y = 0;\n\n for &d in problem.as_slice() {\n let (x,y) = loc(d);\n if x < min_x {\n min_x = x;\n } else if x > max_x {\n max_x = x;\n }\n if y < min_y {\n min_y = y;\n } else if y > max_y {\n max_y = y;\n }\n if x != 1 && y > max_side_y {\n max_side_y = y;\n }\n }\n\n let dx = max_x - min_x;\n let dy = max_y - min_y;\n let dsy = max_side_y - min_y;\n writeln!(&mut std::io::stderr(), \"{:?}\", (dx,dy,dsy)).unwrap();\n dy == 3 || (dx,dsy) == (2,2)\n}\n\nfn main() {\n let p = read_problem();\n println!(\"{}\", if solve(p) { \"YES\" } else { \"NO\" });\n}\n", "lang": "Rust", "bug_code_uid": "4ffa0b4d52597b768d2c3821b9a79fed", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "apr_id": "7446507ca7a47a9870e46ef74d37f365", "difficulty": 1400, "tags": ["brute force", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9108409321175278, "equal_cnt": 5, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 4, "bug_source_code": "use std::io;\nuse std::io::Read;\n\nfn main() {\n let mut text = String::new();\n io::stdin().read_to_string(&mut text).unwrap();\n let mut iter = text.split_whitespace();//.map(|x| x.parse::().unwrap());\n let n = iter.next().unwrap().parse::().unwrap();\n let s = iter.next().unwrap();\n let mut up = true;\n let mut down = true;\n let mut left = true;\n let mut right = true;\n for c in s.chars() {\n let d = c as i64 - '0' as i64;\n if d >= 1 && d <= 3 {\n up = false;\n }\n if d == 7 || d == 9 || d == 0 {\n down = false;\n }\n if d == 1 || d == 4 || d == 7 {\n left = false;\n }\n if d % 3 == 0 && d != 0 {\n right = false;\n }\n }\n println!(\"{}\", if (up || down || left || right) {\"NO\"} else {\"YES\"});\n\n}\n\nfn get_pos(num: i64) -> (i64, i64) {\n if num == 0 {\n (3, 1)\n } else {\n ((num - 1) / 3, (num - 1) % 3)\n }\n}\n", "lang": "Rust", "bug_code_uid": "42cafbb6188e92dfad58dbff33d28849", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "apr_id": "5c9c343fff42b283d3f48c743fb66445", "difficulty": 1400, "tags": ["brute force", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9598246895544192, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "fn main() {\n let friend_count = get_input_usize();\n let finger_count: usize = get_input().split_ascii_whitespace().map(|v| v.parse::().unwrap()).sum();\n\n let total = friend_count + 1;\n let position = finger_count % total;\n\n let res = vec![1,2,3,4,5].iter().fold(0, |total, next| {\n if (next + position) % total == 0 {\n total\n } else {\n total + 1\n }\n });\n\n println!(\"{}\", res);\n\n}\n\n\nfn get_input() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n buffer.trim().to_owned()\n}\n\nfn get_input_usize() -> usize {\n get_input().parse().unwrap()\n}\n", "lang": "Rust", "bug_code_uid": "ca5b07b1856451b157b73e382f3421b9", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "apr_id": "a8c6f7c8b08d09c6b06af956d8e51170", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9985549132947977, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "fn main() {\n let friend_count = get_input_usize();\n let finger_count: usize = get_input().split_ascii_whitespace().map(|v| v.parse::().unwrap()).sum();\n\n let total_people = friend_count + 1;\n let position = finger_count % total_people;\n\n let res = vec![1,2,3,4,5].iter().fold(0, |res, next| {\n if (next + position) % total_people == 0 {\n res\n } else {\n res + 1\n }\n });\n\n println!(\"{}\", res);\n\n}\n\n\nfn get_input() -> String {\n let mut buffer = String::new();\n std::io::stdin().read_line(&mut buffer).expect(\"Failed\");\n buffer.trim().to_owned()\n}\n\nfn get_input_usize() -> usize {\n get_input().parse().unwrap()\n}\n", "lang": "Rust", "bug_code_uid": "93bf4618e622a5c75366cfe363ef1477", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "apr_id": "a8c6f7c8b08d09c6b06af956d8e51170", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7136038186157518, "equal_cnt": 7, "replace_cnt": 6, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 7, "bug_source_code": "fn read_int() -> u16 {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n let x = input.trim().parse::().unwrap();\n x\n}\n\nfn read_int_vec() -> Vec{\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"read error\");\n let mut vec = input.split_whitespace()\n .map(|i| i.parse::().expect(\"parse error\"))\n .collect::>();\n vec\n}\n\nfn main() {\n \n let x = read_int() + 1;\n let vec = read_int_vec();\n let sum: u16 = vec.iter().sum();\n\n if ((sum % x) + x) % x == 0 {\n println!(\"{}\", 2);\n } else {\n println!(\"{}\", 1);\n }\n}", "lang": "Rust", "bug_code_uid": "0cb7398cc39c295cec9aa341fb11e8eb", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "apr_id": "2a0aaa4184f6feee723c4a6764012900", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9801192842942346, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 2, "bug_source_code": "fn read_int() -> u16 {\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"Failed\");\n let x = input.trim().parse::().unwrap();\n x\n}\n\nfn read_int_vec() -> Vec{\n let mut input = String::new();\n std::io::stdin().read_line(&mut input).expect(\"read error\");\n let mut vec = input.split_whitespace()\n .map(|i| i.parse::().expect(\"parse error\"))\n .collect::>();\n vec\n}\n\nfn main() {\n \n let x = read_int() + 1;\n let vec = read_int_vec();\n let sum: u16 = vec.iter().sum();\n\n let mut total = 0;\n let mut range = 1..6;\n loop {\n match range.next() {\n Some(i) => {\n // println!(\"also: ({}+{}) % {} = {}\", sum, i, x, (((sum+i) % x) + x)% x);\n if !((((sum+i) % x) + x) % x == 1){\n // println!(\"====\");\n total = total + 1;\n }\n },\n None => { break }\n }\n }\n println!(\"}\", total);\n\n}", "lang": "Rust", "bug_code_uid": "92f0857ae173bb71c9db479d8abdab1e", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "apr_id": "2a0aaa4184f6feee723c4a6764012900", "difficulty": 1000, "tags": ["math", "implementation"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9696515548894717, "equal_cnt": 7, "replace_cnt": 3, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 6, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, bytes) => {\n read_value!($iter, String).bytes().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n//\n\n// 異なる値が含まれるやつはどっちがどっちかわからないので不可能\n// 同じ値のみを聞き出す戦略\n// 同じ値のみを残せるように聞く戦略\n// 同じ値を残せるように聞く戦略ができるならのみを聞き出すことも可能\n//\n// 同じ値のみを残す\n// a をk 個聞き出せる条件は\n// aを使わないで(k - i) * a を作れないこと\n// 分割統治bitset?\n\nuse std::cmp::*;\n\nfn run() {\n input! {\n n: usize,\n a: [usize; n],\n }\n let mut a = a.into_iter().map(|a| (a, 1)).collect::>();\n a.sort();\n a.dedup_by(|a, b| {\n a.0 == b.0 && {\n b.1 += a.1;\n true\n }\n });\n let w = n * 100;\n let mut dp = vec![vec![0u8; w + 1]; n + 1];\n dp[0][0] = 1;\n for &(a, c) in a.iter() {\n for i in (1..=n).rev() {\n for j in a..=w {\n let mut v = dp[i][j];\n for k in 1..=min(j / a, min(i, c)) {\n v = v.saturating_add(dp[i - k][j - k * a]);\n }\n dp[i][j] = v;\n }\n }\n }\n /*\n for i in 0..=n {\n for j in 0..=w {\n print!(\"{} \", dp[i][j]);\n }\n println!();\n }\n */\n let s = a.iter().fold(0, |s, a| s + a.0 * a.1);\n let mut ans = 1;\n for &(a, c) in a.iter() {\n for k in 2..=c {\n if dp[k][k * a] == 1 || dp[n - k][s - k * a] == 1 {\n ans = max(ans, k);\n }\n }\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "3b3fb791b14a240dc3a85ea2a2f047e9", "src_uid": "ccc4b27889598266e8efe73b8aa3666c", "apr_id": "ee4bf08ff1ffb242ee4ac0888a517ee9", "difficulty": 2100, "tags": ["dp", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9850413038624694, "equal_cnt": 3, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "use std::io::{self, Stdin};\nuse std::str::{self, FromStr};\nuse std::error::Error;\nuse std::thread;\n\nfn exec() {\n let mut sc = Scanner::new();\n let n: i64 = sc.ne();\n let ans = if is_prime(n) {\n 1\n } else if n & 1 == 1 {\n 3\n } else {\n 2\n };\n println!(\"{}\", ans);\n}\n\nfn is_prime(x: i64) -> bool {\n let mut y = 2;\n while y * y <= x {\n if x % y == 0 {\n return false;\n }\n y += 1;\n }\n x != 1\n}\nconst DEFAULT_STACK: usize = 16 * 1024 * 1024;\nfn main() {\n let builder = thread::Builder::new();\n let th = builder.stack_size(DEFAULT_STACK);\n let handle = th.spawn(|| { exec(); }).unwrap();\n let _ = handle.join();\n}\n\n#[allow(dead_code)]\nstruct Scanner {\n stdin: Stdin,\n id: usize,\n buf: Vec,\n}\n\n#[allow(dead_code)]\nimpl Scanner {\n fn new() -> Scanner {\n Scanner {\n stdin: io::stdin(),\n id: 0,\n buf: Vec::new(),\n }\n }\n fn next_line(&mut self) -> Option {\n let mut res = String::new();\n match self.stdin.read_line(&mut res) {\n Ok(0) => return None,\n Ok(_) => Some(res),\n Err(why) => panic!(\"error in read_line: {}\", why.description()),\n }\n }\n fn next(&mut self) -> Option {\n while self.buf.len() == 0 {\n self.buf = match self.next_line() {\n Some(r) => {\n self.id = 0;\n r.trim().as_bytes().to_owned()\n }\n None => return None,\n };\n }\n let l = self.id;\n assert!(self.buf[l] != b' ');\n let n = self.buf.len();\n let mut r = l;\n while r < n && self.buf[r] != b' ' {\n r += 1;\n }\n let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::() {\n Ok(s) => Some(s),\n Err(_) => panic!(\"parse error\"),\n };\n while r < n && self.buf[r] == b' ' {\n r += 1;\n }\n if r == n {\n self.buf.clear();\n } else {\n self.id = r;\n }\n res\n }\n fn ne(&mut self) -> T {\n self.next::().unwrap()\n }\n}\n", "lang": "Rust", "bug_code_uid": "51bf74754721e5283140de2ce47295e4", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "apr_id": "691981e7a9c87aef8061ace1f3bf2ce2", "difficulty": 1600, "tags": ["math", "number theory"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8192796610169492, "equal_cnt": 18, "replace_cnt": 11, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 17, "bug_source_code": "#![allow(unused_imports)]\n#![allow(unused_macros)]\n#![allow(dead_code)]\n#![allow(unused_labels)]\n\nuse std::char::*;\nuse std::cmp::*;\nuse std::collections::*;\nuse std::io::*;\nuse std::str::FromStr;\n\nmacro_rules! debug {($($a:expr),*) => {eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);}}\nmacro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }\nmacro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }\nmacro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( \"Parse error\" ) } ; }\n\n\nfn read() -> T {\n let stdin = stdin();\n let stdin = stdin.lock();\n let token: String = stdin\n .bytes()\n .map(|c| c.expect(\"failed to read char\") as char)\n .skip_while(|c| c.is_whitespace())\n .take_while(|c| !c.is_whitespace())\n .collect();\n token.parse().ok().expect(\"failed to parse token\")\n}\n\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:usize = 30;\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 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 vc: vec![0;n],\n }\n }\n\n fn dfs(&mut self, crt: usize) {\n if self.f[crt] { return; }\n self.c += 1;\n self.f[crt] = true;\n self.v.push(crt);\n self.vc[crt] = self.c;\n self.u[crt] = self.v.len()-1;\n for i in 0..self.e[crt].len() {\n self.dfs(self.e[crt][i]);\n }\n //debug!(crt, self.c, self.vc[crt]);\n self.vc[crt] = self.c - self.vc[crt];\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 main() {\n //let t:usize = read();\n\n //'outer: for _ in 0..t {\n let n:usize = read();\n let m:usize = read();\n let mut p:Vec<(usize,usize,i64,usize)> = (0..m).map(|i| (read::()-1,read::()-1,read(),i)).collect();\n\n p.sort_by(|a,b| a.0.cmp(&b.0));\n //debug!(p);\n\n let mut e = vec![m;n];\n let mut c = vec![0;m];\n for i in 0..m {\n e[p[i].1] = i;\n c[p[i].3] = p[i].2;\n }\n\n let mut idx = 0;\n let mut v = vec![];\n for i in 0..n {\n if e[i] != m {\n if c[e[i]] != 0 {\n println!(\"-1\");\n return;\n }\n v.push(m+1);\n }\n else if idx == m {\n v.push(0);\n }\n else if i >= p[idx].0 {\n v.push(p[idx].3+1);\n c[p[idx].3] -= 1;\n if c[p[idx].3] == 0 {\n idx += 1;\n }\n }\n else {\n v.push(0);\n }\n }\n //debug!(v);\n for e in v {print!(\"{} \", e);} println!();\n\n //}\n}\n\n/*\n\n\n*/\n", "lang": "Rust", "bug_code_uid": "4bd5ddd6b46cdcf002a300fa65a31b51", "src_uid": "02d8d403eb60ae77756ff96f71b662d3", "apr_id": "e44220c3be8feaad8804ecd99bafaee9", "difficulty": 1700, "tags": ["greedy", "sortings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.024744744744744744, "equal_cnt": 36, "replace_cnt": 30, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 36, "bug_source_code": "//! http://codeforces.com/problemset/problem/815/E\n\nuse std::cmp::Ordering;\n\n#[derive(PartialEq)]\nstruct Segment {\n start: usize,\n len: usize\n}\n\nimpl Segment {\n fn min_dist(&self) -> usize {\n (self.len + 1) / 2\n }\n\n fn split(self) -> Box> {\n let mut segments = Vec::new();\n let segment1;\n let segment2;\n if self.len % 2 == 0 {\n segment1 = Segment { start: self.start, len: self.len / 2 - 1 };\n segment2 = Segment { start: self.start + self.len / 2, len: self.len / 2 };\n } else {\n segment1 = Segment { start: self.start, len: self.len / 2 };\n segment2 = Segment { start: self.start + self.len / 2 + 1, len: self.len / 2 };\n }\n if segment1.len > 0 { segments.push(segment1); }\n if segment2.len > 0 { segments.push(segment2); }\n Box::new(segments.into_iter())\n }\n\n fn house(&self) -> usize {\n if self.len % 2 == 0 {\n self.start + self.len / 2 - 1\n } else {\n self.start + self.len / 2\n }\n }\n}\n\nimpl PartialOrd for Segment {\n fn partial_cmp(&self, them: &Self) -> Option {\n let (o_len, t_len) = (self.min_dist(), them.min_dist());\n Some(match o_len.cmp(&t_len) {\n Ordering::Less => Ordering::Greater,\n Ordering::Greater => Ordering::Less,\n Ordering::Equal => self.start.cmp(&them.start)\n })\n }\n}\n\nfn main() {\n use std::io;\n let mut buf = String::new();\n io::stdin().read_line(&mut buf).unwrap();\n let mut ns = buf.split(\" \")\n .map(|str| str.trim().parse::().unwrap());\n let n = ns.next().unwrap();\n let k = ns.next().unwrap();\n let mut last = 1;\n let mut segments = BinHeap::new();\n for i in 1..k {\n if i == 1 { last = n; segments.insert(Segment { start: 2, len: n - 2 }); }\n else {\n let segment = segments.pop_min()\n .unwrap();\n last = segment.house();\n for s in segment.split() {\n segments.insert(s);\n }\n }\n }\n println!(\"{}\", last);\n}\n\n// -----------------------------------------------------------------------------\n\npub struct BinHeap {\n pub elements: Vec\n}\n\npub fn left_child(i: usize) -> usize { (i * 2) + 1 }\npub fn right_child(i: usize) -> usize { (i * 2) + 2 }\npub fn parent(i: usize) -> usize { i.saturating_sub(1) / 2 }\n\npub type HeapElementId = usize;\n\nimpl BinHeap {\n pub fn new() -> Self {\n BinHeap { elements: Vec::new() }\n }\n pub fn with_capacity(capacity: usize) -> Self {\n BinHeap { elements: Vec::with_capacity(capacity) }\n }\n}\n\nimpl BinHeap {\n pub fn min(&self) -> Option<&T> {\n self.elements.first()\n }\n\n pub fn pop_min(&mut self) -> Option {\n let elements = &mut self.elements;\n if elements.is_empty() { return None; }\n let i = elements.len() - 1;\n elements.swap(0, i);\n let min = elements.pop().unwrap();\n if !elements.is_empty() {\n let mut i = 0;\n let n = elements.len();\n while i < n {\n let (l, r) = (left_child(i), right_child(i));\n let mut swap = i;\n swap = if l < n && elements[l] < elements[swap] { l } else { swap };\n swap = if r < n && elements[r] < elements[swap] { r } else { swap };\n if swap == i { break; }\n elements.swap(i, swap);\n i = swap;\n }\n }\n Some(min)\n }\n\n pub fn insert(&mut self, element: T) -> HeapElementId {\n let i = self.elements.len();\n self.elements.push(element);\n self.bubble(i)\n }\n\n pub fn reduce_key(&mut self, key: T, element_id: HeapElementId) -> HeapElementId {\n if key < self.elements[element_id] { self.elements[element_id] = key; }\n self.bubble(element_id)\n }\n\n fn bubble(&mut self, element_id: HeapElementId) -> HeapElementId {\n let elements = &mut self.elements;\n let mut i = element_id;\n loop {\n let parent = parent(i);\n if i == 0 || elements[parent] < elements[i] { break; }\n elements.swap(i, parent);\n i = parent;\n }\n return i;\n }\n}\n", "lang": "Rust", "bug_code_uid": "a811ca1c062f6642032ccfc36e9cc398", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "apr_id": "fa172f3e558ef6d5c1ced529974a3c15", "difficulty": 2900, "tags": ["constructive algorithms", "implementation", "binary search"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.09296051017905323, "equal_cnt": 44, "replace_cnt": 27, "delete_cnt": 4, "insert_cnt": 13, "fix_ops_cnt": 44, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// ここまで\n\nfn calc(n: u64, k: usize, p: &[u64], map: &mut std::collections::BTreeMap<(u64, usize), u64>) -> u64 {\n if k == 0 {\n return n;\n }\n let a = p[k - 1];\n if a >= n {\n return 0;\n }\n if let Some(&v) = map.get(&(n, k)) {\n return v;\n }\n let val = calc(n, k - 1, p, map) - calc(n / a, k - 1, p, map);\n map.insert((n, k), val);\n val\n}\n\nfn run() {\n input! {\n n: u64,\n }\n let m = 1_000_000;\n let mut is_prime = vec![true; m + 1];\n for i in 2.. {\n if i * i > m {\n break;\n }\n if is_prime[i] {\n let mut j = i * i;\n while j <= m {\n is_prime[j] = false;\n j += i;\n }\n }\n }\n let mut p = vec![];\n for (i, b) in is_prime.iter().enumerate().skip(2) {\n if *b {\n p.push(i as u64);\n }\n }\n let mut ans = 0u64;\n for p in p.iter() {\n if p.pow(3) > n {\n break;\n }\n ans += 1;\n }\n let mut map = std::collections::BTreeMap::new();\n for (i, a) in p.iter().enumerate() {\n if *a * p[i + 1] > n {\n break;\n }\n let n = n / a;\n let k = match p.binary_search_by(|p| (*p * *p).cmp(&n)) {\n Ok(k) => k + 1,\n Err(k) => k,\n };\n ans += calc(n, k, &p, &mut map) - 1 + k as u64 - (i + 1) as u64;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "82c5779ec7182d58e3922cb7eb23a6f5", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "apr_id": "cd704259d5d58bd14a3743e0cae36694", "difficulty": 2400, "tags": ["dp", "number theory", "data structures", "math", "sortings", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.0939531460811971, "equal_cnt": 41, "replace_cnt": 26, "delete_cnt": 4, "insert_cnt": 11, "fix_ops_cnt": 41, "bug_source_code": "//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より\nmacro_rules! input {\n (source = $s:expr, $($r:tt)*) => {\n let mut iter = $s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n ($($r:tt)*) => {\n let s = {\n use std::io::Read;\n let mut s = String::new();\n std::io::stdin().read_to_string(&mut s).unwrap();\n s\n };\n let mut iter = s.split_whitespace();\n input_inner!{iter, $($r)*}\n };\n}\n\nmacro_rules! input_inner {\n ($iter:expr) => {};\n ($iter:expr, ) => {};\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\n let $var = read_value!($iter, $t);\n input_inner!{$iter $($r)*}\n };\n}\n\nmacro_rules! read_value {\n ($iter:expr, ( $($t:tt),* )) => {\n ( $(read_value!($iter, $t)),* )\n };\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\n };\n ($iter:expr, chars) => {\n read_value!($iter, String).chars().collect::>()\n };\n ($iter:expr, usize1) => {\n read_value!($iter, usize) - 1\n };\n ($iter:expr, $t:ty) => {\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\n };\n}\n\n// ここまで\n\nfn calc(n: u64, k: usize, p: &[u64], map: &mut std::collections::BTreeMap<(u64, usize), u64>) -> u64 {\n if k == 0 {\n return n;\n }\n let a = p[k - 1];\n if a >= n {\n return 1;\n }\n if let Some(&v) = map.get(&(n, k)) {\n return v;\n }\n let val = calc(n, k - 1, p, map) - calc(n / a, k - 1, p, map);\n map.insert((n, k), val);\n val\n}\n\nfn run() {\n input! {\n n: u64,\n }\n let m = 1_000_000;\n let mut is_prime = vec![true; m + 1];\n for i in 2.. {\n if i * i > m {\n break;\n }\n if is_prime[i] {\n let mut j = i * i;\n while j <= m {\n is_prime[j] = false;\n j += i;\n }\n }\n }\n let mut p = vec![];\n for (i, b) in is_prime.iter().enumerate().skip(2) {\n if *b {\n p.push(i as u64);\n }\n }\n let mut ans = 0u64;\n for p in p.iter() {\n if p.pow(3) > n {\n break;\n }\n ans += 1;\n }\n let mut map = std::collections::BTreeMap::new();\n for (i, a) in p.iter().enumerate() {\n if *a * p[i + 1] > n {\n break;\n }\n let n = n / a;\n let k = match p.binary_search_by(|&p| (p * p).cmp(&n)) {\n Ok(k) => k + 1,\n Err(k) => k,\n };\n ans += calc(n, k, &p, &mut map) - 1 + k as u64 - (i + 1) as u64;\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "a7975f8790941c5d9ed8aac7979da2af", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "apr_id": "cd704259d5d58bd14a3743e0cae36694", "difficulty": 2400, "tags": ["dp", "number theory", "data structures", "math", "sortings", "two pointers"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4767651106171271, "equal_cnt": 45, "replace_cnt": 30, "delete_cnt": 6, "insert_cnt": 8, "fix_ops_cnt": 44, "bug_source_code": "struct FenwickTree {\n val: Vec,\n}\n\nimpl FenwickTree {\n fn new(n: usize) -> Self {\n FenwickTree {\n val: vec![0; n + 1],\n }\n }\n fn add(&mut self, mut x: usize, v: i64) {\n while let Some(p) = self.val.get_mut(x) {\n *p += v;\n x += x & (!x + 1);\n }\n }\n fn sum(&mut self, mut x: usize) -> i64 {\n assert!(x < self.val.len());\n let mut ans = 0;\n while x > 0 {\n ans += self.val[x];\n x -= x & (!x + 1);\n }\n ans\n }\n}\n\nfn sieve(n: usize) -> Vec {\n let mut is_prime = vec![true; n + 1];\n for i in 2.. {\n if i * i > n {\n break;\n }\n if is_prime[i] {\n let mut j = i * i;\n while j <= n {\n is_prime[j] = false;\n j += i;\n }\n }\n }\n let len = is_prime.iter().skip(2).filter(|p| **p).count();\n let mut prime = Vec::with_capacity(len);\n for (i, is_prime) in is_prime.into_iter().enumerate().skip(2) {\n if is_prime {\n prime.push(i as i64);\n }\n }\n prime\n}\n\n// N 以下の素数の個数を数える\nfn prime_count(n: i64) -> i64 {\n let mut m = 1;\n while (m + 1) * (m + 1) <= n {\n m += 1;\n }\n let p = sieve(m as usize);\n let bound = (n as f64).cbrt().powi(2) as i64 + 2;\n let mut query = vec![];\n let mut stack = vec![(n, p.len())];\n while let Some((n, k)) = stack.pop() {\n if k == 0 {\n continue;\n }\n let q = p[k - 1];\n if q * q > n {\n let x = match p[..k].binary_search_by(|&p| (p * p).cmp(&n)) {\n Ok(k) => k + 1,\n Err(k) => k,\n };\n stack.push((n, x));\n } else if n <= bound {\n query.push((k, n));\n } else {\n stack.push((n, k - 1));\n stack.push((n / q, k - 1));\n }\n }\n query.sort();\n query.dedup();\n let m = bound as usize;\n let mut bit = FenwickTree::new(m);\n for i in 1..=m {\n bit.add(i, 1);\n }\n let mut is_prime = vec![true; m + 1];\n let mut memo = vec![0; query.len()];\n let mut pos = 0;\n for (i, p) in p.iter().enumerate() {\n let p = *p as usize;\n let mut j = p;\n while j <= m {\n if is_prime[j] {\n bit.add(j, -1);\n }\n is_prime[j] = false;\n j += p;\n }\n while let Some(&(k, n)) = query.get(pos) {\n if k > i + 1 {\n break;\n } else {\n memo[pos] = bit.sum(n as usize);\n pos += 1;\n }\n }\n if pos >= query.len() {\n break;\n }\n }\n let mut ans = 0;\n let mut stack = vec![(n, p.len(), 1)];\n while let Some((n, k, sign)) = stack.pop() {\n if k == 0 {\n ans += sign * n;\n continue;\n }\n let q = p[k - 1];\n if q * q > n {\n let x = match p[..k].binary_search_by(|p| (p * p).cmp(&n)) {\n Ok(k) => k + 1,\n Err(k) => k,\n };\n ans += -sign * (k - x) as i64;\n stack.push((n, x, sign));\n } else if n <= bound {\n ans += sign * memo[query.binary_search(&(k, n)).unwrap()];\n } else {\n stack.push((n, k - 1, sign));\n stack.push((n / q, k - 1, -sign));\n }\n }\n ans - 1 + p.len() as i64\n}\n\nfn run() {\n let mut s = String::new();\n std::io::stdin().read_line(&mut s).unwrap();\n let n: i64 = s.trim().parse().unwrap();\n let p = sieve((n as f64).sqrt() as usize + 2);\n let mut ans = 0i64;\n for p in p.iter() {\n if p.pow(3) <= n {\n ans += 1;\n } else {\n break;\n }\n }\n for (i, p) in p.iter().enumerate() {\n if p.pow(2) <= n {\n ans +=prime_count(n / *p) - (i + 1) as i64;\n }\n }\n println!(\"{}\", ans);\n}\n\nfn main() {\n run();\n}\n", "lang": "Rust", "bug_code_uid": "7f4639d30290852ddf002e73928c354e", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "apr_id": "cd704259d5d58bd14a3743e0cae36694", "difficulty": 2400, "tags": ["dp", "number theory", "data structures", "math", "sortings", "two pointers"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.013377800388144631, "equal_cnt": 21, "replace_cnt": 12, "delete_cnt": 2, "insert_cnt": 7, "fix_ops_cnt": 21, "bug_source_code": "fn main() {\n let small_prime_limit = 200_000_000;\n let mut is_prime = vec![true; small_prime_limit/2];\n is_prime[0] = false;\n\n for i in 1..(((small_prime_limit+1) as f64).sqrt() as usize / 2) {\n if is_prime[i] {\n for j in ((3*i+1)..(small_prime_limit/2)).step_by(2*i+1) {\n is_prime[j] = false;\n }\n }\n }\n\n let mut small_primes = vec![2];\n for (idx, is_p) in is_prime.iter().enumerate() {\n if *is_p {\n small_primes.push(2*idx + 1);\n }\n }\n\n println!(\"{}\", small_primes.len());\n}\n", "lang": "Rust", "bug_code_uid": "23a62be05c0d259c087437088af91fae", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "apr_id": "bd35a48d0e4a1d46f13a43a97a6afb2c", "difficulty": 2400, "tags": ["dp", "number theory", "data structures", "math", "sortings", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9998761609907121, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "use std::io;\nuse std::cmp;\n\nconst s: &[u8] = \"AsBf=V6Y6O8LWOLGSK.E*F@E?ERCGIE?8<>J*@U=DG)>GAYBI@=>C@TAY;YD:8WED>X;O@@DU=P7OBDC;;P@O88D<7*BLBK:65>;=(?/A(;J<*=QAG4-D5;D@Y>+:Q=E<-@S3:B>,EH:Y4:BG=4C-3C>RE=6W:N?W<4:,???D=Q7BBO:G==8N@.?>76=QEY3R9TBY9:D83ACQ8I?5;W:BAI<+9A@T59F<:.>Y61<>?X=/9KA>>/:38*B;8GA?75AA8ACO4G?28SDD71?S;KAR9C7@AN7K@7@A65?(=V:/8EA4:8B-6UBE72=*>5=H?W51>M:OA7<5=J11?W9G:G>3:G@>9H:D@N<*:F<4<4<1C94?>M77E)8,?N==6X@O;P73=4CQ4F@G<+B?;:9R>B<0>H7;=H>9=/>W<>;;:+=7>E:F?L0MAN@V8H?O4GAQ=998<(<.>E=H?L6J=L9):P==CE7U??8N:3=A=6I8YFR6B>V::L=>?T=S9,;N::AT=+28F(:.68?<9*>UAV1CE@;Y9I;L=K;Q:5@/:J@15T@C7H;*A19.DC6Y;;=-<<7C:DE9:JI71?X@?4@:3=B?T<0:L=@95:S=S@)4X?8?-=,5RE05CCB2/>>>@?+:P;M?C;S8M>Q7M?H:-;S?A6=B:?-2WDT6<<*@8>M:68+<,5UA.=E;U5AC3928-;L=0AG6*C24G@.@M82?(?R4>;*=HAG=G6M93A@66AL=A7I>;7X=F=K8=DE84;8<@A57(A/6RBI62D=I;Y73A.:X6B:4B>75FO76>+959-=1=34N@0=I>F9G=A7/:9;M9(<(A*8+DL4L;L=9?-9-=9>=7B:7N=@79=,>E;J:M;Y;T?0?Q4L837C>*>A;.:P39>V9GB09U;<@?J2(;(CC=?8VI;;@L4Q=(?C6M@K7G;2@6:==*>17U;,D+6E>J=)87<<:Q?=8*A.78/><@P;1>)9+9X8P:UB??R7L929QCX6H:)?1;7@)3/*F-R5?E=5L@>6L8LI;4D?,;=:L>P<,78J7/=-DW4J?M7-XP71=<<)?V:U4/DH8N7W=1?Q+=U=-6S;7AL;7?N8B>C8>>J5N>Q:??QAU5T8R=G;J?A?(81:.BT97>R4W>N59HX:J9R8+@13*@F;D8R?R32>HCV7N8XDH6O9H@+7>AF5K>Q?0:R??8(3FE19R>I7>;*CH7O95BQ:L38A?-91=):?=+;-?IS9,>H;=;F?I;S59?6:JQ8U<3;0CF-I@<==>,<2?52;@B>L<)>Y=M5=?K=@7*6-?B>1:FAY9GHCV1J?29IBE9R8A=R>B54DL;S37BW4@DI7T9B?J<(<5;<@4=R7U>5;-A?5U?/9O:08-?18I?L?S7R=M91B;8F:A98M79?R;3>AM6O;*:G?R@X4F=D:U?5;A73<5BL35DC:6=C8N9K:OBN4GA.51?.=T=;D;7G:E;L6L>V=;;0;1>J:M><;Y>(99U?-9>9F;0=G;)>@<(/9G>*:*>/>138B49)A-:/;.;JB<34D-8O;1;<<<I<,?3<9L?@7Q;>;+?)1OGY8Q<95DAO@<9Y?M8F;*;9?=8(@*->/57AH92?*:U=L?R2@?(=-9+B45V@M6;EH8L;*:F>K6,B<=M2PBY8DAS6H0<-;)43CE>N:E?Y4.@>8+@D65>T=);D9KCD<7/BBG;@B(4J<+@K9=45*CT;N42?:>1:/9<98G+8T;8;;8/@;9E7GFA8K8I@A839B:A@V>96B>)=E=9:.;--:F>)6VB38B7S?.@08FAU8?6CAF8:74(FP2PDP4R@N6QB.:M9??-;0>68C;A?E8)A+9Q?Q7Y:4>/<.7X@R9M=K;>A17I:L=S;H:K:0?G85>?;E>.<3;?959WBP:N:2:8==@(?C8>6?>J:S/<4.5T=WV>08@>.;S;5<>=M>M82=7<68E>E?43->O>N,B:6T=O=(7XAX9Q=V:=>38A=1BW3XAS3S@T7;B@6SH;Q@36793A;;Y6)AA9X:FBW5:?J:I;B8L>G9F?)=(=U;+90CW3A=3?W:V:Q=R9S9N>A=9?74K=1>)R:2>07GAL9D=Y93@76/DY5=9N=H9*F-6,=*;2:/52GX4,?1?+<56I@V:-;7C@809K:OCU35>A:(AT=,=4?K:;9U>3-62=*@W:/9QEQ6R(=M;B?,5Q:V>C=S<.A-49@S:N7DAD>T8L?E4G?6@E9V;O4-?,@U9M=H90@Q;7:U;K97=NAM858(>?8,FP3MC56B=X8;<4>081BI3.L?0X28;<26OA?;Q<-=E@B4H>T6/BI7N@F3YC9;2;3>5<*7C:H;A>0=<>53QA.=10<3:F8O@35.=1>O>P@D0(CP79?B*;)=S7*BV7G<)>)=D9P<@<@8Y<+A47F8QAT9S?T9Q<,69>PA>O>-;673::V<,7;7CER7W<(>2>F21C?;3<->.=07Y=*;+BA1=C9=N7C=N>>9Y;B5O?N<(=2:/CC8.L:O9<:79H=<@<;I;<<17M@Y8WBC6AY7/>M<=9H>C;4<1;+B)@L4O6:?O7M:(HH2:<:;,<>;H>O<=;99*=J72BL;78D:I@<4A>3>884G@T:47:BM>A5@=E:9(;K;+9A;=BJ9S?932G@9-:E:TBV5F9TCL;U4X>;BE0RB>76;R>Y>:<,5J?;98>I:6=D;*8*@.BA<;8/7*?8:=:(=U>G64B?;B=B=761=E<+=98Y>AH6J9MAD72@.=E>JH8/C-27<:@K?L6U97P@Q7+;JDU069+8<D1*<+BV8<><;*AX;L/TB,=S;V;6;<=8;*7R?>::?X4MC=;*:N8J;AG*08BE75B:;V5.HH3W?=3>AD;R37H16TD;-NF;9;7XDT7)8,?=E=C<:4MDP:V>T48:E?N9@=?@6>U73<0:Y>-94=8=Q:U6WHJ0?<=?9=Q8);M@V8Y=R<3=@;D8C;+94?T;@<-=;7E>X64D*A*6@3UEH:T?;8XK@I4*CS6<8N>??G9L93EV7(8L::?0:,C027?>@J8D?TA74CKI1R9Y:P;F>29U;0;?;=:ACH78P@K=7;T76AH9.>M8*=K>B6Y9P=>??>X23CY719BCC8):/@3)@S6,;=B7<273>P=2>-3PDY8H7DB?;>9/@,6(B<58@59-AI4UDF9E5I<+E//GE4=);371T>N<:?K3NA8;98>AW7TCH7TB@;8;M7Y?.9*A06H8-E9=N9V9-<0>8:H>F7==U;A:0:O9?>6=(Y8KE8.58@M88@8;:I:28R>CAD;.8>;:,5?B-7O?M43B-+8T4,@(@+6;@?85=EA)=G5W?L4EBV:F8L;/>YB08K8G<;D.5;:H@=@A4K<4C88E7CDP/9@);1@(=R8CCD49AW36A5;R:6:,=8@?71::;CA=<0=66/9-=0?+7=FO705M:IFA>K6U55B(@K/JA@A;4F<4=B=C-;A9>8:>T@@;T9G>M4UAV@R3E>P7Y:U>;B?2;CD60AE8BH>*7J:O@B8:>H<3B65N:O9H==8B?(49AY>6:OA*8Y=7;L;S70;.AA:MAN7L:,78<-=?AB>M:58K9N>A?U7<7;@->J7F=-?=:4:5AK4@@:;YA9;80/@0<6C@4L?P89>(<:9P=@;S8A9;<U;<@X8>97J=09T;+5+JL4R3OGS:N8N>2=:1=IM<>69;W9J>X9/86:>CY936,GP9F9:88E)7<<.:8:(@8-?7T65@C6JBG;4AAV:*8?9IJ6.S?2:X:T?T;+>L;+=W<;=.-*CS=L<89X?E=NAK/5>D9S;9@46>>;;C>>;T>N7?C@3G>=;>@Y8M>T80>F:=?V;J8X7H>8AA84B:4J>B<-7B:@JN37<78FBX3R=QD*5-BV5L83<?9TCG7YT7.>JC6;;939M;N;0?/3>IJ59;:<3?V6U=F9;;0>+>)<9C82G:W:H65OAU1IA*?J8V<*=T;@9-<78TBU65=?B(7S;5A=I846V;CA6BE8J?M5O=<9=A?;;6R>+9VBR62>8;M/:@>E6B;8>G<4;L>2BL4H@P0E>*=O=G>L46BD7*<0=Y@=9Q7X?:>A:,@28R>N3)Q5D=.DH>P8Q:J=G4L@8?R-,DW>,9>@A3NBY=E:U:E:O=H;9@W.V>/=RD-?R3P:9;S?Y=7?A3K=5F53)?:@:R=,=B=9>V5,?*;*E*0H@D9.>X;C?Y//D4>?B52992B175<,:>CB9@>Y3,EK9TQ:U;:@G7Y8,?E>->H4L??7P;D?=7NFJ=(3B@4.>Y9HE>:@;?;:L>P8B=X9U<7CW2UAP4YC(9@:0BF65>F8Q4UEC9091=R?1@G3C>9<4AG:,:O:O?C:*2S@0C487:N;A=9;R9:EU3T>T=9<8V?U9?ES3T77<3@/6T@/@K:H?82(B?:5=T6AAJ3:CC90>C:3?69);285@@96;>:N8S;0<;@(99@-6YC<7E8GEE3->1DG34<M=W3?G38;<79=A,24A*J;5;65CEG6N>K92:BF7:=51>L=Y;V8T=6?O5.>,>H;97+B+6@<0B1=65OB+8C?@3H@KAT;09T5-?D=A9O@Q8>:/8?AB:5BS7I:M?45/@O;Q8VB28W8HB<9+@K6::4>W;O>2:782C@=N8X2BHH4RBK2)=P=)?9<7988C>L?27MD,7MAD9H7A@86T=(;RC*6V>S7W85CM;99B;/:KA2908H?;58=I>M;E;*>4=?=P4,B?=D:-A?3?AX2F@7>98V75J*1*?+=)@S,5XCD>M4)><>T48=V9D?J;>?.=J7E;XB.22A>7HB)8H>=7?@Q7S;RA*5;:U@Q>N4*D7787OA49OC@17B?Q:D<@9=:<:/?F@E5*B59+B)6I;5;H8WD>5??U6NA):):/:4:<@+7Q>C>F<:BK7F<450?.A.83;J=Q6+BM=-3?A.=V7V=<==80>FD20O<.AP87?*<06NDJ5+>S7F6+D;>S;460AB:1=S<<9:?,92:<<5;I94B>::?=)?E9Y9*@K9=AH5J89F;675-HW76:5;/X8+=B8KES7S6DI:28?@?:0BC59>M;?;9>C1F>JBK:S;9:<7J;N9GHC6Q6<1;9;Y<*@R:S@,8I6)>+*;.8.=+83CL;W56?>>C7J=K=<8M@/?V3B2;77;@T?J?<,XG1;Y9O;P>7:H9R7(CC<93F@K;,=I=*:S;3>W=U<7;C79J16CA73?3<)<;1?=927+8X=X6JC)?54I;4)8W>@B=2K;O@>=;6E9T8:G5PAX55;<@26@=+?78><6<(C/63C20J@V:R<4=-K;)=X>N>I5I=E8Y=UB055=>AP9(A)5Y>H7L9DS8.=08N>9;0CN7E9H@A9W7DB<6-@-7-?>;H?H978X=Q<+<0UJ,7K4QBJ6A>1;+?<;Y>98;7;AE768AHO/;>H@I:P<7@Y/GFK<>59;7>R:Y@;7;@.;)9C>H5FCW:W9H:*DK;68R<<9+<*=+;TA(70;V94AA6.?.A/8P5E?.98<<@/:6?O8X9:>B<8;T>T7,?G:P74E<;G61;2>@>39G96=K;C?S:I=63KD*3DF58:9<=CJ;B7PC-9D7SAX4?@H@D8::7<7>,><3P@@7:>Q;P:TE14D=H=L3DC1>M4CF737:2?.=NC4)D)W?C:U;Y8)CL7W:D>180CJ2NB;9J:(;9@V9.<-=SAL4P=G@(4.:-;BA8>291B48X7CE90O=,@-9Y=,?=S34C094=Y=B6>U@Q9GEI/LD50UF(6+BW5M>14R;QY;S9;=<7J9K>-?1;;V:?8Q@?=;9(8T9W<>>.C+:E65=J@H9>=O9K:/=87G=2D;86@44@A,;F=;3:FP55=18==1BA7>;F?LJ6,;5>;CU6*+7U;:;1@Q9;;+>.6L>1<@:J9)DG;<;-;?9?@F=:4O:A<@>M?X;>3.F/>A7X:V;@6,>4>JC74:@N4JB.?I6Q1>*8H8@>N:O;N;NA520@+;A:CDA4L>/?W78;Y59G@8=>810B8@38.:L7H@2@H<)6V>O;BD(1LC1:E56B>>86;8J6@CA8O817*C->O8/;/=97=I;D84DQ5<<:;I>B7+H=S:I0;V9A85E87<M=A=<6A9+@A9PA?50=)?G8+D67M9+9T?F<79*<)>58KC,>W1Q?I:H>0<=3VCH?J7W6M=N=2?6=Y8:>?;77D;>8=859D@B>W:U@E97:C=D7+@79R::>+=A9V=Y>T6Q7SCA8(>R>R35:*FH=A9)9E;Y7Y?R>O;<<*9)BQ;:8,9WP0L?>@192>S:B9NI;J;X=+8(P6KCL6U>R7Y<9>9=191>537KK7,0IA;;P;,8VCJ=<:.AO2L@H=A5<:;@W<4=):M=T8.?49,=6:7>V@-7+=<8I=9=-@U1CCN=T7B:J@Q:44TCL)>D7+8BD-==:,:+7,BO*48>O>M=S8K?@>N7+X;;<29NBG25A->L?+<07L79EB9*5D;><.=L@Q9/6:@1=:(>-9F91?F:0=S8M7M@J>>7V@L6+F>3)B36I<):;?WB>F:B8=8;37V>-<3?66B@D76D05>@6;+9M*7<@M64C*:?:6@R9L<>:/9P=>>.;+:@B(@?/PN:9>);Y?46O>BD*5UA)7E88@U8@?*>X9V9TC-8>;H9>:,A29S:E>@@37?=(6V*7@=/;V;PC=O3;CL7+>>2>FG86BD?:,-AL=?@,9+<5>05N>1T9W:A>98,;>>L:M:88*BJ:K>D9*;F=(:PDX5Y8E?*4@:,E167GQ/XA,9E>0><;Y7H;P8?DF:R:?6H<@6U:O?>;5;U;L=0@8:R6X?J@81(A/9>>S;.=5:8<7;:5WBC@.7;<*9N:/A:>M?B.U@(=W584:/BP50A47K:3A68G@I78;L:)B85/B(:K:C?I=(2;F>59A,;+>C3A49*98A)1=0BS59>>9VB66??P9,2@HP8NM83D/:G4=CAD;D9H;J?R=96,G<2I>1AQ7H=*=48.;9A35.8CFB8=8O?V>>9*A130>O<<6H@/:(?+;C67W<,=B:2;FO9A?2:R=/:Q,;2:O-AJ;F4/EM4E::ED5*>0?/:A>R7C@O1W

E(:.;=8*;D>F5@W;2;C>9<0>15G8VB(4/GA8V>,9.?351@+>M38=>;AB+8D@42T@H>1;G;=:6==*:Y:W9A>-78@E45AC8D@U42?X8W@D89>N7/?@-:T7T>L89C)83:3;E?+6GBG;J92:/>8<@?=627WC99F88)7NAR8D?+5>?<9(;L>L:A6C@D;0?4=F6;=09PA>9C=J;C:IBE;C7H?8>R7C4UCG7+@N8A>6;/?+:?7-:)@E:8@+8HB@:-:3?U8X9W?F6XA79/:B71GM3Y>,;C?N77?U>D3Y;;B869@W9?>)4JA080AK;M:Y?=R80A66:8J;VDS6KA-7R>S;BA;9,3(EF87>C;D55@AH<<8VL71>2B08;C99H0KFV3EAJB,7-44D?4AA1A562?H5,=H?*9XBF7N=0:L;1><7V@H5MBK<:7;=@>G9K??8858@U;E@3=2:1=R2CAI9T>R8L<<>(>N@2969G8-8B>8@G6W7>@T9+;AA-7P>S6-:0G>2U>.>;L>09,<0:.A24SE/7A-0TG?86;V7=:F>?DM/GE476:NA(6?CB7Y@*5-<==YN51AT41BB;HGA29+?64+:F>3EC54?F=Y:,:198>HA.3/B-=G9JAG3Q71AT4*DA9Q<9:A>1:A<7:->,4/L76T;H<)2WCA9IF;01@17;@R6.;4?=A(5OG8/,A3>:91=26W:1AC?26;?2Q6M@/8XAL5C@B84:WAU6*9/AX8J:1B?7FR>S7R@O7)@7=,3@<(<.B35+CG94A2?(.(@LBC9O:E70:-HJ3==M?4=(6(?X8796BS5X@.8TI:89X>6=S7(>A>:4T=6?,:H=D?58I7Q8VD+57GY5(:5??;BAI5J66:->)=C;M;)AM3HB33H>XD-2:DR4:?K>M=03CAS8PAH:W;K9T:K@M8@;I==@0;,8K6JGH1)?JRA);F9:92B5:C2;56BB?>X>2709L>R=94.;TB89O?GH:G:T?V8E:C:O?18J:PA3?J=E1W>1<*9B5J>.=B>16S6TE*:P:=D>3W9X>2@L4T>99?;0?R<397=-D)9T3ND?2B=<<<=Q:UF2317)@QB@<87X:89*;R@Q?W3)=;=M;>:O=P;L@J6N(7<>2X=N2-GA.LC,:F=J7/LQ-P;WB,9G4W=,?+;DEB32<);NC;9,<9>M57@<5=9YAB07I@?5(AV7?8+EV8*:J6H>K@8;D<*=493<;:BB4M9DA8;9=.9D9C@3K?A967A;H?=:J>(929P=.DF4(C/9S=.2AB873?N*?W:.:JD(9K6B?F8(=8?T;S8?;F<+A(2>A6;,>+@+3<:8>G=B6AJ<814A:F?(>V22IG47<9<2@V9)<.9@63GB=-:-6,?9=K7S:2;=?Q;I=*7L?Q@19U?Y;L=D8C>-;M>194?57<89+?=8M;P:9;F;+;3@.:OA=4-HQ4L<.8IC=-HAU7;U:69NB44A@898=Y=K99=<=4;P@S87>B5M:P;A@;3DF.*>1>+>R3GD93EW1;?X54=N?><;8.?O8>CP7D:9;B;A9@=;A9;,62AM==D:+?U7;:>9HE;4N9;<=B.:V;>:A7N?T?I:+?A6A?;=N8-;(7,@2AB8H;*8+?)@Y?51/?M7+CA9V>U93;,:9B37NE(6I7VBU/2@*>3;M@W82=772?L93?6=V42D@5?A4;B6X:V@5:UAG1Q@N95A27.=H;H??8FAI5:9=437@=?Y?K;A;D38C)8/8I<-D(:5>X2@=I:-A*<@@W8(8GAW;0;54UB=9J=K?R8F;0>J?K6L7)?F4BEE5FDK5BCP7A:F9:;F>G=1;@7)K56?H13HK;46N?P=O746BCS7K;IAC:L;-@/MB,?67609IB.:Y;=;O;8;*=(:0,=F?G:;;=;<<1?09U>W6(>;:X37T@=71;=N;D4SCF7A=F6+CR5N>F;W<;:UBO6*=T?J<78=92D=:P?184@7>?1N:.@.6A>X;,D28,6HD2<-9P;*;4>(:Q5C?:=-=Q>Y6+;5>?:)?T9=H3=1LB<:V?313FJ4L?S;::F:3AY;L:7899J?(=G=@6YB/=/8(?76+>>:A8P@=7IE?5X<4:?>=?08E>Y>/5P>R65DC29B?=*;3;39;BN7D9S@KC?0*>48HA58R;.<29S8,FVG6Y@X9G1H?T;9=1@)<89D>=54=LA3<4@I4PAQ6C<2@L8.;8=(6?D@:L=A7388A+<(;.=/:Y?U6(?19K>(?C6B@8U<1>D5I=??M>57B=;;,:I>0A/6RAM:V86=A:>1/JG:057DK;P6?B:>>F;H:C:3W3(-7@H74?K;W<;A>>W3781=*=/>T8S?Y65AP<7:W9L@M6T8DF85L=,;O;L9?=X8VDP6J@U73:5<):TB/=J8:7MB89C;B6>C<4,@17PA-=S8Q?W:F?I6X<9<(:VAX04F9>.61=49?;NAV5K?W;<94=S?J89;L;4@Y-OL86Q@N7455>DC?:D:A7GAP>66F9>C18L:90BQ60:D:5DC1L?D=S9=A:S=N>97F8=@,?=:(=/>(5I>7:J@L5<7VDB8B;@:?C59*<-8R@-?=6Y<>9X;8B143?E9:75A68*<>DR0OIE2JBA8PBK3I;:?Q:V<3:R>G:5@M42BR8F?5>W0(@080C276<;0?:9;B+8D7=;8?P93:*FU3D9@;0<*:HBD:@C;5D6.7E:7U?G<.;G:3AQ59?N6O>-?J83;J1=S75DF4C=;2XJA4(B;<+71@3<=3N<5G35,<09<>G?S9F;C<,:2>-<@AO5::X<-7DCF:08=?I8OA65?CT:E,56=TB83+CT6*7=BV?(:.6:@R9(?4;6:*;UCJP>16+>0?9QBA91>)@;5T;4?I>4;*=<5??P9C8G>F>(?>43B>6WB@8>=*4W@*>8-7A>Q>P;V<==B=Y,L?P;2:Y@07X>?<07-?B=>758@/>D6->-?+88=?(;9(1<,?6:+@51IC+:@JT0E71EY:C=K+HG,9+9Q>OAL9G9C6HANB88A=9=M49=C?O65@(;N>,7;A(:+M?J=Q9O9ND<3E:T:K=IAA8+9@=08R=VAQ8;8Y=D>8T:Q6FET8U4?<.@7959IAG=O99;0=O4/@;BH7+;(;I@?6@?S6>CU5*?;(71B/7C@I=E8N60>W9SC=64B*7T=R;A=V8?D8/YJA702;DD29F<6>P738PBK>A2/B0=?;U2SD.?;32?E<@>G5-=M<;C49><6:=<;7L?D=M9V8R?0AU6DB-4M;I3)D7=@9ABC80?U2M=VD+27EV58:B>*A8D?*:6;*@L95=S3AD><)8J91AC@Q2Q>9;2:=88H<894;,A=<;<)8@:N9/=J<07?>1>*82A/7P>G@.3;B(=T:DB,5,8YD+3F@D=54JFF48=V;K=A>C:E=<0*J10-D09/=*:5>D:H>S;8<837B9;M;F>,:99.@SC93D868@BB@F=>7Q6</=R;T9=?I77A\".as_bytes();\n\nfn count_primes_in_range(lb: u64, ub: u64, small_primes: &Vec) -> u64 {\n let mut is_prime = vec![true; (ub+1-lb) as usize];\n for p in small_primes {\n if p*p <= ub {\n for j in (((p - lb%p) % p)..(is_prime.len() as u64)).step_by(*p as usize) {\n is_prime[j as usize] = false;\n }\n }\n }\n is_prime.iter().filter(|&is_p| *is_p).count() as u64\n}\n\nfn main() {\n let mut input = String::new();\n io::stdin().read_line(&mut input).unwrap();\n let n: u64 = input.trim().parse().unwrap();\n\n let small_prime_limit = cmp::min(n, 200_000_000) as usize;\n let mut is_prime = vec![true; small_prime_limit/2];\n is_prime[0] = false;\n\n for i in 1..(((small_prime_limit+1) as f64).sqrt() as usize / 2) {\n if is_prime[i] {\n for j in ((3*i+1)..(is_prime.len())).step_by(2*i+1) {\n is_prime[j] = false;\n }\n }\n }\n\n let mut small_primes = vec![2];\n for (idx, is_p) in is_prime.iter().enumerate() {\n if *is_p {\n small_primes.push((2*idx + 1) as u64);\n }\n }\n\n let mut prime_pi: Vec = vec![0, 148_933, 283_146, 412_849];\n for i in 0..24997 {\n prime_pi.push(2*prime_pi[i+3] - prime_pi[i+2] + 1000 - s[2*i] as u64 + 40 - (s[2*i+1] as u64 - 40)*50);\n }\n\n let mut res: u64 = 0;\n for p in &small_primes {\n if p*p*p <= n {\n res += 1;\n } else {\n break;\n }\n }\n\n let mut pi_n_on_p = 0;\n\n let pi_sqrt_n = match small_primes.binary_search(&((n as f64).sqrt().floor() as u64)) {\n Ok(i) => i + 1,\n Err(i) => i,\n };\n\n for i in (0..pi_sqrt_n).rev() {\n if n / small_primes[i] <= small_prime_limit as u64 {\n while pi_n_on_p + 1 < small_primes.len() && small_primes[pi_n_on_p + 1] * small_primes[i] <= n {\n pi_n_on_p += 1;\n }\n res += (pi_n_on_p - i) as u64;\n } else {\n let bucket = n / small_primes[i] / 2_000_000;\n res += prime_pi[bucket as usize] +\n count_primes_in_range(\n bucket * 2_000_000 + 1,\n n / small_primes[i],\n &small_primes\n ) - i as u64 - 1;\n }\n }\n\n println!(\"{}\", res);\n\n //for i in 0..25_000 {\n //println!(\"{}\", count_primes_in_range(i*2_000_000+1, (i+1)*2_000_000, &small_primes));\n //}\n}\n", "lang": "Rust", "bug_code_uid": "fea462f5b5ba12729c9d3fb8e5b84698", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "apr_id": "bd35a48d0e4a1d46f13a43a97a6afb2c", "difficulty": 2400, "tags": ["dp", "number theory", "data structures", "math", "sortings", "two pointers"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8361581920903954, "equal_cnt": 4, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 3, "bug_source_code": "use std::io::{self, BufRead};\nuse std::collections::HashSet;\n\nfn parse_problem(mut input: B) -> io::Result> {\n let mut buffer = String::new();\n input.read_line(&mut buffer)?;\n buffer.truncate(buffer.trim_end().len());\n let mut positions = Vec::new();\n let mut curr = (0, 0);\n for c in buffer.chars() {\n let next = match c {\n 'L' => Ok((curr.0 - 1, curr.1)),\n 'U' => Ok((curr.0, curr.1 + 1)),\n 'R' => Ok((curr.0 + 1, curr.1)),\n 'D' => Ok((curr.0, curr.1 - 1)),\n _ => Err(io::Error::new(io::ErrorKind::InvalidInput, \"bad input\")),\n }?;\n positions.push(curr);\n curr = next;\n }\n positions.push(curr);\n Ok(positions)\n}\n\nfn main() -> io::Result<()> {\n let positions = parse_problem(io::stdin().lock())?;\n let mut seen_positions = HashSet::new();\n for pos in positions {\n if !seen_positions.insert(pos) {\n println!(\"BUG\");\n return Ok(())\n }\n }\n println!(\"OK\");\n Ok(())\n}\n", "lang": "Rust", "bug_code_uid": "8eb3a022c3bb35e66a9f18c1b67fe538", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "apr_id": "5abcce797af8db443a6e60e4cd68db54", "difficulty": 1400, "tags": ["graphs", "constructive algorithms", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9988966531813167, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\n\nfn read_line() -> String {\n let mut input_line = String::new();\n io::stdin().read_line(&mut input_line).unwrap();\n return String::from(input_line.trim());\n}\n\nenum Protocol { HTTP, FTP }\n\nfn fix_protocol(s: &String) -> (String, Protocol) {\n let mut res: String = String::new();\n if s.chars().nth(0) == Some('f') {\n (s.chars().skip(3).collect(), Protocol::FTP)\n } else {\n (s.chars().skip(4).collect(), Protocol::HTTP)\n }\n}\n\n\n\nfn main() {\n let mut s = read_line();\n let (s_skip_proto, protocol) = fix_protocol(&s);\n let mut s_res = s_skip_proto.clone();\n let s_res_skipped: String = s_skip_proto.chars().skip(1).collect();\n\n // res = String::from(\"http://\");\n // let appendix: String = s.chars().skip(4).collect();\n // res.push_str(&appendix);\n\n println!(\"{}\", s_skip_proto);\n\n match s_res_skipped.find(\"ru\") {\n Some(i) => {\n s_res.insert(i + 1, '.');\n if i + 4 < s_res.len() {\n // println!(\"------------- {}\", i + 5);\n s_res.insert(i + 4, '/');\n }\n },\n _ => panic!(\"no ruurururur\")\n }\n\n let mut s_res_res = match protocol {\n Protocol::HTTP => String::from(\"http://\"),\n _ => String::from(\"ftp://\") \n };\n s_res_res.push_str(&s_res);\n \n \n println!(\"{}\", s_res_res);\n}", "lang": "Rust", "bug_code_uid": "0d5f1d222b01da087a788a649fb24539", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "apr_id": "f9d4a0cadb82b21fd21f4fff488363f0", "difficulty": 1100, "tags": ["strings", "implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9349470499243571, "equal_cnt": 3, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "fn gcd(a: i32, b: i32) -> i32 {\n let (mut a, mut b) = if a > b { (b, a) } else { (a, b) };\n while a != 0 {\n let tmp = a;\n a = b % a;\n b = tmp;\n }\n return b;\n}\n\nfn main() {\n let v: Vec = {\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n line.trim().split(\" \").map(|s| s.parse::().unwrap()).collect()\n };\n let (a, b, mut n) = (v[0], v[1], v[2]);\n\n while n != 0 {\n n -= gcd(a, n);\n if n == 0 {\n println!(\"0\");\n }\n n -= gcd(b, n);\n if n == 0 {\n println!(\"1\");\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "b2dfb0dbbed67dabf9db830188dd1f43", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "apr_id": "4a3da6e12445bbfe33444d1e334222a0", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9800472001716369, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 0, "fix_ops_cnt": 2, "bug_source_code": "#![allow(non_snake_case, unused_imports, deprecated, dead_code)]\n\n// Input macros\nmacro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }\nmacro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }\nmacro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect(\"Parse error\") }; }\n\n// Module\nuse std::cmp::{min,max};\nuse std::collections::{VecDeque,HashMap,HashSet,BTreeMap,BTreeSet,BinaryHeap};\n// Module for v1.15.1\nuse std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead\n\n// Functions\nfn gcd(a: u64, b: u64) -> u64 {\n assert!(a != 0 || b != 0);\n if a == 0 {\n return b;\n }\n else {\n return gcd(b%a, a);\n }\n}\n\n// Main\nfn main() {\n\n input! {\n A: u64,\n B: u64,\n mut N: u64,\n }\n\n let mut turn = 0;\n let stones = vec![A,B];\n loop {\n println!(\"turn {}, N:{}\", turn, N);\n let d = gcd(stones[turn], N);\n if N > d {\n N -= d;\n turn = 1-turn;\n } else if N==d {\n println!(\"== turn:{} d:{}\", turn,d);\n turn = 1-turn;\n break;\n } else {\n break;\n }\n }\n\n println!(\"{}\", 1-turn);\n}", "lang": "Rust", "bug_code_uid": "d910766f8d0106a5e06073e955451f6b", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "apr_id": "ef25f9bec332b0011af45224280821cd", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.41975308641975306, "equal_cnt": 12, "replace_cnt": 6, "delete_cnt": 3, "insert_cnt": 3, "fix_ops_cnt": 12, "bug_source_code": "use std::io;\n\nfn main() {\n let mut line = String::new();\n io::stdin()\n .read_line(&mut line)\n .expect(\"error\");\n\n let line: String = line.trim().parse().expect(\"no\");\n let inputs: Vec = line.split(\" \")\n .map(|x| x.parse().expect(\"Not an integer!\"))\n .collect();\n\n let (mut a, mut b, mut n) = (inputs[0], inputs[1], inputs[2]);\n let w = inputs[0];\n let z = inputs[1];\n\n loop {\n //println!(\" n equal {}\",n);\n let mut m = n.clone();\n\n\n while (n != 0) {\n if a == n {\n println!(\"{}\", n);\n } else {\n let t = n;\n n = a % n;\n a = t;\n }\n }\n if w == m {\n a = w;\n }\n //println!(\"gcd{} {} = {}\",w,m,a);\n\n if a > m {\n println!(\"1\");\n break;\n }\n\n let d = (m - a).clone();\n\n while (m != 0) {\n let k = m;\n m = b % m;\n b = k;\n }\n //println!(\"gcd {} {} = {}\",z,d,b);\n\n n = d - b;\n if d < b {\n println!(\"0\");\n break;\n }\n }\n}\n\n\n\n\n\n", "lang": "Rust", "bug_code_uid": "c066546a8dd2b1d01388b67dd1a22327", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "apr_id": "3bea07e41dc5ad734ac76eee9f8b3877", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.4292828685258964, "equal_cnt": 14, "replace_cnt": 5, "delete_cnt": 2, "insert_cnt": 7, "fix_ops_cnt": 14, "bug_source_code": "use std::io;\n\nfn main() {\n let mut line = String::new();\n io::stdin()\n .read_line(&mut line)\n .expect(\"error\");\n\n let line: String = line.trim().parse().expect(\"no\");\n let inputs: Vec = line.split(\" \")\n .map(|x| x.parse().expect(\"Not an integer!\"))\n .collect();\n\n let (mut a, mut b, mut n) = (inputs[0], inputs[1], inputs[2]);\n let w = inputs[0];\n let z = inputs[1];\n\n loop{\n //println!(\" n equal {}\",n);\n let mut m = n.clone();\n\n\n while (n != 0) {\n\n\n let t = n;\n n = a % n;\n a = t;\n\n }\n if w == m {\n a = w;\n }\n //println!(\"gcd{} {} = {}\",w,m,a);\n\n if a > m {\n println!(\"1\");\n break;\n }\n\n let d = (m - a).clone();\n\n while (m != 0) {\n let k = m;\n m = b % m;\n b = k;\n }\n //println!(\"gcd {} {} = {}\",z,d,b);\n\n n = d - b;\n if d < b {\n println!(\"0\");\n break;\n }\n\n}}\n\n\n\n\n\n", "lang": "Rust", "bug_code_uid": "03e902f067075db092f37d7539f167fc", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "apr_id": "3bea07e41dc5ad734ac76eee9f8b3877", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9994490358126722, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_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": "Rust", "bug_code_uid": "0fac995840288be5364625fac26ec9d6", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "apr_id": "71b5cbe9d219f978b8625a95e63aa052", "difficulty": 1100, "tags": ["math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9983498349834984, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::io;\n\nfn main() {\n let mut s = String::new();\n io::stdin().read_line(&mut s).unwrap();\n let mut s = s.split_whitespace();\n let x: i32 = s.next().unwrap().parse().unwrap();\n let y: i32 = s.next().unwrap().parse().unwrap();\n let z: i32 = s.next().unwrap().parse().unwrap();\n let t1: i32 = s.next().unwrap().parse().unwrap();\n let t2: i32 = s.next().unwrap().parse().unwrap();\n let t3: i32 = s.next().unwrap().parse().unwrap();\n if (x - y).abs() * t1 < ((x - z).abs() + (x - y).abs()) * t2 + 2 * t3 {\n println!(\"NO\");\n } else {\n println!(\"YES\");\n }\n}\n", "lang": "Rust", "bug_code_uid": "83c8c5537742e65a210a21609662737b", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "apr_id": "707e3dec21cfe59a8d1e2f2a4f820cec", "difficulty": 800, "tags": ["implementation"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8587667560321716, "equal_cnt": 45, "replace_cnt": 16, "delete_cnt": 2, "insert_cnt": 26, "fix_ops_cnt": 44, "bug_source_code": "#[allow(unused_imports)]\r\nuse std::cmp::*;\r\n#[allow(unused_imports)]\r\nuse std::collections::*;\r\n#[allow(unused_imports)]\r\nuse std::io;\r\n#[allow(unused_imports)]\r\nuse std::iter::*;\r\n#[allow(unused_imports)]\r\nuse std::mem::*;\r\n#[allow(unused_imports)]\r\nuse std::str::*;\r\n#[allow(unused_imports)]\r\nuse std::usize;\r\n\r\n// vec with some initial value\r\n#[allow(unused_macros)]\r\nmacro_rules! vvec {\r\n ($($x:expr),+; $y:expr; $n:expr) => {{\r\n let mut v = vec![$y; $n];\r\n\r\n let mut it = v.iter_mut();\r\n $(\r\n *it.next().unwrap() = $x;\r\n )+\r\n\r\n v\r\n }}\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! it {\r\n ($x:expr) => {\r\n once($x)\r\n };\r\n ($first:expr,$($x:expr),+) => {\r\n chain(\r\n once($first),\r\n it!($($x),+)\r\n )\r\n }\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! pushed {\r\n ($c:expr, $x:expr) => {{\r\n let mut c = $c;\r\n c.push($x);\r\n c\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! inserted {\r\n ($c:expr, $($x:expr),*) => {{\r\n let mut c = $c;\r\n c.insert($($x),*);\r\n c\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_tuple {\r\n ($($t:ty),+) => {{\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n\r\n let mut it = line.trim()\r\n .split_whitespace();\r\n\r\n ($(\r\n it.next().unwrap().parse::<$t>().ok().unwrap()\r\n ),+)\r\n }}\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read() -> T {\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n line.trim().to_string().parse().ok().unwrap()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_str() -> Vec {\r\n read::().chars().collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_row() -> Vec {\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n\r\n line.trim()\r\n .split_whitespace()\r\n .map(|s| s.parse().ok().unwrap())\r\n .collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_col(n: usize) -> Vec {\r\n (0..n).map(|_| read()).collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_mat(n: usize) -> Vec> {\r\n (0..n).map(|_| read_row()).collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_vec R>(n: usize, mut f: F) -> Vec {\r\n (0..n).map(|_| f()).collect()\r\n}\r\n\r\ntrait IterCopyExt<'a, T>: IntoIterator + Sized\r\nwhere\r\n T: 'a + Copy,\r\n{\r\n fn citer(self) -> std::iter::Copied {\r\n self.into_iter().copied()\r\n }\r\n}\r\n\r\nimpl<'a, T, I> IterCopyExt<'a, T> for I\r\nwhere\r\n I: IntoIterator,\r\n T: 'a + Copy,\r\n{\r\n}\r\n\r\nfn main() {\r\n let n = read::()\r\n .chars()\r\n .map(|c| c.to_digit(10).unwrap() as usize)\r\n .collect::>();\r\n\r\n const B: usize = 500;\r\n\r\n let dp = n.citer().fold(\r\n vec![\r\n vec![vec![0usize; B]; B],\r\n vvec![vec![usize::MAX; B]; vec![1usize; B]; B],\r\n ],\r\n |prev, d| {\r\n // eprintln!(\"{:?}\", prev);\r\n (0..2)\r\n .map(|t| {\r\n let d = d + t;\r\n let mut dp = (0..B)\r\n .map(|i| {\r\n let mut v = vec![usize::MAX; B];\r\n\r\n if i >= d {\r\n v[i - d] = prev[0][i][i - d].saturating_add(i + (i - d));\r\n }\r\n\r\n if i + 10 >= d && i + 10 - d < B {\r\n v[i + 10 - d] =\r\n prev[1][i][i + 10 - d].saturating_add(i + (i + 10 - d))\r\n }\r\n\r\n v\r\n })\r\n .collect::>();\r\n for i in 0..B {\r\n for j in 0..B {\r\n if i > 0 {\r\n dp[i][j] = min(dp[i][j], dp[i - 1][j]);\r\n }\r\n if j > 0 {\r\n dp[i][j] = min(dp[i][j], dp[i][j - 1]);\r\n }\r\n }\r\n }\r\n dp\r\n })\r\n .collect::>()\r\n },\r\n );\r\n let ans = dp[0][B - 1][B - 1];\r\n println!(\"{}\", ans);\r\n}\r\n", "lang": "Rust", "bug_code_uid": "86b3377740126a393a4aecb10ff0ce1e", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "apr_id": "b279243e0cc2ca4512e7c073aeff5846", "difficulty": 2900, "tags": ["dp", "greedy", "shortest paths"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9941236068895644, "equal_cnt": 7, "replace_cnt": 5, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "#[allow(unused_imports)]\r\nuse std::cmp::*;\r\n#[allow(unused_imports)]\r\nuse std::collections::*;\r\n#[allow(unused_imports)]\r\nuse std::io;\r\n#[allow(unused_imports)]\r\nuse std::iter::*;\r\n#[allow(unused_imports)]\r\nuse std::mem::*;\r\n#[allow(unused_imports)]\r\nuse std::str::*;\r\n#[allow(unused_imports)]\r\nuse std::usize;\r\n\r\n// vec with some initial value\r\n#[allow(unused_macros)]\r\nmacro_rules! vvec {\r\n ($($x:expr),+; $y:expr; $n:expr) => {{\r\n let mut v = vec![$y; $n];\r\n\r\n let mut it = v.iter_mut();\r\n $(\r\n *it.next().unwrap() = $x;\r\n )+\r\n\r\n v\r\n }}\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! it {\r\n ($x:expr) => {\r\n once($x)\r\n };\r\n ($first:expr,$($x:expr),+) => {\r\n chain(\r\n once($first),\r\n it!($($x),+)\r\n )\r\n }\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! pushed {\r\n ($c:expr, $x:expr) => {{\r\n let mut c = $c;\r\n c.push($x);\r\n c\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! inserted {\r\n ($c:expr, $($x:expr),*) => {{\r\n let mut c = $c;\r\n c.insert($($x),*);\r\n c\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_tuple {\r\n ($($t:ty),+) => {{\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n\r\n let mut it = line.trim()\r\n .split_whitespace();\r\n\r\n ($(\r\n it.next().unwrap().parse::<$t>().ok().unwrap()\r\n ),+)\r\n }}\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read() -> T {\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n line.trim().to_string().parse().ok().unwrap()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_str() -> Vec {\r\n read::().chars().collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_row() -> Vec {\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n\r\n line.trim()\r\n .split_whitespace()\r\n .map(|s| s.parse().ok().unwrap())\r\n .collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_col(n: usize) -> Vec {\r\n (0..n).map(|_| read()).collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_mat(n: usize) -> Vec> {\r\n (0..n).map(|_| read_row()).collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_vec R>(n: usize, mut f: F) -> Vec {\r\n (0..n).map(|_| f()).collect()\r\n}\r\n\r\ntrait IterCopyExt<'a, T>: IntoIterator + Sized\r\nwhere\r\n T: 'a + Copy,\r\n{\r\n fn citer(self) -> std::iter::Copied {\r\n self.into_iter().copied()\r\n }\r\n}\r\n\r\nimpl<'a, T, I> IterCopyExt<'a, T> for I\r\nwhere\r\n I: IntoIterator,\r\n T: 'a + Copy,\r\n{\r\n}\r\n\r\nconst B: i64 = 500;\r\nconst C: i64 = 50;\r\n\r\nfn main() {\r\n let n = read::()\r\n .chars()\r\n .map(|c| c.to_digit(10).unwrap() as i64)\r\n .collect::>();\r\n\r\n let dp = n.citer().fold(\r\n (-C..=C)\r\n .map(|t| {\r\n (0..B)\r\n .map(|i| {\r\n if i < t {\r\n vec![i64::MAX; B as usize]\r\n } else {\r\n vec![t; B as usize]\r\n }\r\n })\r\n .collect::>()\r\n })\r\n .collect::>(),\r\n |prev, d| {\r\n // eprintln!(\"{:?}\", prev);\r\n (-C..=C)\r\n .map(|t| {\r\n let d = d + t;\r\n let mut dp = (0..B)\r\n .map(|i| {\r\n let mut v = vec![i64::MAX; B as usize];\r\n\r\n (-C..=C).for_each(|c| {\r\n if i + 10 * c >= d && i + 10 * c < B + d {\r\n let j = i + 10 * c - d;\r\n v[j as usize] = prev[(c + C) as usize][i as usize][j as usize]\r\n .saturating_add(i + j);\r\n }\r\n });\r\n\r\n v\r\n })\r\n .collect::>();\r\n for i in 0..B {\r\n for j in 0..B {\r\n if i > 0 {\r\n dp[i as usize][j as usize] =\r\n min(dp[i as usize][j as usize], dp[i as usize - 1][j as usize]);\r\n }\r\n if j > 0 {\r\n dp[i as usize][j as usize] =\r\n min(dp[i as usize][j as usize], dp[i as usize][j as usize - 1]);\r\n }\r\n }\r\n }\r\n dp\r\n })\r\n .collect::>()\r\n },\r\n );\r\n let ans = dp[0 + C as usize][B as usize - 1][B as usize - 1];\r\n println!(\"{}\", ans);\r\n}\r\n", "lang": "Rust", "bug_code_uid": "32a9bc433748e254bf3bb3d1c7fc8b54", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "apr_id": "b279243e0cc2ca4512e7c073aeff5846", "difficulty": 2900, "tags": ["dp", "greedy", "shortest paths"], "bug_exec_outcome": "MEMORY_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9995947315096251, "equal_cnt": 5, "replace_cnt": 0, "delete_cnt": 2, "insert_cnt": 2, "fix_ops_cnt": 4, "bug_source_code": "#[allow(unused_imports)]\r\nuse std::cmp::*;\r\n#[allow(unused_imports)]\r\nuse std::collections::*;\r\n#[allow(unused_imports)]\r\nuse std::io;\r\n#[allow(unused_imports)]\r\nuse std::iter::*;\r\n#[allow(unused_imports)]\r\nuse std::mem::*;\r\n#[allow(unused_imports)]\r\nuse std::str::*;\r\n#[allow(unused_imports)]\r\nuse std::usize;\r\n\r\n// vec with some initial value\r\n#[allow(unused_macros)]\r\nmacro_rules! vvec {\r\n ($($x:expr),+; $y:expr; $n:expr) => {{\r\n let mut v = vec![$y; $n];\r\n\r\n let mut it = v.iter_mut();\r\n $(\r\n *it.next().unwrap() = $x;\r\n )+\r\n\r\n v\r\n }}\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! it {\r\n ($x:expr) => {\r\n once($x)\r\n };\r\n ($first:expr,$($x:expr),+) => {\r\n chain(\r\n once($first),\r\n it!($($x),+)\r\n )\r\n }\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! pushed {\r\n ($c:expr, $x:expr) => {{\r\n let mut c = $c;\r\n c.push($x);\r\n c\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! inserted {\r\n ($c:expr, $($x:expr),*) => {{\r\n let mut c = $c;\r\n c.insert($($x),*);\r\n c\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_tuple {\r\n ($($t:ty),+) => {{\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n\r\n let mut it = line.trim()\r\n .split_whitespace();\r\n\r\n ($(\r\n it.next().unwrap().parse::<$t>().ok().unwrap()\r\n ),+)\r\n }}\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read() -> T {\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n line.trim().to_string().parse().ok().unwrap()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_str() -> Vec {\r\n read::().chars().collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_row() -> Vec {\r\n let mut line = String::new();\r\n io::stdin().read_line(&mut line).unwrap();\r\n\r\n line.trim()\r\n .split_whitespace()\r\n .map(|s| s.parse().ok().unwrap())\r\n .collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_col(n: usize) -> Vec {\r\n (0..n).map(|_| read()).collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_mat(n: usize) -> Vec> {\r\n (0..n).map(|_| read_row()).collect()\r\n}\r\n\r\n#[allow(dead_code)]\r\nfn read_vec R>(n: usize, mut f: F) -> Vec {\r\n (0..n).map(|_| f()).collect()\r\n}\r\n\r\ntrait IterCopyExt<'a, T>: IntoIterator + Sized\r\nwhere\r\n T: 'a + Copy,\r\n{\r\n fn citer(self) -> std::iter::Copied {\r\n self.into_iter().copied()\r\n }\r\n}\r\n\r\nimpl<'a, T, I> IterCopyExt<'a, T> for I\r\nwhere\r\n I: IntoIterator,\r\n T: 'a + Copy,\r\n{\r\n}\r\n\r\nconst B: i32 = 500;\r\nconst C: i32 = 50;\r\n\r\nfn main() {\r\n let n = read::()\r\n .chars()\r\n .map(|c| c.to_digit(10).unwrap() as i32)\r\n .collect::>();\r\n\r\n let dp = n.citer().fold(\r\n (-C..=C)\r\n .map(|t| {\r\n (0..B)\r\n .map(|i| {\r\n if i < t {\r\n vec![i32::MAX; B as usize]\r\n } else {\r\n vec![t; B as usize]\r\n }\r\n })\r\n .collect::>()\r\n })\r\n .collect::>(),\r\n |prev, d| {\r\n // eprintln!(\"{:?}\", prev);\r\n (-C..=C)\r\n .map(|t| {\r\n let d = d + t;\r\n let mut dp = (0..B)\r\n .map(|i| {\r\n let mut v = vec![i32::MAX; B as usize];\r\n\r\n (-C..=C).for_each(|c| {\r\n if i + 10 * c >= d && i + 10 * c < B + d {\r\n let j = i + 10 * c - d;\r\n v[j as usize] = prev[(c + C) as usize][i as usize][j as usize]\r\n .saturating_add(i + j);\r\n }\r\n });\r\n\r\n v\r\n })\r\n .collect::>();\r\n for i in 0..B {\r\n for j in 0..B {\r\n if i > 0 {\r\n dp[i as usize][j as usize] =\r\n min(dp[i as usize][j as usize], dp[i as usize - 1][j as usize]);\r\n }\r\n if j > 0 {\r\n dp[i as usize][j as usize] =\r\n min(dp[i as usize][j as usize], dp[i as usize][j as usize - 1]);\r\n }\r\n }\r\n }\r\n dp\r\n })\r\n .collect::>()\r\n },\r\n );\r\n let ans = dp[0 + C as usize][B as usize - 1][B as usize - 1];\r\n println!(\"{}\", ans);\r\n}\r\n", "lang": "Rust", "bug_code_uid": "4904624386a872df66a76f8a8d230f39", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "apr_id": "b279243e0cc2ca4512e7c073aeff5846", "difficulty": 2900, "tags": ["dp", "greedy", "shortest paths"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.6832774317201725, "equal_cnt": 44, "replace_cnt": 29, "delete_cnt": 7, "insert_cnt": 7, "fix_ops_cnt": 43, "bug_source_code": "const N:usize = 666; \r\n\r\n\r\nfn main() {\r\n\r\n let mut str = String::new();\r\n\tstd::io::stdin().read_line(&mut str).expect(\"\");\r\n let input :Vec<&str> = str.trim().split(\" \").collect();\r\n let n = input[0].parse::().unwrap();\r\n let modn = input[1].parse::().unwrap();\r\n let mut dp:Vec<[i64;2]> = vec![[0;2];N*N];\r\n let shift = N*N/2;\r\n dp[shift][1]=1;\r\n for _i in 1..n{\r\n let mut new_dp:Vec<[i64;2]> = vec![[0;2];N*N];\r\n let i = _i as usize;\r\n for _j in 0..(N*N-1){\r\n let j = _j as usize;\r\n if dp[j][1]==0 && dp[j][0]==0{\r\n continue;\r\n }\r\n new_dp[j-i][1] = (new_dp[j-i][1]+dp[j][1])%modn;\r\n new_dp[j+1][1] = (new_dp[j+1][1]-2*dp[j][1] + modn + modn)%modn;\r\n new_dp[j+i+2][1]=(new_dp[j+i+2][1]+dp[j][1])%modn;\r\n\r\n new_dp[j+1][0] = (new_dp[j+1][0]+dp[j][1]*(i as i64))%modn;\r\n new_dp[j][0] = (new_dp[j][0]+(modn-dp[j][1])*(i as i64+1))%modn;\r\n new_dp[j-i][0] = (new_dp[j-i][0]+dp[j][1])%modn;\r\n\r\n let t:i64 = (i as i64 +1)*dp[j][0]%modn;\r\n new_dp[j][0] = (new_dp[j][0]+t)%modn;\r\n new_dp[j+1][0] = (new_dp[j+1][0]+(modn-t)*2)%modn;\r\n new_dp[j+2][0] = (new_dp[j+2][0]+t)%modn;\r\n }\r\n //for j in shift-10..shift+11{\r\n // println!(\"{} {}\",j as i32-shift as i32,new_dp[j][0])\r\n //}\r\n for j in 0..(N*N-1){\r\n new_dp[j+1][0]=(new_dp[j+1][0]+new_dp[j][0])%modn;\r\n new_dp[j+1][1]=(new_dp[j+1][1]+new_dp[j][1])%modn;\r\n }\r\n for j in 0..(N*N-1){\r\n new_dp[j+1][0]=(new_dp[j+1][0]+new_dp[j][0])%modn;\r\n new_dp[j+1][1]=(new_dp[j+1][1]+new_dp[j][1])%modn;\r\n }\r\n dp = new_dp;\r\n }\r\n let mut ans:i64 = 0;\r\n for j in shift+1..N*N{\r\n ans = (ans + dp[j][0])%modn;\r\n }\r\n println!(\"{}\",ans);\r\n\r\n}\r\n", "lang": "Rust", "bug_code_uid": "eb6a7585f1682fddbdc3c1cc1deea260", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "apr_id": "5d4da264600799ca7014fdbcab172258", "difficulty": 2400, "tags": ["dp", "fft", "math", "combinatorics"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8987758945386064, "equal_cnt": 13, "replace_cnt": 6, "delete_cnt": 1, "insert_cnt": 6, "fix_ops_cnt": 13, "bug_source_code": "// ---------- begin ModInt ----------\r\nmod modint {\r\n\r\n #[allow(dead_code)]\r\n pub struct Mod;\r\n impl ConstantModulo for Mod {\r\n const MOD: u32 = 1_000_000_007;\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub struct StaticMod;\r\n static mut STATIC_MOD: u32 = 0;\r\n impl Modulo for StaticMod {\r\n fn modulo() -> u32 {\r\n unsafe { STATIC_MOD }\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl StaticMod {\r\n pub fn set_modulo(p: u32) {\r\n unsafe {\r\n STATIC_MOD = p;\r\n }\r\n }\r\n }\r\n\r\n use std::marker::*;\r\n use std::ops::*;\r\n\r\n pub trait Modulo {\r\n fn modulo() -> u32;\r\n }\r\n\r\n pub trait ConstantModulo {\r\n const MOD: u32;\r\n }\r\n\r\n impl Modulo for T\r\n where\r\n T: ConstantModulo,\r\n {\r\n fn modulo() -> u32 {\r\n T::MOD\r\n }\r\n }\r\n\r\n pub struct ModInt(pub u32, PhantomData);\r\n\r\n impl Clone for ModInt {\r\n fn clone(&self) -> Self {\r\n ModInt::new_unchecked(self.0)\r\n }\r\n }\r\n\r\n impl Copy for ModInt {}\r\n\r\n impl Add for ModInt {\r\n type Output = ModInt;\r\n fn add(self, rhs: Self) -> Self::Output {\r\n let mut d = self.0 + rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl AddAssign for ModInt {\r\n fn add_assign(&mut self, rhs: Self) {\r\n *self = *self + rhs;\r\n }\r\n }\r\n\r\n impl Sub for ModInt {\r\n type Output = ModInt;\r\n fn sub(self, rhs: Self) -> Self::Output {\r\n let mut d = T::modulo() + self.0 - rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl SubAssign for ModInt {\r\n fn sub_assign(&mut self, rhs: Self) {\r\n *self = *self - rhs;\r\n }\r\n }\r\n\r\n impl Mul for ModInt {\r\n type Output = ModInt;\r\n fn mul(self, rhs: Self) -> Self::Output {\r\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\r\n ModInt::new_unchecked(v as u32)\r\n }\r\n }\r\n\r\n impl MulAssign for ModInt {\r\n fn mul_assign(&mut self, rhs: Self) {\r\n *self = *self * rhs;\r\n }\r\n }\r\n\r\n impl Neg for ModInt {\r\n type Output = ModInt;\r\n fn neg(self) -> Self::Output {\r\n if self.0 == 0 {\r\n Self::zero()\r\n } else {\r\n Self::new_unchecked(T::modulo() - self.0)\r\n }\r\n }\r\n }\r\n\r\n impl std::fmt::Display for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::fmt::Debug for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::str::FromStr for ModInt {\r\n type Err = std::num::ParseIntError;\r\n fn from_str(s: &str) -> Result {\r\n let val = s.parse::()?;\r\n Ok(ModInt::new(val))\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: usize) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: u64) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: i64) -> ModInt {\r\n let m = T::modulo() as i64;\r\n ModInt::new((val % m + m) as u32)\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new_unchecked(d: u32) -> Self {\r\n ModInt(d, PhantomData)\r\n }\r\n pub fn zero() -> Self {\r\n ModInt::new_unchecked(0)\r\n }\r\n pub fn one() -> Self {\r\n ModInt::new_unchecked(1)\r\n }\r\n pub fn is_zero(&self) -> bool {\r\n self.0 == 0\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new(d: u32) -> Self {\r\n ModInt::new_unchecked(d % T::modulo())\r\n }\r\n pub fn pow(&self, mut n: u64) -> Self {\r\n let mut t = Self::one();\r\n let mut s = *self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t *= s;\r\n }\r\n s *= s;\r\n n >>= 1;\r\n }\r\n t\r\n }\r\n }\r\n}\r\n// ---------- end ModInt ----------\r\n\r\nuse modint::*;\r\ntype M = ModInt;\r\n\r\n// ---------- begin input macro ----------\r\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\r\nmacro_rules! input {\r\n (source = $s:expr, $($r:tt)*) => {\r\n let mut iter = $s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n ($($r:tt)*) => {\r\n let s = {\r\n use std::io::Read;\r\n let mut s = String::new();\r\n std::io::stdin().read_to_string(&mut s).unwrap();\r\n s\r\n };\r\n let mut iter = s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! input_inner {\r\n ($iter:expr) => {};\r\n ($iter:expr, ) => {};\r\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\r\n let $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n ($iter:expr, bytes) => {\r\n read_value!($iter, String).bytes().collect::>()\r\n };\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n// ---------- end input macro ----------\r\n\r\nuse std::collections::*;\r\nuse std::io::Write;\r\n\r\ntype Map = HashMap;\r\ntype Set = BTreeSet;\r\ntype Deque = VecDeque;\r\n\r\n// 一致してる間は転倒数一致、後ろの寄与も一致\r\n// p_0 < q_0 の問題がn=2..50 で解ければいい\r\n// 初項を決めたらあとは転倒数を保持するdpでいいんじゃ?\r\n// N^5 になってるが\r\n// いや7乗だこれ\r\n\r\nfn run() {\r\n input!(n: usize, modulo: u32);\r\n StaticMod::set_modulo(modulo);\r\n let mut ans = M::zero();\r\n let mut binom = vec![vec![M::zero(); n + 1]; n + 1];\r\n binom[0][0] = M::one();\r\n for i in 1..=n {\r\n binom[i][0] = M::one();\r\n for j in 1..=i {\r\n binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];\r\n }\r\n }\r\n let mut dp = Map::new();\r\n for rem in (1..=n).rev() {\r\n let mut next = Map::new();\r\n for i in 0..rem {\r\n for j in (i + 1)..rem {\r\n *next.entry(i as i32 - j as i32).or_insert(M::zero()) += binom[n][rem];\r\n }\r\n }\r\n let mut trans = Map::new();\r\n for i in 0..rem {\r\n for j in 0..rem {\r\n *trans.entry(i as i32 - j as i32).or_insert(M::zero()) += M::one();\r\n }\r\n }\r\n for (diff, way) in dp {\r\n for (d, w) in trans.iter() {\r\n *next.entry(diff + *d).or_insert(M::zero()) += *w * way;\r\n }\r\n }\r\n dp = next;\r\n }\r\n let mut ans = M::zero();\r\n for (diff, way) in dp {\r\n if diff > 0 {\r\n ans += way;\r\n }\r\n }\r\n let ans = ans.0 % modulo;\r\n println!(\"{}\", ans);\r\n}\r\n\r\nfn main() {\r\n run();\r\n}\r\n", "lang": "Rust", "bug_code_uid": "817705a3f5c196a95019312fb9e5d9ee", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "apr_id": "b482729fd33ebf2e17e294c3142eef68", "difficulty": 2400, "tags": ["dp", "fft", "math", "combinatorics"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7569468870911009, "equal_cnt": 12, "replace_cnt": 8, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 11, "bug_source_code": "/*\r\n date : 2021 / 4 / 7\r\n author : quickn (quickn.tech)\r\n email : quickwshell@gmail.com\r\n*/\r\n\r\nuse std::io::{self, BufWriter, Write};\r\n\r\nmod scanner {\r\n use std::{io, str};\r\n /* https://github.com/EbTech/rust-algorithms */\r\n\r\n /// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts\r\n /// **REQUIRES** Rust 1.34 or higher\r\n pub struct UnsafeScanner {\r\n reader: R,\r\n buf_str: Vec,\r\n buf_iter: str::SplitAsciiWhitespace<'static>,\r\n }\r\n\r\n impl UnsafeScanner {\r\n pub fn new(reader: R) -> Self {\r\n Self {\r\n reader,\r\n buf_str: Vec::new(),\r\n buf_iter: \"\".split_ascii_whitespace(),\r\n }\r\n }\r\n\r\n /// This function should be marked unsafe, but noone has time for that in a\r\n /// programming contest. Use at your own risk!\r\n pub fn token(&mut self) -> T {\r\n loop {\r\n if let Some(token) = self.buf_iter.next() {\r\n return token.parse().ok().expect(\"Failed parse\");\r\n }\r\n self.buf_str.clear();\r\n self.reader\r\n .read_until(b'\\n', &mut self.buf_str)\r\n .expect(\"Failed read\");\r\n self.buf_iter = unsafe {\r\n let slice = str::from_utf8_unchecked(&self.buf_str);\r\n std::mem::transmute(slice.split_ascii_whitespace())\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nuse std::cmp::{min, max};\r\n\r\nfn s2vec(s: String) -> Vec {\r\n s.chars().collect()\r\n}\r\n\r\nconst MOD: i64 = 998244353;\r\n\r\nfn main() {\r\n let (stdin, stdout) = (io::stdin(), io::stdout());\r\n let (mut scan, mut sout) = (\r\n scanner::UnsafeScanner::new(stdin.lock()),\r\n BufWriter::new(stdout.lock()),\r\n );\r\n let n: usize = scan.token();\r\n let mut dp: Vec = vec![0;n+1];\r\n let mut dp2: Vec = vec![0;2*n+1];\r\n dp[0] = 1;\r\n dp[1] = 1;\r\n dp[2] = 1;\r\n dp2[1] = 1;\r\n let mut sum = 2;\r\n for i in 2..=n {\r\n dp2[i] = 1;\r\n let mut p = 2;\r\n while p*p <= i {\r\n if i % p == 0 {\r\n dp2[i] += 1;\r\n dp2[i] %= MOD;\r\n if i / p != p {\r\n dp2[i] += 1;\r\n dp2[i] %= MOD;\r\n }\r\n }\r\n p += 1;\r\n }\r\n dp[i] = (dp2[i] + sum)%MOD;\r\n sum += dp[i];\r\n sum %= MOD;\r\n }\r\n writeln!(sout, \"{}\", dp[n]).ok();\r\n}\r\n", "lang": "Rust", "bug_code_uid": "6b0e25036688f12418897e88d4d35d3a", "src_uid": "09be46206a151c237dc9912df7e0f057", "apr_id": "534ee05046bd8d1b567a957d4d3d4958", "difficulty": 1700, "tags": ["dp", "math", "combinatorics", "number theory"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.7751364676879733, "equal_cnt": 10, "replace_cnt": 4, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 9, "bug_source_code": "/*\r\n date : 2021 / 4 / 7\r\n author : quickn (quickn.tech)\r\n email : quickwshell@gmail.com\r\n*/\r\n\r\nuse std::io::{self, BufWriter, Write};\r\n\r\nmod scanner {\r\n use std::{io, str};\r\n /* https://github.com/EbTech/rust-algorithms */\r\n\r\n /// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts\r\n /// **REQUIRES** Rust 1.34 or higher\r\n pub struct UnsafeScanner {\r\n reader: R,\r\n buf_str: Vec,\r\n buf_iter: str::SplitAsciiWhitespace<'static>,\r\n }\r\n\r\n impl UnsafeScanner {\r\n pub fn new(reader: R) -> Self {\r\n Self {\r\n reader,\r\n buf_str: Vec::new(),\r\n buf_iter: \"\".split_ascii_whitespace(),\r\n }\r\n }\r\n\r\n /// This function should be marked unsafe, but noone has time for that in a\r\n /// programming contest. Use at your own risk!\r\n pub fn token(&mut self) -> T {\r\n loop {\r\n if let Some(token) = self.buf_iter.next() {\r\n return token.parse().ok().expect(\"Failed parse\");\r\n }\r\n self.buf_str.clear();\r\n self.reader\r\n .read_until(b'\\n', &mut self.buf_str)\r\n .expect(\"Failed read\");\r\n self.buf_iter = unsafe {\r\n let slice = str::from_utf8_unchecked(&self.buf_str);\r\n std::mem::transmute(slice.split_ascii_whitespace())\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nuse std::cmp::{min, max};\r\n\r\nfn s2vec(s: String) -> Vec {\r\n s.chars().collect()\r\n}\r\n\r\nconst MOD: i64 = 998244353;\r\n\r\nfn main() {\r\n let (stdin, stdout) = (io::stdin(), io::stdout());\r\n let (mut scan, mut sout) = (\r\n scanner::UnsafeScanner::new(stdin.lock()),\r\n BufWriter::new(stdout.lock()),\r\n );\r\n let n: usize = scan.token();\r\n let mut dp: Vec = vec![0;1_000_001];\r\n let mut dp2: Vec = vec![0;1_000_001];\r\n dp[0] = 1;\r\n dp[1] = 1;\r\n dp[2] = 1;\r\n let mut sum = 2;\r\n for i in 2..=n {\r\n dp2[i] = 1;\r\n let mut p = 2;\r\n while p*p <= i {\r\n if i % p == 0 {\r\n dp2[i] += 1;\r\n dp2[i] %= MOD;\r\n if i / p != p {\r\n dp2[i] += 1;\r\n dp2[i] %= MOD;\r\n }\r\n }\r\n p += 1;\r\n }\r\n dp[i] = (dp2[i] + sum)%MOD;\r\n sum += dp[i];\r\n sum %= MOD;\r\n }\r\n writeln!(sout, \"{}\", dp[n]).ok();\r\n}\r\n", "lang": "Rust", "bug_code_uid": "3f4833719e5d17cf8c49882d457c3b27", "src_uid": "09be46206a151c237dc9912df7e0f057", "apr_id": "534ee05046bd8d1b567a957d4d3d4958", "difficulty": 1700, "tags": ["dp", "math", "combinatorics", "number theory"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9999367168712822, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_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\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 //if b >= m - a { a.wrapping_add(b).wrapping_sub(m) } else { a + b }\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 //if a < b { a.wrapping_add(m).wrapping_sub(b) } else { a - b }\n norm(a.wrapping_sub(m), 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(if self.val == 0 { 0 } else { Self::modulus() - self.val })\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\n// const MODULUS: u32 = 998_244_353;\n// //const MODULUS: u32 = 1_000_000_007;\n// #[inline(always)]\n// fn get_modulus() -> u32 { MODULUS }\n\nstatic 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": "Rust", "bug_code_uid": "201bb0b18d1ea237aa6534b6c2a016f4", "src_uid": "77443424be253352aaf2b6c89bdd4671", "apr_id": "098bde1dc52cd82cdb67098daccc5240", "difficulty": 1900, "tags": ["dp", "number theory", "math", "brute force", "two pointers"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9993323371379519, "equal_cnt": 8, "replace_cnt": 0, "delete_cnt": 3, "insert_cnt": 4, "fix_ops_cnt": 7, "bug_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": "Rust", "bug_code_uid": "3fcf1efc70155d8fdd1cbd513742d1b1", "src_uid": "77443424be253352aaf2b6c89bdd4671", "apr_id": "098bde1dc52cd82cdb67098daccc5240", "difficulty": 1900, "tags": ["dp", "number theory", "math", "brute force", "two pointers"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8740871095468544, "equal_cnt": 325, "replace_cnt": 93, "delete_cnt": 229, "insert_cnt": 3, "fix_ops_cnt": 325, "bug_source_code": "#![allow(unused_imports)]\r\nuse pio2::*;\r\nuse std::{\r\n collections::*,\r\n io::{self, prelude::*},\r\n};\r\nfn run(mut pin: I, mut out: O) {\r\n let t: u32 = 1;\r\n for _ in 0..t {\r\n case(&mut pin, &mut out);\r\n }\r\n}\r\nuse mod_int::*;\r\ntype Mint = ModInt;\r\nfn case(mut pin: I, mut out: O) {\r\n let (n, m): (usize, u32) = pin.parse();\r\n set_var_mod(m);\r\n let mut dp = vec![Mint::new(0); n + 1];\r\n dp[n] = Mint::new(1);\r\n let mut sum = Mint::new(0);\r\n for i in (1..=n).rev() {\r\n dp[i] += sum;\r\n sum += dp[i];\r\n let mut r = 0;\r\n for d in 2..=i {\r\n let q = i / d;\r\n d!(i, q);\r\n if q == i / (d + 1) {\r\n r = q;\r\n break;\r\n }\r\n dp[q] = dp[q] + dp[i];\r\n }\r\n let mut s = i;\r\n for j in 1..=r {\r\n let t = i / (j + 1);\r\n let a = s - t;\r\n s = t;\r\n d!(i, j, a);\r\n dp[j] = dp[j] + Mint::new(a as u32) * dp[i];\r\n }\r\n d!(i, sum);\r\n }\r\n let ans = dp[1];\r\n wln!(out, \"{}\", ans);\r\n}\r\nfn main() {\r\n let stdin = io::stdin();\r\n let mut pin = Scanner::new(stdin.lock());\r\n let stdout = io::stdout();\r\n let mut out = stdout.lock();\r\n run(&mut pin, &mut out);\r\n}\r\npub mod mod_int {\r\n use std::{cmp, fmt, marker::PhantomData, ops, sync::atomic};\r\n #[macro_export]\r\n macro_rules! def_mint {\r\n ($modulo:expr, $ModuloTy:ident) => {\r\n pub struct $ModuloTy;\r\n impl crate::mod_int::Modulo for $ModuloTy {\r\n fn modulo() -> u32 {\r\n $modulo\r\n }\r\n }\r\n pub type Mint = crate::mod_int::ModInt<$ModuloTy>;\r\n pub fn mint(x: u32) -> Mint {\r\n crate::mod_int::ModInt::new(x)\r\n }\r\n };\r\n }\r\n pub trait Modulo {\r\n fn modulo() -> u32;\r\n }\r\n pub struct VarMod;\r\n static VAR_MOD: atomic::AtomicU32 = atomic::AtomicU32::new(0);\r\n pub fn set_var_mod(m: u32) {\r\n VAR_MOD.store(m, atomic::Ordering::Relaxed);\r\n }\r\n impl Modulo for VarMod {\r\n fn modulo() -> u32 {\r\n VAR_MOD.load(atomic::Ordering::Relaxed)\r\n }\r\n }\r\n #[repr(transparent)]\r\n pub struct ModInt(u32, PhantomData<*const M>);\r\n impl ModInt {\r\n pub fn new(x: u32) -> Self {\r\n debug_assert!(x < M::modulo());\r\n Self(x, PhantomData)\r\n }\r\n pub fn normalize(self) -> Self {\r\n if self.0 < M::modulo() {\r\n self\r\n } else {\r\n Self::new(self.0 % M::modulo())\r\n }\r\n }\r\n pub fn get(self) -> u32 {\r\n self.0\r\n }\r\n pub fn inv(self) -> Self {\r\n assert_ne!(self, Self::new(0));\r\n self.pow(M::modulo() - 2)\r\n }\r\n pub fn half(self) -> Self {\r\n Self::new(self.0 / 2 + self.0 % 2 * ((M::modulo() + 1) / 2))\r\n }\r\n pub fn modulo() -> u32 {\r\n M::modulo()\r\n }\r\n }\r\n impl ops::Neg for ModInt {\r\n type Output = Self;\r\n fn neg(self) -> Self {\r\n Self::new(if self.0 == 0 { 0 } else { M::modulo() - self.0 })\r\n }\r\n }\r\n impl ops::Neg for &ModInt {\r\n type Output = ModInt;\r\n fn neg(self) -> Self::Output {\r\n -(*self)\r\n }\r\n }\r\n impl ops::Add for ModInt {\r\n type Output = Self;\r\n fn add(self, rhs: Self) -> Self {\r\n let s = self.0 + rhs.0;\r\n Self::new(if s < M::modulo() { s } else { s - M::modulo() })\r\n }\r\n }\r\n impl ops::Sub for ModInt {\r\n type Output = Self;\r\n fn sub(self, rhs: Self) -> Self {\r\n Self::new(if self.0 >= rhs.0 {\r\n self.0 - rhs.0\r\n } else {\r\n M::modulo() + self.0 - rhs.0\r\n })\r\n }\r\n }\r\n impl ops::Mul for ModInt {\r\n type Output = Self;\r\n fn mul(self, rhs: Self) -> Self {\r\n Self::new((self.0 as u64 * rhs.0 as u64 % M::modulo() as u64) as u32)\r\n }\r\n }\r\n impl ops::Div for ModInt {\r\n type Output = Self;\r\n fn div(self, rhs: Self) -> Self {\r\n self * rhs.inv()\r\n }\r\n }\r\n macro_rules ! op_impl { ($ ($ Op : ident $ op : ident $ OpAssign : ident $ op_assign : ident) *) => { $ (impl < M : Modulo > ops ::$ Op <& Self > for ModInt < M > { type Output = Self ; fn $ op (self , rhs : & Self) -> Self { self .$ op (* rhs) } } impl < M : Modulo > ops ::$ Op < ModInt < M >> for & ModInt < M > { type Output = ModInt < M >; fn $ op (self , rhs : ModInt < M >) -> ModInt < M > { (* self) .$ op (rhs) } } impl < M : Modulo > ops ::$ Op <& ModInt < M >> for & ModInt < M > { type Output = ModInt < M >; fn $ op (self , rhs : & ModInt < M >) -> ModInt < M > { (* self) .$ op (* rhs) } } impl < M : Modulo > ops ::$ OpAssign for ModInt < M > { fn $ op_assign (& mut self , rhs : Self) { * self = ops ::$ Op ::$ op (* self , rhs) ; } } impl < M : Modulo > ops ::$ OpAssign <& ModInt < M >> for ModInt < M > { fn $ op_assign (& mut self , rhs : & ModInt < M >) { self .$ op_assign (* rhs) ; } }) * } ; }\r\n op_impl! { Add add AddAssign add_assign Sub sub SubAssign sub_assign Mul mul MulAssign mul_assign Div div DivAssign div_assign }\r\n impl std::iter::Sum for ModInt {\r\n fn sum>(iter: I) -> Self {\r\n iter.fold(ModInt::new(0), |x, y| x + y)\r\n }\r\n }\r\n impl<'a, M: Modulo + 'a> std::iter::Sum<&'a ModInt> for ModInt {\r\n fn sum>>(iter: I) -> Self {\r\n iter.copied().sum()\r\n }\r\n }\r\n impl std::iter::Product for ModInt {\r\n fn product>(iter: I) -> Self {\r\n iter.fold(ModInt::new(1), |x, y| x * y)\r\n }\r\n }\r\n impl<'a, M: Modulo + 'a> std::iter::Product<&'a ModInt> for ModInt {\r\n fn product>>(iter: I) -> Self {\r\n iter.copied().product()\r\n }\r\n }\r\n pub trait Pow {\r\n fn pow(self, n: T) -> Self;\r\n }\r\n macro_rules ! mod_int_pow_impl { ($ ($ uty : ident $ ity : ident) *) => { $ (impl < M : Modulo > Pow <$ uty > for ModInt < M > { fn pow (mut self , mut n : $ uty) -> Self { let mut y = Self :: new (1) ; while n > 0 { if n & 1 == 1 { y *= self ; } self *= self ; n /= 2 ; } y } } impl < M : Modulo > Pow <$ ity > for ModInt < M > { fn pow (self , n : $ ity) -> Self { if n >= 0 { self . pow (n as $ uty) } else { self . inv () . pow (- n as $ uty) } } }) * } ; }\r\n mod_int_pow_impl ! (usize isize u32 i32 u64 i64);\r\n macro_rules ! mod_int_from_impl { ($ ($ T : ident) *) => { $ (impl < M : Modulo > From <$ T > for ModInt < M > { # [allow (unused_comparisons)] fn from (x : $ T) -> Self { if M :: modulo () <= $ T :: max_value () as u32 { Self :: new (x . rem_euclid (M :: modulo () as $ T) as u32) } else if x < 0 { Self :: new ((M :: modulo () as i32 + x as i32) as u32) } else { Self :: new (x as u32) } } }) * } }\r\n mod_int_from_impl ! (isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128);\r\n impl From for ModInt {\r\n fn from(x: bool) -> Self {\r\n Self::new(x as u32)\r\n }\r\n }\r\n impl Copy for ModInt {}\r\n impl Clone for ModInt {\r\n fn clone(&self) -> Self {\r\n *self\r\n }\r\n }\r\n impl Default for ModInt {\r\n fn default() -> Self {\r\n Self::new(0)\r\n }\r\n }\r\n impl cmp::PartialEq for ModInt {\r\n fn eq(&self, other: &Self) -> bool {\r\n self.0 == other.0\r\n }\r\n }\r\n impl cmp::Eq for ModInt {}\r\n impl cmp::PartialOrd for ModInt {\r\n fn partial_cmp(&self, other: &Self) -> Option {\r\n self.0.partial_cmp(&other.0)\r\n }\r\n }\r\n impl cmp::Ord for ModInt {\r\n fn cmp(&self, other: &Self) -> cmp::Ordering {\r\n self.0.cmp(&other.0)\r\n }\r\n }\r\n impl std::hash::Hash for ModInt {\r\n fn hash(&self, state: &mut H) {\r\n self.0.hash(state);\r\n }\r\n }\r\n impl fmt::Display for ModInt {\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n self.0.fmt(f)\r\n }\r\n }\r\n impl fmt::Debug for ModInt {\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n self.0.fmt(f)\r\n }\r\n }\r\n}\r\npub mod macros {\r\n #[macro_export]\r\n macro_rules ! w { ($ ($ arg : tt) *) => { write ! ($ ($ arg) *) . unwrap () ; } }\r\n #[macro_export]\r\n macro_rules ! wln { ($ dst : expr $ (, $ ($ arg : tt) *) ?) => { { writeln ! ($ dst $ (, $ ($ arg) *) ?) . unwrap () ; # [cfg (debug_assertions)] $ dst . flush () . unwrap () ; } } }\r\n #[macro_export]\r\n macro_rules! w_iter {\r\n ($dst:expr, $fmt:expr, $iter:expr, $delim:expr) => {{\r\n let mut first = true;\r\n for elem in $iter {\r\n if first {\r\n w!($dst, $fmt, elem);\r\n first = false;\r\n } else {\r\n w!($dst, concat!($delim, $fmt), elem);\r\n }\r\n }\r\n }};\r\n ($dst:expr, $fmt:expr, $iter:expr) => {\r\n w_iter!($dst, $fmt, $iter, \" \")\r\n };\r\n }\r\n #[macro_export]\r\n macro_rules ! w_iter_ln { ($ dst : expr , $ ($ t : tt) *) => { { w_iter ! ($ dst , $ ($ t) *) ; wln ! ($ dst) ; } } }\r\n #[macro_export]\r\n macro_rules ! e { ($ ($ t : tt) *) => { # [cfg (debug_assertions)] eprint ! ($ ($ t) *) } }\r\n #[macro_export]\r\n macro_rules ! eln { ($ ($ t : tt) *) => { # [cfg (debug_assertions)] eprintln ! ($ ($ t) *) } }\r\n #[macro_export]\r\n macro_rules ! __tstr { ($ h : expr $ (, $ t : expr) +) => { concat ! (__tstr ! ($ ($ t) ,+) , \", \" , __tstr ! (@)) } ; ($ h : expr) => { concat ! (__tstr ! () , \" \" , __tstr ! (@)) } ; () => { \"\\x1B[94m[{}:{}]\\x1B[0m\" } ; (@) => { \"\\x1B[1;92m{}\\x1B[0m = {:?}\" } }\r\n #[macro_export]\r\n macro_rules ! d { ($ ($ a : expr) ,*) => { eln ! (__tstr ! ($ ($ a) ,*) , file ! () , line ! () , $ (stringify ! ($ a) , $ a) ,*) } ; }\r\n}\r\npub mod pio2 {\r\n use std::{\r\n io::prelude::*,\r\n marker::PhantomData,\r\n mem::{self, MaybeUninit},\r\n str,\r\n };\r\n pub trait Input {\r\n fn bytes(&mut self) -> &[u8];\r\n #[inline]\r\n fn str(&mut self) -> &str {\r\n str::from_utf8(self.bytes()).unwrap()\r\n }\r\n #[inline]\r\n fn parse(&mut self) -> T\r\n where\r\n DefaultParser: Parser,\r\n {\r\n self.parse_with(DefaultParser)\r\n }\r\n #[inline]\r\n fn parse_with>(&mut self, mut parser: P) -> T {\r\n parser.parse(self)\r\n }\r\n #[inline]\r\n fn seq(&mut self, n: usize) -> Seq\r\n where\r\n DefaultParser: Parser,\r\n {\r\n self.seq_with(n, DefaultParser)\r\n }\r\n #[inline]\r\n fn seq_with>(&mut self, n: usize, parser: P) -> Seq {\r\n Seq {\r\n src: self,\r\n rest: n,\r\n parser,\r\n phantom: PhantomData,\r\n }\r\n }\r\n }\r\n impl Input for &mut I {\r\n #[inline]\r\n fn bytes(&mut self) -> &[u8] {\r\n (**self).bytes()\r\n }\r\n }\r\n pub struct Scanner {\r\n src: R,\r\n buf: Vec,\r\n pos: usize,\r\n len: usize,\r\n }\r\n impl Scanner {\r\n #[inline]\r\n pub fn new(src: R) -> Self {\r\n Self {\r\n src,\r\n buf: vec![0; 1 << 16],\r\n pos: 0,\r\n len: 0,\r\n }\r\n }\r\n fn read(&mut self) -> usize {\r\n if self.pos > 0 {\r\n self.buf.copy_within(self.pos..self.len, 0);\r\n self.len -= self.pos;\r\n self.pos = 0;\r\n } else if self.len >= self.buf.len() {\r\n self.buf.resize(2 * self.buf.len(), 0);\r\n }\r\n let n = self.src.read(&mut self.buf[self.len..]).unwrap();\r\n self.len += n;\r\n assert!(self.len <= self.buf.len());\r\n n\r\n }\r\n }\r\n impl Input for Scanner {\r\n fn bytes(&mut self) -> &[u8] {\r\n loop {\r\n while let Some(d) = unsafe { self.buf.get_unchecked(self.pos..self.len) }\r\n .iter()\r\n .position(u8::is_ascii_whitespace)\r\n {\r\n let p = self.pos;\r\n self.pos += d + 1;\r\n if d > 0 {\r\n return unsafe { self.buf.get_unchecked(p..p + d) };\r\n }\r\n }\r\n if self.read() == 0 {\r\n let p = self.pos;\r\n if p == self.len {\r\n panic!(\"reached EOF\");\r\n }\r\n self.pos = self.len;\r\n return unsafe { self.buf.get_unchecked(p..self.len) };\r\n }\r\n }\r\n }\r\n }\r\n pub struct Seq<'a, I: ?Sized, T, P> {\r\n src: &'a mut I,\r\n rest: usize,\r\n parser: P,\r\n phantom: PhantomData<*const T>,\r\n }\r\n impl<'a, I: Input + ?Sized, T, P: Parser> Iterator for Seq<'a, I, T, P> {\r\n type Item = T;\r\n #[inline]\r\n fn next(&mut self) -> Option {\r\n if self.rest > 0 {\r\n self.rest -= 1;\r\n Some(self.src.parse_with(&mut self.parser))\r\n } else {\r\n None\r\n }\r\n }\r\n #[inline]\r\n fn size_hint(&self) -> (usize, Option) {\r\n (self.rest, Some(self.rest))\r\n }\r\n }\r\n impl<'a, I: Input + ?Sized, T, P: Parser> ExactSizeIterator for Seq<'a, I, T, P> {}\r\n pub trait Parser {\r\n fn parse(&mut self, src: &mut I) -> T;\r\n }\r\n impl> Parser for &mut P {\r\n #[inline]\r\n fn parse(&mut self, src: &mut I) -> T {\r\n (*self).parse(src)\r\n }\r\n }\r\n #[derive(Clone, Copy, Debug)]\r\n pub struct DefaultParser;\r\n macro_rules ! impls { ($ m : ident , $ ($ ty : ty) ,*) => { $ ($ m ! ($ ty) ;) * } ; }\r\n macro_rules! int {\r\n ($ty:ty) => {\r\n impl Parser<$ty> for DefaultParser {\r\n #[inline]\r\n fn parse(&mut self, src: &mut I) -> $ty {\r\n let f = |s: &[u8]| s.iter().fold(0, |x, b| 10 * x + (b & 0xf) as $ty);\r\n let s = src.bytes();\r\n if let Some((&b'-', t)) = s.split_first() {\r\n -f(t)\r\n } else {\r\n f(s)\r\n }\r\n }\r\n }\r\n };\r\n }\r\n impls!(int, isize, i8, i16, i32, i64, i128);\r\n macro_rules! uint {\r\n ($ty:ty) => {\r\n impl Parser<$ty> for DefaultParser {\r\n #[inline]\r\n fn parse(&mut self, src: &mut I) -> $ty {\r\n src.bytes().iter().fold(0, |x, b| 10 * x + (b & 0xf) as $ty)\r\n }\r\n }\r\n };\r\n }\r\n impls!(uint, usize, u8, u16, u32, u64, u128);\r\n macro_rules! from_bytes {\r\n ($ty:ty) => {\r\n impl Parser<$ty> for DefaultParser {\r\n #[inline]\r\n fn parse(&mut self, src: &mut I) -> $ty {\r\n src.bytes().into()\r\n }\r\n }\r\n };\r\n }\r\n impls!(from_bytes, Vec, Box<[u8]>);\r\n macro_rules! from_str {\r\n ($ty:ty) => {\r\n impl Parser<$ty> for DefaultParser {\r\n #[inline]\r\n fn parse(&mut self, src: &mut I) -> $ty {\r\n src.str().parse::<$ty>().expect(\"failed to parse\")\r\n }\r\n }\r\n };\r\n }\r\n impls!(from_str, String, char, f32, f64);\r\n macro_rules ! tuple { ($ ($ T : ident) ,+) => { impl <$ ($ T) ,+> Parser < ($ ($ T ,) +) > for DefaultParser where $ (DefaultParser : Parser <$ T >) ,+ { # [inline] fn parse < I : Input + ? Sized > (& mut self , src : & mut I) -> ($ ($ T ,) +) { ($ (< Self as Parser <$ T >>:: parse (self , src) ,) +) } } } ; }\r\n tuple!(A);\r\n tuple!(A, B);\r\n tuple!(A, B, C);\r\n tuple!(A, B, C, D);\r\n tuple!(A, B, C, D, E);\r\n tuple!(A, B, C, D, E, F);\r\n tuple!(A, B, C, D, E, F, G);\r\n tuple!(A, B, C, D, E, F, G, H);\r\n macro_rules ! array { ($ ($ N : literal) *) => { $ (impl < T > Parser < [T ; $ N] > for DefaultParser where DefaultParser : Parser < T > { fn parse < I : Input + ? Sized > (& mut self , src : & mut I) -> [T ; $ N] { unsafe { let mut arr : [MaybeUninit < T >; $ N] = MaybeUninit :: uninit () . assume_init () ; for elem in & mut arr { * elem = MaybeUninit :: new (src . parse ()) ; } mem :: transmute_copy (& arr) } } }) * } }\r\n array ! (1 2 3 4 5 6 7 8);\r\n}\r\n", "lang": "Rust", "bug_code_uid": "0b5aedd50e6489c38e79febee90781cc", "src_uid": "77443424be253352aaf2b6c89bdd4671", "apr_id": "bdc7d40e9057c312ca7503efe7ec0f52", "difficulty": 1900, "tags": ["dp", "number theory", "math", "brute force", "two pointers"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.998985740707595, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 1, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "#![allow(unused_imports)]\nuse pio2::*;\nuse procon_temp::mod_int::ModInt;\nuse std::{\n collections::*,\n io::{self, prelude::*},\n};\nfn run(mut pin: I, mut out: O) {\n let t: u32 = 1;\n for _ in 0..t {\n case(&mut pin, &mut out);\n }\n}\nfn case(mut pin: I, mut out: O) {\n use mod_int::*;\n type Mint = ModInt;\n let (n, m): (usize, u32) = pin.parse();\n set_var_mod(m);\n let mut div = vec![Mint::new(0); n + 1];\n let mut dp = vec![Mint::new(0); n + 1];\n dp[1] = Mint::new(1);\n let mut sum = Mint::new(0);\n for i in 1..=n {\n div[i] = div[i] + div[i - 1];\n dp[i] = dp[i] + sum + div[i];\n sum += dp[i];\n for z in 2.. {\n if i * z > n {\n break;\n }\n div[i * z] += dp[i];\n if let Some(d) = div.get_mut((i + 1) * z) {\n *d -= dp[i];\n }\n }\n }\n let ans = dp[n];\n wln!(out, \"{}\", ans);\n}\nfn main() {\n let stdin = io::stdin();\n let mut pin = Scanner::new(stdin.lock());\n let stdout = io::stdout();\n let mut out = stdout.lock();\n run(&mut pin, &mut out);\n}\npub mod mod_int {\n use std::{cmp, fmt, marker::PhantomData, ops, sync::atomic};\n #[macro_export]\n macro_rules! def_mint {\n ($modulo:expr, $ModuloTy:ident) => {\n pub struct $ModuloTy;\n impl crate::mod_int::Modulo for $ModuloTy {\n fn modulo() -> u32 {\n $modulo\n }\n }\n pub type Mint = crate::mod_int::ModInt<$ModuloTy>;\n pub fn mint(x: u32) -> Mint {\n crate::mod_int::ModInt::new(x)\n }\n };\n }\n pub trait Modulo {\n fn modulo() -> u32;\n }\n pub struct VarMod;\n static VAR_MOD: atomic::AtomicU32 = atomic::AtomicU32::new(0);\n pub fn set_var_mod(m: u32) {\n VAR_MOD.store(m, atomic::Ordering::Relaxed);\n }\n impl Modulo for VarMod {\n fn modulo() -> u32 {\n VAR_MOD.load(atomic::Ordering::Relaxed)\n }\n }\n #[repr(transparent)]\n pub struct ModInt(u32, PhantomData<*const M>);\n impl ModInt {\n pub fn new(x: u32) -> Self {\n debug_assert!(x < M::modulo());\n Self(x, PhantomData)\n }\n pub fn normalize(self) -> Self {\n if self.0 < M::modulo() {\n self\n } else {\n Self::new(self.0 % M::modulo())\n }\n }\n pub fn get(self) -> u32 {\n self.0\n }\n pub fn inv(self) -> Self {\n assert_ne!(self, Self::new(0));\n self.pow(M::modulo() - 2)\n }\n pub fn half(self) -> Self {\n Self::new(self.0 / 2 + self.0 % 2 * ((M::modulo() + 1) / 2))\n }\n pub fn modulo() -> u32 {\n M::modulo()\n }\n }\n impl ops::Neg for ModInt {\n type Output = Self;\n fn neg(self) -> Self {\n Self::new(if self.0 == 0 { 0 } else { M::modulo() - self.0 })\n }\n }\n impl ops::Neg for &ModInt {\n type Output = ModInt;\n fn neg(self) -> Self::Output {\n -(*self)\n }\n }\n impl ops::Add for ModInt {\n type Output = Self;\n fn add(self, rhs: Self) -> Self {\n let s = self.0 + rhs.0;\n Self::new(if s < M::modulo() { s } else { s - M::modulo() })\n }\n }\n impl ops::Sub for ModInt {\n type Output = Self;\n fn sub(self, rhs: Self) -> Self {\n Self::new(if self.0 >= rhs.0 {\n self.0 - rhs.0\n } else {\n M::modulo() + self.0 - rhs.0\n })\n }\n }\n impl ops::Mul for ModInt {\n type Output = Self;\n fn mul(self, rhs: Self) -> Self {\n Self::new((self.0 as u64 * rhs.0 as u64 % M::modulo() as u64) as u32)\n }\n }\n impl ops::Div for ModInt {\n type Output = Self;\n fn div(self, rhs: Self) -> Self {\n self * rhs.inv()\n }\n }\n macro_rules ! op_impl { ($ ($ Op : ident $ op : ident $ OpAssign : ident $ op_assign : ident) *) => { $ (impl < M : Modulo > ops ::$ Op <& Self > for ModInt < M > { type Output = Self ; fn $ op (self , rhs : & Self) -> Self { self .$ op (* rhs) } } impl < M : Modulo > ops ::$ Op < ModInt < M >> for & ModInt < M > { type Output = ModInt < M >; fn $ op (self , rhs : ModInt < M >) -> ModInt < M > { (* self) .$ op (rhs) } } impl < M : Modulo > ops ::$ Op <& ModInt < M >> for & ModInt < M > { type Output = ModInt < M >; fn $ op (self , rhs : & ModInt < M >) -> ModInt < M > { (* self) .$ op (* rhs) } } impl < M : Modulo > ops ::$ OpAssign for ModInt < M > { fn $ op_assign (& mut self , rhs : Self) { * self = ops ::$ Op ::$ op (* self , rhs) ; } } impl < M : Modulo > ops ::$ OpAssign <& ModInt < M >> for ModInt < M > { fn $ op_assign (& mut self , rhs : & ModInt < M >) { self .$ op_assign (* rhs) ; } }) * } ; }\n op_impl! { Add add AddAssign add_assign Sub sub SubAssign sub_assign Mul mul MulAssign mul_assign Div div DivAssign div_assign }\n impl std::iter::Sum for ModInt {\n fn sum>(iter: I) -> Self {\n iter.fold(ModInt::new(0), |x, y| x + y)\n }\n }\n impl<'a, M: Modulo + 'a> std::iter::Sum<&'a ModInt> for ModInt {\n fn sum>>(iter: I) -> Self {\n iter.copied().sum()\n }\n }\n impl std::iter::Product for ModInt {\n fn product>(iter: I) -> Self {\n iter.fold(ModInt::new(1), |x, y| x * y)\n }\n }\n impl<'a, M: Modulo + 'a> std::iter::Product<&'a ModInt> for ModInt {\n fn product>>(iter: I) -> Self {\n iter.copied().product()\n }\n }\n pub trait Pow {\n fn pow(self, n: T) -> Self;\n }\n macro_rules ! mod_int_pow_impl { ($ ($ uty : ident $ ity : ident) *) => { $ (impl < M : Modulo > Pow <$ uty > for ModInt < M > { fn pow (mut self , mut n : $ uty) -> Self { let mut y = Self :: new (1) ; while n > 0 { if n & 1 == 1 { y *= self ; } self *= self ; n /= 2 ; } y } } impl < M : Modulo > Pow <$ ity > for ModInt < M > { fn pow (self , n : $ ity) -> Self { if n >= 0 { self . pow (n as $ uty) } else { self . inv () . pow (- n as $ uty) } } }) * } ; }\n mod_int_pow_impl ! (usize isize u32 i32 u64 i64);\n macro_rules ! mod_int_from_impl { ($ ($ T : ident) *) => { $ (impl < M : Modulo > From <$ T > for ModInt < M > { # [allow (unused_comparisons)] fn from (x : $ T) -> Self { if M :: modulo () <= $ T :: max_value () as u32 { Self :: new (x . rem_euclid (M :: modulo () as $ T) as u32) } else if x < 0 { Self :: new ((M :: modulo () as i32 + x as i32) as u32) } else { Self :: new (x as u32) } } }) * } }\n mod_int_from_impl ! (isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128);\n impl From for ModInt {\n fn from(x: bool) -> Self {\n Self::new(x as u32)\n }\n }\n impl Copy for ModInt {}\n impl Clone for ModInt {\n fn clone(&self) -> Self {\n *self\n }\n }\n impl Default for ModInt {\n fn default() -> Self {\n Self::new(0)\n }\n }\n impl cmp::PartialEq for ModInt {\n fn eq(&self, other: &Self) -> bool {\n self.0 == other.0\n }\n }\n impl cmp::Eq for ModInt {}\n impl cmp::PartialOrd for ModInt {\n fn partial_cmp(&self, other: &Self) -> Option {\n self.0.partial_cmp(&other.0)\n }\n }\n impl cmp::Ord for ModInt {\n fn cmp(&self, other: &Self) -> cmp::Ordering {\n self.0.cmp(&other.0)\n }\n }\n impl std::hash::Hash for ModInt {\n fn hash(&self, state: &mut H) {\n self.0.hash(state);\n }\n }\n impl fmt::Display for ModInt {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n self.0.fmt(f)\n }\n }\n impl fmt::Debug for ModInt {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n self.0.fmt(f)\n }\n }\n}\npub mod macros {\n #[macro_export]\n macro_rules ! w { ($ ($ arg : tt) *) => { write ! ($ ($ arg) *) . unwrap () ; } }\n #[macro_export]\n macro_rules ! wln { ($ dst : expr $ (, $ ($ arg : tt) *) ?) => { { writeln ! ($ dst $ (, $ ($ arg) *) ?) . unwrap () ; # [cfg (debug_assertions)] $ dst . flush () . unwrap () ; } } }\n #[macro_export]\n macro_rules! w_iter {\n ($dst:expr, $fmt:expr, $iter:expr, $delim:expr) => {{\n let mut first = true;\n for elem in $iter {\n if first {\n w!($dst, $fmt, elem);\n first = false;\n } else {\n w!($dst, concat!($delim, $fmt), elem);\n }\n }\n }};\n ($dst:expr, $fmt:expr, $iter:expr) => {\n w_iter!($dst, $fmt, $iter, \" \")\n };\n }\n #[macro_export]\n macro_rules ! w_iter_ln { ($ dst : expr , $ ($ t : tt) *) => { { w_iter ! ($ dst , $ ($ t) *) ; wln ! ($ dst) ; } } }\n #[macro_export]\n macro_rules ! e { ($ ($ t : tt) *) => { # [cfg (debug_assertions)] eprint ! ($ ($ t) *) } }\n #[macro_export]\n macro_rules ! eln { ($ ($ t : tt) *) => { # [cfg (debug_assertions)] eprintln ! ($ ($ t) *) } }\n #[macro_export]\n macro_rules ! __tstr { ($ h : expr $ (, $ t : expr) +) => { concat ! (__tstr ! ($ ($ t) ,+) , \", \" , __tstr ! (@)) } ; ($ h : expr) => { concat ! (__tstr ! () , \" \" , __tstr ! (@)) } ; () => { \"\\x1B[94m[{}:{}]\\x1B[0m\" } ; (@) => { \"\\x1B[1;92m{}\\x1B[0m = {:?}\" } }\n #[macro_export]\n macro_rules ! d { ($ ($ a : expr) ,*) => { eln ! (__tstr ! ($ ($ a) ,*) , file ! () , line ! () , $ (stringify ! ($ a) , $ a) ,*) } ; }\n}\npub mod pio2 {\n use std::{\n io::prelude::*,\n marker::PhantomData,\n mem::{self, MaybeUninit},\n str,\n };\n pub trait Input {\n fn bytes(&mut self) -> &[u8];\n #[inline]\n fn str(&mut self) -> &str {\n str::from_utf8(self.bytes()).unwrap()\n }\n #[inline]\n fn parse(&mut self) -> T\n where\n DefaultParser: Parser,\n {\n self.parse_with(DefaultParser)\n }\n #[inline]\n fn parse_with>(&mut self, mut parser: P) -> T {\n parser.parse(self)\n }\n #[inline]\n fn seq(&mut self, n: usize) -> Seq\n where\n DefaultParser: Parser,\n {\n self.seq_with(n, DefaultParser)\n }\n #[inline]\n fn seq_with>(&mut self, n: usize, parser: P) -> Seq {\n Seq {\n src: self,\n rest: n,\n parser,\n phantom: PhantomData,\n }\n }\n }\n impl Input for &mut I {\n #[inline]\n fn bytes(&mut self) -> &[u8] {\n (**self).bytes()\n }\n }\n pub struct Scanner {\n src: R,\n buf: Vec,\n pos: usize,\n len: usize,\n }\n impl Scanner {\n #[inline]\n pub fn new(src: R) -> Self {\n Self {\n src,\n buf: vec![0; 1 << 16],\n pos: 0,\n len: 0,\n }\n }\n fn read(&mut self) -> usize {\n if self.pos > 0 {\n self.buf.copy_within(self.pos..self.len, 0);\n self.len -= self.pos;\n self.pos = 0;\n } else if self.len >= self.buf.len() {\n self.buf.resize(2 * self.buf.len(), 0);\n }\n let n = self.src.read(&mut self.buf[self.len..]).unwrap();\n self.len += n;\n assert!(self.len <= self.buf.len());\n n\n }\n }\n impl Input for Scanner {\n fn bytes(&mut self) -> &[u8] {\n loop {\n while let Some(d) = unsafe { self.buf.get_unchecked(self.pos..self.len) }\n .iter()\n .position(u8::is_ascii_whitespace)\n {\n let p = self.pos;\n self.pos += d + 1;\n if d > 0 {\n return unsafe { self.buf.get_unchecked(p..p + d) };\n }\n }\n if self.read() == 0 {\n let p = self.pos;\n if p == self.len {\n panic!(\"reached EOF\");\n }\n self.pos = self.len;\n return unsafe { self.buf.get_unchecked(p..self.len) };\n }\n }\n }\n }\n pub struct Seq<'a, I: ?Sized, T, P> {\n src: &'a mut I,\n rest: usize,\n parser: P,\n phantom: PhantomData<*const T>,\n }\n impl<'a, I: Input + ?Sized, T, P: Parser> Iterator for Seq<'a, I, T, P> {\n type Item = T;\n #[inline]\n fn next(&mut self) -> Option {\n if self.rest > 0 {\n self.rest -= 1;\n Some(self.src.parse_with(&mut self.parser))\n } else {\n None\n }\n }\n #[inline]\n fn size_hint(&self) -> (usize, Option) {\n (self.rest, Some(self.rest))\n }\n }\n impl<'a, I: Input + ?Sized, T, P: Parser> ExactSizeIterator for Seq<'a, I, T, P> {}\n pub trait Parser {\n fn parse(&mut self, src: &mut I) -> T;\n }\n impl> Parser for &mut P {\n #[inline]\n fn parse(&mut self, src: &mut I) -> T {\n (*self).parse(src)\n }\n }\n #[derive(Clone, Copy, Debug)]\n pub struct DefaultParser;\n macro_rules ! impls { ($ m : ident , $ ($ ty : ty) ,*) => { $ ($ m ! ($ ty) ;) * } ; }\n macro_rules! int {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n let f = |s: &[u8]| s.iter().fold(0, |x, b| 10 * x + (b & 0xf) as $ty);\n let s = src.bytes();\n if let Some((&b'-', t)) = s.split_first() {\n -f(t)\n } else {\n f(s)\n }\n }\n }\n };\n }\n impls!(int, isize, i8, i16, i32, i64, i128);\n macro_rules! uint {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n src.bytes().iter().fold(0, |x, b| 10 * x + (b & 0xf) as $ty)\n }\n }\n };\n }\n impls!(uint, usize, u8, u16, u32, u64, u128);\n macro_rules! from_bytes {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n src.bytes().into()\n }\n }\n };\n }\n impls!(from_bytes, Vec, Box<[u8]>);\n macro_rules! from_str {\n ($ty:ty) => {\n impl Parser<$ty> for DefaultParser {\n #[inline]\n fn parse(&mut self, src: &mut I) -> $ty {\n src.str().parse::<$ty>().expect(\"failed to parse\")\n }\n }\n };\n }\n impls!(from_str, String, char, f32, f64);\n macro_rules ! tuple { ($ ($ T : ident) ,+) => { impl <$ ($ T) ,+> Parser < ($ ($ T ,) +) > for DefaultParser where $ (DefaultParser : Parser <$ T >) ,+ { # [inline] fn parse < I : Input + ? Sized > (& mut self , src : & mut I) -> ($ ($ T ,) +) { ($ (< Self as Parser <$ T >>:: parse (self , src) ,) +) } } } ; }\n tuple!(A);\n tuple!(A, B);\n tuple!(A, B, C);\n tuple!(A, B, C, D);\n tuple!(A, B, C, D, E);\n tuple!(A, B, C, D, E, F);\n tuple!(A, B, C, D, E, F, G);\n tuple!(A, B, C, D, E, F, G, H);\n macro_rules ! array { ($ ($ N : literal) *) => { $ (impl < T > Parser < [T ; $ N] > for DefaultParser where DefaultParser : Parser < T > { fn parse < I : Input + ? Sized > (& mut self , src : & mut I) -> [T ; $ N] { unsafe { let mut arr : [MaybeUninit < T >; $ N] = MaybeUninit :: uninit () . assume_init () ; for elem in & mut arr { * elem = MaybeUninit :: new (src . parse ()) ; } mem :: transmute_copy (& arr) } } }) * } }\n array ! (1 2 3 4 5 6 7 8);\n}\n", "lang": "Rust", "bug_code_uid": "c0da71eea97a0304c1a70e1a23315871", "src_uid": "77443424be253352aaf2b6c89bdd4671", "apr_id": "bdc7d40e9057c312ca7503efe7ec0f52", "difficulty": 1900, "tags": ["dp", "number theory", "math", "brute force", "two pointers"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.6526500219010074, "equal_cnt": 12, "replace_cnt": 8, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 11, "bug_source_code": "fn main() {\r\n let (r, w) = (std::io::stdin(), std::io::stdout());\r\n let mut sc = IO::new(r.lock(), w.lock());\r\n\r\n let n: usize = sc.read();\r\n let m: i64 = sc.read();\r\n let mut dp = vec![0; n + 1];\r\n let mut suffix_sum = 0;\r\n dp[n] = 1;\r\n\r\n for cur in (2..=n).rev() {\r\n dp[cur] = mod_add(dp[cur], suffix_sum, m);\r\n suffix_sum = mod_add(suffix_sum, dp[cur], m);\r\n\r\n let mut min_next = n;\r\n for z in 2.. {\r\n if z * z > cur {\r\n break;\r\n }\r\n let next = cur / z;\r\n dp[next] = mod_add(dp[next], dp[cur], m);\r\n min_next = min_next.min(next);\r\n }\r\n\r\n for next in 1..min_next {\r\n let z = cur / next;\r\n let z_next = cur / (next + 1);\r\n let count = z - z_next;\r\n let add = ((count as i64) * dp[cur]) % m;\r\n dp[next] = mod_add(dp[next], add, m);\r\n if z_next == 1 {\r\n break;\r\n }\r\n }\r\n }\r\n dp[1] = mod_add(dp[1], suffix_sum, m);\r\n\r\n // eprintln!(\"{:?}\", dp);\r\n println!(\"{}\", dp[1]);\r\n}\r\n\r\nfn mod_add(x: i64, y: i64, m: i64) -> i64 {\r\n let r = x + y;\r\n if r >= m {\r\n r - m\r\n } else {\r\n r\r\n }\r\n}\r\n\r\nfn mod_sub(x: i64, y: i64, m: i64) -> i64 {\r\n let r = x + m - y;\r\n if r >= m {\r\n r - m\r\n } else {\r\n r\r\n }\r\n}\r\n\r\npub struct IO(R, std::io::BufWriter);\r\n\r\nimpl IO {\r\n pub fn new(r: R, w: W) -> IO {\r\n IO(r, std::io::BufWriter::new(w))\r\n }\r\n pub fn write(&mut self, s: S) {\r\n use std::io::Write;\r\n self.1.write_all(s.to_string().as_bytes()).unwrap();\r\n }\r\n pub fn read(&mut self) -> T {\r\n use std::io::Read;\r\n let buf = self\r\n .0\r\n .by_ref()\r\n .bytes()\r\n .map(|b| b.unwrap())\r\n .skip_while(|&b| b == b' ' || b == b'\\n' || b == b'\\r' || b == b'\\t')\r\n .take_while(|&b| b != b' ' && b != b'\\n' && b != b'\\r' && b != b'\\t')\r\n .collect::>();\r\n unsafe { std::str::from_utf8_unchecked(&buf) }\r\n .parse()\r\n .ok()\r\n .expect(\"Parse error.\")\r\n }\r\n pub fn usize0(&mut self) -> usize {\r\n self.read::() - 1\r\n }\r\n pub fn vec(&mut self, n: usize) -> Vec {\r\n (0..n).map(|_| self.read()).collect()\r\n }\r\n pub fn chars(&mut self) -> Vec {\r\n self.read::().chars().collect()\r\n }\r\n}\r\n", "lang": "Rust", "bug_code_uid": "0aa6de4cac0b4b97a0884bb85b43cff9", "src_uid": "77443424be253352aaf2b6c89bdd4671", "apr_id": "ebb562d995ae5320604fd3633e70fb81", "difficulty": 1900, "tags": ["dp", "number theory", "math", "brute force", "two pointers"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.6793148880105402, "equal_cnt": 14, "replace_cnt": 8, "delete_cnt": 2, "insert_cnt": 3, "fix_ops_cnt": 13, "bug_source_code": "#[allow(unused_imports)]\nuse std::io::{self, BufRead, Write, BufWriter};\n\nmacro_rules! parse_line {\n ($($t: ty),+) => ({\n let mut line = String::new();\n std::io::stdin().read_line(&mut line).unwrap();\n let mut iter = line.split_whitespace();\n ($(iter.next().unwrap().parse::<$t>().unwrap()),+)\n })\n}\n\n#[allow(dead_code)]\nfn count_number(n : usize, m : usize) -> usize{\n if n == 2 {\n return 2;\n }\n let mut save = vec![1; n + 1];\n for i in 2..n{\n save[i] = (save[i] + i - i / 2) % m;\n let x = save[i];\n for j in (i + 1) .. (n + 1){\n let start = if (j / (i + 1)) > 1 { j / (i + 1) } else { 1 };\n let way = (j / i) + 1 - start;\n save[j] = (save[j] + way * x) % m;\n }\n }\n return (save[n] + n - (n / 2)) % m;\n}\n\n#[allow(dead_code)]\nfn count_number2(n : usize, m : i32) -> i32{\n fn div_way(x : usize, k : usize) -> i32{\n let (a, b) = ((x / k) as i32, (x / (k + 1)) as i32);\n if b > 1 { a - b } else { a - 1 }\n }\n\n fn diff(x : usize, k : usize) -> i32{\n div_way(x, k) - div_way(x - 1, k)\n }\n\n if n == 2 {\n return 2;\n }\n let mut save = vec![0; n + 1];\n save[1] = 1;\n save[2] = -2;\n for i in 2..n + 1{\n if i % 2 == 0 {\n save[i] = (save[i] + 2 * save[i - 1] + save[ i / 2 ] + diff(i, 1)) % m;\n }\n else {\n save[i] = (save[i] + 2 * save[i - 1] + diff(i, 1)) % m;\n }\n\n let x = save[i];\n for j in (2 * i + 1) .. (n + 1){\n save[j] = (save[j] + diff(j, i) * x) % m;\n }\n }\n return save[n];\n}\n\n#[allow(dead_code)]\npub fn main(){\n let stdout = io::stdout();\n let lock_out = stdout.lock();\n let mut buff = BufWriter::new(lock_out);\n\n let (n, m) = parse_line!(usize, i32);\n buff.write_fmt(format_args!(\"{}\\n\", count_number2(n, m))).unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "9f8fc9f1e4b1f47261605fa23f864208", "src_uid": "77443424be253352aaf2b6c89bdd4671", "apr_id": "c6bccfe87e9399c864160ee396077f4f", "difficulty": 1900, "tags": ["dp", "number theory", "math", "brute force", "two pointers"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.931744653988795, "equal_cnt": 10, "replace_cnt": 3, "delete_cnt": 4, "insert_cnt": 3, "fix_ops_cnt": 10, "bug_source_code": "use std::cmp::max;\r\nuse std::io::{self, prelude::*, BufWriter};\r\nuse std::str::FromStr;\r\n\r\ntype M = DynamicModInt;\r\n\r\nfn solve(scan: &mut Scanner, out: &mut W) {\r\n let n: usize = scan.next();\r\n M::set_modulus(scan.next());\r\n\r\n let mut dp = vec![M::zero(); n + 1];\r\n dp[1] = M::one();\r\n let mut sum = M::one();\r\n for i in 2..=n {\r\n let root = (i as f64).sqrt() as usize;\r\n for j in 2..=root {\r\n let delta = dp[i / j];\r\n dp[i] += delta;\r\n }\r\n // i = 2 root = 1\r\n // high = 2\r\n // low = 2\r\n for k in 1..=root {\r\n let high = i / k;\r\n let low = max(2, max(root + 1, i / (k + 1) + 1));\r\n if low <= high {\r\n assert_eq!(i / low, k);\r\n assert_eq!(i / high, k);\r\n let delta = dp[k] * M::from(high - low + 1);\r\n dp[i] += delta;\r\n }\r\n }\r\n\r\n dp[i] += sum;\r\n sum += dp[i];\r\n }\r\n writeln!(out, \"{}\", dp[n]).ok();\r\n}\r\n\r\nfn main() {\r\n let (stdin, stdout) = (io::stdin(), io::stdout());\r\n let mut scan = Scanner::new(stdin.lock());\r\n let mut out = BufWriter::new(stdout.lock());\r\n\r\n let tests = 1; // scan.next::();\r\n for _ in 0..tests {\r\n solve(&mut scan, &mut out);\r\n }\r\n}\r\n\r\n// {{{ Scanner\r\npub struct Scanner {\r\n reader: R,\r\n buffer: Vec,\r\n}\r\n\r\nimpl Scanner {\r\n pub fn new(reader: R) -> Self {\r\n Self {\r\n reader,\r\n buffer: vec![],\r\n }\r\n }\r\n\r\n pub fn next(&mut self) -> T {\r\n loop {\r\n if let Some(token) = self.buffer.pop() {\r\n return token.parse().ok().unwrap();\r\n }\r\n let mut line = String::new();\r\n self.reader.read_line(&mut line).unwrap();\r\n self.buffer = line\r\n .split_ascii_whitespace()\r\n .rev()\r\n .map(String::from)\r\n .collect();\r\n }\r\n }\r\n\r\n pub fn next_vec(&mut self, n: usize) -> Vec {\r\n (0..n).map(|_| self.next()).collect()\r\n }\r\n}\r\n// }}}\r\n// {{{ DynamicModInt\r\nuse std::fmt;\r\nuse std::iter::{Product, Sum};\r\nuse std::ops::*;\r\n\r\n#[derive(Clone, Copy, Eq, PartialEq, Debug, Hash)]\r\npub struct DynamicModInt(pub i32);\r\n\r\nimpl Default for DynamicModInt {\r\n fn default() -> Self {\r\n DynamicModInt(0)\r\n }\r\n}\r\n\r\nimpl fmt::Display for DynamicModInt {\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n}\r\n\r\nimpl DynamicModInt {\r\n pub fn set_modulus(modulus: i32) {\r\n *Self::modulus_ref() = modulus;\r\n }\r\n\r\n pub fn modulus() -> i32 {\r\n *Self::modulus_ref()\r\n }\r\n\r\n fn modulus_ref() -> &'static mut i32 {\r\n static mut MODULES: i32 = 0;\r\n return unsafe { &mut MODULES };\r\n }\r\n\r\n pub fn raw(val: i32) -> Self {\r\n DynamicModInt(val)\r\n }\r\n\r\n #[inline]\r\n fn canon(val: i32) -> Self {\r\n DynamicModInt(if val < 0 { val + Self::modulus() } else { val })\r\n }\r\n\r\n #[inline]\r\n pub fn zero() -> Self {\r\n DynamicModInt(0)\r\n }\r\n\r\n #[inline]\r\n pub fn one() -> Self {\r\n DynamicModInt(1)\r\n }\r\n\r\n #[inline]\r\n pub fn two() -> Self {\r\n DynamicModInt(2)\r\n }\r\n\r\n pub fn pow(self, n: u64) -> Self {\r\n let mut n = n;\r\n let mut res = Self::one();\r\n let mut a = self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n res = res * a;\r\n }\r\n a = a * a;\r\n n >>= 1;\r\n }\r\n\r\n res\r\n }\r\n\r\n pub fn inv(self) -> Self {\r\n self.pow(Self::modulus() as u64 - 2)\r\n }\r\n}\r\n\r\nmacro_rules! from_bigger_int {\r\n ($($int:ident)*) => {$(\r\n impl From<$int> for DynamicModInt {\r\n fn from(val: $int) -> Self {\r\n Self::canon((val % Self::modulus() as $int) as i32)\r\n }\r\n }\r\n )*};\r\n}\r\nfrom_bigger_int!(u32 usize i64 u64 i128 u128);\r\n\r\nmacro_rules! from_smaller_int {\r\n ($($int: ident)*) => {$(\r\n impl From<$int> for DynamicModInt {\r\n fn from(val: $int) -> Self {\r\n Self::canon(val as i32 % Self::modulus())\r\n }\r\n }\r\n )*}\r\n}\r\nfrom_smaller_int!(i32 i16 u16 i8 u8);\r\n\r\nimpl Neg for DynamicModInt {\r\n type Output = Self;\r\n fn neg(self) -> Self {\r\n DynamicModInt(if self.0 == 0 {\r\n 0\r\n } else {\r\n Self::modulus() - self.0\r\n })\r\n }\r\n}\r\n\r\nimpl Add for DynamicModInt {\r\n type Output = Self;\r\n fn add(self, other: Self) -> Self {\r\n let s = self.0 + other.0;\r\n let m = Self::modulus();\r\n DynamicModInt(if s >= m { s - m } else { s })\r\n }\r\n}\r\n\r\nimpl Sub for DynamicModInt {\r\n type Output = Self;\r\n fn sub(self, other: Self) -> Self {\r\n Self::canon(self.0 - other.0)\r\n }\r\n}\r\n\r\nimpl Mul for DynamicModInt {\r\n type Output = Self;\r\n fn mul(self, other: Self) -> Self {\r\n let mul: u64 = (self.0 as u64 * other.0 as u64) % Self::modulus() as u64;\r\n DynamicModInt(mul as i32)\r\n }\r\n}\r\n\r\nimpl Div for DynamicModInt {\r\n type Output = Self;\r\n fn div(self, other: Self) -> Self {\r\n self * other.inv()\r\n }\r\n}\r\n\r\nimpl AddAssign for DynamicModInt {\r\n fn add_assign(&mut self, other: Self) {\r\n *self = *self + other;\r\n }\r\n}\r\n\r\nimpl SubAssign for DynamicModInt {\r\n fn sub_assign(&mut self, other: Self) {\r\n *self = *self - other;\r\n }\r\n}\r\n\r\nimpl MulAssign for DynamicModInt {\r\n fn mul_assign(&mut self, other: Self) {\r\n *self = *self * other;\r\n }\r\n}\r\n\r\nimpl DivAssign for DynamicModInt {\r\n fn div_assign(&mut self, other: Self) {\r\n *self = *self / other;\r\n }\r\n}\r\n\r\nimpl Sum for DynamicModInt {\r\n fn sum>(iter: I) -> Self {\r\n iter.fold(Self::zero(), Add::add)\r\n }\r\n}\r\n\r\nimpl Product for DynamicModInt {\r\n fn product>(iter: I) -> Self {\r\n iter.fold(Self::one(), Mul::mul)\r\n }\r\n}\r\n// }}}\r\n", "lang": "Rust", "bug_code_uid": "92eecd7d1b8b5c85dba5ed73ecd33771", "src_uid": "77443424be253352aaf2b6c89bdd4671", "apr_id": "845ca4a9a8350769a7ff3ea48896205f", "difficulty": 1900, "tags": ["dp", "number theory", "math", "brute force", "two pointers"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9208953223428494, "equal_cnt": 25, "replace_cnt": 16, "delete_cnt": 5, "insert_cnt": 3, "fix_ops_cnt": 24, "bug_source_code": "pub mod pr {\n #[inline(always)]\n #[allow(dead_code)]\n pub fn ln(x: T) {\n print!(\"{}\\n\", x)\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn e(x: T) {\n print!(\"{} \", x)\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn pb() {\n print!(\" \")\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn endl() {\n print!(\"\\n\")\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn slice(v: &[T]) {\n for x in v {\n print!(\"{} \", &x);\n }\n print!(\"\\n\")\n }\n}\npub mod algo {\n pub fn calculate_array_inversions(arr: &[T]) -> i64 {\n let (answer, _) = _calculate_array_inversions(arr);\n return answer;\n }\n fn _calculate_array_inversions(\n arr: &[T],\n ) -> (i64, Vec) {\n let n = arr.len();\n match n {\n 0 | 1 => return (0, arr.to_vec()),\n 3..=10 => return _calculate_array_inversions_brute_force(arr),\n _ => (),\n }\n let mid = n / 2;\n let left = &arr[0..mid];\n let right = &arr[mid..];\n let (left_val, left_sorted) = _calculate_array_inversions(left);\n let (right_val, right_sorted) = _calculate_array_inversions(right);\n let (swap_count, vec_sorted) = _merge_sorted_vecs(left_sorted, right_sorted);\n let answer = left_val + right_val + swap_count;\n return (answer, vec_sorted);\n }\n fn _merge_sorted_vecs(\n left: Vec,\n right: Vec,\n ) -> (i64, Vec) {\n assert!(!left.is_empty());\n assert!(!right.is_empty());\n let mut sorted = Vec::with_capacity(left.len() + right.len());\n let mut swap_count = 0;\n let mut lp: usize = 0;\n let mut rp: usize = 0;\n while lp < left.len() && rp < right.len() {\n match left[lp] <= right[rp] {\n true => {\n sorted.push(left[lp]);\n lp += 1;\n }\n false => {\n sorted.push(right[rp]);\n rp += 1;\n let left_remained = left.len() - lp;\n swap_count += left_remained as i64;\n }\n }\n }\n while lp < left.len() {\n sorted.push(left[lp]);\n lp += 1;\n }\n while rp < right.len() {\n sorted.push(right[rp]);\n rp += 1;\n }\n assert_eq!(sorted.len(), left.len() + right.len());\n assert_eq!(left.len(), lp);\n assert_eq!(right.len(), rp);\n return (swap_count, sorted);\n }\n fn _calculate_array_inversions_brute_force(\n arr: &[T],\n ) -> (i64, Vec) {\n let n = arr.len();\n let mut answer = 0;\n for i in 0..n {\n for j in i + 1..n {\n if arr[i] > arr[j] {\n answer += 1;\n }\n }\n }\n let mut v = arr.to_vec();\n v.sort_unstable();\n return (answer, v);\n }\n #[allow(dead_code)]\n pub fn find_max_min_pos(slice: &[T]) -> (T, T, usize, usize) {\n std::assert!(slice.len() > 0);\n let mut max = &slice[0];\n let mut min = &slice[0];\n let mut max_pos: usize = 0;\n let mut min_pos: usize = 0;\n for index in 1..slice.len() {\n if slice[index] < *min {\n min = &slice[index];\n min_pos = index;\n }\n if slice[index] > *max {\n max = &slice[index];\n max_pos = index;\n }\n }\n (*max, *min, max_pos, min_pos)\n }\n}\npub mod nd {\n pub struct Arr {\n _max_n: usize,\n _max_m: usize,\n _data: Vec,\n }\n impl Arr {\n pub fn new(size: (usize, usize), default: T) -> Self {\n let dimensions = 2;\n let container_size = (size.0 + 1) * (size.1 + 1) + 1;\n let mut v = Vec::with_capacity(container_size);\n for _ in 0..container_size {\n v.push(default);\n }\n Arr {\n _max_n: size.0,\n _max_m: size.1,\n _data: v,\n }\n }\n fn _get_pos(&self, n: usize, m: usize) -> usize {\n assert!(n <= self._max_n);\n assert!(m <= self._max_m);\n n * self._max_m + m\n }\n pub fn get(&self, n: usize, m: usize) -> T {\n let p = self._get_pos(n, m);\n self._data[p]\n }\n pub fn set(&mut self, n: usize, m: usize, ans: T) -> T {\n let p = self._get_pos(n, m);\n self._data[p] = ans;\n ans\n }\n }\n impl std::fmt::Debug for Arr {\n fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n write!(f, \"Dim={}, ({},{})\\n\", 2, self._max_n, self._max_m);\n for i in 0..self._max_n {\n write!(f, \" [\");\n for j in 0..self._max_m {\n write!(f, \"{}\", self.get(i, j));\n if j + 1 < self._max_m {\n write!(f, \",\");\n }\n }\n write!(f, \"]\\n\");\n }\n write!(f, \"\")\n }\n }\n}\npub mod multi_queue {\n use std::collections::HashMap;\n use std::collections::VecDeque;\n pub struct MultiQueue\n where\n KeyT: Eq + std::hash::Hash,\n {\n _data: HashMap>,\n }\n impl MultiQueue {\n pub fn new() -> Self {\n MultiQueue {\n _data: HashMap::new(),\n }\n }\n pub fn push(&mut self, key: KeyT, value: ValT) {\n let mut entry = self._data.entry(key).or_insert(VecDeque::new());\n entry.push_back(value);\n }\n #[doc = \" Return None if 1. key not found 2. queue consumed\"]\n pub fn pop(&mut self, key: KeyT) -> Option {\n let mut queue = self._data.get_mut(&key);\n if queue.is_none() {\n return None;\n }\n let mut queue = queue.expect(\"Get Queue\");\n queue.pop_front()\n }\n }\n}\npub mod nums {\n #[doc = \" Returns a vector representing the bits.\"]\n #[doc = \" i=63 is the highest bit, i=0 is the lowest bit\"]\n #[doc = \" x = sigma v[i]*(2^i)\"]\n #[doc = \" # Arguments\"]\n #[doc = \"\"]\n #[doc = \" * `x`: A 64-bit number to be represented in bits\"]\n #[doc = \"\"]\n #[doc = \" returns: Vec\"]\n #[doc = \"\"]\n #[allow(dead_code)]\n pub fn represent_into_bits(x: u64) -> Vec {\n let mut result = Vec::with_capacity(64);\n let mut x = x;\n for _ in 0..64 {\n let bit = x & 1;\n let bit = bit as u8;\n result.push(bit);\n x >>= 1;\n }\n assert_eq!(result.len(), 64);\n result\n }\n pub fn represent_from_bits(a: &Vec) -> u64 {\n assert_eq!(a.len(), 64);\n let mut result: u64 = 0;\n for i in 0..64 {\n result += a[i] as u64 * (1u64 << i);\n }\n result\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn multi_mod(x: i32, y: i32, modulo: i32) -> i32 {\n let mid: i64 = (x as i64) * (y as i64);\n let mid = mid % (modulo as i64);\n return mid as i32;\n }\n #[allow(dead_code)]\n pub fn pow_mod(base: i32, exp: u32, modulo: i32) -> i32 {\n let mut answer: i64 = 1;\n if exp > 10 {\n let sub_exp = exp / 2;\n let mut p: i64 = pow_mod(base, sub_exp, modulo) as i64;\n p = p as i64 * p as i64 % modulo as i64;\n if exp % 2 == 1 {\n p = p * base as i64 % modulo as i64;\n }\n return p as i32;\n }\n for _ in 0..exp {\n answer *= base as i64;\n answer %= modulo as i64;\n }\n answer as i32\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn in_closed_range(left: i32, right: i32, x: i32) -> bool {\n left <= x && x <= right\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn in_closed_range_reversible(left: i32, right: i32, x: i32) -> bool {\n match left.cmp(&right) {\n std::cmp::Ordering::Less => in_closed_range(left, right, x),\n std::cmp::Ordering::Equal => x == left,\n std::cmp::Ordering::Greater => in_closed_range(right, left, x),\n }\n }\n pub fn select_lowest_kth_bit(x: u32, b: u32) -> u32 {\n let result = (x >> b) & 1;\n assert!(result == 0 || result == 1);\n result\n }\n #[allow(dead_code)]\n pub fn calc_combination_with_mod(a: i32, b: i32, modulo: i32) -> i32 {\n let mut num: i64 = 1;\n let mut den: i64 = 1;\n for i in 0..b {\n num = num * (a - i) as i64 % modulo as i64;\n den = den * (i + 1) as i64 % modulo as i64;\n }\n let answer = num * pow_mod(den as i32, modulo as u32 - 2, modulo) as i64;\n let answer = answer % modulo as i64;\n answer as i32\n }\n}\npub mod iters {\n pub fn permutation_chars(s: &str) -> Vec> {\n return permutation(s.as_bytes());\n }\n pub fn permutation(s: &[T]) -> Vec> {\n assert!(s.len() > 0);\n let mut possibilities = 1;\n for i in 1..=s.len() {\n possibilities *= i;\n }\n permutation_dfs(s, &vec![false; s.len()])\n }\n fn permutation_dfs(s: &[T], used: &Vec) -> Vec> {\n assert_eq!(s.len(), used.len());\n let mut result_list = Vec::new();\n for pos in 0..s.len() {\n if used[pos] {\n continue;\n }\n let mut new_used = used.clone();\n new_used[pos] = true;\n let select = s[pos];\n let recursive_results = permutation_dfs(s, &new_used);\n if recursive_results.is_empty() {\n let mut r = Vec::with_capacity(s.len());\n r.push(select);\n result_list.push(r);\n } else {\n for v in recursive_results {\n let mut r = v;\n r.push(select);\n result_list.push(r);\n }\n }\n }\n result_list\n }\n}\nuse std::error;\nuse std::fmt;\nuse std::str::FromStr;\n#[non_exhaustive]\n#[derive(Debug, PartialEq)]\npub enum Error {\n MissingMatch,\n MissingClosingBrace,\n UnexpectedValue(u8, Option),\n InvalidUtf8(Vec),\n PartialUtf8(usize, Vec),\n Parse(String, &'static str),\n}\nimpl error::Error for Error {}\nimpl fmt::Display for Error {\n fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n use crate::Error::*;\n use std::str::from_utf8;\n match *self {\n InvalidUtf8(ref raw) => write!(f, \"input was not valid utf8: {:?}\", raw),\n Parse(ref s, arg) => write!(f, \"could not parse {} as target type of {}\", s, arg),\n UnexpectedValue(exp, act) => write!(\n f,\n \"found value {:?} not matching the pattern value {}\",\n act.map(|b| b as char),\n exp as char\n ),\n PartialUtf8(n, ref raw) => write!(\n f,\n \"input was only partially valid utf8: \\\"{}\\\" followed by {:?}\",\n from_utf8(&raw[..n]).unwrap(),\n &raw[n..]\n ),\n MissingMatch => write!(f, \"Bad read! format string: did not contain {{}}\"),\n MissingClosingBrace => write!(\n f,\n \"found single open curly brace at the end of the format string\"\n ),\n }\n }\n}\npub fn match_next(expected: u8, iter: &mut dyn Iterator) -> Result<(), Error> {\n let next = iter.next();\n if next != Some(expected) {\n return Err(Error::UnexpectedValue(expected, next));\n }\n Ok(())\n}\npub fn parse_capture(\n name: &'static str,\n next: Option,\n iter: &mut dyn Iterator,\n) -> Result\nwhere\n T: FromStr,\n ::Err: ::std::fmt::Debug,\n{\n static WHITESPACES: &[u8] = b\"\\t\\r\\n \";\n let raw: Vec = match next {\n Some(c) => iter.take_while(|&ch| ch != c).collect(),\n None => iter\n .skip_while(|ch| WHITESPACES.contains(ch))\n .take_while(|ch| !WHITESPACES.contains(ch))\n .collect(),\n };\n match String::from_utf8(raw) {\n Ok(s) => FromStr::from_str(&s).map_err(|_| Error::Parse(s, name)),\n Err(e) => {\n let n = e.utf8_error().valid_up_to();\n let raw = e.into_bytes();\n if n == 0 {\n Err(Error::InvalidUtf8(raw))\n } else {\n Err(Error::PartialUtf8(n, raw))\n }\n }\n }\n}\n#[macro_export]\nmacro_rules ! try_read (() => { $ crate :: try_read ! (\"{}\") } ; ($ text : expr) => { { (|| -> std :: result :: Result < _ , $ crate :: Error > { let __try_read_var__ ; $ crate :: try_scan ! ($ text , __try_read_var__) ; Ok (__try_read_var__) }) () } } ; ($ text : expr , $ input : expr) => { { (|| -> std :: result :: Result < _ , $ crate :: Error > { let __try_read_var__ ; $ crate :: try_scan ! ($ input => $ text , __try_read_var__) ; Ok (__try_read_var__) }) () } } ;) ;\n#[macro_export]\nmacro_rules ! try_scan (($ pattern : expr , $ ($ arg : expr) ,*) => { use :: std :: io :: Read ; $ crate :: try_scan ! (:: std :: io :: stdin () . bytes () . map (std :: result :: Result :: unwrap) => $ pattern , $ ($ arg) ,*) ; } ; ($ input : expr => $ pattern : expr , $ ($ arg : expr) ,*) => { { $ crate :: try_scan ! (@ impl question_mark ; $ input => $ pattern , $ ($ arg) ,*) } } ; (@ question_mark : $ ($ e : tt) +) => { { ($ ($ e) +) ? } } ; (@ unwrap : $ ($ e : tt) +) => { { ($ ($ e) +) . unwrap () } } ; (@ impl $ action : tt ; $ input : expr => $ pattern : expr , $ ($ arg : expr) ,*) => { { #! [allow (clippy :: try_err)] use $ crate :: { Error , match_next , parse_capture } ; let pattern : &'static str = $ pattern ; let stdin : & mut Iterator < Item = u8 > = & mut ($ input) ; let mut pattern = pattern . bytes () ; $ ($ arg = loop { match $ crate :: try_scan ! (@$ action : pattern . next () . ok_or (Error :: MissingMatch)) { b'{' => match $ crate :: try_scan ! (@$ action : pattern . next () . ok_or (Error :: MissingClosingBrace)) { b'{' => $ crate :: try_scan ! (@$ action : match_next (b'{' , stdin)) , b'}' => break $ crate :: try_scan ! (@$ action : parse_capture (stringify ! ($ arg) , pattern . next () , stdin)) , _ => return $ crate :: try_scan ! (@$ action : Err (Error :: MissingClosingBrace)) , } , c => $ crate :: try_scan ! (@$ action : match_next (c , stdin)) , } } ;) * for c in pattern { $ crate :: try_scan ! (@$ action : match_next (c , stdin)) } format_args ! ($ pattern , $ ($ arg) ,*) ; } } ;) ;\n#[doc = \" All text input is handled through this macro\"]\n#[macro_export]\nmacro_rules ! read (($ ($ arg : tt) *) => { $ crate :: try_read ! ($ ($ arg) *) . unwrap () } ;) ;\n#[doc = \" This macro allows to pass several variables so multiple values can be read\"]\n#[macro_export]\nmacro_rules ! scan (($ text : expr , $ ($ arg : expr) ,*) => { use :: std :: io :: Read ; $ crate :: scan ! (:: std :: io :: stdin () . bytes () . map (std :: result :: Result :: unwrap) => $ text , $ ($ arg) ,*) ; } ; ($ input : expr => $ pattern : expr , $ ($ arg : expr) ,*) => { { $ crate :: try_scan ! (@ impl unwrap ; $ input => $ pattern , $ ($ arg) ,*) } } ;) ;\n#[inline(always)]\n#[allow(dead_code)]\npub fn read_ivec(n: usize) -> Vec {\n let mut vec = Vec::with_capacity(n);\n for _ in 0..n {\n let x: i32 = read!();\n vec.push(x);\n }\n return vec;\n}\n#[inline]\n#[allow(dead_code)]\npub fn read_ived_1(n: usize) -> Vec {\n let mut vec = Vec::with_capacity(n + 1);\n vec.push(0);\n for _ in 0..n {\n let x: i32 = read!();\n vec.push(x);\n }\n return vec;\n}\n#[inline(always)]\n#[allow(dead_code)]\npub fn read_uvec(n: usize) -> Vec {\n let mut vec = Vec::with_capacity(n);\n for _ in 0..n {\n let x: u32 = read!();\n vec.push(x);\n }\n return vec;\n}\nconst MODULO: i32 = 1_000_000_007;\nfn solve() -> Option {\n let n = read!();\n let k = read!();\n if k == 0 {\n return Some(1);\n }\n if n == 1 {\n let ans = nums::pow_mod(2, k, MODULO);\n return Some(ans as i64);\n }\n let free_select_01 = nums::pow_mod(2, n, MODULO);\n let mut greater_or_equal_select_01: i64 = 0;\n for selected_1 in (0..=n).step_by(2) {\n let c = nums::calc_combination_with_mod(n as i32, selected_1 as i32, MODULO);\n greater_or_equal_select_01 += c as i64;\n greater_or_equal_select_01 %= MODULO as i64;\n }\n if n % 2 != 0 {\n greater_or_equal_select_01 += 1;\n greater_or_equal_select_01 %= MODULO as i64;\n }\n let answer = calc(\n n,\n k - 1,\n free_select_01,\n greater_or_equal_select_01 as i32,\n MODULO,\n );\n Some(answer)\n}\nfn calc(\n n: u32,\n bit: u32,\n free_select_01: i32,\n greater_or_equal_select_01: i32,\n modulo: i32,\n) -> i64 {\n let mut answer: i64 = 0;\n if bit == 0 {\n return greater_or_equal_select_01 as i64;\n }\n if n % 2 == 0 {\n answer += nums::pow_mod(free_select_01, bit, modulo) as i64;\n }\n let x = greater_or_equal_select_01 as i64\n * calc(\n n,\n bit - 1,\n free_select_01,\n greater_or_equal_select_01,\n modulo,\n )\n % MODULO as i64;\n answer += x as i64;\n answer %= MODULO as i64;\n answer\n}\nfn main() {\n let testcases: i32 = read!();\n for _ in 0..testcases {\n solve_and_print();\n }\n}\n#[inline]\nfn solve_and_print() {\n let answer = solve();\n match answer {\n None => (),\n _ => pr::ln(answer.unwrap()),\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "152fa72cc4e8dbed4d58077b2bed45c0", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "apr_id": "af64a25928b5d109336f2c047ae2385e", "difficulty": 1700, "tags": ["dp", "combinatorics", "matrices", "bitmasks", "math"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9672938833272184, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "pub mod pr {\n #[inline(always)]\n #[allow(dead_code)]\n pub fn ln(x: T) {\n print!(\"{}\\n\", x)\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn e(x: T) {\n print!(\"{} \", x)\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn pb() {\n print!(\" \")\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn endl() {\n print!(\"\\n\")\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn slice(v: &[T]) {\n for x in v {\n print!(\"{} \", &x);\n }\n print!(\"\\n\")\n }\n}\npub mod algo {\n pub fn calculate_array_inversions(arr: &[T]) -> i64 {\n let (answer, _) = _calculate_array_inversions(arr);\n return answer;\n }\n fn _calculate_array_inversions(\n arr: &[T],\n ) -> (i64, Vec) {\n let n = arr.len();\n match n {\n 0 | 1 => return (0, arr.to_vec()),\n 3..=10 => return _calculate_array_inversions_brute_force(arr),\n _ => (),\n }\n let mid = n / 2;\n let left = &arr[0..mid];\n let right = &arr[mid..];\n let (left_val, left_sorted) = _calculate_array_inversions(left);\n let (right_val, right_sorted) = _calculate_array_inversions(right);\n let (swap_count, vec_sorted) = _merge_sorted_vecs(left_sorted, right_sorted);\n let answer = left_val + right_val + swap_count;\n return (answer, vec_sorted);\n }\n fn _merge_sorted_vecs(\n left: Vec,\n right: Vec,\n ) -> (i64, Vec) {\n assert!(!left.is_empty());\n assert!(!right.is_empty());\n let mut sorted = Vec::with_capacity(left.len() + right.len());\n let mut swap_count = 0;\n let mut lp: usize = 0;\n let mut rp: usize = 0;\n while lp < left.len() && rp < right.len() {\n match left[lp] <= right[rp] {\n true => {\n sorted.push(left[lp]);\n lp += 1;\n }\n false => {\n sorted.push(right[rp]);\n rp += 1;\n let left_remained = left.len() - lp;\n swap_count += left_remained as i64;\n }\n }\n }\n while lp < left.len() {\n sorted.push(left[lp]);\n lp += 1;\n }\n while rp < right.len() {\n sorted.push(right[rp]);\n rp += 1;\n }\n assert_eq!(sorted.len(), left.len() + right.len());\n assert_eq!(left.len(), lp);\n assert_eq!(right.len(), rp);\n return (swap_count, sorted);\n }\n fn _calculate_array_inversions_brute_force(\n arr: &[T],\n ) -> (i64, Vec) {\n let n = arr.len();\n let mut answer = 0;\n for i in 0..n {\n for j in i + 1..n {\n if arr[i] > arr[j] {\n answer += 1;\n }\n }\n }\n let mut v = arr.to_vec();\n v.sort_unstable();\n return (answer, v);\n }\n #[allow(dead_code)]\n pub fn find_max_min_pos(slice: &[T]) -> (T, T, usize, usize) {\n std::assert!(slice.len() > 0);\n let mut max = &slice[0];\n let mut min = &slice[0];\n let mut max_pos: usize = 0;\n let mut min_pos: usize = 0;\n for index in 1..slice.len() {\n if slice[index] < *min {\n min = &slice[index];\n min_pos = index;\n }\n if slice[index] > *max {\n max = &slice[index];\n max_pos = index;\n }\n }\n (*max, *min, max_pos, min_pos)\n }\n}\npub mod nd {\n pub struct Arr {\n _max_n: usize,\n _max_m: usize,\n _data: Vec,\n }\n impl Arr {\n pub fn new(size: (usize, usize), default: T) -> Self {\n let dimensions = 2;\n let container_size = (size.0 + 1) * (size.1 + 1) + 1;\n let mut v = Vec::with_capacity(container_size);\n for _ in 0..container_size {\n v.push(default);\n }\n Arr {\n _max_n: size.0,\n _max_m: size.1,\n _data: v,\n }\n }\n fn _get_pos(&self, n: usize, m: usize) -> usize {\n assert!(n <= self._max_n);\n assert!(m <= self._max_m);\n n * self._max_m + m\n }\n pub fn get(&self, n: usize, m: usize) -> T {\n let p = self._get_pos(n, m);\n self._data[p]\n }\n pub fn set(&mut self, n: usize, m: usize, ans: T) -> T {\n let p = self._get_pos(n, m);\n self._data[p] = ans;\n ans\n }\n }\n impl std::fmt::Debug for Arr {\n fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {\n write!(f, \"Dim={}, ({},{})\\n\", 2, self._max_n, self._max_m);\n for i in 0..self._max_n {\n write!(f, \" [\");\n for j in 0..self._max_m {\n write!(f, \"{}\", self.get(i, j));\n if j + 1 < self._max_m {\n write!(f, \",\");\n }\n }\n write!(f, \"]\\n\");\n }\n write!(f, \"\")\n }\n }\n}\npub mod multi_queue {\n use std::collections::HashMap;\n use std::collections::VecDeque;\n pub struct MultiQueue\n where\n KeyT: Eq + std::hash::Hash,\n {\n _data: HashMap>,\n }\n impl MultiQueue {\n pub fn new() -> Self {\n MultiQueue {\n _data: HashMap::new(),\n }\n }\n pub fn push(&mut self, key: KeyT, value: ValT) {\n let mut entry = self._data.entry(key).or_insert(VecDeque::new());\n entry.push_back(value);\n }\n #[doc = \" Return None if 1. key not found 2. queue consumed\"]\n pub fn pop(&mut self, key: KeyT) -> Option {\n let mut queue = self._data.get_mut(&key);\n if queue.is_none() {\n return None;\n }\n let mut queue = queue.expect(\"Get Queue\");\n queue.pop_front()\n }\n }\n}\npub mod nums {\n #[doc = \" Returns a vector representing the bits.\"]\n #[doc = \" i=63 is the highest bit, i=0 is the lowest bit\"]\n #[doc = \" x = sigma v[i]*(2^i)\"]\n #[doc = \" # Arguments\"]\n #[doc = \"\"]\n #[doc = \" * `x`: A 64-bit number to be represented in bits\"]\n #[doc = \"\"]\n #[doc = \" returns: Vec\"]\n #[doc = \"\"]\n #[allow(dead_code)]\n pub fn represent_into_bits(x: u64) -> Vec {\n let mut result = Vec::with_capacity(64);\n let mut x = x;\n for _ in 0..64 {\n let bit = x & 1;\n let bit = bit as u8;\n result.push(bit);\n x >>= 1;\n }\n assert_eq!(result.len(), 64);\n result\n }\n pub fn represent_from_bits(a: &Vec) -> u64 {\n assert_eq!(a.len(), 64);\n let mut result: u64 = 0;\n for i in 0..64 {\n result += a[i] as u64 * (1u64 << i);\n }\n result\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn multi_mod(x: i32, y: i32, modulo: i32) -> i32 {\n let mid: i64 = (x as i64) * (y as i64);\n let mid = mid % (modulo as i64);\n return mid as i32;\n }\n #[allow(dead_code)]\n pub fn pow_mod(base: i32, exp: u32, modulo: i32) -> i32 {\n let mut answer: i64 = 1;\n if exp > 10 {\n let sub_exp = exp / 2;\n let mut p: i64 = pow_mod(base, sub_exp, modulo) as i64;\n p = p as i64 * p as i64 % modulo as i64;\n if exp % 2 == 1 {\n p = p * base as i64 % modulo as i64;\n }\n return p as i32;\n }\n for _ in 0..exp {\n answer *= base as i64;\n answer %= modulo as i64;\n }\n answer as i32\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn in_closed_range(left: i32, right: i32, x: i32) -> bool {\n left <= x && x <= right\n }\n #[inline(always)]\n #[allow(dead_code)]\n pub fn in_closed_range_reversible(left: i32, right: i32, x: i32) -> bool {\n match left.cmp(&right) {\n std::cmp::Ordering::Less => in_closed_range(left, right, x),\n std::cmp::Ordering::Equal => x == left,\n std::cmp::Ordering::Greater => in_closed_range(right, left, x),\n }\n }\n pub fn select_lowest_kth_bit(x: u32, b: u32) -> u32 {\n let result = (x >> b) & 1;\n assert!(result == 0 || result == 1);\n result\n }\n #[allow(dead_code)]\n pub fn calc_combination_with_mod(a: i32, b: i32, modulo: i32) -> i32 {\n let mut num: i64 = 1;\n let mut den: i64 = 1;\n for i in 0..b {\n num = num * (a - i) as i64 % modulo as i64;\n den = den * (i + 1) as i64 % modulo as i64;\n }\n let answer = num * pow_mod(den as i32, modulo as u32 - 2, modulo) as i64;\n let answer = answer % modulo as i64;\n answer as i32\n }\n}\npub mod iters {\n pub fn permutation_chars(s: &str) -> Vec> {\n return permutation(s.as_bytes());\n }\n pub fn permutation(s: &[T]) -> Vec> {\n assert!(s.len() > 0);\n let mut possibilities = 1;\n for i in 1..=s.len() {\n possibilities *= i;\n }\n permutation_dfs(s, &vec![false; s.len()])\n }\n fn permutation_dfs(s: &[T], used: &Vec) -> Vec> {\n assert_eq!(s.len(), used.len());\n let mut result_list = Vec::new();\n for pos in 0..s.len() {\n if used[pos] {\n continue;\n }\n let mut new_used = used.clone();\n new_used[pos] = true;\n let select = s[pos];\n let recursive_results = permutation_dfs(s, &new_used);\n if recursive_results.is_empty() {\n let mut r = Vec::with_capacity(s.len());\n r.push(select);\n result_list.push(r);\n } else {\n for v in recursive_results {\n let mut r = v;\n r.push(select);\n result_list.push(r);\n }\n }\n }\n result_list\n }\n}\nuse std::error;\nuse std::fmt;\nuse std::str::FromStr;\n#[non_exhaustive]\n#[derive(Debug, PartialEq)]\npub enum Error {\n MissingMatch,\n MissingClosingBrace,\n UnexpectedValue(u8, Option),\n InvalidUtf8(Vec),\n PartialUtf8(usize, Vec),\n Parse(String, &'static str),\n}\nimpl error::Error for Error {}\nimpl fmt::Display for Error {\n fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n use crate::Error::*;\n use std::str::from_utf8;\n match *self {\n InvalidUtf8(ref raw) => write!(f, \"input was not valid utf8: {:?}\", raw),\n Parse(ref s, arg) => write!(f, \"could not parse {} as target type of {}\", s, arg),\n UnexpectedValue(exp, act) => write!(\n f,\n \"found value {:?} not matching the pattern value {}\",\n act.map(|b| b as char),\n exp as char\n ),\n PartialUtf8(n, ref raw) => write!(\n f,\n \"input was only partially valid utf8: \\\"{}\\\" followed by {:?}\",\n from_utf8(&raw[..n]).unwrap(),\n &raw[n..]\n ),\n MissingMatch => write!(f, \"Bad read! format string: did not contain {{}}\"),\n MissingClosingBrace => write!(\n f,\n \"found single open curly brace at the end of the format string\"\n ),\n }\n }\n}\npub fn match_next(expected: u8, iter: &mut dyn Iterator) -> Result<(), Error> {\n let next = iter.next();\n if next != Some(expected) {\n return Err(Error::UnexpectedValue(expected, next));\n }\n Ok(())\n}\npub fn parse_capture(\n name: &'static str,\n next: Option,\n iter: &mut dyn Iterator,\n) -> Result\nwhere\n T: FromStr,\n ::Err: ::std::fmt::Debug,\n{\n static WHITESPACES: &[u8] = b\"\\t\\r\\n \";\n let raw: Vec = match next {\n Some(c) => iter.take_while(|&ch| ch != c).collect(),\n None => iter\n .skip_while(|ch| WHITESPACES.contains(ch))\n .take_while(|ch| !WHITESPACES.contains(ch))\n .collect(),\n };\n match String::from_utf8(raw) {\n Ok(s) => FromStr::from_str(&s).map_err(|_| Error::Parse(s, name)),\n Err(e) => {\n let n = e.utf8_error().valid_up_to();\n let raw = e.into_bytes();\n if n == 0 {\n Err(Error::InvalidUtf8(raw))\n } else {\n Err(Error::PartialUtf8(n, raw))\n }\n }\n }\n}\n#[macro_export]\nmacro_rules ! try_read (() => { $ crate :: try_read ! (\"{}\") } ; ($ text : expr) => { { (|| -> std :: result :: Result < _ , $ crate :: Error > { let __try_read_var__ ; $ crate :: try_scan ! ($ text , __try_read_var__) ; Ok (__try_read_var__) }) () } } ; ($ text : expr , $ input : expr) => { { (|| -> std :: result :: Result < _ , $ crate :: Error > { let __try_read_var__ ; $ crate :: try_scan ! ($ input => $ text , __try_read_var__) ; Ok (__try_read_var__) }) () } } ;) ;\n#[macro_export]\nmacro_rules ! try_scan (($ pattern : expr , $ ($ arg : expr) ,*) => { use :: std :: io :: Read ; $ crate :: try_scan ! (:: std :: io :: stdin () . bytes () . map (std :: result :: Result :: unwrap) => $ pattern , $ ($ arg) ,*) ; } ; ($ input : expr => $ pattern : expr , $ ($ arg : expr) ,*) => { { $ crate :: try_scan ! (@ impl question_mark ; $ input => $ pattern , $ ($ arg) ,*) } } ; (@ question_mark : $ ($ e : tt) +) => { { ($ ($ e) +) ? } } ; (@ unwrap : $ ($ e : tt) +) => { { ($ ($ e) +) . unwrap () } } ; (@ impl $ action : tt ; $ input : expr => $ pattern : expr , $ ($ arg : expr) ,*) => { { #! [allow (clippy :: try_err)] use $ crate :: { Error , match_next , parse_capture } ; let pattern : &'static str = $ pattern ; let stdin : & mut Iterator < Item = u8 > = & mut ($ input) ; let mut pattern = pattern . bytes () ; $ ($ arg = loop { match $ crate :: try_scan ! (@$ action : pattern . next () . ok_or (Error :: MissingMatch)) { b'{' => match $ crate :: try_scan ! (@$ action : pattern . next () . ok_or (Error :: MissingClosingBrace)) { b'{' => $ crate :: try_scan ! (@$ action : match_next (b'{' , stdin)) , b'}' => break $ crate :: try_scan ! (@$ action : parse_capture (stringify ! ($ arg) , pattern . next () , stdin)) , _ => return $ crate :: try_scan ! (@$ action : Err (Error :: MissingClosingBrace)) , } , c => $ crate :: try_scan ! (@$ action : match_next (c , stdin)) , } } ;) * for c in pattern { $ crate :: try_scan ! (@$ action : match_next (c , stdin)) } format_args ! ($ pattern , $ ($ arg) ,*) ; } } ;) ;\n#[doc = \" All text input is handled through this macro\"]\n#[macro_export]\nmacro_rules ! read (($ ($ arg : tt) *) => { $ crate :: try_read ! ($ ($ arg) *) . unwrap () } ;) ;\n#[doc = \" This macro allows to pass several variables so multiple values can be read\"]\n#[macro_export]\nmacro_rules ! scan (($ text : expr , $ ($ arg : expr) ,*) => { use :: std :: io :: Read ; $ crate :: scan ! (:: std :: io :: stdin () . bytes () . map (std :: result :: Result :: unwrap) => $ text , $ ($ arg) ,*) ; } ; ($ input : expr => $ pattern : expr , $ ($ arg : expr) ,*) => { { $ crate :: try_scan ! (@ impl unwrap ; $ input => $ pattern , $ ($ arg) ,*) } } ;) ;\n#[inline(always)]\n#[allow(dead_code)]\npub fn read_ivec(n: usize) -> Vec {\n let mut vec = Vec::with_capacity(n);\n for _ in 0..n {\n let x: i32 = read!();\n vec.push(x);\n }\n return vec;\n}\n#[inline]\n#[allow(dead_code)]\npub fn read_ived_1(n: usize) -> Vec {\n let mut vec = Vec::with_capacity(n + 1);\n vec.push(0);\n for _ in 0..n {\n let x: i32 = read!();\n vec.push(x);\n }\n return vec;\n}\n#[inline(always)]\n#[allow(dead_code)]\npub fn read_uvec(n: usize) -> Vec {\n let mut vec = Vec::with_capacity(n);\n for _ in 0..n {\n let x: u32 = read!();\n vec.push(x);\n }\n return vec;\n}\nconst MODULO: i32 = 1_000_000_007;\nfn solve() -> Option {\n let n = read!();\n let k = read!();\n if k == 0 {\n return Some(1);\n }\n if n == 1 {\n let ans = nums::pow_mod(2, k, MODULO);\n return Some(ans as i64);\n }\n let free_select_01 = nums::pow_mod(2, n, MODULO);\n let mut factorial = vec![1i64; n as usize + 1];\n for i in 1usize..=(n as usize) {\n factorial[i] = factorial[i - 1] * i as i64;\n factorial[i] %= MODULO as i64;\n }\n let mut greater_or_equal_select_01: i64 = 0;\n for selected_1 in (0..=n as usize).step_by(2) {\n let a = factorial[n as usize];\n let b = factorial[n as usize - selected_1];\n let b = nums::pow_mod(b as i32, MODULO as u32 - 2, MODULO);\n let b2 = factorial[selected_1];\n let b2 = nums::pow_mod(b2 as i32, MODULO as u32 - 2, MODULO);\n let c = a * b as i64 % MODULO as i64 * b2 as i64 % MODULO as i64;\n greater_or_equal_select_01 += c as i64;\n greater_or_equal_select_01 %= MODULO as i64;\n }\n if n % 2 != 0 {\n greater_or_equal_select_01 += 1;\n greater_or_equal_select_01 %= MODULO as i64;\n }\n let mut answer: i64 = greater_or_equal_select_01 as i64;\n let mut prev: i64 = 0;\n let mut pow_bit = 1 as i64;\n for bit in 1..k {\n prev = answer;\n answer = 0;\n let x = greater_or_equal_select_01 as i64 * prev % MODULO as i64;\n answer += x as i64;\n answer %= MODULO as i64;\n if n % 2 == 0 {\n pow_bit *= free_select_01 as i64;\n pow_bit %= MODULO as i64;\n answer += pow_bit;\n answer -= prev;\n answer %= MODULO as i64;\n }\n }\n Some(answer)\n}\nfn calc(\n n: u32,\n bit: u32,\n free_select_01: i32,\n greater_or_equal_select_01: i32,\n modulo: i32,\n) -> i64 {\n let mut answer: i64 = 0;\n if bit == 0 {\n return greater_or_equal_select_01 as i64;\n }\n if n % 2 == 0 {\n answer += nums::pow_mod(free_select_01, bit, modulo) as i64;\n }\n let x = greater_or_equal_select_01 as i64\n * calc(\n n,\n bit - 1,\n free_select_01,\n greater_or_equal_select_01,\n modulo,\n )\n % MODULO as i64;\n answer += x as i64;\n answer %= MODULO as i64;\n answer\n}\nfn main() {\n let testcases: i32 = read!();\n for _ in 0..testcases {\n solve_and_print();\n }\n}\n#[inline]\nfn solve_and_print() {\n let answer = solve();\n match answer {\n None => (),\n _ => pr::ln(answer.unwrap()),\n }\n}\n\n", "lang": "Rust", "bug_code_uid": "d8d03c49208c89628635368cb4e95756", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "apr_id": "af64a25928b5d109336f2c047ae2385e", "difficulty": 1700, "tags": ["dp", "combinatorics", "matrices", "bitmasks", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9983169031017072, "equal_cnt": 5, "replace_cnt": 1, "delete_cnt": 2, "insert_cnt": 1, "fix_ops_cnt": 4, "bug_source_code": "#![allow(non_snake_case)]\n\nuse std::io::{self, prelude::*};\n\nfn solve(scn: &mut Scanner, wrt: &mut W) {\n let MOD: u64 = 1000000000+7;\n\n let N = scn.token::();\n let K = scn.token();\n\n let pw = |b: u64, mut a: u64| {\n let mut res = 1;\n let mut p = b;\n while a > 0 {\n if a & 1 == 1 {\n res = (res * p) % MOD;\n }\n p = (p*p) % MOD;\n a >>= 1;\n }\n res\n };\n\n let mut ans = 0;\n let mut dw = 1;\n\n for i in 0..K {\n if N & 1 == 0 {\n //auto win here and n even\n ans = (ans + ((dw * pw(2, K-i-1)) % MOD)) % MOD;\n dw = (dw * (pw(2, N-1) - 1)) % MOD;\n } else {\n //n odd\n dw = ((dw * (pw(2, N-1) + 1)) % MOD) % MOD;\n }\n }\n\n ans = (ans + dw) % MOD;\n\n writeln!(wrt, \"{}\", ans).unwrap();\n}\n\nfn main() {\n let stdin = io::stdin();\n let stdout = io::stdout();\n let mut reader = Scanner::new(stdin.lock());\n let mut writer = io::BufWriter::new(stdout.lock());\n\n let T = reader.token::();\n //let T = 1;\n for _ in 0..T {\n solve(&mut reader, &mut writer);\n }\n}\n\npub struct Scanner {\n reader: B,\n buf_str: Vec,\n buf_iter: std::str::SplitWhitespace<'static>,\n}\n\nimpl Scanner {\n pub fn new(reader: B) -> Self {\n Self {\n reader,\n buf_str: Vec::new(),\n buf_iter: \"\".split_whitespace(),\n }\n }\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 = std::str::from_utf8_unchecked(&self.buf_str);\n std::mem::transmute(slice.split_whitespace())\n }\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "f2814db2b3de4ab342f38f7d79968013", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "apr_id": "23e596b3c50267f6897e0df0ec5716e6", "difficulty": 1700, "tags": ["dp", "combinatorics", "matrices", "bitmasks", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.98963948787062, "equal_cnt": 11, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 4, "fix_ops_cnt": 10, "bug_source_code": "// ---------- begin ModInt ----------\r\n// モンゴメリ乗算を用いる\r\n// ほぼCodeforces用\r\n// 注意\r\n// new_unchecked は値xが 0 <= x < modulo であることを仮定\r\n// ModInt の中身は正規化された値で持ってるので直接読んだり書いたりするとぶっ壊れる\r\n// 奇素数のみ\r\nmod modint {\r\n\r\n use std::marker::*;\r\n use std::ops::*;\r\n\r\n pub trait Modulo {\r\n fn modulo() -> u32;\r\n fn rem() -> u32;\r\n fn ini() -> u64;\r\n fn reduce(x: u64) -> u32 {\r\n assert!(x < (Self::modulo() as u64) << 32);\r\n let b = (x as u32 * Self::rem()) as u64;\r\n let t = x + b * Self::modulo() as u64;\r\n let mut c = (t >> 32) as u32;\r\n if c >= Self::modulo() {\r\n c -= Self::modulo();\r\n }\r\n c as u32\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub enum Mod1_000_000_007 {}\r\n\r\n impl Modulo for Mod1_000_000_007 {\r\n fn modulo() -> u32 {\r\n 1_000_000_007\r\n }\r\n fn rem() -> u32 {\r\n 2226617417\r\n }\r\n fn ini() -> u64 {\r\n 582344008\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub enum Mod998_244_353 {}\r\n\r\n impl Modulo for Mod998_244_353 {\r\n fn modulo() -> u32 {\r\n 998_244_353\r\n }\r\n fn rem() -> u32 {\r\n 998244351\r\n }\r\n fn ini() -> u64 {\r\n 932051910\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn generate_umekomi_modulo(p: u32) {\r\n assert!(p < (1 << 31) && p > 2 && p & 1 == 1 && (2u32..).take_while(|v| v * v <= p).all(|k| p % k != 0));\r\n let mut t = 1u32;\r\n let mut s = !p + 1;\r\n let mut n = !0u32 >> 2;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t *= s;\r\n }\r\n s *= s;\r\n n >>= 1;\r\n }\r\n let mut ini = (1u64 << 32) % p as u64;\r\n ini = (ini << 32) % p as u64;\r\n assert!(t * p == !0);\r\n println!(\"pub enum Mod{} {{}}\", p);\r\n println!(\"impl Modulo for Mod{} {{\", p);\r\n println!(\" fn modulo() -> u32 {{\");\r\n println!(\" {}\", p);\r\n println!(\" }}\");\r\n println!(\" fn rem() -> u32 {{\");\r\n println!(\" {}\", t);\r\n println!(\" }}\");\r\n println!(\" fn ini() -> u32 {{\");\r\n println!(\" {}\", ini);\r\n println!(\" }}\");\r\n println!(\"}}\");\r\n let mut f = vec![];\r\n let mut n = p - 1;\r\n for i in 2.. {\r\n if i * i > n {\r\n break;\r\n }\r\n if n % i == 0 {\r\n f.push(i);\r\n while n % i == 0 {\r\n n /= i;\r\n }\r\n }\r\n }\r\n if n > 1 {\r\n f.push(n);\r\n }\r\n let mut order = 1;\r\n let mut n = p - 1;\r\n while n % 2 == 0 {\r\n n /= 2;\r\n order <<= 1;\r\n }\r\n let z = (2u64..).find(|z| {\r\n f.iter().all(|f| mod_pow(*z, ((p - 1) / *f) as u64, p as u64) != 1)\r\n }).unwrap();\r\n let zeta = mod_pow(z, ((p - 1) / order) as u64, p as u64);\r\n println!(\"impl transform::NTTFriendly for Mod{} {{\", p);\r\n println!(\" fn order() -> usize {{\");\r\n println!(\" {}\", order);\r\n println!(\" }}\");\r\n println!(\" fn zeta() -> u32 {{\");\r\n println!(\" {}\", zeta);\r\n println!(\" }}\");\r\n println!(\"}}\");\r\n }\r\n\r\n pub struct ModInt(u32, PhantomData);\r\n\r\n impl Clone for ModInt {\r\n fn clone(&self) -> Self {\r\n ModInt::build(self.0)\r\n }\r\n }\r\n\r\n impl Copy for ModInt {}\r\n\r\n impl Add for ModInt {\r\n type Output = ModInt;\r\n fn add(self, rhs: Self) -> Self::Output {\r\n let mut d = self.0 + rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n Self::build(d)\r\n }\r\n }\r\n\r\n impl AddAssign for ModInt {\r\n fn add_assign(&mut self, rhs: Self) {\r\n *self = *self + rhs;\r\n }\r\n }\r\n\r\n impl Sub for ModInt {\r\n type Output = ModInt;\r\n fn sub(self, rhs: Self) -> Self::Output {\r\n let mut d = self.0 - rhs.0;\r\n if d >= T::modulo() {\r\n d += T::modulo();\r\n }\r\n Self::build(d)\r\n }\r\n }\r\n\r\n impl SubAssign for ModInt {\r\n fn sub_assign(&mut self, rhs: Self) {\r\n *self = *self - rhs;\r\n }\r\n }\r\n\r\n impl Mul for ModInt {\r\n type Output = ModInt;\r\n fn mul(self, rhs: Self) -> Self::Output {\r\n Self::build(T::reduce(self.0 as u64 * rhs.0 as u64))\r\n }\r\n }\r\n\r\n impl MulAssign for ModInt {\r\n fn mul_assign(&mut self, rhs: Self) {\r\n *self = *self * rhs;\r\n }\r\n }\r\n\r\n impl Neg for ModInt {\r\n type Output = ModInt;\r\n fn neg(self) -> Self::Output {\r\n if self.0 == 0 {\r\n Self::zero()\r\n } else {\r\n Self::build(T::modulo() - self.0)\r\n }\r\n }\r\n }\r\n\r\n impl std::fmt::Display for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.get())\r\n }\r\n }\r\n\r\n impl std::fmt::Debug for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.get())\r\n }\r\n }\r\n\r\n impl std::str::FromStr for ModInt {\r\n type Err = std::num::ParseIntError;\r\n fn from_str(s: &str) -> Result {\r\n let val = s.parse::()?;\r\n Ok(ModInt::new(val))\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: usize) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: u64) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: i64) -> ModInt {\r\n let m = T::modulo() as i64;\r\n ModInt::new((val % m + m) as u32)\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n fn build(d: u32) -> Self {\r\n ModInt(d, PhantomData)\r\n }\r\n pub fn zero() -> Self {\r\n Self::build(0)\r\n }\r\n pub fn is_zero(&self) -> bool {\r\n self.0 == 0\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new_unchecked(d: u32) -> Self {\r\n Self::build(T::reduce(d as u64 * T::ini()))\r\n }\r\n pub fn new(d: u32) -> Self {\r\n Self::new_unchecked(d % T::modulo())\r\n }\r\n pub fn one() -> Self {\r\n Self::new_unchecked(1)\r\n }\r\n pub fn get(&self) -> u32 {\r\n T::reduce(self.0 as u64)\r\n }\r\n pub fn pow(&self, mut n: u64) -> Self {\r\n let mut t = Self::one();\r\n let mut s = *self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t *= s;\r\n }\r\n s *= s;\r\n n >>= 1;\r\n }\r\n t\r\n }\r\n pub fn inv(&self) -> Self {\r\n assert!(!self.is_zero());\r\n self.pow((T::modulo() - 2) as u64)\r\n }\r\n }\r\n\r\n pub fn mod_pow(mut r: u64, mut n: u64, m: u64) -> u64 {\r\n let mut t = 1 % m;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t = t * r % m;\r\n }\r\n r = r * r % m;\r\n n >>= 1;\r\n }\r\n t\r\n }\r\n}\r\n// ---------- end ModInt ----------\r\n// ---------- begin Precalc ----------\r\nmod precalc {\r\n use super::modint::*;\r\n #[allow(dead_code)]\r\n pub struct Precalc {\r\n inv: Vec>,\r\n fact: Vec>,\r\n ifact: Vec>,\r\n }\r\n #[allow(dead_code)]\r\n impl Precalc {\r\n pub fn new(n: usize) -> Precalc {\r\n let mut inv = vec![ModInt::one(); n + 1];\r\n let mut fact = vec![ModInt::one(); n + 1];\r\n let mut ifact = vec![ModInt::one(); n + 1];\r\n for i in 2..(n + 1) {\r\n fact[i] = fact[i - 1] * ModInt::new_unchecked(i as u32);\r\n }\r\n ifact[n] = fact[n].inv();\r\n if n > 0 {\r\n inv[n] = ifact[n] * fact[n - 1];\r\n }\r\n for i in (1..n).rev() {\r\n ifact[i] = ifact[i + 1] * ModInt::new_unchecked((i + 1) as u32);\r\n inv[i] = ifact[i] * fact[i - 1];\r\n }\r\n Precalc {\r\n inv: inv,\r\n fact: fact,\r\n ifact: ifact,\r\n }\r\n }\r\n pub fn inv(&self, n: usize) -> ModInt {\r\n assert!(n > 0);\r\n self.inv[n]\r\n }\r\n pub fn fact(&self, n: usize) -> ModInt {\r\n self.fact[n]\r\n }\r\n pub fn ifact(&self, n: usize) -> ModInt {\r\n self.ifact[n]\r\n }\r\n pub fn perm(&self, n: usize, k: usize) -> ModInt {\r\n if k > n {\r\n return ModInt::zero();\r\n }\r\n self.fact[n] * self.ifact[n - k]\r\n }\r\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\r\n if k > n {\r\n return ModInt::zero();\r\n }\r\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\r\n }\r\n }\r\n}\r\n// ---------- end Precalc ----------\r\n\r\nuse modint::*;\r\n\r\ntype M = ModInt;\r\n\r\n// ---------- begin input macro ----------\r\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\r\nmacro_rules! input {\r\n (source = $s:expr, $($r:tt)*) => {\r\n let mut iter = $s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n ($($r:tt)*) => {\r\n let s = {\r\n use std::io::Read;\r\n let mut s = String::new();\r\n std::io::stdin().read_to_string(&mut s).unwrap();\r\n s\r\n };\r\n let mut iter = s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! input_inner {\r\n ($iter:expr) => {};\r\n ($iter:expr, ) => {};\r\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\r\n let $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n ($iter:expr, bytes) => {\r\n read_value!($iter, String).bytes().collect::>()\r\n };\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n// ---------- end input macro ----------\r\n\r\nuse std::io::Write;\r\nuse std::collections::*;\r\n\r\ntype Map = BTreeMap;\r\ntype Set = BTreeSet;\r\ntype Deque = VecDeque;\r\n\r\nfn run() {\r\n input! {\r\n t: usize,\r\n ask: [(usize, usize); t],\r\n }\r\n for (n, k) in ask {\r\n let mut ans = M::zero();\r\n let mut even = M::one();\r\n for i in 0..k {\r\n if n % 2 == 1 {\r\n ans += even * M::new(2).pow((k - 1 - i) as u64 * n as u64);\r\n }\r\n even *= M::new(2).pow((n - 1) as u64);\r\n }\r\n ans += even;\r\n println!(\"{}\", ans);\r\n }\r\n}\r\n\r\nfn main() {\r\n run();\r\n}\r\n", "lang": "Rust", "bug_code_uid": "c336bec5df6c3f1b7730d3f30ebde1ed", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "apr_id": "9df2a6a01d74a957590d1fe9716980c5", "difficulty": 1700, "tags": ["dp", "combinatorics", "matrices", "bitmasks", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9991797631155878, "equal_cnt": 4, "replace_cnt": 2, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 3, "bug_source_code": "#![allow(unused_parens)]\r\n#![allow(unused_imports)]\r\n#![allow(non_upper_case_globals)]\r\n#![allow(non_snake_case)]\r\n#![allow(unused_mut)]\r\n#![allow(unused_variables)]\r\n#![allow(dead_code)]\r\n\r\ntype Vec2 = Vec>;\r\ntype Vec3 = Vec>>;\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! invec {\r\n ( $ t : ty ) => {{\r\n let mut s = String::new();\r\n match std::io::stdin().read_line(&mut s) {\r\n Ok(0) => Vec::<$t>::new(),\r\n Ok(n) => s\r\n .trim()\r\n .split_whitespace()\r\n .map(|s| s.parse::<$t>().unwrap())\r\n .collect::>(),\r\n Err(_) => Vec::<$t>::new(),\r\n }\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! get {\r\n ($t:ty) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n line.trim().parse::<$t>().unwrap()\r\n }\r\n };\r\n ($($t:ty),*) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n let mut iter = line.split_whitespace();\r\n (\r\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\r\n )\r\n }\r\n };\r\n ($t:ty; $n:expr) => {\r\n (0..$n).map(|_|\r\n get!($t)\r\n ).collect::>()\r\n };\r\n ($($t:ty),*; $n:expr) => {\r\n (0..$n).map(|_|\r\n get!($($t),*)\r\n ).collect::>()\r\n };\r\n ($t:ty ;;) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n line.split_whitespace()\r\n .map(|t| t.parse::<$t>().unwrap())\r\n .collect::>()\r\n }\r\n };\r\n ($t:ty ;; $n:expr) => {\r\n (0..$n).map(|_| get!($t ;;)).collect::>()\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\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 mut 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\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 ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\r\n let mut $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n\r\n ($next:expr, [$t:tt]) => {\r\n {\r\n let len = read_value!($next, usize);\r\n (0..len).map(|_| read_value!($next, $t)).collect::>()\r\n }\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\n#[cfg(debug_assertions)]\r\nmacro_rules! mydbg {\r\n //($arg:expr) => (dbg!($arg))\r\n //($arg:expr) => (println!(\"{:?}\",$arg));\r\n ($($a:expr),*) => {\r\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\r\n }\r\n}\r\n#[cfg(not(debug_assertions))]\r\nmacro_rules! mydbg {\r\n ($($arg:expr),*) => {};\r\n}\r\n\r\nmacro_rules! echo {\r\n ($($a:expr),*) => {\r\n $(println!(\"{}\",$a))*\r\n }\r\n}\r\n\r\nuse std::cmp::*;\r\nuse std::collections::*;\r\nuse std::ops::{Add, Div, Mul, Rem, Sub};\r\n\r\ntrait SafeRangeContain {\r\n fn safe_contains(&self, x: i64) -> bool;\r\n}\r\n\r\nimpl SafeRangeContain for std::ops::Range {\r\n fn safe_contains(&self, x: i64) -> bool {\r\n if x < 0 {\r\n return false;\r\n }\r\n return self.contains(&(x as usize));\r\n }\r\n}\r\n\r\n#[allow(dead_code)]\r\nstatic INF_I64: i64 = i64::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic INF_I32: i32 = i32::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic INF_USIZE: usize = usize::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic M_O_D: usize = 1000000007;\r\n#[allow(dead_code)]\r\nstatic PAI: f64 = 3.1415926535897932;\r\n\r\ntrait IteratorExt: Iterator {\r\n fn toVec(self) -> Vec;\r\n}\r\n\r\nimpl IteratorExt for T {\r\n fn toVec(self) -> Vec {\r\n self.collect()\r\n }\r\n}\r\n\r\ntrait CharExt {\r\n fn toNum(&self) -> usize;\r\n fn toAlphabetIndex(&self) -> usize;\r\n fn toNumIndex(&self) -> usize;\r\n}\r\nimpl CharExt for char {\r\n fn toNum(&self) -> usize {\r\n return *self as usize;\r\n }\r\n fn toAlphabetIndex(&self) -> usize {\r\n return self.toNum() - 'a' as usize;\r\n }\r\n fn toNumIndex(&self) -> usize {\r\n return self.toNum() - '0' as usize;\r\n }\r\n}\r\n\r\ntrait VectorExt {\r\n fn joinToString(&self, s: &str) -> String;\r\n}\r\nimpl VectorExt for Vec {\r\n fn joinToString(&self, s: &str) -> String {\r\n return self\r\n .iter()\r\n .map(|x| x.to_string())\r\n .collect::>()\r\n .join(s);\r\n }\r\n}\r\n\r\ntrait StringExt {\r\n fn get_reverse(&self) -> String;\r\n}\r\nimpl StringExt for String {\r\n fn get_reverse(&self) -> String {\r\n self.chars().rev().collect::()\r\n }\r\n}\r\n\r\ntrait UsizeExt {\r\n fn pow(&self, n: usize) -> usize;\r\n}\r\nimpl UsizeExt for usize {\r\n fn pow(&self, n: usize) -> usize {\r\n return ((*self as u64).pow(n as u32)) as usize;\r\n }\r\n}\r\n\r\n//https://github.com/rust-lang-ja/ac-library-rs\r\n\r\npub mod internal_math {\r\n // remove this after dependencies has been added\r\n #![allow(dead_code)]\r\n use std::mem::swap;\r\n\r\n /// # Arguments\r\n /// * `m` `1 <= m`\r\n ///\r\n /// # Returns\r\n /// x mod m\r\n /* const */\r\n pub(crate) fn safe_mod(mut x: i64, m: i64) -> i64 {\r\n x %= m;\r\n if x < 0 {\r\n x += m;\r\n }\r\n x\r\n }\r\n\r\n /// Fast modular by barrett reduction\r\n /// Reference: https://en.wikipedia.org/wiki/Barrett_reduction\r\n /// NOTE: reconsider after Ice Lake\r\n pub(crate) struct Barrett {\r\n pub(crate) _m: u32,\r\n pub(crate) im: u64,\r\n }\r\n\r\n impl Barrett {\r\n /// # Arguments\r\n /// * `m` `1 <= m`\r\n /// (Note: `m <= 2^31` should also hold, which is undocumented in the original library.\r\n /// See the [pull reqeust commment](https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484661007)\r\n /// for more details.)\r\n pub(crate) fn new(m: u32) -> Barrett {\r\n Barrett {\r\n _m: m,\r\n im: (-1i64 as u64 / m as u64).wrapping_add(1),\r\n }\r\n }\r\n\r\n /// # Returns\r\n /// `m`\r\n pub(crate) fn umod(&self) -> u32 {\r\n self._m\r\n }\r\n\r\n /// # Parameters\r\n /// * `a` `0 <= a < m`\r\n /// * `b` `0 <= b < m`\r\n ///\r\n /// # Returns\r\n /// a * b % m\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn mul(&self, a: u32, b: u32) -> u32 {\r\n mul_mod(a, b, self._m, self.im)\r\n }\r\n }\r\n\r\n /// Calculates `a * b % m`.\r\n ///\r\n /// * `a` `0 <= a < m`\r\n /// * `b` `0 <= b < m`\r\n /// * `m` `1 <= m <= 2^31`\r\n /// * `im` = ceil(2^64 / `m`)\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn mul_mod(a: u32, b: u32, m: u32, im: u64) -> u32 {\r\n // [1] m = 1\r\n // a = b = im = 0, so okay\r\n\r\n // [2] m >= 2\r\n // im = ceil(2^64 / m)\r\n // -> im * m = 2^64 + r (0 <= r < m)\r\n // let z = a*b = c*m + d (0 <= c, d < m)\r\n // a*b * im = (c*m + d) * im = c*(im*m) + d*im = c*2^64 + c*r + d*im\r\n // c*r + d*im < m * m + m * im < m * m + 2^64 + m <= 2^64 + m * (m + 1) < 2^64 * 2\r\n // ((ab * im) >> 64) == c or c + 1\r\n let mut z = a as u64;\r\n z *= b as u64;\r\n let x = (((z as u128) * (im as u128)) >> 64) as u64;\r\n let mut v = z.wrapping_sub(x.wrapping_mul(m as u64)) as u32;\r\n if m <= v {\r\n v = v.wrapping_add(m);\r\n }\r\n v\r\n }\r\n\r\n /// # Parameters\r\n /// * `n` `0 <= n`\r\n /// * `m` `1 <= m`\r\n ///\r\n /// # Returns\r\n /// `(x ** n) % m`\r\n /* const */\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn pow_mod(x: i64, mut n: i64, m: i32) -> i64 {\r\n if m == 1 {\r\n return 0;\r\n }\r\n let _m = m as u32;\r\n let mut r: u64 = 1;\r\n let mut y: u64 = safe_mod(x, m as i64) as u64;\r\n while n != 0 {\r\n if (n & 1) > 0 {\r\n r = (r * y) % (_m as u64);\r\n }\r\n y = (y * y) % (_m as u64);\r\n n >>= 1;\r\n }\r\n r as i64\r\n }\r\n\r\n /// Reference:\r\n /// M. Forisek and J. Jancina,\r\n /// Fast Primality Testing for Integers That Fit into a Machine Word\r\n ///\r\n /// # Parameters\r\n /// * `n` `0 <= n`\r\n /* const */\r\n pub(crate) fn is_prime(n: i32) -> bool {\r\n let n = n as i64;\r\n match n {\r\n _ if n <= 1 => return false,\r\n 2 | 7 | 61 => return true,\r\n _ if n % 2 == 0 => return false,\r\n _ => {}\r\n }\r\n let mut d = n - 1;\r\n while d % 2 == 0 {\r\n d /= 2;\r\n }\r\n for &a in &[2, 7, 61] {\r\n let mut t = d;\r\n let mut y = pow_mod(a, t, n as i32);\r\n while t != n - 1 && y != 1 && y != n - 1 {\r\n y = y * y % n;\r\n t <<= 1;\r\n }\r\n if y != n - 1 && t % 2 == 0 {\r\n return false;\r\n }\r\n }\r\n true\r\n }\r\n\r\n // omitted\r\n // template constexpr bool is_prime = is_prime_constexpr(n);\r\n\r\n /// # Parameters\r\n /// * `b` `1 <= b`\r\n ///\r\n /// # Returns\r\n /// (g, x) s.t. g = gcd(a, b), xa = g (mod b), 0 <= x < b/g\r\n /* const */\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn inv_gcd(a: i64, b: i64) -> (i64, i64) {\r\n let a = safe_mod(a, b);\r\n if a == 0 {\r\n return (b, 0);\r\n }\r\n\r\n // Contracts:\r\n // [1] s - m0 * a = 0 (mod b)\r\n // [2] t - m1 * a = 0 (mod b)\r\n // [3] s * |m1| + t * |m0| <= b\r\n let mut s = b;\r\n let mut t = a;\r\n let mut m0 = 0;\r\n let mut m1 = 1;\r\n\r\n while t != 0 {\r\n let u = s / t;\r\n s -= t * u;\r\n m0 -= m1 * u; // |m1 * u| <= |m1| * s <= b\r\n\r\n // [3]:\r\n // (s - t * u) * |m1| + t * |m0 - m1 * u|\r\n // <= s * |m1| - t * u * |m1| + t * (|m0| + |m1| * u)\r\n // = s * |m1| + t * |m0| <= b\r\n\r\n swap(&mut s, &mut t);\r\n swap(&mut m0, &mut m1);\r\n }\r\n // by [3]: |m0| <= b/g\r\n // by g != b: |m0| < b/g\r\n if m0 < 0 {\r\n m0 += b / s;\r\n }\r\n (s, m0)\r\n }\r\n\r\n /// Compile time (currently not) primitive root\r\n /// @param m must be prime\r\n /// @return primitive root (and minimum in now)\r\n /* const */\r\n pub(crate) fn primitive_root(m: i32) -> i32 {\r\n match m {\r\n 2 => return 1,\r\n 167_772_161 => return 3,\r\n 469_762_049 => return 3,\r\n 754_974_721 => return 11,\r\n 998_244_353 => return 3,\r\n _ => {}\r\n }\r\n\r\n let mut divs = [0; 20];\r\n divs[0] = 2;\r\n let mut cnt = 1;\r\n let mut x = (m - 1) / 2;\r\n while x % 2 == 0 {\r\n x /= 2;\r\n }\r\n for i in (3..std::i32::MAX).step_by(2) {\r\n if i as i64 * i as i64 > x as i64 {\r\n break;\r\n }\r\n if x % i == 0 {\r\n divs[cnt] = i;\r\n cnt += 1;\r\n while x % i == 0 {\r\n x /= i;\r\n }\r\n }\r\n }\r\n if x > 1 {\r\n divs[cnt] = x;\r\n cnt += 1;\r\n }\r\n let mut g = 2;\r\n loop {\r\n if (0..cnt).all(|i| pow_mod(g, ((m - 1) / divs[i]) as i64, m) != 1) {\r\n break g as i32;\r\n }\r\n g += 1;\r\n }\r\n }\r\n // omitted\r\n // template constexpr int primitive_root = primitive_root_constexpr(m);\r\n\r\n #[cfg(test)]\r\n mod tests {\r\n #![allow(clippy::unreadable_literal)]\r\n #![allow(clippy::cognitive_complexity)]\r\n use crate::internal_math::{inv_gcd, is_prime, pow_mod, primitive_root, safe_mod, Barrett};\r\n use std::collections::HashSet;\r\n\r\n #[test]\r\n fn test_safe_mod() {\r\n assert_eq!(safe_mod(0, 3), 0);\r\n assert_eq!(safe_mod(1, 3), 1);\r\n assert_eq!(safe_mod(2, 3), 2);\r\n assert_eq!(safe_mod(3, 3), 0);\r\n assert_eq!(safe_mod(4, 3), 1);\r\n assert_eq!(safe_mod(5, 3), 2);\r\n assert_eq!(safe_mod(73, 11), 7);\r\n assert_eq!(safe_mod(2306249155046129918, 6620319213327), 1374210749525);\r\n\r\n assert_eq!(safe_mod(-1, 3), 2);\r\n assert_eq!(safe_mod(-2, 3), 1);\r\n assert_eq!(safe_mod(-3, 3), 0);\r\n assert_eq!(safe_mod(-4, 3), 2);\r\n assert_eq!(safe_mod(-5, 3), 1);\r\n assert_eq!(safe_mod(-7170500492396019511, 777567337), 333221848);\r\n }\r\n\r\n #[test]\r\n fn test_barrett() {\r\n let b = Barrett::new(7);\r\n assert_eq!(b.umod(), 7);\r\n assert_eq!(b.mul(2, 3), 6);\r\n assert_eq!(b.mul(4, 6), 3);\r\n assert_eq!(b.mul(5, 0), 0);\r\n\r\n let b = Barrett::new(998244353);\r\n assert_eq!(b.umod(), 998244353);\r\n assert_eq!(b.mul(2, 3), 6);\r\n assert_eq!(b.mul(3141592, 653589), 919583920);\r\n assert_eq!(b.mul(323846264, 338327950), 568012980);\r\n\r\n // make `z - x * self._m as u64` overflow.\r\n // Thanks @koba-e964 (at https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484932161)\r\n let b = Barrett::new(2147483647);\r\n assert_eq!(b.umod(), 2147483647);\r\n assert_eq!(b.mul(1073741824, 2147483645), 2147483646);\r\n }\r\n\r\n #[test]\r\n fn test_pow_mod() {\r\n assert_eq!(pow_mod(0, 0, 1), 0);\r\n assert_eq!(pow_mod(0, 0, 3), 1);\r\n assert_eq!(pow_mod(0, 0, 723), 1);\r\n assert_eq!(pow_mod(0, 0, 998244353), 1);\r\n assert_eq!(pow_mod(0, 0, i32::max_value()), 1);\r\n\r\n assert_eq!(pow_mod(0, 1, 1), 0);\r\n assert_eq!(pow_mod(0, 1, 3), 0);\r\n assert_eq!(pow_mod(0, 1, 723), 0);\r\n assert_eq!(pow_mod(0, 1, 998244353), 0);\r\n assert_eq!(pow_mod(0, 1, i32::max_value()), 0);\r\n\r\n assert_eq!(pow_mod(0, i64::max_value(), 1), 0);\r\n assert_eq!(pow_mod(0, i64::max_value(), 3), 0);\r\n assert_eq!(pow_mod(0, i64::max_value(), 723), 0);\r\n assert_eq!(pow_mod(0, i64::max_value(), 998244353), 0);\r\n assert_eq!(pow_mod(0, i64::max_value(), i32::max_value()), 0);\r\n\r\n assert_eq!(pow_mod(1, 0, 1), 0);\r\n assert_eq!(pow_mod(1, 0, 3), 1);\r\n assert_eq!(pow_mod(1, 0, 723), 1);\r\n assert_eq!(pow_mod(1, 0, 998244353), 1);\r\n assert_eq!(pow_mod(1, 0, i32::max_value()), 1);\r\n\r\n assert_eq!(pow_mod(1, 1, 1), 0);\r\n assert_eq!(pow_mod(1, 1, 3), 1);\r\n assert_eq!(pow_mod(1, 1, 723), 1);\r\n assert_eq!(pow_mod(1, 1, 998244353), 1);\r\n assert_eq!(pow_mod(1, 1, i32::max_value()), 1);\r\n\r\n assert_eq!(pow_mod(1, i64::max_value(), 1), 0);\r\n assert_eq!(pow_mod(1, i64::max_value(), 3), 1);\r\n assert_eq!(pow_mod(1, i64::max_value(), 723), 1);\r\n assert_eq!(pow_mod(1, i64::max_value(), 998244353), 1);\r\n assert_eq!(pow_mod(1, i64::max_value(), i32::max_value()), 1);\r\n\r\n assert_eq!(pow_mod(i64::max_value(), 0, 1), 0);\r\n assert_eq!(pow_mod(i64::max_value(), 0, 3), 1);\r\n assert_eq!(pow_mod(i64::max_value(), 0, 723), 1);\r\n assert_eq!(pow_mod(i64::max_value(), 0, 998244353), 1);\r\n assert_eq!(pow_mod(i64::max_value(), 0, i32::max_value()), 1);\r\n\r\n assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 1), 0);\r\n assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 3), 1);\r\n assert_eq!(pow_mod(i64::max_value(), i64::max_value(), 723), 640);\r\n assert_eq!(\r\n pow_mod(i64::max_value(), i64::max_value(), 998244353),\r\n 683296792\r\n );\r\n assert_eq!(\r\n pow_mod(i64::max_value(), i64::max_value(), i32::max_value()),\r\n 1\r\n );\r\n\r\n assert_eq!(pow_mod(2, 3, 1_000_000_007), 8);\r\n assert_eq!(pow_mod(5, 7, 1_000_000_007), 78125);\r\n assert_eq!(pow_mod(123, 456, 1_000_000_007), 565291922);\r\n }\r\n\r\n #[test]\r\n fn test_is_prime() {\r\n assert!(!is_prime(0));\r\n assert!(!is_prime(1));\r\n assert!(is_prime(2));\r\n assert!(is_prime(3));\r\n assert!(!is_prime(4));\r\n assert!(is_prime(5));\r\n assert!(!is_prime(6));\r\n assert!(is_prime(7));\r\n assert!(!is_prime(8));\r\n assert!(!is_prime(9));\r\n\r\n // assert!(is_prime(57));\r\n assert!(!is_prime(57));\r\n assert!(!is_prime(58));\r\n assert!(is_prime(59));\r\n assert!(!is_prime(60));\r\n assert!(is_prime(61));\r\n assert!(!is_prime(62));\r\n\r\n assert!(!is_prime(701928443));\r\n assert!(is_prime(998244353));\r\n assert!(!is_prime(1_000_000_000));\r\n assert!(is_prime(1_000_000_007));\r\n\r\n assert!(is_prime(i32::max_value()));\r\n }\r\n\r\n #[test]\r\n fn test_is_prime_sieve() {\r\n let n = 1_000_000;\r\n let mut prime = vec![true; n];\r\n prime[0] = false;\r\n prime[1] = false;\r\n for i in 0..n {\r\n assert_eq!(prime[i], is_prime(i as i32));\r\n if prime[i] {\r\n for j in (2 * i..n).step_by(i) {\r\n prime[j] = false;\r\n }\r\n }\r\n }\r\n }\r\n\r\n #[test]\r\n fn test_inv_gcd() {\r\n for &(a, b, g) in &[\r\n (0, 1, 1),\r\n (0, 4, 4),\r\n (0, 7, 7),\r\n (2, 3, 1),\r\n (-2, 3, 1),\r\n (4, 6, 2),\r\n (-4, 6, 2),\r\n (13, 23, 1),\r\n (57, 81, 3),\r\n (12345, 67890, 15),\r\n (-3141592 * 6535, 3141592 * 8979, 3141592),\r\n (i64::max_value(), i64::max_value(), i64::max_value()),\r\n (i64::min_value(), i64::max_value(), 1),\r\n ] {\r\n let (g_, x) = inv_gcd(a, b);\r\n assert_eq!(g, g_);\r\n let b_ = b as i128;\r\n assert_eq!(((x as i128 * a as i128) % b_ + b_) % b_, g as i128 % b_);\r\n }\r\n }\r\n\r\n #[test]\r\n fn test_primitive_root() {\r\n for &p in &[\r\n 2,\r\n 3,\r\n 5,\r\n 7,\r\n 233,\r\n 200003,\r\n 998244353,\r\n 1_000_000_007,\r\n i32::max_value(),\r\n ] {\r\n assert!(is_prime(p));\r\n let g = primitive_root(p);\r\n if p != 2 {\r\n assert_ne!(g, 1);\r\n }\r\n\r\n let q = p - 1;\r\n for i in (2..i32::max_value()).take_while(|i| i * i <= q) {\r\n if q % i != 0 {\r\n break;\r\n }\r\n for &r in &[i, q / i] {\r\n assert_ne!(pow_mod(g as i64, r as i64, p), 1);\r\n }\r\n }\r\n assert_eq!(pow_mod(g as i64, q as i64, p), 1);\r\n\r\n if p < 1_000_000 {\r\n assert_eq!(\r\n (0..p - 1)\r\n .scan(1, |i, _| {\r\n *i = *i * g % p;\r\n Some(*i)\r\n })\r\n .collect::>()\r\n .len() as i32,\r\n p - 1\r\n );\r\n }\r\n }\r\n }\r\n }\r\n}\r\npub mod modint {\r\n //! Structs that treat the modular arithmetic.\r\n //!\r\n //! For most of the problems, It is sufficient to use [`ModInt1000000007`] or [`ModInt998244353`], which can be used as follows.\r\n //!\r\n //! ```\r\n //! use ac_library_rs::ModInt1000000007 as Mint; // rename to whatever you want\r\n //! use proconio::{input, source::once::OnceSource};\r\n //!\r\n //! input! {\r\n //! from OnceSource::from(\"1000000006 2\\n\"),\r\n //! a: Mint,\r\n //! b: Mint,\r\n //! }\r\n //!\r\n //! println!(\"{}\", a + b); // `1`\r\n //! ```\r\n //!\r\n //! If the modulus is not fixed, you can use [`ModInt`] as follows.\r\n //!\r\n //! ```\r\n //! use ac_library_rs::ModInt as Mint; // rename to whatever you want\r\n //! use proconio::{input, source::once::OnceSource};\r\n //!\r\n //! input! {\r\n //! from OnceSource::from(\"3 3 7\\n\"),\r\n //! a: u32,\r\n //! b: u32,\r\n //! m: u32,\r\n //! }\r\n //!\r\n //! Mint::set_modulus(m);\r\n //! let a = Mint::new(a);\r\n //! let b = Mint::new(b);\r\n //!\r\n //! println!(\"{}\", a * b); // `2`\r\n //! ```\r\n //!\r\n //! # Major changes from the original ACL\r\n //!\r\n //! - Converted the struct names to PascalCase.\r\n //! - Renamed `mod` `modulus`.\r\n //! - Moduli are `u32`, not `i32`.\r\n //! - Each `Id` does not have a identifier number. Instead, they explicitly own `&'static LocalKey>`.\r\n //! - The type of the argument of `pow` is `u64`, not `i64`.\r\n //! - Modints implement `FromStr` and `Display`. Modints in the original ACL don't have `operator<<` or `operator>>`.\r\n //!\r\n //! [`ModInt1000000007`]: ./type.ModInt1000000007.html\r\n //! [`ModInt998244353`]: ./type.ModInt998244353.html\r\n //! [`ModInt`]: ./type.ModInt.html\r\n\r\n use crate::internal_math;\r\n use std::{\r\n cell::RefCell,\r\n convert::{Infallible, TryInto as _},\r\n fmt,\r\n hash::{Hash, Hasher},\r\n iter::{Product, Sum},\r\n marker::PhantomData,\r\n ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign},\r\n str::FromStr,\r\n sync::atomic::{self, AtomicU32, AtomicU64},\r\n thread::LocalKey,\r\n };\r\n\r\n pub type ModInt1000000007 = StaticModInt;\r\n pub type ModInt998244353 = StaticModInt;\r\n pub type ModInt = DynamicModInt;\r\n\r\n /// Represents where _m_ is a constant value.\r\n ///\r\n /// Corresponds to `atcoder::static_modint` in the original ACL.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::ModInt1000000007 as Mint;\r\n /// use proconio::{input, source::once::OnceSource};\r\n ///\r\n /// input! {\r\n /// from OnceSource::from(\"1000000006 2\\n\"),\r\n /// a: Mint,\r\n /// b: Mint,\r\n /// }\r\n ///\r\n /// println!(\"{}\", a + b); // `1`\r\n /// ```\r\n #[derive(Copy, Clone, Eq, PartialEq)]\r\n #[repr(transparent)]\r\n pub struct StaticModInt {\r\n val: u32,\r\n phantom: PhantomData M>,\r\n }\r\n\r\n impl StaticModInt {\r\n /// Returns the modulus, which is [`::VALUE`].\r\n ///\r\n /// Corresponds to `atcoder::static_modint::mod` in the original ACL.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::ModInt1000000007 as Mint;\r\n ///\r\n /// assert_eq!(1_000_000_007, Mint::modulus());\r\n /// ```\r\n ///\r\n /// [`::VALUE`]: ../trait.Modulus.html#associatedconstant.VALUE\r\n #[inline(always)]\r\n pub fn modulus() -> u32 {\r\n M::VALUE\r\n }\r\n\r\n /// Creates a new `StaticModInt`.\r\n ///\r\n /// Takes [any primitive integer].\r\n ///\r\n /// Corresponds to the constructor of `atcoder::static_modint` in the original ACL.\r\n ///\r\n /// [any primitive integer]: ../trait.RemEuclidU32.html\r\n #[inline]\r\n pub fn new(val: T) -> Self {\r\n Self::raw(val.rem_euclid_u32(M::VALUE))\r\n }\r\n\r\n /// Constructs a `StaticModInt` from a `val < Self::modulus()` without checking it.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::raw` in the original ACL.\r\n ///\r\n /// # Constraints\r\n ///\r\n /// - `val` is less than `Self::modulus()`\r\n ///\r\n /// See [`ModIntBase::raw`] for more more details.\r\n ///\r\n /// [`ModIntBase::raw`]: ./trait.ModIntBase.html#tymethod.raw\r\n #[inline]\r\n pub fn raw(val: u32) -> Self {\r\n Self {\r\n val,\r\n phantom: PhantomData,\r\n }\r\n }\r\n\r\n /// Retruns the representative.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::val` in the original ACL.\r\n #[inline]\r\n pub fn val(self) -> u32 {\r\n self.val\r\n }\r\n\r\n /// Returns `self` to the power of `n`.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::pow` in the original ACL.\r\n #[inline]\r\n pub fn pow(self, n: u64) -> Self {\r\n ::pow(self, n)\r\n }\r\n\r\n /// Retruns the multiplicative inverse of `self`.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::inv` in the original ACL.\r\n ///\r\n /// # Panics\r\n ///\r\n /// Panics if the multiplicative inverse does not exist.\r\n #[inline]\r\n pub fn inv(self) -> Self {\r\n if M::HINT_VALUE_IS_PRIME {\r\n if self.val() == 0 {\r\n panic!(\"attempt to divide by zero\");\r\n }\r\n debug_assert!(\r\n internal_math::is_prime(M::VALUE.try_into().unwrap()),\r\n \"{} is not a prime number\",\r\n M::VALUE,\r\n );\r\n self.pow((M::VALUE - 2).into())\r\n } else {\r\n Self::inv_for_non_prime_modulus(self)\r\n }\r\n }\r\n }\r\n\r\n /// These methods are implemented for the struct.\r\n /// You don't need to `use` `ModIntBase` to call methods of `StaticModInt`.\r\n impl ModIntBase for StaticModInt {\r\n #[inline(always)]\r\n fn modulus() -> u32 {\r\n Self::modulus()\r\n }\r\n\r\n #[inline]\r\n fn raw(val: u32) -> Self {\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn val(self) -> u32 {\r\n self.val()\r\n }\r\n\r\n #[inline]\r\n fn inv(self) -> Self {\r\n self.inv()\r\n }\r\n }\r\n\r\n /// Represents a modulus.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// macro_rules! modulus {\r\n /// ($($name:ident($value:expr, $is_prime:expr)),*) => {\r\n /// $(\r\n /// #[derive(Copy, Clone, Eq, PartialEq)]\r\n /// enum $name {}\r\n ///\r\n /// impl ac_library_rs::modint::Modulus for $name {\r\n /// const VALUE: u32 = $value;\r\n /// const HINT_VALUE_IS_PRIME: bool = $is_prime;\r\n ///\r\n /// fn butterfly_cache() -> &'static ::std::thread::LocalKey<::std::cell::RefCell<::std::option::Option>>> {\r\n /// thread_local! {\r\n /// static BUTTERFLY_CACHE: ::std::cell::RefCell<::std::option::Option>> = ::std::default::Default::default();\r\n /// }\r\n /// &BUTTERFLY_CACHE\r\n /// }\r\n /// }\r\n /// )*\r\n /// };\r\n /// }\r\n ///\r\n /// use ac_library_rs::StaticModInt;\r\n ///\r\n /// modulus!(Mod101(101, true), Mod103(103, true));\r\n ///\r\n /// type Z101 = StaticModInt;\r\n /// type Z103 = StaticModInt;\r\n ///\r\n /// assert_eq!(Z101::new(101), Z101::new(0));\r\n /// assert_eq!(Z103::new(103), Z103::new(0));\r\n /// ```\r\n pub trait Modulus: 'static + Copy + Eq {\r\n const VALUE: u32;\r\n const HINT_VALUE_IS_PRIME: bool;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>>;\r\n }\r\n\r\n /// Represents _1000000007_.\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum Mod1000000007 {}\r\n\r\n impl Modulus for Mod1000000007 {\r\n const VALUE: u32 = 1_000_000_007;\r\n const HINT_VALUE_IS_PRIME: bool = true;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>> {\r\n thread_local! {\r\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\r\n }\r\n &BUTTERFLY_CACHE\r\n }\r\n }\r\n\r\n /// Represents _998244353_.\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum Mod998244353 {}\r\n\r\n impl Modulus for Mod998244353 {\r\n const VALUE: u32 = 998_244_353;\r\n const HINT_VALUE_IS_PRIME: bool = true;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>> {\r\n thread_local! {\r\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\r\n }\r\n &BUTTERFLY_CACHE\r\n }\r\n }\r\n\r\n /// Cache for butterfly operations.\r\n pub struct ButterflyCache {\r\n pub(crate) sum_e: Vec>,\r\n pub(crate) sum_ie: Vec>,\r\n }\r\n\r\n /// Represents where _m_ is a dynamic value.\r\n ///\r\n /// Corresponds to `atcoder::dynamic_modint` in the original ACL.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::ModInt as Mint;\r\n /// use proconio::{input, source::once::OnceSource};\r\n ///\r\n /// input! {\r\n /// from OnceSource::from(\"3 3 7\\n\"),\r\n /// a: u32,\r\n /// b: u32,\r\n /// m: u32,\r\n /// }\r\n ///\r\n /// Mint::set_modulus(m);\r\n /// let a = Mint::new(a);\r\n /// let b = Mint::new(b);\r\n ///\r\n /// println!(\"{}\", a * b); // `2`\r\n /// ```\r\n #[derive(Copy, Clone, Eq, PartialEq)]\r\n #[repr(transparent)]\r\n pub struct DynamicModInt {\r\n val: u32,\r\n phantom: PhantomData I>,\r\n }\r\n\r\n impl DynamicModInt {\r\n /// Returns the modulus.\r\n ///\r\n /// Corresponds to `atcoder::dynamic_modint::mod` in the original ACL.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::ModInt as Mint;\r\n ///\r\n /// assert_eq!(998_244_353, Mint::modulus()); // default modulus\r\n /// ```\r\n #[inline]\r\n pub fn modulus() -> u32 {\r\n I::companion_barrett().umod()\r\n }\r\n\r\n /// Sets a modulus.\r\n ///\r\n /// Corresponds to `atcoder::dynamic_modint::set_mod` in the original ACL.\r\n ///\r\n /// # Constraints\r\n ///\r\n /// - This function must be called earlier than any other operation of `Self`.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::ModInt as Mint;\r\n ///\r\n /// Mint::set_modulus(7);\r\n /// assert_eq!(7, Mint::modulus());\r\n /// ```\r\n #[inline]\r\n pub fn set_modulus(modulus: u32) {\r\n if modulus == 0 {\r\n panic!(\"the modulus must not be 0\");\r\n }\r\n I::companion_barrett().update(modulus);\r\n }\r\n\r\n /// Creates a new `DynamicModInt`.\r\n ///\r\n /// Takes [any primitive integer].\r\n ///\r\n /// Corresponds to the constructor of `atcoder::dynamic_modint` in the original ACL.\r\n ///\r\n /// [any primitive integer]: ../trait.RemEuclidU32.html\r\n #[inline]\r\n pub fn new(val: T) -> Self {\r\n ::new(val)\r\n }\r\n\r\n /// Constructs a `DynamicModInt` from a `val < Self::modulus()` without checking it.\r\n ///\r\n /// Corresponds to `atcoder::dynamic_modint::raw` in the original ACL.\r\n ///\r\n /// # Constraints\r\n ///\r\n /// - `val` is less than `Self::modulus()`\r\n ///\r\n /// See [`ModIntBase::raw`] for more more details.\r\n ///\r\n /// [`ModIntBase::raw`]: ./trait.ModIntBase.html#tymethod.raw\r\n #[inline]\r\n pub fn raw(val: u32) -> Self {\r\n Self {\r\n val,\r\n phantom: PhantomData,\r\n }\r\n }\r\n\r\n /// Retruns the representative.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::val` in the original ACL.\r\n #[inline]\r\n pub fn val(self) -> u32 {\r\n self.val\r\n }\r\n\r\n /// Returns `self` to the power of `n`.\r\n ///\r\n /// Corresponds to `atcoder::dynamic_modint::pow` in the original ACL.\r\n #[inline]\r\n pub fn pow(self, n: u64) -> Self {\r\n ::pow(self, n)\r\n }\r\n\r\n /// Retruns the multiplicative inverse of `self`.\r\n ///\r\n /// Corresponds to `atcoder::dynamic_modint::inv` in the original ACL.\r\n ///\r\n /// # Panics\r\n ///\r\n /// Panics if the multiplicative inverse does not exist.\r\n #[inline]\r\n pub fn inv(self) -> Self {\r\n Self::inv_for_non_prime_modulus(self)\r\n }\r\n }\r\n\r\n /// These methods are implemented for the struct.\r\n /// You don't need to `use` `ModIntBase` to call methods of `DynamicModInt`.\r\n impl ModIntBase for DynamicModInt {\r\n #[inline]\r\n fn modulus() -> u32 {\r\n Self::modulus()\r\n }\r\n\r\n #[inline]\r\n fn raw(val: u32) -> Self {\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn val(self) -> u32 {\r\n self.val()\r\n }\r\n\r\n #[inline]\r\n fn inv(self) -> Self {\r\n self.inv()\r\n }\r\n }\r\n\r\n pub trait Id: 'static + Copy + Eq {\r\n fn companion_barrett() -> &'static Barrett;\r\n }\r\n\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum DefaultId {}\r\n\r\n impl Id for DefaultId {\r\n fn companion_barrett() -> &'static Barrett {\r\n static BARRETT: Barrett = Barrett::default();\r\n &BARRETT\r\n }\r\n }\r\n\r\n /// Pair of _m_ and _ceil(2竅カ竅エ/m)_.\r\n pub struct Barrett {\r\n m: AtomicU32,\r\n im: AtomicU64,\r\n }\r\n\r\n impl Barrett {\r\n /// Creates a new `Barrett`.\r\n #[inline]\r\n pub const fn new(m: u32) -> Self {\r\n Self {\r\n m: AtomicU32::new(m),\r\n im: AtomicU64::new((-1i64 as u64 / m as u64).wrapping_add(1)),\r\n }\r\n }\r\n\r\n #[inline]\r\n const fn default() -> Self {\r\n Self::new(998_244_353)\r\n }\r\n\r\n #[inline]\r\n fn update(&self, m: u32) {\r\n let im = (-1i64 as u64 / m as u64).wrapping_add(1);\r\n self.m.store(m, atomic::Ordering::SeqCst);\r\n self.im.store(im, atomic::Ordering::SeqCst);\r\n }\r\n\r\n #[inline]\r\n fn umod(&self) -> u32 {\r\n self.m.load(atomic::Ordering::SeqCst)\r\n }\r\n\r\n #[inline]\r\n fn mul(&self, a: u32, b: u32) -> u32 {\r\n let m = self.m.load(atomic::Ordering::SeqCst);\r\n let im = self.im.load(atomic::Ordering::SeqCst);\r\n internal_math::mul_mod(a, b, m, im)\r\n }\r\n }\r\n\r\n impl Default for Barrett {\r\n #[inline]\r\n fn default() -> Self {\r\n Self::default()\r\n }\r\n }\r\n\r\n /// A trait for [`StaticModInt`] and [`DynamicModInt`].\r\n ///\r\n /// Corresponds to `atcoder::internal::modint_base` in the original ACL.\r\n ///\r\n /// [`StaticModInt`]: ../struct.StaticModInt.html\r\n /// [`DynamicModInt`]: ../struct.DynamicModInt.html\r\n pub trait ModIntBase:\r\n Default\r\n + FromStr\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + Copy\r\n + Eq\r\n + Hash\r\n + fmt::Display\r\n + fmt::Debug\r\n + Neg\r\n + Add\r\n + Sub\r\n + Mul\r\n + Div\r\n + AddAssign\r\n + SubAssign\r\n + MulAssign\r\n + DivAssign\r\n {\r\n /// Returns the modulus.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::mod` and `atcoder::dynamic_modint::mod` in the original ACL.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::modint::ModIntBase;\r\n ///\r\n /// fn f() {\r\n /// let _: u32 = Z::modulus();\r\n /// }\r\n /// ```\r\n fn modulus() -> u32;\r\n\r\n /// Constructs a `Self` from a `val < Self::modulus()` without checking it.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::raw` and `atcoder::dynamic_modint::raw` in the original ACL.\r\n ///\r\n /// # Constraints\r\n ///\r\n /// - `val` is less than `Self::modulus()`\r\n ///\r\n /// **Note that all operations assume that inner values are smaller than the modulus.**\r\n /// If `val` is greater than or equal to `Self::modulus()`, the behaviors are not defined.\r\n ///\r\n /// ```should_panic\r\n /// use ac_library_rs::ModInt1000000007 as Mint;\r\n ///\r\n /// let x = Mint::raw(1_000_000_007);\r\n /// let y = x + x;\r\n /// assert_eq!(0, y.val());\r\n /// ```\r\n ///\r\n /// ```text\r\n /// thread 'main' panicked at 'assertion failed: `(left == right)`\r\n /// left: `0`,\r\n /// right: `1000000007`', src/modint.rs:8:1\r\n /// note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\r\n /// ```\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::modint::ModIntBase;\r\n ///\r\n /// fn f() -> Z {\r\n /// debug_assert!(Z::modulus() >= 100);\r\n ///\r\n /// let mut acc = Z::new(0);\r\n /// for i in 0..100 {\r\n /// if i % 3 == 0 {\r\n /// // I know `i` is smaller than the modulus!\r\n /// acc += Z::raw(i);\r\n /// }\r\n /// }\r\n /// acc\r\n /// }\r\n /// ```\r\n fn raw(val: u32) -> Self;\r\n\r\n /// Retruns the representative.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::val` and `atcoder::dynamic_modint::val` in the original ACL.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::modint::ModIntBase;\r\n ///\r\n /// fn f(x: Z) {\r\n /// let _: u32 = x.val();\r\n /// }\r\n /// ```\r\n fn val(self) -> u32;\r\n\r\n /// Retruns the multiplicative inverse of `self`.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::inv` and `atcoder::dynamic_modint::inv` in the original ACL.\r\n ///\r\n /// # Panics\r\n ///\r\n /// Panics if the multiplicative inverse does not exist.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::modint::ModIntBase;\r\n ///\r\n /// fn f(x: Z) {\r\n /// let _: Z = x.inv();\r\n /// }\r\n /// ```\r\n fn inv(self) -> Self;\r\n\r\n /// Creates a new `Self`.\r\n ///\r\n /// Takes [any primitive integer].\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::modint::ModIntBase;\r\n ///\r\n /// fn f() {\r\n /// let _ = Z::new(1u32);\r\n /// let _ = Z::new(1usize);\r\n /// let _ = Z::new(-1i64);\r\n /// }\r\n /// ```\r\n ///\r\n /// [any primitive integer]: ../trait.RemEuclidU32.html\r\n #[inline]\r\n fn new(val: T) -> Self {\r\n Self::raw(val.rem_euclid_u32(Self::modulus()))\r\n }\r\n\r\n /// Returns `self` to the power of `n`.\r\n ///\r\n /// Corresponds to `atcoder::static_modint::pow` and `atcoder::dynamic_modint::pow` in the original ACL.\r\n ///\r\n /// # Example\r\n ///\r\n /// ```\r\n /// use ac_library_rs::modint::ModIntBase;\r\n ///\r\n /// fn f() {\r\n /// let _: Z = Z::new(2).pow(3);\r\n /// }\r\n /// ```\r\n #[inline]\r\n fn pow(self, mut n: u64) -> Self {\r\n let mut x = self;\r\n let mut r = Self::raw(1);\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n r *= x;\r\n }\r\n x *= x;\r\n n >>= 1;\r\n }\r\n r\r\n }\r\n }\r\n\r\n /// A trait for `{StaticModInt, DynamicModInt, ModIntBase}::new`.\r\n pub trait RemEuclidU32 {\r\n /// Calculates `self` _mod_ `modulus` losslessly.\r\n fn rem_euclid_u32(self, modulus: u32) -> u32;\r\n }\r\n\r\n macro_rules! impl_rem_euclid_u32_for_small_signed {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n (self as i64).rem_euclid(i64::from(modulus)) as _\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n impl_rem_euclid_u32_for_small_signed!(i8, i16, i32, i64, isize);\r\n\r\n impl RemEuclidU32 for i128 {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n self.rem_euclid(i128::from(modulus)) as _\r\n }\r\n }\r\n\r\n macro_rules! impl_rem_euclid_u32_for_small_unsigned {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n self as u32 % modulus\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n macro_rules! impl_rem_euclid_u32_for_large_unsigned {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n (self % (modulus as $ty)) as _\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n impl_rem_euclid_u32_for_small_unsigned!(u8, u16, u32);\r\n impl_rem_euclid_u32_for_large_unsigned!(u64, u128);\r\n\r\n #[cfg(target_pointer_width = \"32\")]\r\n impl_rem_euclid_u32_for_small_unsigned!(usize);\r\n\r\n #[cfg(target_pointer_width = \"64\")]\r\n impl_rem_euclid_u32_for_large_unsigned!(usize);\r\n\r\n trait InternalImplementations: ModIntBase {\r\n #[inline]\r\n fn inv_for_non_prime_modulus(this: Self) -> Self {\r\n let (gcd, x) = internal_math::inv_gcd(this.val().into(), Self::modulus().into());\r\n if gcd != 1 {\r\n panic!(\"the multiplicative inverse does not exist\");\r\n }\r\n Self::new(x)\r\n }\r\n\r\n #[inline]\r\n fn default_impl() -> Self {\r\n Self::raw(0)\r\n }\r\n\r\n #[inline]\r\n fn from_str_impl(s: &str) -> Result {\r\n Ok(s.parse::()\r\n .map(Self::new)\r\n .unwrap_or_else(|_| todo!(\"parsing as an arbitrary precision integer?\")))\r\n }\r\n\r\n #[inline]\r\n fn hash_impl(this: &Self, state: &mut impl Hasher) {\r\n this.val().hash(state)\r\n }\r\n\r\n #[inline]\r\n fn display_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\r\n fmt::Display::fmt(&this.val(), f)\r\n }\r\n\r\n #[inline]\r\n fn debug_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\r\n fmt::Debug::fmt(&this.val(), f)\r\n }\r\n\r\n #[inline]\r\n fn neg_impl(this: Self) -> Self {\r\n Self::sub_impl(Self::raw(0), this)\r\n }\r\n\r\n #[inline]\r\n fn add_impl(lhs: Self, rhs: Self) -> Self {\r\n let modulus = Self::modulus();\r\n let mut val = lhs.val() + rhs.val();\r\n if val >= modulus {\r\n val -= modulus;\r\n }\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn sub_impl(lhs: Self, rhs: Self) -> Self {\r\n let modulus = Self::modulus();\r\n let mut val = lhs.val().wrapping_sub(rhs.val());\r\n if val >= modulus {\r\n val = val.wrapping_add(modulus)\r\n }\r\n Self::raw(val)\r\n }\r\n\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self;\r\n\r\n #[inline]\r\n fn div_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::mul_impl(lhs, rhs.inv())\r\n }\r\n }\r\n\r\n impl InternalImplementations for StaticModInt {\r\n #[inline]\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::raw((u64::from(lhs.val()) * u64::from(rhs.val()) % u64::from(M::VALUE)) as u32)\r\n }\r\n }\r\n\r\n impl InternalImplementations for DynamicModInt {\r\n #[inline]\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::raw(I::companion_barrett().mul(lhs.val, rhs.val))\r\n }\r\n }\r\n\r\n macro_rules! impl_basic_traits {\r\n () => {};\r\n (impl <$generic_param:ident : $generic_param_bound:tt> _ for $self:ty; $($rest:tt)*) => {\r\n impl <$generic_param: $generic_param_bound> Default for $self {\r\n #[inline]\r\n fn default() -> Self {\r\n Self::default_impl()\r\n }\r\n }\r\n\r\n impl <$generic_param: $generic_param_bound> FromStr for $self {\r\n type Err = Infallible;\r\n\r\n #[inline]\r\n fn from_str(s: &str) -> Result {\r\n Self::from_str_impl(s)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound, V: RemEuclidU32> From for $self {\r\n #[inline]\r\n fn from(from: V) -> Self {\r\n Self::new(from)\r\n }\r\n }\r\n\r\n #[allow(clippy::derive_hash_xor_eq)]\r\n impl<$generic_param: $generic_param_bound> Hash for $self {\r\n #[inline]\r\n fn hash(&self, state: &mut H) {\r\n Self::hash_impl(self, state)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> fmt::Display for $self {\r\n #[inline]\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n Self::display_impl(self, f)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> fmt::Debug for $self {\r\n #[inline]\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n Self::debug_impl(self, f)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> Neg for $self {\r\n type Output = $self;\r\n\r\n #[inline]\r\n fn neg(self) -> $self {\r\n Self::neg_impl(self)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> Neg for &'_ $self {\r\n type Output = $self;\r\n\r\n #[inline]\r\n fn neg(self) -> $self {\r\n <$self>::neg_impl(*self)\r\n }\r\n }\r\n\r\n impl_basic_traits!($($rest)*);\r\n };\r\n}\r\n\r\n impl_basic_traits! {\r\n impl _ for StaticModInt ;\r\n impl _ for DynamicModInt;\r\n }\r\n\r\n macro_rules! impl_bin_ops {\r\n () => {};\r\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~ <$rhs_ty:ty> -> $output:ty { { $lhs_body:expr } ~ { $rhs_body:expr } } $($rest:tt)*) => {\r\n impl <$($generic_param: $generic_param_bound),*> Add<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn add(self, rhs: $rhs_ty) -> $output {\r\n <$output>::add_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Sub<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn sub(self, rhs: $rhs_ty) -> $output {\r\n <$output>::sub_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Mul<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn mul(self, rhs: $rhs_ty) -> $output {\r\n <$output>::mul_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Div<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn div(self, rhs: $rhs_ty) -> $output {\r\n <$output>::div_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl_bin_ops!($($rest)*);\r\n };\r\n}\r\n\r\n macro_rules! impl_assign_ops {\r\n () => {};\r\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~= <$rhs_ty:ty> { _ ~= { $rhs_body:expr } } $($rest:tt)*) => {\r\n impl <$($generic_param: $generic_param_bound),*> AddAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn add_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self + apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> SubAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn sub_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self - apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> MulAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn mul_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self * apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> DivAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn div_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self / apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl_assign_ops!($($rest)*);\r\n };\r\n}\r\n\r\n #[inline]\r\n fn apply O, X, O>(f: F, x: X) -> O {\r\n f(x)\r\n }\r\n\r\n impl_bin_ops! {\r\n for > ~ > -> StaticModInt { { |x| x } ~ { |x| x } }\r\n for > ~ <&'_ StaticModInt > -> StaticModInt { { |x| x } ~ { |&x| x } }\r\n for <&'_ StaticModInt > ~ > -> StaticModInt { { |&x| x } ~ { |x| x } }\r\n for <&'_ StaticModInt > ~ <&'_ StaticModInt > -> StaticModInt { { |&x| x } ~ { |&x| x } }\r\n for > ~ > -> DynamicModInt { { |x| x } ~ { |x| x } }\r\n for > ~ <&'_ DynamicModInt> -> DynamicModInt { { |x| x } ~ { |&x| x } }\r\n for <&'_ DynamicModInt> ~ > -> DynamicModInt { { |&x| x } ~ { |x| x } }\r\n for <&'_ DynamicModInt> ~ <&'_ DynamicModInt> -> DynamicModInt { { |&x| x } ~ { |&x| x } }\r\n\r\n for > ~ -> StaticModInt { { |x| x } ~ { StaticModInt::::new } }\r\n for > ~ -> DynamicModInt { { |x| x } ~ { DynamicModInt::::new } }\r\n }\r\n\r\n impl_assign_ops! {\r\n for > ~= > { _ ~= { |x| x } }\r\n for > ~= <&'_ StaticModInt > { _ ~= { |&x| x } }\r\n for > ~= > { _ ~= { |x| x } }\r\n for > ~= <&'_ DynamicModInt> { _ ~= { |&x| x } }\r\n\r\n for > ~= { _ ~= { StaticModInt::::new } }\r\n for > ~= { _ ~= { DynamicModInt::::new } }\r\n }\r\n\r\n macro_rules! impl_folding {\r\n () => {};\r\n (impl<$generic_param:ident : $generic_param_bound:tt> $trait:ident<_> for $self:ty { fn $method:ident(_) -> _ { _($unit:expr, $op:expr) } } $($rest:tt)*) => {\r\n impl<$generic_param: $generic_param_bound> $trait for $self {\r\n #[inline]\r\n fn $method(iter: S) -> Self\r\n where\r\n S: Iterator,\r\n {\r\n iter.fold($unit, $op)\r\n }\r\n }\r\n\r\n impl<'a, $generic_param: $generic_param_bound> $trait<&'a Self> for $self {\r\n #[inline]\r\n fn $method(iter: S) -> Self\r\n where\r\n S: Iterator,\r\n {\r\n iter.fold($unit, $op)\r\n }\r\n }\r\n\r\n impl_folding!($($rest)*);\r\n };\r\n}\r\n\r\n impl_folding! {\r\n impl Sum<_> for StaticModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\r\n impl Product<_> for StaticModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\r\n impl Sum<_> for DynamicModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\r\n impl Product<_> for DynamicModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\r\n }\r\n\r\n #[cfg(test)]\r\n mod tests {\r\n use crate::modint::ModInt1000000007;\r\n\r\n #[test]\r\n fn static_modint_new() {\r\n assert_eq!(0, ModInt1000000007::new(0u32).val);\r\n assert_eq!(1, ModInt1000000007::new(1u32).val);\r\n assert_eq!(1, ModInt1000000007::new(1_000_000_008u32).val);\r\n\r\n assert_eq!(0, ModInt1000000007::new(0u64).val);\r\n assert_eq!(1, ModInt1000000007::new(1u64).val);\r\n assert_eq!(1, ModInt1000000007::new(1_000_000_008u64).val);\r\n\r\n assert_eq!(0, ModInt1000000007::new(0usize).val);\r\n assert_eq!(1, ModInt1000000007::new(1usize).val);\r\n assert_eq!(1, ModInt1000000007::new(1_000_000_008usize).val);\r\n\r\n assert_eq!(0, ModInt1000000007::new(0i64).val);\r\n assert_eq!(1, ModInt1000000007::new(1i64).val);\r\n assert_eq!(1, ModInt1000000007::new(1_000_000_008i64).val);\r\n assert_eq!(1_000_000_006, ModInt1000000007::new(-1i64).val);\r\n }\r\n\r\n #[test]\r\n fn static_modint_add() {\r\n fn add(lhs: u32, rhs: u32) -> u32 {\r\n (ModInt1000000007::new(lhs) + ModInt1000000007::new(rhs)).val\r\n }\r\n\r\n assert_eq!(2, add(1, 1));\r\n assert_eq!(1, add(1_000_000_006, 2));\r\n }\r\n\r\n #[test]\r\n fn static_modint_sub() {\r\n fn sub(lhs: u32, rhs: u32) -> u32 {\r\n (ModInt1000000007::new(lhs) - ModInt1000000007::new(rhs)).val\r\n }\r\n\r\n assert_eq!(1, sub(2, 1));\r\n assert_eq!(1_000_000_006, sub(0, 1));\r\n }\r\n\r\n #[test]\r\n fn static_modint_mul() {\r\n fn mul(lhs: u32, rhs: u32) -> u32 {\r\n (ModInt1000000007::new(lhs) * ModInt1000000007::new(rhs)).val\r\n }\r\n\r\n assert_eq!(1, mul(1, 1));\r\n assert_eq!(4, mul(2, 2));\r\n assert_eq!(999_999_937, mul(100_000, 100_000));\r\n }\r\n\r\n #[test]\r\n fn static_modint_prime_div() {\r\n fn div(lhs: u32, rhs: u32) -> u32 {\r\n (ModInt1000000007::new(lhs) / ModInt1000000007::new(rhs)).val\r\n }\r\n\r\n assert_eq!(0, div(0, 1));\r\n assert_eq!(1, div(1, 1));\r\n assert_eq!(1, div(2, 2));\r\n assert_eq!(23_809_524, div(1, 42));\r\n }\r\n\r\n #[test]\r\n fn static_modint_sum() {\r\n fn sum(values: &[i64]) -> ModInt1000000007 {\r\n values.iter().copied().map(ModInt1000000007::new).sum()\r\n }\r\n\r\n assert_eq!(ModInt1000000007::new(-3), sum(&[-1, 2, -3, 4, -5]));\r\n }\r\n\r\n #[test]\r\n fn static_modint_product() {\r\n fn product(values: &[i64]) -> ModInt1000000007 {\r\n values.iter().copied().map(ModInt1000000007::new).product()\r\n }\r\n\r\n assert_eq!(ModInt1000000007::new(-120), product(&[-1, 2, -3, 4, -5]));\r\n }\r\n\r\n #[test]\r\n fn static_modint_binop_coercion() {\r\n let f = ModInt1000000007::new;\r\n let a = 10_293_812_usize;\r\n let b = 9_083_240_982_usize;\r\n assert_eq!(f(a) + f(b), f(a) + b);\r\n assert_eq!(f(a) - f(b), f(a) - b);\r\n assert_eq!(f(a) * f(b), f(a) * b);\r\n assert_eq!(f(a) / f(b), f(a) / b);\r\n }\r\n\r\n #[test]\r\n fn static_modint_assign_coercion() {\r\n let f = ModInt1000000007::new;\r\n let a = f(10_293_812_usize);\r\n let b = 9_083_240_982_usize;\r\n let expected = (((a + b) * b) - b) / b;\r\n let mut c = a;\r\n c += b;\r\n c *= b;\r\n c -= b;\r\n c /= b;\r\n assert_eq!(expected, c);\r\n }\r\n }\r\n}\r\nuse modint::ModInt1000000007 as mint;\r\nuse modint::*;\r\n\r\npub struct Combination {\r\n fact: Vec,\r\n ifact: Vec,\r\n}\r\nimpl Combination {\r\n pub fn new(n: i32) -> Self {\r\n let mut fact = vec![mint::new(0); (n + 1) as usize];\r\n let mut ifact = vec![mint::new(0); (n + 1) as usize];\r\n fact[0] = mint::new(1);\r\n for i in 1..n + 1 {\r\n fact[i as usize] = fact[(i - 1) as usize] * mint::new(i as i64)\r\n }\r\n ifact[n as usize] = fact[n as usize].inv();\r\n for i in (1..n + 1).rev() {\r\n ifact[(i - 1) as usize] = ifact[i as usize] * mint::new(i as i64)\r\n }\r\n let a = Combination {\r\n fact: fact,\r\n ifact: ifact,\r\n };\r\n return a;\r\n }\r\n #[macro_use]\r\n pub fn gen(&mut self, n: i32, k: i32) -> mint {\r\n if (k < 0 || k > n) {\r\n return mint::new(0 as i64);\r\n };\r\n return self.fact[n as usize] * self.ifact[k as usize] * self.ifact[(n - k) as usize];\r\n }\r\n pub fn P(&mut self, n: i32, k: i32) -> mint {\r\n self.fact[n as usize] * self.ifact[(n - k) as usize]\r\n }\r\n}\r\n\r\nfn main() {\r\n let T = get!(usize);\r\n let mut cmb = Combination::new(2 * 100000 + 10);\r\n\r\n for testcase in 0..T {\r\n mydbg!(testcase);\r\n let mut ans: mint = mint::new(0);\r\n let (N, K) = get!(usize, usize);\r\n\r\n let mut E = mint::new(1);\r\n for i in 1.. {\r\n let k = i * 2;\r\n if k > N {\r\n break;\r\n }\r\n E += cmb.gen(N as i32, k as i32);\r\n }\r\n\r\n mydbg!(E);\r\n\r\n let mut dp = vec![vec![mint::new(0); 3]; K + 1];\r\n dp[0][0] = mint::new(1);\r\n for i in 0..K {\r\n for j in 0..2 {\r\n if dp[i][j] == mint::new(0) {\r\n continue;\r\n }\r\n if j == 0 {\r\n //1\r\n if N % 2 == 1 {\r\n dp[i + 1][j + 1] = dp[i + 1][j + 1] + dp[i][j];\r\n }\r\n\r\n //0\r\n dp[i + 1][j] = dp[i + 1][j] + dp[i][j] * E;\r\n } else {\r\n dp[i + 1][j] = dp[i + 1][j] + dp[i][j] * mint::new(2).pow(N as u64);\r\n }\r\n }\r\n }\r\n\r\n echo!(dp[K][0] + dp[K][1]);\r\n }\r\n}\r\n", "lang": "Rust", "bug_code_uid": "7ffe92b351a7672fe162b5ac24fa4ecc", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "apr_id": "73c8394ce2074345ced9c20141713e8f", "difficulty": 1700, "tags": ["dp", "combinatorics", "matrices", "bitmasks", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9967802067446195, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "/*\r\n date : 2021 / 4 / 7\r\n author : quickn (quickn.tech)\r\n email : quickwshell@gmail.com\r\n*/\r\n\r\nuse std::io::{self, BufWriter, Write};\r\n\r\nmod scanner {\r\n use std::{io, str};\r\n /* https://github.com/EbTech/rust-algorithms */\r\n\r\n /// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts\r\n /// **REQUIRES** Rust 1.34 or higher\r\n pub struct UnsafeScanner {\r\n reader: R,\r\n buf_str: Vec,\r\n buf_iter: str::SplitAsciiWhitespace<'static>,\r\n }\r\n\r\n impl UnsafeScanner {\r\n pub fn new(reader: R) -> Self {\r\n Self {\r\n reader,\r\n buf_str: Vec::new(),\r\n buf_iter: \"\".split_ascii_whitespace(),\r\n }\r\n }\r\n\r\n /// This function should be marked unsafe, but noone has time for that in a\r\n /// programming contest. Use at your own risk!\r\n pub fn token(&mut self) -> T {\r\n loop {\r\n if let Some(token) = self.buf_iter.next() {\r\n return token.parse().ok().expect(\"Failed parse\");\r\n }\r\n self.buf_str.clear();\r\n self.reader\r\n .read_until(b'\\n', &mut self.buf_str)\r\n .expect(\"Failed read\");\r\n self.buf_iter = unsafe {\r\n let slice = str::from_utf8_unchecked(&self.buf_str);\r\n std::mem::transmute(slice.split_ascii_whitespace())\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nuse std::cmp::{min, max};\r\n\r\nfn s2vec(s: String) -> Vec {\r\n s.chars().collect()\r\n}\r\n\r\nconst MOD: i64 = 1000000007;\r\n\r\nfn pow_mod(a: i64, x: i64) -> i64 {\r\n let (mut a_t, mut x_t, mut r) = (a, x, 1);\r\n while x_t > 0 {\r\n if x_t % 2 == 1 {\r\n r *= a_t;\r\n r %= MOD;\r\n }\r\n a_t *= a_t;\r\n a_t %= MOD;\r\n x_t /= 2;\r\n }\r\n r\r\n}\r\n\r\nfn main() {\r\n let (stdin, stdout) = (io::stdin(), io::stdout());\r\n let (mut scan, mut sout) = (\r\n scanner::UnsafeScanner::new(stdin.lock()),\r\n BufWriter::new(stdout.lock()),\r\n );\r\n let t: usize = scan.token();\r\n for _case in 0..t {\r\n let (n, k): (usize, usize) = (scan.token(), scan.token());\r\n if k > 0 {\r\n let mut dp: Vec> = vec![vec![0;2];k+1];\r\n dp[1][0] = pow_mod(2, (n-1) as i64) - if n % 2 == 0 { 1 } else { 0 };\r\n dp[1][1] = 1;\r\n for i in 2..=k {\r\n dp[i][0] = (((dp[i-1][0] + dp[i-1][1])%MOD)*(pow_mod(2, (n-1) as i64) - if n % 2 == 0 { 1 } else { 0 }))%MOD;\r\n if n % 2 == 0 {\r\n dp[i][1] = pow_mod(2, (n as i64)*((i-1) as i64));\r\n } else {\r\n dp[i][1] = dp[i-1][1];\r\n }\r\n }\r\n writeln!(sout, \"{}\", (dp[k][0] + dp[k][1])%MOD).ok();\r\n } else {\r\n writeln!(sout, \"1\").ok();\r\n }\r\n }\r\n}\r\n", "lang": "Rust", "bug_code_uid": "052d8d193dee37d6c6aefc27d353caa3", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "apr_id": "93682060628cabd1bbb6fa2820102998", "difficulty": 1700, "tags": ["dp", "combinatorics", "matrices", "bitmasks", "math"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9995641277105808, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "// ---------- begin ModInt ----------\r\nmod modint {\r\n\r\n #[allow(dead_code)]\r\n pub struct Mod;\r\n impl ConstantModulo for Mod {\r\n const MOD: u32 = 1_000_000_007;\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub struct StaticMod;\r\n static mut STATIC_MOD: u32 = 0;\r\n impl Modulo for StaticMod {\r\n fn modulo() -> u32 {\r\n unsafe { STATIC_MOD }\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl StaticMod {\r\n pub fn set_modulo(p: u32) {\r\n unsafe {\r\n STATIC_MOD = p;\r\n }\r\n }\r\n }\r\n\r\n use std::marker::*;\r\n use std::ops::*;\r\n\r\n pub trait Modulo {\r\n fn modulo() -> u32;\r\n }\r\n\r\n pub trait ConstantModulo {\r\n const MOD: u32;\r\n }\r\n\r\n impl Modulo for T\r\n where\r\n T: ConstantModulo,\r\n {\r\n fn modulo() -> u32 {\r\n T::MOD\r\n }\r\n }\r\n\r\n pub struct ModInt(pub u32, PhantomData);\r\n\r\n impl Clone for ModInt {\r\n fn clone(&self) -> Self {\r\n ModInt::new_unchecked(self.0)\r\n }\r\n }\r\n\r\n impl Copy for ModInt {}\r\n\r\n impl Add for ModInt {\r\n type Output = ModInt;\r\n fn add(self, rhs: Self) -> Self::Output {\r\n let mut d = self.0 + rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl AddAssign for ModInt {\r\n fn add_assign(&mut self, rhs: Self) {\r\n *self = *self + rhs;\r\n }\r\n }\r\n\r\n impl Sub for ModInt {\r\n type Output = ModInt;\r\n fn sub(self, rhs: Self) -> Self::Output {\r\n let mut d = T::modulo() + self.0 - rhs.0;\r\n if d >= T::modulo() {\r\n d -= T::modulo();\r\n }\r\n ModInt::new_unchecked(d)\r\n }\r\n }\r\n\r\n impl SubAssign for ModInt {\r\n fn sub_assign(&mut self, rhs: Self) {\r\n *self = *self - rhs;\r\n }\r\n }\r\n\r\n impl Mul for ModInt {\r\n type Output = ModInt;\r\n fn mul(self, rhs: Self) -> Self::Output {\r\n let v = self.0 as u64 * rhs.0 as u64 % T::modulo() as u64;\r\n ModInt::new_unchecked(v as u32)\r\n }\r\n }\r\n\r\n impl MulAssign for ModInt {\r\n fn mul_assign(&mut self, rhs: Self) {\r\n *self = *self * rhs;\r\n }\r\n }\r\n\r\n impl Neg for ModInt {\r\n type Output = ModInt;\r\n fn neg(self) -> Self::Output {\r\n if self.0 == 0 {\r\n Self::zero()\r\n } else {\r\n Self::new_unchecked(T::modulo() - self.0)\r\n }\r\n }\r\n }\r\n\r\n impl std::fmt::Display for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::fmt::Debug for ModInt {\r\n fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n }\r\n\r\n impl std::str::FromStr for ModInt {\r\n type Err = std::num::ParseIntError;\r\n fn from_str(s: &str) -> Result {\r\n let val = s.parse::()?;\r\n Ok(ModInt::new(val))\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: usize) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as usize) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: u64) -> ModInt {\r\n ModInt::new_unchecked((val % T::modulo() as u64) as u32)\r\n }\r\n }\r\n\r\n impl From for ModInt {\r\n fn from(val: i64) -> ModInt {\r\n let m = T::modulo() as i64;\r\n ModInt::new((val % m + m) as u32)\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new_unchecked(d: u32) -> Self {\r\n ModInt(d, PhantomData)\r\n }\r\n pub fn zero() -> Self {\r\n ModInt::new_unchecked(0)\r\n }\r\n pub fn one() -> Self {\r\n ModInt::new_unchecked(1)\r\n }\r\n pub fn is_zero(&self) -> bool {\r\n self.0 == 0\r\n }\r\n }\r\n\r\n #[allow(dead_code)]\r\n impl ModInt {\r\n pub fn new(d: u32) -> Self {\r\n ModInt::new_unchecked(d % T::modulo())\r\n }\r\n pub fn pow(&self, mut n: u64) -> Self {\r\n let mut t = Self::one();\r\n let mut s = *self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n t *= s;\r\n }\r\n s *= s;\r\n n >>= 1;\r\n }\r\n t\r\n }\r\n pub fn inv(&self) -> Self {\r\n assert!(self.0 != 0);\r\n self.pow(T::modulo() as u64 - 2)\r\n }\r\n }\r\n}\r\n// ---------- end ModInt ----------\r\n// ---------- begin Precalc ----------\r\nmod precalc {\r\n use super::modint::*;\r\n #[allow(dead_code)]\r\n pub struct Precalc {\r\n inv: Vec>,\r\n fact: Vec>,\r\n ifact: Vec>,\r\n }\r\n #[allow(dead_code)]\r\n impl Precalc {\r\n pub fn new(n: usize) -> Precalc {\r\n let mut inv = vec![ModInt::one(); n + 1];\r\n let mut fact = vec![ModInt::one(); n + 1];\r\n let mut ifact = vec![ModInt::one(); n + 1];\r\n for i in 2..(n + 1) {\r\n fact[i] = fact[i - 1] * ModInt::new_unchecked(i as u32);\r\n }\r\n ifact[n] = fact[n].inv();\r\n if n > 0 {\r\n inv[n] = ifact[n] * fact[n - 1];\r\n }\r\n for i in (1..n).rev() {\r\n ifact[i] = ifact[i + 1] * ModInt::new_unchecked((i + 1) as u32);\r\n inv[i] = ifact[i] * fact[i - 1];\r\n }\r\n Precalc {\r\n inv: inv,\r\n fact: fact,\r\n ifact: ifact,\r\n }\r\n }\r\n pub fn inv(&self, n: usize) -> ModInt {\r\n assert!(n > 0);\r\n self.inv[n]\r\n }\r\n pub fn fact(&self, n: usize) -> ModInt {\r\n self.fact[n]\r\n }\r\n pub fn ifact(&self, n: usize) -> ModInt {\r\n self.ifact[n]\r\n }\r\n pub fn perm(&self, n: usize, k: usize) -> ModInt {\r\n if k > n {\r\n return ModInt::zero();\r\n }\r\n self.fact[n] * self.ifact[n - k]\r\n }\r\n pub fn comb(&self, n: usize, k: usize) -> ModInt {\r\n if k > n {\r\n return ModInt::zero();\r\n }\r\n self.fact[n] * self.ifact[k] * self.ifact[n - k]\r\n }\r\n }\r\n}\r\n// ---------- end Precalc ----------\r\n\r\nuse modint::*;\r\ntype M = ModInt;\r\n\r\n// ---------- begin input macro ----------\r\n// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8\r\nmacro_rules! input {\r\n (source = $s:expr, $($r:tt)*) => {\r\n let mut iter = $s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n ($($r:tt)*) => {\r\n let s = {\r\n use std::io::Read;\r\n let mut s = String::new();\r\n std::io::stdin().read_to_string(&mut s).unwrap();\r\n s\r\n };\r\n let mut iter = s.split_whitespace();\r\n input_inner!{iter, $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! input_inner {\r\n ($iter:expr) => {};\r\n ($iter:expr, ) => {};\r\n ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {\r\n let $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n ($iter:expr, bytes) => {\r\n read_value!($iter, String).bytes().collect::>()\r\n };\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n// ---------- end input macro ----------\r\n\r\nfn run() {\r\n input! {\r\n n: usize,\r\n m: u32,\r\n }\r\n StaticMod::set_modulo(m);\r\n let pc = precalc::Precalc::new(n);\r\n let mut pow = vec![M::one(); n + 1];\r\n let two = M::new(2);\r\n for i in 1..=n {\r\n pow[i] = pow[i - 1] * two;\r\n }\r\n // dp[a][b]: 最後の空白がa, b個置いた\r\n let mut dp = vec![vec![M::zero(); n + 2]; n + 2];\r\n dp[0][0] = M::one();\r\n for i in 0..=(n + 1) {\r\n for j in 0..=i {\r\n let way = dp[i][j];\r\n if way.is_zero() {\r\n continue;\r\n }\r\n for k in 1..=(n - i) {\r\n dp[i + k + 1][j + k] += pow[k - 1] * way * pc.comb(j + k, j);\r\n }\r\n }\r\n }\r\n let mut ans = M::zero();\r\n for dp in dp[n + 1].iter() {\r\n ans += *dp;\r\n }\r\n println!(\"{}\", ans);\r\n}\r\n\r\nfn main() {\r\n run();\r\n}\r\n", "lang": "Rust", "bug_code_uid": "e90856b2d59b2874f0929b4ff2e974ff", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "apr_id": "7150554216d1a9757b13defdf77686c3", "difficulty": 2200, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.5149700598802395, "equal_cnt": 9, "replace_cnt": 5, "delete_cnt": 1, "insert_cnt": 2, "fix_ops_cnt": 8, "bug_source_code": "use std::io::stdin;\n\nfn main() {\n let stdin = stdin();\n let mut string = String::new();\n\n stdin.read_line(&mut string).unwrap();\n\n let n = string.trim().parse::().unwrap();\n\n let nodes = 2u128.pow(n as u32) - 2;\n let mut re = 1;\n\n for _ in 0..nodes {\n re = re * 4;\n while re > (1e9 as u128 + 7) {\n re = re % (1e9 as u128 + 7)\n }\n }\n\n println!(\"{}\", re * 6 % (1e9 as u128 + 7))\n}\n", "lang": "Rust", "bug_code_uid": "f5d0ab0dbe0cb4ba92aadc1e0dbb8025", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "apr_id": "3a1fac4d14f05bd78761d0be9ac57fe6", "difficulty": 1300, "tags": ["math", "combinatorics"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.8773642464917633, "equal_cnt": 10, "replace_cnt": 1, "delete_cnt": 3, "insert_cnt": 6, "fix_ops_cnt": 10, "bug_source_code": "#![feature(int_log)]\nuse std::io::stdin;\n\nfn main() {\n let stdin = stdin();\n let mut string = String::new();\n\n stdin.read_line(&mut string).unwrap();\n\n let n = string.trim().parse::().unwrap();\n\n let mut nodes = 2u128.pow(n as u32) - 2;\n let mut re = 1;\n loop{\n let mut inner_re = 4;\n if nodes == 0{\n break;\n }\n\n let times = nodes.log2();\n for _ in 0..times{\n inner_re = inner_re * inner_re;\n if inner_re > (1e9 as u128 + 7){\n inner_re = inner_re% (1e9 as u128 + 7)\n }\n }\n\n re = re * inner_re % (1e9 as u128 + 7);\n nodes = nodes - 2u128.pow(times);\n }\n println!(\"{}\", re * 6 % (1e9 as u128 + 7))\n}\n", "lang": "Rust", "bug_code_uid": "fe3ca22504dba410fc3a1901a7b3f14b", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "apr_id": "3a1fac4d14f05bd78761d0be9ac57fe6", "difficulty": 1300, "tags": ["math", "combinatorics"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8993407190919595, "equal_cnt": 33, "replace_cnt": 14, "delete_cnt": 9, "insert_cnt": 9, "fix_ops_cnt": 32, "bug_source_code": "#![allow(unused_parens)]\r\n#![allow(unused_imports)]\r\n#![allow(non_upper_case_globals)]\r\n#![allow(non_snake_case)]\r\n#![allow(unused_mut)]\r\n#![allow(unused_variables)]\r\n#![allow(dead_code)]\r\n\r\ntype Vec2 = Vec>;\r\ntype Vec3 = Vec>>;\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! invec {\r\n ( $ t : ty ) => {{\r\n let mut s = String::new();\r\n match std::io::stdin().read_line(&mut s) {\r\n Ok(0) => Vec::<$t>::new(),\r\n Ok(n) => s\r\n .trim()\r\n .split_whitespace()\r\n .map(|s| s.parse::<$t>().unwrap())\r\n .collect::>(),\r\n Err(_) => Vec::<$t>::new(),\r\n }\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! get {\r\n ($t:ty) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n line.trim().parse::<$t>().unwrap()\r\n }\r\n };\r\n ($($t:ty),*) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n let mut iter = line.split_whitespace();\r\n (\r\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\r\n )\r\n }\r\n };\r\n ($t:ty; $n:expr) => {\r\n (0..$n).map(|_|\r\n get!($t)\r\n ).collect::>()\r\n };\r\n ($($t:ty),*; $n:expr) => {\r\n (0..$n).map(|_|\r\n get!($($t),*)\r\n ).collect::>()\r\n };\r\n ($t:ty ;;) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n line.split_whitespace()\r\n .map(|t| t.parse::<$t>().unwrap())\r\n .collect::>()\r\n }\r\n };\r\n ($t:ty ;; $n:expr) => {\r\n (0..$n).map(|_| get!($t ;;)).collect::>()\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\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 mut 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\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 ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\r\n let mut $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n\r\n ($next:expr, [$t:tt]) => {\r\n {\r\n let len = read_value!($next, usize);\r\n (0..len).map(|_| read_value!($next, $t)).collect::>()\r\n }\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\n#[cfg(debug_assertions)]\r\nmacro_rules! mydbg {\r\n //($arg:expr) => (dbg!($arg))\r\n //($arg:expr) => (println!(\"{:?}\",$arg));\r\n ($($a:expr),*) => {\r\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\r\n }\r\n}\r\n#[cfg(not(debug_assertions))]\r\nmacro_rules! mydbg {\r\n ($($arg:expr),*) => {};\r\n}\r\n\r\nmacro_rules! echo {\r\n ($($a:expr),*) => {\r\n $(println!(\"{}\",$a))*\r\n }\r\n}\r\n\r\nuse std::cmp::*;\r\nuse std::collections::*;\r\nuse std::ops::{Add, Div, Mul, Rem, Sub};\r\n\r\ntrait SafeRangeContain {\r\n fn safe_contains(&self, x: i64) -> bool;\r\n}\r\n\r\nimpl SafeRangeContain for std::ops::Range {\r\n fn safe_contains(&self, x: i64) -> bool {\r\n if x < 0 {\r\n return false;\r\n }\r\n return self.contains(&(x as usize));\r\n }\r\n}\r\n\r\n#[allow(dead_code)]\r\nstatic INF_I64: i64 = i64::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic INF_I32: i32 = i32::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic INF_USIZE: usize = usize::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic M_O_D: usize = 1000000007;\r\n#[allow(dead_code)]\r\nstatic PAI: f64 = 3.1415926535897932;\r\n\r\ntrait IteratorExt: Iterator {\r\n fn toVec(self) -> Vec;\r\n}\r\n\r\nimpl IteratorExt for T {\r\n fn toVec(self) -> Vec {\r\n self.collect()\r\n }\r\n}\r\n\r\ntrait CharExt {\r\n fn toNum(&self) -> usize;\r\n fn toAlphabetIndex(&self) -> usize;\r\n fn toNumIndex(&self) -> usize;\r\n}\r\nimpl CharExt for char {\r\n fn toNum(&self) -> usize {\r\n return *self as usize;\r\n }\r\n fn toAlphabetIndex(&self) -> usize {\r\n return self.toNum() - 'a' as usize;\r\n }\r\n fn toNumIndex(&self) -> usize {\r\n return self.toNum() - '0' as usize;\r\n }\r\n}\r\n\r\ntrait VectorExt {\r\n fn joinToString(&self, s: &str) -> String;\r\n}\r\nimpl VectorExt for Vec {\r\n fn joinToString(&self, s: &str) -> String {\r\n return self\r\n .iter()\r\n .map(|x| x.to_string())\r\n .collect::>()\r\n .join(s);\r\n }\r\n}\r\n\r\ntrait StringExt {\r\n fn get_reverse(&self) -> String;\r\n}\r\nimpl StringExt for String {\r\n fn get_reverse(&self) -> String {\r\n self.chars().rev().collect::()\r\n }\r\n}\r\n\r\ntrait UsizeExt {\r\n fn pow(&self, n: usize) -> usize;\r\n}\r\nimpl UsizeExt for usize {\r\n fn pow(&self, n: usize) -> usize {\r\n return ((*self as u64).pow(n as u32)) as usize;\r\n }\r\n}\r\nfn solve() {\r\n let (N, M, mut k) = get!(usize, usize, usize);\r\n let mut map = vec![vec!['!'; M]; N];\r\n\r\n for j in 0..M {\r\n if j % 2 == 1 || j + 1 >= M {\r\n continue;\r\n }\r\n\r\n for i in (0..N).rev() {\r\n let c = N - i - 1;\r\n if c % 2 == 0 {\r\n for l in 0..min(i + 1, k) {\r\n map[l][j] = '0';\r\n map[l][j + 1] = '0';\r\n }\r\n k -= min(i + 1, k);\r\n }\r\n }\r\n }\r\n\r\n for i in 0..N {\r\n for j in 0..M {\r\n if i + 1 < N && map[i][j] == '!' && map[i + 1][j] == '!' {\r\n map[i][j] = '1';\r\n map[i + 1][j] = '1';\r\n }\r\n }\r\n }\r\n\r\n if k == 0 {\r\n for i in 0..N {\r\n for j in 0..M {\r\n if map[i][j] == '!' {\r\n echo!(\"NO\");\r\n return;\r\n }\r\n }\r\n }\r\n echo!(\"YES\");\r\n } else {\r\n echo!(\"NO\");\r\n }\r\n}\r\n\r\nfn main() {\r\n let T = get!(usize);\r\n for testcase in 0..T {\r\n mydbg!(testcase);\r\n let mut ans: u64 = 0;\r\n solve();\r\n }\r\n}\r\n", "lang": "Rust", "bug_code_uid": "bf3fae340fa83d801bb9f4600d824ce9", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "apr_id": "4164737fad64b79489acc4ee00ac2302", "difficulty": 1700, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9819791337337971, "equal_cnt": 2, "replace_cnt": 1, "delete_cnt": 0, "insert_cnt": 0, "fix_ops_cnt": 1, "bug_source_code": "use std::{io, io::prelude::*, str};\n\nstruct Scanner {\n reader: R,\n buffer: Vec,\n}\nimpl Scanner {\n fn new(reader: R) -> Self {\n Self {\n reader,\n buffer: vec![],\n }\n }\n\n fn t(&mut self) -> T {\n loop {\n if let Some(token) = self.buffer.pop() {\n return token.parse().ok().expect(\"Failed parse\");\n }\n let mut input = String::new();\n self.reader.read_line(&mut input).expect(\"Failed read\");\n self.buffer = input.split_whitespace().rev().map(String::from).collect();\n }\n }\n}\n\nfn check(mut n: usize, mut m: usize, mut k: usize) -> bool {\n m /= 2;\n if m == 0 {\n return k == 0;\n }\n\n if n % 2 == 1 {\n if k < m {\n return false;\n }\n k -= m;\n n -= 1;\n }\n if k % 2 == 1 {\n return false;\n }\n\n let mut rows = 0usize;\n while k >= m * 2 {\n k -= m * 2;\n rows += 2;\n }\n if n < rows {\n return false;\n }\n\n n -= rows;\n k / 2 <= n\n}\n\nfn main() {\n let (stdin, stdout) = (io::stdin(), io::stdout());\n let mut scan = Scanner::new(stdin.lock());\n let mut out = io::BufWriter::new(stdout);\n\n let tn: usize = scan.t();\n for _ in 0..tn {\n let (n, m, k): (usize, usize, usize) = (scan.t(), scan.t(), scan.t());\n\n let ok = check(n, m, k);\n if ok {\n writeln!(out, \"YES\").ok();\n } else {\n writeln!(out, \"NO\").ok();\n }\n }\n}\n", "lang": "Rust", "bug_code_uid": "110813d0d1762570071981ec01a2eb2b", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "apr_id": "baf75938c8e4878fdbfa52cb74127ba0", "difficulty": 1700, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9893190921228304, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_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\nuse std::io::Write;\r\nuse std::collections::*;\r\n\r\ntype Map = BTreeMap;\r\ntype Set = BTreeSet;\r\ntype Deque = VecDeque;\r\n\r\nfn run() {\r\n input! {\r\n t: usize,\r\n ask: [(usize, usize, usize); t],\r\n }\r\n let out = std::io::stdout();\r\n let mut out = std::io::BufWriter::new(out.lock());\r\n for (h, w, k) in ask {\r\n let b = k;\r\n let a = h * w / 2 - b;\r\n let ans = match (h % 2, w % 2, a % 2, b % 2) {\r\n (0, 0, 0, 0) => \"YES\",\r\n (0, 0, _, _) => \"NO\",\r\n (0, 1, _, 0) => \"YES\",\r\n (0, 1, _, _) => \"NO\",\r\n (1, 0, 0, _) => \"YES\",\r\n _ => \"NO\",\r\n };\r\n writeln!(out, \"{}\", ans).ok();\r\n }\r\n}\r\n\r\nfn main() {\r\n run();\r\n}\r\n", "lang": "Rust", "bug_code_uid": "2de3ccfc44a0aae2f269eb4c89813d2d", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "apr_id": "6c06deef1f8efb0375ff1a339a4b20d0", "difficulty": 1700, "tags": ["math", "constructive algorithms"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9470360269843549, "equal_cnt": 12, "replace_cnt": 5, "delete_cnt": 3, "insert_cnt": 3, "fix_ops_cnt": 11, "bug_source_code": "#![allow(unused_parens)]\r\n#![allow(unused_imports)]\r\n#![allow(non_upper_case_globals)]\r\n#![allow(non_snake_case)]\r\n#![allow(unused_mut)]\r\n#![allow(unused_variables)]\r\n#![allow(dead_code)]\r\n\r\ntype Vec2 = Vec>;\r\ntype Vec3 = Vec>>;\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! invec {\r\n ( $ t : ty ) => {{\r\n let mut s = String::new();\r\n match std::io::stdin().read_line(&mut s) {\r\n Ok(0) => Vec::<$t>::new(),\r\n Ok(n) => s\r\n .trim()\r\n .split_whitespace()\r\n .map(|s| s.parse::<$t>().unwrap())\r\n .collect::>(),\r\n Err(_) => Vec::<$t>::new(),\r\n }\r\n }};\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! get {\r\n ($t:ty) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n line.trim().parse::<$t>().unwrap()\r\n }\r\n };\r\n ($($t:ty),*) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n let mut iter = line.split_whitespace();\r\n (\r\n $(iter.next().unwrap().parse::<$t>().unwrap(),)*\r\n )\r\n }\r\n };\r\n ($t:ty; $n:expr) => {\r\n (0..$n).map(|_|\r\n get!($t)\r\n ).collect::>()\r\n };\r\n ($($t:ty),*; $n:expr) => {\r\n (0..$n).map(|_|\r\n get!($($t),*)\r\n ).collect::>()\r\n };\r\n ($t:ty ;;) => {\r\n {\r\n let mut line: String = String::new();\r\n std::io::stdin().read_line(&mut line).unwrap();\r\n line.split_whitespace()\r\n .map(|t| t.parse::<$t>().unwrap())\r\n .collect::>()\r\n }\r\n };\r\n ($t:ty ;; $n:expr) => {\r\n (0..$n).map(|_| get!($t ;;)).collect::>()\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\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 mut 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\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 ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {\r\n let mut $var = read_value!($iter, $t);\r\n input_inner!{$iter $($r)*}\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\nmacro_rules! read_value {\r\n ($iter:expr, ( $($t:tt),* )) => {\r\n ( $(read_value!($iter, $t)),* )\r\n };\r\n\r\n ($iter:expr, [ $t:tt ; $len:expr ]) => {\r\n (0..$len).map(|_| read_value!($iter, $t)).collect::>()\r\n };\r\n\r\n ($next:expr, [$t:tt]) => {\r\n {\r\n let len = read_value!($next, usize);\r\n (0..len).map(|_| read_value!($next, $t)).collect::>()\r\n }\r\n };\r\n ($iter:expr, chars) => {\r\n read_value!($iter, String).chars().collect::>()\r\n };\r\n\r\n ($iter:expr, usize1) => {\r\n read_value!($iter, usize) - 1\r\n };\r\n\r\n ($iter:expr, $t:ty) => {\r\n $iter.next().unwrap().parse::<$t>().expect(\"Parse error\")\r\n };\r\n}\r\n\r\n#[allow(unused_macros)]\r\n#[cfg(debug_assertions)]\r\nmacro_rules! mydbg {\r\n //($arg:expr) => (dbg!($arg))\r\n //($arg:expr) => (println!(\"{:?}\",$arg));\r\n ($($a:expr),*) => {\r\n eprintln!(concat!($(stringify!($a), \" = {:?}, \"),*), $($a),*);\r\n }\r\n}\r\n#[cfg(not(debug_assertions))]\r\nmacro_rules! mydbg {\r\n ($($arg:expr),*) => {};\r\n}\r\n\r\nmacro_rules! echo {\r\n ($($a:expr),*) => {\r\n $(println!(\"{}\",$a))*\r\n }\r\n}\r\n\r\nuse std::cmp::*;\r\nuse std::collections::*;\r\nuse std::ops::{Add, Div, Mul, Rem, Sub};\r\n\r\ntrait SafeRangeContain {\r\n fn safe_contains(&self, x: i64) -> bool;\r\n}\r\n\r\nimpl SafeRangeContain for std::ops::Range {\r\n fn safe_contains(&self, x: i64) -> bool {\r\n if x < 0 {\r\n return false;\r\n }\r\n return self.contains(&(x as usize));\r\n }\r\n}\r\n\r\n#[allow(dead_code)]\r\nstatic INF_I64: i64 = i64::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic INF_I32: i32 = i32::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic INF_USIZE: usize = usize::max_value() / 2;\r\n#[allow(dead_code)]\r\nstatic M_O_D: usize = 1000000007;\r\n#[allow(dead_code)]\r\nstatic PAI: f64 = 3.1415926535897932;\r\n\r\ntrait IteratorExt: Iterator {\r\n fn toVec(self) -> Vec;\r\n}\r\n\r\nimpl IteratorExt for T {\r\n fn toVec(self) -> Vec {\r\n self.collect()\r\n }\r\n}\r\n\r\ntrait CharExt {\r\n fn toNum(&self) -> usize;\r\n fn toAlphabetIndex(&self) -> usize;\r\n fn toNumIndex(&self) -> usize;\r\n}\r\nimpl CharExt for char {\r\n fn toNum(&self) -> usize {\r\n return *self as usize;\r\n }\r\n fn toAlphabetIndex(&self) -> usize {\r\n return self.toNum() - 'a' as usize;\r\n }\r\n fn toNumIndex(&self) -> usize {\r\n return self.toNum() - '0' as usize;\r\n }\r\n}\r\n\r\ntrait VectorExt {\r\n fn joinToString(&self, s: &str) -> String;\r\n}\r\nimpl VectorExt for Vec {\r\n fn joinToString(&self, s: &str) -> String {\r\n return self\r\n .iter()\r\n .map(|x| x.to_string())\r\n .collect::>()\r\n .join(s);\r\n }\r\n}\r\n\r\ntrait StringExt {\r\n fn get_reverse(&self) -> String;\r\n}\r\nimpl StringExt for String {\r\n fn get_reverse(&self) -> String {\r\n self.chars().rev().collect::()\r\n }\r\n}\r\n\r\ntrait UsizeExt {\r\n fn pow(&self, n: usize) -> usize;\r\n}\r\nimpl UsizeExt for usize {\r\n fn pow(&self, n: usize) -> usize {\r\n return ((*self as u64).pow(n as u32)) as usize;\r\n }\r\n}\r\n\r\nfn main() {\r\n solve();\r\n}\r\n\r\nfn solve() {\r\n let mut ans: u64 = 0;\r\n let (N, M) = get!(usize, u64);\r\n let mut dp = vec![0; N + 5];\r\n dp[N] = 1;\r\n let mut sum = 0;\r\n for i in (1..=N).rev() {\r\n dp[i] += sum;\r\n dp[i] %= M;\r\n let mut tmp = HashSet::new();\r\n\r\n for j in 1..=i {\r\n if j * j > i {\r\n break;\r\n }\r\n let a = i / j;\r\n // dp[a] += dp[i];\r\n // dp[a] %= M;\r\n tmp.insert(j);\r\n tmp.insert(a);\r\n }\r\n\r\n for &a in &tmp {\r\n if a == i {\r\n continue;\r\n }\r\n let b = i / (a + 1);\r\n let c = i / a;\r\n let d = (dp[i] * (c - b) as u64) % M;\r\n dp[a] += d;\r\n dp[a] %= M;\r\n }\r\n\r\n sum += dp[i];\r\n sum %= M;\r\n }\r\n let ans = dp[1] % M;\r\n\r\n echo!(ans);\r\n}\r\n", "lang": "Rust", "bug_code_uid": "4a8d43c23e1673a59cf019db3753d604", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "apr_id": "37f426b5bae720148a385e3052684ffa", "difficulty": 1700, "tags": ["dp", "number theory", "data structures", "math", "brute force"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9968827260023648, "equal_cnt": 2, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 1, "fix_ops_cnt": 1, "bug_source_code": "use std::cmp::*;\nuse std::collections::*;\n\nstruct IO(R, std::io::BufWriter);\n\nimpl IO {\n pub fn new(r: R, w: W) -> IO {\n IO(r, std::io::BufWriter::new(w))\n }\n pub fn write(&mut self, s: S) {\n use std::io::Write;\n self.1.write_all(s.to_string().as_bytes()).unwrap();\n }\n pub fn writeln(&mut self, s: S) {\n self.write(format!(\"{}\\n\", s.to_string()));\n }\n pub fn writevec(&mut self, v: &[T]) {\n let s = v\n .iter()\n .map(|x| x.to_string())\n .collect::>()\n .join(\" \");\n self.writeln(format!(\"{} \", &s));\n }\n pub fn read(&mut self) -> T {\n use std::io::Read;\n let buf = self\n .0\n .by_ref()\n .bytes()\n .map(|b| b.unwrap())\n .skip_while(|&b| b == b' ' || b == b'\\n' || b == b'\\r' || b == b'\\t')\n .take_while(|&b| b != b' ' && b != b'\\n' && b != b'\\r' && b != b'\\t')\n .collect::>();\n unsafe { std::str::from_utf8_unchecked(&buf) }\n .parse()\n .ok()\n .expect(\"Parse error.\")\n }\n pub fn usize(&mut self) -> usize {\n self.read::()\n }\n pub fn i32(&mut self) -> i32 {\n self.read::()\n }\n pub fn i64(&mut self) -> i64 {\n self.read::()\n }\n pub fn vec(&mut self, n: usize) -> Vec {\n (0..n).map(|_| self.read()).collect()\n }\n pub fn vecn(&mut self) -> Vec {\n let n: usize = self.read();\n self.vec(n)\n }\n pub fn chars(&mut self) -> Vec {\n self.read::().chars().collect()\n }\n}\n\nfn pow(mut a: i64, mut b: i64) -> i64 {\n let mut r = 1;\n loop {\n if b & 1 == 1 {\n r *= a;\n }\n b >>= 1;\n if b == 0 {\n break;\n }\n a *= a;\n }\n r\n}\n\nfn solve_one(s: Vec) -> i64 {\n if [\"__\".to_owned(), \"_X\".to_owned()].contains(&s.iter().collect::()) {\n return 3;\n }\n if s.len() == 1 {\n return if \"0_X\".contains(s[0]) { 1 } else { 0 };\n }\n if s[0] == '0' {\n return 0;\n }\n\n let l = s[s.len() - 1];\n let k = s[s.len() - 2];\n\n // println!(\"l: {}, k: {}\", l, k);\n\n let mut combs = HashMap::new();\n\n if !\"05_X\".contains(l) {\n return 0;\n }\n if l == '0' || l == '_' {\n if !\"05_X\".contains(k) {\n if l != '_' {\n return 0;\n }\n } else if k == 'X' {\n *combs.entry(Some(5)).or_insert(0) += 1;\n if s[0] != 'X' {\n *combs.entry(Some(0)).or_insert(0) += 1;\n }\n } else {\n *combs.entry(None).or_insert(0) += if k == '_' { 2 } else { 1 };\n }\n }\n if l == '5' || l == '_' {\n if !\"27_X\".contains(k) {\n if l != '_' {\n return 0;\n }\n } else if k == 'X' {\n *combs.entry(Some(2)).or_insert(0) += 1;\n *combs.entry(Some(7)).or_insert(0) += 1;\n } else {\n *combs.entry(None).or_insert(0) += if k == '_' { 2 } else { 1 };\n }\n }\n if l == 'X' {\n if k == '0' || k == '5' {\n if s[0] != 'X' {\n *combs.entry(Some(0)).or_insert(0) += 1;\n }\n } else if k == '2' || k == '7' {\n *combs.entry(Some(5)).or_insert(0) += 1;\n } else if k == '_' {\n if s[0] != 'X' {\n *combs.entry(Some(0)).or_insert(0) += if s.len() == 2 { 1 } else { 2 };\n }\n *combs.entry(Some(5)).or_insert(0) += 2;\n } else if k == 'X' {\n if s[0] != 'X' {\n *combs.entry(Some(0)).or_insert(0) += 1;\n }\n } else {\n return 0;\n }\n }\n\n let b = s[..s.len() - 2].to_vec();\n let u = b.iter().filter(|&&c| c == '_').count();\n let x = b.iter().filter(|&&c| c == 'X').count();\n\n // println!(\"{:?}\", combs);\n\n // let c = pow(10, (u + if) as i64);\n\n let mut count = 0;\n\n for (xv, cnt) in combs {\n let a = match xv {\n Some(p) => u,\n None => u + if x > 0 { 1 } else { 0 },\n } as i64;\n\n let mut ch = pow(10, a);\n if s[0] == '_' && s.len() > 2 {\n ch = ch / 10 * 9;\n }\n\n count += ch * cnt;\n }\n\n count\n}\n\npub fn main() {\n let mut sc = IO::new(std::io::stdin(), std::io::stdout());\n let ans = solve_one(sc.chars());\n sc.writeln(ans);\n}\n", "lang": "Rust", "bug_code_uid": "fd07fca003980b0bbe81ee4d295ac41a", "src_uid": "4a905f419550a6c839992b40f1617af3", "apr_id": "c39794315e88267b0c4461359d0fbc19", "difficulty": 1800, "tags": ["dfs and similar", "dp", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.9726169844020798, "equal_cnt": 6, "replace_cnt": 1, "delete_cnt": 1, "insert_cnt": 3, "fix_ops_cnt": 5, "bug_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 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 s = s.clone();\r\n s.iter_mut().for_each(|s| {\r\n if *s == b'X' {\r\n *s = b'0' + v as u8;\r\n }\r\n });\r\n if s[0] == b'0' && s.len() > 1 {\r\n continue;\r\n }\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 {\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": "Rust", "bug_code_uid": "bfb697a0d4bb8a0ada132b6e289e0901", "src_uid": "4a905f419550a6c839992b40f1617af3", "apr_id": "5bf4d6399497fb8c2ff00bf8914e03ed", "difficulty": 1800, "tags": ["dfs and similar", "dp", "brute force"], "bug_exec_outcome": "WRONG_ANSWER", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"} {"similarity_score": 0.8801287208366855, "equal_cnt": 14, "replace_cnt": 8, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 14, "bug_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": "Rust", "bug_code_uid": "01873e60e1d09bfc4faaff6c35ecd871", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "apr_id": "9517e28727f49a609f9ed2dfe16ef985", "difficulty": 2100, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.884962858863682, "equal_cnt": 12, "replace_cnt": 6, "delete_cnt": 2, "insert_cnt": 4, "fix_ops_cnt": 12, "bug_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] = vec![1; x + 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": "Rust", "bug_code_uid": "9ccd1e37cfce2dd119f3aaebd96c4002", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "apr_id": "9517e28727f49a609f9ed2dfe16ef985", "difficulty": 2100, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9911818989678037, "equal_cnt": 8, "replace_cnt": 2, "delete_cnt": 3, "insert_cnt": 2, "fix_ops_cnt": 7, "bug_source_code": "use std::io::{self, prelude::*, BufWriter};\r\nuse std::str::FromStr;\r\n\r\ntype M = DynamicModInt;\r\n\r\nfn solve(sc: &mut Scanner, out: &mut W) {\r\n let n: usize = sc.next();\r\n let mx: usize = sc.next();\r\n let comb = Comb::::new(n);\r\n\r\n let mut dp = vec![vec![M::zero(); mx + 1]; n + 1];\r\n dp[1][1..=mx].iter_mut().for_each(|v| *v = M::one());\r\n let mut p = vec![vec![M::zero(); n]; n];\r\n for i in 0..n {\r\n for j in 0..n {\r\n p[i][j] = M::from(i).pow(j as u64);\r\n }\r\n }\r\n for i in 1..=n {\r\n for m in 1..=mx {\r\n let delta = dp[i][m];\r\n if delta.0 == 0 {\r\n continue;\r\n }\r\n let mut nm = m + i - 1;\r\n for k in (0..=n - i).take_while(move |_| nm <= mx) {\r\n dp[i + k][nm] += delta * comb.choose(i + k, i) * p[i + k - 1][k];\r\n nm += 1;\r\n }\r\n }\r\n }\r\n let ans = M::from(mx).pow(n as u64) - dp[n].iter().cloned().sum::();\r\n writeln!(out, \"{}\", ans).ok();\r\n}\r\n\r\nfn main() {\r\n M::set_modulus(998244353);\r\n let (stdin, stdout) = (io::stdin(), io::stdout());\r\n let mut scan = Scanner::new(stdin.lock());\r\n let mut out = BufWriter::new(stdout.lock());\r\n\r\n let tests: usize = 1; // scan.next();\r\n for _ in 0..tests {\r\n solve(&mut scan, &mut out);\r\n }\r\n}\r\n\r\n// {{{ Scanner\r\npub struct Scanner {\r\n reader: R,\r\n buffer: Vec,\r\n}\r\n\r\nimpl Scanner {\r\n pub fn new(reader: R) -> Self {\r\n Self {\r\n reader,\r\n buffer: vec![],\r\n }\r\n }\r\n\r\n pub fn next(&mut self) -> T {\r\n loop {\r\n if let Some(token) = self.buffer.pop() {\r\n return token.parse().ok().unwrap();\r\n }\r\n self.buffer = self\r\n .next_line()\r\n .split_ascii_whitespace()\r\n .rev()\r\n .map(String::from)\r\n .collect();\r\n }\r\n }\r\n\r\n pub fn next_vec(&mut self, n: usize) -> Vec {\r\n (0..n).map(|_| self.next()).collect()\r\n }\r\n\r\n pub fn next_line(&mut self) -> String {\r\n let mut line = String::new();\r\n self.reader.read_line(&mut line).unwrap();\r\n line\r\n }\r\n}\r\n// }}}\r\n// {{{ DynamicModInt\r\nuse std::fmt;\r\nuse std::iter::{Product, Sum};\r\nuse std::ops::*;\r\n\r\n#[derive(Clone, Copy, Eq, PartialEq, Debug, Hash)]\r\npub struct DynamicModInt(pub i32);\r\n\r\nimpl Default for DynamicModInt {\r\n fn default() -> Self {\r\n DynamicModInt(0)\r\n }\r\n}\r\n\r\nimpl fmt::Display for DynamicModInt {\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n write!(f, \"{}\", self.0)\r\n }\r\n}\r\n\r\nimpl DynamicModInt {\r\n pub fn set_modulus(modulus: i32) {\r\n *Self::modulus_ref() = modulus;\r\n }\r\n\r\n pub fn modulus() -> i32 {\r\n *Self::modulus_ref()\r\n }\r\n\r\n fn modulus_ref() -> &'static mut i32 {\r\n static mut MODULUS: i32 = 1;\r\n unsafe { &mut MODULUS }\r\n }\r\n\r\n pub fn raw(val: i32) -> Self {\r\n DynamicModInt(val)\r\n }\r\n\r\n #[inline]\r\n fn canon(val: i32) -> Self {\r\n DynamicModInt(if val < 0 { val + Self::modulus() } else { val })\r\n }\r\n\r\n #[inline]\r\n pub fn zero() -> Self {\r\n DynamicModInt(0)\r\n }\r\n\r\n #[inline]\r\n pub fn one() -> Self {\r\n DynamicModInt(1)\r\n }\r\n\r\n #[inline]\r\n pub fn two() -> Self {\r\n DynamicModInt(2)\r\n }\r\n\r\n pub fn pow(self, n: u64) -> Self {\r\n let mut n = n;\r\n let mut res = Self::one();\r\n let mut a = self;\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n res *= a;\r\n }\r\n a *= a;\r\n n >>= 1;\r\n }\r\n\r\n res\r\n }\r\n\r\n pub fn inv(self) -> Self {\r\n self.pow(Self::modulus() as u64 - 2)\r\n }\r\n}\r\n\r\nmacro_rules! from_bigger_int {\r\n ($($int:ident)*) => {$(\r\n impl From<$int> for DynamicModInt {\r\n fn from(val: $int) -> Self {\r\n Self::canon((val % Self::modulus() as $int) as i32)\r\n }\r\n }\r\n )*};\r\n}\r\nfrom_bigger_int!(u32 usize i64 u64 i128 u128);\r\n\r\nmacro_rules! from_smaller_int {\r\n ($($int: ident)*) => {$(\r\n impl From<$int> for DynamicModInt {\r\n fn from(val: $int) -> Self {\r\n Self::canon(val as i32 % Self::modulus())\r\n }\r\n }\r\n )*}\r\n}\r\nfrom_smaller_int!(i32 i16 u16 i8 u8);\r\n\r\nimpl Neg for DynamicModInt {\r\n type Output = Self;\r\n fn neg(self) -> Self {\r\n DynamicModInt(if self.0 == 0 {\r\n 0\r\n } else {\r\n Self::modulus() - self.0\r\n })\r\n }\r\n}\r\n\r\nimpl Add for DynamicModInt {\r\n type Output = Self;\r\n fn add(self, other: Self) -> Self {\r\n let s = self.0 + other.0;\r\n let m = Self::modulus();\r\n DynamicModInt(if s >= m { s - m } else { s })\r\n }\r\n}\r\n\r\nimpl Sub for DynamicModInt {\r\n type Output = Self;\r\n fn sub(self, other: Self) -> Self {\r\n Self::canon(self.0 - other.0)\r\n }\r\n}\r\n\r\nimpl Mul for DynamicModInt {\r\n type Output = Self;\r\n fn mul(self, other: Self) -> Self {\r\n let mul: u64 = (self.0 as u64 * other.0 as u64) % Self::modulus() as u64;\r\n DynamicModInt(mul as i32)\r\n }\r\n}\r\n\r\nimpl Div for DynamicModInt {\r\n type Output = Self;\r\n #[allow(clippy::suspicious_arithmetic_impl)]\r\n fn div(self, other: Self) -> Self {\r\n self * other.inv()\r\n }\r\n}\r\n\r\nimpl AddAssign for DynamicModInt {\r\n fn add_assign(&mut self, other: Self) {\r\n *self = *self + other;\r\n }\r\n}\r\n\r\nimpl SubAssign for DynamicModInt {\r\n fn sub_assign(&mut self, other: Self) {\r\n *self = *self - other;\r\n }\r\n}\r\n\r\nimpl MulAssign for DynamicModInt {\r\n fn mul_assign(&mut self, other: Self) {\r\n *self = *self * other;\r\n }\r\n}\r\n\r\nimpl DivAssign for DynamicModInt {\r\n fn div_assign(&mut self, other: Self) {\r\n *self = *self / other;\r\n }\r\n}\r\n\r\nimpl Sum for DynamicModInt {\r\n fn sum>(iter: I) -> Self {\r\n iter.fold(Self::zero(), Add::add)\r\n }\r\n}\r\n\r\nimpl Product for DynamicModInt {\r\n fn product>(iter: I) -> Self {\r\n iter.fold(Self::one(), Mul::mul)\r\n }\r\n}\r\n// }}}\r\n// {{{ Comb\r\nuse std::ops::{Add, Div, Mul};\r\n\r\npub struct Comb {\r\n fac: Vec,\r\n inv_fac: Vec,\r\n}\r\n\r\nimpl + Eq + Add + Mul + Div> Comb {\r\n pub fn new(maxn: usize) -> Self {\r\n let one = F::from(1);\r\n let mut fac = vec![one; maxn + 1];\r\n for i in 1..=maxn {\r\n fac[i] = fac[i - 1] * F::from(i);\r\n }\r\n let mut inv_fac = vec![one; maxn + 1];\r\n inv_fac[maxn] = one / fac[maxn];\r\n assert!(fac[maxn] * inv_fac[maxn] == one);\r\n for i in (1..maxn).rev() {\r\n inv_fac[i] = inv_fac[i + 1] * F::from(i + 1);\r\n }\r\n Comb { fac, inv_fac }\r\n }\r\n\r\n pub fn choose(&self, n: usize, k: usize) -> F {\r\n if k > n {\r\n F::from(0)\r\n } else {\r\n self.fac[n] * self.inv_fac[k] * self.inv_fac[n - k]\r\n }\r\n }\r\n\r\n pub fn fac(&self, n: usize) -> F {\r\n self.fac[n]\r\n }\r\n\r\n pub fn inv_fac(&self, n: usize) -> F {\r\n self.inv_fac[n]\r\n }\r\n}\r\n// }}}\r\n//\r\n", "lang": "Rust", "bug_code_uid": "8309950a15468e21929df09896aae110", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "apr_id": "99a9620650cee1e3f72330a728d07add", "difficulty": 2100, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "RUNTIME_ERROR", "potential_dominant_fix_op": "delete", "lang_cluster": "Rust"} {"similarity_score": 0.9108971419837995, "equal_cnt": 7, "replace_cnt": 4, "delete_cnt": 1, "insert_cnt": 1, "fix_ops_cnt": 6, "bug_source_code": "/*\r\n date : 2021 / 4 / 7\r\n author : quickn (quickn.tech)\r\n email : quickwshell@gmail.com\r\n*/\r\n\r\nuse std::io::{self, BufWriter, Write};\r\n\r\nmod scanner {\r\n use std::{io, str};\r\n /* https://github.com/EbTech/rust-algorithms */\r\n\r\n /// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts\r\n /// **REQUIRES** Rust 1.34 or higher\r\n pub struct UnsafeScanner {\r\n reader: R,\r\n buf_str: Vec,\r\n buf_iter: str::SplitAsciiWhitespace<'static>,\r\n }\r\n\r\n impl UnsafeScanner {\r\n pub fn new(reader: R) -> Self {\r\n Self {\r\n reader,\r\n buf_str: Vec::new(),\r\n buf_iter: \"\".split_ascii_whitespace(),\r\n }\r\n }\r\n\r\n /// This function should be marked unsafe, but noone has time for that in a\r\n /// programming contest. Use at your own risk!\r\n pub fn token(&mut self) -> T {\r\n loop {\r\n if let Some(token) = self.buf_iter.next() {\r\n return token.parse().ok().expect(\"Failed parse\");\r\n }\r\n self.buf_str.clear();\r\n self.reader\r\n .read_until(b'\\n', &mut self.buf_str)\r\n .expect(\"Failed read\");\r\n self.buf_iter = unsafe {\r\n let slice = str::from_utf8_unchecked(&self.buf_str);\r\n std::mem::transmute(slice.split_ascii_whitespace())\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nuse std::cmp::{min, max};\r\n\r\nfn s2vec(s: String) -> Vec {\r\n s.chars().collect()\r\n}\r\n\r\nconst MOD: i64 = 998244353;\r\n\r\nfn pow_mod(a: i64, x: i64) -> i64 {\r\n let mut r = 1;\r\n let mut a_t = a;\r\n let mut x_t = x;\r\n while x_t != 0 {\r\n if x_t % 2 == 1 {\r\n r *= a_t;\r\n r %= MOD;\r\n }\r\n a_t *= a_t;\r\n a_t %= MOD;\r\n x_t /= 2;\r\n }\r\n r\r\n}\r\n\r\nconst MAX: usize = 501;\r\n\r\nfn main() {\r\n let (stdin, stdout) = (io::stdin(), io::stdout());\r\n let (mut scan, mut sout) = (\r\n scanner::UnsafeScanner::new(stdin.lock()),\r\n BufWriter::new(stdout.lock()),\r\n );\r\n let n: usize = scan.token();\r\n let x: usize = scan.token();\r\n let mut dp: Vec> = vec![vec![0;MAX];n+1];\r\n let mut binom: Vec> = vec![vec![0;MAX+1];MAX+1];\r\n binom[0][0] = 1;\r\n for i in 1..=MAX {\r\n binom[i][0] = 1;\r\n binom[i][i] = 1;\r\n for j in 1..i {\r\n binom[i][j] += binom[i-1][j-1];\r\n binom[i][j] %= MOD;\r\n binom[i][j] += binom[i-1][j];\r\n binom[i][j] %= MOD;\r\n }\r\n }\r\n dp[n][0] = 1;\r\n for r in (1..=n).rev() {\r\n for lx in 0..=x {\r\n for y in 0..=(n-r) {\r\n if lx >= y+r-1 {\r\n let d = max(0, min(x-lx+(y+r-1), y+r-1));\r\n dp[r][lx] += (((dp[r+y][lx-(y+r-1)]*binom[y+r][y])%MOD)*pow_mod(d as i64, y as i64))%MOD;\r\n dp[r][lx] %= MOD;\r\n }\r\n }\r\n }\r\n }\r\n let mut all = pow_mod(x as i64, n as i64);\r\n for lx in 0..=x {\r\n all -= (dp[1][lx]*((x - lx) as i64))%MOD;\r\n all += MOD;\r\n all %= MOD;\r\n }\r\n writeln!(sout, \"{}\", all).ok();\r\n}\r\n", "lang": "Rust", "bug_code_uid": "2ee23ae89a71ad0be28beba416b40ca3", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "apr_id": "d92c7a50de8e92a871a2121e7f9cb06d", "difficulty": 2100, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9552238805970149, "equal_cnt": 9, "replace_cnt": 7, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 9, "bug_source_code": "//spnauti-rusT {{{\n#[allow(unused_imports)]use std::{io::*,collections::*,fmt::Debug,str::{self,*},cmp::*,ops::{self,*},iter::{self,*}};\nmacro_rules!l{\n\t($($v:ident),+:$t:ty=$e:expr)=>{$(let$v:$t=$e;)+};(mut $($v:ident),+ =$e:expr)=>{$(let mut$v=$e;)+};\n\t(mut $($v:ident),+:$t:ty=$e:expr)=>{$(let mut$v:$t=$e;)+};($($v:ident),+ =$e:expr)=>{$(let$v=$e;)+};}\nmacro_rules!v{\n\t($(:$t:ty)?=$e:expr)=>{$e$(as$t)?};([$d:expr]$(:$t:ty)?)=>{Vec::$(<$t>::)?with_capacity($d)};\n\t([]$(:$t:ty)?)=>{Vec::$(<$t>::)?new()};([$d:expr]$($s:tt)+)=>{vec![v!($($s)+);$d]};}\nfn rio()->(Reader,BufWriter){(Reader::new(),BufWriter::new(stdout()))}\nstruct Reader{buf:Vec,pos:usize,x:*mut Stdin,q:StdinLock<'static>}//'\n#[allow(dead_code)]impl Reader{\n\tfn new()->Self{let x=Box::into_raw(Box::new(stdin()));let q=unsafe{&*x}.lock();Self{x,q,buf:v!([]),pos:0}}\n\tfn next_line(&mut self)->bool{self.buf.clear();self.pos=0;self.q.read_until(b'\\n',&mut self.buf).unwrap_or(0)>0}\n\tfn byte(&mut self)->Option{\n\t\tif self.pos==self.buf.len(){if!self.next_line(){return None;}}self.pos+=1;Some(self.buf[self.pos-1])}\n\tfn vb(&mut self)->Vec{let mut s=v!([10]);let mut f=false;while let Some(c)=self.byte(){\n\t\tif!c.is_ascii_whitespace(){s.push(c);f=true;}else if f{break;}}s}\n\tfn p(&mut self)->T where T::Err:Debug{let w=self.vb();str::from_utf8(w.as_ref()).unwrap().parse::().unwrap()}\n\tfn u(&mut self) -> usize { self.p() }\n}impl Drop for Reader{fn drop(&mut self){unsafe{Box::from_raw(self.x)};}}\n//----------}}}\n\n// Field (mod prime) {{{\nmod field {\n\tuse std::ops::*;\n\t#[allow(dead_code)] pub const Z0: Field = Field(0);\n\t#[allow(dead_code)] pub const Z1: Field = Field(1);\n\tconst P5: i32 = 998_244_353;\n\tconst P6: i64 = P5 as i64;\n\t#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Default)] pub struct Field(pub i32);\n\t#[allow(dead_code)] impl Field {\n\t\tpub fn new>(a: T) -> Self { Self(Self::cv(a)) }\n\t\tpub unsafe fn new_unchecked(a: i32) -> Self { Self(a) }\n\t\tfn hi(mut a: i32) -> i32 { if a >= P5 { a -= P5; } a }\n\t\tfn lo(mut a: i32) -> i32 { if a < 0 { a += P5; } a }\n\t\tfn cv>(a: T) -> i32 { Self::lo((a.into() % P6) as i32) }\n\t\tpub fn inv(self) -> Self { self.pow(P5-2) }\n\t\tpub fn pow>(self, b: T) -> Self {\n\t\t\tlet b = b.into(); if b == 0 { Self(1) } else {\n\t\t\t\tlet mut res = self.pow(b/2); res *= res; if b % 2 == 1 {res *= self;} res\n\t\t\t}\n\t\t}\n\t}\n\timpl Add for Field { type Output = Self; fn add(self, a: Self) -> Self::Output { Self(Self::hi(self.0 + a.0)) }}\n\timpl Sub for Field { type Output = Self; fn sub(self, a: Self) -> Self::Output { Self(Self::lo(self.0 - a.0)) }}\n\timpl Mul for Field { type Output = Self; fn mul(self, a: Self) -> Self::Output { Self(Self::cv(self.0 as i64 * a.0 as i64)) }}\n\timpl Div for Field { type Output = Self; fn div(self, a: Self) -> Self::Output { self * a.inv() }}\n\timpl Neg for Field { type Output = Self; fn neg(self) -> Self::Output { Self(Self::lo(-self.0)) }}\n\timpl AddAssign for Field { fn add_assign(&mut self, a: Self) { *self = *self + a; } }\n\timpl SubAssign for Field { fn sub_assign(&mut self, a: Self) { *self = *self - a; } }\n\timpl MulAssign for Field { fn mul_assign(&mut self, a: Self) { *self = *self * a; } }\n\timpl DivAssign for Field { fn div_assign(&mut self, a: Self) { *self = *self / a; } }\n\tuse std::fmt::{Display, Formatter, Result};\n\timpl Display for Field { fn fmt(&self, f: &mut Formatter) -> Result { write!(f, \"{}\", self.0) } }\n}\n#[allow(unused_imports)] use field::{Field, Field as Z, Z0, Z1};\n//}}}\n\nfn main() {\n\tlet (mut rin,mut rout) = rio();\n\tconst N: usize = 1000;\n\n\tl!(mut f,fi = v!([N+1] = Z1));\n\tfor i in 2..N {\n\t\tf[i] = f[i-1] * Z::new(i as i32);\n\t\tfi[i] = f[i].inv();\n\t}\n\tlet cnr = |n,r| -> Z {\n\t\tif r > n {\n\t\t\tZ0\n\t\t} else {\n\t\t\tf[n] * fi[n-r] * fi[r]\n\t\t}\n\t};\n\n\tl!(n,x = rin.u());\n\tlet mut dp = v!([x+1][n+1] = Z0);\n\tlet mut s = Z0;\n\tfor i in 1..=x {\n\t\tdp[i][1] = Z1;\n\t\tfor j in 2..=n.min(i) {\n\t\t\tlet mut res = Z0;\n\t\t\tfor k in 1..=j {\n\t\t\t\tres += dp[i-j+1][k] * Z::new((j-1) as i32).pow((j-k) as i32) * cnr(j-1,k-1);\n\t\t\t}\n\t\t\tdp[i][j] = res;\n\t\t}\n\t\ts += dp[i][n];\n\t}\n\ts *= Z::new(n as i32);\n\tlet ans = Z::new(x as i32).pow(n as i32) - s;\n\twriteln!(rout, \"{}\", ans).unwrap();\n}\n", "lang": "Rust", "bug_code_uid": "165a55d02a462157a63e609afe0a219c", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "apr_id": "427add1352acae413abc699a94ddc71e", "difficulty": 2100, "tags": ["dp", "math", "combinatorics"], "bug_exec_outcome": "TIME_LIMIT_EXCEEDED", "potential_dominant_fix_op": "replace", "lang_cluster": "Rust"} {"similarity_score": 0.9280509255381523, "equal_cnt": 3, "replace_cnt": 0, "delete_cnt": 0, "insert_cnt": 2, "fix_ops_cnt": 2, "bug_source_code": "#[allow(unused_imports)]\r\nuse std::io::{stdout, BufWriter, Write};\r\nfn main() {\r\n let out = stdout();\r\n let mut out = BufWriter::new(out.lock());\r\n\r\n inputv! {\r\n t:usize,\r\n }\r\n ModInt::set_modulus(1_000_000_007);\r\n let mut dpf = DpFactorial::new();\r\n\r\n for _ in 0..t {\r\n inputv! {\r\n n:usize,k:usize,\r\n }\r\n let mut ans = ModInt::new(0);\r\n for q in 0..=k {\r\n ans += dpf.get_combination(k, q) * ModInt::new(n - 1).pow(q as u64);\r\n }\r\n writeln!(out, \"{}\", ans).unwrap();\r\n }\r\n}\r\n\r\n//https://github.com/rust-lang-ja/ac-library-rs\r\n//https://github.com/manta1130/competitive-template-rs\r\n\r\nuse dpfactorial::*;\r\nuse modint::*;\r\n\r\npub mod dpfactorial {\r\n use crate::modint::*;\r\n\r\n #[derive(Default)]\r\n pub struct DpFactorial {\r\n normal: Vec,\r\n inv: Vec,\r\n }\r\n impl DpFactorial {\r\n #[allow(dead_code)]\r\n pub fn new() -> DpFactorial {\r\n let mut obj = DpFactorial {\r\n normal: Vec::new(),\r\n inv: Vec::new(),\r\n };\r\n obj.normal.push(ModInt::new(1));\r\n obj.inv.push(ModInt::new(1));\r\n obj\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_factorial(&mut self, n: usize) -> ModInt {\r\n if n < self.normal.len() {\r\n return self.normal[n];\r\n }\r\n for z in self.normal.len()..n as usize + 1 {\r\n let buf = ModInt::new(z);\r\n let buf = buf * self.normal[z - 1];\r\n\r\n self.normal.push(buf);\r\n }\r\n self.normal[n]\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_factorial_inv(&mut self, n: usize) -> ModInt {\r\n if n < self.inv.len() {\r\n return self.inv[n];\r\n }\r\n for z in self.inv.len()..n + 1 {\r\n let mut buf = ModInt::new(z);\r\n buf = buf.inv();\r\n let buf = buf * self.inv[z - 1];\r\n self.inv.push(buf);\r\n }\r\n self.inv[n]\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_combination(&mut self, n: usize, r: usize) -> ModInt {\r\n if n < r {\r\n return ModInt::new(0);\r\n }\r\n self.get_factorial(n) * self.get_factorial_inv(n - r) * self.get_factorial_inv(r)\r\n }\r\n\r\n #[allow(dead_code)]\r\n pub fn get_permutation(&mut self, n: usize, r: usize) -> ModInt {\r\n if n < r {\r\n return ModInt::new(0);\r\n }\r\n self.get_factorial(n) * self.get_factorial_inv(n - r)\r\n }\r\n }\r\n}\r\npub mod internal_math {\r\n #![allow(dead_code)]\r\n use std::mem::swap;\r\n\r\n /* const */\r\n pub(crate) fn safe_mod(mut x: i64, m: i64) -> i64 {\r\n x %= m;\r\n if x < 0 {\r\n x += m;\r\n }\r\n x\r\n }\r\n\r\n pub(crate) struct Barrett {\r\n pub(crate) _m: u32,\r\n pub(crate) im: u64,\r\n }\r\n\r\n impl Barrett {\r\n pub(crate) fn new(m: u32) -> Barrett {\r\n Barrett {\r\n _m: m,\r\n im: (-1i64 as u64 / m as u64).wrapping_add(1),\r\n }\r\n }\r\n\r\n pub(crate) fn umod(&self) -> u32 {\r\n self._m\r\n }\r\n\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn mul(&self, a: u32, b: u32) -> u32 {\r\n mul_mod(a, b, self._m, self.im)\r\n }\r\n }\r\n\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn mul_mod(a: u32, b: u32, m: u32, im: u64) -> u32 {\r\n let mut z = a as u64;\r\n z *= b as u64;\r\n let x = (((z as u128) * (im as u128)) >> 64) as u64;\r\n let mut v = z.wrapping_sub(x.wrapping_mul(m as u64)) as u32;\r\n if m <= v {\r\n v = v.wrapping_add(m);\r\n }\r\n v\r\n }\r\n\r\n /* const */\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn pow_mod(x: i64, mut n: i64, m: i32) -> i64 {\r\n if m == 1 {\r\n return 0;\r\n }\r\n let _m = m as u32;\r\n let mut r: u64 = 1;\r\n let mut y: u64 = safe_mod(x, m as i64) as u64;\r\n while n != 0 {\r\n if (n & 1) > 0 {\r\n r = (r * y) % (_m as u64);\r\n }\r\n y = (y * y) % (_m as u64);\r\n n >>= 1;\r\n }\r\n r as i64\r\n }\r\n\r\n /* const */\r\n pub(crate) fn is_prime(n: i32) -> bool {\r\n let n = n as i64;\r\n match n {\r\n _ if n <= 1 => return false,\r\n 2 | 7 | 61 => return true,\r\n _ if n % 2 == 0 => return false,\r\n _ => {}\r\n }\r\n let mut d = n - 1;\r\n while d % 2 == 0 {\r\n d /= 2;\r\n }\r\n for &a in &[2, 7, 61] {\r\n let mut t = d;\r\n let mut y = pow_mod(a, t, n as i32);\r\n while t != n - 1 && y != 1 && y != n - 1 {\r\n y = y * y % n;\r\n t <<= 1;\r\n }\r\n if y != n - 1 && t % 2 == 0 {\r\n return false;\r\n }\r\n }\r\n true\r\n }\r\n\r\n /* const */\r\n #[allow(clippy::many_single_char_names)]\r\n pub(crate) fn inv_gcd(a: i64, b: i64) -> (i64, i64) {\r\n let a = safe_mod(a, b);\r\n if a == 0 {\r\n return (b, 0);\r\n }\r\n\r\n let mut s = b;\r\n let mut t = a;\r\n let mut m0 = 0;\r\n let mut m1 = 1;\r\n\r\n while t != 0 {\r\n let u = s / t;\r\n s -= t * u;\r\n m0 -= m1 * u; // |m1 * u| <= |m1| * s <= b\r\n\r\n swap(&mut s, &mut t);\r\n swap(&mut m0, &mut m1);\r\n }\r\n if m0 < 0 {\r\n m0 += b / s;\r\n }\r\n (s, m0)\r\n }\r\n\r\n /* const */\r\n pub(crate) fn primitive_root(m: i32) -> i32 {\r\n match m {\r\n 2 => return 1,\r\n 167_772_161 => return 3,\r\n 469_762_049 => return 3,\r\n 754_974_721 => return 11,\r\n 998_244_353 => return 3,\r\n _ => {}\r\n }\r\n\r\n let mut divs = [0; 20];\r\n divs[0] = 2;\r\n let mut cnt = 1;\r\n let mut x = (m - 1) / 2;\r\n while x % 2 == 0 {\r\n x /= 2;\r\n }\r\n for i in (3..std::i32::MAX).step_by(2) {\r\n if i as i64 * i as i64 > x as i64 {\r\n break;\r\n }\r\n if x % i == 0 {\r\n divs[cnt] = i;\r\n cnt += 1;\r\n while x % i == 0 {\r\n x /= i;\r\n }\r\n }\r\n }\r\n if x > 1 {\r\n divs[cnt] = x;\r\n cnt += 1;\r\n }\r\n let mut g = 2;\r\n loop {\r\n if (0..cnt).all(|i| pow_mod(g, ((m - 1) / divs[i]) as i64, m) != 1) {\r\n break g as i32;\r\n }\r\n g += 1;\r\n }\r\n }\r\n}\r\npub mod modint {\r\n\r\n use crate::internal_math;\r\n use std::{\r\n cell::RefCell,\r\n convert::{Infallible, TryInto as _},\r\n fmt,\r\n hash::{Hash, Hasher},\r\n iter::{Product, Sum},\r\n marker::PhantomData,\r\n ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign},\r\n str::FromStr,\r\n sync::atomic::{self, AtomicU32, AtomicU64},\r\n thread::LocalKey,\r\n };\r\n\r\n pub type ModInt1000000007 = StaticModInt;\r\n pub type ModInt998244353 = StaticModInt;\r\n pub type ModInt = DynamicModInt;\r\n\r\n #[derive(Copy, Clone, Eq, PartialEq)]\r\n #[repr(transparent)]\r\n pub struct StaticModInt {\r\n val: u32,\r\n phantom: PhantomData M>,\r\n }\r\n\r\n impl StaticModInt {\r\n #[inline(always)]\r\n pub fn modulus() -> u32 {\r\n M::VALUE\r\n }\r\n\r\n #[inline]\r\n pub fn new(val: T) -> Self {\r\n Self::raw(val.rem_euclid_u32(M::VALUE))\r\n }\r\n\r\n #[inline]\r\n pub fn raw(val: u32) -> Self {\r\n Self {\r\n val,\r\n phantom: PhantomData,\r\n }\r\n }\r\n\r\n #[inline]\r\n pub fn val(self) -> u32 {\r\n self.val\r\n }\r\n\r\n #[inline]\r\n pub fn pow(self, n: u64) -> Self {\r\n ::pow(self, n)\r\n }\r\n\r\n #[inline]\r\n pub fn inv(self) -> Self {\r\n if M::HINT_VALUE_IS_PRIME {\r\n if self.val() == 0 {\r\n panic!(\"attempt to divide by zero\");\r\n }\r\n debug_assert!(\r\n internal_math::is_prime(M::VALUE.try_into().unwrap()),\r\n \"{} is not a prime number\",\r\n M::VALUE,\r\n );\r\n self.pow((M::VALUE - 2).into())\r\n } else {\r\n Self::inv_for_non_prime_modulus(self)\r\n }\r\n }\r\n }\r\n\r\n impl ModIntBase for StaticModInt {\r\n #[inline(always)]\r\n fn modulus() -> u32 {\r\n Self::modulus()\r\n }\r\n\r\n #[inline]\r\n fn raw(val: u32) -> Self {\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn val(self) -> u32 {\r\n self.val()\r\n }\r\n\r\n #[inline]\r\n fn inv(self) -> Self {\r\n self.inv()\r\n }\r\n }\r\n\r\n pub trait Modulus: 'static + Copy + Eq {\r\n const VALUE: u32;\r\n const HINT_VALUE_IS_PRIME: bool;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>>;\r\n }\r\n\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum Mod1000000007 {}\r\n\r\n impl Modulus for Mod1000000007 {\r\n const VALUE: u32 = 1_000_000_007;\r\n const HINT_VALUE_IS_PRIME: bool = true;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>> {\r\n thread_local! {\r\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\r\n }\r\n &BUTTERFLY_CACHE\r\n }\r\n }\r\n\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum Mod998244353 {}\r\n\r\n impl Modulus for Mod998244353 {\r\n const VALUE: u32 = 998_244_353;\r\n const HINT_VALUE_IS_PRIME: bool = true;\r\n\r\n fn butterfly_cache() -> &'static LocalKey>>> {\r\n thread_local! {\r\n static BUTTERFLY_CACHE: RefCell>> = RefCell::default();\r\n }\r\n &BUTTERFLY_CACHE\r\n }\r\n }\r\n\r\n pub struct ButterflyCache {\r\n pub(crate) sum_e: Vec>,\r\n pub(crate) sum_ie: Vec>,\r\n }\r\n\r\n #[derive(Copy, Clone, Eq, PartialEq)]\r\n #[repr(transparent)]\r\n pub struct DynamicModInt {\r\n val: u32,\r\n phantom: PhantomData I>,\r\n }\r\n\r\n impl DynamicModInt {\r\n #[inline]\r\n pub fn modulus() -> u32 {\r\n I::companion_barrett().umod()\r\n }\r\n\r\n #[inline]\r\n pub fn set_modulus(modulus: u32) {\r\n if modulus == 0 {\r\n panic!(\"the modulus must not be 0\");\r\n }\r\n I::companion_barrett().update(modulus);\r\n }\r\n\r\n #[inline]\r\n pub fn new(val: T) -> Self {\r\n ::new(val)\r\n }\r\n\r\n #[inline]\r\n pub fn raw(val: u32) -> Self {\r\n Self {\r\n val,\r\n phantom: PhantomData,\r\n }\r\n }\r\n\r\n #[inline]\r\n pub fn val(self) -> u32 {\r\n self.val\r\n }\r\n\r\n #[inline]\r\n pub fn pow(self, n: u64) -> Self {\r\n ::pow(self, n)\r\n }\r\n\r\n #[inline]\r\n pub fn inv(self) -> Self {\r\n Self::inv_for_non_prime_modulus(self)\r\n }\r\n }\r\n\r\n impl ModIntBase for DynamicModInt {\r\n #[inline]\r\n fn modulus() -> u32 {\r\n Self::modulus()\r\n }\r\n\r\n #[inline]\r\n fn raw(val: u32) -> Self {\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn val(self) -> u32 {\r\n self.val()\r\n }\r\n\r\n #[inline]\r\n fn inv(self) -> Self {\r\n self.inv()\r\n }\r\n }\r\n\r\n pub trait Id: 'static + Copy + Eq {\r\n fn companion_barrett() -> &'static Barrett;\r\n }\r\n\r\n #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]\r\n pub enum DefaultId {}\r\n\r\n impl Id for DefaultId {\r\n fn companion_barrett() -> &'static Barrett {\r\n static BARRETT: Barrett = Barrett::default();\r\n &BARRETT\r\n }\r\n }\r\n\r\n pub struct Barrett {\r\n m: AtomicU32,\r\n im: AtomicU64,\r\n }\r\n\r\n impl Barrett {\r\n #[inline]\r\n pub const fn new(m: u32) -> Self {\r\n Self {\r\n m: AtomicU32::new(m),\r\n im: AtomicU64::new((-1i64 as u64 / m as u64).wrapping_add(1)),\r\n }\r\n }\r\n\r\n #[inline]\r\n const fn default() -> Self {\r\n Self::new(998_244_353)\r\n }\r\n\r\n #[inline]\r\n fn update(&self, m: u32) {\r\n let im = (-1i64 as u64 / m as u64).wrapping_add(1);\r\n self.m.store(m, atomic::Ordering::SeqCst);\r\n self.im.store(im, atomic::Ordering::SeqCst);\r\n }\r\n\r\n #[inline]\r\n fn umod(&self) -> u32 {\r\n self.m.load(atomic::Ordering::SeqCst)\r\n }\r\n\r\n #[inline]\r\n fn mul(&self, a: u32, b: u32) -> u32 {\r\n let m = self.m.load(atomic::Ordering::SeqCst);\r\n let im = self.im.load(atomic::Ordering::SeqCst);\r\n internal_math::mul_mod(a, b, m, im)\r\n }\r\n }\r\n\r\n impl Default for Barrett {\r\n #[inline]\r\n fn default() -> Self {\r\n Self::default()\r\n }\r\n }\r\n\r\n pub trait ModIntBase:\r\n Default\r\n + FromStr\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + From\r\n + Copy\r\n + Eq\r\n + Hash\r\n + fmt::Display\r\n + fmt::Debug\r\n + Neg\r\n + Add\r\n + Sub\r\n + Mul\r\n + Div\r\n + AddAssign\r\n + SubAssign\r\n + MulAssign\r\n + DivAssign\r\n {\r\n fn modulus() -> u32;\r\n\r\n fn raw(val: u32) -> Self;\r\n\r\n fn val(self) -> u32;\r\n\r\n fn inv(self) -> Self;\r\n\r\n #[inline]\r\n fn new(val: T) -> Self {\r\n Self::raw(val.rem_euclid_u32(Self::modulus()))\r\n }\r\n\r\n #[inline]\r\n fn pow(self, mut n: u64) -> Self {\r\n let mut x = self;\r\n let mut r = Self::raw(1);\r\n while n > 0 {\r\n if n & 1 == 1 {\r\n r *= x;\r\n }\r\n x *= x;\r\n n >>= 1;\r\n }\r\n r\r\n }\r\n }\r\n\r\n pub trait RemEuclidU32 {\r\n fn rem_euclid_u32(self, modulus: u32) -> u32;\r\n }\r\n\r\n macro_rules! impl_rem_euclid_u32_for_small_signed {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n (self as i64).rem_euclid(i64::from(modulus)) as _\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n impl_rem_euclid_u32_for_small_signed!(i8, i16, i32, i64, isize);\r\n\r\n impl RemEuclidU32 for i128 {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n self.rem_euclid(i128::from(modulus)) as _\r\n }\r\n }\r\n\r\n macro_rules! impl_rem_euclid_u32_for_small_unsigned {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n self as u32 % modulus\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n macro_rules! impl_rem_euclid_u32_for_large_unsigned {\r\n ($($ty:tt),*) => {\r\n $(\r\n impl RemEuclidU32 for $ty {\r\n #[inline]\r\n fn rem_euclid_u32(self, modulus: u32) -> u32 {\r\n (self % (modulus as $ty)) as _\r\n }\r\n }\r\n )*\r\n }\r\n}\r\n\r\n impl_rem_euclid_u32_for_small_unsigned!(u8, u16, u32);\r\n impl_rem_euclid_u32_for_large_unsigned!(u64, u128);\r\n\r\n #[cfg(target_pointer_width = \"32\")]\r\n impl_rem_euclid_u32_for_small_unsigned!(usize);\r\n\r\n #[cfg(target_pointer_width = \"64\")]\r\n impl_rem_euclid_u32_for_large_unsigned!(usize);\r\n\r\n trait InternalImplementations: ModIntBase {\r\n #[inline]\r\n fn inv_for_non_prime_modulus(this: Self) -> Self {\r\n let (gcd, x) = internal_math::inv_gcd(this.val().into(), Self::modulus().into());\r\n if gcd != 1 {\r\n panic!(\"the multiplicative inverse does not exist\");\r\n }\r\n Self::new(x)\r\n }\r\n\r\n #[inline]\r\n fn default_impl() -> Self {\r\n Self::raw(0)\r\n }\r\n\r\n #[inline]\r\n fn from_str_impl(s: &str) -> Result {\r\n Ok(s.parse::()\r\n .map(Self::new)\r\n .unwrap_or_else(|_| todo!(\"parsing as an arbitrary precision integer?\")))\r\n }\r\n\r\n #[inline]\r\n fn hash_impl(this: &Self, state: &mut impl Hasher) {\r\n this.val().hash(state)\r\n }\r\n\r\n #[inline]\r\n fn display_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\r\n fmt::Display::fmt(&this.val(), f)\r\n }\r\n\r\n #[inline]\r\n fn debug_impl(this: &Self, f: &mut fmt::Formatter) -> fmt::Result {\r\n fmt::Debug::fmt(&this.val(), f)\r\n }\r\n\r\n #[inline]\r\n fn neg_impl(this: Self) -> Self {\r\n Self::sub_impl(Self::raw(0), this)\r\n }\r\n\r\n #[inline]\r\n fn add_impl(lhs: Self, rhs: Self) -> Self {\r\n let modulus = Self::modulus();\r\n let mut val = lhs.val() + rhs.val();\r\n if val >= modulus {\r\n val -= modulus;\r\n }\r\n Self::raw(val)\r\n }\r\n\r\n #[inline]\r\n fn sub_impl(lhs: Self, rhs: Self) -> Self {\r\n let modulus = Self::modulus();\r\n let mut val = lhs.val().wrapping_sub(rhs.val());\r\n if val >= modulus {\r\n val = val.wrapping_add(modulus)\r\n }\r\n Self::raw(val)\r\n }\r\n\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self;\r\n\r\n #[inline]\r\n fn div_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::mul_impl(lhs, rhs.inv())\r\n }\r\n }\r\n\r\n impl InternalImplementations for StaticModInt {\r\n #[inline]\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::raw((u64::from(lhs.val()) * u64::from(rhs.val()) % u64::from(M::VALUE)) as u32)\r\n }\r\n }\r\n\r\n impl InternalImplementations for DynamicModInt {\r\n #[inline]\r\n fn mul_impl(lhs: Self, rhs: Self) -> Self {\r\n Self::raw(I::companion_barrett().mul(lhs.val, rhs.val))\r\n }\r\n }\r\n\r\n macro_rules! impl_basic_traits {\r\n () => {};\r\n (impl <$generic_param:ident : $generic_param_bound:tt> _ for $self:ty; $($rest:tt)*) => {\r\n impl <$generic_param: $generic_param_bound> Default for $self {\r\n #[inline]\r\n fn default() -> Self {\r\n Self::default_impl()\r\n }\r\n }\r\n\r\n impl <$generic_param: $generic_param_bound> FromStr for $self {\r\n type Err = Infallible;\r\n\r\n #[inline]\r\n fn from_str(s: &str) -> Result {\r\n Self::from_str_impl(s)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound, V: RemEuclidU32> From for $self {\r\n #[inline]\r\n fn from(from: V) -> Self {\r\n Self::new(from)\r\n }\r\n }\r\n\r\n #[allow(clippy::derive_hash_xor_eq)]\r\n impl<$generic_param: $generic_param_bound> Hash for $self {\r\n #[inline]\r\n fn hash(&self, state: &mut H) {\r\n Self::hash_impl(self, state)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> fmt::Display for $self {\r\n #[inline]\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n Self::display_impl(self, f)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> fmt::Debug for $self {\r\n #[inline]\r\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\r\n Self::debug_impl(self, f)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> Neg for $self {\r\n type Output = $self;\r\n\r\n #[inline]\r\n fn neg(self) -> $self {\r\n Self::neg_impl(self)\r\n }\r\n }\r\n\r\n impl<$generic_param: $generic_param_bound> Neg for &'_ $self {\r\n type Output = $self;\r\n\r\n #[inline]\r\n fn neg(self) -> $self {\r\n <$self>::neg_impl(*self)\r\n }\r\n }\r\n\r\n impl_basic_traits!($($rest)*);\r\n };\r\n}\r\n\r\n impl_basic_traits! {\r\n impl _ for StaticModInt ;\r\n impl _ for DynamicModInt;\r\n }\r\n\r\n macro_rules! impl_bin_ops {\r\n () => {};\r\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~ <$rhs_ty:ty> -> $output:ty { { $lhs_body:expr } ~ { $rhs_body:expr } } $($rest:tt)*) => {\r\n impl <$($generic_param: $generic_param_bound),*> Add<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn add(self, rhs: $rhs_ty) -> $output {\r\n <$output>::add_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Sub<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn sub(self, rhs: $rhs_ty) -> $output {\r\n <$output>::sub_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Mul<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn mul(self, rhs: $rhs_ty) -> $output {\r\n <$output>::mul_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> Div<$rhs_ty> for $lhs_ty {\r\n type Output = $output;\r\n\r\n #[inline]\r\n fn div(self, rhs: $rhs_ty) -> $output {\r\n <$output>::div_impl(apply($lhs_body, self), apply($rhs_body, rhs))\r\n }\r\n }\r\n\r\n impl_bin_ops!($($rest)*);\r\n };\r\n}\r\n\r\n macro_rules! impl_assign_ops {\r\n () => {};\r\n (for<$($generic_param:ident : $generic_param_bound:tt),*> <$lhs_ty:ty> ~= <$rhs_ty:ty> { _ ~= { $rhs_body:expr } } $($rest:tt)*) => {\r\n impl <$($generic_param: $generic_param_bound),*> AddAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn add_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self + apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> SubAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn sub_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self - apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> MulAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn mul_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self * apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl <$($generic_param: $generic_param_bound),*> DivAssign<$rhs_ty> for $lhs_ty {\r\n #[inline]\r\n fn div_assign(&mut self, rhs: $rhs_ty) {\r\n *self = *self / apply($rhs_body, rhs);\r\n }\r\n }\r\n\r\n impl_assign_ops!($($rest)*);\r\n };\r\n}\r\n\r\n #[inline]\r\n fn apply O, X, O>(f: F, x: X) -> O {\r\n f(x)\r\n }\r\n\r\n impl_bin_ops! {\r\n for > ~ > -> StaticModInt { { |x| x } ~ { |x| x } }\r\n for > ~ <&'_ StaticModInt > -> StaticModInt { { |x| x } ~ { |&x| x } }\r\n for <&'_ StaticModInt > ~ > -> StaticModInt { { |&x| x } ~ { |x| x } }\r\n for <&'_ StaticModInt > ~ <&'_ StaticModInt > -> StaticModInt { { |&x| x } ~ { |&x| x } }\r\n for > ~ > -> DynamicModInt { { |x| x } ~ { |x| x } }\r\n for > ~ <&'_ DynamicModInt> -> DynamicModInt { { |x| x } ~ { |&x| x } }\r\n for <&'_ DynamicModInt> ~ > -> DynamicModInt { { |&x| x } ~ { |x| x } }\r\n for <&'_ DynamicModInt> ~ <&'_ DynamicModInt> -> DynamicModInt { { |&x| x } ~ { |&x| x } }\r\n\r\n for > ~ -> StaticModInt { { |x| x } ~ { StaticModInt::::new } }\r\n for > ~ -> DynamicModInt { { |x| x } ~ { DynamicModInt::::new } }\r\n }\r\n\r\n impl_assign_ops! {\r\n for > ~= > { _ ~= { |x| x } }\r\n for > ~= <&'_ StaticModInt > { _ ~= { |&x| x } }\r\n for > ~= > { _ ~= { |x| x } }\r\n for > ~= <&'_ DynamicModInt> { _ ~= { |&x| x } }\r\n\r\n for > ~= { _ ~= { StaticModInt::::new } }\r\n for > ~= { _ ~= { DynamicModInt::::new } }\r\n }\r\n\r\n macro_rules! impl_folding {\r\n () => {};\r\n (impl<$generic_param:ident : $generic_param_bound:tt> $trait:ident<_> for $self:ty { fn $method:ident(_) -> _ { _($unit:expr, $op:expr) } } $($rest:tt)*) => {\r\n impl<$generic_param: $generic_param_bound> $trait for $self {\r\n #[inline]\r\n fn $method(iter: S) -> Self\r\n where\r\n S: Iterator,\r\n {\r\n iter.fold($unit, $op)\r\n }\r\n }\r\n\r\n impl<'a, $generic_param: $generic_param_bound> $trait<&'a Self> for $self {\r\n #[inline]\r\n fn $method(iter: S) -> Self\r\n where\r\n S: Iterator,\r\n {\r\n iter.fold($unit, $op)\r\n }\r\n }\r\n\r\n impl_folding!($($rest)*);\r\n };\r\n}\r\n\r\n impl_folding! {\r\n impl Sum<_> for StaticModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\r\n impl Product<_> for StaticModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\r\n impl Sum<_> for DynamicModInt { fn sum(_) -> _ { _(Self::raw(0), Add::add) } }\r\n impl Product<_> for DynamicModInt { fn product(_) -> _ { _(Self::raw(1), Mul::mul) } }\r\n }\r\n}\r\n", "lang": "Rust", "bug_code_uid": "3f924492a05c51c21e2d2665c7f00bdb", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "apr_id": "bd098a62effceb83d3217c3a3fe518ab", "difficulty": 1200, "tags": ["math", "combinatorics", "bitmasks"], "bug_exec_outcome": "COMPILATION_ERROR", "potential_dominant_fix_op": "insert", "lang_cluster": "Rust"}

-:,EP/0HK7+9:=)@7;240FF3?>OBA7IBX;;3U@VAN5.8E=*?B8W<@9+;/@;?.5W?A;Q8;BT;3:J;W:<8P@Y>R1OB45B>28X:4D@9F6FIN47:T6,C68?@E884=F98D;;:A@866D.2?CS3+G)3C@==,:*>Q2CDJ;M>O;P7@:GA.:85N?W9X?6<:<5:R7RB-8FGR5870;.:G=+@593A(6Y:;@+9@=J@F1/F*5)@.70;8@X@S79<7=U4:E@729A?)>=7X9DBX1G@2@U7/:)?K;6@B:J6DGP/0:3JL4Y7M@:=A;H;S7MA2;Y30G*7N;/>A8=>S<6(9-BF=G9B2WKH3Y>Y8(A=<(6L;)?H8W@=4)A76H@M=K9U7;:-=U<:@R6Q:8F011@E8MG<)<5?=@M3V:L>+?T=43R8LGD2:?X=(;V:C@,4H;(EH8J7H>-9(D+2BCF8B>E=(;3;N?@9=9B?6>J3S=J7;<)79BS;+4QE?5Q37DN4EB069E8TYA:24??64:.?A@C9-BD2B93BR==@57*A>7F=M6E<+8S;A@L9YFI/Q=OBO7>>S=)7+9+B@6T@Y9U<,><>.9U3)B)3?@=A9=K74BS3F<3A=:@7/D@9:=4516OE9AF2L?<9LCC3@CV6-:JB.4V>A>0>42*GM6CBO616PEW978A66B@;C:.D=5OC28-:3;-3EGB?S40?F7/>S5.@T=S@24?8+EL7D=GC82CA=6??J:*=R8G?W9.=2@U4;@O=38>E=7F778BD78)9:=E;1B921D38/?F<3;F8AAD8W=-7@-5W23=EM57:H?D<+93;;CR9S5(AH9(BI8O8G?C:>:-7YA6C;B45?X@O5R>R4/CG8CA=9(?=7+65G;2D7LH845BO:4;;@G7EA6:.4@F54F?87(AD>)?X8Y2N@8=86T@R7-@E>47?=F8.A8?K88=77O<9BV4W;,B.3=>XAB:96:A79E33H=:,<)9D>S:M>>>R,WGA?D4X==<,=P8S?C8X=(=(?A1CER8Q7WE<5+MJ-T;O=4AD9K7J?A:A>F>;8)=<<5I:7CI00J844A0;L8W=V;76;A/:EE)5-9+CJ5SA37C82CU6A@J:K9TB2<,7V=@?U(8U>H=8S4K=7C)8:9(>>+8L?561B+;A;(@=66C<6V9BDU2+=2AV8D;;9H@.=G;3;C5REK5S;9=J92EM4.:AE14F;U>T=?64?*;U:3R?M05C?:P9,A299>,AF738M;F<8;<9W=.B=;,<,6+>O<;8/>@;-8>C>:3>7=<66?W=767A?6WI=3:O@75CAY;4KC@17.=@=5<29@:RB41EA3::N;,>X66<,:.B)98:.<:BG8/>O8P<-@H7A46IH5F=W9,I=;:A>C<:7K>K=@8K=*8YD=8-;=;I?G6YA;7,?J6O=G?U8-?L9/:B:X>A;EA61OB??+6U>64RD5:C=5>A:6998/:JD28:53EK7OA@:=44@:6/D??M7T6YB;4Y5N>>>N9T9IB74Y;:BX9.;M<6BA3:L4@?.:*BNF9+P6J8VCR5T9FW;49MAQ::6?A3AF5T9J=B;3@57E=F3G<8?4?67-?Q9+=(@2:O=P5T;H=+:>DS5V:8A8:U=F8:9H=1:8@7:57*E646BW3@BV5/BX?M/+C78P=.AW6@Y6E:B:7BH7XA):(=7;@<14/GX17C>75BQ5S;K9@?;A*:Y88D-6360F-8U<@9>B22V?W;S9A>+:CBD>(5X8H:)@9KB14=?8?>72A,7G>-;1:U>=>P:/8P:Q@V?K2?CM4,E@4J?+:P8IC+6(85>5@E=?;X?J43?:?49V3YAO@;9K4PCL8L?>;8:H3HH)7A>87+@E?P809M@T9U7K?@;)?P?H91:K91@K5S>N:H>=9W>W;D;C=C7R8)BO;N:8;S;+=3:8P8/@A?+4)<,=Q9>?V>;:,;+6,EK5A@FBG2<:LF=-=B/?36VC-:(97?;;H7BAP;P9,AC0H?G;,?;89>P:/;T9/EG59:+??>80BE2;;A@294AP7,B23-@L9/@>7RAG8V6;BS=X3U<4>>>13JB9;8:/CG/OB@=HR8*=B9+?:-AI1XEH95;*=4<1?T7M:<==?G4IBS6I?3<;:G7P;H;=E2948A@<9B49GI(S;V@/73@X9V6J>V5CAD>E6C8LCW4VD145>4>?:A;/::6O@-?D:;CJ5E;+8,=Q;K(DI4,9C=M=.;C:<<)@*31;DC,@*7M9,?6<::M9BD<2L53HH5?EB34BJ5U=RAA;?8,8U5@BS?G<)90AQ7J:3;C;5?0@W4,C=8I;D7U=U=HAN9+6W;C=9?<75A4465YDI7<9K9WBD79=Q;N?X7,=G9?:BBY9-?Q81<=>37<8C=V6G>0CH1R>>>AA?7I@B2?><60A+;XA)3U=R@-918DFC2S=U@49;@P/7?YDJ4PFE38B-3K=-C)?+593QC(=?:SX:5=W6C0AAA=R35?);->><,7P=(;X<-=->4:(=Y5TE9R:H=E;*?C8X=CKBQ.JI)0I;ICU7W>V:H6=>A>T86B<7+>7>Y>Q6P7XCU:X6/?K58CK8:BP8259GM3BEM45X56A2>,86A7<=5WA>5TD?5P:B@;8*AD4DB4=74=X3@CL=>:(7W>(:3=Q8L>H?G1HB)?D5I6T>*>?6T>Y=W3.EE6==V:2=W?Y9C;>@G6A<=>8:J?D57;F;U;;@M8-=14+BN=K>*;/>O>601DR:C8H?E>09,:T=+;H@B7+;X>2:L9D96H//HDI3XC:=S7WEA6:K=,>(2I?B<8@O57=<<6@P:*8U>Q=9;5:889?.5)T3FCQ7/7CGV:<2QC?2?@A50D?>29M5:(@54.>2<4ED4*6@:BGU31=T<)8(A1=O=;>E813QI103AJ:>AQ2TF1:X4DC;5:9;CX7J:I=R@>9K:9@/=G7W>I8@;J69FQ76DV0BIB20:85;O9+7CH0=-6*@A?-1HA74=H-4M>@;V:69P>?>B<69H7NB)8;:7H=P=,7AAR7T=M?T77@787:C57ATCA8-:4:V>/:R<+;?=U:H:P>4::=1<:83;MCN86;)74?O7SAM=L6CB6BB4U?P31:5)EV;?:*9J?/46B8>O8*=@5,DL:O9T@@99@K:7:I:(I22*=J57>4?B:J;2=K:C;N;V4@D+:5<7C@V8/9H9A>39SQ6DA;:S<.?X;46UCA8>9-80B:8MB<A;K=DB@0+>I;,=S;=?.8484?CA89>Q9,66>R;X:1>P>I=M:C7T>M:X7P@)>A94;@AP2)A58FCT7<3DC*A*2E@K1>;.1<?4XFR67;I@-92?44H;@?1<1:*?V:+:.=G=H8??(<9?.6>:;EL31A58,=*@O;Q8M?Q:O6T>M>DG/X?;@52SA771@6?E:69?80=O?(;B=D53AK:+=(;U<0:3A6>BB8A+E6:89T7/<3A86C?+=674R:Q9J;0:W;79B@:99A777=VAQ7K=2:.:P81??=-97>R>)7)@R9471?R9O>(:IAT3H>=CK6O?H:*76B@3H>L;?<2<7AS:K=07O?4;46L@L=74AA0:K?Q?24)>,=P>K:=8688ADBS5M:?9R:G@F<2290;9U987J<->-A=?S5671?2;T?B2A5(B-9S:1A@8-<-<7=V:==-9W6-G74T?J*9F8H:>N8V8K;M?27?FW-J>MBS5-CC>:96:F=-;G=8<)6BEP0M@,>,5(AR;<:C?=:D9W?X;H1JA:DB5L8Q@G41D*<2;V:>?<3,>O@1>>X3L:TEV971;?RA+<>1DBI>,;:;,9U93AS:I:*==9I)8CA=>J3EF56G;NBF8-:+>66-F-4(5GD>4KGS3VBU7X;8:W@86PT80>K?-7A9T>2A66S=O6C;W<<;C7R@993;?6VC>;3@76R@::B>@0N=V=DCY935@EW0R=S@R4LF,8X6-AP8Q9>BF90B48);,6ED8:*:(9N;ECU7A>I6H?B9B>?6B76BS=M:?>=6EDT:.5-@/6?F;::.?-14B-.8DEH57:P>/:,9VCG:96W7;9@87V8W>Q>+5/LA/1AU7N:*>E?-7R>K=09Y=.=@7B@-8*@6=G8L;P<(8N?G76<8?E;F/?V1NAJ7<@@9Y;.?-:NY:57P;M=F>,;I?T0EG(9440@X:1?X;+88.=SDJ,9E@1?;U7CD?2T?Q>J;V)?*;GP@P9.67@P:W;=>893;9?/45V@8;*;<9ID<.>?E@25NGA64?96CAUA228Y9G71AX@J5X;0<(>L;49S8O?39QEA.I>V<+=K@W9):C>6>48/.9WCW03:BDO6?@5@;8I8E?E9E9+.=84FHR.R@?>98F.5CE=/BAN6K;G;B@P?B8/E-1N?+=@;4=963AQ9E9Y?T4/;=DT;*:U9R@/8)2;V<+;.>YAF:V7V=F9A/<*8+CJ27@A4>73PFF6(:B>.<16KBQ9Q<<>.;963DD8R?N8-83E<1ED*:I62A480A5;?@9VJ8J9H>,:3=4?06@@77-C3;(;(:*@;?K2>CJ0EA;K7D=W@0D6*A+AL3@B2I<.E;;743C7;O8D@W8CA11GACAB59AX40>H;C>S=I9:6AI8Q<59P;9HN1E9F>:A8994@G;*7CCV8:6OA(8P73:5B/6M:>>*:X7>DAA;1>@C;,67B(?(9I>E107A<81@J>G5R?W;99IL4@B=@(=>;K4/8@AM?I:7A@;T7A:U?P:T9,93@A;7:G8MC,9W=K:E:Q<6>+8P7A=UCV8;5RE,96:K75@)=PDCX3JD(22=@=Y73@=92=>A?9W;X5B>O@R:19N@>8M>-AH5::E;UC:6>(>?>F1HC;:G:J4CGH5;;J?.?B3):0DS57E+@F3=EK2P<8=0:C@>8L@/:T<)B*8)6E@5:5B5<36<>G3S?OBF4U:A@(1NL?5<>E5.D25CA<<(8LBS3=>I7,:MA7;9;U5?.7I>Q81=T5UE(9V3;=Q?I?65O;K@Y*>O7T?I8C82@O9J>19:>F,6P=(;7?X75=V:S=4>658?J@F9CD59E/?P=N6JB4;<4H@09)>)>7N5M=R>49B=M==>81.AI9T>+=P8=:G=@=N6N?8BI87:,4<.>R7:;0A.@F9=7(AE6W@<6V@C>F5R<(9J>:?C>?13BB;46;V3.G93J=R:?AF?A9F5-AF36??(94<+A<8:;B:03=5;E=W61@F5Q@47*?-,;M47CD8H=D?F5S>J8+D*9-7CAX<:?(<-4P=Q;H<9;::;;TDF609Q@>B5+?-B?=;2U@P9P;Y@D8(<(@88K@1:K:G;V;K@34Y?G:O==7JD)6;??;65.6I=D<*:,;A@W9K;,9Q=R>8:,:*AP869F?H8FA773?Q8@=/9)BP:4>Q35>N>3?3:U29>,@(>=3*7?5P6+BM<5@03Y?M9HB9.ABU=9<.5UBH;+8MB59C<>?A5X;,>*0AK9=8;GJ4G>?5;9-CC:C@05F?Y9>:4A29(D..7F+3.JL,THT7/74=(@Y=F1G?K=39(+=C;::7>F9V8*D)997G@A;K9-:-;MC+;;8.?*;E8O;0?W;<8+A=78;3DE7-96A/55>+?@:J99:;>H83?MY@I:M:@=C;A7.>P=1AG6M:N?5:G:;9R@1;O8G@W6;?9:JAF9C6OAD9*>)?V844A@A>,<)9@7W?>?E;(8E@:<;:P?6:X1HFX5SA)6Q=W>@7.?-9A>->A9S==U7D?09*>M7QE-6=X9F;X=*8R?W:2P3X>NCK9?6=?3:(;1=9;=;A>SCD3NA)980RE*E60@Q72:T@-6G<,>*;7?DA*=H63>=A>,5@:-K34:?E>.4Q@J=2:O89:A:I?E85>/4/=B=0:B:PAP6/;G@.?C:(;L9@BG2(BM=Q8C;@75A(8>;/DP7O6QA88C)=P4-E07V4)GP7)8WDM26?<=4?R60=M;/;?S8LA01:=H>FA/4?A.;N3,B)8P=D@U65;8M=S@794>M4A:9B2;D7V;@6QJ18O=:4*@;:=><:U9)DX7):):1>(@>929AAT8/;.AO2,@G?@=Y3Q>N:F9>DC5E?07S<293DF;5;29J:0BH9I7(A/;V?43?AL@6:K@H5M=N9978X:B76BV6S?B?S7TA(8D<1;.@75ECL:X=E8+9*EH.GCN0IC*@Y5*BW<15/HA0/AF;DAY9V5D?(=E6J@=<>5L?@<7H5V@4=?:I:/EG/)82C:75BN>B7(7J?C;7>6?X=48V<6:4;,7VDX84:)@9=89=8*BW3*=Y?3:6@K60=Q1UC78K7X=U@*6B<4AL70:8:J?1>-8+R17DE(6H4YCR<;;3<,8A@N75BW2*C:43A,;K>/5+A2=V>H7<H?D1HF<8S7,>=;I?77G<9?+4,I<8D3H94B:;M9P:89*=>:*:SAW3MGR<<8E=;=<<39>/>C=?==B30F0:B7NFO4/@H7L4V>IAD8A>M:5:>;+?/?B;<:M:J9?B;779E@(>Y<19P;7>L88;*78B99Y;K<323B?C;K@86(=1<)?19H7:DK70:V84?>9B7LG3;-;6B/7E?M./FE:;A66S?P1G>0@W8Q=F5W=EB)6O8P@99K76EA9G;);>;Q9M>/=X7O>1;A9B99J>T6:B>;G868R?F<3;/>A;><293C40IT26>F:V:X?B<:>H94>D2N<6>,<8DD:V:89:2;L9<@B:O;M;A:K:N<1@2=9.:*=O;B=0:V?D6@:=A-:N=8:)=C?N9,89BK5(FB1Y@<2KEL;@7?BF3L>D;X:+;N7MA:AI8:?E55D875?N:F:;6B>1?;:S8SAM?;5H?29JAJ3E@350/61C4:C:@:H9?@,?C7,>Y6XAR7/@9=28:>T?28K=S/L@)CX>U8@?<67?93CC6:D8;BF53BJ6LA-27BG=;;O<82*A>??8Y@W9T?I4QC=S=,7N>/3(GP8L6@?-@>3TD-;V;54P@U>B7P=;AS;S;(4/8YE02MAE9@@R74M56EA8=9)AE9V:X6.=?>@=E??7;B,9P;W:,9O9X?W6AFV;B2=AJ<9?F74:>AM:U:M8L>M=?92;<=39/?Y7Q?8;I=X9RK2W)D26B;86A>-I?<6J>(4UCAAL8/9<>A;74SB8:*?P;69.<98U?J7(I?1BB-86A:489HCU*BW31C:73C:;.5O>/=S5Q<3>29Q;9?26L@Y=O9(>R94?Q:3<(6BHX10>,*>W3(@I:C@Y7CBU7.9GCC9L?B9X1NA<>??O2FA<=Q4V@/8-EA9Q2,B@@28V99@<:?<*AK<>=W3L=;;/LB?59I85BN94@14T:(@;V;;;58RGX75=.23G85684DA8>88CL/@EM6.<,?X13L13=A<9;8J8SAK=XY<*=*2VB374?,AL32C+=P6A9K<-DI1PA?BM0C;K??>=?U71;+=J:O:4;Y??8.T:=EK15=-;)?F:7@U3KC88E8(DX9T9,71EP5C@6;B5XBL3R<4EE5X9=9K<3BE7@=J9R?T8TBC2?DDA=5,;WBB7X9I:O=D<-:R9.E>1-UK;==B;KB452;I8F9GF)7F8XCC9W=X56=/:3E@43>)75G:5M;H3SB+=O=)?+4SD)2>*7)D*3S@4;:9E=YCV3/;29/=Q@Y>34C;RE63L?4?D8@>4K<59)8+F167=98WBS3/CB>Q;R46>/=-75@5;8?896=99J:*A67G79H75C@+;;<+8*@7>U02B5:9;Y;V82>RDB9W;B8.=D>55WYAN8U8I=L9/:Y@A;@;W>.9@>K9X;->M7KA,;=5T*1=.:E?-5XF@U8=<@C<5G;*5G8/L06>Q9T>E3(@@<;8HL?O9;4;?V4V@C?<;6?O2EC?:4;B9>AV6U<)?A74I?8:=>@=9;@=K>32B>F@O4B@I63@;AN8T?F1,D;7??=AS8C7/B,4E?2AH0N8@?P=V<>=X9V8/?W;T8)6Y;B@I97=LD*8I4MDX8A34CR:*:C:3F;+,C5CS56=5@U<(8==E72;?DL1QC>1X>T?;9=D9:47)=26?@0>799?A7(A,6=AS:;<;?4;H7+?L6IP8)?UW7ABL88>U?W6D7-AG>39?<>=?7C?+AQ5I;9:1@C>J:M64=,B58B;F7,E86(;89CB10)G,8?5TIA4O@U3.I*7378>;?>4DW8)65BY3DC??V?,4,;B>Y/A>KD8:G9G8UHK21=T9M?*@H1LA;Q?X:U:>9I@-9:=M8=>5=B:)=>>N5=A29,6HCD5JGD7V<2@23O:KAQ7,:0=G?B8->W:S8Q>>9I>+:@C?:N7>:*A8:==;<6>==S;L56=W6)A?;6:9>4?EI6T85DY6(:-A36>B(3XA67/G:1H?D;KC-34:UA=963>W:V@?2<@Y=<8/;V:N>M=.:+8-B5>87(<1>*9T?:<>9.@5:S89F337=N=@8R;7,:07U@J>X7K=D8A?M>F5Y:1?R::>O9X;P>(;<<7C>D9<=A:68F>H99>N=S<3>A?+776BBU9P;8?2/2=?=@-=,(:699@)@N6.;K?0>/53=N?;/5>0@P83AS9/=?==;>AD92;,:*>8;L57W=29OHE(@DP;86.8B<:,Q:?7(@-A:0D?2S9M6Q?;A:5,@L8M<8=1@:9J4(?*AQ7;C19E48A;:N?JJ<+MJ76@67?HB74J;S<25DDE=7I@/;*8K;E=J;(@M9;=E:=:X=:V76?5AN2KA*:U:U>/5C?Q8@AW:T>:4D@4?99X:4AQ/IB99T?U=D5U>W=:=U:?W=QG2>H,5/;>:S>HBU916@>/@;8?9B=687C>9S7N@;>2=581:>>86J?=9B>>8=Q8E;3E04Q7;>8>/;C;->6;8?<6@7N?A@26)8-BO<1?S73DI4U;95GC8AQ:P4N9KDK72<17L=6DT7H>H98C//8C,42B(I6D8BA*9+;BA(:N:6=O9(AY9;4WFI916O=+:IEN8877;GFK2L9SA<9T7P5DH18XAS5V@B6@DO/9A+@D2MC+;D;3@@7(BF3;?(;D;6:8;U8?E?9)B54G47V;E8<;39??9<;=-A+9@?,/.CF93<5>89/@E87@;3O>AB<;@@(0B@7=P6/AJ4XB?9Y=T5RBKB81MC*1JGH<7:S5Y?X(5Q@F76C17V=.AP4M+84;>2:B<5<,8384;,?-:;@A5NA=;=F6L:@;0*@+9L8F:SB>:):O:3?J;;B=04?><,D17BHJ=W9C=R4RBN7XB:S74DF2DD.7R9Q;:<.><;5=H;>77>/:GEO7?>A6O?C95B65+88@A:JA:H:R<<=?8A?U:E?*5E<.@3/3O:.CP50C:8-;RA67?7N@79(>M::A>86T>?5FCA8<;X=<7L>>9W;NDE5G>K2IH(3CDF8.=V9U84?W>29L@G8?<5;@;==,37EM;G6872GC9D55B1;D=2;I9GC>3=56FL@T5+?93Q@KB286<6=98,79@F?2;E=R3*BA?@15B2E:Y?(9Q:A;AF52@@B:(:1=<:C@>:,:>8;H<-7)5=E/><4KA*@E6.78B17XD78:@M870-JJ5@DO4H;>8=>1@Q6ICS;26?7CG23GCC4KCW5T;:=>AG5B=Q8W@G:O=1;/6A>Y=5>58<>D6SEO2V;BAC<38R===L55?CA=7P6YAO@*3D@6?4,@@:B:*C:;57S97DE1P?V?4=7?C5=9A=>=K74A6:+9T?4:*>*;P>N/2CO?P2YGJM9@81BR;L3AD710HM>25T7@;LBC?(4QA06+B*7:7,@;C635@C96EF2EB+6J<6?X7W;D=39N;4?N2X?E<,8J:2AP;LTAS;B44;H>==E?Y:U;:;C3>BGAE5R:Q9-DL;@04BX;B?3@71SA*9:@M8.64>9?.AX418T?E=<;M<,;R=R;3;MB45@9@@T;66:@>?/4M@57WCV8+=(<13>IB4C8X>N9PB.9W6KBT:8=<79@;CX;B66E;8119M=G7,>A@M8,>56B;@@K??7I>/4Q?8;H:9>(;5>H>W6)<;?(;5>G9.9M;-BN7F8F>EAF;,6>:WW:K?V;G=X7R7L<*BM>D2K=.=98EF)8?7<;9.89?;>C>>4P<*;-5SEH60B17N?=<-:W<<=J>.7:8GAJ9XBP8B;17X:V?*:6B*:29/;,:D=O7-@OAG2DAS:?AV5V;(T;V=7<>H31DC:C?T9->/;K9*87@@?:8H@J/5B-9F@0?=52AK7O>W8N75FV65D<5<<78?=?LB>=;H8+;P@A4JAA>22JC)>J91=(=?9I?K3Y2;O>=7N?C6V@+><75=JAU9A8Y:+>:6N@H63?M9VA999?L9V@J95:N90AN7G=:.6AAQ9Y8><0BF1XCF=F9@S3O@?9A:.;K;R@L3Y=Y;X?2@Y3O;D=>BT=66VY.8:@E6P9?EM8=7G=?AE5C>>78B(>O<::A>8:3>BE;02KBD7;<373G*:<7R<9G67E@A?C=N8A?:?:3A?94/?(=Q9W@B:9?D52<+@4<873@R:6:4>+@0:Q9S9095FG8A?L20C46:=*AR:(:,9>;:@4AS4?:/=)A?3QAE;69(A,8X6IF11LBJ6R>H@M5@W?)8V?07,=S2=Q6+BX=:1KA0>SBG;8;R9):9BIA4@8+?CB:9W7L;2AL6(@A=4:+93>R?T985MB/7+EX6P;E?(4@?8><6=+?R52<:?*;(9HCT53=T8T;Q9N?W9*:A@5?TQ6PCX5R:48;CT6MCE:D=:4=>:8WBJ6XA?9*3,H15>?V9H;C:2?87IA+8P;LB?DCM3R=M8G?U>P<572AW4I?P>T?@7U<>:O7R>;@.6@?<3=BA=QP2JBN45>A=9=J8J.5)AM8/=C@3;L4QCW:::15FAQ<=;3@090B34>7D@8?T8L;O7A?2@6;1;>>053DM18AD@@7D:Q@74@DE00@.>OA,80<,=;>P8R:W=47V>:/>:8-R>F:73/CE948;BN;;2WE2A@Y<03.B<87AQ5B?69+C7:O:E<,;5?F6+@A8:L+0/C9=Y=+9Q=I:Q5)AC9D@8@H2S<3G;M:D;R;F>2==:H38(=5:0BI2+D@7)>U@(6B:M>/,8PB+9>907GD6:YO7<M=P>B4XBB8W=:;,B=1/=);WDU.>CFAD9=3KDF:67HAF>>6Y3PBD7TAN90;??<9Y941GG:/:::>:O@B8,81BO:H;O;;71>K:3>58GCC8T>W6WCW;;3@>A?R10G>5:;2D766;*@L8,>B7=E>9;P;R6.?K;*>*@@2YI12??U;W>54C:P@T@U76=9=752?;=V84:S?B82?K@23GB55I@A:EAA4,?:8UB56,8S?K@L9T9D8YE,7D9T@>47>M71CSAL558W@W;F?M:X=S697-=I=Q?=;/9E@H:M;K;/>R//C176GF7R@Q6(=+=-7V?W<;8M?S:@):X=MBE5:=VBL4@A45+GQ42;J>D=P:P6U:1EY9A:?>A:(;S7V;3=M?4:7>(97?77RA05N>-@W24EH8R6Q;2BW6WAH5/D/:C=H3==:A,;U<<8S9I@X3>=6/A*3=?C?9=T=O3FA>87:Q?J6MC88G:W8*A0=985A<;W6-@1;J9W?+5:?-=8A-;68L?98Q<)8QAR6,>7?/6EA69Q9B>56.AG?-3-@,=V:+?=8-7T?*A94-E+;X5;AX8K:1@?997VBK669GC6?S4+>K=W:B;W;7=V@A4?:@DT6N6MB895>272>);R9==T>69;AV9?42@R7;:40C*HC24<2N?;1UB+@I:R?.2A>7AX;0-0C@;/@Q:W:V?5;U9L?@6A@I;,=O5*=B>:7FC>:H<+8X@;6/=9>U6;FJ56;LAS4H@(75AI8*=>55@9<=?N?-4H=FA>779C@*?Y;R9Q7I:>9XD+5,CI3N?;>R=/:A4@R4SA0>:6LBPF?7B>@5/@EN5,;*@-8T>J?J.OJW::2?B.>)63=S?O:E>U:=->G4AA33(GA4.CI2+E66G:WE:7,7.AS:0=R=,5/BK4(>5A.;T;->N5I>=:I=X86;U?*:G;4>W69EA/ID?CV.4DD528FCQ7BE;V=/<2;5:?BE7(=J9I>Y@8H;-<9;WEM3J;.=A0;2;5<6?982=X8N;ICK9F6B@H=Q77B=6Y?6=T4.?L=S93:Q<4@P6U;*@6?I>::*93@D:4;,=S8?94K,-FDR40;K>E:UD53D=O<2;H8.E(;:2TA@:O;?65C(6E@6=K:T?96.;C?D9P@(8N?:9/80?>9OB1;K?E65;O7IBG54BK5QC66X=3A24I:?K;4814?09F@Y7UB@1.B=9H>L7N;6AF8@>0=A8<>39)<.;1A-K=?G:/?*6?@P8/=9:M9C>;5PB7T5)D740C/E:X@V8,D788R@W?I3*=>@J?V7Y:B;B>64/FW8Q5KBQ28H(*GK5;E;79Q?3=57R>Y?(4(B03;CI<;(9->P:C:4AV6+@D9X9R>B=E:L;*BV2.=S97<,H1=R7TG15+@(6S?99V?.G=0<-;P7B;@7/C*93C82B9LB-?1;J=:7+;?U7SAL95>A6>7:5/V?7CT6F=MDN;<:X3:AI9FCL2O0=-<8<972?P=-=V8-9XF;5.?M8N)-8U9;A7:0B,6L:8<;:-@C5@G:;;E9+6KB*8CDV5Y6F<1C05E?4@X6>?N;/;P=G9<>R8OC7.;>FP8,5>?M9+DL66>U3OE88O@6-=D8*F5;E7.<=;.>2:@B.;/3J=-?D93A@66=/?848A+;+AN*75=09ND(95:X8T=H=T>64A;4C29I6UD<7F?M4P@Q:S=18-C,6R?7:D73<)4B?@?<7(8+B4@C1+CY;,=15=:1@8?WD=.H:2?.6XA);KB@1D=I>H8X=*=2<:3+CC7Q?22+@L19/>H?,:479@022D*;)BR6,A@:3828M@,;SDT0-@M3AP76@76QE65W;L;451@E:4(:XC-6F:5>S7QBL739;9CC(9K>XB<6Y:+?H3TFR=A6L8H>W5-C,5+>8<;A(<.7FB4:37S?F9,;Q@(6>>J<4;+@25C<7CI69CY/T:N?O=7=G;:9;=@<;?G8(?/7E;OC;70.<4;,>>;N75:NCL:*89<*@):O:>:T?I5TCJ6JBT9J;=087BU53?O<;9D0:P>E?H6)>C7L@1;5T2UBM9@@?7X5EH51?BU4)>UB95D>?=9<:;O@N28?)=+@==14?@@)8AC6:Y6I<5=0@1;1;+9Y;?;5?J=X;W30@,<1<,=D>>7>?P:2BD4H:UEN6T>14V:JAS8F7V@7?>:K:7PBP9:@M:0;7;S7C;@>SA(8+=P9U966PD@;.;;>B4P>-BS8/;:<3H6G<+=Y9W>S=L3M?6=GE(7L;32S@->C9O??6H@U>;=B4*BO6I:C>R@?:P7E7>4,E2X67B25S=K<882AX7/@H80?K?17<9>9,F+6N@I:*69S94<:C44P>.?H6II>1::B>597B(7D7;-?:2S>B=2=V=J6.GR,MDC999<>X>(:9?P5W;AB+8V:WBJ1+>/:(@Y;22FB@?TBAF;,8+AG4H?B7T<0AK<5<7;,;T@O4=6R7W?P?8:L51CD7M:4BU7H?,9P/RF66;:9J2=M:D9A68B/>13.<4@+=T21AA9UDG4891<9<78/B@8Q9AA?6T=A:T>W4>@89<;-D55H;;EL-C<)=JAU8R;(@@>W6OC;66C=(:*91=D;E=.6I==AQ;S@K1>A*=9;N63C?;O7Y@+;18D:G;YC(9-?H7*=0=?7H=::P@=:;7G;-BG8L9D>B;O;C9*CT3=B7=*:M>49O<17D>I:M?A7IAU:98/0;N1YFX41DK5;BQ6,?=;C:3=@8(9QA19J;Q=C75C5?@6@;:B7V:WCJ,3HE@>4<>LB-6D<9;IV;T6ICN5HBS46=K@<6G7J>O+=W8;=T8Y>?;+<*>F;K72B-6/ANJ4L@D;U?+?,6;?+2VF?9<8;?S@+9=AP2C>1=0;L??2-EE;,?N4E9PD-9K<4<*8+:NG:1KC656=S;4=R=69;<39EAE>R:K=;5T=R;*M64@87(>L7EC+>+21>R?9<=:99(>7@X:27I=*@I;@;)74DA=F3>::?)=(7/?2<3;W=B:E;4@O8K:6@D:7<:;7>@AS0L?*T;7>@8MCA2+HR7G7D@0<;68=.8OBH3>@(?;=<838,FF7I:I3;W:@4@F=8@;18/?N@G;3<);O8>9*@V9KA>:/8EA)4*CT79=.:B9)C=9J>N;64A=0AA8(@>8GBQ7L>E6D=XBF189NA:7BD922EH4OAR=<8B74@5C+6ME+4L;;9*==?Y/BC8:U9;IQ20?@8M:N:R@98T9IHA1M;I>RA7R7><2>150<6=@6=>-D;42AL<<5BU5.F:(CB1SAG8E:.C+4)CXK9,A@6R:DBC44?V9SBE8<:/>T5JE+50A;4BC?4/F)3V=Y?X63?VAY4H96BKR?748.=7CN7E@C9V=W:Q;S?+84@H7M97AY6NCW5S9SAQ8B8YAQ6V:3=1=)?F;:9>8P@S?K4E78G(SM5@@P;0>N8>@N9(CE/A:P?:?=;=;B:T8?=5G,3Q:-:@=+AN94=0/2D1@X;59>@262>V@B898VD=8:<*5*?6D77T:Q?I877W>Q=K7H?A@)6W7G;K:<><@87PA-8F@L6:>4DN8U0S?)>U<6W?F<,@;:>B>V5;DG:>9Q62CL7J9.A4;1:,9:@@*?R57=M:15)<2EN:::A:IDN6K1EE)94@K6Y7(C5<=;P5);?85@=5@49D;@88?6>);@90A::.;.9L;6?V:1@.39AP<39T:/ER7P;QD57DP4/CQ:*2I>DIM248TBW46C<49BG>=5IFB5A;C=S8D?76V=.AO5N>H1@<;AC)3G9R@>9@9(@E=(?S0DFG5XB>1PAH7+D-7/>H?T6U:K8;=1:9D73)C3<)5PCE5BH;F9;<6@::M5XD/7L:HAM7;9SB-3DE576;==VE15-<2?X=@;5<@=R8>:Q0@F5E;X;M7L@Y:(C863<)6)@71=9;4==8/<@6,@-;*>081B<<):?>B6@=?92?DB(3I;(=7=6;3=I64@R;===:K=5:T6TDBB8U?,?T3)BJ:=9N?J;7>+>-6V7O:U=>?;D8W38K9;>T6MFD5(>Q>U;9=EI77<>:*@:8DD@@4I65?C@C7@==7P@X:O?X34?):UA98E9;=3=L8SC/:3:E:UBM23AD4T@18+B0?RY/7ED70?X9B<:CY3MW>J4,C<7L>B65;3><>;I95T/SK99S2HAX8*;X?872:;B49J;/>X:C86GK3A;J>)5CH;:H4Q>P84=XA,1ADP9K@7.MAWEY7W?R4I=4=D:;;Q;N=T9C:(=>;L92;HAV6A;0@N<6;9;@B<6*=-=S7DA;;39,;?=O71C67<::T:,?M5A@5;BA;4@AN:L4J=G=.B/4U:+<6:E;V=V@:48@3:G05/;DFA81A32H>RU>C9(;R6J?1=M;A7XD@4(D66/?X4M?0;N:J:9>S?A@073>R1L?@:G>V?97A<=;H8?H3.CB9=7>B:6;8;NBI7O=WS65<-?S:E8M8:FX5Y>M4V@1<;;B=:9O>N:178CH72?>>:8;:2;I9O9K:V=Y8P:5BE6U5CC9@;;8(:.=@>;:M?O;I7J>J=D=A:,9?=T8(C1;S8I>Y6@?V6/@P?A4E8PGN10AO3CE-:QH<:A(7/>L5J=A8)?5@C8K9:@0>U92:?=U@:9*7Y>J;Q;*=26W>M>(;GAI,MK7995TAN83;HAN8V:;>O?H;R;O4GB8<=6S89BO9SAY7G;0:(;6@J3H?R=4DH23;6@4>Y5CY8+>C:K>W;5?W7V60EE908B@Q5.?L>F7D6BJF19?@9C?;T?K9?07FT96<)<-4:1;,:W<6<7@?6@=H:79G59IE6AB?1K>HDP3@@S:S;G;*=+9>;8:=;V8(C<;=BI5B>W2@?K;N?D:C>E;L=9?A3A=8I5*9@Q@H<)48?V6;AI;Y8+<:@88MC.7J??:25?C3?I8P5.9C=YDA35=P>);7K8K;Q@F8K?<6?@G<-==.8EF:1<=;2:B@/3KC36*=*8EFY=L5H?V;*9O;><>>O9D<:;7==9O:N@A56;FLM.3>,A1=J-P3L:(@,A.2WBA;98;:+=G9W?659D0AP5<;,?37?:3=VBE1FDU8P68E.89.47D96EAQ7M*8=U?R8F5)DX20H76PA/6U>7>W6Y<7;:>:,>N<3>I8>9V=V@179:0?B9J=)=B89>;91=K>-758CF+B31K@Q8*99@9=D5F;T;4>TC74.?S?83->M@J=)25;+G.:;2-@J;+:1AK=;5GB=:1@6;V:3N=T>H.VBJ6UAL9H@S<:91>U=L93=?=.>I50@R4AK@5T70:8?H?92WD18A<.@O:8<*:YA66Y9T<*B@67<5<7=L=.4,>A@<:M5)?VBF2T@A9C>N;AB0769/;R;H;+>(?G8)?I?-5+S8G9PA(9@8*BA8J4HIN:Q8=592>@4SB5:G8-:W?6AX2EA985C:5;;JNA>90;1;IA,8(BA5QGX4R>J9S?L9/BW6Q;(<=9;@E:>>)8E>J:.>8>36J9SC/9G>97-BX7U5>A(74A@@N4LA20@K?1J?<;N?T;E>B1YB5;K6S:MADA)9)?G79>49WAG7*8A7CAW;F=*949UEP:J6R7Q@PR?>6J?L=4;L7:?H;4>44)C97+5;79*<381<*C*:R7E>N4>F=8B7)AG84CN9K;42FC)7/DK>K2P;FBO;R5:A195>G=;6K;BC95X>X3EC7@D7E8>?V<3=361AA@1879Q>Y76=67?A?64>+?>@H76=Y58DG56;;D86M8A:=BM:5=+=7:E<74O>S@:>87L=??2EBAA/60L;>B29263B)6<==>@-6M;Q7R=:=3<8?@8)@D=*6J7/F9/MAF?=7(DH3T?<9@@-=;6?>Y:L>>;A>L6,;*C8;U5J>LBN4=:ED62?BB2N9XGN>-5T?=4,D:75>1>R<9=38C:2?(<49A;9?V;J8U=.C53E9?92G96T>D:H44@)@;<@5O@,83:+AU>E6S=V9T:K?A9:?0<19:?V;@:QCY1A@M;*:?:=DW4?>;7DC=7P:T9=>WH8CB+7EDA4E=JBL7(@L1PC07+?W:T8R?:=C4,E*::7W>T@Y19B>:F:T?57I9)@97D<,;:=31:X?Y:1AQ8L5KAG>C?C78=*9K=<<)7S=A>J79BH81<4;@:C8=:E5DG;5N9=9@=C8GK81I?+:779;Y:>D><90+EE919X@H3W?7AL:56AFW9Y45BO5Y>R:4=YC92>Y;1?W-RGY9>;;=7<;<+?93W=CA=5O8*CG58B>86@8?N1@@,>;8C?M;M>@8C>A6VBF4B55.@O:S@=17@4?;=69M4(BG8TCA9E5>>3;K;1@W@851<18Y@>4W@A,7VF96S8:L1/BS:Q>E:AE+6U8Q7/@D>K6V?F6P;;8H9VAU63@6>X62@R;6;N4.BS<*>C9I?X9?;O:4<8>M50F)0)D>=K9Q9-8=9JC>6YDE53?:?08L:VBX7F:@7;@0<<8*=C=B>D;V;3>4;<7DCS20<0FT24?+:<8T<5D05ME98X5-<,AB8M?<;76;58.(A724BR>563=-/:6@.9*=E17A0=.;.B<9K;=7/CK9H6K@1>Q:C8J@-7Y>OAK0OCR8C?Q2VF/7,@S6(=:?/966@>S9K>399@3=26;D;90?94@DB4/A-;E7.EL2AB=7.K6E@*84;L?N?25693>J28R;O6IA+<(K<,>H6.@I:Y:E92G/;/7)N9*B3:@77?07A@D:S9W?Q4/>>>B):W;W>Q;;87?-7<>7;5:KER4IA+5C:T49X;S::<>?<6:=8:W;5BG;+;K;4>?8J3HGP8;8/C;2,FI5/=D?8:-==8X=:;X;P<+;V>V;PC(/*@>34C<=C9P8OFW1TDL4K=3<<=F=Y<45FBB8>73A4:6?49<>,@<43:/@89O>A<.9:?>8O9Q@1?<:M;9(@>4H?O;.>2:E:.@*:7=37DCO;/;69)E67M89;W84?4H9MB678A/3OA3T9;5?B19/BE5@;?>7:0=1B30M?)>N7D+5A@0;X6Q4@C94:K7(@>:?AL:584BM55:I;I@X<78P=J;,<,>E9F;X:5;+<4@4=-7;AY8/D85R9N?,3FG08)8.<=(6L7ED744:V9H:X979EB17J>FD92?O4CB=:(4+D76CF/:18G9Q9@E*7.3QBY?+;M8LCK6R=5808Y=H;5=>AG:86:A4<4;?6;.=E=09;;4AJ3K=?;W=>C(51>J4JD6=,<56-96B8>;7(<1>P9D><89>I9XBF/;D28Q=A>49=<2=Q5L@8<-=*9G?U9M?C92:A8-H<2L=B>1;E9=K:9T:D@?46>I7B>M+44=7D2,2<8K=3AF:O87=7EP3)7YT42:1;JCK>;6*>7<>8H5I50EE9:?*7W>5B+0C>,BM=5:A8+-:IC?;+:27FA83;B+7:@/>P?(0X?=>B?*7E=T8A:4<0B=7E=@:2>3=SV?*51?GBQ34CB5LB:5X=A:Y92<*A:;8:V8.=PD84I:M;U9W<17OBV8.9BD>1.E84?=T>9;<9OD93R?R;E9::8:5CW?D;R6,:*I4/*B9;S<6??3*B,9R>0;S>*37CJ9J=)=)9,=(CH:3>B:)99=T8C;39Q@R9A>ADE88AR5L<5AD;I728V@083=L:3C7?6@>*>K8S>*9)>(>M;?=A4E67DK9+;+AY:D8KA36?@+4F=M1@I:.>A0GE58PA0>=4S<7)=K@@?>D<7;@AU6F9X9I>2?;:,87==?NR8;BX8:9L:.09+B>95R=W==?R9;;.8-?V:C??;597=+97==?G3EAR<@64J7R@.55YBD:);DH<.B+6F<:1:VAI=@90<=8*F45.:FCI7@:U>A=K8J4JDK>85+DC?(57;@>09)=<=8>?4)GN39@B7T?O=<89:L8C?E=68V?@;R:G6E5MJ<30=CAC7(AM2G9=C:4PGG9L:J7GBK2=B->58Y>8::<7>0=*7K;3<4=R95=1?L5O;X>X<(8UBO9T9S:)>88R=Q:4@0>W5-3K;=?5BX2Q;(?Y19R?,:6?;5O=N?44@?YN9?9;;HA/6H=/?J8A=046FK=S7P?)8L>07+BP>F4LB=41;3:N=HAI9*===J<348F*/J=WD=67AD7*<,<,;F@S:0:X;=9U?P;292>P@735BU4KA)93==7NAW=@8Y@@7/@881AL4E>)8XBL=<4<>U8M?:>O?-7?9P?;<-8J9B?/;M;S?@3,A3=2B:1U;2AD7R?G6ND):*:.9F>O8O>O<09P7::LEP59@>AD-PBS4=@2A*9R9*A02KBS?F7I9AC34-AW:2>B:G::?9A86*=J91=U9;36W;EI7,(EQ6F;V?)=H:D;V6NA(4-IU609Y;;;L=E8HF.9L=L81=R5X5CHS5=C>4C8BHJ87:38.;.AG?A<969:I>>9-@P;PX<<83:TCH77G?/4CL7M8?=S6G;PC.7HBT4E?P75?KB3:<;->23O=FGK/7>8X=+;<=U<54C@>=H5BGX1J>;8XFN4P=T=Y;.21IE7<=X;>92A2:.9568A>=O@W8A:V=,6@=><:=R8F=89L9+=98Q@S9+;1>C7R>U<38,>)?7<7=I4+FJ6X>+9<@*6U;I=>=S8B?/7.B86*;7B+9/>O5)AW;S8Y7V?XB=2D;BC992L=78Y@H6+:RDF61;K>TA96??6KCL8T5V@69=<9>A5??LC=::>M4;7IE126EV7>AK9+;H83??:9;Y:YB<7E9:BK61;AA951AK4;59D>88;BF;U1TAL8*;;CJ92>F;67P;;@K=12C>(=PB66Q?X6R:-A-:C?E:7-;EWA@3CDQ>S5B8G;6E6;X5:73FO:G99R8T:U71JQ57;4B05F7XES7>5.BT95EW9;7=9E:,A.:K;67,=UBT;E;U6@<3=.BD59C07M9??<99;D:P?T/GDS*>S2DBR95;WBK3:AK6N>B;C8RAB9U>P>S0GB28)@9=O6,?V=A9FG>06@P87A8;;.?*5PBR?U3=;4:F?L;JA*2F@.;P=1>Q8(B:6C8F?-?>809PCC:68(;?BL978R?I=<6:D53+;F8WAR:J=*BY58<9:E>U7(EM3@C16J;.9LA89?4W>@BD7@B6:5;8:37CA9??6<>.<7BO)N>6<:9A9BAG5:>5=86AHF6F:>7XD@+6BA94.?9;I:V<2>,6HDE=)5P?K87?L=U>W/+CD;D8;::>RLX9Q@9=)=6E;4A0<3?37/>N:9;S;KA*:/2CFI<)8?A;8.;7@O4D:=32C@99C77*<8;N:X=A5HCP@B/U<,?DB;8J:K=D@S.*G@6T<3:POG7@=O>H8I495:=?T<>7B>=<=6+DE5F@9>V15?C=*BM8L8WC-25E137?O4ND66,?X>9>>@C8V3-:=A?-2@D.AJ3+AB7D>C5G5,@=16BO<5>98H=DAN98=,5?=;C=7.8/BA68=1D>5F95=N><7:D5;H9);B76C259;;2>A88=AL6W5NC58K>7:<@88>>(;W=Q<2=J6B<8@S38=,@PBA7R5==:;,>9B25.<>?.;@8(<48A?RA29T7O<)AE:4=*0=EG;A>385>K<.;+9J;O;WAY6*@E>-9(7.>C?V?K70:MII4V7N=5DU:@8N?W:O:L77=U6;>X?2A+1Q@O:Y?.=09S=L68@6>F7?>T35C?8/JD.K<-<.7@A6F11J:)<@>Q<47I=9@@5V?S@J9F;A8NB.966KD>7T8D7SD?9R?8=T8P?I2NC27NBX>W5.=C8P5=K>6;J6@EA4,A3:J=D4BA29C<8AA>Y7C>?4?A/=V@N62?@:J88>A:F=4<6AM8.;9>N7Q>/:*=M9WBK6(;A9+E-5H?/94?+CJ+>BG;B=?8P:*C.:@7.@9J:KD47>>C67:8=H;.;,B@8A=<73GU38==>U:C)9/C66R?184=XET+AG+27/5T?X6UDA8:;(?D;.;E:W3:B>8F@Q=:5-:8A@@X4K8-A(>96E=YAY3.BJ;)8JEQ1,?B>D>S:?8?@R74?/89?4<36EBB68C(6P:W@53:6=T=R=Q;I7SN94:3?.=D:T=<7FBF9<84BJ9/84E?8*;2>P5;;CA@958U@A?Y53;X?29H=-B+7Y=J664-/GY<,7B9UCE8L4.GH8C5@@)7*BBA./BEM8+?==T72=(>?;,=D8U=;=;89<29?@C9K>3=C90=8:2=T5-9KA>C0.NBR=J;M>,895;:?R5,B<>0:<80@951@M:?5W?7BG:@65BM7?>8=78F:4;SG>8W7P=S<.55>A9A@<(:O?0;4:D08AC(2BCI4O@8=89,;6:1;4B7