Problem:
 Score : 300 points    Problem Statement Every day, N passengers arrive at Takahashi Airport.
The i -th passenger arrives at time T_i .  Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.
Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.
Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.
For that reason, it is necessary to arrange buses so that the i -th passenger can take a bus departing at time between T_i and T_i + K (inclusive).  When setting the departure times for buses under this condition, find the minimum required number of buses.
Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.      Constraints  2 \leq N \leq 100000  1 \leq C \leq 10^9  1 \leq K \leq 10^9  1 \leq T_i \leq 10^9  C , K and T_i are integers.         Input The input is given from Standard Input in the following format:  N  C  K  T_1  T_2  :  T_N       Output Print the minimum required number of buses.        Sample Input 1 5 3 5
1
2
3
6
12      Sample Output 1 3  For example, the following three buses are enough:   A bus departing at time 4.5 , that carries the passengers arriving at time 2 and 3 .  A bus departing at time 6 , that carries the passengers arriving at time 1 and 6 .  A bus departing at time 12 , that carries the passenger arriving at time 12 .        Sample Input 2 6 3 3
7
6
2
8
10
6      Sample Output 2 3

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

t.sort()

waitP = 1
l = t[0]
ans = 0

for i in range(1, n):
    if waitP == c:
        ans += 1
        l = t[i]
        waitP = 1
        if i == n - 1:
            ans += 1
    elif waitP != c:
        if t[i] - l <= k:
            waitP += 1
            if i == n - 1:
                ans += 1
        elif t[i] - l > k:
            ans += 1
            l = t[i]
            waitP = 1
            if i == n - 1:
                ans += 1

print(ans)

Solution (Python):
N,C,K = map(int,input().split())
lisT = [int(input()) for _ in range(N)]

lisT.sort()
teiin = C
limit = K
timeup = 0
passengers = C
buscnt = 0
for i in range(N):
    if lisT[i] > timeup or passengers==0:
        timeup = lisT[i] + K
        passengers = C
        buscnt += 1
        passengers -= 1
    else:
        passengers -= 1

print(buscnt)

Solution (Python):
n, c, k = map(int, input().split())
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()
ans = 1
bus = 0
d_time = t[0]+k
for i in t:
    if i>d_time or bus==c:
        ans += 1
        bus = 1
        d_time = i+k
    else:
        bus += 1
print(ans)

Solution (Python):
def myAnswer(N:int,C:int,K:int,T:list)->int:
   T.sort()
   ans = 0
   counter = 1
   hantei = T.pop(0)
   for t in T:
      if(counter == C or (t - hantei) > K):
         ans += 1
         hantei = t
         counter = 1
      else:
         counter += 1
   ans += 1
   return ans

def modelAnswer():
   return
def main():
   N,C,K = map(int,input().split())
   T = [int(input()) for _ in range(N)]
   print(myAnswer(N,C,K,T))

if __name__ == '__main__':
   main()

Solution (Python):
n,c,k=map(int,input().split())

cnt=0


time=[]
for _ in range(n):
    time.append(int(input()))


time.sort()

count_up=0
member=0
cnt=0

temp=[]

for t in time:
    if count_up==0:
        count_up=t

    if t>count_up+k:
        
        cnt+=1
        count_up=t
        member=1
        temp=[t]
    else:
        member+=1
        temp.append(t)
        if member>=c:
            
            member=0
            cnt+=1
            count_up=0
            temp=[]

if member>0:
    cnt+=1
    

print(cnt)

Solution (Python):
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)

Solution (Python):
N, C, K = map(int, input().split())
bus_count = 0
waiting_count = 0
time_limit = 0
D = [int(input()) for _ in range(N)]
D.sort()

for i in range(N):
    T = D[i]
    waiting_count += 1
    if T > time_limit and not time_limit == 0:
        time_limit = T + K
        bus_count += 1
        waiting_count = 1
    if waiting_count == C:
        bus_count += 1
        waiting_count = 0
        time_limit = 0
    else:
        if waiting_count == 1:
            time_limit = T + K

