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):
def inpl(): return [int(i) for i in input().split()]

N, C, K = inpl()
A = []
for _ in range(N):
    A.append(int(input()))
A = list(sorted(A))
bus = 0
st = -K-1
nop = 0
for i in A:
    if st + K < i or nop == C:
        bus += 1
        st = i
        nop = 1
    else:
        nop += 1
print(bus)

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

ans = 0
space = C
dept = 0
for t in T:
    if t <= dept and space > 0:
        space -= 1
        continue
    dept = t+K
    space = C-1
    ans += 1
print(ans)

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

p = 0 
w = t[0] 

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

print(res)

Solution (Python):
import sys

def main() -> None:
    n, c, k = map(int, input().split())
    t = [int(sys.stdin.readline()) for _ in range(n)]
    ans = wait_start = wait_people = 0

    for ti in sorted(t):
        if ti - wait_start > k or wait_people == c:
            wait_people = 0
        wait_people += 1

        if wait_people == 1:
            wait_start = ti
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main() -> None:
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    ans = wait_start = wait_people = 0

    for ti in sorted(t):
        if ti - wait_start > k or wait_people == c:
            wait_people = 0
        wait_people += 1

        if wait_people == 1:
            wait_start = ti
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

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

res = 0
s = []
for x in t:
    if len(s)==0:
        s.append(x)
    else:
        
        if x-s[0]>k:
            while len(s)>0 and x-s[0]>k:
                res += 1
                s = s[c:]
            s.append(x)
        elif len(s)+1>c:
            res += 1
            s = s[c:]
            s.append(x)
        else:
            s.append(x)

if len(s)>0:
    res += 1
print(res)

Solution (Python):
N,C,K = map(int,input().split())
T = [int(input()) for i in range(N)]
T = sorted(T)
counter = 0
ans = 1
A = []
while counter != N :
    if len(T) > 0 and len(A) < C and ((len(A) == 0) or (T[0] <= A[0] + K)) :
        A.append(T[0])
        T.pop(0)
        counter += 1
    else :
        A = []
        ans += 1
print(ans)

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

bus = 0
kyaku = 0
dep_time = 0
for t in T:
    if t > dep_time or kyaku == C:
        dep_time = t + K
        kyaku = 1
        bus += 1
    else:
        kyaku += 1

print(bus)

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

Bus, Cap = 1, 1
Lim = T[0]+K
for i in range(N-1):
    if T[i+1] <= Lim:
        if Cap < C:
            Cap += 1
        else:
            Bus += 1
            Cap = 1
            Lim = T[i+1] + K
    else:
        Bus += 1
        Cap = 1
        Lim = T[i+1] + K
print(Bus)

Solution (Python):
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()
ans = 0
first = T[0]
arrived = 0
for t in T:
    if first + K < t or arrived == C:
        ans += 1
        arrived = 0
        first = t
    arrived += 1
print(ans + (arrived > 0))

Solution (Python):
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append((int(input()), False))
    T.append((T[-1][0] + K, True))
T.sort(key=lambda x: (x[0], x[1]))
ans = 0
arrived = 0
head = 0
for t, bo in T:
    if arrived == 0 and not bo:
        head = t
    arrived += not bo
    if (bo and arrived > 0 and head <= t - K) or arrived == C:
        arrived = 0
        ans += 1
        head = 2000000009
if arrived > 0:
    ans += 1
print(ans)

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

ans = 0
bus = []

for t in times:
    if len(bus) in (0,c) or bus[0] + k < t:
        bus = []
        ans += 1
    bus.append(t)

print(ans)

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

T.sort()

for t in T:

    if passenger == 0:
        
        time = t
        passenger = 1
        count += 1

    
    elif 1 <= passenger < C:
        if t - time <= K:
            
            passenger += 1
        else:       
            
            count += 1
            passenger = 1
            time = t
            
    
    else:
        
        count += 1
        passenger = 1
        time = t
        
print(count)

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

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

t_list.sort()

count = 0
passenger = 0
time = 0

for t in t_list:
    if passenger == 0:
        passenger += 1
        count += 1
        time = t
    elif 1 <= passenger < C:
        if t - time <= K:
            passenger += 1
        else:
            passenger = 1
            count += 1
            time = t
    else:
        passenger = 1
        count += 1
        time = t

