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: Accepted

Solution code:
def digit_sum(number):
    ans = 0
    for n in str(number):
        ans += int(n)
    return ans

def obj_func(number):
    return number/digit_sum(number)

K = int(input())
num_list = []
d = 1
n = 1

for i in range(K):
    num_list.append(n)
    if obj_func(n + 10**(d-1)) > obj_func(n + 10**d):
        d += 1
    n += 10**(d-1)

print(*num_list, sep='\n')

Submission status: Accepted

Solution code:
K = int(input())


def f(n):
    s = 0
    for n_i in str(n):
        s += int(n_i)
    x = int(n) / s
    return x


order = 1
x = 1
for i in range(K):
    print(x)
    if f(x + 10 ** (order - 1)) > f(x + 10 ** (order)):
        order += 1
    x += 10 ** (order - 1)

Submission status: Accepted

Solution code:
import math
K = int(input())

def S_n(i):
    return sum(list(map(int, str(i))))

def snuke(n):
    return n / S_n(n)

j = 1
order = 1
for i in range(K):
    print(j)
    if snuke(j + 10**(order-1)) > snuke(j + 10**order):
        order += 1
    j += 10**(order-1)

Submission status: Accepted

Solution code:
# almost the copy of answer #2730510 

def S(n):
    return sum(list(map(int, str(n))))

def norm(n):
    return n/S(n)

k = int(input())
j = 1
order = 1
for i in range(k):
    print(j)
    if norm(j+10**(order-1)) > norm(j+10**(order)):
        order += 1
    j += 10**(order-1)

Submission status: Accepted

Solution code:
def SUNUKE(i):
    x=str(i)
    SUM=0

    for j in range(len(x)):
        SUM+=int(x[j])

    return SUM,i/SUM

SUNUKESUU=[0,1,2,3,4,5,6,7,8,9]
i=10
keta=0

while i<10**16:


    if SUNUKE(i)[1]>=10**keta:
        i-=10**keta
        keta+=1
        
    else:
        if SUNUKESUU[-1]!=i:
            SUNUKESUU+=[i]
        i+=10**keta
    

for i in range(1,int(input())+1):
    print(SUNUKESUU[i])

Submission status: Accepted

Solution code:
K = int(input())
c = 0
tick = 1
i=1

while c < K:
    s = sum(map(int,list(str(i))))
    if s*tick<i:
        i += 9*tick
        tick*=10
    else:
        print(i)
        c+=1
        i+=tick

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp
import itertools as it
import functools
import math

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

K = ri()

@functools.lru_cache()
def Sx(i):
  return i/sum(int(s) for s in str(i))

def gen():
  diff = 1
  n = 1
  while True:
    if Sx(n) <= Sx(n+diff):
      yield n
      n += diff
    else:
      n -= diff
      diff *= 10
      n += diff

for n in it.islice(gen(),K):
  print(n)

Submission status: Accepted

Solution code:
k = int(input())
# if k < 10:
#     print(k)
#     exit()

def s(n):
    return sum(list(map(int, str(n))))

seeds = [i for i in range(1, 10)]
for i in range(15):
    for j in range(10):
        for m in range(10):
            for y in range(10):
                seeds.append(int(str(m + j*10 + y*100) + str(9)*i))

# print(seeds)

seeds = [i for i in seeds if i!=0]

l = []
for i in seeds:
    l.append([i, s(i), i/s(i)])

# for i in range(1, 10**6):
#     l.append([i, s(i), i/s(i)])


l.sort(key=lambda x:x[2])
# for i in range(len(l)):
#     print(l[i])

max = 0
ans = []
for i in range(len(l)):
    if l[i][0] > max:
        max = l[i][0]
        ans.append(l[i][0])
        # print(l[i][0], end=" ")

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

# max = 0
# for i in range(len(l)):
#     if l[i][0] > max:
#         max = l[i][0]
#         print(l[i][0]+1, end=" ")
# print()

