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 = 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
		start = pas
		res += 1

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

print res

Solution (Python):
n, c, k = map(int, input().split())
arrivals = [int(input()) for i in range(n)]
arrivals.sort()
 
res = 0
room = c
bus_start = None
 
for t in arrivals:
 
    previous_bus_has_left = bus_start is not None and bus_start + k < t
    if previous_bus_has_left:
        res += 1
        room = c
 
    if room == c:
        bus_start = t
 
    room -= 1
 
    if room == 0:
        res += 1
        room = c
        bus_start = None
 
if room < c:
    res += 1
 
print(res)

Solution (Python):
N,C,K = map(int, raw_input().split(" "))
timelist = []
for i in range(0, N):
    timelist.append(int(raw_input()))
timelist.sort()


class Foo:

    timelist = []
    buslist = []
    firstId = 0
    capacity = 0

    def __init__(self, timelist):
        self.timelist = timelist

    def addBus(self, i):
        self.buslist.append(self.timelist[i])
        self.firstId  = i + 1
        self.capacity = 0

    def calc(self):
        for i in range(0, N):

            if i == N - 1:
                self.addBus(i)
                break

            nexttime = self.timelist[i + 1]

            self.capacity += 1
            
            if nexttime > timelist[self.firstId] + K:
                self.addBus(i)
                continue

            
            if self.capacity >= C:
                self.addBus(i)
                continue


    def printBusList(self):
        for bus in self.buslist:
            print(bus)

    def printTotalBusNum(self):
        print(len(self.buslist))


foo = Foo(timelist)
foo.calc()
foo.printTotalBusNum()

Solution (Python):
def numBuses(people, cap, wait):
	buses = 0
	currentCap = 0
	departTime = -1
	for person in people:
		if departTime == -1 or currentCap == cap or departTime - person > wait:
			departTime = person
			buses += 1
			currentCap = 1
		else:
			currentCap += 1
	return buses

[n, cap, wait] = list(map(lambda x: int(x), input().split()))
people = []
for i in range(n):
	people.append(int(input()))
print(numBuses(sorted(people, reverse=True), cap, wait))

Solution (Python):


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

idx = 0
bus = 0
while(True):
    if idx == N:
        break
    bus += 1
    limit = T[idx] + K
    for c in range(idx,idx+C):
        if idx == N:
            break
        dep = T[c]
        if dep <= limit:
            idx += 1
            continue
        else:
            break
print(bus)

Solution (Python):
n, c, k = map(int, input().split())
q = sorted([int(input()) for i in range(n)])
ans = 1
f = q.pop(0)
p = 1
for i in q:
    if i > f + k or p >= c:
        ans += 1
        f = i
        p = 1
    else:
        p += 1
print(ans)

Solution (Python):
arg = input().split(' ')
n = int(arg[0])
c = int(arg[1])
k = int(arg[2])
t = []
for i in range(n):
  t.append(int(input()))
t.sort()

res = 1
first = t[0]
pas = 0

for ti in t:
  if ti <= first + k:
    if pas == c:
      res += 1
      first = ti
      pas = 0
    pas += 1
  else:
    res += 1
    first = ti
    pas = 1

print(res)

Solution (Python):


n,c,k=map(int,raw_input().split())
ll=[]
for i in xrange(n):
 temp=int(raw_input())
 ll.append(temp)
l=sorted(ll)

cnt=0
i=0
r=0
while i<n:
 if l[i]-l[r]>k:
  cnt+=1
  r=i
  i+=1
 elif i-r>=c:
  cnt+=1
  r=i
  i+=1
 else:
  i+=1

print cnt+1

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

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

t_list.sort()

bus_cnt = 0
bus_member = []
for t in t_list:
    if len(bus_member) != 0 and K < t - bus_member[0]:
        bus_member.clear()
        bus_cnt += 1

    bus_member.append(t)

    if C <= len(bus_member):
        bus_member.clear()
        bus_cnt += 1

if len(bus_member) != 0:
    bus_cnt += 1

print(bus_cnt)

