qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a,b,c=map(int,input().split())
l=sorted([int(input()) for i in range(a)])
ans=0
now=l[0]
cur=1
for i in range(1,a):
  x=l[i]
  if cur==b:
    now=x
    cur=1
    ans+=1
  elif x-now>c:
    now=x
    ans+=1
    cur=1
  else:
    cur+=1
print(ans+min(1,cur-1))

Fixed code:
a,b,c=map(int,input().split())
l=sorted([int(input()) for i in range(a)])
ans=0
now=l[0]
cur=1
for i in range(1,a):
  x=l[i]
  if cur==b:
    now=x
    cur=1
    ans+=1
  elif x-now>c:
    now=x
    ans+=1
    cur=1
  else:
    cur+=1
print(ans+1)
Buggy code:
N,C,K = [int(hoge) for hoge in input().split()]
ans = 0
time = -float("inf")
bus = 0
Ts = sorted([int(input()) for i in range(N)])
for T in Ts:
    if (T > time + K) or bus==C:
        ans += 1
        time = T
        bus = 1
    else:
        bus += 1
    print(time,bus)
print(ans)

Fixed code:
N,C,K = [int(hoge) for hoge in input().split()]
ans = 0
time = -float("inf")
bus = 0
Ts = sorted([int(input()) for i in range(N)])
for T in Ts:
    if (T > time + K) or bus==C:
        ans += 1
        time = T
        bus = 1
    else:
        bus += 1
print(ans)
Buggy code:
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np
import sys
import math
input = sys.stdin.readline
n,c,k = map(int,input().split())
A = [int(input()) for i in range(n)]
a = sorted(A)
ans = 0
time = 0.1 
num = 0
for i in range(n):
    if ans == 0:
        ans +=1
        time = A[0]
        num +=1
    elif ans != 0 and a[i] < time +k and num < c :
        num +=1
    elif  ans != 0 and (c <=num  or  time +k <=a[i]):
      
        time = a[i] +0.1
        num = 1
        ans +=1
print(ans)

Fixed code:
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np
import sys
import math
input = sys.stdin.readline
n,c,k = map(int,input().split())
A = [int(input()) for i in range(n)]
a = sorted(A)
ans = 0
time = 0.1 
num = 0
for i in range(n):
    if ans == 0:
        ans +=1
        time = a[0] 
        num +=1
    elif ans != 0 and a[i] <= time +k and num < c :
        num +=1
    elif  ans != 0 and (c <=num  or  time +k <=a[i]):
      
        time = a[i] 
        num = 1
        ans +=1
print(ans)
Buggy code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while idx > n - 1:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)

    print(ans)


if __name__ == '__main__':
    main()


Fixed code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n, c, k = ns()
    t = [ni() for _ in range(n)]
    t.sort()

    ans = 0
    idx = 0
    while True:
        ans += 1

        k_idx = bisect.bisect_right(t, t[idx] + k)
        c_idx = idx + c

        idx = min(k_idx, c_idx)
        if idx > n-1:
            break

    print(ans)


if __name__ == '__main__':
    main()
Buggy code:
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 1
buss = 0
fir = t[0]
for i in range(1, n):
    if fir <= t[i] and t[i] <= fir + k and cnt <= c:
        cnt += 1
    else:
        buss += 1
        cnt = 1
        fir = t[i]
if cnt >= 1:
    buss += 1
print(buss)

Fixed code:
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 1
buss = 0
fir = t[0]
for i in range(1, n):
    if fir <= t[i] and t[i] <= fir + k and cnt < c:
        cnt += 1
    else:
        buss += 1
        cnt = 1
        fir = t[i]
if cnt >= 1:
    buss += 1
print(buss)
Buggy code:
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

t_crr = t[0]
cnt = 0
ans = 1

for i in t:
    # print(cnt, ans, t_crr, i)
    if i - t_crr <= k and cnt < c:
        cnt += 1
        continue
    else:
        ans += 1
        cnt = 1

print(ans)

Fixed code:
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

t_crr = t[0]
cnt = 0
ans = 1

for i in t:
    # print(cnt, ans, t_crr, i)
    if i - t_crr <= k and cnt < c:
        cnt += 1
        continue
    else:
        t_crr = i
        ans += 1
        cnt = 1

