Problem:
Score : 500 points

Problem Statement

Let S(n) denote the sum of the digits in the decimal notation of n.
For example, S(123) = 1 + 2 + 3 = 6.

We will call an integer n a Snuke number when, for all positive integers m such that m > n, \frac{n}{S(n)} \leq \frac{m}{S(m)} holds.

Given an integer K, list the K smallest Snuke numbers.

Constraints

1 \leq K

The K-th smallest Snuke number is not greater than 10^{15}.

Input

Input is given from Standard Input in the following format:

K

Output

Print K lines. The i-th line should contain the i-th smallest Snuke number.

Sample Input 1

10

Sample Output 1

1
2
3
4
5
6
7
8
9
19

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let k: usize = input();

    let dsum = |x: i64| {
        let (mut t, mut s) = (x, 0);
        while t > 0 {
            s += t % 10;
            t /= 10;
        }
        s
    };
    let snuke = |x: i64| x as f64 / dsum(x) as f64;

    let mut mul = 1;
    let mut ans = vec![];
    for _ in 1..16 {
        let mut rng: Vec<i64> = (1..10).rev().collect();
        let mut base = mul;
        while base > 1 {
            let mut supinf = snuke(10 * mul - 1);
            let mut nx = vec![];
            for &x in &rng {
                let nmn = (x * base) as f64 / (dsum(x) + dsum(base - 1)) as f64;
                let nmn_c = (x * base + base - 1) as f64 / (dsum(x) + dsum(base - 1)) as f64;
                debug!(base, supinf, x, nmn, nmn_c);
                if nmn <= supinf {
                    for j in 0..10 {
                        nx.push(x * 10 + 9 - j);
                    }
                    supinf = f64::min(supinf, nmn_c);
                }
            }
            std::mem::swap(&mut rng, &mut nx);
            debug!(rng);
            debug!(nx);
            base /= 10;
        }

        let mut inf = snuke(10 * mul - 1);
        for &x in &rng {
            if snuke(x) <= inf {
                ans.push(x);
                inf = snuke(x);
            }
        }

        mul *= 10;
        if ans.len() >= k {
            break;
        }
    }

    ans.sort();
    with_stdout_lock(|mut w| {
        for a in ans.iter().take(k) {
            writeln!(w, "{}", a).unwrap();
        }
    });
}