Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    count_bus = 0
    L = len(T)

    i = 0
    while i < L:
        # print('T[{}]: {}'.format(i, T[i]))
        t = T[i]
        for j in range(1, C):
            if i+j >= L:
                i += j
                count_bus += 1
                break

            if T[i+j] <= t + K:
                pass
                if j == C-1:
                    i += j + 1
                    count_bus += 1
                    break

            else:
                count_bus += 1
                i += j
                break

    print(count_bus)


if __name__ == '__main__':
    resolve()

Fixed submission:
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

# print(T)

bus = 1
org = T[0]
_count = 0

for t in T:

    if t - org <= K and _count < C:
        _count += 1
        # print('1- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))
    else:
        bus += 1
        org = t
        _count = 1
        # print('2- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))

print(bus)

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    
    count_bus = 0
    
    i = 0
    while i < len(T):
        # print('T[{}]: {}'.format(i, T[i]))
        t = T[i]
        for j in range(1, C):
            if i+j >= len(T):
                i += j
                count_bus += 1
                break
    
            if T[i+j] <= t + K:
                pass
                if j == C-1:
                    i += j + 1
                    count_bus += 1
                    break
    
            else:
                count_bus += 1
                i += j
                break
    
    print(count_bus)


if __name__ == '__main__':
    resolve()

Fixed submission:
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

# print(T)

bus = 1
org = T[0]
_count = 0

for t in T:

    if t - org <= K and _count < C:
        _count += 1
        # print('1- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))
    else:
        bus += 1
        org = t
        _count = 1
        # print('2- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))

print(bus)

Buggy python submission (verdict: Time Limit Exceeded):
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
count_bus = 0

i = 0
while i < len(T):
    t = T[i]
    for j in range(1, C):
        if i+j >= len(T):
            i += j
            count_bus += 1
            break
        if T[i+j] <= t + K:
            pass
            if j == C-1:
                i += j + 1
                count_bus += 1
                break
        else:
            count_bus += 1
            i += j
            break

print(count_bus)

Fixed submission:
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

# print(T)

bus = 1
org = T[0]
_count = 0

for t in T:

    if t - org <= K and _count < C:
        _count += 1
        # print('1- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))
    else:
        bus += 1
        org = t
        _count = 1
        # print('2- t:{}, org:{}, _count:{}, bus:{}'.format(t, org, _count, bus))

print(bus)