stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <stdio.h>

#include <string.h>

#include <algorithm>

#define int long long



using namespace std;



int a[123456];

int vis[123456];



signed main()

{

    int flag=0;

    int n,c,k;

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

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

    {

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

    }

    sort(a,a+n);

    int sum=0;

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

    {

        int f=a[i]+k;

        int h=0;

        while(i<n)

        {

            if(a[i]<=f)

            {

                vis[i]=1;

                h++;

            }

            if(h==c)

            {

                if(i==n-1)

                    flag=1;

                sum++;

                break;

            }

            if(a[i] > f)

            {

                i--;

                sum++;

                break;

            }

            i++;

        }

    }

    if(flag==0) sum++;

    cout<<sum<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.015980204452122x):
#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 <iostream>

#include <algorithm>

#include <stdio.h>

using namespace std;

const int N = 1e5+19;

int a[N];

int main(){

    int n, c, k;

    while(~scanf("%d %d %d",&n,&c,&k)){

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

        sort(a,a+n);

        int ans = 1;

        int st = a[0], res = 1;

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

            if(res < c && a[i] <= st+k){

                res++;

            }

            else{

                ans++;

                st = a[i];

                res = 1;

            }

        }

        cout << ans << endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.0494304894645285x):
#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<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

#define MAX 100100

inline int read()

{

	int x=0;bool t=false;char ch=getchar();

	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();

	if(ch=='-')t=true,ch=getchar();

	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();

	return t?-x:x;

}

int n,C,K,T[MAX],ans,s,t;

int main()

{

	n=read();C=read();K=read();

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

	sort(&T[1],&T[n+1]);

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

		if(!s)++ans,s=1,t=T[i];

		else

		{

			if(s==C)++ans,s=1,t=T[i];

			else

			{

				if(T[i]-t>K)++ans,s=1,t=T[i];

				else ++s;

			}

		}

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

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.233206544529983x):
#include "cstdio"

#include "algorithm"

using namespace std;

int s[100005],i,j,n,k,c,ss;

int A(){

    int a=0,k=1;char c=getchar();

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

        if(c=='-') k=-1;c=getchar();

    }

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

        a=a*10+c-'0';c=getchar();

    }

    return a*k;

}

int main(){

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

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

	s[i]=A();

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

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

		for(j=i;j<=n&&j<=i+c-1&&s[j]<=s[i]+k;j++);i=j-1;

		ss++;

	}

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

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

using namespace std;

const int N=1e5+5;

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

int main()

{

	cin>>n>>c>>k;

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

	sort(a,a+n);

	ji=a[0];

	sum=1;

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

	{

		if(k<a[i]-ji||sum==c)

			ans++,sum=1,ji=a[i];

		else

			sum++;

	}

	if(sum)ans++;

	cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.217589069673734x):
#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 <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

#include <cmath>

#include <cstring>

#include <iostream>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <string>

#include <stack>

#include <fstream>

#include <iomanip>

#include <algorithm>

#include <functional>

//#include <unordered_set>

#define INF 2147483647

#define MAXN  100005

#define PII pair<int, int>

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

PII	v[MAXN];

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

#ifdef local_debug

	ifstream inputs("input.txt");

	cin.rdbuf(inputs.rdbuf());

	freopen("input.txt", "r", stdin);

#endif

	int n, c, k, d;

	while (cin >> n >> c >> k) {

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

		{

			cin >> d;

			v[i].first = d;

			v[i].second = d + k;

		}

		sort(v, v + n, [](PII a, PII b) {

			return a.second < b.second;

		});

		int e = v[0].second;

		int t = 0, cnt = 0;

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

		{

			if (e >= v[i].first)

			{

				t++;

				if (t == c)

				{

					t = 0;

					cnt++;

					e = v[i].second;

				}

			}

			else

			{

				cnt++;

				t = 0;

				e = v[i].second;

			}

		}

		cout << cnt + 1 << endl;

	}

	return 0;

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;



using VS = vector<string>;    using LL = long long;

using VI = vector<int>;       using VVI = vector<VI>;

using PII = pair<int, int>;   using PLL = pair<LL, LL>;

using VL = vector<LL>;        using VVL = vector<VL>;



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

#define RALL(a) (a).rbegin(), (a).rend()

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

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

//#pragma GCC optimize ("-O3") 

#ifdef YANG33

#include "mydebug.hpp"

#else

#define DD(x) 

#endif

const int INF = 1e9;                          const LL LINF = 1e16;

const LL MOD = 1000000007;                    const double PI = acos(-1.0);

int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };



/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */

/* ------問題------







-----問題ここまで----- */

/* -----解説等-----





----解説ここまで---- */





