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):

if False:
    N,M=map(int,input().split())
    case=[i for i in range(N+1)]
    for _ in range(M):
        now=int(input())
        i=case.index(now)
        case[i]=case[0]
        case[0]=now
        
    for i in range(1,N+1):
        print(case[i])


if False:
    N=int(input())-1
    N=N%30
    ans=list(range(1,7))
    for i in range(N+1):
        ans[i%5],ans[i%5+1]=ans[i%5+1],ans[i%5]
        
    print(''.join(map(str,ans)))


if True:
    N,C,K=map(int,input().split())
    T=[int(input()) for _ in range(N)]
    T.sort()
    cnt=1
    pas=1 
    tim=K+T[0] 
    
    for i in range(1,N):
        t=T[i]
        if tim<t or pas>=C:
            cnt+=1
            tim=t+K
            pas=1
        else:
            pas+=1
        
    print(cnt)

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

first = T[0]
count = 0
res = 0
for i in range(N):
    if count < C and T[i] <= first + K:
        count += 1
    else:
        res += 1
        first = T[i]
        count = 1
print(res + 1)

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

first = T[0]
count = 0
res = 0
for i in range(N):
    if count < C and T[i] <= first + K:
        count += 1
    else:
        res += 1
        first = T[i]
        count = 1
print(res + 1)

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

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

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

T.sort()
ans=1
mem=1
s=T[0]

for i in range(N):
    if T[i]>s+K or mem>=C:
        ans+=1
        s=T[i]
        mem=1
    else:
        mem+=1
print(min(ans,N))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = sorted([int(readline()) for i in range(n)])
cnt = 0
ans = 1
time = t[0] + k
for i in range(n):
    if cnt >= c or time < t[i]:
        ans += 1
        cnt = 0
        time = t[i] + k
    cnt += 1
print(ans)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,c,k = m()

t = []

for i in range(n):
    t.append(onem())
t.sort()

po = 1

jo = 1

ti = t[0] + k

for i in range(1,n):
    on = t[i]
    if ti < on:
        po += 1
        jo = 1
        ti = on + k
    else:
        if jo + 1 <= c:
            jo += 1
        else:
            po += 1
            jo = 1
            ti = on + k
print(po)

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, C, K = MAP()
T = [INT() for _ in range(N)]

T.sort()

ans = 1
cnt = 1
t_limit = T[0]+K

for i in range(1, N):
	if cnt == C:  
		t_limit = T[i]+K
		cnt = 1
		ans += 1
	elif t_limit >= T[i]:  
		cnt += 1
	else:  
		t_limit = T[i]+K
		cnt = 1
		ans += 1
print(ans)

Solution (Python):
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
cnt = 0
while T:
    T_min = T[0]
    for _ in range(C):
        if T[0] <= T_min + K:
            T.pop(0)
            if not T:
                break
        else:
            break
    cnt += 1
print(cnt)

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




j=0
k=0
p=[]  
bus=0
t=0

while k<N:
  
  if j<N:
    if T[j]<=U[k]:
      
      p.append(j)
      t=T[j]
      j +=1
      
      if len(p)>=C:
        
        k=max(p)+1
        p=[]
        
        bus +=1
    else:
      
      t=U[k]
      k=max(p)+1
      
      p=[]
      
      bus +=1
  else:
    t=U[k]
    p=[]
    
    bus +=1
    k =N
    
print(bus)

Solution (Python):
def main():
    n, c, k, *t = map(int, open(0).read().split())
    t.sort()
    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
            p = 1
            l = v + k
    print(cnt)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

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

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

cnt = 1
teiin = 1
for i in range(n):
    if i == 0:
        mati = t[i] + k
    else:
        if teiin < c:
            if mati >= t[i]:
                teiin += 1
            else:
                cnt += 1
                teiin = 1
                mati = t[i] + k
        else:
            cnt += 1
            teiin = 1
            mati = t[i] + k


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()
x = 0
ans = 1
w = T[0] + k
for i in range(n):
    if T[i] <= w and x < c:
        x += 1
    else:
        ans += 1
        x = 1
        w = T[i]+k
print(ans)

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
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)

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

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






count = 0
i = 0
while i < N:
    timax = T[i] + K
    
    c = 0
    count += 1
    while i < N and c < C and T[i] <= timax:
        c += 1
        i += 1