Submission status: Accepted

Solution code:
K = int(input())

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

# the number of 9s
n9 = 0
e = 10 ** n9

count = 0
upper = 1
while count < K:
    n = (upper + 1) * e - 1
    s = S(upper) + 9 * n9
    if n <= e * s:
        print(n)
        upper += 1
        count += 1
    else:
        n9 += 1
        e  *= 10
        upper //= 10

Submission status: Accepted

Solution code:
def S(n):
    num = 0
    for c in str(n):
        num += int(c)
    return num

def norm(n):
    return n / S(n)

k = int(input())
j = 1
order = 1
for i in range(k):
    print(j) #, norm(j))
    if norm(j + 10 ** (order - 1)) > norm(j + 10 ** (order)):
        order += 1
    j += 10 ** (order - 1)

Submission status: Runtime Error

Solution code:
K = int(input())
snuke = []
for i in range(16):
    for j in range(1,10):
        snuke.append(int(str(j) + "9"*i))

for i in range(K):
    print(snuke[i])

Submission status: Runtime Error

Solution code:
K = int(input())
snuke = []
for i in range(15):
    for j in range(1,10):
        snuke.append(int(str(j) + "9"*i))

for i in range(K):
    print(snuke[i])

Submission status: Runtime Error

Solution code:
k = int(input())

l = []
for i in range(5):
    ten = 10**i
    for j in range(1,100):
        a = ten
        b = j
        n = a*b-1
        if n == 0:
            continue
        s = sum(map(int,str(n)))
        l.append([n/s,n])
l.sort()
now = 0
count = 0
i = 0
while count < k:
    if l[i][1] > now:
        now = l[i][1]
        count += 1
        print(l[i][1])
    i += 1

Submission status: Runtime Error

Solution code:
k = int(input())

l = []
for i in range(17):
    ten = 10**i
    for j in range(2,11):
        a = ten
        b = j
        n = a*b-1
        s = sum(map(int,str(n)))
        l.append([s,n])
l.sort()

for i in range(k):
    print(l[i][1])

Submission status: Runtime Error

Solution code:
k = input()

print(1)
print(2)
print(3)
print(4)
print(5)
print(6)
print(7)
print(8)
print(9)

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

Submission status: Runtime Error

Solution code:
import math
N, K = map(int,input().split())
print(math.ceil((N-1)/(K-1)))

Submission status: Runtime Error

Solution code:
k=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: Runtime Error

Solution code:
sunuke=[]
for i in range(30):
    for j in range(2,11):
        sunuke.append(j*(10**i)-1)

for i in range(int(input())):
    print(sunuke[i])

Submission status: Runtime Error

Solution code:
sunuke=[]
for i in range(20):
    for j in range(2,11):
        sunuke.append(j*10**i-1)

for i in range(int(input())):
    print(sunuke[i])

Submission status: Runtime Error

Solution code:
sunuke=[]
for i in range(20):
    for j in range(2,11):
        sunuke.append(j*10**i+-1)

for i in range(int(input())):
    print(sunuke[i])

Submission status: Runtime Error

Solution code:
sunuke=[]
for i in range(17):
    for j in range(2,11):
        sunuke.append(j*10**i+-1)

for i in range(int(input())):
    print(sunuke[i])

Submission status: Runtime Error

Solution code:
sunuke=[]
for i in range(17):
    for j in range(1,10):
        sunuke.append(j*10**i+(10**i-1))

for i in range(int(input())):
    print(sunuke[i])

Submission status: Runtime Error

Solution code:

sunuke=[]
for i in range(17):
    for j in range(1,10):
        sunuke.append(j*10**i+(10**i-1))

for i in range(int(input())):
    print(sunuke[i])

Submission status: Runtime Error

Solution code:

sunuke=[]
for i in range(16):
    for j in range(1,10):
        sunuke.append(j*10**i+(10**i-1))

