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 Python (3.4.3) (judge verdict: Runtime Error)

import random

def f(n,l):
    if len(l)>n:
        return 0
    s=""
    for i in l:
        s+=str(9-i)
    for i in range(n-len(l)):
        s+="9"
    return int(s)

def f2(i):
    j=i+0
    s=0
    while i>0:
        s+=i%10
        i//=10
    return j/s

def f3(l):
    ret=[list(l)]
    for i in range(1000):
        random.shuffle(l)
        if l not in ret:
            ret.append(list(l))
    return ret

l=[[[1]], [], [], [], [], [], [], []]
for i in range(7):
    for temp in l[i]:
        if temp+[1] not in l[i+1]:
            for k in f3(temp+[1]):
                l[i+1].append(k)
        for j in range(len(temp)):
            temp2=list(temp)
            temp2[j]+=1
            if temp2 not in l[i+1]:
                for k in f3(temp2):
                    l[i+1].append(k)
cand=[[] for i in range(14)]
for i in range(8):
    for j in l[i]:
        for k in range(1,15):
            ret=f(k,j)
            if ret>0 :
                cand[len(str(ret))-1].append(ret)
                cand[len(str(ret))-1].sort()
                cand[len(str(ret))-1].reverse()
cand.reverse()
x=f2(10**15-1)
res=[]
for i in range(14):
    res.append(10**(15-i)-1)
    for j in cand[i]:
        if x>f2(9+j*10):
            x=f2(9+j*10)
            res.append(9+j*10)
res.reverse()
res=[1,2,3,4,5,6,7,8,9]+res

k=int(input())
for i in range(k):
    print(res[i])