print(ans)
Buggy code:
from collections import deque
n,c,k = map(int,input().split())
t = []
for _ in range(n):
    tt = int(input())
    t.append(tt)
t.sort()
ans = deque([])
cnt = 0
for i, tt in enumerate(t):
    if i == 0:
        ans.append([tt+k,1])
        cnt += 1
    else:
        flg = False
        for i in range(len(ans)):
            tmp = ans.popleft()
            if tmp[0] < tt or tmp[1] == c:

                continue
            else:
                flg = True
                break
        if flg :
            tmp[1] += 1
            if tmp[1] != c:
                a.append(tmp)
                ans.appendleft(tmp)
        else:
            tmp = [tt+k,1]
            ans.append(tmp)
            cnt += 1
print(cnt)


Fixed code:
from collections import deque
n,c,k = map(int,input().split())
t = []
for _ in range(n):
    tt = int(input())
    t.append(tt)
t.sort()
ans = deque([])
cnt = 0
for i, tt in enumerate(t):
    if i == 0:
        ans.append([tt+k,1])
        cnt += 1
    else:
        flg = False
        for i in range(len(ans)):
            tmp = ans.popleft()
            if tmp[0] < tt or tmp[1] == c:

                continue
            else:
                flg = True
                break
        if flg :
            tmp[1] += 1
            if tmp[1] != c:
                ans.appendleft(tmp)
        else:
            tmp = [tt+k,1]
            ans.append(tmp)
            cnt += 1
print(cnt)
Buggy code:
N, C, K, *T = map(int, open(0).read().split())
T.sort()

ans = 1
curm = T[0]
curc = 0
for t in T:
    curc += 1
    if t > curm+K or curc == C:
        ans += 1
        curm = t
        curc = 1

print(ans)


Fixed code:
N, C, K, *T = map(int, open(0).read().split())
T.sort()

ans = 1
curm = T[0]
curc = 0
for t in T:
    curc += 1
    if t > curm+K or curc > C:
        ans += 1
        curm = t
        curc = 1
print(ans)
Buggy code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c, k = map(int, input().split())
    T = sorted(list(int(input()) for _ in range(n)))
    print(T)
    res = 0
    cnt = 0
    dep = T[0] + k
    for i in range(n):
        if T[i] <= dep:
            cnt += 1

        if cnt == c or T[i] > dep:
            res += 1
            cnt = 0
            dep = T[i] + k

    print(res + 1)


if __name__ == '__main__':
    resolve()


Fixed code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, c, k = map(int, input().split())
    T = sorted(list(int(input()) for _ in range(n)))
    res = 0
    cnt = 0
    dep = T[0] + k
    for i in range(n):
        if cnt == c or T[i] > dep:
            res += 1
            cnt = 1
            dep = T[i] + k
        else:
            cnt += 1

    print(res + 1)


if __name__ == '__main__':
    resolve()
Buggy code:
from sys import stdin
import sys
import math

[N, C, K] = list(map(int, stdin.readline().rstrip().split()))
T = sorted([int(input()) for i in range(N)])

print(T)

bus = 1
passenger = 0
first_passengers_time = -1
for i in T:
    print("%d %d" % (bus, i))
    if passenger == C or (passenger > 0 and first_passengers_time + K < i):
        bus += 1
        passenger = 0
        first_passengers_time = 0

    if passenger == 0:
        passenger += 1
        first_passengers_time = i
    elif passenger < C and first_passengers_time + K >= i:
        passenger += 1

print(bus)


Fixed code:
from sys import stdin
import sys
import math

[N, C, K] = list(map(int, stdin.readline().rstrip().split()))
T = sorted([int(input()) for i in range(N)])

bus = 1
passenger = 0
first_passengers_time = -1
for i in T:
    if passenger == C or (passenger > 0 and first_passengers_time + K < i):
        bus += 1
        passenger = 0
        first_passengers_time = 0

    if passenger == 0:
        passenger += 1
        first_passengers_time = i
    elif passenger < C and first_passengers_time + K >= i:
        passenger += 1

print(bus)
Buggy code:
n,c,k = map(int,input().split())
ab = []
for _ in range(n):
    t=int(input())
    ab.append(t)
ab.sort()

bus = 1
bustime = ab[0] + k
customer = 1

