stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;





}








// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: