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

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

using namespace std;

using ll = long long;
#define REP(i, n) for(int (i) = 0;(i) < (n);(i)++)

int n;
string s;

using i64 = int64_t;
const i64 B = 100000007;
const i64 MOD[3] = {998244353, 1000000007, 1000000009};
i64 t[3] = {1, 1, 1};
i64 sz;
vector<vector<i64>> Table;

bool func(int x) {

  map<i64,int> M[3];
  bool res = true;
  bitset<5000 + 10> bs[3];

  for(int i = 0;i < 3;i++){

    int flag = 0;

    i64 mod = MOD[i];
    i64 t = 1;
    for(int j = 0;j < x;j++){
      t = (t * B) % mod;
    }

    i64 h = 0;
    for(int j = 0;j < x;j++){
      h = ((h * B) % mod + s[j]) % mod;
    }
    M[i][h] = x - 1;
    for(int j = x;j < n;j++){
      h = ((h * B) % mod + s[j]) % mod;
      h = (h + mod - ((s[j - x] * t) % mod)) % mod;
      if(M[i][h] && (j - x + 1) > M[i][h]){
        bs[i][j] = 1;
      }
      if(!M[i][h]) M[i][h] = x;
    }
    bs[0] &= bs[i];
  }
  return bs[0].count() >= 1;
}

int main(void) {
  cin >> n >> s;
  int l = 0, r = n + 1;
  while (l + 1 != r) {
    int mid = (l + r) / 2;
    if (func(mid)) l = mid;
    else r = mid;
  }
  cout << l << '\n';
}



Compiler output:
a.cc: In function 'bool func(int)':
a.cc:26:3: error: 'bitset' was not declared in this scope
   26 |   bitset<5000 + 10> bs[3];
      |   ^~~~~~
a.cc:6:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
    5 | #include <map>
  +++ |+#include <bitset>
    6 | 
a.cc:26:21: error: 'bs' was not declared in this scope; did you mean 's'?
   26 |   bitset<5000 + 10> bs[3];
      |                     ^~
      |                     s
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        for (int j = 0; j < T.size(); ++j) {
            int l = min(lcp[j], j);
            ans = max(ans, l);
        }
    }
        
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:13: error: 'res' was not declared in this scope; did you mean 'rep'?
   40 |     cout << res << endl;
      |             ^~~
      |             rep
Language: C++

#include<iostream>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	int r[n+1][n+1]; p(dp, 0, int);
	for (int i = n-1; i >= 0; i--) {
		for (int j = n-1; j >= 0; j--) {
			if (s[i] == s[j]) dp[i][j] = r[i+1][j+1] + 1;
			chmax(ans, min(abs(i-j), r[i][j]));
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:28: error: 'dp' was not declared in this scope
    8 |         int r[n+1][n+1]; p(dp, 0, int);
      |                            ^~
a.cc:8:35: error: expected primary-expression before 'int'
    8 |         int r[n+1][n+1]; p(dp, 0, int);
      |                                   ^~~
a.cc:8:26: error: 'p' was not declared in this scope
    8 |         int r[n+1][n+1]; p(dp, 0, int);
      |                          ^
a.cc:12:25: error: 'chmax' was not declared in this scope
   12 |                         chmax(ans, min(abs(i-j), r[i][j]));
      |                         ^~~~~
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
constexpr long long mod1 = 1e9+7;
using namespace std;

vector<int> zalgo(string s){
  int i = 1, j = 0, n = s.size();
  vector<int> v(n);
  v[0] = n;
  while(i < n){
    while(i + j < n && s[j] == s[i+j]) ++j;
    v[i] = j;
    if(j == 0) ++i;
    else{
      int k = 1;
      while(k < j && k + v[k] < j){
        v[i+k] = v[k];
        ++k;
      }
      i += k;
      j -= k;
    }
  }
  return v;
}

int main(){
  int n, ans = 0; string s; cin >> n >> s;
  vector<vector<int>> v(n-1);
  vector<string> u(n-1);
  rep(i, n-1){
    string tmp = "";
    rep(j, n-i) tmp += s[i+j];
    u[i] = tmp;
  }
  rep(i, n-1) v[i] = zalgo(u[i]);
  rep(i, n-1) rep(j, v[i].size()) ans = max(ans, min(v[i][j], j);
  cout << ans << "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:65: error: expected ')' before ';' token
   38 |   rep(i, n-1) rep(j, v[i].size()) ans = max(ans, min(v[i][j], j);
      |                                            ~                    ^
      |                                                                 )
Language: C++

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N, ans;
string S;
int cnt[26];
vector<int> ocs[26];

void solve() {
    cin >> N >> S;
    
    for (int i = 0; i < N; i++) {
		ocs[S[i] - 97].push_back(i);
	} 
	for (int i = 0; i < N; i++) {
		int dec = S[i] - 97;
		// cout << dec << "\n";
		// cout << ocs[dec].size() << "\n";
		for (int oc = cnt[dec] + 1; oc < ocs[dec].size(); oc++) {
			if (min(cnt[dec][oc] - i, N - cnt[dec]oc]) <= ans) continue;
			int len = 0;
			int a = i, b = ocs[dec][oc];
			// cout << a << " " << b << "\n";
			while (a < ocs[dec][oc] && b < N && S[a] == S[b]) {
				len++;
				a++; b++;
			}
			
			chmax(ans, len);
		}
		cnt[dec]++;
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Compiler output:
a.cc: In function 'void solve()':
a.cc:46:41: error: invalid types 'int[int]' for array subscript
   46 |                         if (min(cnt[dec][oc] - i, N - cnt[dec]oc]) <= ans) continue;
      |                                         ^
a.cc:46:63: error: expected ')' before 'oc'
   46 |                         if (min(cnt[dec][oc] - i, N - cnt[dec]oc]) <= ans) continue;
      |                                ~                              ^~
      |                                                               )
a.cc:46:65: error: expected ')' before ']' token
   46 |                         if (min(cnt[dec][oc] - i, N - cnt[dec]oc]) <= ans) continue;
      |                            ~                                    ^
      |                                                                 )