print(count)

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

t.sort()

diff = 0
cnt = 1
ans = 0
for i in range(n - 1):
    diff += abs(t[i + 1] - t[i])
    cnt += 1
    if diff > k or cnt > c:
        cnt = 1
        diff = 0
        ans += 1
print(ans + 1)

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

for t in T:
    if t>base+K or count>=C:
        answer+=1
        base=t
        count=1
    else:
        count+=1
    
answer+=1

print(answer)

Solution (Python):
from math import ceil


def main():
    passengers, capacity, waiting_limit = map(int, input().split())
    arrive_time = [int(input()) for _ in range(passengers)]
    arrive_time.sort()
    count = 0
    waiting = 0
    waiting_since = -1
    for t in arrive_time:
        if waiting_since > 0 and waiting_since + waiting_limit < t or capacity <= waiting:
            count += ceil(waiting / capacity)
            waiting = 0
            waiting_since = -1
        waiting += 1
        if waiting_since < 0:
            waiting_since = t
    count += ceil(waiting / capacity)
    print(count)


if __name__ == '__main__':
    main()

Solution (Python):

import sys

def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N,C,K = MAP()
    T = [INT() for _ in range(N)]
    T.sort()
    passengers = 1
    deadline = T[0]+K
    answer = 0

    for i in range(1,N):
        if passengers<C and T[i]<=deadline:
            passengers += 1
        elif passengers == C or T[i]>deadline: 
            passengers = 1
            answer += 1
            deadline = T[i]+K
    if passengers>0:
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()

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

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

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

if C == 1:
    print(N)
    exit()

ans = 1
time = -1
for i,t in enumerate(T):
    if time < 0:
        cnt, time = 1, t + K
    elif t <= time:
        cnt += 1
    else:
        ans += 1
        cnt, time = 1, t + K
    
    if cnt == C:
        time = -1
        ans += 1

print(ans)

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

cnt = 0
tmp = 0
jousha = 0
for t in T:
    jousha += 1
    if jousha == 1:
        tmp = t

    if t - tmp > K:
        cnt += 1
        jousha = 1
        tmp = t
        continue

    if jousha == C:
        tmp = 0
        cnt += 1
        jousha = 0
        continue
if tmp != 0:
    cnt+=1
print(cnt)

Solution (Python):
n,c,k = map(int,input().split())
T = [int(input()) for _ in range(n)]
T.sort()
count = 0
ans = 0
time = 0
for t in T:
  if count == 0:
    time = t
  if time +k < t:
    count = 0
    time = t
    ans += 1
  count += 1
  if count == c:
    ans += 1
    count = 0
    continue
else:
  if count>0:
    ans += 1
print(ans)

Solution (Python):
N, C, K = map(int,input().split())
T = sorted([int(input()) for _ in range(N)])
ans, cnt = 0, 0
st = T[0]
for i in range(N):
  if T[i] > st + K or cnt == C:
    ans += 1
    cnt = 1
    st = T[i]
  else:
    cnt += 1
print(ans+1)

Solution (Python):
N,C,K=map(int,input().split())
T=[int(input()) for _ in range(N)]
T.sort()
t=T[0]
cnt=0
mem=0
for i in range(N):
    if (t+K<T[i])or(mem==C):
        cnt=cnt+1
        t=T[i]
        mem=1
    else:
        mem=mem+1
print(cnt+1)

Solution (Python):
import bisect
import math
n, c, k = list(map(int, input().split()))
t = [0] * n
for i in range(n):
    t[i] = int(input())
t.sort()
bus_count = 0
pre_index = 0
index = 0
while index < n:
    
    leave = t[index] + k
    count = 0
    bus_count += 1
    while index < n and count < c and leave >= t[index]:
        count += 1
        index += 1
print(bus_count)

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

j = 0
count = 1
while j + count in range(n):
  if a[j + count] <= a[j] + k and count < c:
    count = count + 1
  else:
    bus = bus + 1
    j = j + count
    count = 1
print(bus)

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

T.sort()

bus = 0  
wait = 0  
dep = None  