Solution (Python):
class Queue:
    class Node:
        def __init__(self, key):
            
            self.key = key
            self.next = None

    def __init__(self, N):
        self.head = None
        self.tail = None
        self.size = 0
        self.N = N

    def push(self, x):
        if self.size >= self.N:
            print 'error: size is N'
            return None
        self.size += 1
        node = self.Node(x)
        if self.size == 1:
            self.head = node
            self.tail = self.head
            
        else:
            self.tail.next = node
            self.tail = node
            

    def pop(self):
        if self.size < 1:
            print 'error: size is 0'
            return None
        self.size -= 1
        x = self.head.key
        self.head = self.head.next
        
        return x

    def get_size(self):
        return self.size

    def PrintAll(self):
        c_node = self.head
        while c_node is not None:
            print c_node.key,
            c_node = c_node.next
        print
    def get_head(self):
        return self.head.key

N, C, K = map(lambda x:int(x), raw_input().split())

T_raw=[]
for i in range(N):
    T_raw.append(int(raw_input()))

T_raw.sort()
T = Queue(N)
for i in range(N):
    T.push(T_raw[i])

result=0
while 1:
    
    Bus=[]
    while 1:
        Bus.append(T.pop())
        if T.get_size() == 0 or Bus[0]+K < T.get_head() or len(Bus) == C:
            result+=1
            break
        
    if T.get_size() == 0:
        break
        
print result

Solution (Python):


def main():
	n = 0 
	c = 0 
	k = 0 
	arraival_time = [] 

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

	for i in range(n):
		tmp = int(input())
		arraival_time.append(tmp)

	arraival_time.sort()
	counting_bus = 0

	while(1):
		passenger = []
		times = 0
		rslt = making_bus(c, k, arraival_time, passenger, times) 
		if rslt == 0:
			break
		elif rslt == 1:
			counting_bus += 1

	print(counting_bus)
		
		

def making_bus(c, k, arraival_time, passenger,times):
	if arraival_time:
		if not passenger:
			passenger.append(arraival_time.pop(0))
			times += 1
			
			making_bus(c, k, arraival_time, passenger, times)
			return 1
	
		elif (len(passenger) < c):
			if (arraival_time[0]-passenger[0] <= k):
				passenger.append(arraival_time.pop(0))
				times += 1
				
				making_bus(c, k, arraival_time, passenger, times)
				return 1
			else:
				return 1
		else:
			return 1
				
	elif times == 0:
		return 0
	elif times > 0:
		return 1







if __name__ == '__main__':
	main()

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

first = -1
cnt = 0
ans = 1
for t in T:
    if first == -1:
        first = t
        cnt = 1
    else:
        if first + k < t or c == cnt:
            first = t
            cnt = 1
            ans += 1
        else:
            cnt += 1
print ans

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n,c,k = LI()
    a = [II() for _ in range(n)]
    a.sort()
    m = a[0]
    t = 1
    r = 0
    for ai in a[1:]:
        if ai > m+k or t == c:
            r += 1
            t = 1
            m = ai
            continue
        t += 1

    if t > 0:
        r += 1
    return r

print(main())

Solution (Python):



def identity(x):
    return x

def mapv(f,s):
    return list(map(f,s))

def readln():
    _res = mapv(int,str(input()).split(' '))
    return _res

def seq(n,f=(lambda x: 0)):
    return [f(i) for i in range(0,n)]

n,c,k = readln()
t = [0 for i in range(0,n)]
for i in range(0,n):
    t[i] = int(input())
t = sorted(t)
ans,left = 0,0
while left < n:
    right = left
    while right < n and right - left < c and t[right] - t[left] <= k :
        right = right + 1
    ans = ans + 1
    left = right
print(ans)

Solution (Python):

import sys
import os
import numpy as np

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


v = list()

for i in range(0,N):
  t = int(input())
  v.append(t)

v.sort()

M = 1000000009
now_n = 0
now_f = M
ans = 0

for i in range(0,N):
  if now_n >= C or (now_f != M and v[i]-now_f > K):
    ans += 1
    now_n = 0
    now_f = M
  now_f = min(now_f, v[i])
  now_n += 1

if now_n != 0:
  ans += 1


print(ans)

Solution (Python):


n_cus, n_bus, n_wai = map(int, input().split())
l_arr = [int(input()) for i in range(n_cus)]
l_arr.sort()

n_time_angry = 0
n_now_sheet = n_bus
l_waiting_cus = []
n_need_bus = 0

for arr in l_arr:
    if arr <= n_time_angry and n_now_sheet > 0:
        n_now_sheet -= 1
    else:
        n_time_angry = arr + n_wai
        n_now_sheet = n_bus - 1
        n_need_bus += 1
        
print(n_need_bus)

Solution (Python):


from sys import stdin