print(count)

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

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

T = sorted(T)

TT = []

for i in range(N - 1):
	TT.append(T[i + 1] - T[i])

ans = 1
c = 1
t = 0

for i in range(N - 1):
	t += TT[i]
	c += 1
	if t > K:
		ans += 1
		t = 0
		c = 1

	if c > C:
		ans += 1
		t = 0
		c = 1

print(ans)

Solution (Python):
from operator import itemgetter
from math import ceil
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:
  buscnt = 0
  tlimit = T[i] + K
  while i < N and T[i] <= tlimit and buscnt < C:
    buscnt += 1
    i += 1
  if i==N:
    break
  
  
  ans += 1

if buscnt > 0:
  ans += 1

print(ans)

Solution (Python):
n,c,k=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
a=t[0];b=1;d=0
for j in range(n):
  d+=1
  if t[j]>a+k or d>c:
     a=t[j]
     b+=1
     d=1
print(b)

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

res = 0
count_teiin = 0
prev_bus = -1
for i in t:
    
    if prev_bus == -1 or prev_bus+k < i:
        res += 1
        prev_bus = i
        count_teiin = 1
    else:
        count_teiin += 1
    
    if count_teiin == c:
        prev_bus = -1
print(res)

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

Ts.sort()

num = 1
limT = Ts[0] + K
ans = 0
for T in Ts[1:]:
    if limT < T or num == C:
        
        num = 1
        limT = T + K
        ans += 1
    else:
        num += 1

print(ans)

Solution (Python):
n, c, k=map(int, raw_input().split())
t=[input() for i in range(n)]
t.sort()
result=0
cap=0
time=-1
for cur in t:
	if cap==0 or time+k<cur:
		result+=1
		cap=c
		time=cur
	cap-=1
print result

Solution (Python):
n, c, k = map(int, input().split())
t = sorted([int(input()) for _ in range(n)])
bus = []
count = 0
p = t.pop(0)
bus.append(p)
while t != []:
    p = t.pop(0)
    if bus[0] + k >= p and len(bus) < c:
        bus.append(p)
    else:
        count += 1
        bus = [p]
print(count+1)

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

Solution (Python):
list_t = []
n,c,k = map(int, input().split())
for i in range(n):
    list_t.append(int(input()))
list_t.sort()
count = 0
j = 0
start_time = list_t[j]
start_j = j

while j < n:
    if j - start_j + 1 > c:
        count += 1
        start_j = j
        start_time = list_t[j]
        j += 1
    elif list_t[j] - k > start_time:
        count += 1
        start_j = j
        start_time = list_t[j]
        j += 1
    else:
        j += 1
print(count+1)

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

cnt = 0
rider = 0
limit = -1
for t in ts:
    if (rider == c) or not(t <= limit <= (t + k)):
        cnt += 1
        limit = (t + k)
        rider = 1
    else:
        rider += 1

print(cnt)

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

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

Bcnt = 0
i = 0
while True:
    if len(T) <= i:
        break
    BS = T[i] + K
    Bcnt += 1
    i += 1
    cnt = 1
    while cnt < C and len(T) > i:
        if T[i] <= BS:
            i += 1
            cnt += 1
        else:
            break
print(Bcnt)

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

Bcnt = 0
while True:
    if len(T) <= 0:
        break
    BS = T[0] + K
    Bcnt += 1
    del T[0]
    cnt = 1
    while cnt < C and len(T) > 0:
        if T[0] <= BS:
            del T[0]
            cnt += 1
        else:
            break
print(Bcnt)

Solution (Python):

def inpl(): return list(map(int, input().split()))
N, C, K = inpl()
T = sorted([int(input()) for _ in range(N)])
ans = 1
b, c = T[0], 1
for t in T[1:]:
    if (t > b+K) or (C <= c):
        ans += 1
        b, c = t, 1
    else:
        c += 1
print(ans)

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,C,K = inpl()
tt = [int(input()) for i in range(N)]
tt.sort()
tt.append(10**10)
ans = n = s = 0

for i in range(N):
	t = tt[i]
	if n == 0:
		s = t
	n += 1
	if n == C or tt[i+1]-s > K:
		ans += 1
		n = 0

