struct Scanner { buf_read: BR, } impl Scanner
{ fn new(buf_read: BR) -> Scanner
{ Scanner { buf_read: buf_read } } fn read_until_f

(&mut self, predicate: P) -> std::io::Result where P: std::ops::Fn(&u8) -> bool, { use std::io::BufRead; let mut buf = std::vec::Vec::new(); loop { let (done, used) = { let available: &[u8] = match self.buf_read.fill_buf() { Ok(b) => b, Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => continue, Err(e) => return Err(e), }; match available.iter().position(&predicate) { Some(i) => { buf.extend_from_slice(&available[..i + 1]); (true, i + 1) } None => { buf.extend_from_slice(available); (false, available.len()) } } }; self.buf_read.consume(used); if done || used == 0 { return match String::from_utf8(buf) { Ok(s) => Ok(s), Err(_) => Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "error")), } } } } fn next(&mut self) -> T where < T as std::str::FromStr >::Err: std::fmt::Debug { use ::std::str::FromStr; let mut with_delim = self.read_until_f(|&c| { c == b' ' || c == b'\n' }).unwrap(); with_delim.pop(); FromStr::from_str(with_delim.as_str()).unwrap() } fn ni(&mut self) -> i32 { self.next() } fn nl(&mut self) -> i64 { self.next() } fn ns(&mut self) -> String { self.next() } } fn has_three_in_decimal_digits(n: i64) -> bool { if n == 0 { false } else { n%10 == 3 || has_three_in_decimal_digits(n/10) } } fn main() { let stdin = std::io::stdin(); let mut scanner = Scanner::new(stdin.lock()); let a = scanner.nl(); let b = scanner.nl(); for i in a..b { if i % 3 == 0 || has_three_in_decimal_digits(i) { println!("{}", i); } } }