Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
min = n
range_value = one_index if k > one_index else k
for i in range(range_value+1):
    left = one_index - k + i + 1
    right = len(nums[one_index+1:]) - i
    if left + right > n-1:
        break
    else:
        min_tmp = (-(-left//(k-1)))+(-(-right//(k-1)))+1
        if min > min_tmp:
            min = min_tmp
print(min)


Fixed submission:
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
if k == len(nums):
    print(1)
else:
    print(math.ceil((n-1)/(k-1)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
min = n
for i in range(k):
    left = one_index - i
    right = len(nums[one_index+1:]) + i
    if left + right > n-1:
        continue
    else:
        min_tmp = (-(-left//(k-1)))+(-(-right//(k-1)))
        if min > min_tmp:
            min = min_tmp
print(min)


Fixed submission:
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
if k == len(nums):
    print(1)
else:
    print(math.ceil((n-1)/(k-1)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
min = n
for i in range(k):
    left = one_index - i
    right = len(nums[one_index+1:]) + i
    if left + right > n-1:
        continue
    else:
        min_tmp = math.ceil(left/(k-1))+math.ceil(right/(k-1))
        if min > min_tmp:
            min = min_tmp
print(min)


Fixed submission:
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
if k == len(nums):
    print(1)
else:
    print(math.ceil((n-1)/(k-1)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
min = n
for i in range(k):
    left = one_index - i
    right = len(nums[one_index+1:]) + i
    if left < 0 or right < 0:
        continue
    else:
        min_tmp = math.ceil(left/(k-1))+math.ceil(right/(k-1))
        if min > min_tmp:
            min = min_tmp
print(min)


Fixed submission:
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
if k == len(nums):
    print(1)
else:
    print(math.ceil((n-1)/(k-1)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
result = []
for i in range(k):
    left = one_index - i
    right = len(nums[one_index+1:]) + i
    if left < 0 or right < 0:
        continue
    else:
        result.append(math.ceil(left/(k-1))+math.ceil(right/(k-1)))
print(min(result))


Fixed submission:
# -*- coding:utf-8 -*-
import math
n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
one_index = nums.index(1)
if k == len(nums):
    print(1)
else:
    print(math.ceil((n-1)/(k-1)))