N,C,K=map(int,raw_input().split())
T=map(int,stdin.read().split())

T.sort()
t_star=T[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1>C:
        cnt+=1
        t_star=t
        b_star=b

print cnt+1

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

bus = 0
new_bus = True
start_time = 0
capacity = 0

while t:
    time = t[0]
    if new_bus:
        new_bus = False
        capacity = 0
        start_time = time
        bus += 1

    wait_time = time - start_time
    if wait_time > k:
        if t:
            new_bus = True
            continue
        else:
            bus += 1
            break

    t.pop(0)
    capacity += 1

    if capacity == c:
        new_bus = True
        continue

print(bus)

Solution (Python):



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

res = 0
room = c
bus_start = None

for t in arrivals:

    if room == c:
        bus_start = t

    has_left_because_angry_passenger = bus_start + k < t
    if has_left_because_angry_passenger:
        res += 1
        room = c
        bus_start = t

    room -= 1

    if room == 0:
        res += 1
        room = c

if room < c:
    res += 1

print(res)

Solution (Python):
from __future__ import division
import math
from collections import deque

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

T = [input() for i in xrange(N)]
T.sort()

minT = T[0]
minTidx = 0
lenT = len(T)
bus = 0

for i in xrange(lenT):
    v = T[i]

    diffH = v - minT
    diff = i - minTidx
    if diffH > K:
        bus += 1
        minTidx += min(C,diff)
        minT = T[minTidx]


    diff = i - minTidx
    if i==lenT-1:
        cnt = math.ceil((diff+1) / C)
        bus += cnt

    else:
        diff = i - minTidx
        if (diff+1) >= C:
            bus += 1
            minTidx += C
            minT = T[minTidx]



print int(bus)

Solution (Python):
def main():
    N, C, K = map(int, input().split())
    i = 0
    T = []
    while i < N:
        T.append(int(input()))
        i += 1
    T.sort()
    T.reverse()

    c = 1
    i = 1
    bus = 1
    time = T[0]
    while i < N:
        if time - T[i] > K or c == C:
            bus += 1
            c = 1
            time = T[i]
        elif time - T[i] <= K:
            c += 1
        i += 1

    print(str(bus))

main()

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

t = sorted(t)

p = 0 
f = 0 
b = 0 

for i in t:
    if f == 0:
        f = i
    elif f + k < i or c <= p:
        b += 1
        f = i
        p = 0
    p += 1

b += 1

print(b)

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

T.sort()
bus = 1
s = T[0]
c = 1
for t in T[1:]:
	if t > s+K or c == C:
		c = 0
		s = t
		bus += 1
	c += 1
print bus

Solution (Python):

import sys



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

    print("N={}, C={}, K={}".format(N, C, K),
          file=sys.stderr)

    
    M = 1               
    n = 0               
    Tlim = Ts[0] + K    

    for T in Ts:
        if T > Tlim or n >= C:
            
            M += 1
            Tlim = T + K
            
            n = 1
        else:
            
            n += 1

    
    print(M)


if __name__ == '__main__':
    main()

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

for i in range(N):
    people[i]=int(input())
    
people=np.sort(people)

count=0
ride=C+1
ridetime=0
for i in range(N):
    if ridetime+K>=people[i] and ride<C:
        ride+=1
    else:
        count+=1
        ride=1
        ridetime=people[i]

print(count)

Solution (Python):
import collections
n,c,k = map(int,input().split())
d = collections.deque()
ans = 0
lis = []
for _ in range(n):
    lis.append(int(input()))
lis.sort()

wait = lis[0]
for tm in lis[1:]:

    if tm > wait+k:
        ans += 1
        d.clear()
        wait = 1000000000
    d.append(tm)
    if len(d) == c-1:
        ans += 1
        d.clear()
        wait = 1000000000

    if len(d)!=0 and wait == 1000000000:
        wait = d.popleft()


if c==1: ans = n-1
print(ans+1)

Solution (Python):


inp = list(map(int, input().split()))
N = inp[0]
C = inp[1]
K = inp[2]

t = []
for i in range(0, N):
    t.append(int(input()))

t.sort()

b = 0
p = 0
s = -1
for i in range(0, N):
    
    if p == C:
        b += 1
        p = 0
        s = -1
    
    if s == -1:
        s = t[i]
        p = 1
        continue
    
    if t[i] > s + K:
        b += 1
        p = 1
        s = t[i]
        continue
    
    else:
        p += 1

if p > 0:
    b += 1
print(b)

Solution (Python):
import sys

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def nal(): return list(map(int, stdin.readline().split()))
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())