for i in range(1,n):
    if ab[i] <= bustime:
        customer += 1
        if customer == c:
            bustime = ab[i+i]+k
            customer = 0
            bus += 1
    elif bustime < ab[i]:
        bustime = ab[i]+k
        customer = 1
        bus += 1
print(bus)

Fixed code:
n,c,k = map(int,input().split())
ab = []
for _ in range(n):
    t=int(input())
    ab.append(t)
ab.sort()

bus = 1
bustime = ab[0] + k
customer = 1

for i in range(1,n):
    if customer < c and ab[i] <= bustime:
        customer += 1
    else:
        bustime = ab[i]+k
        customer = 1
        bus += 1
print(bus)
Buggy code:
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
passenger = 0
departure_limit = 0
bus_cnt = 0

for T in t:
    if passenger+1 > c or T > departure_limit:
        departure_limit = T+k
        passenger = 1
        bus_cnt += 1

print(bus_cnt+1)

Fixed code:
import collections

n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]

t.sort()

passenger = 0
departure_limit = t[0] + k
bus_cnt = 0

for T in t:
    if passenger+1 > c or T > departure_limit:
        departure_limit = T+k
        passenger = 1
        bus_cnt += 1
    else:
        passenger+=1

print(bus_cnt+1)
Buggy code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 0
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 1
        now = i
        ans += 1
    else:
        p += 1

print(ans)

Fixed code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,c,k = na()
t = []

for i in range(n):
    u = ni()
    t.append(u)

t.sort()

now = t[0]
p = 1
ans = 1

for i in t:
    if i-now > k or p > c:
        p = 2
        now = i
        ans += 1
    else:
        p += 1

print(ans)
Buggy code:
N,C,K = map(int,input().split())
T =[int(input()) for i in range(N)]

p = 0
r = 0
cnt = 1

T.sort()

for i in range(len(T)):
    if p == 0:
        p = 1
        q = T[i]
        r = 1
    elif p == 1 and q + K >= T[i] and r <= C:
        r += 1
    else:
        cnt += 1
        p = 1
        q = T[i]
        r = 1

print(cnt)


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

p = 0
r = 0
cnt = 1

T.sort()

for i in range(len(T)):
    if p == 0:
        p = 1
        q = T[i]
        r = 1
    elif p == 1 and q + K >= T[i] and r < C:
        r += 1
    else:
        cnt += 1
        p = 1
        q = T[i]
        r = 1

print(cnt)
Buggy code:
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    cnt = 1
    p, l = 0, u[0] + k
    for v in t:
        if v <= l and p < c:
            p += 1
        else:
            cnt += 1
            l = v + k
    print(cnt)


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t = sorted(t)
    u = tuple(t)

    cnt = 1
    p, l = 0, u[0] + k
    for v in t:
        if v <= l and p < c:
            p += 1
        else:
            cnt += 1
            l = v + k
            p = 1
    print(cnt)


if __name__ == '__main__':
    main()
Buggy code:
N, C, K = map(int, input().split())
T = [0] * N
for i in range(N):
  T[i] = int(input())
T = sorted(T)
ans = 0
waiting = []
for t in T:
  if len(waiting) == C:
    ans += 1
    waiting = []
  elif len(waiting) > 0 and t > waiting[0] + K:
    ans += 1
    waiting = []
  else:
    waiting.append(t)
else:
  ans += 1
print(ans)

Fixed code:
N, C, K = map(int, input().split())
T = [0] * N
for i in range(N):
  T[i] = int(input())
T = sorted(T)
ans = 0
waiting = []
for t in T:
  if len(waiting) == C:
    ans += 1
    waiting = []
  if len(waiting) > 0 and t > waiting[0] + K:
    ans += 1
    waiting = []
  waiting.append(t)
else:
  ans += 1
print(ans)
Buggy code:
n,c,k = map(int, input().split())
Ts = [int(input()) for i in range(n)] + [10**10]
Ts = sorted(Ts)

ans = 0
cnt = 0
flg = 0
prev = Ts[0]
for i in range(1,len(Ts)):
    now = Ts[i]
    if now - prev <= k:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        prev = Ts[i]
    if cnt > c:
        ans += 1
        cnt = 1
        prev = Ts[i]
    # print("i",i,"cnt",cnt,"ans",ans)
print(ans)



Fixed code:
n,c,k = map(int, input().split())
Ts = [int(input()) for i in range(n)] + [10**10]
Ts = sorted(Ts)

