Language: C

  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int lb(int l,int r,int n,int *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<=d[m]?lb(l,m,n,d):lb(m+1,r,n,d);
}
int main(){
  long long n,m,ans=0,e=0,i;
  int s=0,c[200010],d[200010],a=0,b[200010]={};
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  hin(0);
  for(i=0;i<n;i++){
    s=(s+d[i]-1+m)%m;
    c[i]=s;
    hin(s);
  }
  //for(i=0;i<n;i++)printf("%d ",c[i]);printf("\n");
  for(i=0;i<n;i++)d[i]=N[hout()];
  b[0]++;
  for(i=0;i<m-1;i++){
    //printf("%d\n",lb(0,n,c[i],d));
    b[lb(0,n,c[i],d)]++;
  }//printf("\n");
  a=0;
  //for(i=0;i<5;i++)printf("%lld ",b[i]);printf("\n");
  for(i=0;i<n;i++){
    b[lb(0,n,a,d)]--;
    //int j;
    //for(j=0;j<5;j++)printf("%lld ",b[j]);printf("\n");
    ans+=b[lb(0,n,a,d)];//printf("%lld %d\n",ans,lb(0,n,a,d));
    //printf("!%d %d\n",c[i+m],lb(0,n,c[i+m],d));
    if(i+m-1<n)b[lb(0,n,c[i+m-1],d)]++;
    //for(j=0;j<5;j++)printf("%lld ",b[j]);printf("\n");printf("\n");
    a=c[i];
  }
  printf("%lld\n",ans);
  return 0;
}
	   


Compiler output:
main.c:1:9: error: 'C' undeclared here (not in a function)
    1 |   int i=C++;
      |         ^
main.c:2:3: error: expected identifier or '(' before 'for'
    2 |   for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
      |   ^~~
main.c:2:26: error: expected declaration specifiers or '...' before numeric constant
    2 |   for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
      |                          ^
main.c:2:28: error: expected declaration specifiers or '...' before 'i'
    2 |   for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
      |                            ^
main.c:2:34: error: expected '=', ',', ';', 'asm' or '__attribute__' before '/=' token
    2 |   for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
      |                                  ^~
main.c:3:3: warning: data definition has no type or storage class
    3 |   H[i]=R++;
      |   ^
main.c:3:3: error: type defaults to 'int' in declaration of 'H' [-Wimplicit-int]
main.c:3:3: error: variably modified 'H' at file scope
main.c:3:8: error: 'R' undeclared here (not in a function)
    3 |   H[i]=R++;
      |        ^
main.c:4:1: error: expected identifier or '(' before '}' token
    4 | }
      | ^
main.c: In function 'hout':
main.c:8:11: error: implicit declaration of function 'hyouka' [-Wimplicit-function-declaration]
    8 |   for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
      |           ^~~~~~
main.c: In function 'main':
main.c:20:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   20 |   scanf("%lld %lld",&n,&m);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 |   int i=C++;
main.c:20:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   20 |   scanf("%lld %lld",&n,&m);
      |   ^~~~~
main.c:20:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:22:3: error: implicit declaration of function 'hin' [-Wimplicit-function-declaration]
   22 |   hin(0);
      |   ^~~
main.c:29:24: error: 'N' undeclared (first use in this function)
   29 |   for(i=0;i<n;i++)d[i]=N[hout()];
      |                        ^
main.c:29:24: note: each undeclared identifier is reported only once for each function it appears in
main.c:47:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   47 |   printf("%lld\n",ans);
      |   ^~~~~~
main.c:47:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:47:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:47:3: note: include '<stdio.h>' or provide a declaration of 'printf'