stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int n, ans = 0 ;

int d[55], cnt[30] ;

bool vis[30] ;

vector<int> v ;

void dfs (int cur) {

    if (cur == n) {

        int res = 1e9 ;

        for (int i = 0; i < v.size(); i ++)

            for (int j = i + 1; j < v.size(); j ++)

                res = min (res, min (abs (v[i] - v[j]), 24 - abs (v[i] - v[j]))) ;

        ans = max (ans, res) ;

        return ;

    }

    dfs (cur + 1) ;

    if (!vis[v[cur]]) {

        v[cur] = 24 - v[cur] ;

        dfs (cur + 1) ;

        v[cur] = 24 - v[cur] ;

    }

}

int main() {

    cin >> n ;

    cnt[0] = 1 ;

    for (int i = 1; i <= n; i ++) {

        scanf("%d", &d[i]) ;

        cnt[d[i]] ++ ;

    }

    for (int i = 0; i <= 12; i ++)

        if (cnt[i] >= 3) {

            printf("0\n"); return 0 ;

        }

    for (int i = 0; i <= 12; i ++) {

        if (cnt[i] == 1) v.push_back (i) ;

        if (cnt[i] == 2) {

            v.push_back (i), v.push_back (24 - i) ;

            vis[i] = 1; vis[24 - i] = 1 ;

        }

    }

    dfs (1) ;

    cout << ans << endl;

    return 0 ;

}


// Faster C++ solution for the same problem (measured speedup: 5.24439666842309x):
#include<stdio.h>

#include<algorithm>



using namespace std;



int dp[55][55][55];

int ar[55];

int n;



int serc(int x, int l, int r) {

  if (x == n) {

    return 1000000;

  }

  int &ret = dp[x][l][r];

  if (ret != -1) {

    return ret;

  }

  ret = 0;



  // ambil ke kanan

  ret = max(ret, min(serc(x + 1, l, x), min(ar[x] - ar[r], 24 - ar[l] - ar[x])));



  // ambil ke kiri

  ret = max(ret, min(serc(x + 1, x, r), min(ar[x] - ar[l], 24 - ar[r] - ar[x])));

  return ret;

}