int main() {



	LL N, C, K;

	cin >> N >> C >> K;

	VL a(N);

	FOR(i, 0, N) {

		cin >> a[i];

	}

	SORT(a);



	LL ans = 0;

	for (LL i = 0; i < N;) {

		ans++;

		LL t = i;

		while (t < N&&t - i < C&&a[t] <= a[i] + K)t++;

		i = t;

	}

	cout << ans << endl;

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

int n,c,k;

int t[200000];

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 pre = -1;

	int cnt = 0;

	int ans = 0;

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

		if(pre == -1){

			pre = t[i];

			ans++;

			cnt++;

		}

		else{

			if(t[i] - pre > k){

				pre = -1;

				cnt = 0;

				i--;

			}

			else if(cnt >= c){

				pre = -1;

				cnt = 0;

				i--;

			}

			else{

				cnt ++;

			}

		}

	}

	printf("%d",ans);

	return 0;

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;



int n,c,k;

int t[int(1e5+7)];

int ans;

int main()

{

	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 nt=t[1],re=c-1;

	ans++;

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

	{

		if(nt+k>=t[i]&&re>0){re--;continue;}

		ans++,nt=t[i],re=c-1;

	}

	printf("%d",ans);

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

#include<iostream>

#include<cmath>

#include<algorithm>

using namespace std;

int T[100010];

int main()

{

	int n,c,k,ans=0;

	cin>>n>>c>>k;

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

	{

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

	}

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

	T[n+1]=(int)1e9+10;

	int i=1;

	while(i<=n)

	{

		if(i==n)

		{

			ans++;break;	

		}

		int l=i,r=n,j;

		while(l<r)

		{

			j=(l+r)>>1;

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

			{

				l=j+1;

			}

			else r=j;

		}

		if(l==n)

		{

			if(T[n]-T[i]<=k&&n-i+1<=c)

			{	ans++;

				break;	}

		}

		//j=l-1;

		//i=j+1;

		i=l;

		ans++;

	}

	cout<<ans;

	return 0;

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.832820765166381x):
#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);

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

int T[100100],Head,Tail,N,C,K,ans;

int main()

{

	cin>>N>>C>>K;

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

		cin>>T[i];

	sort(T,T+N);

	while(true)

	{

		while(Tail<min(N,Head+C)&&T[Tail]<=T[Head]+K)

			Tail++;

		Head=Tail;

		ans++;

		if(Tail==N)

			break;

	}

	cout<<ans<<endl;

	return 0;

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

const int N=1e5+5;

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

int main()

{

	cin>>n>>c>>k;

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

	sort(a,a+n);

	ji=a[0];

	sum=1;

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

	{

		if(k<a[i]-ji||sum==c)

			ans++,sum=1,ji=a[i];

		else

			sum++;

	}

	if(sum)ans++;

	cout<<ans<<endl;

}

/*

Ì°ÐÄË¼Â·£º½«Í¬Ò»¶ÎÊ±¼äÄÚµÄÈËÒ»µ©×øÂúÁËÒ»Á¾³µ»òÕßÊ±¼ä³¬¹ýÁË£¬ÄÇÃ´¾ÍÔÙÐÂ¿ªÒ»Á¾³µ£¬

ÖØÐÂ¼ÇÂ¼Ò»ÏÂ×îÐÂµÄÊ±¼ä£¬È¥ÈÝÄÉ¸ü¶àµÄÈË¡£ 

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

#include <cstring>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <iostream>

#include <algorithm>

#define mt(a) memset(a,0,sizeof(a))

#define ll long long

using namespace std;

int main(void)

{

	int n,c,k;

	int p[200005];

	mt(p);

	cin>>n>>c>>k;

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

		cin>>p[i];

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

	ll ans = 1;

	int t = 1;

	int sum = 1;

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

	{

		if(p[i]<=p[t]+k&&sum<c)

		{

			sum++;

		}

		else

		{

			sum = 1;

			ans++;

			t = i;

		}		

	}

	cout<<ans<<endl;

	return 0;

}

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

#include <cstring>

#include <algorithm>

#define N 110000

using namespace std;

int n,c,k,t[N],l;

int main(){

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

	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;

	l=1;

	t[n+1]=0x7FFFFFFF;

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

		int sum=0;

		while(l<i and t[l]+k<t[i]) l+=min(i-l,c),sum++;

		ans+=sum;

	}

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

	return 0;

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

#include <cmath>

#include <cstring>

#include <iostream>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <string>

#include <stack>

#include <fstream>

#include <iomanip>

#include <algorithm>

#include <functional>

//#include <unordered_set>

#define INF 2147483647

#define MAXN  100005

#define PII pair<int, int>

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

PII	v[MAXN];

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

#ifdef local_debug

	ifstream inputs("input.txt");

	cin.rdbuf(inputs.rdbuf());

	freopen("input.txt", "r", stdin);

#endif

	int n, c, k, d;

	while (cin >> n >> c >> k) {

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

		{

			cin >> d;

			v[i].first = d;

			v[i].second = d + k;

		}

		sort(v, v + n, [](PII a, PII b) {

			return a.second < b.second;

		});

		int e = v[0].second;

		int t = 0, cnt = 0;

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

		{

			if (e >= v[i].first)

			{

				t++;

				if (t == c)

				{

					t = 0;

					cnt++;

					e = v[i].second;

				}

			}

			else

			{

				cnt++;

				t = 0;

				e = v[i].second;

			}

		}

		cout << cnt + 1 << endl;

	}

	return 0;

}

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

#include <cstring>

#include <algorithm>

#define N 110000

using namespace std;

int n,c,k,t[N],l;

int main(){

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

	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;

	l=1;

	t[n+1]=0x7FFFFFFF;

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

		int sum=0;

		while(l<i and t[l]+k<t[i]) l+=min(i-l,c),sum++;

		ans+=sum;

	}

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

	return 0;

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

using namespace std;



using VS = vector<string>;    using LL = long long;

using VI = vector<int>;       using VVI = vector<VI>;

using PII = pair<int, int>;   using PLL = pair<LL, LL>;

using VL = vector<LL>;        using VVL = vector<VL>;



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

#define RALL(a) (a).rbegin(), (a).rend()

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

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)

#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)

//#pragma GCC optimize ("-O3") 

#ifdef YANG33

#include "mydebug.hpp"

#else

#define DD(x) 

#endif

const int INF = 1e9;                          const LL LINF = 1e16;

const LL MOD = 1000000007;                    const double PI = acos(-1.0);

int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };



/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */

/* ------問題------







-----問題ここまで----- */

/* -----解説等-----





----解説ここまで---- */





int main() {



	LL N, C, K;

	cin >> N >> C >> K;

	VL a(N);

	FOR(i, 0, N) {

		cin >> a[i];

	}

	SORT(a);



	LL ans = 0;

	for (LL i = 0; i < N;) {

		ans++;

		LL t = i;

		while (t < N&&t - i < C&&a[t] <= a[i] + K)t++;

		i = t;

	}

	cout << ans << endl;

}


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

#include <cstring>

#include <algorithm>

#define N 110000

using namespace std;

int n,c,k,t[N],l;

int main(){

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

	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;

	l=1;

	t[n+1]=0x7FFFFFFF;

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

		int sum=0;

		while(l<i and t[l]+k<t[i]) l+=min(i-l,c),sum++;

		ans+=sum;

	}

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

	return 0;

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

#include<cstdio>

#include<algorithm>

using namespace std;

int n,c,k;

int t[200000];

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 pre = -1;

	int cnt = 0;

	int ans = 0;

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

		if(pre == -1){

			pre = t[i];

			ans++;

			cnt++;

		}

		else{

			if(t[i] - pre > k){

				pre = -1;

				cnt = 0;

				i--;

			}

			else if(cnt >= c){

				pre = -1;

				cnt = 0;

				i--;

			}

			else{

				cnt ++;

			}

		}

	}

	printf("%d",ans);

	return 0;

}

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