ans = 0
cnt = 1
flg = 0
prev = Ts[0]
for i in range(1,len(Ts)):
    now = Ts[i]
    if now - prev <= k:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        prev = Ts[i]
    if cnt > c:
        ans += 1
        cnt = 1
        prev = Ts[i]
    # print("i",i,"cnt",cnt,"ans",ans)
print(ans)
Buggy code:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
T.append(T[-1])

fst = T[0]
cnt = 1
ans = 0
flg = 0

for i in range(1,N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    # print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    ans += 1

print(ans+1)
        
        




Fixed code:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
T.append(T[-1])

fst = T[0]
cnt = 0
ans = 0
flg = 0

for i in range(N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    # print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    ans += 1

print(ans)
Buggy code:
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]

t.sort()
key = t[0]+k
len_t = 0
ans1 = 0
for i in range(n):
    if t[i] <= key and len_t < c:
        print(len_t)
        len_t += 1
    else:
        ans1 += 1
        key = t[i]+k
        len_t = 1
ans1 += 1
print(ans1)

Fixed code:
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]

t.sort()
key = t[0]+k
len_t = 0
ans1 = 0
for i in range(n):
    if t[i] <= key and len_t < c:
        len_t += 1
    else:
        ans1 += 1
        key = t[i]+k
        len_t = 1
ans1 += 1
print(ans1)
Buggy code:
n, c, k = list(map(int, input().split(' ')))

ts = []
for i in range(n):
    ts.append(int(input()))

tss = sorted(ts, reverse=True)

base = tss[0]
count = 0
limit = 0
for i in range(n):
    limit += 1
    if base - tss[i] > k:
        count += 1
        base = tss[i]
        limit = 0
    elif limit > c:
        count += 1
count += 1
print(count)


Fixed code:
n, c, k = list(map(int, input().split(' ')))

ts = []
for i in range(n):
    ts.append(int(input()))

tss = sorted(ts, reverse=True)

base = tss[0]
count = 0
limit = 0
for i in range(n):
    limit += 1
    if base - tss[i] > k or limit > c:
        count += 1
        base = tss[i]
        limit = 1
count += 1
print(count)
Buggy code:
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sorted()

pas = 1
last_bus = t[0] + k
ans = 1

for i in t[1:]:
  if i <= last_bus and pas < c:
    pas +=1
  else:
    ans +=1
    pas =1
    last_bus = i + k
    
    
print(ans)
  
  


Fixed code:
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()

pas = 1
last_bus = t[0] + k
ans = 1

for i in t[1:]:
  if i <= last_bus and pas < c:
    pas +=1
  else:
    ans +=1
    pas =1
    last_bus = i + k
    
    
print(ans)
Buggy code:
N, C, K = [int(x) for x in input().split()]
T_lst = [int(input()) for i in range(N)]
T_lst.sort()

bus = 1
st = T_lst[0]
num = 1
for i in range(1, N):
    if T_lst[i] <= st + K and num <= C:
        num += 1
        continue
    else:
        st = T_lst[i]
        bus += 1
        num = 0
print(bus)


Fixed code:
N, C, K = [int(x) for x in input().split()]
T_lst = [int(input()) for i in range(N)]
T_lst.sort()

bus = 1
st = T_lst[0]
num = 1
for i in range(1, N):
    if T_lst[i] <= st + K and num < C:
        num += 1
    else:
        bus += 1
        st = T_lst[i]
        num = 1
print(bus)
Buggy code:
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]

T.sort()

#%%
cnt = 0
ans = 1
time = T[0]
for i in range(N):
    if cnt == 0:
        time = T[i]

    if time <= T[i] <= time + K:
        cnt += 1
    else:
        ans += 1
        cnt = 0

    if cnt == C:
        ans += 1
        cnt = 0

if cnt == 1:
    ans += 1
print(ans)

Fixed code:
#%%
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]

T.sort()


cnt = 0
ans = 1
time = T[0]
for i in range(N-1):
    cnt += 1
    if cnt == C or time + K < T[i+1]:
        ans += 1
        cnt = 0
        time = T[i + 1]

print(ans)
Buggy code:
N,C,K = map(int,input().split())
li = []
for t in range(N):
  li.append(int(input()))

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < 2:
	  break
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)

Fixed code:
N,C,K = map(int,input().split())
li = []
for t in range(N):
  li.append(int(input()))

