Language: C

#include <stdio.h>
#include <string.h>
#define ll long long
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;

const int N = 1200100;
const int M = 1000100;
const int Maxn = 100100;
char str[M], tmp[Maxn];
int r[N], vis[N], cnt[M];
int id[Maxn];

int ua[N], ub[N], us[N], sa[N];
int cmp(int *r,int a,int b,int l){
	return r[a]==r[b]&&r[a+l]==r[b+l];
}
void da(int *r,int *sa,int n,int m){ //da(r, sa, n + 1, 256);(r[n] = 0)
	int i,j,p,*x=ua,*y=ub,*t; 			//r[]蟄俶叛蜴溷ュ礼ャヲ荳イ?御ク比サ残har蜿倅クコint
	for(i=0;i<m;i++) us[i]=0; 	//sa[i]陦ィ遉コ謗貞錐荳コi逧?錘郛?オキ蟋倶ク区?(i>=1,sa[i]>=0)
	for(i=0;i<n;i++) us[x[i]=r[i]]++;
	for(i=1;i<m;i++) us[i]+=us[i-1];
	for(i=n-1;i>=0;i--) sa[--us[x[i]]]=i;
	for(j=1,p=1;p<n;j*=2,m=p){
		for(p=0,i=n-j;i<n;i++) y[p++]=i;
		for(i=0;i<n;i++) if(sa[i]>=j) y[p++]=sa[i]-j;
		for(i=0;i<m;i++) us[i]=0;
		for(i=0;i<n;i++) us[x[i]]++;
		for(i=1;i<m;i++) us[i]+=us[i-1];
		for(i=n-1;i>=0;i--) sa[--us[x[y[i]]]]=y[i];
		for(t=x,x=y,y=t,p=1,x[sa[0]]=0,i=1;i<n;i++)
			x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++;
	}
}
int rank[N],height[N]; //height[i]荳コ謗堤ャャi-1蜥檎ャャi逧?錘郛?噪蜈ャ蜈ア蜑咲シ?柄蠎ヲ
void calheight(int *r,int *sa,int n){
     int i,j,k=0;
     for(i=1;i<=n;i++) rank[sa[i]]=i;
     for(i=0;i<n;height[rank[i++]]=k)
     	for(k?k--:0,j=sa[rank[i]-1];r[i+k]==r[j+k];k++);
}
int *RMQ = height; // RMQ荳コ譟・隸「逧?焚扈?霑咎?RMQ=height
//int RMQ[N];
int mm[N];
int best[20][N]; //best[i][j]陦ィ遉コ[j, j + 2^i)蛹コ髣エ荳ュ逧?怙蟆丞?
void initRMQ(int n){
     int i,j,a,b;
     for(mm[0]=-1,i=1;i<=n;i++)
     	mm[i]=((i&(i-1))==0)?mm[i-1]+1:mm[i-1];
     for(i=1;i<=n;i++) best[0][i]=i;
     for(i=1;i<=mm[n];i++)
     for(j=1;j<=n+1-(1<<i);j++){
       a=best[i-1][j];
       b=best[i-1][j+(1<<(i-1))];
       if(RMQ[a]<RMQ[b]) best[i][j]=a;
       else best[i][j]=b;
     }
}

