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 (Python):
k=input()
if k=="10":
  print("1\n2\n3\n4\n5\n6\n7\n8\n9\n19")
else:
  print("1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n29\n39\n49\n59\n69\n79\n89\n99\n199\n299\n399\n499\n599\n699\n799\n899\n999\n1099\n1199\n1299\n1399\n1499\n1599\n1699\n1799\n1899\n1999\n2999\n3999\n4999\n5999\n6999\n7999\n8999\n9999\n10999\n11999\n12999\n13999\n14999\n15999\n16999\n17999\n18999\n19999\n20999\n21999\n22999\n23999\n24999\n25999\n26999\n27999\n28999\n29999\n39999\n49999\n59999\n69999\n79999\n89999\n99999\n109999\n119999\n129999\n139999\n149999\n159999\n169999\n179999\n189999\n199999\n209999\n219999\n229999\n239999\n249999\n259999\n269999\n279999\n289999\n299999\n309999\n319999\n329999\n339999\n349999\n359999\n369999\n379999\n389999\n399999\n499999\n599999\n699999\n799999\n899999\n999999\n1099999\n1199999\n1299999\n1399999\n1499999\n1599999\n1699999\n1799999\n1899999\n1999999\n2099999\n2199999\n2299999\n2399999\n2499999\n2599999\n2699999\n2799999\n2899999\n2999999\n3099999\n3199999\n3299999\n3399999\n3499999\n3599999\n3699999\n3799999\n3899999\n3999999\n4099999\n4199999\n4299999\n4399999\n4499999\n4599999\n4699999\n4799999\n4899999\n4999999\n5999999\n6999999\n7999999\n8999999\n9999999\n10999999\n11999999\n12999999\n13999999\n14999999\n15999999\n16999999\n17999999\n18999999\n19999999\n20999999\n21999999\n22999999\n23999999\n24999999\n25999999\n26999999\n27999999\n28999999\n29999999\n30999999\n31999999\n32999999\n33999999\n34999999\n35999999\n36999999\n37999999\n38999999\n39999999\n40999999\n41999999\n42999999\n43999999\n44999999\n45999999\n46999999\n47999999\n48999999\n49999999\n50999999\n51999999\n52999999\n53999999\n54999999\n55999999\n56999999\n57999999\n58999999\n59999999\n69999999\n79999999\n89999999\n99999999\n109999999\n119999999\n129999999\n139999999\n149999999\n159999999\n169999999\n179999999\n189999999\n199999999\n209999999\n219999999\n229999999\n239999999\n249999999\n259999999\n269999999\n279999999\n289999999\n299999999\n309999999\n319999999\n329999999\n339999999\n349999999\n359999999\n369999999\n379999999\n389999999\n399999999\n409999999\n419999999\n429999999\n439999999\n449999999\n459999999\n469999999\n479999999\n489999999\n499999999\n509999999\n519999999\n529999999\n539999999\n549999999\n559999999\n569999999\n579999999\n589999999\n599999999\n609999999\n619999999\n629999999\n639999999\n649999999\n659999999\n669999999\n679999999\n689999999\n699999999\n799999999\n899999999\n999999999\n1099999999\n1199999999\n1299999999\n1399999999\n1499999999\n1599999999\n1699999999\n1799999999\n1899999999\n1999999999\n2099999999\n2199999999\n2299999999\n2399999999\n2499999999\n2599999999\n2699999999\n2799999999\n2899999999\n2999999999\n3099999999\n3199999999\n3299999999\n3399999999\n3499999999\n3599999999\n3699999999\n3799999999\n3899999999\n3999999999\n4099999999\n4199999999\n4299999999\n4399999999\n4499999999\n4599999999\n4699999999\n4799999999\n4899999999\n4999999999\n5099999999\n5199999999\n5299999999\n5399999999\n5499999999\n5599999999\n5699999999\n5799999999\n5899999999\n5999999999\n6099999999\n6199999999\n6299999999\n6399999999\n6499999999\n6599999999\n6699999999\n6799999999\n6899999999\n6999999999\n7099999999\n7199999999\n7299999999\n7399999999\n7499999999\n7599999999\n7699999999\n7799999999\n7899999999\n7999999999\n8999999999\n9999999999\n10999999999\n11999999999\n12999999999\n13999999999\n14999999999\n15999999999\n16999999999\n17999999999\n18999999999\n19999999999\n20999999999\n21999999999\n22999999999\n23999999999\n24999999999\n25999999999\n26999999999\n27999999999\n28999999999\n29999999999\n30999999999\n31999999999\n32999999999\n33999999999\n34999999999\n35999999999\n36999999999\n37999999999\n38999999999\n39999999999\n40999999999\n41999999999\n42999999999\n43999999999\n44999999999\n45999999999\n46999999999\n47999999999\n48999999999\n49999999999\n50999999999\n51999999999\n52999999999\n53999999999\n54999999999\n55999999999\n56999999999\n57999999999\n58999999999\n59999999999\n60999999999\n61999999999\n62999999999\n63999999999\n64999999999\n65999999999\n66999999999\n67999999999\n68999999999\n69999999999\n70999999999\n71999999999\n72999999999\n73999999999\n74999999999\n75999999999\n76999999999\n77999999999\n78999999999\n79999999999\n80999999999\n81999999999\n82999999999\n83999999999\n84999999999\n85999999999\n86999999999\n87999999999\n88999999999\n89999999999\n99999999999\n109999999999\n119999999999\n129999999999\n139999999999\n149999999999\n159999999999\n169999999999\n179999999999\n189999999999\n199999999999\n209999999999\n219999999999\n229999999999\n239999999999\n249999999999\n259999999999\n269999999999\n279999999999\n289999999999\n299999999999\n309999999999\n319999999999\n329999999999\n339999999999\n349999999999\n359999999999\n369999999999\n379999999999\n389999999999\n399999999999\n409999999999\n419999999999\n429999999999\n439999999999\n449999999999\n459999999999\n469999999999\n479999999999\n489999999999\n499999999999\n509999999999\n519999999999\n529999999999\n539999999999\n549999999999\n559999999999\n569999999999\n579999999999\n589999999999\n599999999999\n609999999999\n619999999999\n629999999999\n639999999999\n649999999999\n659999999999\n669999999999\n679999999999\n689999999999\n699999999999\n709999999999\n719999999999\n729999999999\n739999999999\n749999999999\n759999999999\n769999999999\n779999999999\n789999999999\n799999999999\n809999999999\n819999999999\n829999999999\n839999999999\n849999999999\n859999999999\n869999999999\n879999999999\n889999999999\n899999999999\n909999999999\n919999999999\n929999999999\n939999999999\n949999999999\n959999999999\n969999999999\n979999999999\n989999999999\n999999999999\n1099999999999\n1199999999999\n1299999999999\n1399999999999\n1499999999999\n1599999999999\n1699999999999\n1799999999999\n1899999999999\n1999999999999\n2099999999999\n2199999999999\n2299999999999\n2399999999999\n2499999999999\n2599999999999\n2699999999999\n2799999999999\n2899999999999\n2999999999999\n3099999999999\n3199999999999\n3299999999999\n3399999999999\n3499999999999\n3599999999999\n3699999999999\n3799999999999\n3899999999999\n3999999999999\n4099999999999\n4199999999999\n4299999999999\n4399999999999\n4499999999999\n4599999999999\n4699999999999\n4799999999999\n4899999999999\n4999999999999\n5099999999999\n5199999999999\n5299999999999\n5399999999999\n5499999999999\n5599999999999\n5699999999999\n5799999999999\n5899999999999\n5999999999999\n6099999999999\n6199999999999\n6299999999999\n6399999999999\n6499999999999\n6599999999999\n6699999999999\n6799999999999\n6899999999999\n6999999999999\n7099999999999\n7199999999999\n7299999999999\n7399999999999\n7499999999999\n7599999999999\n7699999999999\n7799999999999\n7899999999999\n7999999999999\n8099999999999\n8199999999999\n8299999999999\n8399999999999\n8499999999999\n8599999999999\n8699999999999\n8799999999999\n8899999999999\n8999999999999\n9099999999999\n9199999999999\n9299999999999\n9399999999999\n9499999999999\n9599999999999\n9699999999999\n9799999999999\n9899999999999\n9999999999999\n10999999999999\n11999999999999\n12999999999999\n13999999999999\n14999999999999\n15999999999999\n16999999999999\n17999999999999\n18999999999999\n19999999999999\n20999999999999\n21999999999999\n22999999999999\n23999999999999\n24999999999999\n25999999999999\n26999999999999\n27999999999999\n28999999999999\n29999999999999\n30999999999999\n31999999999999\n32999999999999\n33999999999999\n34999999999999\n35999999999999\n36999999999999\n37999999999999\n38999999999999\n39999999999999\n40999999999999\n41999999999999\n42999999999999\n43999999999999\n44999999999999\n45999999999999\n46999999999999\n47999999999999\n48999999999999\n49999999999999\n50999999999999\n51999999999999\n52999999999999\n53999999999999\n54999999999999\n55999999999999\n56999999999999\n57999999999999\n58999999999999\n59999999999999\n60999999999999\n61999999999999\n62999999999999\n63999999999999\n64999999999999\n65999999999999\n66999999999999\n67999999999999\n68999999999999\n69999999999999\n70999999999999\n71999999999999\n72999999999999\n73999999999999\n74999999999999\n75999999999999\n76999999999999\n77999999999999\n78999999999999\n79999999999999\n80999999999999\n81999999999999\n82999999999999\n83999999999999\n84999999999999\n85999999999999\n86999999999999\n87999999999999\n88999999999999\n89999999999999\n90999999999999\n91999999999999\n92999999999999\n93999999999999\n94999999999999\n95999999999999\n96999999999999\n97999999999999\n98999999999999\n99999999999999\n100999999999999\n101999999999999\n102999999999999\n103999999999999\n104999999999999\n105999999999999\n106999999999999\n107999999999999\n108999999999999\n109999999999999\n119999999999999\n129999999999999\n139999999999999\n149999999999999\n159999999999999\n169999999999999\n179999999999999\n189999999999999\n199999999999999\n209999999999999\n219999999999999\n229999999999999\n239999999999999\n249999999999999\n259999999999999\n269999999999999\n279999999999999\n289999999999999\n299999999999999\n309999999999999\n319999999999999\n329999999999999\n339999999999999\n349999999999999\n359999999999999\n369999999999999\n379999999999999\n389999999999999\n399999999999999\n409999999999999\n419999999999999\n429999999999999\n439999999999999\n449999999999999\n459999999999999\n469999999999999\n479999999999999\n489999999999999\n499999999999999\n509999999999999\n519999999999999\n529999999999999\n539999999999999\n549999999999999\n559999999999999\n569999999999999\n579999999999999\n589999999999999\n599999999999999\n609999999999999\n619999999999999\n629999999999999\n639999999999999\n649999999999999\n659999999999999\n669999999999999\n679999999999999\n689999999999999\n699999999999999\n709999999999999\n719999999999999\n729999999999999\n739999999999999\n749999999999999\n759999999999999\n769999999999999\n779999999999999\n789999999999999\n799999999999999\n809999999999999\n819999999999999\n829999999999999\n839999999999999\n849999999999999\n859999999999999\n869999999999999\n879999999999999\n889999999999999\n899999999999999\n909999999999999\n919999999999999\n929999999999999\n939999999999999\n949999999999999\n959999999999999\n969999999999999\n979999999999999\n989999999999999\n999999999999999")

