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):
import sys
input = sys.stdin.readline
from itertools import accumulate


def read():
    
    N, C, K = map(int, input().strip().split())
    T = []
    for i in range(N):
        t = int(input().strip())
        T.append(t)
    return N, C, K, T


def solve(N, C, K, T):
    T.sort()
    i = 0
    ans = 0
    while i < N:
        tk = T[i] + K
        j0 = i
        for j in range(j0, min(j0+C, N)):
            if T[j] <= tk:
                i += 1
            else:
                break
        ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

Solution (Python):
n, c, k = map(int, input().split())
t = []    
for _ in range(n):
    t.append(int(input()))
t.sort()
first = t[0]
wait = 0
need = 1
for i in t:
    wait += 1
    if first + k < i or wait > c:
        need += 1
        wait = 1
        first = i
        continue
print(need)

Solution (Python):
from collections import deque
N,C,K = map(int,input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
T = deque(T)
bus = 0
while True:
    bus += 1
    Time = T[0]+K
    num = 0
    while num < C and T[0] <= Time:
        T.popleft()
        num += 1
        if not T:
            print(bus)
            exit()

Solution (Python):
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]+[float("INF")]
t.sort()
now = 0
count = 0
ans = 0
for i in t:
    if now == 0:
        now = i
        count += 1
    else:
        if i <= now+k:
            if count < c:
                count += 1
            else:
                ans += 1
                now = i
                count = 1
        else:
            ans += 1
            now = i
            count = 1
print(ans)

Solution (Python):
N,C,K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
ans=s=0
while s<N:
    t=T[s]+K
    sm=1
    for i in range(s+1,min(s+C,N)):
        if T[i]<=t:
            sm+=1
        else:
            break
    s+=sm
    ans+=1
print(ans)

Solution (Python):
n, c, k = map(int, input().split())
p = [0 for i in range(n + 1)]
t0 = [int(input()) for i in range(n)]
t0.sort()
t = []
for i in range(n):
    temp = t0[i]
    t.append([temp, 1, i])
    t.append([temp + k, 2, i])
t.sort()
count = 0
for i in t:
    num = i[2]
    if i[1] == 1:
        p[num] += 1
    else:
        num2 = (p[num] - 1) // c + 1
        count += num2
        temp = num + 1
        num3 = c * num2 - p[num]
        while num3 > 0:
            if p[temp] == 0:
                break
            else:
                num4 = min(num3, p[temp])
                num3 -= num4
                p[temp] -= num4
                temp += 1
        p[num] = 0
print(count)

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


T = sorted(T)

num  = 0  
bus = 0
flag = 0

if C != 1:
  
  for n in range(N):
    if flag == 0:
      person_limit = C-1
      time_limit = T[n] + K
      flag = 1
    else:
      if T[n] <= time_limit:
        person_limit -= 1
        if person_limit == 0:
          bus += 1
          flag = 0
      else:
        bus += 1
        person_limit = C-1
        time_limit = T[n] + K
        flag = 1

    if n == N-1 and flag == 1:
      bus += 1

else:
  bus = len(T)

print(bus)

Solution (Python):
def main():
    N, C, K = list(map(int, input().split()))
    T = [int(input()) for _ in range(N)]
    
    T.sort(reverse=True)
    arrival_time_from = T[0] - K
    cnt_bus, cnt_passenger = 1, 0
    for t in T:
        if t >= arrival_time_from and cnt_passenger < C:
            cnt_passenger += 1
        else:
            arrival_time_from = t - K
            cnt_passenger = 1
            cnt_bus += 1
    print(cnt_bus)


if __name__ == '__main__':
    main()

Solution (Python):
n, c, k = list(map(int, input().split()))
t = []

for i in range(n):
    t.append(int(input()))

t = sorted(t)

cnt = 1
cap = 1
first = t[0]

for i in range(1, n):
    if t[i] > first + k:
        cnt += 1
        cap = 1
        first = t[i]
    elif cap == c:
        cnt += 1
        cap = 1
        first = t[i]
    else:
        cap += 1