count = 0
ans = 0

newLi = sorted(li)

while(len(newLi)):
  for c in range(C - 1):
    if len(newLi) < 2:
      break
    
    if newLi[1] <= newLi[0] + K:
      newLi.pop(1)
    else:
      break

  newLi.pop(0)
  ans += 1

print(ans)
Buggy code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

peo = 0
bus = 1
out = T[0] + k

for t in T:
    if t <= out and peo <= c:
        peo += 1
    else:
        out = t + k
        peo = 0
        bus += 1

print(bus)

Fixed code:
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

out = T.pop(0) + k
peo = 1
bus = 1

for t in T:
    if t <= out and peo < c:
        peo += 1

    else:
        out = t + k
        peo = 1
        bus += 1

print(bus)
Buggy code:
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
time = T.pop(0)+K
people = 1
ans = 1
for t in T:
    if t <= time and people < C:
        people += 1
    else:
        if people == C:
            time += t
        else:
            time += K
        people = 0
        ans += 1
print(ans)

Fixed code:
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
time = T.pop(0)
people = 1
ans = 1
for t in T:
    if t <= time + K and people < C:
        people += 1
    else:
        time = t
        people = 1
        ans += 1
print(ans)
Buggy code:
N, C, K = [int(i) for i in input().split()]
T = list(sorted([int(i) for i in input().split()]))
ans = 1
limit = 0
ti = T[0]
for i in range(N - 1):
    limit += 1
    if ti + K < T[i + 1] or limit == C:
        ti = T[i + 1]
        ans += 1
        limit = 0
print(ans)


Fixed code:
N, C, K = [int(i) for i in input().split()]
T = sorted([int(input()) for i in range(N)])
ans = 1
limit = 0
ti = T[0]
for i in range(N - 1):
    limit += 1
    if ti + K < T[i + 1] or limit == C:
        ti = T[i + 1]
        ans += 1
        limit = 0
print(ans)
Buggy code:
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
ans = 1
busNin = 0
busFirstp = 0
for i in range(n):
    if t[i]-t[busFirstp] > k or busNin == c:
        ans += 1
        busNin = 1
        busFirstp = i
        continue
    busNin += 1
print(ans)


Fixed code:
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
ans = 1
busNin = 0
busFirstp = 0
for i in range(n):
    if t[i]-t[busFirstp] > k or busNin == c:
        ans += 1
        busNin = 1
        busFirstp = i
        continue
    busNin += 1
print(ans)
Buggy code:
N,C,K=map(int,input().split())
cus=[None]*N
for i in range(N):
  t=int(input())
  cus[i]=[t,t+K]
cus=sorted(cus,key=lambda x:x[1])

last=-1
ans=0
rest=0
for i in range(N):
  if rest==0 or last<cus[i][1]:
    last=cus[i][1]
    ans+=1
    rest=C-1
  elif rest>0:
    rest-=1
print(ans)

Fixed code:
N,C,K=map(int,input().split())
cus=[None]*N
for i in range(N):
  t=int(input())
  cus[i]=[t,t+K]
cus=sorted(cus,key=lambda x:x[1])

last=-1
ans=0
rest=0
for i in range(N):
  if rest==0 or last<cus[i][0]:
    last=cus[i][1]
    ans+=1
    rest=C-1
  elif rest>0:
    rest-=1
print(ans)
Buggy code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] >= bt):
        ans += 1
        btl.append(bt)
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
    if (cnt == c):
        btl.append(t[i])
        ans += 1
        cnt,bt = 0,10**9+1

if (cnt != 0):
    ans += 1

print(ans)

Fixed code:
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] > bt)|(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)
Buggy code:
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
ans=0
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=0
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+2 if t[-1]-x>k or y==0 else ans+1)

Fixed code:
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
ans=0
x=t[0]
y=0
for i in range(n-1):
    y+=1
    if t[i]-x>k:
        ans+=1
        x=t[i]
        y=1
    elif y==c:
        ans+=1
        x=t[i+1]
        y=0
print(ans+2 if t[-1]-x>k else ans+1)
Buggy code:
N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))

T.sort()
i = 0
start = 0
ans = 0
limit = C
for i in range(N):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif T[start] + K >= T[i + 1] and limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)

Fixed code:
N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))

T.sort()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)