criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>

using namespace std;

string S;

int DFS(pair<int, int> p, int depth){
    if(p.second + depth >= S.length())
        return depth;

    if (p.first + depth >= p.second)
        return depth;

    if(S[p.first + depth] == S[p.second + depth])
        return DFS(p, depth + 1);

    return depth;
}

int main(void){
    int N, result = 0;

    cin >> N >> S;

    for(int i = 0; i < S.length(); i++){
        for(int j = i + 1; j < S.length(); j++){
            if(S[i] == S[j]){}
                int tmp = DFS(make_pair(i, j), 1);
                i += tmp;
                result = max(result, tmp);
        }
        }
    }
    cout << result << endl;
    return 0;
}

Compiler output:
a.cc:37:5: error: 'cout' does not name a type
   37 |     cout << result << endl;
      |     ^~~~
a.cc:38:5: error: expected unqualified-id before 'return'
   38 |     return 0;
      |     ^~~~~~
a.cc:39:1: error: expected declaration before '}' token
   39 | }
      | ^
Language: C++

疲れた。。。

Compiler output:
a.cc:1:1: error: extended character 。 is not valid in an identifier
    1 | 疲れた。。。
      | ^
a.cc:1:1: error: extended character 。 is not valid in an identifier
a.cc:1:1: error: extended character 。 is not valid in an identifier
a.cc:1:1: error: '\U000075b2\U0000308c\U0000305f\U00003002\U00003002\U00003002' does not name a type
    1 | 疲れた。。。
      | ^~~~~~~~~~~~
Language: C++

using namespace std;