n, c, k = nal()

t = []
for i in range(n):
    t.append(ni())
t.sort()

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

print(ans + 1)

Solution (Python):
n,c,k=map(int,raw_input().split())
t=[int(raw_input()) for _ in xrange(n)]
t.sort()
i=0
ans=0

while i<n:
    li=t[i]+k
    cnt=0
    f=0
    
    while i<n and t[i]<=li:
        cnt+=1
        if cnt==c:
            f=1
            ans+=1
            cnt=0
        i+=1
    if f==0:
        ans+=1
    else:
        i-=cnt
print ans

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

ni,nt,ans = 0,0,0
while 1:
    if ni >= n:
        break
    nt = t[ni]
    for i in range(1,c+1):
        if ni>=n or t[ni] > nt + k:
            break
        ni += 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()

ni,nt,ans = 0,0,0
while 1:
    if ni >= n:
        break
    nt = t[ni]
    for i in range(1,c+1):
        if ni>=n or t[ni] > nt + k:
            break
        ni += 1
    ans += 1
print(ans)

Solution (Python):
n,c,k = [int(x) for x in input().split()]
l = []
for x in range(n):
    num = int(input())
    second = num+k;
    l.append([num,second])

cnt = 1
pas = 1;
l = sorted(l,key=lambda x:x[1])
hold = l[0];
for x in range(1,n):
    if l[x][0] <= hold[1]:
        if pas == c:
            cnt += 1
            pas = 1
            hold = l[x]
        else:
            pas += 1
        pass
    else:
        cnt+= 1
        hold = l[x]
        pas = 1
print(cnt)

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

for _ in xrange(n):
    arrive.append(input())
arrive = sorted(arrive)

i = 0
buses = 0
while i < len(arrive):
    dep = arrive[i] + k
    j = 1
    while j < c and len(arrive) > j + i:
        if arrive[j + i] <= dep:
            j += 1
        else:
            break
    buses += 1

    i += j

print buses

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

bus = 0
bus_t = None
bus_on_board = 0

for t in Ts:
	if bus_t is not None and t <= bus_t and bus_on_board < C:
		bus_on_board += 1
	else:
		bus += 1
		bus_t = t + K
		bus_on_board = 1
print(bus)

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

T = []
for i in range(n):
    t = int(input())
    T.append(t)
T.sort()
bus = 0
while(True):
    if len(T) == 0:
        break
    start = T[0]
    for i in range(c):
        if len(T)!=0: 
            if start+k >= T[0]:
                T.remove(T[0])
            else:
                break
    bus += 1
print(bus)

Solution (Python):
N, C, K = map(int, input().rstrip().split())
TT = sorted(map(int, [input() for _ in range(N)]))
startT = TT[0]
bus_count = 1
p = 1
for T in TT[1:]:
    if T - startT > K or p >= C:
        bus_count += 1
        startT = T
        p = 1
    else:
        p += 1
print(bus_count)

Solution (Python):
N, C, K = map(int, raw_input().split())
T = []
for i in xrange(N):
    T.append(int(raw_input()))
T = list(sorted(T))
nBus = 0
curBus = []
for i in xrange(N):
    if len(curBus) == 0:
        curBus.append(T[i])
        continue
    if (T[i] - curBus[0] > K) or len(curBus) == C:
        nBus += 1
        curBus = []
    curBus.append(T[i])
if len(curBus) > 0:
    nBus += 1
print nBus

Solution (Python):
a = [int(x) for x in input().strip().split()]
t = []
for i in range(a[0]):
  t.append(int(input().strip()))
t.sort()

m = 0
i = 0
while True:
  if i+a[1] - 1 > a[0] - 1:
    ii = a[0] - 1
  else:
    ii = i+a[1] - 1
  if t[ii] - t[i] <= a[2]:
    i = ii + 1
    m += 1
  else:
    for j in range(i+1, ii+1):
      if t[j] - t[i] > a[2]:
        m += 1
        i = j
        break
  if i == a[0]:
    break

print(m)

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

bus_num = 0
while T:
    passengers = 1
    t = T[0]
    T.pop(0)
    while T and passengers < C and T[0] <= t + K:
        T.pop(0)
        passengers += 1
    bus_num +=1
print(bus_num)