print(ans)

Solution (Python):
n,c,k=map(int,input().split())
o=sorted(int(input()) for _ in range(n))
cnt=0
l=0
r=0

while l<n:
  while r<n and o[r]<=o[l]+k and r-l+1<=c:
    r+=1
  cnt+=1
  l=r

print(cnt)

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

ans = 1

earl = t[0]
count = 0
for i in range(n):
    if t[i]-earl > k or count == c:
        count = 0
        earl = t[i]
        ans += 1
    count += 1

print(ans)

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

t = sorted(t)
cnt_bus = 0
i = 0
while i < n:
    cnt_rider = 0
    l, r = i, min(i + c - 1, n - 1)
    while l <= r:
        mid = (l + r) // 2
        if t[mid] > t[i] + k:
            r = mid - 1
        else:
            
            p = mid
            l = mid + 1

    cnt_rider = p - i + 1
    i += cnt_rider
    cnt_bus += 1
    
print(cnt_bus)

Solution (Python):
from collections import deque

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

tk = [(ti, ti+k) for ti in t]
tk.sort(key=lambda x:x[1])
tk = deque(tk)



ans = 0

while tk:
    _, bus = tk[0]
    
    
    cnt = 0
    while (tk[cnt][0] <= bus) and (cnt < c):
        cnt += 1
        
        if cnt == len(tk):
            break
        
        
    
    for _ in range(min(cnt,c)):
        tk.popleft()
    
    ans += 1
        
print(ans)

Solution (Python):
from collections import deque

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

tk = [(ti, ti+k) for ti in t]
tk.sort(key=lambda x:x[1])
tk = deque(tk)



ans = 0

while tk:
    _, bus = tk[0]
    
    
    cnt = 0
    while (tk[cnt][0] <= bus):
        cnt += 1
        
        if cnt == len(tk):
            break
        
        
    
    for _ in range(min(cnt,c)):
        tk.popleft()
    
    ans += 1
        
print(ans)

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

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

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

t.sort()

lowest = 0
res = 1

for i in range(n):
	if i - lowest >= c:
		lowest = i
		res += 1
	elif t[i] - t[lowest] > k:
		lowest = i
		res += 1

print res

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


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

t.sort()

ans = 0
depart = t[0]
people = 0

i = 0
while i < n:
	if t[i] <= depart + k and people < c :
		people += 1
		i += 1

	else :
		ans += 1
		people = 0
		depart = t[i]

print ans + 1

Solution (Python):



def main():
    n, c, k = list(map(int, input().split()))
    t = [0] * n

    for i in range(n):
        ti = int(input())
        t[i] = (ti, ti + k)

    sorted_t = sorted(t, key=lambda x: x[1])
    pos = sorted_t[0][1]
    remain = c - 1
    bus_count = 1

    for i in range(1, n):
        if remain >= 1 and sorted_t[i][0] <= pos:
            remain -= 1
        else:
            bus_count += 1
            pos = sorted_t[i][1]
            remain = c - 1

    print(bus_count)


if __name__ == '__main__':
    main()

Solution (Python):



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

    remain_seats = c - 1
    departure_time = t[0] + k
    bus_count = 1

    
    
    for i in range(1, n):
        if remain_seats >= 1 and t[i] <= departure_time:
            remain_seats -= 1
        else:
            bus_count += 1
            remain_seats = c - 1
            departure_time = t[i] + k

    print(bus_count)


if __name__ == '__main__':
    main()

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

t = []
for i in range(n):
    t.append(int(input()))
t.sort()
a = t[0]
b = 1
ans = 1
for i in range(1,n):
    if t[i]-a <= k and b < c:
        b += 1
    else:
        ans += 1
        a = t[i]
        b = 1
print(ans)

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

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

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

T.sort()

result = 0
i = 0
j = 0
while i < N:
    if j == N or T[j] - T[i] > K:
        n = max(min(C, j - i), 1)
        if n == 0: raise
        
        i += n
        result += 1
        continue
    if j >= i + C:
        
        i += C
        result += 1
        continue
    j += 1

print(result)

Solution (Python):
import bisect

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

