Language: C++

#include <iostream>
#include <stdlib.h>
#include <utility>
using namespace std;
const int MaxN=100003;
int n,c,k,res=0,nnx=0,nny=0,idx[MaxN],idy[MaxN];
bool dau[MaxN];
struct ta{ int x,y;};

ta a[MaxN];
ta b[2*MaxN],trx[8*MaxN],trey[8*MaxN];
void upx(int i){
    if (idx[i]==0){
        nnx++;
        idx[i]=nnx;
        trx[nnx]=i;
    }
    int cha=nnx,hh=a[i].x,con=cha/2;
    while (con>0){
        if (a[trx[cha]].x<=hh) break;
        trx[cha*2]=trx[cha];
        idx[trx[cha]]=cha*2;
        cha=con;
        con=cha/2;
    }
    idx[i]=cha;
    trx[cha]=i;
}
void upy(int i){
    if (idy[i]==0){
        nny++;
        idy[i]=nny;
        trey[nny]=i;
    }
    int cha=nny,hh=a[i].y,con=cha/2;
    while (con>0){
        if (a[trey[cha]].x<=hh) break;
        trey[cha*2]=trey[cha];
        idy[trey[cha]]=cha*2;
        cha=con;
        con=cha/2;
    }
    idy[i]=cha;
    trey[cha]=i;
}
void downx(){
}
void downy(int i){
    int cha=i,con=cha*2,hh=a[trey[i]].y;
    while (con<=nny){
        if (con<nny && a[trey[con]].y>a[trey[con+1]].y) con++;
        if (hh<=a[trey[con]].y) break;
        trey[cha]=trey[con];
        idy[trey[con]]=cha;
        cha=con;
        con=cha*2;
    }
    idy[i]=cha;
    trey[cha]=i;
}
int popx(){
    int i=trx[1];
    trx[1]=trx[nnx];
    idx[trx[nnx]]=1;
    idx[i]=0;
    nnx--;
    downx();
    return i;
}
int popy(int i){
    int j=trey[i];
    trey[i]=trey[nny];
    idy[trey[nny]]=i;
    nny--;
    downy(i);
    idy[j]=0;
    return j;
}
void Sort(int l,int r){
    int hh=(rand % (r-l+1))+l;
    int i=l,j=r;
    while (i<j){
        while ( (a[hh].x>a[i].x)||(a[hh].x==a[i].x && a[i].y<a[hh].y)) i++;
        while ( (a[hh].x<a[j].x)||(a[hh].x==a[j].x && a[j].y>a[hh].y)) j--;
        if (i<=j){
            swap(a[i],a[j]); i++; j--;
        }
    }
    if (i<r) Sort(i,r);
    if (j>l) Sort(l,j);
}
void process(int c){
    int i=1,k,co;
    while (nny>0){
        res++;
        k=a[popy(1)].y;
        co=1;
        while (co<c && i<n && a[i].x<=k){
            co++;
            popy(idy[i]);
            i++;
        }
    }
}
void main(){
    cin >> n >> c >> k;
    int i,j=-1,h;
    for (i=0;i<n;i++){
      cin >> a[i].x;
      a[i].y=a[i].x+k;
      dau[i]=true;
    }
    Sort(0,n-1);
    for (i=0;i<n;i++) upy(i);
    process(c);
    cout << res;
}


Compiler output:
a.cc: In function 'void upx(int)':
a.cc:16:18: error: no match for 'operator=' (operand types are 'ta' and 'int')
   16 |         trx[nnx]=i;
      |                  ^
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(const ta&)'
    8 | struct ta{ int x,y;};
      |        ^~
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'const ta&'
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(ta&&)'
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'ta&&'
a.cc:20:14: error: no match for 'operator[]' (operand types are 'ta [100003]' and 'ta')
   20 |         if (a[trx[cha]].x<=hh) break;
      |              ^
a.cc:22:12: error: no match for 'operator[]' (operand types are 'int [100003]' and 'ta')
   22 |         idx[trx[cha]]=cha*2;
      |            ^
