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(x) for x in input().split()]
T = []
for i in range(N):
    T.append(int(input()))

T.sort()
T = [[t, t+K] for t in T]

bus = [[]]
bus_no = 0
limit = T[0][1]

for t in T:
    if (len(bus[bus_no]) < C and t[0] <= limit):
        bus[bus_no].append(t)
    else:
        bus.append([])
        bus_no += 1
        bus[bus_no].append(t)
        limit = t[1]

print(len(bus))

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

bus=0
wait_p=0
first_t=-1

for i in range(n):
    ti=t[i]
    if(first_t==-1):
        first_t=ti

    wait_p+=1

    if(ti > first_t+k):
        bus+=1
        first_t=ti
        wait_p=1

    if(wait_p >= c):
        bus+=1
        first_t=-1
        wait_p=0


if(first_t!=-1 or wait_p > 0):
    bus+=1

print(bus)

Solution (Python):
n,c,k=map(int,input().split())
ans=0
if c==1:
  print(n)
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
ride=[]
while l:
  a=l.pop(0)
  rode=a
  ride.append(a)
  while len(ride)<c:
    if l==[]:
      ans+=1
      break
    b=l[0]
    if b>ride[0]+k:
      ride.clear()
      ans+=1
      break
    l.pop(0)
    ride.append(b)
    if len(ride)==c:
      ans+=1
      ride.clear()
      break
print(ans)

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

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

Solution (Python):

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



for i in range(N):
    if c_cnt >= C or now > T[i] + K:     
        ans += 1
        c_cnt = 1
        now = T[i]
    else:
        c_cnt += 1
    if i == N - 1:
        if c_cnt != 0:
            ans += 1
        else:
            pass
    
print(ans)

Solution (Python):


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

for _ in range(N):
    t = int(input().split()[0])
    t_list.append(t)

waiting_n = 0
dead_line_t = float("inf")
bus_count = 0
t_list = sorted(t_list)

for i, t in enumerate(t_list):
    if waiting_n == 0:
        dead_line_t = t + K

    waiting_n += 1

    if waiting_n >= C:
        
        waiting_n = 0
        bus_count += 1
        continue

    if i == len(t_list) - 1:
        
        bus_count += 1
        break

    if t_list[i + 1] > dead_line_t:
        
        waiting_n = 0
        bus_count += 1
        continue


ans = bus_count
print(ans)

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

t.sort()

passenger = 0
bus = 1
departure = t[0] + k

for i in range(n):
    if passenger < c and departure >= t[i]:
            passenger += 1
    else:
            bus += 1
            passenger= 1
            departure = t[i] + k
print(bus)

Solution (Python):


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



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

T.sort()

t_ride=0
n_ride=0
count=0
for t in T:
    if t_ride==0:
        t_ride=t
        n_ride+=1
        count+=1
    else:
        if t-t_ride>K or n_ride==C:
            t_ride=t
            n_ride=1
            count+=1
        else:
            n_ride+=1
            
print(count)

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

t.sort()

for i in range(n):
    if (t[i] > bt)|(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)

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

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

for i in range(N):
    A[i]=int(input())
A=sorted(A,reverse=True)

IND=0
total=0
while(len(A)>0):
    total+=1
    IND=A[0]-K
    count=0
    i=0
    while((len(A)>0)&(count<C)) :
        if(A[0]<IND):break
        A.pop(0)
        count+=1
print(total)

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

ans = 0
it = 0
while it < N:
  start = T[it]
  occupancy = 0
  while it < N and occupancy < C and T[it] <= start + K:
    occupancy += 1
    it += 1
  ans += 1
print(ans)

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

    t.sort()

    cnt = 0
    ans = 0
    dep = 0
    for e in t:
        if cnt == c or e > dep:
            dep = e + k
            ans += 1
            cnt = 0

        cnt += 1

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,c,k = inpl()
t = inpln(n)
t.sort()
u = [(i+k) for i in t]
res = 0
now = 0
while now < n:
    time = u[now]
    for i in range(c):
        if now == n:
            break
        if t[now] <= time:
            now += 1
        else:
            break
    res += 1
print(res)

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

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

Solution (Python):

n, c, k = map(int, input().rstrip("\n").split())
time = sorted(int(input()) for _ in range(n))

ans = 1

iter_ = iter(time)
top = next(iter_)
i = 1
next_ = next(iter_)

try:
    while True:

        while next_ - top <= k and i < c:
            next_ = next(iter_)
            i += 1

        ans += 1
        top = next_
        i = 1
        next_ = next(iter_)
except StopIteration:
    print(ans)

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