def search_next_bus(Ti):
  nxt=bisect.bisect_right(A,A[Ti]+K)
  if nxt>Ti+C:
    nxt=Ti+C
  return nxt

cnt=0
ans=0
while True:
  cnt=search_next_bus(cnt)
  ans+=1
  if cnt==N:
    break
print(ans)

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

ans = 1
bus_num = 1
bus_time = t[0]

for i in range(1, n):
	if t[i] > bus_time + k or bus_num == c:
		ans += 1
		bus_num = 1
		bus_time = t[i]
	else:
		bus_num += 1

print(ans)

Solution (Python):

import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)

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

T.sort()

start = 0
end = 0
count = 1
while True:
    if end >= N-1:
        break
    if (end - start + 1 >= C) or (T[end+1] > T[start] + K):
        debug(start, end)
        start = end + 1
        end = start
        if start == N:
            break
        else:
            count += 1
    else:
        end += 1

print(count)

Solution (Python):
import sys

def merge(L,R):
    res = []
    
    l_L = len(L)
    l_R = len(R)
    i = 0
    j = 0
    while (i <= l_L) & (j <= l_R):
        if (i == l_L) & (j == l_R):
            return res
        elif i == l_L:
            res.append(R[j])
            j += 1
        elif j == l_R:
            res.append(L[i])
            i += 1
        elif L[i] <= R[j]:
            res.append(L[i])
            i += 1
        else:
            res.append(R[j])
            j += 1
    return res

def divide(A):
    l_A = len(A)
    l_L = int(l_A / 2)
    l_R = l_A - l_L
    L = A[:l_L]
    R = A[l_L:]
    return L,R

def my_sort(A):
    l_A = len(A)
    if l_A == 1:
        return A
    else:
        L,R = divide(A)
        L = my_sort(L)
        R = my_sort(R)
        return merge(L,R)
    
N , C, K = map(int,input().split())
T = []
for _ in range(0,N):
    T.append(int(input()))
T = my_sort(T)

bus = 0
t_0 = T[0]
t_B = T[0] + K
num = 0


i = 0
while i < len(T):
    t = T[i]
    dt = t - t_0
    if (dt <= K) & (float((num + 1)) / float(C) <= 1):
        num += 1
    else:
        if num != 0:
            
            bus += 1
            t_0 = t
            num = 1
    i += 1
bus += 1
print(bus)

Solution (Python):
N,C,K=map(int,input().split())
tourist=[]
for i in range (N):
    T=int(input())
    tourist.append(T)
tourist.sort()
bus_count=1
bus_tourlist=1
bus_limit=tourist[0]+K
for j in range (1,len(tourist)):
    if bus_tourlist==C or tourist[j]>bus_limit:
        bus_count+=1
        bus_limit=tourist[j]+K
        bus_tourlist=1
    
    else:
        bus_tourlist+=1
print(bus_count)

Solution (Python):
def a_airport_bus(N, C, K, T):
    import bisect
    t = sorted(T)
    index = 0  
    ans = 0
    while index <= N - 1:
        
        num_take_bus = bisect.bisect_right(t, t[index] + K) - index
        if num_take_bus > C:
            index += C  
        else:
            index += num_take_bus  
        ans += 1  
    return ans

N, C, K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]
print(a_airport_bus(N, C, K, T))

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

    t_lst.sort()
    idx, bus = 0, 0
    while idx < n:
        t = t_lst[idx]
        bus += 1
        cus = 1
        idx += 1
        while idx < n and cus < c and t_lst[idx] - t <= k:
            cus += 1
            idx += 1

    print(bus)


if __name__ == '__main__':
    main()

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

p = C
d = T[0]+K
ans = 1
for t in T:
    if p == 0 or t > d:
        d = t+K
        p = C-1
        ans += 1
    else:
        p -= 1

print(ans)

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

T = []

for i in range(N):    
    T.append(int(input()))
    
T = sorted(T)
    
start = T[0]
ans = 1
now_C = 1
for t in T[1:]:
    if t<=start+K and now_C < C:
        now_C += 1
    else:
        start = t
        ans += 1
        now_C = 1

print(ans)

