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 math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,c,k = lr()
t = [ir() for i in range(n)]
t.sort()
ans = 0
count = 0
ind = 0
while ind < n:
    now = t[ind]
    while ind < n and t[ind] <= now+k and count < c:
        ind+=1
        count+=1
    ans+=1
    count=0
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()
ans = 1
cnt = 0
time = T[0]
for t in T:
  if (t<=time+K) and (cnt<C):
    cnt += 1
  else:
    ans += 1
    cnt = 1
    time = t
print(ans)

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

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	N,C,K = linput()
	vA = vinput(N)
	vA.sort()
	
	
	res = 0
	
	cnt = 0 
	x = 0   
	
	for a in vA:
		if a<=x and cnt<C:
			cnt += 1
			continue
		cnt = 1
		res += 1
		x = a+K
	
	
	
	print(res)

if __name__ == "__main__":
	main()

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

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	N,C,K = linput()
	vA = vinput(N)
	vA.sort()
	
	
	res = 0
	i = 0   
	cnt = 0 
	x = 0   
	while i<len(vA):
		if not cnt:
			cnt += 1
			x = vA[i]+K
			i += 1
			res += 1
		elif cnt<C:
			if vA[i]<=x:
				cnt += 1
				i += 1
			else:
				cnt = 1
				x = vA[i]+K
				res += 1
				i += 1
		else:
			cnt = 1
			x = vA[i]+K
			res += 1
			i += 1
	
	
	
	print(res)

if __name__ == "__main__":
	main()

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


from collections import deque

T = deque(sorted(T))

t_ref = T[0]

bus = 0
member = 0

while T != deque([]):
    t = T[0]
    if t - t_ref <= K and member < C:
        member += 1
        t_tmp = T.popleft()


    else:
        bus += 1
        member = 0
        t_ref = T[0]


if member > 0:
    bus += 1

print(bus)

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

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

n = 0
cnt = 0
while n < N:
    target = T[n]+K
    nb = n
    n = bisect.bisect_right(T,target)
    if n - nb > C:
        n = nb + C
    cnt += 1
print(cnt)

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

first = t_li[0]

passengers = 1

busses = 1

for i in range(1, N):
    if passengers < C and t_li[i] - first <= K:
        
        passengers += 1
    else:
        
        busses += 1
        passengers = 1
        first = t_li[i]
print(busses)

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

T.sort()

ans = 0
p = C
d_time = 0

for i in range(N):
    if T[i] - d_time > K or p == C:
        ans += 1
        d_time = T[i]
        p = 1
    else:
        p += 1

print(ans)

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

total = 1
s_time = T[0]
count = 1
for i in range(1, N):
    count += 1
    if s_time + K < T[i] or count > C:
        s_time = T[i]
        count = 1
        total += 1
print(total)

Solution (Python):

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

ans = 0
busp = 0
machi = 0

for i in a:
    if busp == 0:
        busp += 1
        machi = i + k
        if busp >= c:
            ans += 1
            busp = 0
            machi = 0

    elif i <= machi:
        busp += 1
        if busp >= c:
            ans += 1
            busp = 0
            machi = 0

    elif i > machi:
        ans += 1
        busp = 1
        machi = i + k

if busp >= 1:
    ans += 1

print(ans)

Solution (Python):
from collections import deque


N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
d = deque(T)
count = 0
while len(d) > 0:
    t = d.popleft() + K
    for i in range(C-1):
        if len(d) > 0 and d[0] <= t:
            d.popleft()
        else:
            break
    count += 1

print(count)

Solution (Python):
n, c, k=map(int,input().split())
bus=1
pssgr=0
fst_pssgr=0
t_lst=[]
for i in range(n):
    t=int(input())
    t_lst.append(t)

t_lst.sort()

for i in range(n):
    if t_lst[i]-t_lst[fst_pssgr]>k:
        bus+=1
        pssgr=1
        fst_pssgr=i
        continue
    pssgr+=1
    if pssgr==c and i<n-1:
        bus+=1
        pssgr=0
        fst_pssgr=i+1

print(bus)

Solution (Python):


import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
MOD = pow(10, 9) + 7

N, C, K, *T = map(int, read().split())
T.sort()