a.cc:46:65: error: expected primary-expression before ']' token
Language: C

#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n;
    cin>>n;

    string s;
    cin>>s;

    int len = 0;
    int ans = 0;
    while( len < s.length() )
    {
        string str = s.substr(len,s.length()-len);
        vector<int> z_val = z_function(str);

        rep(i,0,z_val.size())
        {
            if ( i >= z_val[i] )
            {
                ans = max(ans,z_val[i]);
            }
        }
        len++;
    }

    cout<<ans<<endl;

}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int n;
string s;
int tree[20000000][26];
int tick = 1;
int mi[20000000];
int ma[20000000];
int sol;

void add(int x)
{
    int node = 1;
    for (int i = x; i < n; ++i)
    {
        int c = s[i] - 'a';
        if (!tree[node][c])
        {
            ++tick;
            mi[tick] = 1e9;
            tree[node][c] = tick;
        }
        node = tree[node][c];
        mi[node] = min(mi[node], x);
        ma[node] = max(ma[node], x);
    }
}

void dfs(int x, int d)
{
    if (ma[x] - mi[x] >= d)
        sol = max(sol, d);

    for (int i = 0; i < 26; ++i)
        if (tree[x][i])
            dfs(tree[x][i], d + 1);
}

int main()
{
    cin >> n >> s;
    for (int i = 0; i < n; ++i)
        add(i);

    dfs(1, 0);
    cout << sol;
}


