Buggy python submission (verdict: Time Limit Exceeded):
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    se = [(s, e) for s, e in zip(start, end)]
    ans = 10**6
    for s, e in se:
        ans = min(ans, math.ceil(len(a[:s])/(k-1)) + math.ceil(len(a[e+1:])/(k-1)))

    print(ans+1)

main()

Fixed submission:
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(s/(k-1)) + math.ceil((n-(e+1))/(k-1)))

    print(ans+1)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(len(a[:s])/(k-1)) + math.ceil(len(a[e+1:])/(k-1)))

    print(ans+1)

main()


Fixed submission:
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(s/(k-1)) + math.ceil((n-(e+1))/(k-1)))

    print(ans+1)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = sorted([min_ind - x for x in range(k) if min_ind - x >= 0])
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(len(a[:s])/(k-1)) + math.ceil(len(a[e+1:])/(k-1)))

    print(ans+1)

main()

Fixed submission:
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(s/(k-1)) + math.ceil((n-(e+1))/(k-1)))

    print(ans+1)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

min_ind = a.index(min(a))

start = sorted([min_ind - x for x in range(k) if min_ind - x >= 0])
end = [s+k-1 for s in start]

ans = 10**6
for s, e in zip(start, end):
    ans = min(ans, math.ceil(len(a[:s])/(k-1)) + math.ceil(len(a[e+1:])/(k-1)))

print(ans+1)

Fixed submission:
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(s/(k-1)) + math.ceil((n-(e+1))/(k-1)))

    print(ans+1)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

min_ind = a.index(min(a))

start = sorted([min_ind - x for x in range(k) if min_ind - x >= 0])
end = [s+k-1 for s in start]

ans = 10**6
for s, e in zip(start, end):
    ans = min(ans, math.ceil(len(a[:s])/(k-1)) + math.ceil(len(a[e+1:])/(k-1)))

print(ans+1)


Fixed submission:
import math

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    min_ind = a.index(min(a))

    start = [min_ind - x for x in range(k) if min_ind - x >= 0]
    end = [s+k-1 for s in start]

    ans = 10**6
    for s, e in zip(start, end):
        ans = min(ans, math.ceil(s/(k-1)) + math.ceil((n-(e+1))/(k-1)))

    print(ans+1)

main()