acc = 0
n_bus = 0
cnt = 0
for t in T:
    if cnt == 0:
        acc = t + .5
        n_bus += 1
        cnt = 1
        if cnt == C:
            cnt = 0
        continue

    if t - acc <= K:
        cnt += 1
    else:
        cnt = 1
        acc = t + .5
        n_bus += 1
        continue
    if cnt == C:
        cnt = 0

print(n_bus)

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

T = []

for i in range(N):
    T.append(int(input()))
T.sort()
res = 0
cnt = 0
i = 0

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, c, k = MI()
    T = sorted([I() for _ in range(n)])
    cnt = 0
    i = 0
    while i < n:
        cnt += 1
        lim = T[i] + k
        cap = 1
        for j in range(i+1, min(n, i+c)):
            if T[j] <= lim:
                cap += 1
            else:
                break
        i += cap
    print(cnt)
if __name__ == '__main__':
    main()

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

ans = 1
now = t[0]
cnt = 0
for i in t:
    cnt += 1
    if i > now + k or cnt > c:
        ans += 1
        cnt = 1
        now = i

print(ans)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n,c,k = list(map(int, input().split()))
ts = [None]*n
for i in range(n):
    ts[i] = int(input())
ts.sort()
ans = 0
last = -float("inf")
num = 0
for t in ts:
    if last<t or num==c:
        last = t+k
        num = 1
        ans += 1
    else:
        num += 1
print(ans)

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

limit = t[0] + k
num = 1
cnt = 1
for i in range(1, n):
  if limit < t[i] or num == c:
    num = 1
    limit = t[i] + k
    cnt += 1
  
  else:
    num += 1
print(cnt)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N, C, K =I()
T = []
for i in range(N):
    t = k()
    T.append(t)

T.sort()
a = T[0]+K
pas = 0
ans = 1

for i in range(N):
    if pas == C or a < T[i]:
        pas = 1
        ans += 1
        a = T[i]+K
    else:
        pas += 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()
ans=1
pas=0
depa=t[0]+k

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

Solution (Python):
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, c, k = MAP()
t = sorted(list(INT() for i in range(n)))

ans = 0
num = 0
time = inf
for i in range(n):
        if t[i]<=time+k and num < c:
                num += 1
        elif t[i]>time+k or num == c:
                ans += 1
                num = 1
                time = inf
        time = min(time, t[i])
ans += 1
print(ans)

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

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_right(la, lak[ind]) - ind
    ind += min(ride, c)
    ans += 1

print(ans)

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

a.sort()
ans = 1
count = 0
pre = a[0]
for i in range(N):
    if count == 0:
        pre = a[i]
    if count >= C or a[i]-pre > K:
        count = 0
        ans += 1
        pre = a[i]
    count += 1
print(ans)

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

T = sorted([int(input()) for _ in range(N)])
ans = 1
count = 0
time = 0
start = -1
for i in range(N):
  if start == -1:
    start = i
  if i != N-1:
    if T[i+1] > T[start] + K or i+1 -start == C:
      ans += 1
      start = -1
  
print(ans)

Solution (Python):
n, c, k = map(int, input().split())
T = [0] * n
for i in range(n):
    T[i] = int(input())
 
T.sort()
ans, s, m = 0, 0, 0
 
for t in T:
    if m == 0:
        s = t
        m = 1
        ans += 1
    else:
        if t <= s + k:  
            m += 1
        else:
            s = t
            m = 1
            ans += 1
    if m == c:
        m = 0
 
print(ans)

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

for t in T:
    if m == 0:
        s = t
        m = 1
        ans += 1
    else:
        if t <= s + k:
            m += 1
        else:
            s = t
            m = 1
            ans += 1
    if m == c:
        m = 0
 
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read






def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))

from math import *


def main():
	n,c,k=MI()
	T=[II() for _ in range(n)]
	T.sort()
	
	
	ans=0
	cnt=0
	now=0
	
	i=0
	
	while i<n:
		
		now=T[i]
		ans+=1
		cnt=1
		while i<n and cnt<=c and now+k>=T[i]:
			i+=1
			cnt+=1
		cnt=0
	
	print(ans)
	
	
	
	
	


	
if __name__ == "__main__":
	main()

Solution (Python):
import sys
N, C, K = map(int, input().split())
A = list(map(int, sys.stdin.readlines()))+[10**10]
A.sort()
a, c, t = 0, 1, A[0]+K
for i in A[1:]:
    if i <= t and c < C:
        c += 1
    else:
        t, c = i + K, 1
        a += 1
 