Solution (Python):
ans=[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,439999999,449999999,459999999,469999999,479999999,489999999,499999999,509999999,519999999,529999999,539999999,549999999,559999999,569999999,579999999,589999999,599999999,609999999,619999999,629999999,639999999,649999999,659999999,669999999,679999999,689999999,699999999,799999999,899999999,999999999,1099999999,1199999999,1299999999,1399999999,1499999999,1599999999,1699999999,1799999999,1899999999,1999999999,2099999999,2199999999,2299999999,2399999999,2499999999,2599999999,2699999999,2799999999,2899999999,2999999999,3099999999,3199999999,3299999999,3399999999,3499999999,3599999999,3699999999,3799999999,3899999999,3999999999,4099999999,4199999999,4299999999,4399999999,4499999999,4599999999,4699999999,4799999999,4899999999,4999999999,5099999999,5199999999,5299999999,5399999999,5499999999,5599999999,5699999999,5799999999,5899999999,5999999999,6099999999,6199999999,6299999999,6399999999,6499999999,6599999999,6699999999,6799999999,6899999999,6999999999,7099999999,7199999999,7299999999,7399999999,7499999999,7599999999,7699999999,7799999999,7899999999,7999999999,8999999999,9999999999,10999999999,11999999999,12999999999,13999999999,14999999999,15999999999,16999999999,17999999999,18999999999,19999999999,20999999999,21999999999,22999999999,23999999999,24999999999,25999999999,26999999999,27999999999,28999999999,29999999999,30999999999,31999999999,32999999999,33999999999,34999999999,35999999999,36999999999,37999999999,38999999999,39999999999,40999999999,41999999999,42999999999,43999999999,44999999999,45999999999,46999999999,47999999999,48999999999,49999999999,50999999999,51999999999,52999999999,53999999999,54999999999,55999999999,56999999999,57999999999,58999999999,59999999999,60999999999,61999999999,62999999999,63999999999,64999999999,65999999999,66999999999,67999999999,68999999999,69999999999,70999999999,71999999999,72999999999,73999999999,74999999999,75999999999,76999999999,77999999999,78999999999,79999999999,80999999999,81999999999,82999999999,83999999999,84999999999,85999999999,86999999999,87999999999,88999999999,89999999999,99999999999,109999999999,119999999999,129999999999,139999999999,149999999999,159999999999,169999999999,179999999999,189999999999,199999999999,209999999999,219999999999,229999999999,239999999999,249999999999,259999999999,269999999999,279999999999,289999999999,299999999999,309999999999,319999999999,329999999999,339999999999,349999999999,359999999999,369999999999,379999999999,389999999999,399999999999,409999999999,419999999999,429999999999,439999999999,449999999999,459999999999,469999999999,479999999999,489999999999,499999999999,509999999999,519999999999,529999999999,539999999999,549999999999,559999999999,569999999999,579999999999,589999999999,599999999999,609999999999,619999999999,629999999999,639999999999,649999999999,659999999999,669999999999,679999999999,689999999999,699999999999,709999999999,719999999999,729999999999,739999999999,749999999999,759999999999,769999999999,779999999999,789999999999,799999999999,809999999999,819999999999,829999999999,839999999999,849999999999,859999999999,869999999999,879999999999,889999999999,899999999999,909999999999,919999999999,929999999999,939999999999,949999999999,959999999999,969999999999,979999999999,989999999999,999999999999,1099999999999,1199999999999,1299999999999,1399999999999,1499999999999,1599999999999,1699999999999,1799999999999,1899999999999,1999999999999,2099999999999,2199999999999,2299999999999,2399999999999,2499999999999,2599999999999,2699999999999,2799999999999,2899999999999,2999999999999,3099999999999,3199999999999,3299999999999,3399999999999,3499999999999,3599999999999,3699999999999,3799999999999,3899999999999,3999999999999,4099999999999,4199999999999,4299999999999,4399999999999,4499999999999,4599999999999,4699999999999,4799999999999,4899999999999,4999999999999,5099999999999,5199999999999,5299999999999,5399999999999,5499999999999,5599999999999,5699999999999,5799999999999,5899999999999,5999999999999,6099999999999,6199999999999,6299999999999,6399999999999,6499999999999,6599999999999,6699999999999,6799999999999,6899999999999,6999999999999,7099999999999,7199999999999,7299999999999,7399999999999,7499999999999,7599999999999,7699999999999,7799999999999,7899999999999,7999999999999,8099999999999,8199999999999,8299999999999,8399999999999,8499999999999,8599999999999,8699999999999,8799999999999,8899999999999,8999999999999,9099999999999,9199999999999,9299999999999,9399999999999,9499999999999,9599999999999,9699999999999,9799999999999,9899999999999,9999999999999,10999999999999,11999999999999,12999999999999,13999999999999,14999999999999,15999999999999,16999999999999,17999999999999,18999999999999,19999999999999,20999999999999,21999999999999,22999999999999,23999999999999,24999999999999,25999999999999,26999999999999,27999999999999,28999999999999,29999999999999,30999999999999,31999999999999,32999999999999,33999999999999,34999999999999,35999999999999,36999999999999,37999999999999,38999999999999,39999999999999,40999999999999,41999999999999,42999999999999,43999999999999,44999999999999,45999999999999,46999999999999,47999999999999,48999999999999,49999999999999,50999999999999,51999999999999,52999999999999,53999999999999,54999999999999,55999999999999,56999999999999,57999999999999,58999999999999,59999999999999,60999999999999,61999999999999,62999999999999,63999999999999,64999999999999,65999999999999,66999999999999,67999999999999,68999999999999,69999999999999,70999999999999,71999999999999,72999999999999,73999999999999,74999999999999,75999999999999,76999999999999,77999999999999,78999999999999,79999999999999,80999999999999,81999999999999,82999999999999,83999999999999,84999999999999,85999999999999,86999999999999,87999999999999,88999999999999,89999999999999,90999999999999,91999999999999,92999999999999,93999999999999,94999999999999,95999999999999,96999999999999,97999999999999,98999999999999,99999999999999,100999999999999,101999999999999,102999999999999,103999999999999,104999999999999,105999999999999,106999999999999,107999999999999,108999999999999,109999999999999,119999999999999,129999999999999,139999999999999,149999999999999,159999999999999,169999999999999,179999999999999,189999999999999,199999999999999,209999999999999,219999999999999,229999999999999,239999999999999,249999999999999,259999999999999,269999999999999,279999999999999,289999999999999,299999999999999,309999999999999,319999999999999,329999999999999,339999999999999,349999999999999,359999999999999,369999999999999,379999999999999,389999999999999,399999999999999,409999999999999,419999999999999,429999999999999,439999999999999,449999999999999,459999999999999,469999999999999,479999999999999,489999999999999,499999999999999,509999999999999,519999999999999,529999999999999,539999999999999,549999999999999,559999999999999,569999999999999,579999999999999,589999999999999,599999999999999,609999999999999,619999999999999,629999999999999,639999999999999,649999999999999,659999999999999,669999999999999,679999999999999,689999999999999,699999999999999,709999999999999,719999999999999,729999999999999,739999999999999,749999999999999,759999999999999,769999999999999,779999999999999,789999999999999,799999999999999,809999999999999,819999999999999,829999999999999,839999999999999,849999999999999,859999999999999,869999999999999,879999999999999,889999999999999,899999999999999,909999999999999,919999999999999,929999999999999,939999999999999,949999999999999,959999999999999,969999999999999,979999999999999,989999999999999,999999999999999]
k=input()
if k=="10":
  print("1\n2\n3\n4\n5\n6\n7\n8\n9\n19")