int main(){
    int T, n, len, tlen, st, ed;
    ll ans=0;
    scanf("%d", &T);
    for(int cs=1; cs<=T; cs++){
        scanf("%s", str);
        len=strlen(str);
        for(int i=0; i<len; i++)  {
            r[i]=str[i]-'a'+1;
            vis[i]=0;
            cnt[i]=0;
        }
        tlen=len;
        scanf("%d", &n);
        for(int i=1; i<=n; i++){
            scanf("%s", tmp);
            r[tlen]=29;
            vis[tlen]=-1;
            tlen++;
            id[i]=tlen+1;
            int ltmp=strlen(tmp);
            for(int j=0; j<ltmp; j++) {
                r[tlen]=tmp[j]-'a'+1;
                vis[tlen++]=i;
            }
        }
        id[n+1]=tlen;
        r[tlen]=0;
        da(r, sa, tlen+1, 35);
        calheight(r, sa, tlen);
        height[1]=0; height[tlen+1]=0;
printf("tlen==%d\n", tlen);
for(int i=1; i<=tlen; i++){
    for(int j=sa[i]; j<tlen; j++) printf("%c", r[j]+'a'-1); puts("");
}
        ans=0;
        for(int i=1; i<=tlen; i++){                         //pai ming
            int t=sa[i], num;
            num=vis[t];                        //t shi xiabiao, num shi xuhao
            if(num>0 && t==id[ num ]){
                    if(height[i+1]>=id[num+1]-id[num]){
                        ed=i+1;
                        while(height[ed]>=id[num+1]-id[num]) {
                            if(vis[sa[ed]]==0) cnt[sa[ed]]=1;
                            ed++;
                        }
                    }
                    if(height[i]  >=id[num+1]-id[num]){
                        st=i;
                        while(st>=2 && height[st]>=id[num+1]-id[num]) {
                            if(vis[sa[st-1]]==0) cnt[sa[st-1]]=1;
                            st--;
                        }
                    }
            }
        }

        for(int i=1; i<=tlen; i++){
            int t=sa[i], num;
            num=vis[t];
            if( num==0 && cnt[t]==0) ans+=len-t;
        }
        printf("Case #%d: %lld\n", cs, ans);
    }
    return 0;
}

Compiler output:
main.c:5:1: error: unknown type name 'using'
    5 | using namespace std;
      | ^~~~~
main.c:5:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    5 | using namespace std;
      |                 ^~~
main.c:10:6: error: variably modified 'str' at file scope
   10 | char str[M], tmp[Maxn];
      |      ^~~
main.c:10:14: error: variably modified 'tmp' at file scope
   10 | char str[M], tmp[Maxn];
      |              ^~~
main.c:11:5: error: variably modified 'r' at file scope
   11 | int r[N], vis[N], cnt[M];
      |     ^
main.c:11:11: error: variably modified 'vis' at file scope
   11 | int r[N], vis[N], cnt[M];
      |           ^~~
main.c:11:19: error: variably modified 'cnt' at file scope
   11 | int r[N], vis[N], cnt[M];
      |                   ^~~
main.c:12:5: error: variably modified 'id' at file scope
   12 | int id[Maxn];
      |     ^~
main.c:14:5: error: variably modified 'ua' at file scope
   14 | int ua[N], ub[N], us[N], sa[N];
      |     ^~
main.c:14:12: error: variably modified 'ub' at file scope
   14 | int ua[N], ub[N], us[N], sa[N];
      |            ^~
main.c:14:19: error: variably modified 'us' at file scope
   14 | int ua[N], ub[N], us[N], sa[N];
      |                   ^~
main.c:14:26: error: variably modified 'sa' at file scope
   14 | int ua[N], ub[N], us[N], sa[N];
      |                          ^~
main.c:35:5: error: variably modified 'rank' at file scope
   35 | int rank[N],height[N]; //height[i]荳コ謗堤ャャi-1蜥檎ャャi逧?錘郛?噪蜈ャ蜈ア蜑咲シ?柄蠎ヲ
      |     ^~~~
main.c:35:13: error: variably modified 'height' at file scope
   35 | int rank[N],height[N]; //height[i]荳コ謗堤ャャi-1蜥檎ャャi逧?錘郛?噪蜈ャ蜈ア蜑咲シ?柄蠎ヲ
      |             ^~~~~~
main.c:44:5: error: variably modified 'mm' at file scope
   44 | int mm[N];
      |     ^~
main.c:45:5: error: variably modified 'best' at file scope
   45 | int best[20][N]; //best[i][j]陦ィ遉コ[j, j + 2^i)蛹コ髣エ荳ュ逧?怙蟆丞?
      |     ^~~~