Problem: p03318
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def f(n):
    s=str(n)
    return sum([int(s[i]) for i in range(len(s))])

sunuke=[]
for i in range(100):
    for j in range(2,11):
        sunuke.append(j*(10**i)-1)
L=len(sunuke)
tmp=sunuke[L-1]/f(sunuke[L-1])
ans=[sunuke[L-1]]
for i in range(len(sunuke)-2,-1,-1):
    x=sunuke[i]/f(sunuke[i])
    if x<=tmp:
        ans.append(sunuke[i])
        tmp=x
ans=ans[::-1]

    

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


Failing test case input:
240

Expected output:
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
1099
1199
1299
1399
1499
1599
1699
1799
1899
1999
2999
3999
4999
5999
6999
7999
8999
9999
10999
11999
12999
13999
14999
15999
16999
17999
18999
19999
20999
21999
22999
23999
24999
25999
26999
27999
28999
29999
39999
49999
59999
69999
79999
89999
99999
109999
119999
129999
139999
149999
159999
169999
179999
189999
199999
209999
219999
229999
239999
249999
259999
269999
279999
289999
299999
309999
319999
329999
339999
349999
359999
369999
379999
389999
399999
499999
599999
699999
799999
899999
999999
1099999
1199999
1299999
1399999
1499999
1599999
1699999
1799999
1899999
1999999
2099999
2199999
2299999
2399999
2499999
2599999
2699999
2799999
2899999
2999999
3099999
3199999
3299999
3399999
3499999
3599999
3699999
3799999
3899999
3999999
4099999
4199999
4299999
4399999
4499999
4599999
4699999
4799999
4899999
4999999
5999999
6999999
7999999
8999999
9999999
10999999
11999999
12999999
13999999
14999999
15999999
16999999
17999999
18999999
19999999
20999999
21999999
22999999
23999999
24999999
25999999
26999999
27999999
28999999
29999999
30999999
31999999
32999999
33999999
34999999
35999999
36999999
37999999
38999999
39999999
40999999
41999999
42999999
43999999
44999999
45999999
46999999
47999999
48999999
49999999
50999999
51999999
52999999
53999999
54999999
55999999
56999999
57999999
58999999
59999999
69999999
79999999
89999999
99999999
109999999
119999999
129999999
139999999
149999999
159999999
169999999
179999999
189999999
199999999
209999999
219999999
229999999
239999999
249999999
259999999
269999999
279999999
289999999
299999999
309999999
319999999
329999999
339999999
349999999
359999999
369999999
379999999
389999999
399999999
409999999
419999999
429999999


Actual output:
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
1999999999999999
2999999999999999
3999999999999999
4999999999999999
5999999999999999
6999999999999999
7999999999999999
8999999999999999
9999999999999999
19999999999999999
29999999999999999
39999999999999999
49999999999999999
59999999999999999
69999999999999999
79999999999999999
89999999999999999
99999999999999999
199999999999999999
299999999999999999
399999999999999999
499999999999999999
599999999999999999
699999999999999999
799999999999999999
899999999999999999
999999999999999999
1999999999999999999
2999999999999999999
3999999999999999999
4999999999999999999
5999999999999999999
6999999999999999999
7999999999999999999
8999999999999999999
9999999999999999999
19999999999999999999
29999999999999999999
39999999999999999999
49999999999999999999
59999999999999999999
69999999999999999999
79999999999999999999
89999999999999999999
99999999999999999999
199999999999999999999
299999999999999999999
399999999999999999999
499999999999999999999
599999999999999999999
699999999999999999999
799999999999999999999
899999999999999999999
999999999999999999999
1999999999999999999999
2999999999999999999999
3999999999999999999999
4999999999999999999999
5999999999999999999999
6999999999999999999999
7999999999999999999999
8999999999999999999999
9999999999999999999999
19999999999999999999999
29999999999999999999999
39999999999999999999999
49999999999999999999999
59999999999999999999999
69999999999999999999999
79999999999999999999999
89999999999999999999999
99999999999999999999999
199999999999999999999999
299999999999999999999999
399999999999999999999999
499999999999999999999999
599999999999999999999999
699999999999999999999999
799999999999999999999999
899999999999999999999999
999999999999999999999999
1999999999999999999999999
2999999999999999999999999
3999999999999999999999999
4999999999999999999999999
5999999999999999999999999
6999999999999999999999999
7999999999999999999999999
8999999999999999999999999
9999999999999999999999999
19999999999999999999999999
29999999999999999999999999
39999999999999999999999999
49999999999999999999999999
59999999999999999999999999
69999999999999999999999999
79999999999999999999999999
89999999999999999999999999
99999999999999999999999999
199999999999999999999999999
299999999999999999999999999
399999999999999999999999999
499999999999999999999999999
599999999999999999999999999
699999999999999999999999999


Fixed submission (verdict: Accepted):
def f(n):
    s=str(n)
    return sum([int(s[i]) for i in range(len(s))])

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

sunuke=list(set(sunuke))
sunuke.sort()
sunuke.pop(0)
L=len(sunuke)

tmp1,tmp2=sunuke[L-1],f(sunuke[L-1])
ans=[sunuke[L-1]]
for i in range(len(sunuke)-2,-1,-1):
    x=sunuke[i]
    if x*tmp2<=tmp1*f(x):
        ans.append(x)
        tmp1,tmp2=x,f(x)

ans.sort()

    

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