print(cnt)

Solution (Python):
n,c,k = map(int,input().split())
t = list(int(input()) for i in range(n))
t.sort()
ans = 0
i = 0
while i < n:
    a = t[i]
    j = i + 1
    z = 1
    for j in range(i+1,min(i+c,n)):
        if a+k >= t[j]:
            z += 1
        else:
            break
    i += z
    ans += 1
print(ans)

Solution (Python):
import math

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

t.sort()

ans = 0
tm = 0
passenger = 0

for i in range(n):
    if passenger == 0 or t[i] > tm + k or passenger == c:
        tm = t[i]
        passenger = 1
        ans += 1
    else:
        passenger += 1

print(ans)

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

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

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

t = [0 for _ in range(n)]

for i in range(n):
    t[i] = int(input())

t.sort()
cnt = 0
st = 0
while st < n:
    fire_time = t[st] + k
    wait_num = bisect.bisect_right(t,fire_time) - st

    if(wait_num <= c):
        st = wait_num + st
    else:
        st = st + c
    cnt += 1

print(cnt)

Solution (Python):
import bisect
import sys

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

if T[0]+K>=T[-1]:
  if N%C==0:
    print(N//C)
  else:
    print(N//C+1)
  sys.exit()
else:
  while True:
    t=bisect.bisect_right(T,T[i]+K)
    if t-i>C:
      i+=C
    else:
      i=t
    ans+=1
    if i==N-1:
      ans+=1
      break
    if i>N-1:
      i=N-1
      break
print(ans)

Solution (Python):
n,capacity,time_limit=map(int,input().split())
a=sorted([int(input()) for _ in range(n)])
c=0
start_num=0

while True:
    if start_num>=n:break
    start_time=a[start_num]
    for x in range(start_num,start_num+capacity):
        if x>=n:break
        if start_time+time_limit>=a[x]:start_num+=1
        else:break
    c+=1

print(c)

Solution (Python):




import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,c,k=MI()
time=[I() for i in range(n)]
time.sort()
lis=[[time[i],time[i]+k] for i in range(n)]

i=0
ans=0
count=0
while i<n:
    if count==c:
        count=0
        ans+=1
        
    elif count==0:
        count=1
        sup=lis[i][1]
        i+=1
        
    elif count<c:
        if lis[i][0]>sup:
            ans+=1
            count=0
            
        else:
            count+=1
            i+=1
            
    
if count!=0:
    ans+=1
    
print(ans)

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


time = T[0] + K
bus = 1
people = 1

for t in T[1:]:
    if t <= time and people < C:
        people += 1
    else:
        time = t + K
        bus += 1
        people = 1
    
print(bus)

Solution (Python):
N,C,K = map(int,input().split())
A = []
for i in range(N):
  temp = int(input())
  A.append(temp)
A.sort()
ans = 1
nxt = A[0]+K
cus = 0
for i in range(N):
  if A[i] <= nxt and cus < C:
    cus +=1
    continue
  else:
    nxt = A[i]+K
    cus = 1
    ans += 1
print(ans)

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




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

Solution (Python):
from bisect import bisect_right
N,C,K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])
cur = 0
cnt = 0
while cur<N:
    ind = bisect_right(T,T[cur]+K)
    if ind-cur<=C:
        cnt += 1
        cur = ind
    else:
        cnt += 1
        cur += C
print(cnt)

Solution (Python):
def solve():
  N, C, K = map(int, input().split())
  ans = 1
  cnt = 0
  T = [int(input()) for _ in range(N)]
  T.sort()
  for i in range(N):
    if i==0:
      now = T[i]
    cnt += 1
    if now+K<T[i] or cnt>C:
      ans += 1
      cnt = 1
      if i<N-1:
        now = T[i]
  return ans
print(solve())

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

ans = 0
now = T[0]
i = 0