if not waiting_count == 0:
    print(bus_count+1)
else:
    print(bus_count)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n,c,k = map(int, input().split())
t = list(int(input()) for i in range(n))
t.sort()
ans =0

from collections import deque
queue = deque()

INF = float('inf')
t.append(INF)

for i in range(n):

    queue.append(t[i])
    limit = queue[0]+k

    if limit < t[i+1] or len(queue)>=c:
        for i in range(min(len(queue), c)):
            queue.popleft()
        ans += 1

while queue:
    for i in range(min(len(queue), c)):
        queue.popleft()
    ans += 1

print(ans)

Solution (Python):
import numpy as np
n, c, k = [int(a) for a in input().split()]
t = []
for _ in range(n):
    t.append(int(input()))
t = np.asarray(t)
t = np.sort(t)

ans = 0
count = 0
lim = 0

for i in range(t.shape[0]):
    if count == 0:
        lim = t[i] + k
        count += 1
    elif t[i] <= lim and count < c:
        count += 1
    else:
        lim = t[i] + k
        ans += 1
        count = 1

print(ans+1)

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

ans = 0
cou = 0
lim = 0

for i in range(n):
    if lim == 0:
        lim = t[i] + k
        cou = 1
        if c == 1:
            lim = 0
            cou = 0
            ans += 1
    elif lim > t[i]:
        if cou == c - 1:
            ans += 1
            cou = 0
            lim = 0
        elif cou < c - 1:
            cou += 1
    elif lim == t[i]:
        ans += 1
        cou = 0
        lim = 0
    elif lim < t[i]:
        ans += 1
        cou = 1
        lim = t[i] + k

if cou > 0:
    ans += 1

print(ans)

Solution (Python):
n, c, k = map(int, input().split())

begin = 0

t = 0
cap = 0

L = []
for i in range(n):
    L.append(int(input()))
L = sorted(L)
for i in range(n):
    a = L[i]
    if begin == 0:
        begin = a
    if a <= begin + k and cap < c:
        cap += 1
    else:
        t += 1
        begin = a
        cap = 1
print(t +1)

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

ans = 0
t.sort()
x = 0
p = 0
for ti in t:
  if x < ti:
    ans += 1
    p = 1
    x = ti+k
  else:
    if p < c:
      p += 1
    else:
      ans += 1
      p = 1
      x = ti+k
print(ans)

Solution (Python):
N, C, K = map(int, input().split())

T = [int(input()) for _ in range(N)]

T.sort()

res = 0
i = 0
while i < N:
	res += 1
	Left = i
	while (i < N and T[i] - T[Left] <= K and i - Left + 1 <= C):
		i += 1

print(res)

Solution (Python):
n,c,k=map(int,input().split())
customer=[int(input()) for i in range(n)]
customer=sorted(customer)
limit=-1
cnt=0
ans=0
for i in range(n):
    if cnt==0:
        limit=customer[i]+k
        cnt+=1
    else:
        if customer[i]>limit:
            ans+=1
            cnt=1
            limit=customer[i]+k
        else:
            if cnt<c:
                cnt+=1
            else:
                ans+=1
                cnt=1
                limit=customer[i]+k
if cnt>0:
    ans+=1
print(ans)

Solution (Python):
n, c, k = map(int, input().split())
times = []
for i in range(n):
    times.append(int(input()))
    
times.sort()

passenger = 0
number_of_unit = 1
waiting_time = times[0] + k
for t in times:
    if c == passenger:
        
        passenger = 0
    elif waiting_time < t:
        
        passenger = 0
    else:
        
        passenger += 1
        
    if passenger == 0:
        waiting_time = t + k
        passenger += 1
        number_of_unit += 1
        

print(number_of_unit)

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

T.sort(reverse=True)


