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 C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

#define ANS_MAX 10000

int main(void) {
    int num = get_int();

    int i;
    int64_t j;

    int64_t prev = 0;
    static int64_t ans[ANS_MAX];
    int aidx = 0;
    for(i = 1; i <= num; i++) {
        int val = i;
        int64_t cur = 0;
        int64_t power10 = 1;
        while(val >= 9) {
            val -= 9;
            cur += 9 * power10;
            power10 *= 10;
        }
        cur += power10 * val;
        int64_t fixed_cur = (cur * (i-1)-1) / i + 1;
#ifdef DEBUG
        printf("%d: (%lld, %lld]\n",i-1, prev, fixed_cur);
#endif
        for(j = 1; j <= cur; j*=10) {
            int64_t val = cur - j;
            if(val >= fixed_cur) continue;
            if(val <= prev) break;
            // ensure that prev < val <= fixed_cur
            ans[aidx++] = val;
        }
        ans[aidx++] = cur;
        prev = cur;
    }
    for(i = 0; i < aidx; i++) {
        printf("%lld\n", ans[i]);
    }
    return 0;
}