for i in range(int(input())):
    print(sunuke[i])

Submission status: Runtime Error

Solution code:
m=float("INF")
sunukes=[]
for i in range(2,-1,-1):
    for j in range(100,10,-1):
        #print(i,j)
        sunuke=j*(10**i)-1
        s=str(sunuke)
        sn=0
        for k in range(len(s)):
            sn+=int(s[k])
        x=sunuke/sn
        #print(sn,x,i,j,j*10**i-1)
        if x<=m :
            m=x
            sunukes.append(sunuke)
for i in range(9,0,-1):
    sunukes.append(i)
k=int(input())
#print(sunukes)
print(sunukes[-k])

Submission status: Runtime Error

Solution code:
q=[]
vis=set() 
q=[i for i in range(1,10)]
nums=[]
while q:
   # nums.append(t)
    t=q.pop(0)
    nums.append(t)
    if not t*10+9 in vis  and t*10+9<=10**15:
        q.append(t*10+9)
        vis.add(t*10+9)
nums.sort()
k=int(input())
for i in range(k):
    print(nums[i])

Submission status: Runtime Error

Solution code:
q=[]
vis=set() 
q=[i for i in range(1,10)]
nums=[]
while q:
   # nums.append(t)
    t=q.pop(0)
    nums.append(t)
    if not t*10+9 in vis  and t*10+9<=10**16:
        q.append(t*10+9)
        vis.add(t*10+9)
nums.sort()
k=int(input())
for i in range(k):
    print(nums[i])

Submission status: Runtime Error

Solution code:
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

v = [1]
n = [1]
for i in range(2, 1000) :
    x = i / S(i)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(i)

suf = 99
for i in range(2, 14) :
    for j in range(10, 100) :
        k =  j * (10 ** i) + suf
        x = k / S(k)
        while v[-1] > x :
            v.pop()
            n.pop()
        v.append(x)
        n.append(k)
    
    suf = suf * 10 + 9

for i in range(K) :
    print(n[i])

Submission status: Runtime Error

Solution code:
K = int(input())

def S(x) :
    ret = 0
    while x :
        ret += x % 10
        x //= 10
    return ret

v = [1]
n = [1]
for i in range(2, 1000) :
    x = i / S(i)
    while v[-1] > x :
        v.pop()
        n.pop()
    v.append(x)
    n.append(i)

suf = 99
for i in range(2, 11) :
    for j in range(10, 100) :
        k =  j * (10 ** i) + suf
        x = k / S(k)
        while v[-1] > x :
            v.pop()
            n.pop()
        v.append(x)
        n.append(k)
    
    suf = suf * 10 + 9

for i in range(K) :
    print(n[i])

Submission status: Runtime Error

Solution code:
s=[]
c=""
for i in range(14):
    for j in range(1,10):
        s.append(str(j)+c)
    c+="9"
t=[]
p=float("INF")
for i in s[::-1]:
    g=int(i)/sum(int(j)for j in i)
    if g<=p:
        t.append(i)
        p=g
t=t[::-1]
for i in range(int(input())):
    print(t[i])

Submission status: Runtime Error

Solution code:
#18:03
k = int(input())
a = []
for i in range(16):
  for j in range(2,11):
    a.append(j * 10 ** i - 1)
for l in range(k):
  print(a[l])

Submission status: Runtime Error

Solution code:
#18:03
k = int(input())
a = []
for i in range(15):
  for j in range(2,11):
    a.append(j * 10 ** i - 1)
for l in range(k):
  print(a[l])

Submission status: Runtime Error

Solution code:
ans = [i for i in range(1,10)]
L1= [10*i+9 for i in range(1,11)]
ans += L1
L2 = [int(str(9)*i) for i in range(3,16)]
ans += L2
K = int(input())
for i in range(K):
        print(ans[i])

Submission status: Runtime Error

Solution code:
K = int(input())

snuke = [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]