t_before = T[0]
cnt = 0
ans = 0
for t in T:
    
    if t_before - t <= K and cnt + 1 <= C:
        cnt += 1
        continue
    else:
        t_before = t
        cnt = 1
        ans += 1

print(ans+1)

Solution (Python):
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    x = int(input())
    T.append(x)
T.sort()
lim = 0
tim = 0
ans = 0
for i in range(N):
    if lim == 0:
        lim += 1
        tim = T[i]
    else:
        if tim + K >= T[i] and lim < C:
            lim += 1
        else:
            lim = 1
            tim = T[i]
            ans += 1

print(ans+1)

Solution (Python):
n, c, k = map(int, input().split())
t = [0] * n
for i in range(n):
    t[i] = int(input())

t.sort()
ans = 0
now_person = 0
first_lim = 0
for i in range(n):
    if now_person == 0:
        first_lim = t[i]
        now_person = 1
        ans += 1
    else:
        if t[i] - first_lim  <= k:
            now_person += 1
        else:
            first_lim = t[i]
            now_person = 1
            ans += 1

    

    if now_person == c:
        now_person = 0

print(ans)

Solution (Python):

n,c,k = map(int, input().split())
t = list(int(input()) for _ in range(n))
t.sort()

T = 0
x = 0
ans = 0
for i in range(n):
    if x == 0: 
        T = t[i] + k
        x += 1
    elif t[i] <= T: 
        x += 1
    elif t[i] > T: 
        ans += 1
        x = 1
        T = t[i] + k
    if x == c: 
        ans += 1
        T = 0
        x = 0
if x != 0: ans += 1
print(ans)

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

i = 0
ans = 0
while i < N:
  tmp = i+1
  while tmp < N:
    if tmp < i+C and T[tmp] <= T[i]+K:
      tmp += 1
    else:
      break
  ans += 1
  i = tmp
print(ans)

Solution (Python):
n,c,k = map(int,input().split()) 
t = [int(input()) for _ in range(n)]
t = sorted(t)
count = 0
bus = []
for i in range(0,n):
    if len(bus)>0: 
        if  c <= len(bus): 
            count += 1
            bus = []
            
        if len(bus)>0 and k < t[i]-bus[0]: 
            count += 1
            bus = [t[i]]
        else:
            bus.append(t[i])
    else:
        bus.append(t[i])
        
    if i==n-1:
        if len(bus)>0:
            count += 1
            bus = []
print(count)

Solution (Python):
n,c,k=map(int,input().split())
t=[0 for i in range(n)]
for i in range(n):
    t[i]=int(input())
t.sort()
ans=0
cnt=1
bef=t[0]
for i in range(1,n):
    if cnt==c:
        ans+=1
        cnt=1
        bef=t[i]
    elif bef+k>=t[i] and cnt<c:
        cnt+=1
    else:
        ans+=1
        cnt=1
        bef=t[i]
    if i==n-1:
        ans+=1
print(ans)

Solution (Python):
N, C, K = map(int, input().split())
arr = sorted([int(input()) for _ in range(N)])
start_t = arr[0]
bus_n = 0
ans = 1
for i in range(N):
    if arr[i] <= start_t + K and bus_n < C:
        bus_n += 1
    else:
        bus_n = 1
        start_t = arr[i]
        ans += 1
print(ans)

Solution (Python):
import sys
input = sys.stdin.buffer.readline

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

lim = 0
ans = 0
wait = 0
for t in T:
    if t > lim:
        if wait:
            ans += 1
        if C == 1:
            ans += 1
            wait = 0
            lim = 0
        else:
            lim = t + K
            wait = 1
    else:
        wait += 1
        if wait == C:
            ans += 1
            wait = 0
            lim = 0
if wait:
    ans += 1

print(ans)

Solution (Python):
n, c, k = map(int, input().split())
t_list = []
for i in range(n):
    t_list.append(int(input()))
t_list.sort()
count = 1
current_c = []
start_t = None


