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



Sample input:
10


Sample output:
1
2
3
4
5
6
7
8
9
19

Submission status: Wrong Answer

Solution code:
k = int(input())
s = 0
a = []
for i in range(1,k+1):
    if i % 9:
        ans = str(i%9) + "9" * (i//9)
    else:
        ans = "9" * (i//9)
    print(ans)
    s += 1
    if s == k:
        quit()
    if (i+1) % 9:
        next_ans = str((i+1)%9) + "9" * ((i+1)//9)
    else:
        next_ans = "9" * ((i+1)//9)
    if i < 10:
        continue
    if i % 9:
        ans = str(i%9 + 1) + "8" + "9" * (i//9 - 1)
    else:
        ans = "10" + "8" + "9" * (i//9 - 1)
    if (int(ans) / i) <= (int(next_ans) / (i+1)):
        print(ans)
        s += 1
    if s == k:
        quit()

Submission status: Wrong Answer

Solution code:
import builtins
def S(n):
    return builtins.sum(map(int, str(n)))

def gen():
    n = 0
    while True:
        for i in range(1, 10):
            tmp = str(i) + '9'*n
            yield int(tmp)
        n += 1

def main(K):
    for i, s in enumerate(gen()):
        if i >= K:
            break
        print(s)

K = int(input())
main(K)

Submission status: Wrong Answer

Solution code:
k = int(input());
for j in range(0, 2000):
	for i in range(1, 10):
		num = (i*(10**j))-1
		if num > 0 and k > 0:
			print(num, end='\n')
			k = k - 1

Submission status: Wrong Answer

Solution code:
k = int(input())
x = [0,1,2,3,4,5,6,7,8,9,19]
for i in x[1:k+1]: print(i)

Submission status: Wrong Answer

Solution code:
K = int(input())
a = 1
for i in range(K):
    a += 10**(i//9)
    print(a-1)

Submission status: Wrong Answer

Solution code:
k = int(input())-1;
for j in range(0, 2000):
	for i in range(1, 9):
		num = i*(10**j)-1
		if num > 0 and k > 0:
			print(num, end='\n')
			k = k - 1

Submission status: Wrong Answer

Solution code:
k=int(input())
if k<10:
    print("\n".join(list(range(1,k+1))))
else:
    cnt = 0
    for i in range(k):
        if i%9==0 and i>0:
            cnt+=1
        print(str(i%9+1)+"9"*cnt)

Submission status: Wrong Answer

Solution code:
K = int(input())
a = 1
for i in range(1, K+1):
    a += 10**(i//10)
    print(a-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
t = []
for i in range(1, 10 ** 5 + 1):
    t.append([i / (i % 10 + i // 10), i])
t.sort()
for i in range(k):
    print(t[i][1])

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

K = int(input())
# K = 100

i = 1
s = [1]

for _ in range(K):
    print("".join(map(str, s)))
    if s[0] != 9:
        s[0] += 1
    else:
        s = [1] + s

Submission status: Wrong Answer

Solution code:
K = int(input())

for i in range(K):
    num = (i+1)%10
    if num == 0:
        continue
    nine = (i+1) //10
    ans = str(num) + "9" * nine
    print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())                  
for i in range(K):                
    n = (i + 1) // 9              
    l = (i + 1) % 9               
    if l != 0:                    
        print( str(l) + "9" * n ) 
    else:                         
        print("9" * n)

Submission status: Wrong Answer

Solution code:
k = int(input())

for i in range(k):
    n = 10 ** (i // 9) * (i % 9 + 2) - 1
    print(n)

Submission status: Wrong Answer

Solution code:
K = int(input())

for i in range(1, K+1):
	print(int(str(i - (i // 9)*9) + ('9' * (i // 9))))

Submission status: Wrong Answer

Solution code:
k = int(input());
for j in range(0, 2000):
	for i in range(1, 9):
		num = i*(10**j)-1
		if num > 0 and k > 0:
			print(num);
			k = k - 1;

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

def main():
    K = int(input())

    on = [1, 2, 3, 4, 5, 6, 7, 8, 9]

    ans = (on
           + [10 * (n + 1) - 1 for n in on]
           + [(10 ** 2) * (n + 1) - 1 for n in on]
           + [(10 ** 3) * (n + 1) - 1 for n in on]
           + [(10 ** 4) * (n + 1) - 1 for n in on]
           + [(10 ** 5) * (n + 1) - 1 for n in on]
           + [(10 ** 6) * (n + 1) - 1 for n in on]
           + [(10 ** 7) * (n + 1) - 1 for n in on]
           + [(10 ** 8) * (n + 1) - 1 for n in on]
           + [(10 ** 9) * (n + 1) - 1 for n in on]
           + [(10 ** 10) * (n + 1) - 1 for n in on]
           + [(10 ** 11) * (n + 1) - 1 for n in on]
           + [(10 ** 12) * (n + 1) - 1 for n in on]
           + [(10 ** 13) * (n + 1) - 1 for n in on]
           + [(10 ** 14) * (n + 1) - 1 for n in on]
           + [(10 ** 15) * (n + 1) - 1 for n in on]
           + [(10 ** 16) * (n + 1) - 1 for n in on])

    print(' '.join(map(str, ans[:K])))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# buf = []
# for n in range(1, 1000):
#     s = str(n)
#     t = sum(map(int, s))
#     buf.append((n / t, n))
# buf.sort()
# print(*buf, sep='\n')


def solve(k):
    i = 0
    ret = []
    while True:
        suffix = '9' * i
        for j in range(1, min(k, 9) + 1):
            ret.append(str(j) + suffix)
        k -= 9
        if k <= 0:
            break
        i += 1
    return ret


k = int(input())
print('\n'.join(solve(k)))

Submission status: Wrong Answer

Solution code:
K = int(input())
cnt = 0
b = 1
ans = 1
while cnt < K:
	print(ans)
	cnt += 1
	if str(ans)[0] ==  '9':
		b *= 10
	ans += (b)

Submission status: Wrong Answer

Solution code:
K = int(input())

for i in range(K):
    num = (i+1)%10
    if num == 0:
        num = 1
    nine = (i+1) //10
    ans = str(num) + "9" * nine
    print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
cnt = 0
b = 1
ans = 1
while cnt <= K:
	print(ans)
	cnt += 1
	if str(ans)[0] ==  '9':
		b *= 10
	ans += (b)

Submission status: Wrong Answer

Solution code:
k = int(input())


def main():
    for i in range(1, min([k + 1, 10])):
        print(i)
    if k < 10:
        return

    for i in range(1, k - 8):
        print(i * 10 + 9)

main()

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
def main(k):
	digit = 0
	cnt = 0
	while True:
		for i in range(9):
			print(str(i+1)+ "9" * digit)
			cnt += 1
			if cnt == k:
				return
		digit += 1


if __name__ == '__main__':
	k = int(input())
	main(k)

Submission status: Wrong Answer

Solution code:
# D
K = int(input())
a = 1
b = 0
res_max = 0

while K > 0:
    res = int(str(a) + str(9)*b)
    if res > res_max:
        res_max = res
        print(int(res))
        K -= 1
    if a < int(str(9)*max(b, 1)):
        a += 1
    else:
        a = 1
        b += 1

Submission status: Wrong Answer

Solution code:
k = int(input())


def main():
    for i in range(1, min([k, 10])):
        print(i)
    if k < 10:
        return

    for i in range(1, k - 8):
        print(i * 10 + 9)

main()

Submission status: Wrong Answer

Solution code:
K = int(input())
for i in range(K//9):
    for j in range(9):
        print(str(j+1)+('9'*i))
for i in range(K%9):
    print(str(i+1) + '9'*(K//9))

Submission status: Wrong Answer

Solution code:
#for i in range(1000, 1200):
#  print(i, i / sum(map(int, str(i))))

lst = []
for i in range(16):
  for j in range(1, 10):
    lst.append(str(j) + "9" * i)
#print(lst)
print(*lst[:int(input())])

Submission status: Wrong Answer

Solution code:
# D
K = int(input())
a = 1
b = 0
while K > 0:
    res = str(a) + str(9)*b
    print(int(res))
    if a < int(str(9)*max(b, 1)):
        a += 1
    else:
        a = 1
        b += 1
    K -= 1

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 1
while i <= k:
    num_9 = i // 9
    left_num = i % 9
    if left_num == 0:
        left_num = 9
        num_9 -= 1
    print(str(left_num).ljust(num_9 + 1, '9'))
    i += 1

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    k = I()
    a = []
    for i in range(20):
        for j in range(1,10):
            a.append('{}{}'.format(j,'9'*i))

    return '\n'.join(a[:k])


print(main())

Submission status: Wrong Answer

Solution code:
K = int(input())

for k in range(1, min(K, 9)+1):
    print(k)

if K >= 10:
    for k in range(1, K-8):
        print(9 + k*10)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    k = I()
    a = []
    for i in range(16):
        for j in range(1,10):
            a.append('{}{}'.format(j,'9'*i))

    return '\n'.join(a[:k])


print(main())

Submission status: Wrong Answer

Solution code:
k=int(raw_input())
cur=add=1
mul=10
while k:
    print cur
    if (cur+1)%mul==0:
        add*=10
        mul*=10
    cur+=add
    k-=1

Submission status: Wrong Answer

Solution code:
def f():
	l = 0
	while True:
		for i in range(1,10):
			yield str(i) + ('9'*l)
		l += 1

K = int(input())

a = f()
for i in range(K):
	x = next(a)
	print(x)

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 1
while K:
  print(i)
  i += 1
  K -= 1
  if i > 9:
    break
j = 1
while K:
  print(j*10+9)
  j += 1
  K -= 1

Submission status: Wrong Answer

Solution code:
k = int(input())
for i in range(1,k+1):
    if i % 9:
        print(str(i%9) + "9" * (i//9))
    else:
        print("9" * (i//9))

Submission status: Wrong Answer

Solution code:
k = int(input())

for i in range(1,10):
    print(i)
    k-=1 
    if k==0:
        break
num = 9 

while k:
    num+=10
    print(num)
    k-=1

Submission status: Wrong Answer

Solution code:
k = int(input())
for i in range(1,k):
    if i % 9:
        print(str(i%9) + "9" * (i//9))
    else:
        print("9" * (i//9))

Submission status: Wrong Answer

Solution code:
K = int(input())

s = ''
while K > 0:
  for i in range(1,min(10,K+1)):
    print(i,s, sep='')
  s += '9'
  K -= 9

Submission status: Wrong Answer

Solution code:
# D
K = int(input())
a = 1
b = 0
while K > 0:
    res = str(a) + str(9)*b
    print(int(res))
    if a < 9:
        a += 1
    else:
        a = 1
        b += 1
    K -= 1

Submission status: Wrong Answer

Solution code:
K = int(input())

s = ''
while K > 0:
  for i in range(1,min(10,K+1)):
    print(i,s, sep='')
  s += '9'
  K -= 10

Submission status: Wrong Answer

Solution code:
k=int(input())
if k<10:
    print("\n".join(list(range(1,k+1))))
else:
    cnt = 0
    for i in range(k):
        if i%10==9 and i>0:
            cnt+=1
        print(str(i%9+1)+"9"*cnt)

Submission status: Wrong Answer

Solution code:
K = int(input())
ans = 0
for i in range(K):
    if i < 9:
        ans += 1
    else:
        ans += 10
    print(ans)

Submission status: Wrong Answer

Solution code:
# for n in range(1,1000):
#     s = str(n)
#     t = sum(map(int, s))
#     print(n, t, n / t)

def solve(k):
    i = 0
    ret = []
    while True:
        suffix = '9' * i
        for j in range(1, min(k, 9) + 1):
            ret.append(str(j) + suffix)
        k -= 9
        if k <= 0:
            break
        i += 1
    return ret


k = int(input())
print('\n'.join(solve(k)))

Submission status: Wrong Answer

Solution code:
k = int(input())
for i in range(1, k + 1):
    a = (i % 9 + 1) * 10 ** (i // 9) - 1
    print(a)

Submission status: Wrong Answer

Solution code:
k = int(input())
m,n = k//10,k%10
for i in range(m):
	for j in range(1,10): print(j*(10**i))
for i in range(1,n+1): print(i*(10**m))

Submission status: Wrong Answer

Solution code:
k = int(input())

n = 2
d = 1
for _ in range(k):
    print(n*d-1)
    n += 1
    if n == 11:
        d *= 10
        n = 2

Submission status: Wrong Answer

Solution code:
k = int(input())

n = 1
d = 1
for _ in range(k):
    print(n*d)
    n += 1
    if n == 10:
        d *= 10
        n = 1

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

k = int(input())

keta = 4

ans_c = []
sunuke = []
for i in range(1, 10**keta):  # 1~9999
    a = i
    b = sum([int(j) for j in str(i)])
    tmp_sunuke = a/b
    ans_c.append(a)
    sunuke.append(tmp_sunuke)

base = 10
nines = 9
while(len(ans_c) <= 9000000):
    for i in range(1000, 10**keta):  # 1000~9999
        a = i*base+nines
        b = sum([int(j) for j in str(i)])
        tmp_sunuke = a/b
        ans_c.append(a)
        sunuke.append(tmp_sunuke)
    base *= 10
    nines = nines*10 + 9
    # print(len(ans_c))

# print(ans_c)

tmp = 10**10
ans = []
for i in reversed(range(len(ans_c))):
    if sunuke[i] <= tmp:
        tmp = sunuke[i]
        ans.append(ans_c[i])
# print(ans)


for i in range(0, k):
    print(ans[-1-i])

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
V = []
for i in range(1, 150):
    for j in range(15):
        val = str(i) + '9' * j
        V.append(int(val))
V = list(set(V))
V.sort()
# print(V)


# メモ化再起
from functools import lru_cache
@lru_cache(maxsize=10000000)
def f(n):
    s = sum([int(x) for x in list(str(n))])
    return n / s

ret = []
for n in range(len(V)):
    isOK = True
    for m in range(n + 1, len(V)):
        if f(V[n]) > f(V[m]):
            isOK = False
            break
    if isOK:
        ret.append(str(V[n]))

print(" ".join(ret[:K]))

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
ans=[2,3,4,5,6,7,8,9,]
for i in range(1,10000):
    for j in range(1,10):
        ans.append(10**i*j)
for ii in range(k):
    print(ans[ii]-1)

Submission status: Time Limit Exceeded

Solution code:
pl=[1,2,3,4,5,6,7,8]
for i in range(1,100):
    for j in range(1000):
        z = j*(10**i)+(10**i-1)
        if z not in pl:
            pl.append(z)
pl.sort()
ql=[]
for v in pl:
    p = v
    s = 0
    for j in range(1000):
        s+=p%10
        p//=10
        if (p==0):
            break
    ql.append(v/s)



gl=[]
sm=100000000000
for i in range(len(pl)-1,-1,-1):
    if ql[i]<=sm:
        gl.append(pl[i])
    sm = min(ql[i],sm)
gl.reverse()

[ print(it) for it in gl[:int(input())] ]

Submission status: Time Limit Exceeded

Solution code:
pl=[1,2,3,4,5,6,7,8]
for i in range(1,100):
    for j in range(10000):
        z = j*(10**i)+(10**i-1)
        if z not in pl:
            pl.append(z)
pl.sort()
ql=[]
for v in pl:
    p = v
    s = 0
    for j in range(1000):
        s+=p%10
        p//=10
        if (p==0):
            break
    ql.append(v/s)



gl=[]
sm=100000000000
for i in range(len(pl)-1,-1,-1):
    if ql[i]<=sm:
        gl.append(pl[i])
    sm = min(ql[i],sm)
gl.reverse()

[ print(it) for it in gl[:int(input())] ]

Submission status: Time Limit Exceeded

Solution code:
def s(n):
    if n<10:
        return n
    else:
        return n%10+s(n//10)

k =int(input())
n=0
for _ in [0]*k:
    n +=1    
    minn = n
    d = 10
    while n>=d:
        m = (n//d+1)*d-1
        if minn*s(m)>m*s(minn):
            minn = m
    n = minn
    print(n)

Submission status: Time Limit Exceeded

Solution code:



def n_snuke(n):
    return n /sum(map(int,str(n)))


# (100o+10x+y)/(o+x+y) > (100o+99)/(o+9+9)
#  100o*18+(10x+y)(o+18) > 100o(x+y) +99(o+x+y)


#
#1 - 10 , 19,29,39,49,59,69,79,89,99

#for i in range(1,1115):
#    print(i,n_snuke(i))


K = int(input())
tmp =0

tmp_list = []
for i in range(K*100):
    tmp = tmp+ 10**(len(str(tmp+1))-1)
    tmp_list.append(tmp)
    #print(tmp,n_snuke(tmp))
r_list = [tmp_list[-1]]
for i in reversed(range(len(tmp_list)-1)):
    if n_snuke(r_list[-1]) >= n_snuke(tmp_list[i]):
        r_list.append(tmp_list[i])
if len(r_list) < K:
    raise
for i in reversed(r_list[-K:]):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

def S(k):
    return sum(int(x) for x in str(k))
def T(k):
    return k / S(k)

d = {}
MAX = int(1e15) + 1e9
for i in range(1, 99999):
    t = i
    while t < MAX:
        d[t] = T(t)
        t = t * 10 + 9

keys = sorted(list(d.keys()))

# for k in keys:
#     print(k, d[k])

mn = None
ans = []
for k in reversed(keys):
    if mn == None:
        mn = d[k]
    else:
        if mn >= d[k]:
            ans.append(k)
            mn = min(mn, d[k])

ans.reverse()
K = int(input())
ans = ans[:K]
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
kosuu = [9,9,10]
for i in range(2,11):
	kosuu.append((10-i)+10*i)
kosuu.append(100)
kosuu.append(110)

ans = []
counter = 0
i = 0
while counter < k:
	if i == 0:
		for e in range(1,kosuu[i]):
			ans.append(e)
		counter += 8
		i += 1
	elif i <= 10:
		first = (i-1)*(10**i)+(10**i)-1
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1
	elif i == 11:
		first = 199999999999
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1
	elif i == 12:
		first = 10999999999999
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1

for s in range(k):
	print(ans[s])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a =[1,2,3,4,5,6,7,8,9]
for i in range(1,10000):
  b = 10**i - 1
  for j in range(1,10):
    a.append(b + j * 10 ** i)
  
for i in range(N):
  print(a[i])

Submission status: Time Limit Exceeded

Solution code:
def keta(n):
    ans = 0
    while n != 0:
        ans += 1
        n // 10
    return ans

def su(n):
    ans = 0
    while n != 0:
        ans += n % 10
        n = n // 10
    return ans

def sunuke(n):
    s = su(n)
    if s == 0:
        return 0
    return n/s

def hantei(n1,n2):
    if sunuke(n1) <= sunuke(n2):
        return 1
    else:
        return 0

def insert(k):
    ans = [1,2,3,4,5,6,7,8,9,19,29,39,49,59,69,79,89,99]
    while len(ans) < k:
        p = 3
        q = 0
        while (p-q-3) >= 0:
            n1 = int('1' + '0'*(p-2-q) + '9'*(q+1))
            n2 = int('1' + '0'*(p-3-q) +'1'+ '9'*(q+1))
            while hantei(n1,n2) == 1:
                ans_temp = [num for num in range(n1, n1+1+int(9*pow(10,q+1)),int(pow(10,q+1)))]
                for a in ans_temp:
                    ans.append(a)
                n1 += int(pow(10,p-1))
                n2 += int(pow(10,p-1))
            if (p-3-q) == 0:
                n0 = int('1'+'9'*(p-1))
                ans_temp = [num for num in range(n0, int(pow(10, p)), int(pow(10, p-1)))]
                for a in ans_temp:
                    ans.append(a)
            else:
                q += 1
        p += 1
    return ans
k = int(input())
ans = insert(k)
i = 0
while i < k:
    print(ans[i])
    i += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
kosuu = [9,9,10]
for i in range(2,11):
	kosuu.append((10-i)+10*i)
kosuu.append(100)
kosuu.append(300)

ans = []
counter = 0
i = 0
while counter < k:
	if i == 0:
		for e in range(1,kosuu[i]):
			ans.append(e)
		counter += 8
		i += 1
	elif i <= 10:
		first = (i-1)*(10**i)+(10**i)-1
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1
	elif i == 11:
		first = 199999999999
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1
	elif i == 12:
		first = 10999999999999
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1

for s in range(k):
	print(ans[s])

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
kosuu = [9,9,10]
for i in range(2,11):
	kosuu.append((10-i)+10*i)
kosuu.append(100)
kosuu.append(200)

ans = []
counter = 0
i = 0
while counter < k:
	if i == 0:
		for e in range(1,kosuu[i]):
			ans.append(e)
		counter += 8
		i += 1
	elif i <= 10:
		first = (i-1)*(10**i)+(10**i)-1
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1
	elif i == 11:
		first = 199999999999
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1
	elif i == 12:
		first = 10999999999999
		for e in range(kosuu[i]):
			ans.append(first+e*10**i)
		counter += kosuu[i]
		i += 1

for s in range(k):
	print(ans[s])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin 
c = [1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1999, 2999, 3999, 4999, 5999, 6999, 7999, 8999, 9999, 19999, 29999, 39999, 49999, 59999, 69999, 79999, 89999, 99999, 199999, 299999, 399999, 499999, 599999, 699999, 799999, 899999, 999999, 1999999, 2999999, 3999999, 4999999, 5999999, 6999999, 7999999, 8999999, 9999999, 19999999, 29999999, 39999999, 49999999, 59999999, 69999999, 79999999, 89999999, 99999999, 199999999, 299999999, 399999999, 499999999, 599999999, 699999999, 799999999, 899999999, 999999999, 1999999999, 2999999999, 3999999999, 4999999999, 5999999999, 6999999999, 7999999999, 8999999999, 9999999999, 19999999999, 29999999999, 39999999999, 49999999999, 59999999999, 69999999999, 79999999999, 89999999999, 99999999999, 199999999999, 299999999999, 399999999999, 499999999999, 599999999999, 699999999999, 799999999999, 899999999999, 999999999999, 1999999999999, 2999999999999, 3999999999999, 4999999999999, 5999999999999, 6999999999999, 7999999999999, 8999999999999, 9999999999999, 19999999999999, 29999999999999, 39999999999999, 49999999999999, 59999999999999, 69999999999999, 79999999999999, 89999999999999, 99999999999999, 199999999999999, 299999999999999, 399999999999999, 499999999999999, 599999999999999, 699999999999999, 799999999999999, 899999999999999, 999999999999999]
n = int(stdin.readline())
c = set(c)
c = list(c)
c.sort()
c = c[:n] 
for i in c:
    print i 
if n > 135:
    while True:
        xx = 3

Submission status: Time Limit Exceeded

Solution code:
args = int(input().rstrip())

def snuke(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s

def find_snuke(args):
    result = []
    i = 1
    while len(result) < args:
        push = True
        p = 0
        for power in range(0,len(str(i))):
            if((i+10**power)/snuke(i+10**power))<(i/snuke(i)):
                push = False
                p = power
        if push:
            result.append(i)
        i=i+10**p
            
    return result

arr = find_snuke(args)
for a in arr:
   print(a)

Submission status: Time Limit Exceeded

Solution code:
args = int(input().rstrip())

def snuke(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s

def find_snuke(args):
    result = []
    i = 1
    while len(result) < args:
        push = True
        for power in range(0,len(str(i))):
            if((i+10**power)/snuke(i+10**power))<(i/snuke(i)):
                push = False
                break
        if push:
            result.append(i)
        i=i+1
            
    return result

arr = find_snuke(args)
for a in arr:
   print(a)

Submission status: Time Limit Exceeded

Solution code:
args = int(input().rstrip())

def snuke(number):
    temp = list(str(number))
    arr = [ int(t) for t in temp] 
    return sum(arr)

def find_snuke(args):
    result = []
    i = 1
    while len(result) < args:
        push = True
        for power in range(0,len(str(i))):
            if((i+10**power)/snuke(i+10**power))<(i/snuke(i)):
                push = False
                break
        if push:
            result.append(i)
        i=i+1
            
    return result

arr = find_snuke(args)
for a in arr:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


K = int(input())

if K <= 9:
    for i in range(1, K+1):
        print(i)
    exit()

for i in range(1, 10):
    print(i)


def S(n):
    res = 0
    while n > 0:
        res += n % 10
        n = n // 10
    return res

def is_snuke(n):
    a = n / S(n)
    for i in range(1, 10):
        m = n + 10 * i
        if a > m / S(m):
            return False
    return True

current = 19
K = K-9
while K > 0:
    if is_snuke(current):
        print(current)
        current += 10
        K -= 1

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


K = int(input())

if K <= 9:
    for i in range(1, K+1):
        print(i)
    exit()

for i in range(1, 10):
    print(i)


def S(n):
    res = 0
    while n > 0:
        res += n % 10
        n = n // 10
    return res

def is_snuke(n):
    for m in range(n+1, n+100):
        if n / S(n) > m / S(m):
            return False
    return True

current = 19
K = K-9
while K > 0:
    if is_snuke(current):
        print(current)
        current += 10
        K -= 1

Submission status: Time Limit Exceeded

Solution code:
args = int(input().rstrip())

def snuke(number):
    temp = list(str(number))
    arr = [ int(t) for t in temp] 
    return sum(arr)

def find_snuke(args):
    result = []
    i = 1
    while len(result) < args:
        push = True
        for power in range(0,len(str(i))):
            if((i+10**power)/snuke(i+10**power))<(i/snuke(i)):
                push = False
        if push:
            result.append(i)
        i=i+1
            
    return result

arr = find_snuke(args)
for a in arr:
   print(a)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


K = int(input())

if K <= 9:
    for i in range(1, K+1):
        print(i)
    exit()

for i in range(1, 10):
    print(i)


def S(n):
    res = 0
    while n > 0:
        res += n % 10
        n = n // 10
    return res

def is_snuke(n):
    for m in range(n+1, n+10000):
        if n / S(n) > m / S(m):
            return False
    return True

current = 19
K = K-9
while K > 0:
    if is_snuke(current):
        print(current)
        current += 10
        K -= 1

Submission status: Accepted

Solution code:
k = int(input())
ans, cur = 0, 1
for i in range(k):
    ans += cur 
    print(ans)
    s = 0
    for i in str(ans + cur):
        s += int(i)
    if cur < (ans + cur) / s:
        cur *= 10

Submission status: Accepted

Solution code:
from fractions import Fraction
def S(n):
  res = 0
  while n:
    n, r = divmod(n, 10)
    res += r
  return res
k = int(input())
n = 1
for _ in range(k):
  print(n)
  n += 1
  m = Fraction(n, S(n))
  temp = n
  for d in range(len(str(n))+1):
    x = 10**(d+1)*(n//(10**(d+1))+1)-1
    if Fraction(x, S(x)) < m:
      m = Fraction(x, S(x))
      temp = x
  n = temp

Submission status: Accepted

Solution code:
K = int(input())
nums = list(range(1, 10))
vals = [1] * 9
d = 1
n = 1
m = 9
while len(nums) < 2 * K:
    m += 10**d
    v = m / sum(map(int, str(m)))
    if v < vals[-1]:
        while v < vals[-1]:
            nums.pop()
            vals.pop()
        m = nums[-1]
        d += 1
    else:
        nums.append(m)
        vals.append(v)
print(*nums[:K], sep='\n')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

k = int(input())

now = 1
step = 1


def sunuke(n):
    r = 0
    while n:
        r += n % 10
        n //= 10
    return r


def ok(a, b):
    return a * sunuke(b) <= b*sunuke(a)


while k:
    if ok(now, now+step):
        print(now)
        k -= 1
        now += step
    else:
        nstep = step*10
        while now % nstep != nstep-1:
            now += step
        step = nstep

Submission status: Accepted

Solution code:
k = int(input())
now = 1
step = 1
def s(n):
    r = 0
    while n:
        r += n % 10
        n //= 10
    return r
def ok(a, b):
    return a * s(b) <= b * s(a)
while k:
    if ok(now, now + step):
        print(now)
        k -= 1
        now += step
    else:
        nstep = step * 10
        while now % nstep != nstep - 1:
            now += step
        step = nstep

Submission status: Accepted

Solution code:
k=int(input())
a,b=0,1
for i in range(k):
  a+=b
  print(a)
  if b<(a+b)/sum(map(int,str(a+b))):
    b*=10

Submission status: Accepted

Solution code:
k = int(input())
snuke = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(1, 150):
    for j in range(1, 17):
        snuke.append(int(str(i)+str(10**j-1)))
snuke = list(set(snuke))
snuke.sort()
ans = []
m = (10**17-1)/(9*17)
for s in snuke[::-1]:
    t = sum(map(int, list(str(s))))
    if m>=s/t:
        ans.append(s)
        m = s/t
ans = list(reversed(ans))
print(*ans[:k], sep = '\n')

Submission status: Accepted

Solution code:
K = int(input())
ans = [10**16]
c = 10**15-1
s = 10**15

for i in range(12,0,-1):
    c = 10**i - 1
    for j in range(999,99,-1):
        C = j * (10**i) + c
        S = C/sum(list(map(int, str(C))))
        if S <= s:
            ans.append(C)
            s = S
for i in range(1,10):
    ans += [i,i*10+9,i*100+99]
ans.sort()    
if K > len(ans):
    K = len(ans)
for i in range(K):
    print(ans[i])

Submission status: Accepted

Solution code:
k=int(input())
a=0
b=1
for i in range(k):
  a+=b
  print(a)
  if b<(a+b)/sum(map(int,str(a+b))):
    b*=10

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
z = int(input())
def s(x):
  y = str(x)
  a = 0
  for i in y:
    a += int(i)
  return (x/a,x)

ls = []
for i in range(1,10):
  for j in range(20):
    for k in range(10):
      for l in range(10):
        x = i*10**j+k*10**(j-1)+l*10**(j-2)-1
        x = int(x)
        if x>0:
          ls.append(s(x))
ls.sort()
ans = [0]
for i in ls:
  if ans[-1] < i[1]:
    ans.append(i[1])
print(*ans[1:z+1])