Solution (Python):
n,c,k=[int(i) for i in input().split()]
a=sorted([int(input()) for i in range(n)])
b=[i+k for i in a]
i0=[]
ans=0
bi=0
for i in range(n):
  i0.append(a[i])
  l=len(i0)
  if l== c or (b[bi] < a[i] and i!=0) :
    ans+=1
    i0=[]
    bi=i
  if l != c and i==n-1:
    ans+=1

print(ans)

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

Solution (Python):
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, C, K] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    T = []
    for i in range(N):
        input_raw = read_func().strip().split()
        T.append(int(input_raw[0]))
    T.sort()
    bus_count = 0
    first_time = T[0]
    people_count = 0
    for i in range(N):
        if T[i] <= first_time + K:
            people_count += 1
            if people_count >= C:
                bus_count += 1
                people_count = 0
                if i + 1 < N:
                    first_time = T[i + 1]
        else:
            bus_count += 1
            first_time = T[i]
            people_count = 1





    bus_count += people_count/C + (0 if people_count % C == 0 else 1)
    print bus_count



if __name__ == '__main__':
    main()

Solution (Python):
n, c, k = map(int,input().split())
take = [int(input()) for _ in range(n)]
take.sort()
ans = 1
p = take[0]
r = 1
for i in range(1, n):
    if r < c:
        if take[i] - p <= k:
            r += 1
        else:
            ans += 1
            r = 1
            p = take[i]
    else:
        ans += 1
        r = 1
        p = take[i]

print(ans)

Solution (Python):


import sys, math, copy




HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n, c, k = map(int, input().split())
    ti = []
    for i in range(n):
        t = int(input())
        ti.append(t)
    ti = sorted(ti)
    next_time = -HUGE
    next_capacity = 0
    count_bus = 0
    for t in ti:
        if (next_capacity) == 0 or (next_time < t) or (next_time > t + k):
            next_time = t + k
            next_capacity = c - 1
            count_bus += 1
        else:
            next_capacity -= 1
    print(count_bus)

main()

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

ans = 0
front = 0
while front < N:
    standard = T[front] + K
    front = min(bisect.bisect_right(T, standard), front+C)
    ans += 1
print(ans)

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

Solution (Python):
import bisect

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

i = 0
ans = 0

while T:
    ans += 1
    check = T[0] + K
    people = bisect.bisect_right(T, check)
    if people > C:
        del T[:C]
    else:
        del T[:people]

print(ans)

Solution (Python):
n,c,k=map(int,input().split())
t=[]
for i in range(n):
  t.append(int(input()))
t.sort()
num=0
pas=0
end=-1
for i in range(n):
  if(end<t[i]):
    num+=1
    end=t[i]+k
    pas=1
    if(pas==c):
      end=-1
  else:
    pas+=1
    if(pas==c):
      end=-1
  
print(num)

Solution (Python):
import bisect

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

ans = 0
while T:
    stop = bisect.bisect_right(T, T[0]+K)
    if stop > C:
        del T[:C]
        ans += 1
    else:
        del T[:stop]
        ans += 1

print(ans)

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

Solution (Python):
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append(int(input()))
T = sorted(T)
first = 0
C_now = C
count = 1
for t in T:
    if C_now == C:
        first = t
        C_now -= 1
    else:
        if t - first <= K:
            C_now -= 1
        else:
            count += 1
            first = t
            C_now = C-1
    if C_now == 0:
        count += 1
        C_now = C
if C_now == C:
    count -= 1
print(count)

Solution (Python):
n,c,k = map(int,input().split())
lis = []
for i in range(n):lis.append(int(input()))
lis.sort()
ans = 0
time = 0
cou = 0
for m in range(n):
    if time == 0:
        time = lis[m]
        cou += 1
    elif lis[m] <= time + k and cou < c:
        cou += 1
    else:
        ans += 1
        cou = 1
        time = lis[m]
ans += 1
print(ans)

Solution (Python):
def minimumNumberOfBus(a, c, k):
    foo = 0
    a = sorted(a)
    cur = 0
    while cur<len(a):
        departing_time = a[cur]+k
        space = c
        while space>0 and cur<len(a) and a[cur]<=departing_time:
            cur += 1
            space -= 1
        foo += 1
    return foo

def main():
    n, c, k = [int(x) for x in raw_input().strip().split()]
    a = [0 for i in xrange(n)]
    for i in xrange(n):
        a[i] = int(raw_input().strip())
    print minimumNumberOfBus(a, c, k)