while i < N:
    ans += 1
    num = 0
    while i < N and T[i] <= now+K and num < C:
        num += 1
        i += 1
    now = T[i]
print(ans)

Solution (Python):
from collections import deque

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


tl.sort()
q = deque(tl)

ans = 0
while q:
    ans += 1
    poped = q.popleft()
    lim = poped + k
    for i in range(c-1):
        if not q:
            break
        next_t = q[0]
        if next_t <= lim:
            q.popleft()
        else:
            break

print(ans)

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

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

while i<N:
    lim = T[i]+K
    ans += 1
    cnt = 0
    
    while i<N and cnt<C and T[i]<=lim:
        i += 1
        cnt += 1
        
print(ans)

Solution (Python):

import bisect
import math
N, c, k = map(int,input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
i=0

ans = 0
while True:
    t=bisect.bisect_right(T, T[i]+k)
    
    if t >= i+c:
        i += c
    else:
        i = t
    ans += 1
    
    if i >= N:
        break
print(ans)

Solution (Python):
def solve():
  N, C, K = map(int, input().split())
  T = [int(input()) for _ in range(N)]
  T.sort()
  cnt = 0
  ans = 1
  for i in range(N-1):
    if i==0:
      t = T[0]
    cnt += 1
    if T[i+1]>t+K or cnt>=C:
      ans += 1
      cnt = 0
      t = T[i+1]
  return ans
print(solve())

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

for i in range(n):
    t.append(int(input()))

t = sorted(t)
i = 1
machi = k
nori = 1
ans = 1

while i != n:
    if  machi-(t[i]-t[i-1]) >= 0 and nori+1 <= c:
        machi -= (t[i]-t[i-1])
        nori += 1
    else:
        ans += 1
        machi = k
        nori = 1
    i += 1

print(ans)

Solution (Python):
def main():
    N, C, K = map(int, input().split())
    T = list()

    for i in range(N):
        T.append(int(input()))
    T = sorted(T)

    ans = 0
    cap = 0
    t0 = T[0]

    for i in range(N):
        if T[i] <= t0 + K:
            if cap + 1 <= C:
                cap += 1
            else:
                ans += 1
                t0 = T[i]
                cap = 1
            
        else:
            ans += 1
            t0 = T[i]
            cap = 1

    if cap > 0:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import sys
n,c,k,*t = map(int, sys.stdin.read().split())
t.sort()

i=0
cnt=0
while i<n:
  departure=t[i]+k
  p=0
  for j in range(i,n):
    if t[j] > departure or p==c:
      break
    p+=1
  i+=p
  cnt+=1
print(cnt)

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

i=0
cnt=0
while i<n:
  departure=t[i]+k
  p=0
  for j in range(i,n):
    if t[j] > departure or p==c:
      break
    p+=1
  i+=p
  cnt+=1
print(cnt)

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

i=0
cnt=0
while i<n:
  departure=t[i]+k
  p=0
  for j in range(i,n):
    if t[j] > departure:
      break
    p+=1
  i+=min(c,p)
  cnt+=1
print(cnt)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, C, K = mapint()

Ts = [int(input()) for _ in range(N)]
Ts.sort()
last_cus = Ts[0]
cum = 1
bus = 0
for i in range(1, N):
    t = Ts[i]
    last_cus = min(last_cus, t)
    if t-last_cus>K:
        bus += 1
        cum = 0
        last_cus = t
    cum += 1
    if cum==C:
        bus += 1
        cum = 0
        last_cus = 10**18
if cum!=0:
    print(bus+1)
else:
    print(bus)

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

bs = 0
st = 0
ans = 0
for t in T:
    if bs == 0:
        st = t
    if bs == C or t-st>K:
        bs = 1
        st = t
        ans += 1
    else:
        bs += 1

if bs > 0:
    ans += 1
print(ans)

Solution (Python):










INF = 10**10


def solve(n,c,k,t):
  res = 1
  busCapacity = c
  time = 0
  for i in range(n):
    if i == 0:
      busCapacity -= 1
      time = t[0]
    elif busCapacity > 0 and time + k >= t[i]:
      
      busCapacity -= 1
    else:
      
      res += 1
      busCapacity = c-1
      time = t[i]

  return res



def main():
  N,C,K = map(int,input().split())
  T = list(sorted(int(input()) for _ in range(N)))
  print(solve(N,C,K,T))
  return

if __name__ == '__main__':
  main()

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7






N, C, K = getNM()
T = getArray(N)
T.sort()

pas = 1
time = T[0]
ans = 1

for i in range(1, N):
    
    if pas >= C:
        
        ans += 1
        pas = 1
        time = T[i]
        continue

    
    if T[i] > time + K:
        
        ans += 1
        pas = 1
        time = T[i]
        continue

    
    pas += 1

print(ans)

Solution (Python):
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
cnt = 0
pas = 0
time = T[0]
for i in range(N-1):
    pas += 1
    if pas and T[i] - time > K:
        pas,time = 1,T[i]
        cnt += 1
        continue
    if pas == C:
        pas,time = 0,T[i+1]
        cnt += 1
print(cnt+1+(pas and T[N-1]-T[N-2]>=K))

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

for i in range(len(T)):
    if res!=0 and time+K<T[i]:
        ans+=1
        res=1
        time=T[i]

    else:
        res+=1
        if res==1:
            time=T[i]
        if res==C:
            ans+=1
            res=0

if res>0:
    ans+=1

print(ans)

Solution (Python):
N,C,K=map(int,input().split())
T=sorted([int(input()) for i in range(N)])
cnt=0
i=0
while(i<N):
    j=i
    lim=T[i]+K
    while(j<N and T[j]<=lim and j-i+1<=C):
        j+=1
    cnt+=1
    i=j
print(cnt)

Solution (Python):


def main():
    N, C, K = map(int, input().split())
    T = sorted([int(input()) for i in range(N)])
    cnt = 0
    past_time = 0
    ans = 0
    for i in range(len(T)):
        if cnt != 0 and past_time != 0 and past_time + K < T[i]:
            ans += 1
            cnt = 1
            past_time = T[i]
        else:
            cnt += 1
            if cnt == 1:
                past_time = T[i]
            if cnt == C:
                ans += 1
                cnt = 0
    if cnt > 0:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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

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

for i in range(1,n):
    if t[i] <= rng and cnt < c:
        cnt += 1
    else:
        rng = t[i]+k
        cnt = 1
        ans += 1
ans += 1

print(ans)

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

if c == 1:
    print(n)
    exit()

end = tl[0] + k
passenger_cnt = 1
bus_cnt = 0
for i in range(1,n):
    
    if end >= tl[i]:
        passenger_cnt += 1
        if i == n-1:
            if passenger_cnt <= c:
                bus_cnt += 1
                break
            else:
                bus_cnt += 2
                break
        elif passenger_cnt == c:
            bus_cnt += 1
            passenger_cnt = 0
            end = tl[i+1]+k

    
    else:
        if i == n-1:
            bus_cnt += 2
            break
        bus_cnt += 1
        end = tl[i] + k
        passenger_cnt = 1

print(bus_cnt)

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

for _ in range(N):
  Ts.append(int(input()))
  
Ts.sort()

cnt = 0
i = 0

while i < N:
  j = i
  while j < N and Ts[j] <= Ts[i] + K and j - i + 1 <= C:
    j += 1
  cnt += 1
  i = j
  
print(cnt)

Solution (Python):

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, c, k = LI()
t = IR(n)
t.sort()
t_limit = list(map(lambda x: x+k, t))
ans = 0
i = 0
bus = 0
limit = 0
while i < n:
    
    if bus == 0:
        
        limit = t_limit[i]
        bus += 1
    elif bus < c:  
        
        
        if t[i] <= limit:  
            
            bus += 1
        else:  
            
            ans += 1
            bus = 1
            limit = t_limit[i]
    else:  
        ans += 1
        bus = 1
        limit = t_limit[i]
    i += 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 = sorted(t)
ans = 0
s = 0
u = float("Inf")
for i in range(n-1):
    s += 1
    u = min(u, t[i])
    if s == c or t[i+1] > u + k:
        ans += 1
        s = 0
        u = float("Inf")
print(ans+1)

Solution (Python):
n,c,k=map(int, input().split())
t=[int(input()) for _ in range(n)]
t.sort()
tmp_lim=t[0]+k
num_bus=0
num_person=1
for i in range(1, n):
    if tmp_lim<t[i] or c<=num_person:
        num_bus+=1
        tmp_lim=t[i]+k
        num_person=1
    else:
        num_person+=1
    
print(num_bus+1)

Solution (Python):

_, c, k, *t = map(int, open(0).read().split())
t.sort()
n = 0
f = t.pop(0)
p = 1
for i in t:
    if i > f + k or p >= c:
        n += 1
        p = 1
        f = i
    else:
        p += 1
print(n + (c > 0))

Solution (Python):
n, c, k = map(int, input().split())
t_l = []
for _ in range(n):
    t_l.append(int(input()))
t_l.sort()
ans = 0
cnt = 0
for t in t_l:
    if cnt == 0:
        t1 = t
    if t <= t1 + k:
        cnt += 1
        if cnt == c:
            cnt = 0
            ans += 1
    else:
        cnt = 1
        ans += 1
        t1 = t
if cnt != 0:
    ans += 1
print(ans)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, C, K = LI()
    T = [I() for _ in range(N)]
    T.sort()

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

    print(ans)

if __name__ == '__main__':
    resolve()

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

sortT = sorted(T)
pre_ti = sortT[0]
ans = 1
c = 0
for ti in sortT:
    c += 1
    if ti - pre_ti <= K and c <= C:
        continue
    c = 1
    ans += 1
    pre_ti = ti

print(ans)

Solution (Python):
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
ans=0
num=0
for i in range(n+3):
    if num>=n:
        break
    num2=t[num]+k
    ans+=1
    for j in range(c-1):
        num+=1
        if num==n:
            break
        if t[num]>num2:
            num-=1
            break
    num+=1
print(ans)

Solution (Python):
N, C, K = list(map(int, input().split()))
T = [int(input()) for _ in range(N)]
T.sort()
i = 0
res = 0
while i < N:
    j = 0
    while i < N and j < C and T[i] - T[i - j] <= K:
        i += 1
        j += 1
    res += 1
print(res)

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

bus_time = False
human = 0
count = 0
for i in range(N):
    now = T[i]
    if bus_time == False:
        bus_time = now + K
        human = 1
        count += 1
    else:
        if now <= bus_time and human < C:
            human += 1
        else:
            bus_time = now + K
            human = 1
            count += 1

print(count)

Solution (Python):
def solve():
    N,C,K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    
    num = 1
    bus_pos = T[0]
    ret = 1
    for t in T[1:]:
        
        if num < C and t <= bus_pos+K:
            num += 1
        else:
            ret += 1
            num = 1
            bus_pos = t
            
    print(ret)
    
solve()

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

T.sort()
s = -(10**10)
cnt = 0
res = 0
for t in T:
    if s+K < t:
        res += 1
        s = t
        cnt = 0
    if cnt == C:
        res += 1
        s = t
        cnt = 0
    cnt += 1

print(res)

Solution (Python):
N, C, K = map(int,input().split())
T = []
ans = 0 
num = 1 
for i in range(N):
    ans = int(input())
    T.append(ans)
T = sorted(T)
ans = 0
S =  T[0] + K 
for i in T:
    if i <= S and ans < C:
        ans += 1
    else:
        num += 1
        S = i + K
        ans = 1
print(num)

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


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

for i in range(N):
	T = int(input())
	t = [T, T + K]
	times.append(t)

times.sort(key=lambda x: x[1])

ans = 0
count = 0
departure_time = 0

for t in times:
	if count == 0:
		departure_time = t[1]
		count = 1
	elif count < C:
		if t[0] <= departure_time:
			count += 1
		else:
			ans += 1
			departure_time = t[1]
			count = 1
	elif count == C:
		ans += 1
		departure_time = t[1]
		count = 1

if count <= C:
	ans += 1

print(ans)

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
from math import floor
def main():
    n, c, k = map(int, input().split())
    times = defaultdict(int)
    for _ in range(n):
        times[int(input()) + k] += 1
    
    ts = dict(sorted(times.items()))

    r = 0
    busg = c 
    busstart = - k - 1
    for tse in ts:
        if busstart + k < tse: 
            r += floor(ts[tse] / c) 
            nokori = ts[tse] % c
            if nokori: 
                r += 1
                busg = c - nokori
                busstart = tse
            else:
                busstart = -k - 1
        else:
            if busg >= ts[tse]: 
                busg -= ts[tse]
            else:             
                r += floor(ts[tse] / c)
                nokori = ts[tse] % c
                if nokori:
                    r += 1
                    busg = c - nokori
                    busstart = tse
                else:
                    busstart = -k - 1
    print(r)

if __name__ == '__main__':
    main()

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

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

t.sort()
i = 0
count = 0
while i < n:
    
    j = i + 1
    if i == n - 1:
        count += 1
        break
    while t[j] - t[i] <= k and j < i + c:
        j += 1
        if j == n:
            i = j
            break

    i = j
    count += 1

print(count)

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

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

tmp, cnt, ans = 0, 0, 0
for t in T:
  if not tmp:
    tmp = t + K
    cnt += 1
    ans += 1
  elif tmp < t or cnt == C:
    tmp = t + K
    cnt = 1
    ans += 1
  else:
    cnt += 1
    
print(ans)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    ans = 0
    oldest = t[0]
    cnt = 1
    for x in t[1:]:
        if oldest + k < x or cnt == c:
            ans += 1
            cnt = 0
            oldest = x
        cnt += 1

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


if __name__ == '__main__':
    main()

Solution (Python):
n,c,k=map(int,input().split())
T=[int(input()) for i in range(n)]
T.sort()
ans=1
now=T[0]
pas=0 

for t in T:
    pas+=1
    if t>now+k or pas>c:
        ans+=1
        now=t
        pas=1

print(ans)

Solution (Python):
def resolve():
    '''
    code here
    '''
    N, C, K = [int(item) for item in input().split()]
    Ts = [int(input()) for _ in range(N)]
    Ts.sort()

    res = 0
    temp_psg = 0
    lim = Ts[0] + K

    for i in range(N):
        temp_psg += 1
        if Ts[i] > lim:
            res += 1
            temp_psg = 1
            lim = Ts[i] + K
        else:
            if temp_psg == C and i < N-1:
                res += 1
                temp_psg = 0
                lim = Ts[i+1] + K
        
    
    if temp_psg > 0:
        res += 1
    print(res)


if __name__ == "__main__":
    resolve()

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd





def solve():
    n, c, k = [int(x) for x in input().split()]
    a = []
    for _ in range(n):
        a.append(int(input()))
    a.sort()
    ans = 0
    bus = 0
    deadline = 0
    for t in a:
        if t <= deadline and bus < c:
            bus += 1
        else:
            bus = 1
            ans += 1
            deadline = t + k
    print(ans)



t = 1

for case in range(1,t+1):
    ans = solve()


"""

abc

"""

Solution (Python):






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





T = sorted(T)
ans = 0
p = 0
t = 0
for i in range(N):
    if t == 0:
        t = T[i]
    if T[i] <= t+K:
        p += 1
        if p >= C:
            ans += 1
            p = 0
            t = 0
    else:
        t = T[i]
        ans += 1
        p = 1
if p > 0:
    ans += 1
print(ans)