stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ull = unsigned long long;

using ld = long double;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

using pli = pair<ll, int>;

using pil = pair<int, ll>;

using uint = unsigned int;

template <typename T>

using Graph = vector<vector<T>>;

const int MOD = 1e9 + 7;

const ld PI = acosl(-1);



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);



    int N;

    cin >> N;



    vector<int> cnt(13);

    cnt[0] = 1;

    bool iszero = false;

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

        int a;

        cin >> a;

        cnt[a]++;

        if (cnt[a] >= 3)

            iszero = true;

    }



    if (iszero) {

        cout << 0 << endl;

        return 0;

    }



    int ans = 0;

    for (int i = 0; i < (1 << 13); ++i) {

        vector<int> v;

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

            if (!cnt[j])

                continue;

            if (cnt[j] == 2) {

                v.push_back(j);

                v.push_back(24 - j);

                continue;

            }

            if (i & (1 << j))

                v.push_back(24 - j);

            else

                v.push_back(j);

        }



        int siz = v.size();

        int res = 12;

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

            for (int k = j + 1; k < siz; ++k) {

                int dif = abs(v[j] - v[k]);

                res = min(res, min(dif, 24 - dif));

            }

        }

        ans = max(ans, res);

    }



    cout << ans << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



int main() {

    int N;

    cin >> N;

    vector<int> D(N + 1);

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

        cin >> D[i];

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



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

        if (i & 1)

            D[i] = 24 - D[i];



    int ans = 13;

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

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

            int stmp = abs(D[i] - D[j]);

            ans = min(ans, min(stmp, 24 - stmp));

        }

    }



    cout << ans << endl;



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll cnt[15]={};

  

  cnt[0]++; //Takahashi-kun

  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}

  

  ll f=0;

  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;

  if(cnt[0]>=2 || cnt[12]>=2) f=1;

  if(f) {pt(0); return 0;}

  

  

  ll ans=0;

  for(ll S=0; S<1<<11; S++) {

    vector<ll> l, r;

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

      if(cnt[i]==1) {

        if(S>>i&1) l.push_back(i);

        else r.push_back(i);

      }else if(cnt[i]==2) {

        l.push_back(i);

        r.push_back(i);

      }

    }

    if(cnt[12]) l.push_back(12);

    

    ll t=INF;

    ll LS=l.size(), RS=r.size();

    if(LS) chmin(t, l[0]-0);

    for(i=0; i<LS-1; i++) chmin(t, l[i+1]-l[i]);

    

    if(RS) chmin(t, r[0]-0);

    for(i=0; i<RS-1; i++) chmin(t, r[i+1]-r[i]);

    

    if(LS&&RS) chmin(t, 24-(l[LS-1]+r[RS-1]));

    

    chmax(ans, t);

    

  }

  

  

  pt(ans);

  

}




// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll d[55];

  

  for(i=0; i<N; i++) cin >> d[i];

  sort(d, d+N);

  

  

  vector<ll> v; v.push_back(0);

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

    if(i&1) v.push_back(d[i]);

    else v.push_back(24-d[i]);

  }

  v.push_back(24);

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

  

  ll ans=INF;

  for(i=0; i<(ll)v.size()-1; i++) chmin(ans, v[i+1]-v[i]);

  

  pt(ans);

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll cnt[15]={};

  

  cnt[0]++; //Takahashi-kun

  for(i=0; i<N; i++) { ll t; cin >> t; cnt[t]++;}

  

  ll f=0;

  for(i=1; i<=11; i++) if(cnt[i]>=3) f=1;

  if(cnt[0]>=2 || cnt[12]>=2) f=1;

  if(f) {pt(0); return 0;}

  

  

  ll ans=0;

  for(ll S=0; S<1<<10; S++) {

    vector<ll> v; v.push_back(0);

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

      if(cnt[i]==1) {

        if(S>>(i-1)&1) v.push_back(i);

        else v.push_back(24-i);

      }else if(cnt[i]==2) {

        v.push_back(i);

        v.push_back(24-i);

      }

    }

    if(cnt[12]) v.push_back(12);

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

    

    

    ll t=INF;

    ll L=v.size();

    for(i=0; i<L-1; i++) chmin(t, v[i+1]-v[i]);

    chmin(t, 24-v[L-1]);

    

    

    chmax(ans, t);

  }

  

  

  pt(ans);

  

}




// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

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

   cin >> a[i];

*/





int main(void) {

  ll i, j, k;

  ll N;

  cin >> N;

  ll d[55];

  

  for(i=0; i<N; i++) cin >> d[i];

  sort(d, d+N);

  

  

  vector<ll> v; v.push_back(0);

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

    if(i&1) v.push_back(d[i]);

    else v.push_back(24-d[i]);

  }

  v.push_back(24);

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

  

  ll ans=INF;

  for(i=0; i<(ll)v.size()-1; i++) chmin(ans, v[i+1]-v[i]);

  

  pt(ans);

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <cstdio>

#include <iostream>

using namespace std;

 

const int N = 51;

int d[N];

int p[N];

int foo[N];

int n;

int res;

 

void backtrack(int i) {

    if (i == n) {

        copy(foo, foo + n, p);

        sort(p, p + n);

        int s = 24;

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

            s = min(s, min(abs(p[i] - p[j]), 24 - abs(p[i] - p[j])));

        }

        res = max(res, s);

    } else {

        for (int t = -1; t <= 1; t += 2) {

            foo[i] = d[i] * t;

            backtrack(i + 1);

            if (d[i] == 12 || d[i] == 0) break;

        }

    }

}

 

int main() {

    scanf("%d", &n);

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

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

	}

    foo[1] = d[1];

    ++ n;

    if (n > 24) {

        printf("0");

        return 0;

    }

    

    backtrack(2);

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



	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

int a[60];



int main()

{

	int n;scanf("%d",&n);n++;

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

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

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

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

	{

		if(i&1)

			a[i]=24-a[i];

		if(a[i]==24)

			a[i]=0;

	}

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

	int mx=2147483647;

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

		mx=std::min(mx,a[i]-a[i-1]);

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

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define GLX glx ak!!

#define ZZH zzh ak!!

#define LYH lyh ak!!

#define XRY xry ak!!

#define ZJH zjh ak!!

#define HP hp ak!!

#define WXH wxh ak!!

#define JIRY jiry good teacher

#define DYH dyh good teacher

#define ll long long

using namespace std;

int n,ans,x,f[110];

bool vis[110];

inline void dfs(int x){

    if(x>12){

        int ret=24;

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

            for(int j=i+1;j<=23;j++)

                if(vis[i]&&vis[j]) ret=min(ret,min(j-i,24-j+i));

        ans=max(ans,ret);

        return ;

    }

    if(f[x]==2){

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

		dfs(x+1);

		return;

	}

	if(f[x]){

        vis[x]=1;

		dfs(x+1);

		vis[x]=0;

        if(x){

        	vis[24-x]=1;

			dfs(x+1);

			vis[24-x]=0;

    	}

		return ;

	}

    dfs(x+1);

	return;

}

int main(){

    scanf("%d",&n);

    f[0]=1;

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

		scanf("%d",&x);

		f[x]++;

	}

	if(f[12]>1||f[0]>1){puts("0");return 0;}

    for(int i=1;i<=12;i++) if(f[i]>2){puts("0");return 0;}

    dfs(0);

    printf("%d",ans);

    return 0;

}

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

}

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

}


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

}

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

}

// 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> 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;

}


// 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;



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;

}

// 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<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;

}

// 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):
/*

	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;

}

// 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<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;

}

// 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<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);

}

// 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: