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::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn s(mut n: i64) -> i64 {
    let mut ret = 0;
    while n > 0 {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

fn score(n: i64) -> f64 {
    (n as f64)  / s(n) as f64
}

fn better(x: i64, y: i64) -> bool {
    return x * s(y) <= y * s(x);
}

fn solve_naive(k: usize) -> Vec<i64> {
    let n: i64 = 1000000;

    let mut a: Vec<(i64)> = vec![];
    let mut mi: f64 = 1e20;
    for x in (1..n).rev() {
        let t = (x as f64) / (s(x) as f64);

        if t <= mi {
            mi = t;
            a.push(x);
        }
    }

    a.reverse();
    return a[..k].to_vec();
}

/*
fn hoge(b: i64) -> (i64, i64) {
    if b <= 1000 {
        return (10, 1);
    } else {
        return (100, 10);
    }
}

fn solve(k: usize) -> Vec<i64> {
    let mut ans: Vec<i64> = vec![];

    let mut b: i64 = 10;
    while ans.len() <= k {
        let (hb, hstart)  = hoge(b);
        let bb = b / hb;

        for head in hstart..hb {
            let x = (head * bb) + (bb - 1);
            ans.push(x);
        }

        b *= 10;
    }
    return ans[0..k].to_vec();
}*/

/*
fn solve(k: usize) -> Vec<i64> {
    let mut ans: Vec<i64> = vec![];

    let mut x: i64 = 1;
    while ans.len() < k {
        let mut b = 1;
        while x >= b && x / b % 10 == 9 {
            b *= 10;
        }

        println!("{} {}", x, b);

        if x < b {  // 9..99
            ans.push(x);
            x += 1;
            continue;
        }

        let y = x + b;
        if better(x, y) {
            ans.push(x);
            x = y;
        } else {
            x = ((x / b / 10) * 10 + 9) * b + x % b;
        }
    }

    return ans;
}
*/
fn solve(k: usize) -> Vec<i64> {
    let mut ans: Vec<i64> = vec![];

    let mut x: i64 = 1;
    let mut b = 1;
    while ans.len() < k {
        if better(x, x + b) {
            ans.push(x);
        }

        let sx = score(x);
        while ((b * 10) as f64) < sx {
            b *= 10;
        }

        let y= x / b * b + (b - 1);
        if x < y {
            x = y;
        } else {
            x += b;
        }
        // println!("{} {} {}", x, b, ans.len());
    }

    return ans;
}

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

    // assert_eq!(solve(k), solve_naive(k));
    // println!("{:?}", solve(k));

    for x in solve(k).iter() {
        println!("{}", x);
    }

    // println!("{}", ans);
}