TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
k = int(input())

def func(a):
    s = 0
    for i in str(a):
        s += int(i)
    return a/s

candidate_lst = []
for i in range(18):
    for j in range(1, 150):
         candidate_lst.append(int(str(j) + '9' * i))
candidate_lst = sorted(candidate_lst)

count = 0
index = -1
snuke = 1
while count < k:
    min_snuke = 10**100
    for m, i in enumerate(candidate_lst[index+1:]):
        if i > 100*snuke:
            break
        po_snuke = func(i)
        if min_snuke > po_snuke:
            min_snuke = po_snuke
            next_snuke = i
            next_index = m
    print(next_snuke)
    snuke = next_snuke
    index = index + next_index + 2
    count += 1          

k = int(input())

def func(a):
    s = 0
    for i in str(a):
        s += int(i)
    return a/s

candidate_lst = []
for i in range(18):
    for j in range(1, 150):
         candidate_lst.append(int(str(j) + '9' * i))
candidate_lst = sorted(list(set(candidate_lst)))

count = 0
index = -1
snuke = 1
while count < k:
    min_snuke = 10**100
    for m, i in enumerate(candidate_lst[index+1:]):
        if i > 100*snuke:
            break
        po_snuke = func(i)
        if min_snuke > po_snuke:
            min_snuke = po_snuke
            next_snuke = i
            next_index = m
    print(next_snuke)
    snuke = next_snuke
    index = index + next_index + 1
    count += 1          

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
K=int(input())
k=0
m=0
def D(x):
  s=str(x)
  array=list(map(int,list(s)))
  return sum(array)