int main()
{
    // 整数の入力
    // スペース区切りの整数の入力
    int N;
    cin >> N;
    string s;
    cin >> s;
    int dp[N][N];
    int ans = 0;
    // 文字列の入力
    for(int i=N; 0<i; i--){
        for (int j=i-1; -1<j; j--) {
            if(s[i]==s[j]){
                if(i<N-1){
                    dp[i][j] = min(dp[i+1][j+1]+1, i-j);
                }else{
                    dp[i][j] = 1;
                }
            }else{
                dp[i][j] = 0;
            }
            if(dp[i][j]>ans){
                ans = dp[i][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin >> N;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:10:5: error: 'string' was not declared in this scope
   10 |     string s;
      |     ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:11:12: error: 's' was not declared in this scope
   11 |     cin >> s;
      |            ^
a.cc:19:32: error: 'min' was not declared in this scope; did you mean 'main'?
   19 |                     dp[i][j] = min(dp[i+1][j+1]+1, i-j);
      |                                ^~~
      |                                main
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout << ans << endl;
      |     ^~~~
a.cc:31:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:20: error: 'endl' was not declared in this scope
   31 |     cout << ans << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

void zalgorithm(string S){
  A[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  string s;
  int ans=0;
  cin>>n>>s;
  string aa=zalgorithm(s);
  ans=aa.size();
  cout<<ans<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'void zalgorithm(std::string)':
a.cc:18:3: error: 'A' was not declared in this scope
   18 |   A[0] = S.size();
      |   ^
a.cc: In function 'int main()':
a.cc:37:23: error: conversion from 'void' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   37 |   string aa=zalgorithm(s);
      |             ~~~~~~~~~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string S;
  
  cin >> n;
  cin >> S;
  int size = S.size();
  //cout << S << endl;
  int ans = 0;

  while(n>0){
    
    FOR(j,0,size-n){
      int p = j;
      FOR(i,n+j,size){
        //dump(i);
        if (size-i < n-p+j)){
        //if (S.size()-p < n-(p-j)){
          //cout << n << " " << p << " " << j << endl;
          break; 
        }
        if (S[i] == S[p]){
          if (++p==n+j){
            cout << n << endl;
            return 0;
          }
        }else{
            p=j+(S[i]==S[j]);
        }
      }
    }
    n--;
  }
  cout << 0 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:28: error: expected primary-expression before ')' token
   37 |         if (size-i < n-p+j)){
      |                            ^
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] characters = s.toCharArray();

        int result = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (characters[i] == characters[j]) {
                    int cnt = 1;
                    for (int k = 1; k < n - j; k++) {
                        if (characters[i + k] == characters[j + k]) {
                            cnt++;
                        } else {
                            if (result < cnt) {
                                result = cnt;
                            }
                            break;
                        }
                    }
                }
            }
        }

        System.out.println(cnt);
    }
}

Compiler output:
Main.java:29: error: cannot find symbol
        System.out.println(cnt);
                           ^
  symbol:   variable cnt
  location: class Main
1 error
Language: C

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map> 

int main(void){
    int N, i, A[5005], len, l[3], b;
    char S[5005];
    scanf("%d", &N);
    scanf("%s", S);
    for (i=1; i<=26; i++) A[i]=0;
    for (i=0; i<N; i++) A[S[i]-96]++;
    len=0;
    for (i=1; i<=26; i++) len+=A[i]/2;
    b=1;
    while (b==1) {
        b=0;
        // printf("len=%d\n", len);
        for (l[1]=0; l[1]<=N-2*len; l[1]++) {
            for (l[2]=l[1]+len; l[2]<=N-len; l[2]++) {
                for (i=0; i<=len-1; i++) {
                    b=0;
                    if (S[l[1]+i]!=S[l[2]+i]) b=1;
                    if (b==1) {
                        // printf("(%d, %d)\n", l[1], l[2]);
                        break;
                    }
                }
                if (b==0) break;
            }
            if (b==0) break;
        }
        if (b==1) len--;
    }
    
    printf("%d", len);
    return 0;
}

Compiler output:
main.c:2:10: fatal error: vector: No such file or directory
    2 | #include <vector>
      |          ^~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	long n,i,j,cur,res;
	cin >> n;
	string s;
	cin >> s;
	string t=s;
	sort(t.begin(), t.end());
	if(t[0]==t[n-1]){
		cout << n/2; return 0;
	}else if(t[0]==t[n-2]){
		if((s[1]!=s[0] && s[2]!=s[1]) || (s[n-1]!=s[n-2] && s[n-1]!=s[n-3]){
			cout << (n-1)/2; return 0;
		}else{
			for(i=0; i<n; i++){
				if(s[i]!=s[0]);
				cout << min(i,n-1-i); return 0;
			}
		}
	}
	cur=0;
	for(i=0; i<n-2*cur; i++){
		for(j=i+cur+1; j<n-cur; j++){
			if(s[i]==s[j]){
				res=1;
				while(i+res<j && j+res<n && s[i+res]==s[j+res]){
					res++;
				}
				cur=max(cur,res);
			}
		}
	}
	cout << cur;
}
	


Compiler output:
a.cc: In function 'int main()':
a.cc:14:84: error: expected ')' before '{' token
   14 |                 if((s[1]!=s[0] && s[2]!=s[1]) || (s[n-1]!=s[n-2] && s[n-1]!=s[n-3]){
      |                   ~                                                                ^
      |                                                                                    )
a.cc:22:9: error: expected primary-expression before '}' token
   22 |         }
      |         ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;


/*
int solve(string s, string t, int n, int m){
    /*for (int i=1; i<=n; ++i) {
        for (int j=1; j<=m; ++j) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }*/
 /*   int maxcase_len=0;
    for(int off = -(int)s.size(); off <= (int)t.size(); off++) {
        int len = 0;
        for(int i = max(off, 0); i < min(s.size()+off, t.size()); i++) {
            if(len > maxcase_len) {
                //maxcase_off1 = i-len-off;
                //maxcase_off2 = i-len;
                maxcase_len = len;
            }
            if(s[i-off] != t[i]) {
                len = 0;
            } else {
                len++;
            }
        }
    }
    cout << maxcase_len<< endl;
    return maxcase_len;
}*/

static int LCSuff[6000][6000];

int LCSubStr(string X, string Y, int m, int n)
{
    //cout << X << " " << m << endl;
    //cout << Y << " " << n <<endl;
    int result = 0;
    for (int i=0; i<=m; i++)
    {
        for (int j=0; j<=n; j++)
        {

            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;
            
            else if (X[i-1] == Y[j-1])
            {
                LCSuff[i][j] = LCSuff[i-1][j-1] + 1;
                result = max(result, LCSuff[i][j]);
            }
            else LCSuff[i][j] = 0;
        }
    }
    //cout << result << endl;
    return result;
}

int main(void){
    int N;
    string S;
    MEMSET(dp, 0);
    cin >> N >> S;
    int Maximum = 0;
    rep(k, N-1){
       Maximum = max(LCSubStr(S.substr(0, k+1), S.substr(k+1), k+1, N-k-1), Maximum);
    }
    cout << Maximum << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:12: error: 'dp' was not declared in this scope
   79 |     MEMSET(dp, 0);
      |            ^~
a.cc:11:30: note: in definition of macro 'MEMSET'
   11 | #define MEMSET(v, h) memset((v), h, sizeof(v))
      |                              ^
Language: C

#include <stdio.h>

#define N_MAX 5001

int main(void){
  int i, j, k;

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

  char s[N_MAX];
  scanf(" %s", s);

  int alp[26][N_MAX]={};
  int same_apl_num[26]={}
  int c_num;
  for(i=0; i<n; i++){
    for(j=0; ; j++){
      c_num=s[i]-'a';
      if(alp[c_num][j] == 0){
        alp[c_num][j]=i;
        same_apl_num[c_num]++;
        break;
      }
    }
  }

  int flag=0;
  for(i=0; i<26; i++){
    if(same_apl_num[i] > 2000){
      flag=1;
      break;
    }
  }

  int len, len_max=0, same_place;
  if(flag) len_max=100;
  for(i=0; i<n; i++){
    if((n-i)/2 <= len_max) break;
    c_num=s[i]-'a';
    for(j=0; ; j++){
      if(alp[c_num][j] == 0) break;
      if(alp[c_num][j] > i){
        same_place=alp[c_num][j];
        if(same_place-i <= len_max) continue;
        for(k=1; ; k++){
          if(s[i+k] != s[same_place+k]) break;
          if(i+k >= same_place) break;
        }
        if(k > len_max) len_max=k;
      }
    }
  }

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

  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:3: error: expected ',' or ';' before 'int'
   16 |   int c_num;
      |   ^~~
main.c:19:7: error: 'c_num' undeclared (first use in this function)
   19 |       c_num=s[i]-'a';
      |       ^~~~~
main.c:19:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main() {
  int N;
  string S;
  cin >> N >> S;
  map<char, vector<int>> M;
  rep(i,N) M[S[i]].push_back(i);
  
  int ans = 0;
  for (auto p : M) {
    // auto key = p.first;
    auto value = p.second;
    rep(i,value.size()) {
      rep(j,i) {
        int &post = value[i];
        int &pre = value[j];
        if (post-pre <= ans) continue;
        int length;

        rep(k,post-pre) {
          if (post+k == N) {
            length = k;
            break;
          }
          if (S[pre+k] != S[post+k]) {
            length = k;
            break;
          }
          if (k == post-pre-1) {
            length = k+1;
          }
        }

        /for (int l=1; l<=post-pre-length; l++) {
          if (pre-l == -1) {
            length += l-1;
            if (ans < length) ans = length;
            break;
          }
          if (S[pre-l] != S[post-l]) {
            length += l-1;
            if (ans < length) ans = length;
            break;
          }
          if (length+l == post-pre) {
            if (ans < post-pre) ans = post-pre;
          }
        }
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: expected primary-expression before '/' token
   40 |         /for (int l=1; l<=post-pre-length; l++) {
      |         ^
a.cc:40:10: error: expected primary-expression before 'for'
   40 |         /for (int l=1; l<=post-pre-length; l++) {
      |          ^~~
a.cc:40:24: error: 'l' was not declared in this scope
   40 |         /for (int l=1; l<=post-pre-length; l++) {
      |                        ^
Language: C

#include <stdio.h>

#define N_MAX 5001

int main(void){
  int i, j, k;

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

  char s[N_MAX];
  scanf(" %s", s);

  int alp[26][N_MAX]={};
  int same_apl_num[26]={}
  int c_num;
  for(i=0; i<n; i++){
    for(j=0; ; j++){
      c_num=s[i]-'a';
      if(alp[c_num][j] == 0){
        alp[c_num][j]=i;
        same_apl_num[c_num]++;
        break;
      }
    }
  }

  int flag=0;
  for(i=0; i<26; i++){
    if(same_apl_num[i] > 1000){
      flag=1;
      break;
    }
  }

  int len, len_max=0, same_place;
  if(flag) len_max=50;
  for(i=0; i<n; i++){
    if((n-i)/2 <= len_max) break;
    c_num=s[i]-'a';
    for(j=0; ; j++){
      if(alp[c_num][j] == 0) break;
      if(alp[c_num][j] > i){
        same_place=alp[c_num][j];
        if(same_place-i <= len_max) continue;
        for(k=1; ; k++){
          if(s[i+k] != s[same_place+k]) break;
          if(i+k >= same_place) break;
        }
        if(k > len_max) len_max=k;
      }
    }
  }

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

  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:16:3: error: expected ',' or ';' before 'int'
   16 |   int c_num;
      |   ^~~
main.c:19:7: error: 'c_num' undeclared (first use in this function)
   19 |       c_num=s[i]-'a';
      |       ^~~~~
main.c:19:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

int cnt = 0,maxv = 0;

void solve(int X,int Y,int stop,string S){
    if(Y+1 >= S.size()) return;
    if(S[X+1] == S[Y+1]){
        if(X + 1 == stop) return;
        ++cnt;
        solve(X+1,Y+1,stop,S,cnt);
    }
    return;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
  	int N;
	string S;
    cin >> N;
    cin >> S;
    for(int i = 0; i < N-1;++i){
        for(int j = i+1;j < N;++j){
            if(S[i] == S[j]){
                ++cnt;
                solve(i,j,j,S);
                maxv = max(maxv,cnt);
                cnt = 0;
            }
        }
    }
    cout << maxv << endl;
}

Compiler output:
a.cc: In function 'void solve(int, int, int, std::string)':
a.cc:23:14: error: too many arguments to function 'void solve(int, int, int, std::string)'
   23 |         solve(X+1,Y+1,stop,S,cnt);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:18:6: note: declared here
   18 | void solve(int X,int Y,int stop,string S){
      |      ^~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

#define max(a,b) ((a)>(b)?(a):(b))

int n,k;
int rank[5010];
int rank2[5010];
int tmp[5010];

int compare_int(const void *a,const void *b){
	int i=*(int*)a,j=*(int*)b;
	if(rank[i]!=rank[j])return rank[i]-rank[j];
	else {
		int ri=i+(k<=n?rank[i+k]:-1);
		int rj=j+(k<=n?rank[j+k]:-1);
	return ri-rj;
	}
}

void construct_sa(char *s,int *sa,int m){
	n=m;
	int i;
	for(i=0;i<=n;i++){
		sa[i]=i;
		rank[i]=(i<n?(s[i]-'a'):-1);
	}
	for(k=1;k<=n;k*=2){
		qsort(sa,n,sizeof(int),compare_int);
		tmp[sa[0]]=0;
		for(i=1;i<=n;i++){
			tmp[sa[i]]=tmp[sa[i-1]]+(compare_int(&sa[i-1],&sa[i])>0?1:0);
		}
		for(i=0;i<=n;i++)rank[i]=tmp[i];
	}
}

void construct_lcp(char *s,int *sa,int lcp,int m){
	int i;
	for(i=0;i<=m;i++)rank2[sa[i]]=i;
	int h=0;
	lcp[0]=0;
	for(i=0;i<n;i++){
		int j=sa[rank2[i]-1];

		if(h>0)h--;
		for(;j+h<n&&i+h<n;h++){
			if(s[j+h]!=s[i+h])break;
		}
		lcp[rank2[i]-1]=h;
	}
}

int main(){
	int i;
	char s[5500];
	int sa[5010];
	int lcp[5010];
	int ans=0;
	scanf("%d%s",&n,s);
	construct_sa(s,sa,n);
	construct_lcp(s,sa,lcp);
	for(i=0;i<n;i++)ans=max(ans,lcp[i]);
	printf("%d\n",ans);
	return 0;
}

Compiler output:
main.c: In function 'construct_lcp':
main.c:42:12: error: subscripted value is neither array nor pointer nor vector
   42 |         lcp[0]=0;
      |            ^
main.c:50:20: error: subscripted value is neither array nor pointer nor vector
   50 |                 lcp[rank2[i]-1]=h;
      |                    ^
main.c: In function 'main':
main.c:62:28: error: passing argument 3 of 'construct_lcp' makes integer from pointer without a cast [-Wint-conversion]
   62 |         construct_lcp(s,sa,lcp);
      |                            ^~~
      |                            |
      |                            int *
main.c:38:40: note: expected 'int' but argument is of type 'int *'
   38 | void construct_lcp(char *s,int *sa,int lcp,int m){
      |                                    ~~~~^~~
main.c:62:9: error: too few arguments to function 'construct_lcp'
   62 |         construct_lcp(s,sa,lcp);
      |         ^~~~~~~~~~~~~
main.c:38:6: note: declared here
   38 | void construct_lcp(char *s,int *sa,int lcp,int m){
      |      ^~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<map>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N;
    string s;
    std::map<string,vector<int> > word;
    string temp;
    int i,j;
    int max;
    int start,end;
    
    cin >> N;
    cin >> s;
    
    for(i=0;i<N;i++){
        for(j=i;j<N && ( j - i + 1 ) <= N/2 + 1;j++){
            temp = s.substr(i,j-i+1);
            word[temp].push_back(i);
        }
    }
    max = 0;
    /*
    for(auto itr = word.begin() ;itr != word.end(); itr++){
        
        start = itr->second.front();
        end = itr->second.back();
        /*
        cout << itr->first << ":";
        for(i=0;i<itr->second.size();i++){
            cout << itr->second[i] << " ";
        }
        cout << endl;
         
        cout << ":" << start <<":" << end << endl;
        */
        if( start + itr->first.length() <= end){
            if( max < itr->first.length()){
                max = itr->first.length();
            }
        }
        
    }
     */
    

    cout << max << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:21: error: 'itr' was not declared in this scope
   46 |         if( start + itr->first.length() <= end){
      |                     ^~~
a.cc: At global scope:
a.cc:53:7: error: expected unqualified-id before '/' token
   53 |      */
      |       ^
a.cc:57:5: error: expected unqualified-id before 'return'
   57 |     return 0;
      |     ^~~~~~
a.cc:58:1: error: expected declaration before '}' token
   58 | }
      | ^
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    rep(i, n-1) {
        string fi = s.substr(0, (i+1));
        string se = s.substr(i+1, s.size()-(i+1));

        int fs = fi.size();
        int ss = se.size();
        
        int dp[fs+1][ss+1];
        memset(dp, 0, sizeof(dp));

        rep(i, fs) {
            rep(j, ss) {
                if (fi[i] == se[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
            }
        }
        ans = max(ans, dp[fs][ss]);
        //cout << fi << " " << se << endl; 
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:9: error: 'memset' was not declared in this scope
   31 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <map>
  +++ |+#include <cstring>
    8 |
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    string S;
    cin >> S;
    int left=0;
    int right=N/2+1;
    while(right-left>1){
        int mid=left+(right-left)/2;
        vector<pair<string,int>> happy;
        bool can=false;
        if(mid==0 || (mid==1 && N>26) || (mid==2 && N>1352))can=true;
        else{
            rep(i,N-mid+1){
                happy.push_back(make_pair(S.substr(i,mid),i));
            }
            sort(all(happy));
            rep(i,happy.size()){
                for(int j=i+1;j<happy.size();j++){
                    if(happy[i].first==happy[j].first){
                        if(happy[i].second+mid<=happy[j].second)can=true;
                    }
                    else{
                        i=j
                        break;
                    }
                }
            }
        }
        if(can)left=mid;
        else right=mid;
    }
    cout << left;

    


}

/*



 */


Compiler output:
a.cc: In function 'int main()':
a.cc:39:28: error: expected ';' before 'break'
   39 |                         i=j
      |                            ^
      |                            ;
   40 |                         break;
      |                         ~~~~~
Language: C++

include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	s=s.rverse(s.begin(),s.end());
	int max=0;
	for(int i=1;i<N;i++){
		string tmp = s.substr(1,max+1);
		if(s.find(tmp,max+1)>0){
	max++;			}

	}
	cout<<max<<endl;
	return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:9: error: 'string' was not declared in this scope
    5 |         string s;
      |         ^~~~~~
a.cc:6:9: error: 'cin' was not declared in this scope
    6 |         cin>>n>>s;
      |         ^~~
a.cc:6:17: error: 's' was not declared in this scope
    6 |         cin>>n>>s;
      |                 ^
a.cc:9:23: error: 'N' was not declared in this scope
    9 |         for(int i=1;i<N;i++){
      |                       ^
a.cc:10:23: error: expected ';' before 'tmp'
   10 |                 string tmp = s.substr(1,max+1);
      |                       ^~~~
      |                       ;
a.cc:11:27: error: 'tmp' was not declared in this scope
   11 |                 if(s.find(tmp,max+1)>0){
      |                           ^~~
a.cc:15:9: error: 'cout' was not declared in this scope
   15 |         cout<<max<<endl;
      |         ^~~~
a.cc:15:20: error: 'endl' was not declared in this scope
   15 |         cout<<max<<endl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 51011, INF = 5 << 28, MOD = 1e9 + 7;

int N;
string S;
void input() {
  cin >> N;
  cin >> S;
}

vi beg[26];
int dp[MX][MX] = {};  // dp[i] : i文字目を始点とする部分文字列のスコア
bool used[MX][MX] = {};
void solve() {
  rep(i, 0, N - 1) { beg[S[i] - 'a'].push_back(i); }

  // int i = 0;
  // int ans = -INF;
  // while (i < N) {
  //   //  debug(i);
  //   int now_i = S[i] - 'a';
  //   int j = i;
  //   for (auto x : beg[now_i]) {
  //     int score = 0;
  //     //   debug(x);
  //     int pl = 0;
  //     while ((x > j + pl) && (x + pl < N)) {
  //       if (S[x + pl] == S[j + pl]) {
  //         ++score;
  //       }
  //       pl++;
  //     }
  //     //  debug(score);
  //     ans = max(ans, score);
  //   }
  //   i++;
  // }
  // cout << ans << endl;
  int ans = -INF;

  rep(WW, 0, 25) {
    // i==0 : Aから始まるやつ！
    vi now_v = beg[WW];
    sort(all(now_v));
    // debugv(now_v);
    rep(i, 0, now_v.size() - 1) {
      rep(j, i + 1, now_v.size() - 1) {
        int indi = now_v[i];
        int indj = now_v[j];

        if (used[indi][indj]) {
          break;
        }

        int cnt = 0;
        while (true) {
          if ((indi + cnt >= indj) || (indj + cnt >= N)) {
            dp[indi][indj] = cnt;
            break;
          }
          if (used[indi + cnt][indj + cnt]) {
            cnt += dp[indi + cnt][indj + cnt];
            dp[indi][indj] = cnt;
            break;
          } else if (S[indi + cnt] == S[indj + cnt]) {
            used[indi + cnt][indj + cnt] = true;
            cnt++;
            dp[indi][indj] = cnt;
            // } else if ((indi + cnt < indj) && (indj + cnt < N)) {
            //   dp[indi][indj] = cnt;
            //   break;
          } else {
            dp[indi][indj] = cnt;
            break;
          }
        }
        ans = max(ans, cnt);
      }
    }
    // debug(WW);
    // debug(ans);
  }

  cout << max(0LL, ans) << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Compiler output:
/tmp/ccmNoQeY.o: in function `solve()':
a.cc:(.text+0x17c): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccmNoQeY.o
a.cc:(.text+0x210): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccmNoQeY.o
a.cc:(.text+0x2f8): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccmNoQeY.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int n;
string s;
const int MOD = 666013;

bool Verify(int len)
{
	int hashCode = 0, power = 1;
	unordered_map <int, vector <int> > M;
	for (int i = 1;i < len;++i)
	{
		hashCode = (1LL * hashCode * 26 + (s[i] - 'a')) % MOD;
		power = (1LL * power * 26) % MOD;
	}
	power = (1LL * power * 26) % MOD;
	for (int i = len;i <= n;++i)
	{
		hashCode = (1LL * hashCode * 26 + (s[i] - 'a')) % MOD;
		if (i > len)
			hashCode = (hashCode - 1LL * power * (s[i - len] - 'a') % MOD + MOD) % MOD;
		M[hashCode].push_back(i);
	}
	for (auto &it : M)
	{
		if (it.second.size() < 2)
			continue;
		for (int j = 1;j < it.second.size();++j)
			if (it.second[j] - it.second[0] >= len)
				return true;
	}
	return false;
}

int main()
{
	cin >> n >> s;
	s = " " + s;
	int left = 1, right = n, mid, ans = 0;
	while (left <= right)
	{
		int mid = (left + right) / 2;
		if (Verify(mid))
		{
			ans = mid;
			left = mid + 1;
		}
		else
			right = mid - 1;
	}
	cout << ans << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'bool Verify(int)':
a.cc:14:29: error: 'vector' was not declared in this scope
   14 |         unordered_map <int, vector <int> > M;
      |                             ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <unordered_map>
  +++ |+#include <vector>
    4 | 
a.cc:14:40: error: template argument 2 is invalid
   14 |         unordered_map <int, vector <int> > M;
      |                                        ^
a.cc:14:40: error: template argument 5 is invalid
a.cc:14:42: error: expected unqualified-id before '>' token
   14 |         unordered_map <int, vector <int> > M;
      |                                          ^
a.cc:26:17: error: 'M' was not declared in this scope
   26 |                 M[hashCode].push_back(i);
      |                 ^
a.cc:28:25: error: 'M' was not declared in this scope
   28 |         for (auto &it : M)
      |                         ^
Language: C++

#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, t) for (int i = (s); i < (int)(t); i++)
using namespace std;
using boost::irange;
typedef long long ll;
const ll mod = 1e9 + 7;

bool haita(int i, int j, int a, int b) {
    return j < a || b < i;
}


int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    unordered_map<string, vector<pair<int, int>>> d;
    for (int i: irange(N)) {
        for (int j: irange(0, min(N - i, N / 2))) {
            string sub = S.substr(i, j + 1);
            if (d.find(sub) == d.end()) {
                vector<pair<int, int>> vec;
                vec.push_back(make_pair(i, j));
                d[sub] = vec;
            } else {
                vector<pair<int, int>> vec = d[sub];
                for (pair<int, int> &p: vec) {
                    if (haita(p.first, p.second, i, j)) {
                        ans = max(ans, (int) sub.size());
                        break;
                    }
                }
                d[sub].push_back(make_pair(i, j));
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: boost/range/irange.hpp: No such file or directory
    2 | #include <boost/range/irange.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

v#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
class RH {
	string s;
	int n, m, base;
	int* has;
	int mypow(int x, int y) {
		if (!y)return 1;
		if (y % 2)return this->mypow(x, y - 1) * x % m;
		int memo = this->mypow(x, y / 2);
		return memo * memo % m;
	}
public:
	RH() {}
	RH(string s, int m, int b) { init(s, m, b); }
	~RH() { delete[] has; }
	void init(string s, int m, int b) {
		n = s.size();
		has = new int[n];
		base = b;
		this->s = s;
		this->m = m;
		rep(i, n) {
			has[i] = (int)s[i];
			if (i)has[i] += base * has[i - 1] % m;
			has[i] %= m;
		}
	}
	int query(int a, int b) {
		assert(!(a >= b || a < 0 || n < b));
		return (has[b - 1] - this->mypow(base, b - a) * (!a ? 0 : has[a - 1]) % m + m) % m;
	}
};
int n;
string s;
signed main() {
	cin >> n >> s;
	RH rh1(s, mod, 1007), rh2(s, mod, 10007);
	int ans = 0;
	rep(i, n) {
		if ((n - i) / 2 <= ans)break;
		for (int j = i + ans; j < n; j++) {
			if (n - j + 1 <= ans)break;
			if (ans) {
				if (rh1.query(i, i + ans) != rh1.query(j, j + ans) || rh2.query(i, i + ans) != rh2.query(j, j + ans))continue;
			}
			for (int k = 0; k < j - i; k++) {
				if (s[i + k] != s[j + k]) {
					ans = max(ans, k);
					goto kaage;
				}
			}
			ans = max(ans, j - i);
		kaage:;
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | v#include <algorithm>
      |  ^
a.cc:1:1: error: 'v' does not name a type
    1 | v#include <algorithm>
      | ^
In file included from a.cc:2:
a.cc: In member function 'long long int RH::query(long long int, long long int)':
a.cc:60:17: error: '__assert_fail' was not declared in this scope
   60 |                 assert(!(a >= b || a < 0 || n < b));
      |                 ^~~~~~
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  string s;
  cin>>n;
  cin>>s;
  //map<string,int> mp;//sの部分文字列とその個数
  //map<string,int> bound_;//現れる一番左の文字列の右端
  string temp;
  bool flag = false;
  int ans = 0;
  for(int l = n;l>=1;l--){//取る部分文字列の長さ
    set<string> ss;
    REP(i,n){//部分文字列の最初の1文字のインデックス
      if(i+l-1>n-1)break;
      temp = s.substr(i,l);
      //mp[temp]++;
      auto it = ss.find(temp);
      if(it ==ss.end()){
        ss.insert(temp);
        bound_[temp] = i+l-1;
      }else{
        if(bound_[temp]<i){
          ans = l;
          flag = true;
          break;
        }
      }
    }
    if(flag)break;
  }
  cout<<ans<<endl;
    
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:9: error: 'bound_' was not declared in this scope; did you mean 'roundl'?
   66 |         bound_[temp] = i+l-1;
      |         ^~~~~~
      |         roundl
a.cc:68:12: error: 'bound_' was not declared in this scope; did you mean 'roundl'?
   68 |         if(bound_[temp]<i){
      |            ^~~~~~
      |            roundl
Language: C++

#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

int LCSubStr(string X, string Y, int m, int n)
{
    // Create a table to store lengths of longest
    // common suffixes of substrings.   Note that
    // LCSuff[i][j] contains length of longest
    // common suffix of X[0..i-1] and Y[0..j-1].

    int LCSuff[m+1][n+1];
    int result = 0;  // To store length of the
                     // longest common substring

    /* Following steps build LCSuff[m+1][n+1] in
        bottom up fashion. */
    for (int i=0; i<=m; i++)
    {
        for (int j=0; j<=n; j++)
        {

            // The first row and first column
            // entries have no logical meaning,
            // they are used only for simplicity
            // of program
            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;

            else if (X[i-1] == Y[j-1])
            {
                LCSuff[i][j] = LCSuff[i-1][j-1] + 1;
                result = max(result, LCSuff[i][j]);
            }
            else LCSuff[i][j] = 0;
        }
    }
    return result;
}

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int length = 0;
    if (n % 2 == 0)
    {
        length = n / 2;
    }
    else
    {
        length = (n - 1 ) / 2;
    }
    int maxi = 0;
    for (int i = 0; i < n; i++)
    {
        string str1 = s.substr(0, i+1);
        int nr = LCSubStr(str1, str2, i+1, n - i - 1);
        if (maxi < nr)
        {
            maxi = nr;
        }

    }
    cout << maxi;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:65:33: error: 'str2' was not declared in this scope; did you mean 'str1'?
   65 |         int nr = LCSubStr(str1, str2, i+1, n - i - 1);
      |                                 ^~~~
      |                                 str1
Language: C++

#include<bits/stdc++.h>
using namespace std;

int longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    // Setting all to 0 
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; // To store result 
    int res_length  = 0; // To store length of result 
  
    // building table in bottom-up manner 
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            // (j-i) > LCSRe[i-1][j-1] to remove 
            // overlapping 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                // updating maximum length of the 
                // substring and updating the finishing 
                // index of the suffix 
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    } 
  
    // If we have non-empty result, then insert all 
    // characters from first character to last 
    // character of string  
  
    return res_length; 
} 

int solve(){
    int n;
    cin>>n;
	string s;
	cin>>s;
	 cout << longestRepeatedSubstring(s);
	}
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:55:9: warning: no return statement in function returning non-void [-Wreturn-type]
   55 |         }
      |         ^
a.cc: At global scope:
a.cc:56:9: error: expected unqualified-id before 'return'
   56 |         return 0;
      |         ^~~~~~
a.cc:57:1: error: expected declaration before '}' token
   57 | }
      | ^
a.cc: In function 'int main()':
a.cc:59:5: error: 'waste' was not declared in this scope
   59 |     waste;
      |     ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

int LCSubStr(string X, string Y, int m, int n)
{
    // Create a table to store lengths of longest
    // common suffixes of substrings.   Note that
    // LCSuff[i][j] contains length of longest
    // common suffix of X[0..i-1] and Y[0..j-1].

    int LCSuff[m+1][n+1];
    int result = 0;  // To store length of the
                     // longest common substring

    /* Following steps build LCSuff[m+1][n+1] in
        bottom up fashion. */
    for (int i=0; i<=m; i++)
    {
        for (int j=0; j<=n; j++)
        {

            // The first row and first column
            // entries have no logical meaning,
            // they are used only for simplicity
            // of program
            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;

            else if (X[i-1] == Y[j-1])
            {
                LCSuff[i][j] = LCSuff[i-1][j-1] + 1;
                result = max(result, LCSuff[i][j]);
            }
            else LCSuff[i][j] = 0;
        }
    }
    return result;
}

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int length = 0;
    if (n % 2 == 0)
    {
        length = n / 2;
    }
    else
    {
        length = (n - 1 ) / 2;
    }
    int maxi = 0;
    for (int i = 0; i < n; i++)
    {
        string str1 = s.substr(0, i+1);
        cout << str1 << " " << str2 << " \n";
        int nr = LCSubStr(str1, str2, i+1, n - i - 1);
        if (maxi < nr)
        {
            maxi = nr;
        }

    }
    cout << maxi;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:65:32: error: 'str2' was not declared in this scope; did you mean 'str1'?
   65 |         cout << str1 << " " << str2 << " \n";
      |                                ^~~~
      |                                str1
Language: C++

#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 4999999999999999999
#define ALL(n) n.begin(),n.end()

ll n;
string a;
int ans = 0, dp[4010][4010];
int main(){
	cin >> n >> a;
	REP(i, a.size()) {
		REP(j, a.size()) {
			if (a[i] == b[j] and dp[i][j] + 1 <= j - i)dp[i + 1][j + 1] = dp[i][j] + 1;
			ans = max(ans, dp[i + 1][j + 1]);
		}
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:37: error: 'b' was not declared in this scope
   33 |                         if (a[i] == b[j] and dp[i][j] + 1 <= j - i)dp[i + 1][j + 1] = dp[i][j] + 1;
      |                                     ^
Language: C++

#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define ll long long
int main()
{
    int n,ans=0;;
    char a[10000];
    scanf("%d",&n);
    getchar();
    gets(a);
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]==a[j])
            {
                int k=j;
                while(a[i]==a[k]&&k<n&&i<j)
                {
                    i++;
                    k++;
                }
                ans=max(ans,k-j);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   12 |     gets(a);
      |     ^~~~
      |     getw
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

string s;
vector<int> pt[26]
//cから始まる連続文字列の最長を求める
int lcs(char c)
{
	int ret=0;
	//それぞれ調べる
	for(int i=0;i<pt[c-'a'].size();i++)
	{
		for(int j=i+1;j<pt[c-'a'].size();j++)
		{
			int a=pt[c-'a'][i];
			int b=pt[c-'a'][j];
			int cnt=0;
			int bs=b;
			while(s[a]==s[b])
			{
				//cerr<<a<<" "<<b<<endl;
				a++;
				b++;
				cnt++;
				if(a==bs || b==s.size())
					break;
			}
			ret=max(ret,cnt);
		}
	}
	return ret;
}

int main()
{
	int n;
	int ans=0;
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		pt[s[i]-'a'].push_back(i);
	}
	for(int i=0;i<26;i++)
		ans=max(ans,lcs('a'+i));
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:16:1: error: expected initializer before 'int'
   16 | int lcs(char c)
      | ^~~
a.cc: In function 'int main()':
a.cc:51:17: error: 'pt' was not declared in this scope
   51 |                 pt[s[i]-'a'].push_back(i);
      |                 ^~
a.cc:54:29: error: 'lcs' was not declared in this scope
   54 |                 ans=max(ans,lcs('a'+i));
      |                             ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
map<string, vector<int>> K;
	int N;
	cin >> N;
	string S;
	cin >> S;
	set<string> Ks;
	fx(N) {
		fy(N) {
			if (x+y+1>N) {
				break;
            }
			K[S.substr(x, y + 1)].push_back(x);
			Ks.insert(S.substr(x, y + 1));
		}
	}
	int ans = 0;

	for each ( string s in Ks)
	{
		if (K[s].size() >= 2) {
			int l1 = K[s][0];
			int l2 = K[s][K[s].size() - 1];
			if (l1 + s.size() <= l2) {
				int z = s.size();
				ans = max(ans, z);
			}
		}
	}

	ce(ans)
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:57:13: error: expected '(' before 'each'
   57 |         for each ( string s in Ks)
      |             ^~~~
      |             (
a.cc:57:27: error: expected primary-expression before 's'
   57 |         for each ( string s in Ks)
      |                           ^
a.cc:57:13: error: 'each' was not declared in this scope
   57 |         for each ( string s in Ks)
      |             ^~~~
a.cc:70:5: error: expected primary-expression before 'return'
   70 |     return 0;
      |     ^~~~~~
a.cc:70:5: error: expected ')' before 'return'
a.cc:57:13: note: to match this '('
   57 |         for each ( string s in Ks)
      |             ^~~~