print(a)

Solution (Python):
n, c, k = map(int, input().split())
l = [int(input()) for _ in range(n)]
l = sorted(l)
val, ans = l[0], 1
count = 1
for i in l[1:]:
    count += 1
    if i-val > k or count > c:
        ans += 1
        count, val = 1, i
print(ans)

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

Solution (Python):
N, C, K = map(int, input().split())
T = [0 for _ in range(N)]
for __ in range(N):
    T[__] = int(input())
 
T.sort()
bus_count = 1
bus_rest = C
bus_depert = T[0]+K
 
for ix in range(N):
 
    if T[ix] <= bus_depert and bus_rest > 0:
        bus_rest -= 1
 
    else:
        bus_count += 1
        bus_depert = T[ix] + K
        bus_rest = C - 1
 
print(bus_count)

Solution (Python):
import sys
input = sys.stdin.readline
N, C, K = [int(x) for x in input().split()]
T = [int(input()) for _ in range(N)]
T.sort()
depart = T[0] + K  
passenger = 0  
bus = 1
for i in range(N):
    if passenger >= C or depart < T[i]:  
        bus += 1
        passenger = 1
        depart = T[i] + K
    else:
        passenger += 1

print(bus)

Solution (Python):
N, C, K = [int(x) for x in input().split()]
T = [int(input()) for _ in range(N)]
T.sort()
depart = T[0] + K  
passenger = 0  
bus = 1
for i in range(N):
    if passenger >= C or depart < T[i]:  
        bus += 1
        passenger = 1
        depart = T[i] + K
    else:
        passenger += 1

print(bus)

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

in_bus = 0
first = 0
last = 0
bus_count = 0
for i in range(N):
    if (i == 0):
        first = T[i]
        last = T[i] + K
        in_bus += 1
        bus_count += 1
        continue

    if (in_bus == C):
        bus_count += 1
        in_bus = 1
        first = T[i]
        last = T[i] + K
        continue

    if (T[i] >= first and last >= T[i]):
        in_bus += 1
    else:
        first = T[i]
        last = T[i] + K
        in_bus = 1
        bus_count += 1


print(bus_count)

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

T.sort()
bus_count = 1
bus_rest = C
bus_depert = T[0]+K

for ix in range(N):

    if T[ix] <= bus_depert and bus_rest > 0:
        bus_rest -= 1

    else:
        bus_count += 1
        bus_depert = T[ix] + K
        bus_rest = C - 1

print(bus_count)

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

Solution (Python):
from collections import Counter
n, c, k = map(int, input().split())
time_people = Counter([int(input()) for _ in range(n)])
times = sorted(time_people.keys())
ans = 0
left = 0
right = 0
while time_people[times[-1]] > 0:
    space = c
    while times[left] + k >= times[right] and space > 0:
        new_passenger = min(c, time_people[times[right]])
        space -= new_passenger
        time_people[times[right]] -= new_passenger
        if right >= len(times):
            break
        if time_people[times[right]] == 0:
            right += 1
            if right == len(times):
                break
    ans += 1
    while left < len(times) and time_people[times[left]] <= 0:
        left += 1
print(ans)

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

bus = 0
pa = 1
S = T[0]

for i in T[1:]:
    pa += 1
    if K < i-S or pa > C:
        bus += 1
        pa = 1
        S = i
print(bus+1)

Solution (Python):

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))



def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


N, C, K = read_ints()
T, = read_col(N)
T.sort()



bus = []  
ans = 0  
for t in T:
    if (len(bus) and bus[0] + K < t) or len(bus) == C:  
        ans += 1  
        
        bus = []
    bus.append(t)
if bus:
    ans += 1
print(ans)

Solution (Python):
N,C,K = map(int, input().split())
L = []
for a in range(N):
  L.append(int(input()))
L.sort()
L.append(10**10)
x = 0
y = 0
z = L[0]
for i in range (N+1):
  if y < C and z+K >= L[i]:
    y += 1
  else:
    x += 1
    y = 1
    z = L[i]    
print(x)

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

ans = 0
x = 0
capacity = 0
for L, R in times:
    if L <= x:
        if c == capacity:
            capacity = 1
            ans += 1
            x = R
        else:
            capacity += 1
    else:
        x = R
        ans += 1
        capacity = 1
