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

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

T.sort()
ans = 1
p = T[0]
count = 1
for i in range(1,N):
    if T[i]-p > K:
        ans += 1
        count = 1
        p = T[i]
    else:
        if count < C:
            count += 1
        else:
            ans += 1
            count = 1
            p = T[i]

print(ans)

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

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

i = 0
n_b = 0
n_passenger_on_waiting_bus = 0
departure_limit=-1

while i < N:
  if T[i] > departure_limit or n_passenger_on_waiting_bus == C:
    n_b +=1
    n_passenger_on_waiting_bus = 1
    departure_limit = T[i] + K
  else:
    n_passenger_on_waiting_bus += 1
  i += 1
    
print(n_b)

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

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

Solution (Python):
import bisect
def solve():
  n,c,k = (int(i) for i in input().split())
  t = [int(input()) for i in range(n)]
  t = sorted(t,reverse = True)
  ans = 0
  
  while t:
    ans += 1
    customer = t.pop(0)
    if len(t) >= 1:
     for i in range(c-1):
      if customer  <= t[0] + k:
        t.pop(0)
      else:
        break
      if len(t) == 0:
        break
  print(ans)
  
solve()

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

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

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

times = [int(input()) for _ in range(n)]
times.sort()

first = times[0]
cnt = 1
result = 0
for t in times[1:]:
    if t > first + k or cnt >= c:
        first = t
        cnt = 1
        result += 1
    else:
        cnt += 1
print(result + 1)

Solution (Python):
N,C,K = map(int,input().split())
t = [int(input()) for _ in range(N)]
t.sort()
L = 0
R = N-1
answer = 0
nextLeft = True

while L<=R:
    answer += 1
    if nextLeft:
        
        nextLeft = False
        TLeft = t[L]
        count = 1
        L += 1
        while count < C:
            if L == N:
                break
            if t[L] <= TLeft + K:
                count += 1
                L+=1
            else:
                break
    else:
        
        nextLeft = True
        TRight = t[R]
        count = 1
        R -= 1
        while count < C:
            if R == -1:
               break 
            if t[R] >= TRight - K:
                count += 1
                R -= 1
            else:
                break
print(answer)

Solution (Python):
from collections import defaultdict

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

ps = defaultdict(int)
for i in range(N):
    T = int(input())
    ps[T] += 1

count = 0
current_ps = 0
time_limit = 10**9+K+1

for t in sorted(ps.keys()):
    if t > time_limit and current_ps > 0:
        count += 1
        current_ps = 0

    if current_ps == 0:
        time_limit = t + K

    current_ps += ps[t]
    while current_ps >= C:
        count += 1
        current_ps -= C
        time_limit = t + K

if current_ps > 0:
    count += 1

print(count)

Solution (Python):
from math import ceil

def main():
    N, C, K =list(map(int, input().split()))
    Ts = []
    for _ in range(N):
        Ts.append(int(input()))

    Ts.sort()

    bus_ct = 0
    in_bus = 1
    st = Ts.pop(0) + K
    for Ti in Ts:
        if Ti > st:
            bus_ct += 1
            in_bus = 1
            st = Ti + K
        elif Ti <= st:
            in_bus += 1

        if in_bus > C:
            bus_ct += 1
            in_bus = 1
            st = Ti + K
    
    if in_bus:
        bus_ct += 1
    
    print(bus_ct)

main()

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

Solution (Python):
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
s = 0
e = T[0]+K
p = 0
ans = 0
for i in range(N):
    if p == C or e < T[i]:
        ans += 1
        s = T[i]
        e = T[i]+K
        p = 0
    s = max(s,T[i])
    e = min(e,T[i]+K)
    p += 1
print(ans+1)

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

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

result = 1
count = 0
f = 0

for i in range(n):
  if (t[i] - t[f]) > k or c == count:
    result += 1
    count = 1
    f = i
  else:
    count += 1
print(result)

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