N=1
S=1
a=0
print(N)
while k<=K:
  N+=10**a
  S=D(N)
  if a<math.log10(N/S):
    a+=1
    N=(N//10**a+1)*10**a-1 
  S=D(N)
  print(N)
  k+=1
    
    


import math
K=int(input())
k=2
m=0
def D(x):
  s=str(x)
  array=list(map(int,list(s)))
  return sum(array)
N=1
S=1
a=0
print(1)
while k<=K:
  N+=10**a
  S=D(N)
  if a<math.log10(N/S):
    a+=1
    N=(N//10**a+1)*10**a-1
  S=D(N)
  print(N)
  k+=1
    
    


Verdicts: Wrong Answer

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

Submission attempts (in order):
N = int(input())
M = N//10
k = N%10
d=0
for j in range (M):
    for i in range(2,11):
        print(i*10**d-1)
    d += 1 
if k != 0:
    for i in range(2,2+k):
        print(i*10**d-1)

def R(x):
    return x / sum(map(int, str(x)))
K = int(input())
D = 0
l = 0
for i in range(K):
    D += 10**l
    print(D)
    if 10**l < R(D+10**l):
        l += 1

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math

def s(n):
    ret = 0

    while n > 0:
        ret += n % 10
        n = n // 10
        
    return ret

def snuke(n):
    candidate = []

    for d in range(int(math.log(n, 10)) + 2):
        x = n - (n % 10**d) + (10**d - 1)
        candidate.append(x)
    
    min_value = candidate[0] / s(candidate[0])
    ans = candidate[0]
    for c in candidate[1:]:
        tmp = c / s(c)
        if tmp < min_value:
            min_value = tmp
            ans = c
            
    return ans

print(snuke(10248))
        

import math

def s(n):
    ret = 0

    while n > 0:
        ret += n % 10
        n = n // 10
        
    return ret

def snuke(n):
    candidate = []

    for d in range(int(math.log(n, 10)) + 2):
        x = n - (n % 10**d) + (10**d - 1)
        candidate.append(x)
    
    min_value = candidate[0] / s(candidate[0])
    ans = candidate[0]
    for c in candidate[1:]:
        tmp = c / s(c)
        if tmp < min_value:
            min_value = tmp
            ans = c
            
    return ans

K = int(input())

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

Verdicts: Wrong Answer

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

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

def isSunuke(n):
	for m in range(n+1, n * 100):
		if (n / s(n)) > (m / s(m)):
			return False
	return True

k = int(input())
found=0
n = 1
while(found < k):
	sn = str(n)
	length = len(sn)
	nines = 0
	for c in sn:
		if c == "9":
			nines += 1
	if nines < length / 2:
		n += 1
		continue
	if isSunuke(n):
		print(n)
		found+=1
	n += 1

import math


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

	log_n = int(math.log(n,10))
	m = n - 10 ** int(log_n // 1.25)

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

		if (s_m < s_mplus1 or (s_n - s_m != 1 and s_n - s_m != -8 and s_n - s_m != -17)) and m > 9:
			m -= 10 ** int(log_n // 1.25)
			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:d}".format(m), "{0:+d}".format(n-m), "{0:d}".format(s_m), s_m_div)
			print(m)
			break


		m -= 10 ** int(log_n // 1.25)



current_sunuke = 999999999999999
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)
if found < k:
	print(current_sunuke)
# end = datetime.datetime.now()
# print(str(end-start))


Verdicts: Wrong Answer

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

Submission attempts (in order):
from math import log10 as l
s=lambda f:sum(map(int,list(str(f))))
p=lambda a,j:(a//10**(j+1)+1)*10**(j+1)-1
n=int(input())
a=1
for i in range(n):
  print(a)
  if(a<10):
    a+=1
    continue
  a+=1
  k=[p(a,j) for j in range(int(l(a)))]
  o=[p(a,j)/s(p(a,j)) for j in range(int(l(a)))]
  a=k[o.index(min(o))]

from math import log10 as l
s=lambda f:sum(map(int,list(str(f))))
p=lambda a,j:(a//10**(j+1)+1)*10**(j+1)-1
n=int(input())
a=1
for i in range(n):
  print(a)
  if(a<9):
    a+=1
    continue
  a+=1
  k=[p(a,j) for j in range(int(l(a)))]
  o=[p(a,j)/s(p(a,j)) for j in range(int(l(a)))]
  a=k[o.index(min(o))]

Verdicts: Wrong Answer

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

Submission attempts (in order):
# coding: utf-8
# Your code here!
k = int(input())
k = 100
count = 0
ans = []
minN = 10**15

for i in reversed(range(5)):
    for j in reversed(range(1,10**4)):
        num = str(j)+"9"*i*3
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(num == "379999"):
            print("tes")
        if(minN > n or n==1):
            minN = n
            ans.append(num)

print(len(ans[0]),len(ans))

for i in list(reversed(ans))[:k]:
    print(i)

# coding: utf-8
# Your code here!
k = int(input())

count = 0
ans = []
minN = 10**15

for i in reversed(range(12)):
    for j in reversed(range(1,10**4)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(num)
            
            
print(len(ans[0]))
for i in list(reversed(ans))[:k]:
    print(i)

# coding: utf-8
# Your code here!
k = int(input())
k = 100
count = 0
ans = []
minN = 10**15

for i in reversed(range(5)):
    for j in reversed(range(1,10**4)):
        num = str(j)+"9"*i*3
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(num)

for i in list(reversed(ans))[:k]:
    print(i)

# coding: utf-8
# Your code here!
k = int(input())

count = 0
ans = []
minN = 10**15

for i in reversed(range(15)):
    for j in reversed(range(1,100)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n):
            minN = n
            ans.append(num)
            
for i in list(reversed(ans))[:k]:
    print(i)

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

# coding: utf-8
# Your code here!
k = int(input())

count = 0
ans = []
minN = 10**15

for i in reversed(range(10)):
    for j in reversed(range(1,10**5)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(num)

print(len(ans[0]))
for i in list(reversed(ans))[:k]:
    print(i)

# coding: utf-8
# Your code here!
k = int(input())
count = 0
ans = []
minN = 10**15

for i in reversed(range(13)):
    minN = 10**15
    for j in reversed(range(1,10**3)):
        num = str(j)+"9"*i
        n = sum([int(k) for k in num])
        n = int(num)/n
        if(minN > n or n==1):
            minN = n
            ans.append(int(num))

for i in list(sorted(list(set(ans))))[:k]:
    print(i)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Time Limit Exceeded

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

Submission attempts (in order):
import sys 

K = int(input())

if K <= 0:
    sys.exit(0)

step = 1 
snuke = 1 

while K >= 0:
    if step < snuke/sum(map(int, str(snuke))):
        snuke += 9 * step
        step *= 10
    else:
        print(snuke)
        snuke += step
        K -= 1

import sys 

K = int(input())

if K <= 0:
    sys.exit(0)

step = 1 
snuke = 1 

while K > 0:
    if step < snuke/sum(map(int, str(snuke))):
        snuke += 9 * step
        step *= 10
    else:
        print(snuke)
        snuke += step
        K -= 1

Verdicts: Wrong Answer

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

Submission attempts (in order):
K = int(input())

if K < 10:
    num_list = [i for i in range(1, K+1)]
    print(*num_list, sep='\n')
else:
    num_list = [i for i in range(1, 10)]
    n = 19
    digits = 2
    while len(num_list) < K:
        num_list.append(n)
        if str(n+1)[0] > 3:
            digits += 1
        n += 10**(digits - 1)
    print(*num_list, sep='\n')

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


Verdicts: Runtime Error

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

Submission attempts (in order):
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np
from operator import itemgetter

k =int(input())
nmax=0
s = []
for i in range(1,200):
    for j in range(14):
        p = i
        for ii in range(j):
            p=p*10+9
        q = i // 100 + (i // 10) % 10 + i % 10 + 9*j
        r = p / q

        s.append((p,q,r))

s= sorted( s, key=itemgetter(2) )
print(s)
num=0
for a in s :
    if a[0] > nmax:
        nmax = a[0]
        print(nmax)
        num += 1
        if num >= k :
            break 
    


# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np
from operator import itemgetter

k =int(input())
nmax=0
s = []
for i in range(1,200):
    for j in range(14):
        p = i
        for ii in range(j):
            p=p*10+9
        q = i // 100 + (i // 10) % 10 + i % 10 + 9*j
        r = p / q

        s.append((p,q,r))

s= sorted( s, key=itemgetter(2) )
#print(s)
num=0
for a in s :
    if a[0] > nmax:
        nmax = a[0]
        print(nmax)
        num += 1
        if num >= k :
            break 
    


Verdicts: Wrong Answer

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

Submission attempts (in order):

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




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




K=int(input())
keta=1
now=1
count=0

def sunuke(n):
    a=0
    for i in str(n):
        a+=int(i)
    return(n/a)

while count < K:
    if sunuke(now) <= sunuke(now+keta):
        print(now)
        now+=keta
        count+=1
    else:
        now+=9*keta
        keta*=10



Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
from itertools import chain, count, islice

def f():
    j = int(input())
    cs = '123456789'
    xs = ['123456789', (c+'9' for c in cs)] 
    for x in chain(*xs):
        if j == 0: return
        yield x
        j -= 1

    for i in count(2):
        for n in range(i-1, i*10-1):
            if j == 0: return
            yield str(n)+('9'*i)
            j -= 1

z = list(f())

from math import log, floor
from itertools import accumulate, chain, islice, repeat
 
k = int(input())
 
def f(n):
    ds = range(int(log(n+1, 10))+1)
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=lambda n:n / sum(map(int, str(n))))
 
snukes = chain(range(1, 9), accumulate(repeat(9), lambda x,_:f(x+1)))
 
for x in islice(snukes, k):
    print(x)

Verdicts: Wrong Answer

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

Submission attempts (in order):
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()

import sys

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


def f(n):
  d = 0
  C = [n]
  while S(n) > (10**d / 9*(d+1)):
    c = 10**(d+1) * (n // 10**(d+1) + 1) - 1
    C.append(c)
    d += 1
  Smin = float('inf')
  res = 0
  for c in C:
    if S(c) < Smin:
      Smin = S(c)
      res = c  
  return res


def main():
  input = sys.stdin.readline
  K = int(input())
  ans = 1
  for _ in range(K):
    print(ans)
    ans = f(ans+1)


if __name__ == '__main__':
  main()

Verdicts: Runtime Error

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

Submission attempts (in order):
K=int(input())
for i in range(1,K):
    if i<=9:
        print(i)
    elif i%10==0:
        pass
    elif i<=19:
        a=(i-10)*10+9
        print(a)
    elif i<=29:
        a=(i-20)*100+99
        print(a)
    elif i<=39:
        a=(i-30)*1000+999
        print(a)
    elif i<=49:
        a=(i-40)*10000+9999
        print(a)
    elif i<=59:
        a=(i-50)*100000+99999
        print(a)
    elif i<=69:
        a=(i-60)*1000000+999999
        print(a)
    elif i<=79:
        a=(i-70)*10000000+9999999
        print(a)
    elif i<=89:
        a=(i-80)*100000000+99999999
        print(a)
    elif i<=99:
        a=(i-90)*1000000000+999999999
        print(a)
    elif i<=109:
        a=(i-100)*10000000000+9999999999
        print(a)
    elif i<=119:
        a=(i-110)*100000000000+99999999999
        print(a)
    elif i<=129:
        a=(i-120)*1000000000000+999999999999
        print(a)
    elif i<=139:
        a=(i-130)*10000000000000+9999999999999
        print(a)
    elif i<=149:
        a=(i-140)*100000000000000+99999999999999
        print(a)
    elif i<=159:
        a=(i-150)*1000000000000000+999999999999999
        print(a)

K=int(input())
D={}
for i in range(1,10**4):
    for j in range(12):
        Sunuke=str(i)+("9"*j)
        if len(Sunuke)<=15 and Sunuke not in D:
            S=0
            for k in range(len(Sunuke)):
                S+=int(Sunuke[k])
            D[int(Sunuke)]=S
D=list(D.items())
D.sort()
#print(D[:10])
import bisect

d=[10**16 for i in range(len(D))]
d[0]=0
ans=[0 for i in range(len(D))]
for i in range(len(D)):
    ans[bisect.bisect_right(d,D[i][0]/D[i][1])]=D[i][0]
    d[bisect.bisect_right(d,D[i][0]/D[i][1])]=D[i][0]/D[i][1]
    
#print(ans[:50])
ANS=[]
MAX=0
for i in range(len(ans)):
    if ans[i]>MAX:
        ANS.append(ans[i])
        MAX=ans[i]
#print(ANS[:100])
for i in range(K):
    print(ANS[i])
#print(d[:10])

Verdicts: Wrong Answer

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

Submission attempts (in order):
k = int(input())

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

l = 1

while len(s) <= k:
    for i in range(1, 11):
        s.append((10 ** l) * i - 1)
        if len(s) > k:
            break
    l += 1


for i in s:
    print(i)

k = int(input())

a = 1
b = 1

def snk(n):
    s = 0
    for i in str(n):
        s += int(i)
    return n / s

for _ in range(k):
    print(a)
    if snk(a + 10 ** (b -1)) > snk(a + 10 ** b):
        b += 1
    a += 10 ** (b-1)


Verdicts: Wrong Answer

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

Submission attempts (in order):
k = int(input())
if k < 10:
    print(k)
    exit()

print(9 + (k-9)*10)


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

print((k-8)*10-1)


#     return sum(list(map(int, str(n))))
#
# l = []

#     l.append([i, s(i), i/s(i)])
#
# l.sort(key=lambda x:x[2])

#     print(l[i])
#
# max = 0

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


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(2, 9)]
for i in range(16):
    for j in range(1, 10):
        for k in range(10):
            seeds.append((k + j*10) * 10**i)

# print(seeds)

seeds = list(map(lambda x:x-1, seeds))

l = []
for i in seeds:
    l.append([i, s(i), i/s(i)])
#
l.sort(key=lambda x:x[2])

#     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=" ")

print(ans[k-1])

# max = 0

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


k = int(input())

#     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)])


#     l.append([i, s(i), i/s(i)])


l.sort(key=lambda x:x[2])

#     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

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
# /user/bin/python
# -*- coding: utf-8 -*-
import sys


k = int(input())
step = ret = 1
for _ in range(k):
  if step < ret / sum(map(int, list(str(ret)))):
    ret += 9*step
    step *= 10
  else:
    print(ret)
    ret += step


# /user/bin/python
# -*- coding: utf-8 -*-

t = i = 1
k = int(input()) 

for _ in range(k):
  if t < i / sum(map(int, list(str(i)))):
    i += 9 * t
    t *= 10
  else:
    print(i)
    i += t


t = i = 1
k = int(input()) 
while k:
  if t < i / sum(map(int, list(str(i)))):
    i += 9 * t
    t *= 10
  else:
    print(i)
    i += t
    k -= 1


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
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])


K = int(input())


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


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

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


Verdicts: Runtime Error

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

Submission attempts (in order):
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)
    elif digit==15:
        for i in range(101,110):
            res.append(i*10**(digit-3)-1)
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
    else:
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
print(res)


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)
    elif digit==15:
        for i in range(101,110):
            res.append(i*10**(digit-3)-1)
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
    else:
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
for i in range(int(input())):
    print(res[i])


Verdicts: Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))