t.sort()
slash = 0
start = t[0]
bus = 1 
for i in range(1, n):
    if t[i] > start + k:
        start = t[i]
        slash += 1
        bus = 1
    elif bus < c:
        bus += 1
    else:
        start = t[i]
        slash += 1
        bus = 1

print(slash + 1)

Solution (Python):





def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    
    
    
    
    
    
    
    
    n,c,k = map(int,input().split())
    t=[]
    for i in range(n):
        t.append(int(input()))
    t.sort()
    ans=1
    x=[0,t[0]+k]
    for i in range(n):
        if x[0]==c:
            ans+=1
            x=[1,t[i]+k]
        elif t[i]<=x[1]:
            x[0]+=1
            if x[1]>t[i]+k:
                x[1]=t[i]+k
        else:
            ans+=1
            x=[1,t[i]+k]
    print(ans)
main()

Solution (Python):
from sys import stdin
N, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
T = sorted([int(stdin.readline().rstrip()) for _ in range(N)])
i, ans = 0, 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(lambda x: int(x), input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
ans=1
sta=t[0]
man=1
for i in range(1,n):
    if t[i]<=sta+k and man<c:
        man+=1
    else:
        sta=t[i]
        man=1
        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()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    
    elif limit == 1:
        ans += 1
        limit = C
        start = i + 1

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()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
t=T[0]+K
a=1
h=1
for i in T[1:]:
    if t>=i and h<C:
        h+=1
    else:
        t=i+K
        h=1
        a+=1
print(a)

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

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

i = 0
result = 0
while(i < N):
    cur = l[i]
    psg = 0
    while(i < N and cur + K >= l[i] and psg < C):
        i += 1
        psg += 1
    result += 1

print(result)

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

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

N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
answer = 1
limit = T[0] + K
n = 0

for i in T:
    if i <= limit and n < C:
        n += 1
    else:
        answer += 1
        n = 1
        limit = i + K

print(answer)

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


if __name__ == "__main__":
    resolve()

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

ans = 0
i = 0
while i < n:
    s = T[i] + k
    j = 0
    while i+j < n and j < c and T[i+j] <= s:
        j += 1
    ans += 1
    i += j

print(ans)

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

for i in T[1:]:
    if P == C or i > N + K:
        B += 1
        P = 0
        N = i
    P += 1
print(B)

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

i = 0
ans = 0
while True:
    r = t[i] + k
    tmp = 0
    for j in range(i, i + c):
        if j >= n:
            break
        if t[j] <= r:
            tmp += 1
        else:
            break
    i += tmp
    ans += 1
    if i== n:
        break
print(ans)

Solution (Python):
n,c,k=map(int,input().split())
t=[]
bus=0
for _ in range(n):
	x=int(input())
	t.append(x)
t.sort()
cnt=0
timelimit=t[0]+k
for i in range(n):
	cnt+=1
	if t[i]>timelimit:
		bus+=1
		cnt=1
		timelimit=t[i]+k
	elif cnt==c:
		bus+=1
		cnt=0
		if i!=n-1:
			timelimit=t[i+1]+k
if cnt!=0:
	bus+=1
print(bus)

Solution (Python):
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
fstTime = 0
pasCnt= 0
ans = 1
for i in T:
  if fstTime == 0:
    fstTime = i

  if i - fstTime <= K and pasCnt < C:
    pasCnt += 1
  else:
    ans += 1
    fstTime = i
    pasCnt = 1
print(ans)

Solution (Python):
import heapq
import sys
input = sys.stdin.readline
def main():
    N,C,K = map(int,input().split())
    pas = []
    for _ in range(N):
        pas.append(int(input()))
    heapq.heapify(pas)
    bus = []
    num = 1
    m = min(pas)
    while pas:
        a = heapq.heappop(pas)
        if len(bus) == C or a-m > K:
            num += 1
            bus = []
            bus.append(a)
            m = a
        else:
            bus.append(a)

    print(num)

if __name__ == "__main__":
    main()

Solution (Python):
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
count = 0
ans = 0
start = 0
for i in range(N):
    if count < C:
        if count == 0:
            count += 1
            start = T[i]
        else:
            if T[i] <= start + K:
                count += 1
            else:
                ans += 1
                count = 1
                start = T[i]
    else:
        count = 1
        ans += 1
        start = T[i]

    if i == N - 1:
        ans += 1
print(ans)

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

Solution (Python):
N, C, K = tuple(map(int, input().split()))
T = [int(input()) for _ in range(N)]
T = sorted(T)
base = T[0]
count = 1
ans = 1
for i in range(1, N):
    if T[i] <= base + K and count < C:
        count += 1
        continue
    base = T[i]
    count = 1
    ans += 1
print(ans)

Solution (Python):
N,C,K,*T=map(int,open(0).read().split());T.sort();B=M=L=0
for t in T:
 M+=1
 if M>C or t>L:B+=1;M=1;L=t+K
print(B)

Solution (Python):
n, c, k = map(int, input().split())
l = sorted([int(input()) for i in range(n)])
count = 1
pas = 0
now = l[0]
for i in range(len(l)):
    check = now + k
    if pas < c and l[i] <= check:
        pas += 1
    else:
        now = l[i]
        pas = 1
        count += 1
print(count)

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

if C == 1:
  print(N)
else:
  cnt = 0
  ans = 0
  left = 0
  right = 0
  for i in range(N):
    if left <= a[i] <= right:
      cnt += 1
      if cnt == C:
        left = 0
        right = 0
    else:
      left = a[i]
      right = a[i] + K
      cnt = 1
      ans += 1
    
    
    
  else:
    print(ans)

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

check=t[0]+k
kyaku=1
ans=1
for i in range(1,n):
    if t[i]<=check and kyaku<c:
        kyaku+=1
        continue
    check=t[i]+k
    kyaku=1
    ans+=1
print(ans)

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

B=0
L=0
ans=0
for T in TT:
  if B==0:
    L=T+K
    B=C-1
    ans+=1
  else:
    if L>=T:
      B-=1
    else:
      L=T+K
      B=C-1
      ans+=1
  
print(ans)

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

arr = []

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

arr.sort()

cnt = 1

a = arr[0]

bc = 1

for i in range(1, n):

    if arr[i] - a <= k:
        bc += 1

        if bc > c:
            bc = 1
            a = arr[i]
            cnt += 1
    else:
        bc = 1
        a = arr[i]
        cnt += 1

print(cnt)

Solution (Python):
N,C,K=map(int,input().split())
T=sorted([int(input()) for j in range(N)])
Bcount=1
person=0
Time=T[0]
for i in T:
  if person < C:
    if i-Time > K:
      Bcount += 1
      person = 1
      Time=i
    else:
      person += 1
  else:
    Bcount += 1
    person = 1
    Time=i

print(Bcount)

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

bus = [T[0]]
count = 1

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

print(count)

Solution (Python):

def main():
    N, C, K, *T = map(int, open(0).read().split())
    T.sort()
    ans, cur, cnt = 0, T[0] + K, 0
    for i in T:
        if i > cur or cnt == C:  
            cur = i + K
            cnt = 1
            ans += 1
        else:  
            cnt += 1
    print(ans + 1)


if __name__ == "__main__":
    main()

Solution (Python):
N, C, K = map(int, input().split())
Ts = []
for i in range(N):
  T = int(input())
  Ts.append(T)
Ts.sort()
r = 0
i = 0
while i < N:
  Imin = i
  Tmin = Ts[Imin]
  while i < N:
    if i < Imin+C and Ts[i] <= Tmin+K:
      i += 1
    else:
      break
  r += 1
print(r)

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

def main():
    N,C,K = map(int,input().split())
    T = []
    for _ in range(N):
        T.append(int(input()))
    T.sort()
    q = collections.deque(T)

    ans = 1
    n = 1
    t0 = q.popleft()
    while q:
        t1 = q.popleft()
        if t1 <= t0 + K and n < C:
            n += 1
        else:
            ans += 1
            n = 1
            t0 = t1
    print(ans)

if __name__ == '__main__':
    main()

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

def main():
    N,C,K = map(int,input().split())
    T = []
    for _ in range(N):
        T.append(int(input()))
    T.sort()
    q = collections.deque(T)

    ans = 1
    n = 1
    t0 = q.popleft()
    while q:
        t1 = q.popleft()
        if t1 < t0 + K + 1 and n < C:
            n += 1
        else:
            ans += 1
            n = 1
            t0 = t1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
N,C,K = map(int, input().split())

Ts = []
for i in range(N):
  Ts.append(int(input()))
Ts = np.array(Ts)

Ts = np.sort(Ts)

ans = 1
t0 = None
for t in Ts:
  if t0 is None:
    t0 = t
    count = 1
  else:
    count += 1
    if (t<=t0+K)&(count<=C):
      pass
    else:
      ans += 1
      t0 = t
      count = 1
print(ans)

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

count = 1
passengers = 0
border = times[0] + k
for t in times:
    passengers += 1
    if c < passengers or border < t:
        count += 1
        passengers = 1
        border = t + k

print(count)

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

count = 0
passengers = 0
border = 0
for i in range(n):
    if border == 0:
        border = times[i] + k
    if c > passengers and border >= times[i]:
        passengers += 1
        if passengers == c:
            count += 1
            passengers = 0
            border = 0
    elif border < times[i]:
        count += 1
        passengers = 1
        border = times[i] + k

print(count + 1 if passengers > 0 else count)

Solution (Python):

import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, C, K = map(int, input().split())
        T = [int(input()) for _ in range(N)]

        T.sort()
        bus = 1
        p = 1
        start = T[0]
        for i in range(1, N):
            p += 1
            if T[i] > K + start or p > C:
                bus += 1
                p = 1
                start = T[i]

        print(bus)



if __name__ == '__main__':
    AtCoder().main()

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

T.sort(reverse=True)
ans = 0
while T:
    t = T.pop()
    ans += 1
    for i in range(C - 1):
        if not T or T[-1] > t + K:
            break
        T.pop()
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()
inf=float("inf")
ans=0
tl=inf
m=0
for i in range(n):
    if tl<t[i]:
        ans+=1
        m=1
        tl=t[i]+k
    elif m==c:
        ans+=1
        m=1
        tl=t[i]+k
    else:
        m+=1
        if m==1:
            tl=t[i]+k
if m:
    ans+=1
print(ans)

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

T.sort()

cur = T[0]
p = 0
cnt = 1

for t in T:
    p += 1
    if t > cur + K or p > C:
        cur = t
        p = 1
        cnt += 1
        
print(cnt)

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

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1
            cc=0

        cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

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

    ans = 0
    tt = t[0]
    cc = 1
    for i in range(1, n):
        if tt + k < t[i] or c == cc:
            tt = t[i]
            ans += 1
            cc = 1
        else:
            cc += 1

    print(ans+1)


if __name__ == '__main__':
    main()

Solution (Python):
n,c,k=list(map(int,input().split())) 
t_=sorted([int(input()) for x in range(n)])
cnt=1
num=[]
for i in t_:
	if len(num)==c:
		cnt+=1
		num=[i]
	elif len(num)!=0 and i>num[0]+k:
		cnt+=1
		num=[i]
	else:
		num.append(i)
print(cnt)

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

ti = t.pop()
limit = ti + k
np = 1
ans = 1
while len(t):
    ti = t.pop()
    if np == c or limit < ti:
        limit = ti + k
        ans += 1
        np = 0
    np += 1
print(ans)

Solution (Python):
N, C, K = [int(i) for i in input().split()]
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
first_passenger = 0
bus_cnt = 1
for i in range(N):
    if T[i] <= T[first_passenger] + K and i - first_passenger + 1 <= C:
        pass
    else:
        bus_cnt += 1
        first_passenger = i
print(bus_cnt)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n,c,k = LI()
    t = IR(n)
    t.sort()
    i = 0
    ans = 0
    while i < n:
        i = min(i+c,bisect.bisect_right(t, t[i]+k))
        ans += 1
    print(ans)
    return

def B():

    return


def C():

    return


def D():

    return


def E():

    return


def F():

    return


if __name__ == "__main__":
    A()

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

    dep = T[0]
    count = 1
    cap = 1
    i = 1
    while i < N:
        while i < N and cap < C and T[i] <= dep +K:
            cap += 1
            i += 1
        if i < N:
            dep = T[i]
            cap = 1
            count += 1
            i += 1
    return count

if __name__ == '__main__':
    print(main())

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

T.sort()
counter = 0
while len(T) > 0:
  if len(T) == 1:
    T.pop()
    counter += 1
  else:
    c = 1
    while c <= len(T)-1 and c < C:
      if T[c] - T[0] <= K:
        c += 1
      else:
        break
  
    del T[:c]
    counter += 1

print(counter)

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

ans = 0
bus = []

for i in range(n):
	if len(bus) == c:
		ans += 1
		bus = [t[i]]
	elif bus != [] and bus[0] + k < t[i]:
		ans += 1
		bus = [t[i]]
	else:
		bus.append(t[i])

print(ans+1)

Solution (Python):

import os,re,sys,operator,math,heapq,string



from sys import stdin,setrecursionlimit


setrecursionlimit(10**6)
input=stdin.readline

n,c,k=map(int,input().split())
t=sorted([int(input().rstrip()) for _ in range(n)])
ans=0
now=[]
for i in range(n):
    if len(now)==c:
        ans+=1
        now=[t[i]]
    elif now!=[] and now[0]+k<t[i]:
        ans+=1
        now=[t[i]]
    else:
        now.append(t[i])
    

print(ans+1)

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

T.sort()
cur, cnt, ans = T[0], 0, 1
for t in T:
    cnt += 1
    if t > cur + K or cnt > C:
        cur, cnt, ans = t, 1, ans + 1
print(ans)

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

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

    i = 0
    ans = 0
    while i < N:
        lim = t[i] + K
        tmp = 0
        for j in range(i, N):
            if t[j] <= lim:
                tmp += 1
            else:
                i = j
                break
            if tmp == C or j == N-1:
                i = j+1
                break
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
N, C, K = map(int,input().split())
para = [int(input()) for i in range(N)]
para.sort()
cnt = 1
p = 1
b = [para[0]]
while p <= N-1 :  
    if para[p] <= b[0] + K :
        if len(b) < C :
            b.append(para[p])
            p += 1 
        else :
            b = []
            cnt += 1 
            b.append(para[p])
            p += 1  
    else :
        b = [para[p]]
        p += 1
        cnt += 1

print(cnt)

Solution (Python):

import sys, math, fractions, itertools, collections, copy, heapq, bisect


def solve(N: int, C: int, K: int, T: "List[int]"):
    T.sort()
    T.append(10000000000000)
    count = 0
    i = 0
    while i < N:
        time = T[i]
        for x in range(C):
            if not time <= T[i] <= time + K:
                count += 1
                break
            i += 1
        else:
            count += 1
    print(count)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    C = int(next(tokens))  
    K = int(next(tokens))  
    T = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, C, K, T)