Solution (Python):
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 0
while len(T) > 0:
    limit = T[0] + K
    counter = 0
    while counter < C:
        if len(T) == 0:
            break
        if T[0] > limit:
            break
        del T[0]
        counter += 1
    answer += 1
print(answer)

Solution (Python):
n,c,k=[int(i) for i in input().split()]
people=list(reversed(sorted([int(input()) for _ in range(n)])))
start=people[0]
cnt=1
ans=1
for i in people[1:]:
    if start-i<=k and i>=start-k and cnt<c:
        cnt+=1
    else:
        cnt=1
        ans+=1
        start=i
print(ans)

Solution (Python):
n, c, k = map(int, input().split())
s = [int(input()) for _ in range(n)]
s = sorted(s)
num = 0
i = s[0]
m = s[0] + k
p = 1
for j in s[1:]:
    if j <= m and p < c:
        p += 1
    else:
        p = 1
        num += 1
        m = j + k
    i = j
num += 1
print(num)

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

bus_count = 1
bus_rider_count = 0
min_T = sTn[0]
for T in sTn:
    if bus_rider_count < C and min_T + K >= T:
        bus_rider_count += 1
    else:
        bus_count += 1
        bus_rider_count = 1
        min_T = T

print(bus_count)

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

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

for i in range(1,N):
  if T[i]-time>K or count==C:
    time = T[i]
    count = 1
    ans += 1
  else:
    count += 1
if count>0:
  ans += 1
print(ans)

Solution (Python):

N,C,K=map(int, input().split())
l = []
ans = 0
for i in range(N):
    l.append(int(input()))
l.sort()
l.append(float("INF"))
l = l[::-1]
while len(l)>1:
  h=l.pop()
  i=h
  j=1
  while len(l)>1 and j<C and h+K>=l[-1]:
    i=l.pop()
    j+=1
  ans+=1
print(ans)

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

ans = 0
i = 0
while i < n:
    cnt = 0
    a = t[i]+k
    for j in range(c):
        if i+j < n:
            if t[i+j] <= a:
                cnt += 1
            else:
                break
        else:
            break
    ans += 1
    i += cnt
print(ans)

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



ans = 0
firstFlag = True
passenger = []	
for i in range(N):
	if firstFlag:
		passenger = [Ts[i] + K,C-1]
		firstFlag = False
		ans += 1
		
	
	if i+1 < N and passenger[0] < Ts[i+1]:
		
		firstFlag = True
	elif passenger[1] <= 0:
		
		firstFlag = True
	else:
		
		passenger[1] -= 1

print(ans)

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



ans = 0
firstFlag = True
passenger = []	
for i in range(N):
	if firstFlag:
		passenger = [Ts[i] + K,C-1]
		firstFlag = False
		ans += 1
		
	
	if passenger[1] <= 0:
		
		firstFlag = True
	elif i+1 < N and passenger[0] < Ts[i+1]:
		
		firstFlag = True
	else:
		
		passenger[1] -= 1

print(ans)

Solution (Python):
from bisect import bisect_right


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

ans = 0
idx = 0
while idx < N:
    in_time_idx = bisect_right(t, t[idx] + K)
    if (in_time_idx - 1) - idx + 1 <= C:
        idx = in_time_idx
    else:
        idx += C
    ans += 1
print(ans)

Solution (Python):
visitor, capacity, limit = map(int, input().split())

visitorList = []

for _ in range(visitor):
    arrivalTime = int(input())
    visitorList.append(arrivalTime)
    
visitorList.sort()
start = visitorList[0]
end = start + limit

count = 0
bus = 1

for j in visitorList:
    if start <= j <= end:
        count += 1
        if count <= capacity:
            continue
        else:
            bus += 1
            start = j
            end = j + limit
            count = 1
    else:
        bus += 1
        start = j
        end = j + limit
        count = 1
        
print(bus)