else:
  for i in range(792):
    print(ans[i])

Solution (Python):
from fractions import Fraction

def calc(a):
    return sum(map(int, list(str(a))))

def comp(a, b):
    return a * calc(b) <= b * calc(a)

MAX = 10**17
K = input()
A = set()
base = 0
front = 1
ok = True
while base < MAX:
    for i in xrange(1, 999):
        tmp = i * front + base
        if tmp <= MAX:
            A.add(tmp)
    base = base * 10 + 9
    front *= 10

A = sorted(list(A), key=lambda x: -x)
m = A[0]
ans = []

for i in xrange(1, len(A)):
    if comp(A[i], m):
        m = A[i]
        ans.append(A[i])

ans.sort()
for i in xrange(K):
    print ans[i]

Solution (Python):
def Ask(x):
    return sum(int(c) for c in str(x))

def Check(x, y):
    return x * Ask(y) > y * Ask(x)

k = int(input())
no = st = 1
for i in range(k):
    print(no)
    if (Check(no + st, no + st * 10)): st *= 10
    no += st

Solution (Python):
def Ask(x):
    ans = 0
    while (x):
        ans += x % 10
        x //= 10
    return ans

def Check(x, y):
    return x * Ask(y) > y * Ask(x)


k = int(input())
no = st = 1
while (k):
    k -= 1
    print(no)
    if (Check(no + st, no + st * 10)): st *= 10
    no += st