if __name__ == '__main__':
    main()

Solution (Python):
nums ,limit ,wait = map(int, input().split())
nums_ary = [0 for i in range(nums)]

for i in range(nums):
    nums_ary[i] = int(input())

nums_ary.sort()
nums_ary.append(10000000000000)
count = 0
i = 0
while i < nums:
    time = nums_ary[i]
    for x in range(limit):
        if not time <= nums_ary[i] <= time + wait:
            count += 1
            break
        i += 1
    else:
        count += 1
print(count)

Solution (Python):
N,C,K = map(int,input().split())
T = sorted(int(input()) for _ in [0]*N)
ans = 0
b = []
for t in T:
    if b and (len(b)==C or b[0]<t-K) :
        ans += 1
        b = []
    b.append(t)
if b:ans += 1
print(ans)

Solution (Python):
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N, C, K = map(int, input().split())
    T = [0] * N

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

    T.sort(reverse=True)
    ans = 0

    nowTime = float('inf')
    nowCount = 0
    for t in T:
        if nowTime - K <= t and nowCount < C:
            nowCount += 1
            continue
        ans += 1
        nowTime = t
        nowCount = 1

    print(ans)

sol()

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

Solution (Python):
def main():
    n, c, k = [int(i) for i in input().split()]
    t = [int(input()) for i in range(n)]
    t.sort()
    i = 0
    
    count = 0
    
    
    
    ans = 0
    while i < n:
        s = t[i] + k
        count = 0
        while i < n and count < c and t[i] <= s:
            count += 1
            i += 1
        ans += 1
        if i == n:
            break
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):