for t in t_list:
    if not start_t:
        start_t = t
        current_c.append(t)
    elif len(current_c) < c:
        if start_t + k < t:
            count += 1
            current_c = [t]
            start_t = t
        else:
            current_c.append(t)
    elif len(current_c) >= c:
        count += 1
        current_c = [t]
        start_t = t
    else:
        print("error")
print(count)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, C, K = MAP()
A = [INT() for i in range(N)]
num = 0
A.sort()
B = []
ans = 0
mi = 0

for i in range(N):
    if len(B) == C:
        
        B = [A[i]]
        ans += 1
        mi = A[i]
    elif len(B) == 0:
        B = [A[i]]
        mi = A[i]
    else:
        gap = A[i] - mi
        if gap <= K:
            B.append(A[i])
        else:
            B = [A[i]]
            ans += 1
            mi = A[i]
    
if len(B) != 0:
    ans += 1
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,c,k=map(int,input().split())
    ans=0
    person=0
    wait=-10**9
    T=[int(input())for _ in range(n)]
    T.sort()
    for i in range(n):
        if T[i]-wait<=k and person+1<=c:
            person+=1
        else:
            ans+=1
            person=1
            wait=T[i]
    print(ans)

if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,c,k=map(int,input().split())
    ans=0
    person=0
    wait=-10**9
    T=[int(input())for _ in range(n)]
    T.sort()
    for i in range(n):
        if T[i]-wait<=k and person+1<=c:
            person+=1
        else:
            ans+=1
            person=1
            wait=T[i]
    print(ans)

if __name__=='__main__':
    main()

Solution (Python):
n,c,k=map(int,input().split())
a=[int(input()) for _ in range(n)]

a.sort()
count=0
c_count=1
box=a[0]
for i in range(1,n):
    if c_count<c:
        if a[i]-box<=k:
            count+=1
            c_count+=1
        else:
            box=a[i]
            c_count=1
    else:
        box=a[i]
        c_count=1
    
print(n-count)

Solution (Python):
n,c,k = map(int,input().split())
t = sorted([int(input()) for i in range(n)])
ans = 0
j = 1
rimit = 0
for i in t:
    if j<c and rimit>=i:
        j+=1
    else:
        ans+=1
        rimit=i+k
        j=1
print(ans)

Solution (Python):
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()

Solution (Python):
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)

Solution (Python):
N, C, K = map(int, input().split(' '))
T = [int(input()) for _ in range(N)]
T.sort()
ans = 1
bus_cap = 1
last_time = T[0]
for t in T[1:]:
    if bus_cap + 1 > C or t - last_time > K:
        ans += 1
        bus_cap = 1
        last_time = t
    else:
        bus_cap += 1
print(ans)

Solution (Python):
n,c,k = map(int,input().split())
li = []
for _ in range(n):
    li.append(int(input()))
li.sort()

all_count = 0
kazu = 0
start = 0
if c == 1:
    print(n)
    exit()
for l in li:
    if kazu == 0 and start == 0:
        all_count += 1
        kazu += 1
        start = l
        continue
    if kazu < c and l - start <= k:
        kazu += 1
    if kazu == c:
        kazu = 0
        start = 0
        continue
    if l - start > k:
        all_count += 1
        kazu = 1
        start = l
print(all_count)

Solution (Python):
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)

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

t.sort()

bus = 0
dis = t[0] + k
temp = 0 

for i in range(n):
    if (t[i] > dis) or (temp+1 > c):
        bus += 1
        dis = t[i]+k
        temp = 1
        
        
    else:
        temp += 1
            
    

print(bus+1)

Solution (Python):
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)

Solution (Python):
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
sorted_T = sorted(T)

first = sorted_T[0]
cap = C-1
limit = first + K
ans = 1

for i in range(1, N):
    if (cap > 0) and (sorted_T[i] < limit):
        cap -= 1
    elif (cap == 0) or ((cap > 0) and (sorted_T[i] > limit)):
        cap = C-1
        first = sorted_T[i]
        limit = first + K
        ans += 1