Solution (Python):
def s(n):
    ret=0    
    for i in range(15):
        ret+=(n%10**(i+1))//10**i
    return ret

k=int(input())
ksnk=set()

for i in range(13):
    for j in range(1,1000):
        n=int(str(j)+'9'*i)
        ksnk.add(n)
ksnk=sorted(list(ksnk), reverse=True)

fmin=float('inf')
ans=[]
for a in ksnk:
    fa=a/s(a)    
    if fa<=fmin:
        ans.append(a)
        fmin=fa
ans.reverse()
for a in ans[:k]:
    print(a)

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    k = f.read_int()

    a = 1
    ans = []
    for n in xrange(1,16):
        ans2 = []
        ma = 0
        nine = float('inf')
        for i in xrange(10**a-1,10**(a-1)-1,-1):
            si = str(i) + '9'*(n-a)
            sn = sum(map(int, list(si)))*1.0/int(si)
            if sn >= ma:
                j = n
                while j > 0 and si[j-1] == '9': j -= 1
                nine = min(n-j, nine)
                ans2.append(si)
                ma = sn
        a = n-nine+1
        ans += ans2[::-1]

    return "\n".join(ans[:k])


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Solution (Python):
K = int(input())

def S(n):
    return sum(int(c) for c in str(n))

n9 = 0  