n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
p=1
dt=t[0]+k
ans=0
for i in range(1,n):
    if p==c:
        p=1
        ans+=1
        dt=t[i]+k
    elif dt<t[i]:
        p=1
        ans+=1
        dt=t[i]+k
    else:
        p+=1
print(ans+1)

Solution (Python):
import sys
input=sys.stdin.readline
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
p=1
dt=t[0]+k
ans=0
for i in range(1,n):
    if p==c:
        p=1
        ans+=1
        dt=t[i]+k
    elif dt<t[i]:
        p=1
        ans+=1
        dt=t[i]+k
    else:
        p+=1
print(ans+1)

Solution (Python):

N, C, K = map(int, input().split())
T = [0]*N
for i in range(N):
    T[i] = int(input())
T.sort()
count = 1
tmp = 0
_tmp = 0  
while tmp < N-1:
    tmp += 1
    if (tmp - _tmp == C or T[tmp] - T[_tmp] > K):
        _tmp = tmp
        count += 1
print(str(count))

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

ans = 0
tmp = 0 
time = 0 
for i in range(N):
    if tmp == 0: 
        tmp += 1
        time = T[i] + K 
        continue
    if tmp == C: 
        ans += 1
        tmp = 1
        time = T[i] + K
        continue
    if tmp < C: 
        if T[i] > time: 
            ans += 1
            tmp = 1
            time = T[i] + K
            continue
        else: 
            tmp += 1

if tmp > 0:
    ans += 1

print (ans)