Solution (Python):
from sys import stdin
def main():
    n, c, k = map(int, stdin.readline().split())
    t = map(int, stdin.read().split())
    t.sort()
    p = t[0]
    ans = 0
    j = 0
    for i, x in enumerate(t):
        if x - p > k or i - j + 1 > c:
            ans += 1
            p = x
            j = i
    print ans + 1
main()

Solution (Python):
n, c, k = map(int, input().split())
t = sorted([int(input()) for i in range(n)])
count = 0
cur_t = -k
cur_c = 0
for v in t:
  if v - cur_t > k:
    count += 1
    cur_c = 1
    cur_t = v
  else:
    cur_c += 1
    if cur_c > c:
      count += 1
      cur_c = 1
      cur_t = v
print(count)

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

t.sort(reverse=True)
bus = 0
while t!=[]:
	init = t.pop()
	count = 1
	while t!=[]:
		if count >= C:
			break
		now = t[-1]
		if now - init > K:
			break
		t.pop()
		count += 1
	bus+=1

print(bus)

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

    first = 0
    index = 1
    count = 1
    rider_num = 1

    while index <= N-1:
        if times[index] - times[first] <= K and rider_num < C:
            index += 1
            rider_num += 1
        else:
            count += 1
            first = index
            index += 1
            rider_num = 1

    print(count)

if __name__ == "__main__":
    main()

Solution (Python):



import sys, math, random, operator
from string import ascii_lowercase, ascii_uppercase
from fractions import Fraction, gcd

from itertools import product, permutations, combinations
from Queue import Queue, PriorityQueue
from collections import deque, defaultdict, Counter


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

if sys.subversion[0] == "PyPy":
    import io, atexit
    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
    sys.stdin = io.BytesIO(sys.stdin.read())
    raw_input = lambda: sys.stdin.readline().rstrip()
pr = lambda *args: sys.stdout.write(" ".join(str(x) for x in args) + "\n")
epr = lambda *args: sys.stderr.write(" ".join(str(x) for x in args) + "\n")
die = lambda *args: pr(*args) ^ exit(0)

read_str = raw_input
read_strs = lambda: raw_input().split()
read_int = lambda: int(raw_input())
read_ints = lambda: map(int, raw_input().split())
read_float = lambda: float(raw_input())
read_floats = lambda: map(float, raw_input().split())

"---------------------------------------------------------------"

N, C, K = read_ints()
arr = []
for i in xrange(N):
    t = read_int()
    arr.append(t)
arr.sort()

last_bus = INF
nfree = 0
ans = 0
for t in reversed(arr):
    if t >= last_bus - K and nfree > 0:
        nfree -= 1
    else:
        
        ans += 1
        nfree = C - 1
        last_bus = t

print ans

Solution (Python):

def getLnInputs():
    return input().split()


def getLnIntInputs():
    return list(map(int, getLnInputs()))


def main():
    N, C, K = getLnIntInputs()

    a_queue = []
    bus_count = 0
    for _ in range(N):
        a_queue.append(int(input()))

    a_queue = sorted(a_queue)
    p_queue = []

    for i in range(N):
        t = a_queue[i]
        if len(p_queue) != 0 and t - p_queue[0] > K:
            p_queue = [t]
            bus_count += 1
            continue

        p_queue.append(t)

        if len(p_queue) == C:
            p_queue = []
            bus_count += 1

    if len(p_queue):
        bus_count += 1

    print(bus_count)
    return


main()

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

time_of_bus = 0
num_of_people = 0
num_of_bus = 0
for i in range(n):
    if time_of_bus == 0:
        time_of_bus = t[i] + k
        num_of_people = 1
        num_of_bus += 1
    elif t[i] <= time_of_bus and num_of_people < c:
        num_of_people += 1
    else:
        time_of_bus = t[i] + k
        num_of_people = 1
        num_of_bus += 1
print(num_of_bus)

Solution (Python):
temp=input().split()
N=int(temp[0])
C=int(temp[1])
K=int(temp[2])
T=[int(input()) for i in range(N)]

T.sort()
ans=1
first=T[0]
bus=1
for i in range(1,N):
	if T[i]<=first+K:
		if bus<C:
			bus+=1
			continue
		else:
			ans+=1
			first=T[i]
			bus=1
	else:
		ans+=1
		bus=1
		first=T[i]
print(ans)

Solution (Python):
N,C,K = map(int,input().split())
A = []
for n in range(N):
	a = int(input())
	A.append(a)