print(ans)

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

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

    t.sort()
    t0 = t[0]
    n = 1
    ans = 0
    for i in t[1::]:
        if n == c or i > k+t0:
            ans += 1
            n = 1
            t0 = i
        else:
            n += 1
    ans += 1
    print(ans)

    return

if __name__ == '__main__':
    main()

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

lmt = 0
flg = True
tmp_c = c
bus_cnt = 0
for i in range(len(T)-1):
    if flg:
        lmt = T[i] + k
        flg = False
        bus_cnt += 1
    if tmp_c >= 0 or lmt >= T[i]:
        tmp_c -= 1
    if tmp_c <= 0 or lmt < T[i+1]:
        flg = True
        tmp_c = c
else:
    if tmp_c <= 0 or lmt < T[-1]:
        bus_cnt += 1

print(bus_cnt)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N,C,K = I()
T = [i() for _ in range(N)]
T.sort()
T = deque(T)
ans = [[] for _ in range(N)]
ans[0].append(T.popleft())
now = 0
while T:
    a = T.popleft()
    if len(ans[now]) == C or a-ans[now][0] > K:
        now += 1
    ans[now].append(a)
print(now+1)

Solution (Python):
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
cnt,now=0,0
while now<n:
    temp=t[now]+k
    a=now
    for i in range(c-1):
        if i+1+a>=n:
            break
        if t[i+1+a]>temp:
            break
        now+=1
    now+=1
    cnt+=1
print(cnt)

Solution (Python):
import sys
n, c, k = map(int, input().split())
a = list(map(int, sys.stdin.readlines()))+[10**10]
a.sort()
ans, cnt, tmp = 0, 1, a[0]+k
for i in a[1:]:
    if i <= tmp and cnt < c:
        cnt += 1
    else:
        tmp, cnt = i + k, 1
        ans += 1

print(ans)

Solution (Python):
import bisect

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

T = [0]*N
for i in range(N):
    T[i] = int(input())
T.sort()




ans = 0
left = 0
while True:
    if left >= N:
        break
    
    ind = bisect.bisect_right(T, T[left]+K)
    
    left = min(ind, left+C)
    ans += 1
    
    
    
print(ans)

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

def main():
    n, c, k = input_list()
    arrivals = []
    for _ in range(n):
        arrivals.append(int(input()))
    arrivals.sort()
    count = 0
    limit = 0
    ans = 0
    for i, a in enumerate(arrivals):
        if limit and limit < a:
            limit = 0
            count = 0
            ans += 1
        if not limit:
            limit = a + k
        if a <= limit:
            count += 1
        if count == c:
            ans += 1
            count = 0
            limit = 0
    if count > 0:
        ans += 1
    print(ans)

def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Solution (Python):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, C, K, *T = map(int, read().split())
T.sort()

def main(N, C, K, T):
    INF = K + 100
    time = -INF
    people = 0
    bus = 0
    for t in T:
        if t > time + K:
            time = t
            people = 1
            bus += 1
            continue
        if people < C:
            
            people += 1
        else:
            
            time = t
            people = 1
            bus += 1
    return bus

print(main(N, C, K, T))

Solution (Python):
N, C, K=map(int, input().split())
X=[]
for _ in range(N):
  X.append(int(input()))
X.sort()
X.append(10**19)
ans=0
tamatta=0
hayaihito=X[0]
for i in range(N+1):
  if tamatta<C and hayaihito+K>=X[i]:
    tamatta+=1
  else:
    ans+=1
    tamatta=1
    hayaihito=X[i]
    
print(ans)

Solution (Python):
n, c, k, *T = map(int, open(0).read().split())
T.sort()
ans = s = 0
while s < n:
    t = T[s] + k
    X = [T[s]]
    for i in range(s+1, min(n, s+c)):
        if T[i] <= t:
            X.append(T[i])
        else:
            break
    s += len(X)
    ans += 1
print(ans)

Solution (Python):



from bisect import bisect_left, bisect_right

def main():
    N,C,K = map(int, input().split())
    Ti = list(int(input()) for _ in range(N))
    Ti.sort()
    i = 0
    ret = 0
    while i<N:
        ret += 1
        s = i
        Ts = Ti[i]
        while i<N and Ti[i]<=(Ts+K) and (i-s)<C:
            i += 1

    print(ret)