print(ans)

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


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

TT = [i + K for i in T]

cnt = 0
i = 0
temp = -1  
while True:
    i = bisect.bisect_right(T, TT[i])
    if i - temp > C:
        i = temp + C + 1
        temp += C
    cnt += 1
    temp = i - 1
    if i >= N:
        break
print(cnt)

Solution (Python):
import bisect













import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


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

    TT = [i + K for i in T]

    cnt = 0
    i = 0
    temp = -1
    while True:
        i = bisect.bisect_right(T, TT[i])
        if i - temp > C:
            i = temp + C + 1
            temp += C
        cnt += 1
        temp=i-1
        if i >= N:
            break
    print(cnt)


resolve()

Solution (Python):

import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') 
def gcd(a,b):return fractions.gcd(a,b) 
def lcm(a,b):return (a*b) // fractions.gcd(a,b) 
def iin(): return int(sys.stdin.readline()) 
def ifn(): return float(sys.stdin.readline()) 
def isn(): return sys.stdin.readline().split() 
def imn(): return map(int, sys.stdin.readline().split()) 
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) 
def fmn(): return map(float, sys.stdin.readline().split()) 
def iln(): return list(map(int, sys.stdin.readline().split())) 
def iln_s(): return sorted(iln()) 
def iln_r(): return sorted(iln(), reverse=True) 
def fln(): return list(map(float, sys.stdin.readline().split())) 
def join(l, s=''): return s.join(l) 
def perm(l, n): return itertools.permutations(l, n) 
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) 
def comb(l, n): return itertools.combinations(l, n) 
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) 
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')






N,C,K = imn()
T = sorted([iin() for _ in range(N)])

departure_time = -1
passenger_cnt = 0
ans = 0
if C == 1:
    print(N)
    exit()
    
for i in range(N):
    if departure_time == -1: 
        departure_time = T[i] + K
        passenger_cnt += 1
        ans += 1
    else:
        if departure_time >= T[i]:
            passenger_cnt += 1 
            if passenger_cnt == C:
                departure_time = -1
                passenger_cnt = 0
        else:
            departure_time = T[i]+K
            passenger_cnt = 1
            ans += 1 
print(ans)

Solution (Python):
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)

Solution (Python):
n,c,k = map(int,input().split())
t = 0
cnt = c
ans = 0
T = [int(input()) for _ in range(n)]
T.sort()
for i in range(n):
    if cnt == c or T[i] > t:
        ans += 1
        t = T[i] + k
        cnt = 1
    else:
        cnt += 1

print(ans)

Solution (Python):
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
ans = 0
i = 0
while i < N:
    p = 0
    lm = T[i] + K
    while i < N and p < C and lm >= T[i]:
        p += 1
        i += 1
    ans += 1
print(ans)

Solution (Python):
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)

Solution (Python):
def main():
    n,c,k=map(int,input().split())
    t=[]
    for i in range(n):
        ti=int(input())
        t.append(ti)
    t.sort()
    ans=0
    i=0
    while i<n:
        j=1
        while j<c and i+j<n:
            if t[i+j]>t[i]+k:
                break
            j+=1
        ans+=1
        i+=j
    print(ans)
if __name__=="__main__":
    main()

Solution (Python):
import sys
from io import StringIO
import unittest

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

    t.sort()
    ans = 1
    bus_base = t[0] + k
    cnt_bus = 0

    for i in range(n):
        if cnt_bus == c:
            cnt_bus = 0
            bus_base = t[i] + k
            ans += 1

        if t[i] <= bus_base:
            cnt_bus += 1
            continue
        else:
            bus_base = t[i] + k
            ans += 1
            cnt_bus = 1

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 3 5
1
2
3
6
12"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """6 3 3
7
6
2
8
10
6"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):
n, c, k = map(int, input().split())
ttt = [int(input()) for _ in range(n)]
ttt.sort()
ans = 0
waiting_count = 0
waiting_first = -1