A.sort()
b = 0
for a in A:
	if b == 0:
		b = 1
		c = 1
		t = a
	elif c >= C:
		b = b + 1
		c = 1
		t = a
	elif a <= t + K and c < C:
		c = c + 1
	elif a > t + K:
		b = b + 1
		c = 1
		t = a
print(b)

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

cnt = 1
t0 = T[0]
c = 0
for t in T:
    if c < C and t <= t0 + K:
        c += 1
    else:
        c = 1
        t0 = t
        cnt += 1
print cnt

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

a = 0

c = 0
l = t[0]
for i in range(N):
    if c == C or t[i] - l > K:
        a += 1
        c = 0
        l = t[i]
    
    c += 1

if c > 0:
    a += 1

print(a)

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

current_bus = -1
n_people_in_current_bus = 0
n_buses = 0
for t in T:
    if t <= current_bus <= t + K and n_people_in_current_bus < C:
        n_people_in_current_bus += 1
    else:
        n_buses += 1
        current_bus = t + K
        n_people_in_current_bus = 1
print(n_buses)

Solution (Python):
n, c, k = list(map(int, input().split()))
ts = []
for i in range(n):
    ts.append(int(input()))
ts = sorted(ts)
cnt = 0
fst = 0
ret = 1
for p in ts:
    if fst==0:
        fst = p
        cnt += 1
    elif p-fst > k or cnt >= c:
        ret += 1
        cnt = 1
        fst = p
    else:
        cnt += 1
    
print(ret)

Solution (Python):
import sys

def solve():
    N, C, K = map(int, sys.stdin.readline().split())
    T = [int(sys.stdin.readline().rstrip()) for i in range(N)]
    T.sort()

    l = T[0]
    cnt = 1
    ans = 1

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

    print(ans)


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

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

Solution (Python):
passengers,bus,limit = (int(n) for n in input().split(" "))
target = []
for p in range(passengers):
    target.append(int(input()))
target.sort()
answer = 0
temp_bus = []
now_time = 0
for p in target:
    
    now_time = p
    if len(temp_bus) == 0:
        temp_bus.append(p)
    elif len(temp_bus) < bus and now_time - temp_bus[0] <= limit:
        temp_bus.append(p)
    elif now_time - temp_bus[0] > limit or len(temp_bus) >= bus:
        temp_bus = []
        answer += 1
        temp_bus.append(p)
else:
    answer += 1
print(answer)

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

N, C, K = ln()

T = []
for i in xrange(N):
    T.append(n())

T.sort()

bus = 0
last = T[0]
count = 1
for t in T[1:]:
    if t - last > K or count == C:
        bus += 1
        last = t
        count = 1
    else:
        count += 1
bus += 1

print bus

Solution (Python):


n, capa, k = [int(x) for x in input().split()]
T = sorted([int(input()) for _ in range(n)])

bus = now = 0
limit = T[0] + k
for t in T:
    if now == capa or t > limit:
        bus += 1
        now = 1
        limit = t + k
    else:
        now += 1

if now > 0:
    bus += 1

print(bus)

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

ans = []
tmp = [T[0]]
now = 1
for i in range(1, N):
    if now == C or T[i] - tmp[0] > K:
        ans.append(tmp)
        tmp = [T[i]]
        now = 1
    else:
        tmp.append(T[i])
        now += 1
ans.append(tmp)

print(len(ans))

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

t = []
for i in xrange(n):
	t.append(int(raw_input()))

t.sort()

d = -k - 1
ans = 0
p = 0
for ti in t:
	if d + k < ti or p >= c:
		ans += 1
		d = ti
		p = 0
	p += 1

print(ans)

Solution (Python):
N,C,K = map(int, raw_input().split())
T = sorted(input() for _ in range(N))
p = N-1
ans = 0
while 0<=p:
    ans += 1
    c = 0
    t = T[p]
    while c<C and 0<=p and t-K<=T[p]:
        c += 1
        p -= 1
print ans

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

ans = 0
c = C
bus_kita = 0
for i in xrange(N):
    if c == C:
        ans += 1
        c -= 1
        bus_kita = T[i]
    elif c == 0:
        ans += 1
        c = C-1
        bus_kita = T[i]
    elif T[i] - bus_kita > K:
        ans += 1
        c = C-1
        bus_kita = T[i]
    else:
        c -= 1
print ans