#include <cstring>

#include <algorithm>

#define N 110000

using namespace std;

int n,c,k,t[N],l;

int main(){

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

	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;

	l=1;

	t[n+1]=0x7FFFFFFF;

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

		int sum=0;

		while(l<i and t[l]+k<t[i]) l+=min(i-l,c),sum++;

		ans+=sum;

	}

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

	return 0;

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

using namespace std;



int n,c,k;

int t[int(1e5+7)];

int ans;

int main()

{

	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 nt=t[1],re=c-1;

	ans++;

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

	{

		if(nt+k>=t[i]&&re>0){re--;continue;}

		ans++,nt=t[i],re=c-1;

	}

	printf("%d",ans);

}

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

#include <cstring>

#include <algorithm>

#define N 110000

using namespace std;

int n,c,k,t[N],l;

int main(){

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

	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;

	l=1;

	t[n+1]=0x7FFFFFFF;

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

		int sum=0;

		while(l<i and t[l]+k<t[i]) l+=min(i-l,c),sum++;

		ans+=sum;

	}

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

	return 0;

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

#include<iostream>

#include<cmath>

#include<algorithm>

using namespace std;

int T[100010];

int main()

{

	int n,c,k,ans=0;

	cin>>n>>c>>k;

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

	{

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

	}

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

	T[n+1]=(int)1e9+10;

	int i=1;

	while(i<=n)

	{

		if(i==n)

		{

			ans++;break;	

		}

		int l=i,r=n,j;

		while(l<r)

		{

			j=(l+r)>>1;

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

			{

				l=j+1;

			}

			else r=j;

		}

		if(l==n)

		{

			if(T[n]-T[i]<=k&&n-i+1<=c)

			{	ans++;

				break;	}

		}

		//j=l-1;

		//i=j+1;

		i=l;

		ans++;

	}

	cout<<ans;

	return 0;

}

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

#include <cstring>

#include <algorithm>

#define N 110000

using namespace std;

int n,c,k,t[N],l;

int main(){

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

	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;

	l=1;

	t[n+1]=0x7FFFFFFF;

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

		int sum=0;

		while(l<i and t[l]+k<t[i]) l+=min(i-l,c),sum++;

		ans+=sum;

	}

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

	return 0;

}