for ti in T:
    if dep is None:  
        dep = ti + K
        bus += 1
    elif ti > dep:  
        dep = ti + K
        bus += 1
        wait = 0

    wait += 1

    if wait == C:  
        dep = None
        wait = 0

print(bus)

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, C, K = (int(i) for i in input().split())
    T = [int(input()) for i in range(N)]
    T.sort()
    from collections import deque
    que = deque([])
    ans = 0
    for t in T:
        if que and que[0] < t:
            for _ in range(C):
                if que:
                    que.popleft()
                else:
                    break
            ans += 1
        que.append(t+K)
        if len(que) >= C:
            for _ in range(C):
                if que:
                    que.popleft()
                else:
                    break
            ans += 1
    if que:
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, c, k = map(int, input().split())
    t = [None]*n
    for i in range(n):
        t[i] = int(input())
    t.sort()
    ans = 0
    l = 0
    x = t[0]+k
    for r in range(1, n):
        if x < t[r] or c < r-l+1:
            ans += 1
            l = r
            x = t[r] + k
        if r == n-1:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]+[10**10]
t.sort()
b=1
p=0
if c==1:
  print(n)
  exit()
while p<n:
  l=t[p]+k
  pp=1
  f=1
  while pp<c and f:
    p+=1
    if t[p]<=l:
      pp+=1
      if pp==c:
        p+=1
    else:
      f=0
  if p<n:
    b+=1
print(b)

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

min_t = 0
i = 0
while i < N:
    ans += 1
    start = i
    while i < N and T[i] - T[start] <= K and i - start < C:
        i += 1
print(ans)

Solution (Python):




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


    

if not(flg):
    ans += 1

print(ans)

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

Solution (Python):
n, c, k = [int(e) for e in input().split()]
t = [] 
bus_count = 0
time_diff = 0
stock = 0
first_customer_arrival_time = 0
i = 0

for _ in range(n):
    t.append(int(input()))
t.sort()
while i < n-1:
    
    if stock == 0:
        first_customer_arrival_time = t[i]
        stock = 1
    else:
        stock += 1
    time_diff = t[i+1] - first_customer_arrival_time
    
    if time_diff > k or stock == c:
        bus_count += 1
        stock = 0
        time_diff = 0 
    i += 1

bus_count += 1
print(bus_count)

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

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

T.sort()

cnt = 0
passengers = 0
due = 0
for t in T:
  if passengers == 0:
    cnt +=1
    passengers += 1
    due = t + K
  elif passengers > 0 and passengers < C and t <= due:
    passengers +=1
  elif t > due or passengers == C:
    passengers = 1
    due = t + K
    cnt +=1
  

print(cnt)

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

time = 0
limit = st[0]+k

d = {}
d[limit] = []
ans = 1
for i, p in enumerate(st):
  if p <= limit and len(d[limit]) < c:
    d[limit].append(p)
  else:
    limit = p + k
    ans += 1
    d[limit] = [p]

print(ans)

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

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


if C == 1:
    print(N)
    exit()

ans = 0
for i in range(N):
    t = T[i]
    if t == -1:
        continue
    remain = C - 1
    for j in range(i + 1, N):
        tj = T[j]
        if tj == -1:
            continue
        if tj > t + K:
            break
        remain -= 1
        T[j] = -1
        if remain == 0:
            break
    ans += 1

print(ans)

Solution (Python):
from sys import stdin

def main():
    input = stdin.readline

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

    T = [0] * N

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

    T.sort()

    bus_num = 1
    jyokyaku = 1
    bus_start = T[0]

    for i in range(1,N):
        jyokyaku = jyokyaku + 1
        
        if(C < jyokyaku):
            bus_num = bus_num + 1
            bus_start = T[i]
            jyokyaku = 1
        elif(T[i] - bus_start > K):
            bus_num = bus_num + 1
            bus_start = T[i]
            jyokyaku = 1

    
    print(bus_num)


if __name__ == "__main__":
    main()

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

p = 0
w = t[0]
res = 0

for i in range(n):
    p += 1
    if t[i]-w > k:
        p = 1
        res += 1
        w = t[i]
        if i==n-1:
            res += 1
    elif c == p:
        p = 0
        res += 1
        if i != n-1:
            w = t[i+1]
    else:
        if i==n-1:
            res += 1
print(res)