Solution (Python):
N,C,K = map(int,input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
i = 0
ans = 0
while i < N:
    Ti = T[i]
    cnt = 0
    while i < N and T[i] <= Ti + K and cnt < C:
        i += 1
        cnt += 1
    ans += 1
print(ans)

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

p = 0
b = 0
for i in range(n):
    t = T[i]
    if p == 0:
        w = t
    p += 1

    if t - w > k:
        b += 1
        p = 1
        w = t    
    elif p == c or t - w == k:
        b += 1
        p = 0

    if i == n - 1 and p > 0:
        b += 1
    
print(b)

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

tmp_c = 0
bus_cnt = 0
wait_lmt = 0
for i,T in enumerate(Ts):
    if tmp_c == 0:
        wait_lmt = T + K
    
    if T <= wait_lmt:
        tmp_c += 1
    
    if i == len(Ts)  - 1 or Ts[i+1] > wait_lmt or tmp_c == C:
        tmp_c = 0
        bus_cnt += 1

print(bus_cnt)

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 = []
for i in range(N):
    T.append(int(input()))
T.sort()
cur = T[0]
bus = 0
limit = 0
for i in range(N):
    if i != N-1:
        if limit <= C-1:
            if T[i] <= cur+K:
                limit += 1
            else:
                bus += 1
                limit = 1
                cur = T[i]
        else:
            bus += 1
            limit = 1
            cur = T[i]
    else:
        if limit <= C-1:
            if T[i] <= cur+K:
                bus += 1
            else:
                bus += 2
        else:
            bus += 2
print(bus)

Solution (Python):


import sys
from collections import deque, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, c, k = LI()
    T = deque(sorted([II() for _ in range(n)]))

    p = T.popleft()
    t = p + k
    res = 0
    while T:
        cnt = 1
        while T and cnt < c and T[0] <= t:
            cnt += 1
            T.popleft()
        res += 1
        p = 0
        if T:
            p = T.popleft()
            t = p + k

    if p:
        res += 1

    return res


print(main())

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

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

Solution (Python):




def solveProblem(personNumber,maxPerson,waitMaxTime,reachTime):
	needBas = 1
	reachTime.sort()
	nowTime = reachTime[0]
	nowPassenger = 0
	for i in  range(0,len(reachTime),+1):
		if nowPassenger < maxPerson and reachTime[i] <= nowTime + waitMaxTime:
			nowPassenger = nowPassenger+1
		else:
			needBas = needBas+1
			nowTime = reachTime[i]
			nowPassenger = 1
	answer = needBas
	return answer


if __name__ == '__main__':
	N,C,K = map(int,input().strip().split(' '))
	dataGetPerson = range(0,N,+1)
	reachTime = []
	for _ in dataGetPerson:
		reachTime.append(int(input()))
	solution = solveProblem(N,C,K,reachTime)
	print("{}".format(solution))

Solution (Python):
n,c,k = (int(i) for i in input().split())
t = sorted(int(input()) for i in range(n))
ans = pas = time = 0
for j in t:
  if j > time or pas >= c:
    ans += 1
    time = j + k
    pas = 1
  elif j <= time and pas < c:
    pas += 1
print(ans)

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

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

ans = 0
limit = 0
buss = 1
for i,t in enumerate(tt):
    if buss == c or t>limit:
        
        ans += 1
        buss = 1
        limit = t+k
    else:
        buss +=1
    
print(ans)

Solution (Python):
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
res=0
i1=0
while(i1<n):
    i2=0
    j=t[i1]+k
    if i1==n-1:
        res+=1
        break
    while(i1+i2<len(t) and t[i1+i2]<=j and i2<c):
        i2+=1
    res+=1
    i1+=i2
print(res)

Solution (Python):
n,c,k=map(int,input().split())
t=sorted([int(input()) for i in range(n)])
ans=0
j=0
e=0
for i in t:
    if j==0:
        j=1
        e=i+k
        ans+=1
    elif e<i:
        j=1
        e=i+k
        ans+=1
    else:
        j+=1
    if j==c:
        j=0
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()
cnt=1
num=0
time=T[0]
for i in range(n):
    if num<c and T[i]<=time+k:
        num+=1
    else:
        cnt+=1
        time=T[i]
        num=1
print(cnt)

Solution (Python):
n, c, k = list(map(int, input().split()))
tlist = [int(input()) for i in range(n)]
tlmt = None
onb = 0
bnum = 1
for t in sorted(tlist):
  if tlmt is None:
    tlmt = t + k
  if t <= tlmt and onb < c:
    onb += 1
  else:
    tlmt = t + k
    onb = 1
    bnum += 1

print(bnum)

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

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

ans += 1
print(ans)

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,c,k = li()
t = [ni() for _ in range(n)]

t.sort()

ans = 0
people = 0
isfirst = True
for ti in t:
    if isfirst:
        first = ti
        people = 1
        isfirst = False
        
    else:
        if ti <= first + k and people < c:
            people += 1
            
        else:
            ans += 1
            
            people = 1
            first = ti

print(ans+1)

Solution (Python):
def inpl(): return list(map(int, input().split()))

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

B = []
ans = 0
for i in range(N):
    t = T[i]
    if len(B) == 0:
        B.append(t)
    elif t <= B[0] + K:
        B.append(t)
    else:
        B = [t]
        ans +=1
    
    if len(B) == C:
        B = []
        ans += 1

ans += len(B) > 0

print(ans)

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

cap = C-1
dep = T[0] + K
ans = 1
for t in T[1:]:
    if cap and t <= dep:
        cap -= 1
    else:
        cap = C-1
        dep = t + K
        ans += 1
print(ans)

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

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

T.sort(reverse=True)

count = 0
while T:
    limit = T[-1]+K
    count += 1
    for i in range(C):
        if T and T[-1] <= limit:
            T.pop()
        else:
            break

print(count)

Solution (Python):

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

t = [int(m) for m in d]

t.sort()
current = 0
ans = 0
psn = 0
getonpsn = 0
for i in range(n):
    psn += 1
    if i == 0:
        current = t[i]
    if t[i] - current > k:
        psn -= 1
        ans += psn // c
        getonpsn += (psn // c) * c
        if psn // c == 0:
            getonpsn += psn
            ans += 1
            psn = 0
            
            current = t[getonpsn]
            if i == n - 1:
                    ans += 1
        elif getonpsn != n:
            current = t[getonpsn]
            if i == n - 1:
                if t[i] - current > k:
                    ans += 2
                else:
                    ans += 1

        psn = psn % c


        psn += 1
    elif i == n - 1:
        ans += (psn + c + 1) // c


print(ans)

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

bus = 0
i = 0
while i < n:
  base = i
  bus += 1
  passenger = 0
  while i < n and t[i] <= t[base] + k and passenger + 1 <= c:
    passenger += 1
    i += 1
print(bus)

Solution (Python):
def solve(N, C, K, Ts):
    Ts.sort()
    count = 0
    ans = 0
    time = 0
    for t in Ts[::-1]:
        if count >= C or t < time - K:
            ans += 1
            count = 0
            time = 0
        count += 1
        if time == 0:
            time = t
    if count > 0:
        ans += 1
    return ans


if __name__ == "__main__":
    N, C, K = tuple(map(int, input().split(" ")))
    Ts = [int(input()) for _ in range(N)]
    print(solve(N, C, K, Ts))

Solution (Python):
n,c,k,*t=map(int,open(0).read().split())
t.sort(reverse=1)
a=0
while t:
  h=t.pop()
  i=h
  j=1
  while t and j<c and i-h<k:
    i=t.pop()
    j+=1
  if i-h>k:
    t.append(i)
  a+=1
print(a)

Solution (Python):
n,c,k,*t=map(int,open(0).read().split())
t.sort(reverse=1)
a=0
while t:
  h=t.pop()
  i=h
  j=1
  while t and j<c and i-h<k:
    i=t.pop()
    j+=1
  if i-h>k:
    t.append(i)
  a+=1
print(a)

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

T = sorted(T)
j = 0
ans = 0
while j < N:
    t = T[j]
    ret = bisect.bisect_right(T, t+K, lo=j, hi=min(j+C, N))
    if ret-j > C:
        ret = C
    j += ret-j
    ans += 1
print(ans)

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

Solution (Python):


import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, C, K = MAP()
tN = [INT() for i in range(N)]

tN.sort()
ans = 0
bus = 0
timer = K
for i in range(N):
    if 1 <= bus <= C-1:
        timer -= tN[i] - tN[i-1]
        
        if timer < 0:
            ans += 1
            bus = 0
            timer = K
    
    if 0 <= bus <= C-2:
        bus += 1
    
    elif bus == C-1:
        ans += 1
        bus = 0
        timer = K

if bus != 0:
    ans += 1
print(ans)

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

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

print(ans)

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

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

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

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

count=1

bus_count=0

for j in range(n-1):
    bus_count+=1
    if(x[j+1-bus_count]+k<x[j+1] or bus_count==c):
        count+=1
        bus_count=0
        
print(count)

Solution (Python):
a,b,c=map(int,input().split())
l=[int(input())for i in range(a)]
l.sort()
p=0
k=0
d=0
for i in range(a):
    q=l[i]
    if p==b or d<q:
        d=q+c
        k+=1
        p=1
    else:
        p+=1
print(k)

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

ans = 0
capa = 0
dept = -1
for t in sorted(T):
    if t > dept or capa == 0:
        ans += 1
        dept = t+K
        capa = C-1
    else:
        capa -= 1
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


N, C, K = il()
T = sorted(imi(N))
ll = []
c = 1
ll = [T[0]]
for t in T[1:]:
    if len(ll) == C or ll[0] + K < t:
        ll = []
        c += 1
    ll.append(t)
print(c)

Solution (Python):
n,c,k=map(int,input().split())
t=[int(input()) for _ in [0]*n]
t.sort()
b=1
h=0
d=t[0]
for i in range(n):
  if(h<c and t[i]-d<=k):
    h+=1
  else:
    b+=1
    h=1
    d=t[i]
print(b)

Solution (Python):
n,c,k=map(int,input().split())
t=[int(input()) for _ in [0]*n]
t.sort()
t=t+[0]
b=1
h=0
d=t[0]
for i in range(n):
  if(h<c and t[i]-d<=k):
    h+=1
  else:
    b+=1
    h=1
    d=t[i]
print(b)

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

T = []

for i in range(N):
    tmp = int(input())
    T.append(tmp)
    
T.sort()
    
ans = 1
now = 1
now_time = T[0]

for i in range(1, N):
    if now==C:
        now=1
        ans=ans+1
        now_time = T[i]
    elif T[i]-now_time<=K:
        now=now+1
    else:
        now=1
        ans=ans+1
        now_time = T[i]
        
print(ans)

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

inputs.sort()

start = inputs[0]
capa = 1
ans = 1
for i in range(1, N):
    capa += 1
    if start + K < inputs[i] or capa > C:
        ans += 1
        capa = 1
        start = inputs[i]

print(ans)

Solution (Python):
N,C,K=map(int,input().split())
T=[]
for i in range(N):
    p=int(input())
    T.append(p)
  
ans = 1
T = sorted(T)
ind = 0
 
for i in range(len(T)):
    if T[i] > T[ind]+K:
        ans += 1
        ind = i
    elif i >= ind + C:
        ans += 1
        ind = i
print(ans)

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

ANS=1
B=1
T=P[0]
for j in range(1,N):
    if K<(P[j]-T):
        ANS+=1
        B=1
        T=P[j]
    elif B<C:
        B+=1
    elif B>=C:
        ANS+=1
        B=1
        T=P[j]

print(ANS)

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

ANS=1
B=1
T=P[0]
for j in range(1,N):
    if K<(P[j]-T):
        ANS+=1
        B=1
        T=P[j]
    elif B<C:
        B+=1
    elif B>=C:
        ANS+=1
        B=1
        T=P[j]

print(ANS)

Solution (Python):
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
num = 1
begin = 0
for j in range(100000):
    for i in range(begin + 1,N):
        wait = T[i] - T[begin]
        if wait > K or i - begin + 1> C:
            num += 1
            begin = i
            break
    else:
        break
print(num)

Solution (Python):
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T.sort()
num = 1
begin = 0
for j in range(100000):
    for i in range(begin + 1,N):
        wait = T[i] - T[begin]
        if wait > K or i - begin + 1> C:
            num += 1
            begin = i
            break
    else:
        break
print(num)

Solution (Python):
N,C,K=map(int,input().split())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A.sort()
k=K
a=0
c=C-1
j=1
while j<N:
    k-=A[j]-A[j-1]
    c-=1
    if k>=0 and c>=0:    
        j+=1
    else:     
        a+=1
        c=C-1
        k=K
        j+=1
print(a+1)

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

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

t = [0 for _ in range(n)]
first = 0  
num = 0  
bass = 0
for i in range(n):
    
    t[i] = int(input())
t = sorted(t)
for i in range(n):
    
    if num == 0:
        first = t[i]
        num += 1
    elif first + k < t[i]:
        
        bass += 1
        first = t[i]
        num = 1
    elif num == c:
        
        bass += 1
        first = t[i]
        num = 1
    else:
        num += 1
print(bass + 1)

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

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

T.sort()
A = T[0]
SUM = 1
ans = 0
for i in range(1, N):
    SUM += 1
    if T[i] - A > K:
        ans += 1
        SUM = 1
        A = T[i]
    elif SUM > C:
        ans += 1
        SUM = 1
        A = T[i]

        
print(ans+1)

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

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

T.sort()
A = T[0]
SUM = 1
ans = 0
for i in range(1, N):
    SUM += 1
    if T[i] - A > K:
        ans += 1
        SUM = 1
        A = T[i]
    elif SUM > C:
        ans += 1
        SUM = 1
        A = T[i]

        
print(ans+1)

Solution (Python):
N, C, K, *T = map(int, open(0).read().split())
T.sort()
head, tail = 0, 1  
cnt = 0
while tail <= N:
    while tail < N and tail - head < C and T[head] + K >= T[tail]:
        tail += 1
    cnt += 1
    head, tail = tail, tail + 1
print(cnt)

Solution (Python):
N, C, K = [int(_) for _ in input().split()]
times = sorted([int(input()) for _ in range(N)], reverse=True)
count = 0
while times:
    t = times.pop()
    count += 1
    num = 1
    while times:
        if times[-1] <= t + K and num < C:
            times.pop()
            num += 1
        else:
            break
print(count)

Solution (Python):
N, C, K = [int(_) for _ in input().split()]
times = sorted([int(input()) for _ in range(N)])
count = 0
while times:
    t = times.pop(0)
    count += 1
    num = 1
    while times:
        if times[0] <= t + K and num < C:
            times.pop(0)
            num += 1
        else:
            break
print(count)

Solution (Python):
n,c,k=map(int,input().split())
x=[0]*2
ans=0
l=[]
for i in range(n):
    n=int(input())
    l.append(n)
l.sort()


for n in l:
    if x[0]==0 and c>1:
        x=[n,1]
    elif x[0]==0:
        ans+=1
    elif n>x[0]+k:
        ans+=1
        x=[n,1]
    elif x[1]+1<c:
        x[1]+=1
    else:
        ans+=1
        x=[0,0]
print(ans+[0,1][x[0]>0])