int main() {

  scanf("%d", &n);

  for (int i = 1; i <= n; i++) {

    scanf("%d", &ar[i]);

    for (int j = 0; j <= n; j++) {

      for (int k = 0; k <= n; k++) {

        dp[i][j][k] = -1;

      }

    }

  }

  n++;

  sort(ar, ar + n);

  printf("%d\n", min(max(serc(2, 0, 1), serc(2, 1, 0)), ar[1] - ar[0]));

  return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

using namespace std;



#define FOR(i,a,b) for (int i = (a); i < (b); i++)

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 100000 + 47;

const int MOD = 1000 * 1000 * 1000 + 7;



int A[MAX];

int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

	ios::sync_with_stdio(false); cin.tie(0);

	int n, c, k;

	cin >> n >> c >> k;

	FOR(i, 0, n)

	{

		cin >> A[i];

	}



	sort(A, A + n);

	int cnt = 1;

	int last = 0;

	int ans = 0;



	FOR(i, 1, n)

	{

		if (cnt == c || A[i] - A[last] > k)

		{

			ans++;

			cnt = 1;

			last = i;

			continue;

		}



		cnt++;

	}



	ans++;

	cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.282525370997044x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://agc011.contest.atcoder.jp/tasks/agc011_a>

問題文============================================================

 高橋空港には，毎日飛行機で N 人の乗客が到着します． i 番目の乗客は時刻 Ti に到着します．

 

 高橋空港に到着する乗客は全員バスで市内へ移動します．

 どのバスも定員は C 人であり，C 人以下の乗客を乗せることができます．

 飛行機の乗客は，飛行機の到着時刻よりも早く出発するバスには乗ることができません．

 また，飛行機の到着時刻から K の時間が経過した後にもバスに乗れていないと，怒り出してしまいます．

 そのため，i 番目の乗客は，出発時刻が Ti 以上 Ti+K 以下であるようなバスに乗れるようにしないといけません．

 

 この条件のもとで，うまくバスの出発時刻を定めるとき，必要なバスの数の最小値を求めてください．

 ただし，バスの出発時刻は必ずしも整数である必要はなく，同じ時刻に出発するバスが複数あってもかまいません．

=================================================================



解説=============================================================



 乗客を時間に関してソートして、

 順番に、定員or時間に関して条件に反しない限りバスに乗せていけば良い

 

================================================================

*/

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    ll N,C,K; cin >> N >> C >> K;

    vector<ll> T(N);

    for(auto &in:T) cin >> in;

    sort(T.begin(),T.end());

    ll ans = 1;

    ll c = 0;

    ll from = 0;

    for(int i = 0; i < N;i++){

        if(c == C){

            ans++;

            c = from = 0;

        }

        

        if(c == 0){

            c++;

            from = T[i];

        }else{

            if(T[i] - from<=K){

                c++;

            }else{

                ans++;

                c = 1;

                from = T[i];

            }

        }

    }

    cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3275975852617545x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int N = 1e5 + 10;



int a[N];



int main(){

	int n, c, k, cnt, now, ans;

	scanf("%d %d %d",&n,&c,&k);

	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);

	sort(a + 1, a + n + 1);

	cnt = 1; now = a[1]; ans = 1;

	for (int i = 2; i <= n; i++){

		if (a[i] - now > k || cnt >= c){

			ans++;

			cnt = 1;

			now = a[i];

		}

		else cnt++;

	}

	printf("%d\n", ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.154377670325553x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cmath>

#include<cctype>

#include<algorithm>

using namespace std;

const int N=1e5+5;

inline int read(){

	int x=0,w=0;char ch=0;

	while(!isdigit(ch)) w|=ch=='-',ch=getchar();

	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();

	return w?-x:x;

}

int n,c,k,cnt,ans,d,t[N];

int main(){

	n=read(),c=read(),k=read();

	for(int i=1;i<=n;++i) t[i]=read();

	if(c==1){

		printf("%d\n",n);

		return 0;

	}

	sort(t+1,t+n+1);

	int last=t[1]+k,cnt=1;

	for(int i=2;i<=n;++i){

		if(!last){

			++cnt,last=t[i]+k;continue;

		}

		if(t[i]<=last){

			++cnt;

		}

		else{

			++ans;d=i-1;cnt=1;

			last=t[i]+k;

		}

		if(cnt==c){

			++ans;last=0;cnt=0;d=i;

		}

	}

	if(d^n) ++ans;

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.133656572295492x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
/*

	Name: D-机场大巴 

	Author: RoseKey

	Date: 14/02/19 16:48

	Description: 贪心+模拟 

*/



#include <set>

#include <map>

#include <stack>

#include <queue>

#include <cmath>

#include <cstdio>

#include <vector>

#include <bitset>

#include <cstring>

#include <utility>

#include <iostream>

#include <algorithm>

#define LL long long

#define Rg register

#define RI register int

#define RC register char

#define ed puts("") 

#define pair pair<LL,LL>

#define space putchar(' ')

using namespace std;

    

template <typename tp> inline void read(tp & x)

{	

    x=0;

    RI f=1;

    RC c=getchar();

    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }

    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 

 	x*=f;

} 	

    

template <typename Tp> inline void print(Tp x)

{		

    if(x<0) x=-x,putchar('-');

    if(x>9) print(x/10);

    putchar(x%10+'0');

}



int n,c,k;

int temp;

LL ans;

LL t[1000005];

int s[1000005];

bool vis[1000005];

bool flag=1;

LL kk;



int main()

{

	read(n),read(c),read(k);

	for(RI i=1;i<=n;++i)

		read(t[i]);

	stable_sort(t+1,t+n+1);

	for(RI i=1;i<=n;++i)

	{

//		int kk=t[i]+k;

//		ans++;

//		temp=c-1;

//		int flag=i;

//		for(RI j=flag+1;j<=n;++j)

//		{

//			if(t[j]<=kk && t[j]+k>=kk)

//			{

//				temp--;

//				if(temp==0)

//					break;	

//			}	

//		}	

//		int hh=c-temp;//多接了几个人

//		i+=hh-1;

		if(flag)

        {

            ++ans,++temp;

            kk=t[i]+k;

            flag=0;

        }

        else if(t[i]<=kk) 

			++temp;

        else if(t[i]>kk)

        {

            flag=true;

			temp=0;

            --i;

        }

        if(temp==c) 

        {

            flag=true;

			temp=0;

        }

	}	

	print(ans);		

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.172597382658093x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

using namespace std;

int t[100010],n,c,k;

bool jd(int x)

{

	int cnt=1; bool flag=true;

	for(int i=2;i<=n;i++)

	{

		if(t[i]-t[i-cnt]>k) {x--;cnt=0;}

		if(t[i]-t[i-cnt]<=k)

		{

			cnt++;

		}

		if(cnt==c) {x--;cnt=0;}

		if(x<0) {flag=false;break;}

	}

	if(flag==false) return false;

	else return true;

}

int main()

{

	scanf("%d%d%d",&n,&c,&k);

	for(int i=1;i<=n;i++) cin>>t[i];

	sort(t+1,t+1+n);

	int head=1,tail=n,mid;

	while(head<tail)

	{

		mid=(head+tail)/2;

		if(jd(mid-1)==false) head=mid+1;

		else tail=mid;

	}

	printf("%d",tail);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.225188936278732x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<algorithm>

using namespace std;

int T[100050];

int N,C,K;

int main()

{

	scanf("%d%d%d",&N,&C,&K);

	for(int i=0;i<N;++i)

	{

		scanf("%d",&T[i]);

	}

	sort(T,T+N);

	int sum=1;

	int cnt=1;

	int st=T[0];

	for(int i=1;i<N;++i)

	{

		if(st+K<T[i])

		{

			sum++;

			cnt=1;

			st=T[i];

			continue;

		}

		if(st+K>=T[i])

		{

			cnt++;

			if(cnt>C)

			{

				cnt=1;

				sum++;

				st=T[i];

			}

		}

	}

	printf("%d",sum);

}

// Faster C++ solution for the same problem (measured speedup: 5.153365529347605x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define rg register

#define ll long long 

inline ll read()

{

    ll x=0,f=1;

    char c=getchar();

    while(c<'0'||c>'9')

    {

        if(c=='-')

        {

            f=-1;

        }

        c=getchar();

    }

    while(c<='9'&&c>='0')

    {

        x=(x<<1)+(x<<3)+(c^48);

        c=getchar();

    }

    return x*f;

}

ll n,c,k;

struct node

{

	ll t,id;

}s[120000];

inline bool cmp(node a,node b)

{

	return a.t<b.t;

}

int main()

{

	n=read();

	c=read();

	k=read();

	for(rg int i=1;i<=n;++i)

	{

		s[i].t=read();

		s[i].id=i; 

	}

	stable_sort(s+1,s+1+n,cmp);

	int tot=0;

	int cnt=1;//当前第几个客人 

	double h=0;

	while(1)

	{

		if(cnt > n)

		{

			break;

		}

		int l=s[cnt].t;//最开始的这名客人的起始时间 

		int r=l+k;//终止时间 

		int hh=cnt;//保存开始这名客人的标号 

		ll sum=0;//累加这辆车坐的人数 

		for(rg int i=hh;i<=n;++i)

		{

			if(sum<c&&s[i].t<=r)

			{

				sum++;

			}

			else

			{

				break;

			}

		}

//		cout<<sum<<endl;

		cnt+=sum;

		tot++;

	}

	cout<<tot;

}

// Faster C++ solution for the same problem (measured speedup: 5.205235457053414x):
#include <cstdio>

#include <algorithm>

using namespace std;

const int MAXN=110000;

int t[MAXN];

int main()

{

//	freopen("A.in", "r", stdin);

//	freopen("A.out", "w", stdout);

	int n, c, k;

	scanf("%d%d%d", &n, &c, &k);

	for (int i=1; i<=n; i++) scanf("%d", &t[i]);

	sort(t+1, t+n+1);

	int ans=0;

	for (int i=1, j; i<=n; i++, i=j)

	{

		ans++; j=i;

		for (int p=0; j<=n&&p<c&&t[i]+k>=t[j]; j++) p++;

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> P;



int MOD=1e9+7;

ll INF=1e18;



int dx[]={1, -1, 0, 0};

int dy[]={0, 0, 1, -1};



int main(){

    int n, c, k; cin>>n>>c>>k;

    vector<int> bus(100010, 0), t(n);

    for(int i=0; i<n; i++) cin>>t[i];

    sort(t.begin(), t.end());

    int cnt=0, cur=t[0], ans=1;

    for(int i=0; i<n; i++){

        if(cur+k<t[i] || c==cnt){

            cnt=1;

            ans++;

            cur=t[i];

        }

        else cnt++;

    }

    cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.3875295190196328x):
#pragma GCC optimize("O3")

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <fstream>

#include <functional>

#include <bitset>

using namespace std;



using ll = long long;

using P = pair<int, int>;

using T = tuple<int, int, int>;



template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}

template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}



constexpr int MOD = 1e9 + 7;

constexpr int inf = 1e9;

constexpr long long INF = 1e18;

constexpr double pi = acos(-1);

constexpr double EPS = 1e-10;



int dx[] = {1, 0, -1, 0};

int dy[] = {0, 1, 0, -1};



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    int n, c, k; cin>>n>>c>>k;

    vector<int> t(n);

    for(int i=0; i<n; i++) cin>>t[i];

    sort(t.begin(), t.end());



    int ans = 0;

    for(int i=0; i<n; i++){

        int start_time = t[i];

        int cnt = 0;

        while(i < n && cnt < c && t[i] - start_time <= k){

            cnt++;

            i++;

        }



        i--;

        ans++;

    }



    cout << ans << endl;



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define pb push_back

#define mk make_pair

#define sc second

#define fr first



using namespace std;



typedef long long ll;



const int N = (int) 1e6 + 5;

const int mod = (int) 1e9 + 7;



int n,c,k,a[N],ans;



int main(){

        cin >> n >> c >> k;



        for(int i = 1; i <= n; i ++)

                cin >> a[i];



        sort(a + 1,a + n + 1);



        int i = 1;



        while(i <= n){

                int pos = upper_bound(a + 1,a + n + 1,a[i] + k) - a - 1;

                if(pos - i + 1 > c)

                        i += c,ans ++;

                else{

                        if(pos != i)

                                i = pos + 1,ans ++;

                        else

                                i ++,ans ++;

                }

        }

        cout << ans << endl;

        return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.020202263971376x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,c,k,a[100005],t,c1;

	long long ans=1;

	scanf("%d%d%d",&n,&c,&k);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	c1=1;t=0;

	for(i=1;i<n;i++)

	{

		if(a[i]<=a[t]+k && c1<c)

		{

			c1++;

		}

		else

		{

			ans++;

			t=i;

			c1=1;

		}

	}

	printf("%lld\n",ans);

  return 0;

}
// Slower C++ solution:
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>



using namespace std;



typedef long long ll;



const int N = (int) 1e5 + 5;

const int mod = (int) 1e9 + 7;



int n, c, k, a[N], l = 1, ans;



inline void solve () {

        scanf ("%d%d%d", &n, &c, &k);

        for (int i = 1; i <= n; i++) {

                scanf ("%d", &a[i]);

        }

        sort (a + 1, a + n + 1);

        for (int i = 2; i <= n; i++) {

                if (i - l == c || a[l] + k < a[i]) {

                        ans++;

                        l = i;

                }

        }

        ans++;

        printf ("%d\n", ans);

}



int tests = 1;



int main () {

//        freopen (".in", "r", stdin);

//        freopen (".out", "w", stdout);

//        scanf ("%d", &tests);

        srand (time (NULL));

        while (tests--) {

                solve ();

        }

        return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.99685506362823x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,c,k,a[100005],t,c1;

	long long ans=1;

	scanf("%d%d%d",&n,&c,&k);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	c1=1;t=0;

	for(i=1;i<n;i++)

	{

		if(a[i]<=a[t]+k && c1<c)

		{

			c1++;

		}

		else

		{

			ans++;

			t=i;

			c1=1;

		}

	}

	printf("%lld\n",ans);

  return 0;

}
// Slower C++ solution:
#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <memory.h>



using namespace std;



int n, ar[1000001], l, r, ans, c, k;



int main()

{

    cin >> n >> c >> k;

    for(int i = 0; i < n; i++)

        scanf("%d", &ar[i]);

    sort(ar, ar + n);



    while(l < n)

    {

        while(ar[r + 1] - k <= ar[l] && r < n - 1 && r - l + 1 < c)

            r++;

        ans++;

        l = r + 1;

    }

    cout << ans;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.027704474258974x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,c,k,a[100005],t,c1;

	long long ans=1;

	scanf("%d%d%d",&n,&c,&k);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	c1=1;t=0;

	for(i=1;i<n;i++)

	{

		if(a[i]<=a[t]+k && c1<c)

		{

			c1++;

		}

		else

		{

			ans++;

			t=i;

			c1=1;

		}

	}

	printf("%lld\n",ans);

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define pb push_back

#define mk make_pair

#define sc second

#define fr first



using namespace std;





int main () {

       int n, c, k;

       cin >> n >> c >> k;



       deque <int> v(n);

       for(int i = 0;i < n;i ++)

           cin >> v[i];



       sort(v.begin(), v.end());

       int cnt = 0;

       while(1)

       {

             int r = v.front() + k, t = 1;

             while(!v.empty() && v.front() <= r)

             {

                  v.pop_front();

                  t ++;

                  if(t > c) break;

             }

             cnt ++;

             if(v.empty()) break;

       }

       cout << cnt;

}


// Faster C++ solution for the same problem (measured speedup: 5.065239429977189x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,c,k,a[100005],t,c1;

	long long ans=1;

	scanf("%d%d%d",&n,&c,&k);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	c1=1;t=0;

	for(i=1;i<n;i++)

	{

		if(a[i]<=a[t]+k && c1<c)

		{

			c1++;

		}

		else

		{

			ans++;

			t=i;

			c1=1;

		}

	}

	printf("%lld\n",ans);

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define ll long long

#define OK puts("OK");

#define sz(s) (int)s.size()

#define all(s) s.begin(), s.end()



using namespace std;



const int N = 1e5 + 10;

const int inf = 1e9 + 7;



int n, k, c, ans, l, cn;

int a[N];



main()

{

    scanf("%d%d%d", &n, &c, &k);

    for(int i = 1; i <= n; i++)

        scanf("%d", a + i);

    sort(a + 1, a + n + 1);

    l = a[1] + k;

    cn = 1;

    for(int i = 2 ; i <= n ; i ++)

    {

        if(cn == c || l < a[i])

        {

            ans ++;

            l = a[i] + k;

            cn = 1;

        }

        else

            cn ++;

    }

    cout << ans + 1 << endl;





}








// Faster C++ solution for the same problem (measured speedup: 5.016975729745389x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,c,k,a[100005],t,c1;

	long long ans=1;

	scanf("%d%d%d",&n,&c,&k);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	c1=1;t=0;

	for(i=1;i<n;i++)

	{

		if(a[i]<=a[t]+k && c1<c)

		{

			c1++;

		}

		else

		{

			ans++;

			t=i;

			c1=1;

		}

	}

	printf("%lld\n",ans);

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n, c, k, i, j, d, a[100100], ans;



    cin >> n >> c >> k;

    for(i = 0; i < n; ++i)

    {

        cin >> a[i];

    }

    sort(a, a + n);

    d = 1; ans = 1; j = a[0];

    for(i = 1; i < n; ++i)

    {

        if(a[i] - j <= k && d + 1 <= c)

            d++;

        else

        {

            ans++;

            j = a[i];

            d = 1;

        }

    }

    cout << ans;



return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.04869921304277x):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,c,k,a[100005],t,c1;

	long long ans=1;

	scanf("%d%d%d",&n,&c,&k);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	c1=1;t=0;

	for(i=1;i<n;i++)

	{

		if(a[i]<=a[t]+k && c1<c)

		{

			c1++;

		}

		else

		{

			ans++;

			t=i;

			c1=1;

		}

	}

	printf("%lld\n",ans);

  return 0;

}