for t in ttt:
    if waiting_first == -1:
        waiting_count = 1
        waiting_first = t
    elif waiting_first + k < t:
        ans += 1
        waiting_count = 1
        waiting_first = t
    else:
        waiting_count += 1
    if waiting_count >= c:
        ans += 1
        waiting_count = 0
        waiting_first = -1
if waiting_count:
    ans += 1
print(ans)

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

t.sort()
bus = 0
limit = t[0] + k
passenger = 0

"""
最初の人のリミットが来るor定員を超える→バス追加
"""

for i in range(n):
    if limit < t[i]:
        
        bus += 1
        passenger = 0
        if i+1 < n:
            limit = t[i] + k
    
    passenger += 1

    if passenger == c:
        
        passenger = 0
        bus += 1
        if i+1 < n:
            limit = t[i+1] + k

if passenger > 0:
    bus += 1

print(bus)

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

c = 0
l = float('inf')
result = 0
for i in range(N):
    t = T[i]
    if t > l:
        result += 1
        l = float('inf')
        c = 0
    if c == 0:
        l = t + K
    c += 1
    if c == C:
        result += 1
        l = float('inf')
        c = 0
if c != 0:
    result += 1
print(result)

Solution (Python):
n,c,k,*t=map(int,open(0).read().split())
t=sorted(t)
cnt=0
ans=1
x=t[0]
for i in range(n):
  cnt+=1
  if t[i]-x>k or cnt>c:
    x=t[i]
    ans+=1
    cnt=1
print(ans)

Solution (Python):
n,c,k=map(int,input().split())
t=[]
for _ in range(n):
  t.append(int(input()))
if c==1:
  print(n)
  exit()

t.sort()
time=0
p=0
taiki=0
ans=0
for i in range(n):
  if taiki==0:
    p=t[i]
    time=0
    taiki+=1
    continue
  taiki+=1
  time+=t[i]-p
  p=t[i]
  if time > k :
    ans+=1
    taiki=1
    time=0
  elif taiki==c:
    ans+=1
    taiki=0
ans += 1 if taiki > 0 else 0
print(ans)

Solution (Python):
from queue import Queue

N, C, K = map(int, input().split())


T = [[0, 0] for _ in range(N)]
for i in range(N):
    t = int(input())
    T[i][0] = t + K
    T[i][1] = t

T.sort()
que = Queue()
for t in T:
    que.put(t)

ans = 0
dest = -1
cap = 0

while not que.empty():
    td, ta = que.get()

    
    if cap == 0:
        dest = td
        cap = 1
    
    elif ta <= dest:
        cap += 1
    
    else:
        ans += 1
        dest = td
        cap = 1

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


if cap > 0:
    ans += 1

print(ans)

Solution (Python):
import collections

N, C, K = map(int, input().split())
T = collections.deque()
for _ in range(N):
    T.append(int(input()))
T = sorted(T)
T = collections.deque(T)

ans = 0

while T:
    time = T[0] + K
    cnt = 0
    while T[0] <= time:
        T.popleft()
        cnt += 1
        if cnt >= C:
            break
        if not T:
            break
    ans += 1
print(ans)

Solution (Python):
N,C,K=map(int,input().split())
Tn=sorted([int(input()) for _ in range(N)])

b_cnt=0
p_cnt=0
time=Tn[0]+K
for t in Tn:

    
    if (time < t) or (p_cnt >= C) :
        
        b_cnt+=1
        p_cnt=0
        time=t+K
        
    p_cnt+=1
else:
    b_cnt+=1

print(b_cnt)

Solution (Python):
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

cnt = 1
time = 0
capa = 1
pre = T[0]

for i in range(1, N):
    capa += 1
    time += T[i]-pre
    if capa>C or time>K:  
        cnt += 1
        time = 0
        capa = 1

    pre = T[i]

print(cnt)

