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++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include<bits/stdc++.h>
using namespace std;

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define DD(x,y)     cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << '\n'
#define DDD(x,y,z)  cerr << __LINE__ << ": " << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << '\n'
#define DBG         cerr << __LINE__ << ": Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

#define MAX     1000000

int s(LL a)
{
    int ret = 0;
    while(a)
    {
        ret += (a%10);
        a /= 10;
    }
    return ret;
}

pair<int,double> val[MAX+10];
bool cmp(pair<int,double>a, pair<int,double>b)
{
    if(fabs(a.yy - b.yy) < eps)
        return a.xx < b.xx;
    return a.yy < b.yy;
}
vector<LL>V;
int main()
{
    //freopen("maxon.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    LL base = 1;
    for(int d = 0; d<3; d++)
    {
        for(int i = 1; i<=9; i++)
        {
            V.pb(i*base+base-1);
//            D(V.back());
        }
        base *= 10;
    }
    int ok = 19;
    int st = 2;
    for(int d = 3; d<=16; d++)
    {
        for(int i = 10; i<=ok; i++)
        {
            V.pb(i*base/10 + base/10 -1 );
//            D(V.back());
//            getchar();
        }
        for(int i = st; i<=9; i++)
        {
            V.pb(i*base+base-1);
        }
        ok += 10;
        ok = min(99, ok);
        base *= 10;
    }
    sort(all(V));
    un(V);
//    for(int i = 0; i<V.size(); i++)
//    {
//        double a = (double)V[i]/s(V[i]);
//        for(int j = i+1; j<V.size(); j++)
//        {
//            double b = (double)V[j]/s(V[j]);
//            if(a > b+eps)
//            {
//                DD(a,b);
//                DD(V[i], V[j]);
////                assert(false);
//            }
//        }
//    }
    int have;
    for(int i = 0; i<V.size(); i++)
    {
        if(V[i] > 1e15)
        {
            have = i;
            break;
        }
    }
    int n;
    sf(n);
    assert( n <= have);
    sort(all(V));
    for(int i = 0; i<n;i ++)
        cout << V[i] << endl;
    return 0;
}