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 Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		String str = String.valueOf(N);
		int K = 0;

		for(int i = 0; i < str.length(); i++){
			K += Integer.parseInt(str.substring(i, i+1));
		}

		String tmp = String.valueOf(K);
		int level = tmp.length()-1;

		for(long i = 0; i < N;i++){
			System.out.println(tmp);

			if(Integer.parseInt(tmp.substring(level,level+1)) != 9){
				if(tmp.length()>1){
					tmp = tmp.substring(0,level) + String.valueOf((Integer.parseInt(tmp.substring(level,level+1))+1))
						+ tmp.substring(level+1,tmp.length());
				}else{
					tmp = String.valueOf((Integer.parseInt(tmp.substring(level,level+1))+1));
				}

			}else{
				if(level == 0){
						if(tmp.length() >=  3){
							tmp = "10" + tmp.substring(1,tmp.length());
							level++;
						}else
							tmp = "1" + tmp;
				}else{
					level--;
				}

			}
		}
	}
}