for n in range(3,16):
    for k in range(1,11):
        snuke.append(10**(n-1)*(10+k)-1)
    for k in range(2,10):
        snuke.append((k+1)*10**n-1)

for k in range(K):
    print(snuke[k])

Submission status: Runtime Error

Solution code:
K = int(input())

snuke = [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]

for n in range(3,16):
    for k in range(1,10):
        snuke.append(10**(n-1)*(10+k)-1)
    for k in range(2,10):
        snuke.append((k+1)*10**n-1)

for k in range(K):
    print(snuke[k])

Submission status: Runtime Error

Solution code:
#D問題
K = int(input())
keta = 1
now = 1
def sunuke(n):
    a = 0
    for i in str(n):
        a+=int(i)
    return(n/a)
count=0
while count < k:
    if sunuke(now) <= sunuke(now+keta):
        print(now)
        now+=keta
        count+=1
    else:
        now+=9*keta
        keta *= 10

Submission status: Runtime Error

Solution code:
#D問題
K = int(input())
keta = 1
now = 1
def sunuke(n):
    a = 0
    for i in str(n):
        a+=int(i)
    return(n/a)
count=0
while count < k:
    if sunuke(ima) <= sunuke(ima+keta):
        print(ima)
        ima += keta
        count += 1
    else:
        ima += 9*keta
        keta *= 10

Submission status: Runtime Error

Solution code:
snuke_num = []
for i in range(20):
  for j in range(1,10):
    snuke_num.append(int(str(j)+"9"*i))

k = int(input())
for i in range(k):
  print(snuke_num[i])

Submission status: Runtime Error

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
from matplotlib import pyplot


def solve(k):
  step = 1
  ret = 0
  mx = 9
  while k > 0:
    ret += step
    k -= 1
    if ret >= mx:
      step *= 10
      mx = mx*10 + 9
    print(ret)

k = int(input())
solve(k)

Submission status: Runtime Error

Solution code:
import sys
K = int(input())
count = 0
nine = ""

arr = [i for i in range(1,10)]
arr_sunuke = [i for i in range(1,10)]
for k in range(13):
    for i in range(1,10):
        for j in range(10):
            arr.append(int(str(i)+str(j)+nine))
            arr_sunuke.append(i + j + k*9)
    nine = nine + str(9)


arr_sunuke2 = [arr[i]/arr_sunuke[i] for i in range(len(arr))]

ans = []
tmp = 100000000000000
for i in range(len(arr)-1, -1, -1):
    if arr_sunuke2[i] <= tmp:
        ans.append(arr[i])
        tmp = arr_sunuke2[i]

ans = ans[::-1]
for i in range(K):
    print(ans[i])

Submission status: Runtime Error

Solution code:
import sys

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


