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: Time Limit Exceeded)

#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn digit_sum(n: i64) -> i64 {
    if n == 0 {
        return 0;
    }
    else {
        return n % 10 + digit_sum(n/10);
    }
}

fn main() {
    let inf = 1i64 << 50;
    let mut count = 0;
    let k = read_i64();
    for n in 1..inf {
        let mut p = 1;
        let mut ok = true;
        for _ in 0..17 {
            let mut m = n + p;
            if ! (n * digit_sum(m) <= m * digit_sum(n)) {
                ok = false;
            }
            p *= 10;
        }
        if ok {
            count += 1;
            println!("{}", n);
            if count >= k {
                break;
            }
        }
    }
    /*
    for n in 1..120 {
        let mut ok = true;
        for m in n+1..100000 {
            if ! (n * digit_sum(m) <= m * digit_sum(n)) {
                println!("{}'s killer : {}", n, m);
                ok = false;
                break;
            }
        }
        if ok {
            println!("{}", n);
        }
    }
    */
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}