Compiler output:
/tmp/cc8bY8LK.o: in function `add(int)':
a.cc:(.text+0x166): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/cc8bY8LK.o
a.cc:(.text+0x18f): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/cc8bY8LK.o
/tmp/cc8bY8LK.o: in function `dfs(int, int)':
a.cc:(.text+0x1cb): relocation truncated to fit: R_X86_64_PC32 against symbol `ma' defined in .bss section in /tmp/cc8bY8LK.o
a.cc:(.text+0x1fc): relocation truncated to fit: R_X86_64_PC32 against symbol `sol' defined in .bss section in /tmp/cc8bY8LK.o
a.cc:(.text+0x20c): relocation truncated to fit: R_X86_64_PC32 against symbol `sol' defined in .bss section in /tmp/cc8bY8LK.o
/tmp/cc8bY8LK.o: in function `main':
a.cc:(.text+0x30f): relocation truncated to fit: R_X86_64_PC32 against symbol `sol' defined in .bss section in /tmp/cc8bY8LK.o
collect2: error: ld returned 1 exit status
Language: C++

#include <string>
#include <vector>

using namespace std;

vector<int> z_algorithm(const string &s) {
  vector<int> prefix(s.size());
  for (int i = 1, j = 0; i < s.size(); i++) {
    if (i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int)s.size();
  return prefix;
}

int main(int argc, const char *argv[]) {
  int n;
  string s;
  cin >> n >> s;
  auto vlen = z_algorithm(s);
  int ans = *max_element(vlen.begin(), vlen.end());
  cout << ans << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:25:3: error: 'cin' was not declared in this scope
   25 |   cin >> n >> s;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <vector>
  +++ |+#include <iostream>
    3 | 
a.cc:27:14: error: 'max_element' was not declared in this scope
   27 |   int ans = *max_element(vlen.begin(), vlen.end());
      |              ^~~~~~~~~~~
a.cc:28:3: error: 'cout' was not declared in this scope
   28 |   cout << ans << '\n';
      |   ^~~~
a.cc:28:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

const int MAX = 2500;
const int INF = 1e6;

int n;
string s;

bool C(int x) {
    string M[MAX];
    if (x > n/2) return false;
    for (int i = 0; i+x <= n; i++) {
        M[i] = s.substr(i, x);
    }
    for (int i = 0; i+x+x <= n; i++) {
        for (int j = i+x; j+x <= n; j++) {
            if (M[i] == M[j]) return true;
        }
    }
    return false;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <string>
using namespace std;
void chmax(int &a, int b) { if (a < b) a = b; }

int main(){
  int N; string S; cin >> N >> S;
  
  int res = 0;
  vector<vector<int>> dp(N+1, vector<int>(N+1, 0));
  for(int i=N-1; i>=0; --i){
    for(int j=N-1; j>i; --j){
      if(S[i] == S[j]) chmax(dp[i][j], dp[i+1][j+1]+1);
      chmax(res, ,min(dp[i][j], j-i));
    }
  }
  cout << res << endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:15:18: error: expected primary-expression before ',' token
   15 |       chmax(res, ,min(dp[i][j], j-i));
      |                  ^
Language: C++

#include <iostream>
#include <string>
using namespace std;

constexpr int N_max = 5000;
constexpr int len_max = N_max / 2;

int main() {
    int n;
    string str;
    cin >> n >> str;
    const char *const s = str.c_str();

    int lo = 0;
    int hi = len_max + 1;
    while (lo + 1 < hi) {
        int len = (lo + hi) / 2;

        for (int pos = 0; pos + len + len <= n; pos++) {
            for (int pos2 = pos + len; pos2 + len <= n; pos2++) {
                if (strncmp(s + pos, s + pos2, len) == 0) {
                    goto found;
                }
            }
        }
        hi = len;
        continue;

    found:
        lo = len;
    }

    cout << lo;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:21: error: 'strncmp' was not declared in this scope
   21 |                 if (strncmp(s + pos, s + pos2, len) == 0) {
      |                     ^~~~~~~
a.cc:2:1: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
Language: C++

#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;

constexpr int N_max = 5000;
constexpr int len_max = N_max / 2;

int main() {
    int n;
    string str;
    cin >> n >> str;
    const char *const s = str.c_str();

    int lo = 0;
    int hi = len_max + 1;
    while (lo + 1 < hi) {
        int len = (lo + hi) / 2;

        for (int pos = 0; pos + len + len <= n; pos++) {
            for (int pos2 = pos + len; pos2 + len <= n; pos2++) {
                if (strncmp(s + pos, s + pos2, len) == 0) {
                    goto found;
                }
            }
        }
        hi = len;
        continue;

    found:
        lo = len;
    }

    cout << lo;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:21: error: 'strncmp' was not declared in this scope
   23 |                 if (strncmp(s + pos, s + pos2, len) == 0) {
      |                     ^~~~~~~
a.cc:5:1: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <vector>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

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

using namespace std;

vector<int> z_algorithm(const string& s)
{
	vector<int> prefix(s.size());
	for (int i = 1, j = 0; i < s.size(); i++) {
		if (i + prefix[i - j] < j + prefix[j]) {
			prefix[i] = prefix[i - j];
		}
		else {
			int k = max(0, j + prefix[j] - i);
			while (i + k < s.size() && s[k] == s[i + k]) ++k;
			prefix[i] = k;
			j = i;
		}
	}
	prefix[0] = (int)s.size();
	return prefix;
}

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

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		auto v = z_algorithm(S.substr(i));
		for (int j = 0; j < N - i; ++j) {
			if (v[j] <= j) {
				ans = max(ans, v[j]);
			}
		}
	}
	cout << ans << endl;
}


Compiler output:
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<int> z_algorithm(const string& s)
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:34:26: error: 'z_algorithm' was not declared in this scope
   34 |                 auto v = z_algorithm(S.substr(i));
      |                          ^~~~~~~~~~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      int l = j - i + 1 ;
      if(s.find(s.substr(i,j))==string::npos){
        break;
      }else{
        ans = max(ans, l);
      }
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc:1:10: fatal error: stdc++.h: No such file or directory
    1 | #include <stdc++.h>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int n , k;
int rank1[100010],rank2[100010];
int tmp[100010];

bool compare_sa(int i , int j){
  if(rank1[i] != rank1[j]) return rank1[i] < rank1[j];
  else{
    int ri = i + k <= n ? rank1[i+k] : -1;
    int rj = j + k <= n ? rank1[j+k] : -1;
    return ri < rj;
  }
}

void construct_sa(string S , int *sa){
  n = S.length();
  
  for(int i=0;i<=n;i++){
    sa[i] = i;
    rank1[i] = i < n ? S[i] : -1;
  }
  
  for(k=1;k<=n;k*=2){
    sort(sa, sa+n+1,compare_sa);
    
    tmp[sa[0]] = 0;
    for(int i=1;i<=n;i++){
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(sa[i-1], sa[i]) ? 1 : 0);
    }
    for(int i = 0;i<=n;i++){
      rank1[i] = tmp[i];
    }
  }
}

void construct_lcp(string S ,int *sa , int *lcp){
  int m = S.length();
  for(int i=0;i<=m;i++) rank2[sa[i]] = i;
  
  int h = 0;
  lcp[0] = 0;
  for(int i=0;i<m;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 a;
string s;
int sa1[100010],lcp1[100010];


int main(){
  cin >> a ;
  cin >> s ;
  
  construct_sa(s,sa1);
  construct_lcp(s,sa1,lcp1);
  
  int ans = 0;
  
  for(int i=0;i< n;i++){
    for(int j=i;j<n;j++){
    if((sa1[i] < n) != (sa1[i+1] < n)){
      lcp1[i] = min(lcp[i],j-i);
      ans = max(ans , lcp1[i]);
    }
  }
  cout << ans << endl;
}
    


Compiler output:
a.cc: In function 'int main()':
a.cc:75:21: error: 'lcp' was not declared in this scope; did you mean 'lcp1'?
   75 |       lcp1[i] = min(lcp[i],j-i);
      |                     ^~~
      |                     lcp1
a.cc:80:2: error: expected '}' at end of input
   80 | }
      |  ^
a.cc:63:11: note: to match this '{'
   63 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int n , k;
int rank1[100010],rank2[100010];
int tmp[100010];

bool compare_sa(int i , int j){
  if(rank1[i] != rank1[j]) return rank1[i] < rank1[j];
  else{
    int ri = i + k <= n ? rank1[i+k] : -1;
    int rj = j + k <= n ? rank1[j+k] : -1;
    return ri < rj;
  }
}

void construct_sa(string S , int *sa){
  n = S.length();
  
  for(int i=0;i<=n;i++){
    sa[i] = i;
    rank1[i] = i < n ? S[i] : -1;
  }
  
  for(k=1;k<=n;k*=2){
    sort(sa, sa+n+1,compare_sa);
    
    tmp[sa[0]] = 0;
    for(int i=1;i<=n;i++){
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(sa[i-1], sa[i]) ? 1 : 0);
    }
    for(int i = 0;i<=n;i++){
      rank1[i] = tmp[i];
    }
  }
}

void construct_lcp(string S ,int *sa , int *lcp){
  int m = S.length();
  for(int i=0;i<=m;i++) rank2[sa[i]] = i;
  
  int h = 0;
  lcp[0] = 0;
  for(int i=0;i<m;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 n;
string s;
int sa[100010],lcp[100010];


int main(){
  cin >> n ;
  cin >> s ;
  
  construct_sa(s,sa);
  construct_lcp(s,sa,lcp);
  
  int ans = 0;
  
  for(int i=0;i< n;i++){
    if((sa[i] < n) != (sa[i+1] < n)){
      ans = max(ans , lcp[i]);
    }
  }
  cout << ans << endl;
}
    


Compiler output:
a.cc:58:5: error: redefinition of 'int n'
   58 | int n;
      |     ^
a.cc:7:5: note: 'int n' previously declared here
    7 | int n , k;
      |     ^
Language: C++

#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int n , k;
int rank1[100010],rank2[100010];
int tmp[100010];

bool compare_sa(int i , int j){
  if(rank1[i] != rank1[j]) return rank1[i] < rank1[j];
  else{
    int ri = i + k <= n ? rank1[i+k] : -1;
    int rj = j + k <= n ? rank1[j+k] : -1;
    return ri < rj;
  }
}

void construct_sa(string S , int *sa){
  n = S.length();
  
  for(int i=0;i<=n;i++){
    sa[i] = i;
    rank1[i] = i < n ? S[i] : -1;
  }
  
  for(k=1;k<=n;k*=2){
    sort(sa, sa+n+1,compare_sa);
    
    tmp[sa[0]] = 0;
    for(int i=1;i<=n;i++){
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(sa[i-1], sa[i]) ? 1 : 0);
    }
    for(int i = 0;i<=n;i++){
      rank[i] = tmp[i];
    }
  }
}

void construct_lcp(string S ,int *sa , int *lcp){
  int m = S.length();
  for(int i=0;i<=m;i++) rank2[sa[i]] = i;
  
  int h = 0;
  lcp[0] = 0;
  for(int i=0;i<m;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;
  }
}

string s;
int sa[100010],lcp[100010];


int main(){
  int ss = s.size();
  
  construct_sa(s,sa);
  construct_lcp(s,sa,lcp);
  
  int ans = 0;
  for(int i=0;i< s.size();i++){
    if((sa[i] < ss) != (sa[i+1] < ss )){
      ans = max(ans , lcp[i]);
    }
  }
  cout << ans << endl;
}
    


Compiler output:
a.cc: In function 'void construct_sa(std::string, int*)':
a.cc:36:12: error: redeclaration of 'auto i'
   36 |       rank[i] = tmp[i];
      |            ^
a.cc:35:13: note: 'int i' previously declared here
   35 |     for(int i = 0;i<=n;i++){
      |             ^
a.cc:36:21: error: use of 'i' before deduction of 'auto'
   36 |       rank[i] = tmp[i];
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

vector<int> zalg(string s) {
    int n = s.size(), i = 1, j = 0;
    vector<int> a(n);
    a[0] = n;
    while (i < n) {
        while (i + j < n && s[j] == s[i + j]) j++;
        a[i] = j;
        if (j == 0) {
            i++;
            continue;
        }
        int k = 1;
        while (i + k < n && k + a[k] < j) {
            a[i + k] = a[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    rep(i, 0, n) {
        string t = s.substr(i);
        vector<int> x = zalg(t);
        debug(x);
        rep(j, 0, n - i) {
            ans = max(ans, min(j, x[j]));
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'debug' was not declared in this scope
   39 |         debug(x);
      |         ^~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


vector<int> Zalgorithm(string s){
    int n = s.size();
    vector<int> res(n);
    res[0] = n;
    int i = 1,j = 0;
    while(i < n){
        while(i+j < n && s[j] == s[i+j]) j++;
        res[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(i+k < n && k+z[k] < j){
            res[i+k] = res[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return res;
}

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    rep(i,N){
        string t = S.substr(i,N-i);
        vector<int> z = Zalgorithm(t);
        int m = z.size();
        repr(j,1,m){
            ans = max(ans,min(z[j],j));
        }
    }
    cout << ans << endl;
}



Compiler output:
a.cc: In function 'std::vector<int> Zalgorithm(std::string)':
a.cc:44:28: error: 'z' was not declared in this scope
   44 |         while(i+k < n && k+z[k] < j){
      |                            ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


vector<int> Zalgorithm(string s){
    int n = s.size();
    vector<int> res(n);
    res[0] = n;
    int i = 1,j = 0;
    while(i < n){
        while(i+j < n && s[j] == s[i+j]) j++;
        z[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(i+k < n && k+z[k] < j){
            z[i+k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return res;
}

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    rep(i,N){
        string t = S.substr(i,N-i);
        vector<int> z = Zalgorithm(t);
        int m = z.size();
        repr(j,1,m){
            ans = max(ans,min(z[j],j));
        }
    }
    cout << ans << endl;
}



Compiler output:
a.cc: In function 'std::vector<int> Zalgorithm(std::string)':
a.cc:38:9: error: 'z' was not declared in this scope
   38 |         z[i] = j;
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
const int MOD1 = 1e9 + 11;
const int B = 1271;
int n;
string s;
ll h[N], f[N];
int geth(int l, int r) {
    ll res = ((h[r] - h[l-1] * f[r-l+1]) % MOD + MOD) % MOD;
    return res;
}
int main() {
    cin >> n >> s;
    f[0] = 1;
    for(int i = 0; i < n; i++) {
        h[i+1] = (h[i] * B + s[i] - 'a') % MOD;
        f[i+1] = f[i] * B % MOD;
    }
    int l = 1, r = n, ans = 0;
    while(l <= r) {
        int mid = (l + r) / 2;
        int f = 0;
        for(int i = 1; i+mid-1 <= n && !f; i++) {
            for(int j = i+mid; j+mid-1 <= n; j++) {
                if(geth(i,i+mid-1) == geth(j,j+mid-1)) {
                    f = 1;
                    break;
                }
            }
        }
        if(f) {
            ans = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int geth(int, int)':
a.cc:11:44: error: 'MOD' was not declared in this scope; did you mean 'MOD1'?
   11 |     ll res = ((h[r] - h[l-1] * f[r-l+1]) % MOD + MOD) % MOD;
      |                                            ^~~
      |                                            MOD1
a.cc: In function 'int main()':
a.cc:18:44: error: 'MOD' was not declared in this scope; did you mean 'MOD1'?
   18 |         h[i+1] = (h[i] * B + s[i] - 'a') % MOD;
      |                                            ^~~
      |                                            MOD1
Language: C++

#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int N, ans;

void Zalgo(string S) {
    vector<int> A(N);
    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;
    }

    rep(i, len) ans = max(ans, min(i, A[i]));
}

int main() {
    string S;
    cin >> N >> S;
    rep(i, N) Zalgo(S.substr(i));
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'void Zalgo(std::string)':
a.cc:8:5: error: 'vector' was not declared in this scope
    8 |     vector<int> A(N);
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | #define rep(i,n) for(int i=0;i<n;++i)
a.cc:8:12: error: expected primary-expression before 'int'
    8 |     vector<int> A(N);
      |            ^~~
a.cc:12:9: error: 'A' was not declared in this scope
   12 |         A[i] = j;
      |         ^
a.cc:23:12: error: 'len' was not declared in this scope; did you mean 'mblen'?
   23 |     rep(i, len) ans = max(ans, min(i, A[i]));
      |            ^~~
a.cc:2:32: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(int i=0;i<n;++i)
      |                                ^
a.cc:23:39: error: 'A' was not declared in this scope
   23 |     rep(i, len) ans = max(ans, min(i, A[i]));
      |                                       ^
Language: C++

// CODE by Kazhybay Askar
#include <bits/stdc++.h>

using namespace std;

#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define mp     make_pair
#define cont   continue
#define ll     long long
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

const int MAXN = 1e5  + 7;
const ll MOD  = 1e9  + 7;
const int P=31;

ll a[MAXN],b[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
int n,m,k,cnt,sum,ans,mx,mn=INF;
bool y;
    
unordered_map<ll,ll>p,q;

void solve(){
	cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        ll h=1;
        for(int j=i;j<n;j++){
            h*=P;
            h+=s[j]-'a';
            h%=MOD;
            p[h]++;
            if(p[h]>1){
                if(q[h]<i){
                    mx=max(mx,j-i+1);
                }
            }
            q[h]=j;
        }
    }
    cout<<mx;
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Compiler output:
a.cc:27:29: error: 'INF' was not declared in this scope
   27 | int n,m,k,cnt,sum,ans,mx,mn=INF;
      |                             ^~~
Language: C++

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=5e3+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,h[ary],bp[ary],p=31;
string s;
ll hash(ll l,ll r){
	if(!l){
		return h[r];
	}
	return (h[r]-(h[l-1]*bp[r-l+1]%mod)+mod)%mod;
}
ll ch(ll k){
	for(int i=0;i<len(s);i++){
		if(i+k-1>=len(s)){
			break;
		}
		for(int j=i+k;j<len(s);j++){
			if(j+k-1>=len(s)){
				break;
			}
			if(hash(i,i+k-1)==hash(j,j+k-1)){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	bp[0]=1;
	for(int i=1;i<=ary-5;i++){
		bp[i]=bp[i-1]*p;
		bp[i]%=mod;
	}
	cin>>n>>s;
	for(int i=0;i<len(s);i++){
		h[i]=s[i];
		if(i){
			h[i]+=(h[i-1]*p);
		}
		h[i]%=mod;
	}
	ll l=1,r=n,ans=0;
	while(l<=r){
		ll m=(l+r)/2;
		if(ch(m)){
			l=m+1;
			ans=m;
		}
		else{
			r=m-1;
		}
	}
	cout<<ans;
}

Compiler output:
a.cc:7:9: warning: "full" redefined
    7 | #define full(x) x.begin(),x.end()
      |         ^~~~
a.cc:6:9: note: this is the location of the previous definition
    6 | #define full(x,n) x,x+n+1
      |         ^~~~
a.cc: In function 'll ch(ll)':
a.cc:54:28: error: reference to 'hash' is ambiguous
   54 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                            ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:4: note:                 'll hash(ll, ll)'
   39 | ll hash(ll l,ll r){
      |    ^~~~
a.cc:54:43: error: reference to 'hash' is ambiguous
   54 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                                           ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:4: note:                 'll hash(ll, ll)'
   39 | ll hash(ll l,ll r){
      |    ^~~~
Language: C++


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second



#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()



typedef double db;
typedef long long ll;

const ll ary=5e3+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,h[ary],bp[ary],p=31;
string s;
ll hash(ll l,ll r){
	return (h[r]-(h[l-1]*bp[r-l+1]%mod)+mod)%mod;
}
ll ch(ll k){
	for(int i=0;i<len(s);i++){
		if(i+k-1>=len(s)){
			break;
		}
		for(int j=i+k;j<len(s);j++){
			if(j+k-1>=len(s)){
				break;
			}
			if(hash(i,i+k-1)==hash(j,j+k-1)){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	bp[0]=1;
	for(int i=1;i<=ary-5;i++){
		bp[i]=bp[i-1]*p;
		bp[i]%=mod;
	}
	cin>>n>>s;
	for(int i=0;i<len(s);i++){
		h[i]=s[i];
		if(i){
			h[i]+=(h[i-1]*p);
		}
		h[i]%=mod;
	}
	ll l=1,r=n,ans=0;
	while(l<=r){
		ll m=(l+r)/2;
		if(ch(m)){
			l=m+1;
			ans=m;
		}
		else{
			r=m-1;
		}
	}
	cout<<ans;
}

Compiler output:
a.cc:6:9: warning: "full" redefined
    6 | #define full(x) x.begin(),x.end()
      |         ^~~~
a.cc:5:9: note: this is the location of the previous definition
    5 | #define full(x,n) x,x+n+1
      |         ^~~~
a.cc: In function 'll ch(ll)':
a.cc:47:28: error: reference to 'hash' is ambiguous
   47 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                            ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:2:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:35:4: note:                 'll hash(ll, ll)'
   35 | ll hash(ll l,ll r){
      |    ^~~~
a.cc:47:43: error: reference to 'hash' is ambiguous
   47 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                                           ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:35:4: note:                 'll hash(ll, ll)'
   35 | ll hash(ll l,ll r){
      |    ^~~~
Language: C++

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <iostream>
//#include <ext/pb_ds/assoc_container.hpp>

//#define full(x,n) x,x+n+1
//#define full(x) x.begin(),x.end()
//#define finish return 0

//#define putb push_back
//#define f first
//#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

//#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
//#define putf push_front
//#define gainb pop_back

//#define gainf pop_front
//#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=5e3+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
//using namespace __gnu_pbds;
ll n,h[ary],bp[ary],p=31;
string s;
long long int hash(ll l,ll r){
	return (h[r]-(h[l-1]*bp[r-l+1]%mod)+mod)%mod;
}
bool ch(ll k){
	for(int i=0;i<s.size();i++){
		if(i+k-1>=s.size()){
			break;
		}
		for(int j=i+k;j<s.size();j++){
			if(j+k-1>=s.size()){
				break;
			}
			if(hash(i,i+k-1)==hash(j,j+k-1)){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	bp[0]=1;
	for(int i=1;i<=ary-5;i++){
		bp[i]=bp[i-1]*p;
		bp[i]%=mod;
	}
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		h[i]=s[i];
		if(i){
			h[i]+=(h[i-1]*p);
		}
		h[i]%=mod;
	}
	long long int l=1,r=n,ans=0;
	while(l<=r){
		long long int m=(l+r)/2;
		if(ch(m)){
			l=m+1;
			ans=m;
		}
		else{
			r=m-1;
		}
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'bool ch(ll)':
a.cc:51:28: error: reference to 'hash' is ambiguous
   51 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                            ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:15: note:                 'long long int hash(ll, ll)'
   39 | long long int hash(ll l,ll r){
      |               ^~~~
a.cc:51:43: error: reference to 'hash' is ambiguous
   51 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                                           ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:15: note:                 'long long int hash(ll, ll)'
   39 | long long int hash(ll l,ll r){
      |               ^~~~
Language: C++

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <iostream>
//#include <ext/pb_ds/assoc_container.hpp>

//#define full(x,n) x,x+n+1
//#define full(x) x.begin(),x.end()
//#define finish return 0

//#define putb push_back
//#define f first
//#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

//#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
//#define putf push_front
//#define gainb pop_back

//#define gainf pop_front
//#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=5e3+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
//using namespace __gnu_pbds;
ll n,h[ary],bp[ary],p=31;
string s;
long long int hash(ll l,ll r){
	return (h[r]-(h[l-1]*bp[r-l+1]%mod)+mod)%mod;
}
long long int ch(ll k){
	for(int i=0;i<s.size();i++){
		if(i+k-1>=s.size()){
			break;
		}
		for(int j=i+k;j<s.size();j++){
			if(j+k-1>=s.size()){
				break;
			}
			if(hash(i,i+k-1)==hash(j,j+k-1)){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	bp[0]=1;
	for(int i=1;i<=ary-5;i++){
		bp[i]=bp[i-1]*p;
		bp[i]%=mod;
	}
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		h[i]=s[i];
		if(i){
			h[i]+=(h[i-1]*p);
		}
		h[i]%=mod;
	}
	long long int l=1,r=n,ans=0;
	while(l<=r){
		long long int m=(l+r)/2;
		if(ch(m)){
			l=m+1;
			ans=m;
		}
		else{
			r=m-1;
		}
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'long long int ch(ll)':
a.cc:51:28: error: reference to 'hash' is ambiguous
   51 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                            ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:15: note:                 'long long int hash(ll, ll)'
   39 | long long int hash(ll l,ll r){
      |               ^~~~
a.cc:51:43: error: reference to 'hash' is ambiguous
   51 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                                           ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:15: note:                 'long long int hash(ll, ll)'
   39 | long long int hash(ll l,ll r){
      |               ^~~~
Language: C++

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <iostream>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=5e3+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,h[ary],bp[ary],p=31;
string s;
ll hash(ll l,ll r){
	return (h[r]-(h[l-1]*bp[r-l+1]%mod)+mod)%mod;
}
ll ch(ll k){
	for(int i=0;i<len(s);i++){
		if(i+k-1>=len(s)){
			break;
		}
		for(int j=i+k;j<len(s);j++){
			if(j+k-1>=len(s)){
				break;
			}
			if(hash(i,i+k-1)==hash(j,j+k-1)){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	bp[0]=1;
	for(int i=1;i<=ary-5;i++){
		bp[i]=bp[i-1]*p;
		bp[i]%=mod;
	}
	cin>>n>>s;
	for(int i=0;i<len(s);i++){
		h[i]=s[i];
		if(i){
			h[i]+=(h[i-1]*p);
		}
		h[i]%=mod;
	}
	ll l=1,r=n,ans=0;
	while(l<=r){
		ll m=(l+r)/2;
		if(ch(m)){
			l=m+1;
			ans=m;
		}
		else{
			r=m-1;
		}
	}
	cout<<ans;
}

Compiler output:
a.cc:7:9: warning: "full" redefined
    7 | #define full(x) x.begin(),x.end()
      |         ^~~~
a.cc:6:9: note: this is the location of the previous definition
    6 | #define full(x,n) x,x+n+1
      |         ^~~~
a.cc: In function 'll ch(ll)':
a.cc:51:28: error: reference to 'hash' is ambiguous
   51 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                            ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:4: note:                 'll hash(ll, ll)'
   39 | ll hash(ll l,ll r){
      |    ^~~~
a.cc:51:43: error: reference to 'hash' is ambiguous
   51 |                         if(hash(i,i+k-1)==hash(j,j+k-1)){
      |                                           ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:39:4: note:                 'll hash(ll, ll)'
   39 | ll hash(ll l,ll r){
      |    ^~~~
Language: C

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=5e3+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,h[ary],bp[ary],p=31;
string s;
ll hash(ll l,ll r){
	return (h[r]-(h[l-1]*bp[r-l+1]%mod)+mod)%mod;
}
ll ch(ll k){
	for(int i=0;i<len(s);i++){
		if(i+k-1>=len(s)){
			break;
		}
		for(int j=i+k;j<len(s);j++){
			if(j+k-1>=len(s)){
				break;
			}
			if(hash(i,i+k-1)==hash(j,j+k-1)){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	bp[0]=1;
	for(int i=1;i<=ary-5;i++){
		bp[i]=bp[i-1]*p;
		bp[i]%=mod;
	}
	cin>>n>>s;
	for(int i=0;i<len(s);i++){
		h[i]=s[i];
		if(i){
			h[i]+=(h[i-1]*p);
		}
		h[i]%=mod;
	}
	ll l=1,r=n,ans=0;
	while(l<=r){
		ll m=(l+r)/2;
		if(ch(m)){
			l=m+1;
			ans=m;
		}
		else{
			r=m-1;
		}
	}
	cout<<ans;
}

Compiler output:
main.c:3:10: fatal error: bits/stdc++.h: No such file or directory
    3 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.