count = 0
upper = 1
while count < K:
    n = int(str(upper) + ('9' * n9))
    if n <= S(n) * (10 ** n9):
        print(n)
        count += 1
        upper += 1
    else:
        n9 += 1
        upper //= 10

Solution (Python):
LEN = 0

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

LEN +=1

for i in range(1,10): SNK.append(i*10+9)

LEN +=1



LEN +=1

for loop in range(2):
    SNK_sub = list(range(pow(10,loop),pow(10,loop+1)))
    SNK += list(map(lambda x:(x*pow(10,LEN-1))+(pow(10,LEN-1)-1),SNK_sub))
    LEN += len(str(max(SNK_sub)))-1
    for d in SNK_sub: 
        SNK += [(i*pow(10,LEN-1))+(pow(10,LEN-1)-1) for i in range(10,10*(d+1))]
        SNK += list(map(lambda x:(x*pow(10,LEN))+(pow(10,LEN)-1),SNK_sub[SNK_sub.index(d)+1:]))
        
        LEN += 1+loop
        if LEN>20:break

print("\n".join(str(i) for i in SNK[:int(input())]))

Solution (Python):
K = int(input())
S = lambda n: sum(map(int,str(n)))
R = lambda n: n/S(n)

arr = []
for i in range(1,200):
    for j in range(1,15):
        arr.append(int(str(i) + '9'*j))

arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
    r = R(a)
    if r < min_r:
        min_r = r
        snukes.append(a)

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

print(*snukes[:-K-1:-1],sep='\n')

Solution (Python):
K = int(input())
S = lambda n: sum(map(int,str(n)))
R = lambda n: n/S(n)

arr = []
for i in range(1,1000):
    for j in range(1,15):
        arr.append(int(str(i) + '9'*j))

arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
    r = R(a)
    if r < min_r:
        min_r = r
        snukes.append(a)

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

print(*snukes[:-K-1:-1],sep='\n')

Solution (Python):
K = int(input())
S = lambda n: sum(map(int,str(n)))
R = lambda n: n/S(n)

arr = []
for i in range(1,10000):
    for j in range(1,15):
        arr.append(int(str(i) + '9'*j))

arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
    r = R(a)
    if r < min_r:
        min_r = r
        snukes.append(a)

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

print(*snukes[:-K-1:-1],sep='\n')

Solution (Python):
def sunuke_sum(arg):
    sum_digit = 0
    for char in arg:
        sum_digit += int(char)
    return sum_digit


input_num = int(input())

sunuke_dict = {}

min_sunuke_div = 10 ** 20
for d in reversed(range(1, 16)):
    for n in reversed(range(10, 1000)):
        i = n * (10 ** d) + (10 ** d - 1)
        sunuke_div = i / sunuke_sum(str(i))
        sunuke_dict[i] = sunuke_div

for i in reversed(range(1, 101)):
    sunuke_div = i / sunuke_sum(str(i))
    sunuke_dict[i] = sunuke_div

sunuke_sorted = sorted(sunuke_dict.items())
sunuke_list = []

for value, div_value in reversed(sunuke_sorted):
    if min_sunuke_div >= div_value:
        sunuke_list.append(value)
        min_sunuke_div = div_value

sunuke_list.reverse()

for i in range(0, input_num):
    print(str(sunuke_list[i]))

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
x=[]
k=i1()
for s in range(1,10):
 x.append([s/sum(list(map(int, list(str(s))))),s])

for i in range(1,1000):
 for j in range(1,15):
   s=10**j*i+10**j-1
   x.append([s/sum(list(map(int, list(str(s))))),s])

y=sorted(x)
m=0
n=0
for i,j in y:
  if n>k-1:
     break
  if j>10**15:
     break
  if j>m:
     m=j
     print(j)
     n+=1

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

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

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

def f(N):
    maxd = math.ceil(math.log(N,10)) + 1
    minScr = 10**15
    ret = 0
    for d in range(maxd):
        x = (10**(d)) * (N // (10**(d)) + 1) - 1
        s = scr(x)
        if minScr > s:
            minScr = s
            ret = x
    return ret

N = 0
for i in range(K):
    N = f(N + 1)
    print(N)

Solution (Python):



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 T(k):
    orig_k = k
    sk = 0
    while k > 0:
        sk += k % 10
        k //= 10
    return orig_k / sk

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

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




mn = None
ans = []
for k in reversed(keys):
    if mn == None:
        ans.append(k)
        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)

Solution (Python):



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 T(k):
    orig_k = k
    sk = 0
    while k > 0:
        sk += k % 10
        k //= 10
    return orig_k / sk

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

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




mn = None
ans = []
for k in reversed(keys):
    if mn == None:
        ans.append(k)
        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)

Solution (Python):



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 T(k):
    orig_k = k
    sk = 0
    while k > 0:
        sk += k % 10
        k //= 10
    return orig_k / sk

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()))




mn = None
ans = []
for k in reversed(keys):
    if mn == None:
        ans.append(k)
        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)

Solution (Python):
import sys
K=int(input())
L=[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]
L=set(L)
for i in range(17):
    for j in range(i*10):
        L.add(pow(10,i) * j + pow(10,i)-1)
L=list(L)
L.sort()
def f(k):
    a=0
    s=k
    while s>0:
        a+=(s %10)
        s=(s - s%10)//10
    return k/a
kou=[]
i=0
while i<len(L):
    flag = True
    for j in range(i+1,len(L)):
        if f(L[i])>f(L[j]):
            flag = False
            break
    if flag:
        kou.append(L[i])
    i +=1
ans=kou[:K]
print('\n'.join(map(str,ans)))

Solution (Python):
K = int(input())

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

num = min(K, 8)
for n in range(1, num + 1):
    print(n)

d = 10
n = 10
Sn = S(10 - 1)
while num < K:
    for j in range(100):
        Snext = S(n + d - 1)
        if Snext < Sn: break

        print(n - 1)
        num += 1
        if num == K: break

        n += d
        Sn = Snext

    d *= 10
    n = (n // d + 1) * d