a.cc:27:14: error: no match for 'operator=' (operand types are 'ta' and 'int')
   27 |     trx[cha]=i;
      |              ^
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(const ta&)'
    8 | struct ta{ int x,y;};
      |        ^~
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'const ta&'
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(ta&&)'
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'ta&&'
a.cc: In function 'void upy(int)':
a.cc:33:19: error: no match for 'operator=' (operand types are 'ta' and 'int')
   33 |         trey[nny]=i;
      |                   ^
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(const ta&)'
    8 | struct ta{ int x,y;};
      |        ^~
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'const ta&'
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(ta&&)'
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'ta&&'
a.cc:37:14: error: no match for 'operator[]' (operand types are 'ta [100003]' and 'ta')
   37 |         if (a[trey[cha]].x<=hh) break;
      |              ^
a.cc:39:12: error: no match for 'operator[]' (operand types are 'int [100003]' and 'ta')
   39 |         idy[trey[cha]]=cha*2;
      |            ^
a.cc:44:15: error: no match for 'operator=' (operand types are 'ta' and 'int')
   44 |     trey[cha]=i;
      |               ^
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(const ta&)'
    8 | struct ta{ int x,y;};
      |        ^~
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'const ta&'
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(ta&&)'
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'ta&&'
a.cc: In function 'void downy(int)':
a.cc:49:29: error: no match for 'operator[]' (operand types are 'ta [100003]' and 'ta')
   49 |     int cha=i,con=cha*2,hh=a[trey[i]].y;
      |                             ^
a.cc:51:25: error: no match for 'operator[]' (operand types are 'ta [100003]' and 'ta')
   51 |         if (con<nny && a[trey[con]].y>a[trey[con+1]].y) con++;
      |                         ^
a.cc:51:40: error: no match for 'operator[]' (operand types are 'ta [100003]' and 'ta')
   51 |         if (con<nny && a[trey[con]].y>a[trey[con+1]].y) con++;
      |                                        ^
a.cc:52:18: error: no match for 'operator[]' (operand types are 'ta [100003]' and 'ta')
   52 |         if (hh<=a[trey[con]].y) break;
      |                  ^
a.cc:54:12: error: no match for 'operator[]' (operand types are 'int [100003]' and 'ta')
   54 |         idy[trey[con]]=cha;
      |            ^
a.cc:59:15: error: no match for 'operator=' (operand types are 'ta' and 'int')
   59 |     trey[cha]=i;
      |               ^
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(const ta&)'
    8 | struct ta{ int x,y;};
      |        ^~
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'const ta&'
a.cc:8:8: note: candidate: 'constexpr ta& ta::operator=(ta&&)'
a.cc:8:8: note:   no known conversion for argument 1 from 'int' to 'ta&&'
a.cc: In function 'int popx()':
a.cc:62:16: error: cannot convert 'ta' to 'int' in initialization
   62 |     int i=trx[1];
      |           ~~~~~^
      |                |
      |                ta
a.cc:64:8: error: no match for 'operator[]' (operand types are 'int [100003]' and 'ta')
   64 |     idx[trx[nnx]]=1;
      |        ^
a.cc: In function 'int popy(int)':
a.cc:71:17: error: cannot convert 'ta' to 'int' in initialization
   71 |     int j=trey[i];
      |           ~~~~~~^
      |                 |
      |                 ta
a.cc:73:8: error: no match for 'operator[]' (operand types are 'int [100003]' and 'ta')
   73 |     idy[trey[nny]]=i;
      |        ^
a.cc: In function 'void Sort(int, int)':
a.cc:80:18: error: invalid operands of types 'int() noexcept' and 'int' to binary 'operator%'
   80 |     int hh=(rand % (r-l+1))+l;
      |             ~~~~ ^ ~~~~~~~
      |             |          |
      |             |          int
      |             int() noexcept
a.cc: At global scope:
a.cc:105:1: error: '::main' must return 'int'
  105 | void main(){
      | ^~~~