if N == K:
    print(1)
    sys.exit()

print((N-K)//(K-1)+1)


import sys
from math import ceil

N, K = map(int, input().split())
A = list(map(int, input().split()))

if N == K:
    print(1)
    sys.exit()

print(ceil((N-K)/(K-1))+1)


Verdicts: Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
n,k=map(int,input().split())
h=[]
for i in range(n):
    h.append(int(input()))
h.sort()

ans=9999999999999
for i in range(n-k+1):
    ans=min(ans,h[i+k-1]-h[i])
print(ans)

n,k=map(int,input().split())
a=list(map(int,input().split()))
print(-(-(n-1)//(k-1)))


Verdicts: Runtime Error

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import sys

input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))

pos = A.index(1)
print(pos)
ans = 0
left = pos
while 0 < left:
    left -= K - 1
    ans += 1
right = pos
while right < N - 1:
    right += K - 1
    ans += 1

print(ans)

import sys

input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))

print((N-2) // (K-1) + 1)

Verdicts: Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
def sunuke_sum(arg):
    sum_digit = 0
    for char in arg:
        sum_digit += int(char)
    return sum_digit


input_num = int(input())

sunuke_list = []
min_sunuke_div = 10 ** 20
for d in reversed(range(1, 16)):
    for n in reversed(range(10, 100)):
        i = n * (10 ** d) + (10 ** d - 1)
        sunuke_div = i / sunuke_sum(str(i))
        if min_sunuke_div >= sunuke_div:
            sunuke_list.append(i)
            min_sunuke_div = sunuke_div

for i in reversed(range(1, 101)):
    sunuke_div = i / sunuke_sum(str(i))
    if min_sunuke_div >= sunuke_div:
        sunuke_list.append(i)
        min_sunuke_div = sunuke_div

sunuke_list.reverse()

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


input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input()
array_str = input_line.split()

array = list(map(int, array_str))

for index, number in enumerate(array):
    if number == 1:
        index_min = index
        break

# from forward

equalized = 1
i = 1
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(i - 1)


Verdicts: Runtime Error

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
N,K=map(int,input().split())
print(-(1-N)//(K-1))


N,K=map(int,input().split())
if N-1%(K-1):
    n=0
else:
    n=1
print((N-1)//(K-1)+n)


N,K=map(int,input().split())
print(-((1-N)//(K-1)))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    if n<=k:
        print(1)
    else:

        while True:
            n-=k
            n+=1
            cnt+=1
            if n<=k:
                cnt+=1
                print(cnt)
                break
reso

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    while True:
        if n<=k:
            cnt+=1
            print(cnt)
            break
        n -= k
        n += 1
        cnt += 1
resolve()

Verdicts: Runtime Error

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import math

N,K=map(int, inp[0].split())  
A=list(map(int, inp[0].split()))  


if N==K:
    print(1)
else:
    print(math.ceil((N-1)/(K-1)))


import math

N,K=map(int, input().split())  
A=list(map(int, input().split()))  


if N==K:
    print(1)
else:
    print(math.ceil((N-1)/(K-1)))


Verdicts: Runtime Error

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import sys
import os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

    print(-(-(N-K)//(K-1)))

if __name__ == '__main__':
    main()


import sys
import os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

    print(-(-N//(K-1))

if __name__ == '__main__':
    main()


import sys
import os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

    print(-(-(N-K)//(K-1))+1)

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in range(n):
  if a[i]==1:
    s+=(i+1)
    break

if s%k!=0 and n%k!=0:
  print(n//k+1)
elif s%k!=0 and n%k==0:
  print(n//k)
else:
  print(n//k+2)



n,k=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in range(n):
  if a[i]==1:
    s+=(i+1)
    break

if s%k!=0 and n%k!=0:
  print(n//k+1)
elif s%k!=0 and n%k==0:
  print(n//k)
elif s%k==0 and n%k==0:
  print(n//k+1)
else:
  print(n//k+2)


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    cnt = 1
    field = K
    for i in range(N):
        if field >= N:
            break
        field += K-1
        cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
print(math.floor(N/K))

N,K=map(int,input().split())
A=list(map(int,input().split()))
print((N-1)/(K-1))


N,K=map(int,input().split())
A=list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))

import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
from math import ceil

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n <= k:
    print(1)
    exit()
res = 0

range_left = array.index(1)
range_right = n - range_left - 1
print(range_left, range_right)

k -= 1
if range_left == 0:
    res += ceil(range_right / k)
    print(res)
    exit()
elif range_right == 0:
    res += ceil(range_left / k)
    print(res)
    exit()

if range_left <= k:
    res += 1
    range_right -= (k - range_left)
    res += ceil(range_right / k)
else:
    res += ceil(range_left / k)
    tmp = 0
    while tmp < range_left:
        tmp += k
    range_right -= tmp % range_left
    res += ceil(range_right / k)
print(res)


import math

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

tmp = array.index(1)

if tmp == 0:
    res1 = 0
    res2 = math.ceil((n-1)/(k-1))
elif tmp == n-1:
    res1 = math.ceil((n-1)/(k-1))
    res2 = 0
else:
    res1 = math.ceil((tmp)/(k-1))
    res2 = math.ceil((n-tmp-1)/(k-1))

print(res1,res2)


from math import ceil

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n <= k:
    print(1)
    exit()
res = 0

range_left = array.index(1)
range_right = n - range_left - 1

k -= 1
if range_left == 0:
    res += ceil(range_right / k)
    print(res)
    exit()
elif range_right == 0:
    res += ceil(range_left / k)
    print(res)
    exit()

if range_left <= k:
    res += 1
    range_right -= (k - range_left)
    res += ceil(range_right / k)
else:
    res += ceil(range_left / k)
    tmp = 0
    while tmp < range_left:
        tmp += k
    range_right -= tmp % range_left
    res += ceil(range_right / k)
print(res)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import math
N, K = map(int, input().split())
A = input().split()
t = A.index("1")
print(t)
if (N - 1) % (K - 1) == 0 and t % (K - 1) == 0 and t != 0 and t != N - 1 and K != 2:
  print(math.ceil((N - 1)/(K - 1)) + 1)
  print(1)
else:
  print(math.ceil((N - 1)/(K - 1)))

import math
N, K = map(int, input().split())
A = input().split()
t = A.index("1")
if (N - 1) % (K - 1) == 0 and t % (K - 1) == 0 and t != 0 and t != N - 1 and K != 2:
  print(math.ceil((N - 1)/(K - 1)) + 1)
else:
  print(math.ceil((N - 1)/(K - 1)))


Verdicts: Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import numpy as np
from math import ceil

N, K = tuple(map(int, input().split()))
A = np.array([int(x) for x in input().split()])

I = np.argmin(A)
D = min(N - I, I) - 1
C = K - 1
small_part = ceil(D / C)
rem = C * small_part - D

print(small_part + ceil((N - rem) / C))

import numpy as np
from math import ceil

N, K = tuple(map(int, input().split()))
A = np.array([int(x) for x in input().split()])

I = np.argmin(A)
D = min(N - I, I)
C = K - 1
small_part = ceil(D / C)
rem = C * small_part - D

print(small_part + ceil((N - rem) / C))

import numpy as np
from math import ceil

N, K = tuple(map(int, input().split()))
A = np.array([int(x) for x in input().split()])

I = np.argmin(A)
D = max(1, min(N - I, I) - 1)
C = K - 1
small_part = ceil(D / C)
done = C * small_part + 1

print(small_part + ceil((N - done) / C))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
N, K = map(int,input().split())
print((N-1)//(K-1))

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

Verdicts: Wrong Answer

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
n,k,*_=open(0);print(((int(n)-2)//(int(k)-1))+1)

n,k=map(int,input().split())
a=list(map(int,input().split()))
print((n-2)//(k-1)+1)

Verdicts: Runtime Error

Accepted
Problem: There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.  On this sequence, Snuke can perform the following operation:    * Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.  Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

Submission attempts (in order):
import numpy as np
print(0)

def ii():
    return int(input())


def lii():
    return list(map(int, input().split(' ')))


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


def main():
    N, K = lii()
    a = lii()
    min_ix = None
    for i, v in enumerate(a):
        if v == 1:
            min_ix = i
            break

    def t(n, k):
        if n <= 0: return 0, 0

        ans = n // k
        if n % k:
            ans += 1
        return ans, n % k

    if N-1 - min_ix >= K-1 and min_ix >= K-1:
        ans1, p1 = t(min_ix, K-1)
        ans2, p2 = t(N-1 - min_ix, K-1)
        ans = ans1 + ans2
        if p1 > 0 and p2 > 0 and p1 + p2 <= K-1:
            ans -= 1
        return ans

    elif min_ix < K-1:
        d = K-1 - min_ix
        ans, _ = t(N-1 - min_ix - d, K-1)
        return 1 + ans

    elif N-1 - min_ix < K-1:
        d = K-1 - (N-1 - min_ix)
        ans, _ = t(min_ix - d, K-1)
        return ans + 1


if __name__ == '__main__':
    print(main())

Verdicts: Wrong Answer

Accepted