Language: C++

#include<bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int min3(int a,int b,int c){return min(min(a,b),c);}
int max3(int a,int b,int c){return max(max(a,b),c);}
int gcd(int x, int y){if(y==0)return x;return gcd(y, x%y);}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int maxn=1e6+6;
typedef long long ll;
const int mod=1e9+7;
int a[maxn];
int main()
{
    int n,c,k;
    scanf("%d%d%d",&n,&c,&k);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int last=a[1];
    int cnt=1;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=last+k)
        {
            cnt++;
            if(cnt>c)cnt=1,ans++,last=a[i];

        }
        else
        {
            cnt=1;
            last=a[i];
            ans++;
        }
    }
    printf("%d\n",ans+1);
    return 0;
}
#include<bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <vector>
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fLL
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int min3(int a,int b,int c){return min(min(a,b),c);}
int max3(int a,int b,int c){return max(max(a,b),c);}
int gcd(int x, int y){if(y==0)return x;return gcd(y, x%y);}
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const int maxn=1e6+6;
typedef long long ll;
const int mod=1e9+7;
int a[maxn];
int main()
{
    int n,c,k;
    scanf("%d%d%d",&n,&c,&k);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int last=a[1];
    int cnt=1;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=last+k)
        {
            cnt++;
            if(cnt>c)cnt=1,ans++,last=a[i];

        }
        else
        {
            cnt=1;
            last=a[i];
            ans++;
        }
    }
    printf("%d\n",ans+1);
    return 0;
}


Compiler output:
a.cc:84:5: error: redefinition of 'int min3(int, int, int)'
   84 | int min3(int a,int b,int c){return min(min(a,b),c);}
      |     ^~~~
a.cc:25:5: note: 'int min3(int, int, int)' previously defined here
   25 | int min3(int a,int b,int c){return min(min(a,b),c);}
      |     ^~~~
a.cc:85:5: error: redefinition of 'int max3(int, int, int)'
   85 | int max3(int a,int b,int c){return max(max(a,b),c);}
      |     ^~~~
a.cc:26:5: note: 'int max3(int, int, int)' previously defined here
   26 | int max3(int a,int b,int c){return max(max(a,b),c);}
      |     ^~~~
a.cc:86:5: error: redefinition of 'int gcd(int, int)'
   86 | int gcd(int x, int y){if(y==0)return x;return gcd(y, x%y);}
      |     ^~~
a.cc:27:5: note: 'int gcd(int, int)' previously defined here
   27 | int gcd(int x, int y){if(y==0)return x;return gcd(y, x%y);}
      |     ^~~
a.cc:87:12: error: redefinition of 'int read()'
   87 | inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
      |            ^~~~
a.cc:28:12: note: 'int read()' previously defined here
   28 | inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
      |            ^~~~
a.cc:89:11: error: redefinition of 'const int maxn'
   89 | const int maxn=1e6+6;
      |           ^~~~
a.cc:30:11: note: 'const int maxn' previously defined here
   30 | const int maxn=1e6+6;
      |           ^~~~
a.cc:91:11: error: redefinition of 'const int mod'
   91 | const int mod=1e9+7;
      |           ^~~
a.cc:32:11: note: 'const int mod' previously defined here
   32 | const int mod=1e9+7;
      |           ^~~
a.cc:92:5: error: redefinition of 'int a [1000006]'
   92 | int a[maxn];
      |     ^
a.cc:33:5: note: 'int a [1000006]' previously declared here
   33 | int a[maxn];
      |     ^
a.cc:93:5: error: redefinition of 'int main()'
   93 | int main()
      |     ^~~~
a.cc:34:5: note: 'int main()' previously defined here
   34 | int main()
      |     ^~~~