if __name__ == '__main__':
    main()

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

lt = list()
for i in range(n):
    lt.append(int(input()))
lt.sort()

b = 1  
p = 0  
m = lt[0]

for i in range(n):
    if p < c and lt[i]-m <= k:
        p += 1
    else:
        p = 1
        b += 1
        m = lt[i]

print(b)

Solution (Python):
n_people,bus_capacity,can_wait = map(int,input().split())
arriving_time_ls = [0] * n_people
for i in range(n_people):
    arriving_time_ls[i] = int(input())
arriving_time_ls.sort()

waiting_last = 0
bus_count = 0
for i in range(1,n_people):
    if (arriving_time_ls[i] - arriving_time_ls[waiting_last] > can_wait) or (i - waiting_last + 1 > bus_capacity):
        bus_count += 1
        waiting_last = i
bus_count += 1
print(bus_count)

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

bus = 0
pas = 0
l = 0
r = 0
while l < N:
    if r == N:
        if pas == 0:
            break
        else:
            bus += 1
            break
    elif T[l] + K >= T[r]:
        pas += 1
        r += 1
        if pas == C:
            bus += 1
            l = r
            pas = 0
    else:
        l = r
        bus += 1
        pas = 0
print(bus)

Solution (Python):
_, c, k, *lst = map(int, open(0).read().split())
lst.sort()
res = 1
tmpt = lst[0]
tmpc = 0
for i in lst:
  tmpc += 1
  if not (tmpc <= c and i - tmpt <= k):
    res += 1
    tmpc = 1
    tmpt = i

print(res)

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

bus=0
arr=0
que=0
for i in range(n):
  tt=t[i]
  if que==0:
    
    arr=tt
    que+=1
    bus+=1
  else:
    if que==c:
      
      bus+=1
      arr=tt
      que=1
    else:
      if arr+k<tt:
        
        bus+=1
        arr=tt
        que=1
      else:
        
        que+=1

print(bus)

Solution (Python):
N,C,K=map(int,input().split())
T=sorted([int(input()) for i in range(N)])
lt=T[0]+K
m=0
b=0
for t in T:
    if lt>=t and m<C:
        m+=1
    else:
        m=1
        b+=1
        lt=t+K
if m>=1:
    b+=1
print(b)

Solution (Python):
n,c,k = map(int,input().split())
t = [0]*n
for i in range(n):
    t[i] = int(input())
t.sort()
ind = 0
ans = 0
bus = 0
while ind <= n-1:
    bus += 1
    ind_o = ind
    for i in range(c):
        if ind_o+i > n-1:
            ind_o += i-1
            break
        if t[ind_o+i] > t[ind_o]+k:
            break
        else:
            ind += 1
print(bus)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

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[i] <= t_limit: 
		cnt += 1 
	else:          
		t_limit = T[i] + K
		cnt = 1
		ans += 1
print(ans)

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

buf.sort()

ans = 0
lasttime = 1e9
tcnt = 0
for i in range(n):
    if i == 0:
        tcnt += 1
        lasttime = buf[i]
        ans += 1
    else:
        t = buf[i]
        if t <= lasttime+k and tcnt < c:
            tcnt += 1
        else:
            ans += 1
            lasttime = buf[i]
            tcnt = 1
    
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *

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

T.sort()
idx = 0
ans = 0

while idx < N :
	tmp = T[idx]
	if idx+C <= bisect(T, tmp+K):
		idx += C
	else:
		idx = bisect(T, tmp+K)
	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()
ans = 1
last_t = T[0]
passengers = 0
for t in T:
    if last_t +k >= t and passengers < c:
        passengers += 1
    else:
        last_t = t
        passengers = 1
        ans += 1

print(ans)

Solution (Python):
np, cp, tl = map(int, input().split())
bn = [1] + [0 for i in range(np-1)]
ar = []
for i in range(np):
  ar.append(int(input())) 
ar.sort()

lim = ar[0] + tl
num = 1
gto = 1
for i in range(1, np):
  if gto == cp or lim < ar[i]:
    lim = ar[i] + tl
    gto = 1
    num += 1
    bn[i] = num
  else:
    gto += 1
    bn[i] = num

print(bn[-1])