def f(n):
  d = 0
  C = [n]
  while S(n) > (10**(d-1) / (9*d)):
    c = 10**(d+1) * (n // 10**(n+1) + 1) - 1
    C.append(c)
  
  Smin = float('inf')
  res = 0
  for c in C:
    if S(c) < Smin:
      res = c  
  return res
  
def main():
  input = sys.stdin.readline
  K = int(input())
  ans = 1
  while _ in range(K):
    print(ans)
    ans = f(ans+1)


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
    
def S(n):
    ans = 0
    while n != 0:
        ans += n % 10 
        n //= 10
    return ans
def get_snuke(n):
    return n / S(n)

def get_keta(n):
    keta = 0
    while n:
        keta += 1
        n //= 10
    return keta
ans = [1]
from collections import deque
from copy import copy
def nexta(K):
    if K == 1:
        return ans[0]

    listInt= []
    bef = ans[K-2]

    while bef:
        listInt.append(bef % 10)
        bef //= 10

    # bef = list(reverse(bef))
    # for i in range(len(bef)-1, -1, -1):
    for i in range(len(listInt)):
        if listInt[i] != 9:
            break
    
    if i == len(listInt)-1 and listInt[i] == 9:
        # ALL 9 
        action5 = copy(listInt)
        action5.append(1)
        action6 = copy(listInt)
        action6.append(9)
        action1 = action5
        action2 = action5
        action3 = action5
        # action4 = action5
        action4 = copy(listInt)
        # action4[i] = "01"
        action4[i] += 1

    else:
        action1 = copy(listInt)
        action1[i] += 1

        action2 = copy(listInt)
        action2[i] = 9
        
        action3 = copy(listInt)
        action3[i] = 9
        if i == len(listInt) -1 :
            action3.append(1)
        # elif i != len(listInt)-1 and action3[i] == 9:
        #     pass
            

        action4 = copy(listInt)
        action4[i] = 9
        if i == len(listInt) -1 :
            action3.append(9)



        action5 = action1
        action6 = action1
        # elif i != len(listInt)-1 and action3[i] == 9:
        #     pass
    # action1_num = int(

    action1 = list(reversed(action1))
    action1 = list(map(lambda x: str(x), action1))
    action2 = list(reversed(action2))
    action2 = list(map(lambda x: str(x), action2))
    action3 = list(reversed(action3))
    action3 = list(map(lambda x: str(x), action3))
    action4 = list(reversed(action4))
    action4 = list(map(lambda x: str(x), action4))
    action5 = list(reversed(action5))
    action5 = list(map(lambda x: str(x), action5))
    action6 = list(reversed(action6))
    action6 = list(map(lambda x: str(x), action6))

    actions = [action1, action2, action3, action4, action5, action6]
    # print("actions: ", actions)
    minvalue = 10**9
    mini = -1

    for e,act in enumerate(actions):
        if minvalue > get_snuke(int("".join(act))):
            mini = e
            minvalue = get_snuke(int("".join(act)))
    # print("mini: ", mini, actions[mini])

    ans.append(int("".join(actions[mini])))# get_snukeactions[mini]

    return 

K = int(input())
for i in range(1,K+1):
    nexta(i)
# print(ans)
print("\n".join(list(map(lambda x: str(x), ans[:K]))))
            

exit(0)

Submission status: Runtime Error

Solution code:
def dsum(n):
    ret = 0
    while n > 0:
        ret += n % 10
        n //= 10
    return ret


def g(n):
    return n / dsum(n)

K = int(input())

res = []
base = 1
for i in range(15):
    for j in range(1, 150):
        res.append(base * (j + 1) - 1)
    base *= 10

res.sort()
res = list(set(res))

ans = []
print(res[:20])
for i, r in enumerate(res):
    flag = true
    for j in range(i + 1, len(res)):
        if g(r) > g(res[j]):
            flag = False
            break
    if flag:
        ans.append(r)

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

Submission status: Runtime Error

Solution code:
k = int(input())
sunuke_list = [1,2,3,4,5,6,7,8]
def s(n):
    n_charlist = list(str(n))
    return sum(list(map(int, n_charlist)))
def combine_int(i,n):
    i_charlist = list(str(i))
    n_charlist = ['9'] * n
    ret_charlist = i_charlist + n_charlist
    ret_str = ''.join(ret_charlist)
    return int(ret_str)
for n in range(1,13):
    i = n-1
    while((i+1)/(s(i)+9*n) <= (i+2)/(s(i+1)+9*n)):
        sunuke_list.append(combine_int(i,n))
        i += 1
for i in range(k):
    print(sunuke_list[i])

Submission status: Runtime Error

Solution code:
import matplotlib.pyplot as plt

k = int(input())
"""
x = []
for i in range(1,k):
    str_number = list(map(int,str(i)))
    sum_number = sum(str_number)
    sunuke = i /float(sum_number)
    x.append(sunuke)
    print(i,":",sunuke)

plt.figure()
plt.plot(x)
plt.show()
"""

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

Submission status: Runtime Error

Solution code:
K = int(input())
sunuke = [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]
i = 0
while i < K:
  print(sunuke[i])
  i+=1

Submission status: Runtime Error

Solution code:
K = int(input())
sunuke = [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]
i = 0
while i < K:
  print(sunuke[i])
  i+=1

Submission status: Runtime Error

Solution code:
from collections import deque
k = int(input())

digsum = lambda x: sum(list(map(int, list(str(x)))))

que = deque([])
MAX = 800000
min_v = MAX
for i in range(MAX-1, 0, -1):
    v = i/digsum(i)
    if v <= min_v:
        que.append(i)
        # print(i, v)
        min_v = v
        
while k > 0:
    print(que.pop())
    k -= 1

Submission status: Runtime Error

Solution code:
from collections import deque
k = int(input())

digsum = lambda x: sum(list(map(int, list(str(x)))))

que = deque([])
MAX = 500000
min_v = MAX
for i in range(MAX-1, 0, -1):
    v = i/digsum(i)
    if v <= min_v:
        que.append(i)
        # print(i, v)
        min_v = v
        
while k > 0:
    print(que.pop())
    k -= 1

Submission status: Runtime Error

Solution code:
import sys
fin = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush


def initialize(adj, s):
    MAX_NUM = float('inf')
    parent = {s: None}
    d = {vertex: MAX_NUM for vertex in adj.keys()}
    d[s] = 0
    return d, parent


def initialize_int(adj, s):
    """
    assume that all vertex in {0, 1, 2, ..., N - 1}
    """
    N = len(adj)
    MAX_NUM = float('inf')
    d = [MAX_NUM] * N
    d[s] = 0
    parent = [None] * N
    return d, parent


# Dijkstra can work using a minheap which does not have decrease_key.
# and also we do not have to implement Vertex class.
# Instead, we can use (distance, vertex).
# in this case, the time it takes is O(ElgE).
# E is at most O(V^2), thus O(ElgE) = O(ElgV).
def dijkstra_simple(adj, w, s):
    d, parent = initialize_int(adj, s)
    priority_queue = []
    heappush(priority_queue, (d[s], s))
    while priority_queue:
        distance, source = heappop(priority_queue) 
        for neighbor in adj[source]:
            new_distance = distance + w[(source, neighbor)]
            if new_distance < d[neighbor]:
                d[neighbor] = new_distance
                parent[neighbor] = source
                heappush(priority_queue, (new_distance, neighbor))
    return d


n, m, s, t = [int(elem) for elem in fin().split()]
s -= 1
t -= 1
adj = [[] for _ in range(n)]
yen_weights = dict()
snuuk_weights = dict()
for _ in range(m):
    u, v, a, b = [int(elem) for elem in fin().split()]
    u -= 1
    v -= 1
    for v1, v2 in [(u, v), (v, u)]:
        adj[v1].append(v2)
        yen_weights[(v1, v2)] = a
        snuuk_weights[(v1, v2)] = b

d_yen = dijkstra_simple(adj, yen_weights, s)
d_snuuk = dijkstra_simple(adj, snuuk_weights, t)
min_cost = float('inf')
min_cost_after_each_year_reversed = []
for vertex in reversed(range(n)):
    min_cost = min(min_cost, d_yen[vertex] + d_snuuk[vertex])
    min_cost_after_each_year_reversed.append(min_cost)

initial_money = 10**15
for cost in reversed(min_cost_after_each_year_reversed):
    print(initial_money - cost)

Submission status: Runtime Error

Solution code:
k = int(input())
ans = []
for i in range(1,200):
    ans.append(int(str(i%9)+'9'*(i//9)))
j = 0
for i in range(k):
    if ans[j]/(j+1) > ans[j+1]/(j+2):
        j += 1
    else:
        print(ans[j])
        j += 1

Submission status: Runtime Error

Solution code:
k = int(input())
ans = []
for i in range(1,136):
    ans.append(int(str(i%9)+'9'*(i//9)))
j = 0
for i in range(k):
    if ans[j]/(j+1) > ans[j+1]/(j+2):
        j += 1
    else:
        print(ans[j])
        j += 1

Submission status: Runtime Error

Solution code:
あいうえお

Submission status: Runtime Error

Solution code:
res = []
for digit in range(1,16):
    if digit<=3:
        for i in range(2,11):
            res.append(10**(digit-1)*i-1)
    elif 4<=digit<=12:
        for i in range(11,(digit-2)*10):
            res.append(i*10**(digit-2)-1)
        for i in range(digit-2,11):
            res.append(i*10**(digit-1)-1)
    else:
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
for i in range(int(input())):
    print(res[i])

Submission status: Runtime Error

Solution code:
import math
#import datetime

def s(n):
	sum = 0
	for c in str(n):
		sum += int(c)
	return sum

k = int(input())
found=0

def next_sunuke(n, s_n, s_n_div):

	global found

	if n == 1:
		return

	m = n - 1
	s_mplus1 = s(m + 1)

	while m >= 1:
		s_m = s(m)

		if (s_m < s_mplus1 or (s_n - s_m != 1 and s_n - s_m != -8)) and m > 9:
			m -= 1
			s_mplus1 = s_m
			continue

		# print("check: " + str(m))

		s_m_div = m / s(m)

		if s_m_div <= s_n_div:
			next_sunuke(m, s_m, s_m_div)
			if found >= k:
				return

			found += 1
			# print("{0:5d}".format(m), "{0:2d}".format(s_m), s_m_div)
			print(m)
			break
		# else:
		# 	log_m = int(math.log(m,10))
		# 	if (m + 1) / (10 ** (log_m - 1)) == 19:

		# 		print ("skip: " + str(m) + " to " + str(10 ** log_m - 1))

		# 		m = 10 ** log_m - 1
		# 		s_mplus1 = s(m+1)
		# 		continue
		m -= 1
		s_mplus1 = s_m


# 適当な大きいスヌケ数
current_sunuke = 999999
s_current_sunuke = s(current_sunuke)
s_current_sunuke_div = current_sunuke / s_current_sunuke

#start = datetime.datetime.now()
next_sunuke(current_sunuke, s_current_sunuke, s_current_sunuke_div)
#end = datetime.datetime.now()
print(str(end-start))

# sunukes=[]

# n = current_sunuke - 1

# while(n >= 1):
# 	s_n = n / s(n)
# 	if s_n <= current_sunuke_n:
# 		#sunukes.insert(0,n)
# 		sunukes.append(n)
# 		current_sunuke = n
# 		current_sunuke_n = s_n
# 	n -= 1

# for n in sunukes:
# 	print (n)

Submission status: Runtime Error

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


def digit(i):
    if i>0:
        return digit(i//10)+[i%10]
    else:
        return []

def Sooo(N):
    return float(N/sum(digit(N)))
base=1
A=[]
for i in range(0,16):
    for j in range(1,151):
        re=base*(j+1)-1
        A.append(int(re))
    base = base*10
A = list(set(A))
A.sort()

for i in range(0,len(A)):
    #for j in range(i+1,len(A)):
        N=Sooo(A[i])
        M=Sooo(A[i+1])
        if N>M:
            A[i]=1

A = list(set(A))
A.sort()

K=int(input())
for i in range(K):
    print(A[i])

Submission status: Runtime Error

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

def digit(i):
    if i>0:
        return digit(i//10)+[i%10]
    else:
        return []

def Sooo(N):
    return float(N/sum(digit(N)))
base=1
A=[]
for i in range(0,37):
    for j in range(1,200):
        re=base*(j+1)-1
        A.append(int(re))
    base = base*10
A = list(set(A))
A.sort()
l=len(A)
#print(l)
ffor i in range(0,len(A)):
    for j in range(i+1,len(A)):
        N=Sooo(A[i])
        M=Sooo(A[j])
        if N>M:
            A[i]=0
            break;
A = list(set(A))
A.sort()
K=int(input())
for i in range(K):
    print(A[i+1])

Submission status: Runtime Error

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


def digit(i):
    if i>0:
        return digit(i//10)+[i%10]
    else:
        return []

def Sooo(N):
    return float(N/sum(digit(N)))
base=1
A=[]
for i in range(0,16):
    for j in range(1,151):
        re=base*(j+1)-1
        A.append(int(re))
    base = base*10
A = list(set(A))
A.sort()

for i in range(0,len(A)):
    for j in range(i+1,len(A)):
        N=Sooo(A[i])
        M=Sooo(A[j])
        if N>M:
            A[i]=0

A = list(set(A))
A.sort()
  
K=int(input())
for i in range(K):
    print(A[i+1])

Submission status: Runtime Error

Solution code:
K = int(input())

res = [(0, 0)]
mm = 0
for i in range(1, 136):
  n = []
  x = i
  while x > 0:
    n.append(str(min(x, 9)))
    x -= 9
  n.reverse()
  x = int(''.join(n))
  
  while x / i < res[-1][0]:
    res = res[:-1]
  res.append((x / i, x))

for i in range(1, K + 1):
  print(res[i][1])

Submission status: Runtime Error

Solution code:
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math 
# import collections
# import string
# ===================================
n = int(input())
s = "9"
for i in range(1, n+1):
	if i < 10:
		print(i)
	else:
		if s[0] == "9":
			s = "1" + s
		else:
			s[0] = int(s[0]) + 1
		print(s)

Submission status: Runtime Error

Solution code:
def abc101_dx():
    k = int(input())

    snuke_nums = []
    for i in range(15):
        snuke_nums.extend([n * (10 ** i) - 1 for n in range(2, 11)])
        if len(snuke_nums) >= k:
            break

    num = len(snuke_nums)
    snuke_sn = [0 for i in range(num)]
    for i in range(num):
        tmp = snuke_nums[i]
        sn = 0
        while tmp:
            sn += tmp % 10
            tmp //= 10
        snuke_sn[i] = snuke_nums[i] / sn

    snuke_sn_sort = sorted(snuke_sn)

    snuke_flag = [False for i in range(num)]
    for i in range(num):
        if snuke_sn[i] != snuke_sn_sort[i]:
            snuke_flag[i] = True

    snuke_ans = []
    for i in range(num):
        if not snuke_flag[i]:
            snuke_ans.append(snuke_nums[i])

    for i in range(k):
        print(snuke_ans[i])

abc101_dx()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
k = int(input())
ans = 10**15
li = []
for i in reversed(list(range(1,10**15))):
    snk = sum([int(j) for j in str(i)])
    if(ans >= i/snk):
        ans = i/snk
        li.append(i)
        
for i in list(reversed(li))[:k]:
    print(i)

Submission status: Runtime Error

Solution code:
K = int(input())

a,b = [],[]
for i in range(16):
    for j in range(1,101):
        a.append(int(str(j)+"9"*i))
        b.append(a[-1] / sum(list(map(int, str(a[-1])))))

n = 0
while True:
    for i in range(len(b)):
        if min(b[(i+1):]) >= b[i]:
            print(a[i])
            n += 1
            if n == K: exit()

Submission status: Runtime Error

Solution code:
K = int(input())
f = 0
num = 1
while f < K:
	keta = len(str(num))
	if keta == 1:
		print(num)
		f += 1
	elif keta == 2:
		if num % 10 == 9:
			print(num)
			f += 1
	else:
		if num == 10 ** (keta-1):
			nine = ''
			nine = int(nine)
		for _ in range(keta-1):
			nine += '9'
		if num % 10 ** (keta-2) == nine:
			print(num)
			f += 1 
	num += 1