Solution (Python):
n, c, k = map(int, input().split())
dat = []
for _ in range(n):
    dat.append(int(input()))
dat.sort()
cn = 1
nt = dat[0] + k
res = 1
for i in range(1, n):
    
    
    if cn == c:
        
        cn = 1
        nt = dat[i] + k
        res += 1
        continue
    if dat[i] > nt:
        
        cn = 1
        nt = dat[i] + k
        res += 1
        continue
    cn += 1
print(res)

Solution (Python):
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
 
count=1
cus=0
pre=T[0]
for t in T:
    if C>cus and pre+K>=t:
        cus+=1
    else:
        cus=1
        pre=t
        count+=1
print(count)

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

cnt = 0
ans = 0
lst = [int(input()) for _ in range(N)]
lst = sorted(lst)
next_t = 10**10
for t in lst:
  next_t = min(t+K,next_t)
  if (t > next_t):
    ans += 1
    cnt = 0
    next_t = t+K
    
  cnt += 1
  if (cnt == C):
    ans += 1
    cnt = 0
    next_t = 10**10
    
if (cnt > 0):
  ans += 1
print(ans)

Solution (Python):
n, c, k = (int(x) for x in input().split())
t = []
for _ in range(n): t.append(int(input()))
t.sort()
a = c_ = idx = 0
t_ = t[0]
while idx < n:
    if t[idx] - t_ > k or c_ == c :
        a += 1
        t_ = t[idx]
        c_ = 0
    elif idx == n - 1:
        idx += 1
        a += 1
    else:
        idx += 1
        c_ += 1
print(a)

Solution (Python):


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

ans = 1 
count = 0 
T.sort()
ts = T[0] 


for t in T:
    if t-ts > K or count == C: 
        ans += 1 
        ts = t 
        count = 1 
    else:
        count += 1 
print(ans)

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

Solution (Python):
N,C,K,*T=map(int, open(0).read().split())
T=sorted(T)
ans=0
cap=0
s=-1
for t in T:
    if t<=s and cap>0:
        cap-=1
    else:
        s=t+K
        cap=C-1
        ans+=1
print(ans)

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

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

bus = []

count = 0
for i in range(N):
    if count == 0:
        first = T[i]
        count += 1
    else:
        if T[i] - first <= K:
            count += 1
        else:
            bus.append(count)
            first = T[i]
            count = 1
    if count >= C:
        bus.append(count)
        count = 0

if count > 0:
    bus.append(count)

print(len(bus))

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

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

bus = []
indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: T[i])

count = 0
for i in range(N):
    if count == 0:
        first = T[sorted_indexes[i]]
        count += 1
    else:
        if T[sorted_indexes[i]] - first <= K:
            count += 1
        else:
            bus.append(count)
            first = T[sorted_indexes[i]]
            count = 1
    if count >= C:
        bus.append(count)
        count = 0

if count > 0:
    bus.append(count)

print(len(bus))

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

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

    else:
        ans+=1
        time=t[i]
        cnt=1
print(ans+1)

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

users = sorted(users, reverse=False)

ans = 0
pos = 0
start = 0

while True:
    count = 0

    if pos == N:
        break
        
    start = users[pos]

    for i in range(C):
        if pos+i < N and users[pos+i] <= start+K:
            count += 1
        else:
            break
    pos += count

    ans += 1


print(ans)

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

def main():
    N, C, K = map(int, input().split())
    times = sorted([int(input()) for _ in range(N)])
    passengers = []
    ans = 0
    while True:
        if len(times) == 0:
            if len(passengers) > 0:
                ans += 1
            break
        elif len(passengers) == 0:
            passengers.append(times.pop(0))
        elif times[0] - passengers[0] <= K:
            passengers.append(times.pop(0))
        elif times[0] - passengers[0] > K:
            ans += 1
            passengers = []

        if len(passengers) == C:
            ans += 1
            passengers = []
    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()
bus_time = [T[0]+K]
bus_num = [0]
t = 0

for i in range(N) :
    if bus_num[t] <= C - 1 :
        if bus_time[t] >= T[i] :
            bus_num[t] += 1
        else :
            t += 1
            bus_time.append(T[i]+K)
            bus_num.append(1)
    else :
        t += 1
        bus_time.append(T[i]+K)
        bus_num.append(1)