Solution (Python):
N,C,K=map(int,input().split())
T=[]
for i in range(N):
    t=int(input())
    T.append(t)
T.sort()
ans=0
tmp=0
count=0
for i in range(N):
    
    if i==0:
        dead=T[i]+K
        count=1
        continue
    count+=1
    if T[i]>dead or count>C:
        ans+=1
        dead=T[i]+K
        count=1
        continue
ans+=1
print(ans)

Solution (Python):
import sys


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


sys.setrecursionlimit(10 ** 9)


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    answer = 0
    cst = C
    time = 0
    for t in T:
        if (time + K >= t) and (cst + 1 <= C):
            cst += 1
        else:
            answer += 1
            time = t
            cst = 1

    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):
n,c,k = [int(i) for i in input().split()]
start = []
end   = []
for i in range(n):
    t = int(input())
    start.append(t)
    end.append(t+k)
    
start.sort()
end.sort()

ind = 0
cnt = 0
while(ind<n):
    time = end[ind]
    for i in range(1,c+1):
        next_ind = ind + i
        if next_ind==n or start[next_ind]>time:
            break
    ind = next_ind
    cnt += 1
print(cnt)

Solution (Python):
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 0
on_bus = 1
arr_time = t[0]
waiting_time = 0
for i in range(1,n):
    on_bus += 1
    waiting_time = t[i] - arr_time
    if on_bus > c or waiting_time >k:
        on_bus = 1
        arr_time = t[i]
        waiting_time = 0
        cnt += 1
print(cnt+1)

Solution (Python):
n,c,k = [int(x) for x in input().split()]
t = []
for _ in range(n):
    t.append(int(input()))
t.sort()

ans = 0
tmp = {"f": 0, "num": c}

for x in t:
    if tmp["f"] >= x and tmp["num"] > 0:
        tmp["num"] -= 1
    else:
        ans += 1
        tmp["num"] = c-1
        tmp["f"] = x+k


print(ans)

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

ans = 0
time = 0
j = c
for i in t:
    if time>=i and j>0:
        j -= 1
    else:
        ans += 1
        j = c-1
        time = i+k

print(ans)

Solution (Python):
N, C, K = map(int, input().split())
T = [0]*N
cnt = 1
bus = 1
for i in range(N):
    T[i] = int(input())
T.sort()
tmp = T[0]+K
for i in range(1, N):
    if(cnt == 0):
        bus += 1
        cnt = 1
        tmp = T[i]+K
        continue
        
    if(T[i] <= tmp and cnt < C):
        cnt += 1
        if(cnt == C):
            cnt = 0
    else:
        cnt = 1
        bus += 1
        tmp = T[i]+K
print(bus)

Solution (Python):
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
  t[i]=int(input())
t=sorted(t)

ans=1
cnt=0
time=t[0]+k

for i in range(n):
  if cnt==c or time<t[i]:
    cnt=1
    ans+=1
    time=t[i]+k
  else:
    cnt+=1
    
print(ans)

Solution (Python):
N, C, K = map(int, input().split())
Tlist = sorted([int(input()) for _ in range(N)])
ans = 0
now = 1
start = Tlist[0]
for t in Tlist[1:]:
    if now == C:
        ans += 1
        start = t
        now = 1
    else:
        if t - start <= K:
            now += 1
        else:
            ans += 1
            start = t
            now = 1
print(ans+1)

Solution (Python):
n, c, k = map(int, input().split())

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

t_list.sort()


ans = 0
tmp = 0
pass_list = []
for t in t_list:
    
    
    
    if len(pass_list) == 0:
        
        ans += 1
        
        tmp = t
        
        pass_list.append(t)
        

    else:
        
        if (t - tmp) > k:
            pass_list = []
            
            ans += 1
            
            tmp = t

            pass_list.append(t)

        
        else:
            pass_list.append(t)

    
    if len(pass_list) == c:
        pass_list = []
        
        
print(ans)