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 Haskell (GHC 7.10.3) (judge verdict: Runtime Error)

import Data.List

main :: IO()
main = do
  k <- readLn :: IO Int
  let candidates = map read [solve n | n <- [0..9*15]] :: [Integer]
      snks = map (\n -> (snkf n, n)) candidates
  printsnk k snks

printsnk :: Int -> [(Double, Integer)] -> IO()
printsnk 0 _ = return ()
printsnk n (s:nk) = do
  let (x, y) = s
      (xm, ym) = minimum nk
  if y < ym then print y else return ()
  printsnk (n - 1) nk

solve n = (show (s + 1)) ++ replicate d '9'
  where
    d = div n 9
    s = mod n 9

f :: String -> Integer -> Integer
f [] n = n
f (s:ss) n = f ss (read [s] + n)

snkf :: Integer -> Double
snkf v = (fromIntegral v) / (fromIntegral sn)
  where
    vstr = show v
    sn = f vstr 0