if __name__ == '__main__':
    main()

Solution (Python):
line = input().split(" ")
a = list(map(int, line))
t = []
ans = 0
for i in range(0, a[0]):
    t.append(int(input()))
t.sort()
while len(t) > 0:
    if len(t) < a[1]:
        a[1]=len(t)
    if t[0] + a[2] > t[a[1] - 1]:
        ans += 1
        del t[0:a[1]]
    else:
        for i in range(0, a[1]):
            if t[i] > t[0] + a[2]:
                del t[0:i]
                ans += 1
                break
print(ans)

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

Solution (Python):
n, c, k = map(int, input().split())
t_list = []
for i in range(n):
    t = int(input())
    t_list.append(t)
t_list = sorted(t_list)
bus = 1
pas = 0
time = t_list[0]
for i in range(1, n):
    if t_list[i] - time <= k:
        pas += 1
    else:
        pas = 0
        bus += 1
        time = t_list[i]
    if pas >= c:
        pas = 0
        bus += 1
        time = t_list[i]
print(bus)

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

ans = dept = seat = 0
for t in src:
    if dept >= t and seat > 0:
        seat -= 1
    else:
        dept = t + K
        seat = C-1
        ans += 1
print(ans)

Solution (Python):
n, capacity, wait = map(int, raw_input().split(' '))

v = []

for i in range(n):
	v.append(int(raw_input()))

v.sort()

last = 0
capacity_left = 0

res = 0

for i in range(n):
	if v[i] <= last and capacity_left > 0:
		capacity_left -= 1
	else:
		last = v[i] + wait
		capacity_left = capacity - 1
		res += 1
	
print res

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

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

ans = 0
prv = -2e9
cnt = 0

for x in xs:
    if cnt == c or prv < x:
        cnt = 1
        prv = x + k
        ans += 1
    else:
        cnt += 1
print(ans)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


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

    ans = 0
    left = 0
    while left < N:
        a = t_list[left] + K
        for i in range(left, min(left + C, N)):
            if t_list[i] > a:
                left = i
                break
        else:
            left += C

        ans += 1


    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
def airport_bus():
	n, c, k = map(int, raw_input().split(" "))
	t = []
	for i in range(n):
		t.append(int(raw_input()))
	t.sort()
	dic_busno_sate = {}
	current_bus = 1
	for x in t:
		c_state = dic_busno_sate.get(current_bus)
		if c_state is None:
			dic_busno_sate[current_bus] = ([x, x+k], 1)
		else:
			time_range = c_state[0]
			p_num = c_state[1]
			if p_num>=c:
				current_bus+=1
				dic_busno_sate[current_bus] = ([x, x + k], 1)
			else:
				left_max = max(time_range[0], x)
				right_min = min(time_range[1], x+k)
				if left_max<=right_min:
					_p_num = p_num+1
					_time_range = [left_max, right_min]
					dic_busno_sate[current_bus] = (_time_range, _p_num)
				else:
					current_bus += 1
					dic_busno_sate[current_bus] = ([x, x + k], 1)
	print current_bus

if __name__ == "__main__":
	airport_bus()

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

Solution (Python):

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

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

Solution (Python):
n, c, k = map(int, raw_input().split())
t = [int(raw_input()) for _ in xrange(n)]
t.sort()
cnt = 0
check = [False] * n
for i in xrange(n):
    if check[i]:continue
    check[i] = True
    lt = t[i] + k
    for j in xrange(i, min(i + c, n)):
        if t[j] > lt :break
        check[j] = True
    cnt += 1
print cnt

Solution (Python):
n,c,k = map(int, raw_input().split())
l = [int(raw_input()) for _ in range(n)]
l.sort()
cnt = 1
p = 0
for i,t in enumerate(l):
    if i-p >= c or l[p] + k < t:
        cnt += 1
        p = i
print cnt

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

res = 1
start = arr[0]
cur = c

for pas in arr:
	if c == 0:
		c = cur - 1
		start = pas
		res += 1
		continue

	if pas <= start + k:
		c -= 1
	else:
		res += 1
		c = cur -1
		start = pas

print res