print(len(bus_time))

Solution (Python):
def boundary_find(array, limit):
    ceil = len(array) - 1 
    floor = 0
    while 1:
        center = (ceil + floor) // 2
        if array[center] <= limit:
            floor = center
        else:
            ceil = center
        if ceil - floor == 1:
            break
    return ceil

n, c, k = map(int, input().split())
tList = [int(input()) for _ in range(n)]
tList.sort()
count = 0
first = 0
while 1:
    limit = tList[first] + k
    last = min(first + c, n)
    if tList[last - 1] <= limit:
        mark = last
    else:
        mark = boundary_find(tList, limit)
    count += 1
    first = mark
    if first == n:
        break
print(count)

Solution (Python):
from collections import deque

def main():
    N,C,K = map(int,input().split())
    T = deque(sorted([int(input()) for _ in range(N)]))
    ans = 0
    while len(T) != 0:
        tmp = T.popleft()
        limit = tmp + K
        count = 1
        while count < C and len(T) != 0:
            tmp = T.popleft()
            if tmp > limit:
                T.appendleft(tmp)
                break
            else:
                count += 1
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):




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

T_list = [int(input().strip()) for _ in range(N)]
T_list.sort()


num_bus=0
i=0
while i < len(T_list):

    
    member_bus=0
    break_flg=False
    for j in range(C):
        if (i+j) < len(T_list):
            if T_list[i+j] <= (T_list[i] + K):
                member_bus += 1
            else:
                break_flg=True
        else:
            break_flg=True
        
        if break_flg:
            break

    num_bus += 1
    i = i + member_bus
            

print(num_bus)

Solution (Python):
from collections import deque

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

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

T = sorted(T)
con = 0
bus = deque()

for i in range(N):
  t = T[i]
  
  
  
  
  if len(bus) == 0 or (t - bus[0] <= K and len(bus) < C):
    bus.append(t)
  else:
    bus = deque()
    con += 1
    bus.append(t)
    
if len(bus) > 0:
  con += 1
  
print(con)

Solution (Python):
N,C,K=map(int,input().split(' '))
T=sorted([int(input()) for i in range(N)])
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)

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from math import ceil

n, c, k = na()
T = nin(n)
T.sort()

ans = 0
i = 0
while i < n:
    m = T[i] + k
    cnt = 0
    while i < n and T[i] <= m and cnt < c:
        i += 1
        cnt += 1
    ans += 1
print(ans)

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

def solve(i):
    global N, C, K, T
    left = C - 1
    if i == N - 1:
        return i
    if left == 0:
        return i
    for j in range(i + 1, N):
        
        if T[i] + K < T[j]:
            return j - 1
        else:
            left -= 1
        if left == 0 or j == N - 1:
            return j

buses = 0
start = -1
for i in range(N):
    if start < i:
        start = solve(i)
        buses += 1

print(buses)

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

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

t=[]
for i in range(n):
 start_t=int(input())
 t.append([start_t,start_t+k])
t=sorted(t,key=lambda x:x[1])

ans=0
inx=0
while inx<n:
 ans+=1
 time=t[inx][1]

 for i in range(c):
  if inx==n:
   break
  if time>=t[inx][0]:
   inx+=1
  else:
   break

print(ans)

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

ans = 1
bus = C
time = T[0] + K
for i in T:
    
    if (bus > 0) & (i <= time):
        bus -= 1
    
    else:
        bus = C - 1
        time = i + K
        ans += 1

print(ans)

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

T.sort()

ans = 1
bus = T[0]
l = 1
for i in range(1,N):
    if T[i]-bus <= K and l <= C-1:
        l += 1
    else:
        bus = T[i]
        l = 1
        ans += 1
print(ans)

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

T.sort()

ans = 1
bus = [T[0]]
l = 1
for i in range(1,N):
    if T[i]-bus[0] <= K and l <= C-1:
        l += 1
    else:
        bus = [T[i]]
        l = 1
        ans += 1
print(ans)

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

T.sort()

ans = 1
bus = [T[0]]
for i in range(1,N):
    if T[i]-bus[0] <= K and len(bus) <= C-1:
        bus.append(T[i])
    else:
        bus = [T[i]]
        ans += 1
print(ans)