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;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tu = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

ll S(ll x){
    string y=to_string(x);
    ll n=y.size();
    ll rec=0;
    for(ll i=0;i<n;i++){
        ll j=y[i]-'0';
        rec+=j;
    ;}
    return rec;
}

int main(){
    set<string> Se;
    for(ll i=0;i<=18;i++){
        for(ll j=0;j<1000;j++){
            string ret="";
            if(j>0)ret=to_string(j);   
            for(ll k=0;k<i;k++){
                ret+='9';
            ;}
            if(ret=="")ret="0";
            Se.insert(ret);
        ;}
    ;}
    priority_queue<ll, vector<ll>, greater<ll>>  ans;
    priority_queue<ll> once;
    ll n=Se.size();
    auto x=Se.begin();
    for(ll i=0;i<n;i++){
        string f=*x;
        ll e=stoll(f);++x;
        once.emplace(e);
    ;}
    ll R=INF,L=1;
    
    while(!once.empty()){
        ll e=once.top();
        once.pop();
        ll h=S(e);
        if(R*h>=L*e){
            ans.emplace(e);
            R=e,L=h;
        }
    }
    ll K;
    cin >> K;
    ans.pop();
    for(ll i=1;i<=K;i++){
        print(ans.top());
        ans.pop();
    ;}

    return 0;
}