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

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

#define SETNUM(rank, i,s) \
  NUM[i] = make_pair(make_pair(rank[i], i+s<n?rank[i+s]:n), i);
#define RENUMBER(rank) \
  sort(NUM, NUM+n); \
  rank[ NUM[0].second ] = 0; \
  for (int i = 1; i < n; ++i) \
    rank[ NUM[i].second ] = rank[ NUM[i-1].second ] \
      + (NUM[i-1].first != NUM[i].first) ;
vector<int> karp_miller_rosenberg(char *text, int r) {
  int n = strlen(text), k;
  int rank[n]; copy(text, text+n, rank);
  pair<pair<int,int>,int> NUM[n];
  for (k = 0; k*2 <= r; k ? k*=2 : ++k) { // power of 2
    for (int i = 0; i < n; ++i) SETNUM(rank, i, k);
    RENUMBER(rank);
  }
  for (int i = 0; i < n; ++i) SETNUM(rank, i, r-k);
  RENUMBER(rank);
  return vector<int>(rank, rank+n);
}

int ranks[32][200000];
void karp_miller_rosenberg_pre(char *text) {
  int n = strlen(text), m = 0;
  pair<pair<int,int>,int> NUM[n];
  copy(text, text+n, ranks[m]);
  for (int k = 0; k <= n; k ? k*=2 : ++k) { // power of 2
    for (int i = 0; i < n; ++i) SETNUM(ranks[m], i, k);
    if (k > 0) ++m; RENUMBER(ranks[m]);
  }
}
int repeated_factor(char *text, int r, int k) {
  int n = strlen(text), t, s;
  pair<pair<int,int>,int> NUM[n];
  int rank[n], count[n];
  for (s = 1, t = 0; s * 2 < r; s *= 2, ++t);
  for (int i = 0; i < n; ++i) SETNUM(ranks[t], i, r-s);
  RENUMBER(rank);
  memset(count, 0, sizeof(count));
  for (int i = 0; i < n; ++i)
    if (++count[ rank[i] ] >= k) return i;
  return -1;
}
string longest_repeated_factor(char *text, int k) {
  karp_miller_rosenberg_pre(text);
  int low = 1, high = strlen(text);
  while (low+1 < high) {
    int mid = (low + high) / 2;
    if (repeated_factor(text, mid, k) < 0) high = mid;
    else                                    low = mid;
  }
  int t = repeated_factor(text, low, k);
  return t >= 0 ? string(text+t, text+t+low+1) : "";
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;
  
    cout << repeated_factor(s,n);
        

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:107:31: error: 'n' was not declared in this scope
  107 |     cout << repeated_factor(s,n);
      |                               ^
Language: C++

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

using namespace std;
typedef long long ll;

bool is_equal_substr(string s1, int s_s1, string s2, int s_s2, int length) {
    if (s1.size() != s2.size()) return false;

    for (int i = 0; i < length; i++) {
        if (s1[s_s1+i] != s2[s_s2+i]) return false;
    }
    return true;
}

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    string S; cin >> S;

    int right = S.size() / 2;
    int left = 0;
    while (right - left > 1) {
        int mid = (right + left) / 2;
        bool is_match = false;
        for (int i = 0; i < S.size(); i++) {
            for (int j = 0; j < S.size() - mid; j++) {
                if (j + mid - 1 < i) {
                    if (is_equal_substr(S, i, S, j, mid)) {
                        is_match = true;
                        break;
                    }
                } else if (i + mid - 1 < j) {
                    if (is_equal_substr(S, i, S, j, mid)) {
                        is_match = true;
                        break;
                    }
                }
            }
            if (is_match) {
                break;
            }
        }
        if (is_match) {
            left = mid;
        } else {
            right = mid;
        }
    }
    if (right - left == 1) {
        int mid = right;
        bool is_match = false;
        for (int i = 0; i < S.size(); i++) {
            for (int j = 0; j < S.size() - mid; j++) {
                if (j + mid - 1 < i) {
                    if (is_equal_substr(S, i, S, j, mid)) {
                        is_match = true;
                        break;
                    }
                } else if (i + mid - 1 < j) {
                    if (is_equal_substr(S, i, S, j, mid)) {
                        is_match = true;
                        break;
                    }
                }
            }
            if (is_match) {
                break;
            }
        }
        cout << (is_match ? right : left) << endl;
    } else {
        assert("Error");
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:77:9: error: 'assert' was not declared in this scope
   77 |         assert("Error");
      |         ^~~~~~
a.cc:8:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    7 | #include <cmath>
  +++ |+#include <cassert>
    8 |
Language: C++

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

const int maxN = 5000 + 9;
ll BASE;

struct StringHash {
    ll MOD;
    vector<ll> h, pw;

    StringHash(const string &s, ll M){
        int n = (int)s.size();
        h.resize(n + 1);    pw.resize(n + 1);
        MOD = M;
        pw[0] = 1;

        for(int i = 1; i <= n; i++){
            pw[i] = (pw[i - 1] * BASE) % MOD;
        }

        for(int i = 1; i <= n; i++){
            h[i] = ((h[i - 1] * BASE) % MOD) + (s[i - 1] - 'a' + 1)) % MOD;
            //cerr << h[i] << ' ';
        }
        //cerr << '\n';
    }

    ll getHash(int i, int j){
        return (h[j] - h[i - 1] * pw[j - i + 1] + MOD * MOD) % MOD;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;  string s;
    cin >> n;
    cin >> s;

    BASE = 6329;

    StringHash f(s, 1e9 + 7);
    StringHash g(s, 1e9 + 9);

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

        bool flag = false;
        map<ll, int> idx;

        for(int i = 1; i + len - 1 <= n; i++){
            ll a = f.getHash(i, i + len - 1);
            if(idx.count(a)){
                if(i >= idx[a] + len){
                    flag = true;
                    break;
                }
            }

            idx[a] = i;
        }

        if(flag){
            ans = len;
            lo = len + 1;
        } else {
            hi = len - 1;
        }
    }

    cout << ans << '\n';

    return 0;
}


Compiler output:
a.cc: In constructor 'StringHash::StringHash(const std::string&, ll)':
a.cc:23:68: error: expected ';' before ')' token
   23 |             h[i] = ((h[i - 1] * BASE) % MOD) + (s[i - 1] - 'a' + 1)) % MOD;
      |                                                                    ^
Language: C++

from collections import Counter


def resolve():
    n = int(input())
    s = input()
    for i in range(n // 2, 0, -1):
        c = Counter([s[x:x + i] for x in range(n - i + 1)])
        for j in [x for x in c if c.get(x) > 1]:
            if j in s[s.find(j) + i:]:
                print(i)
                return
    print(0)


if __name__ == '__main__':
    resolve()

Compiler output:
a.cc:16:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   16 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import Counter
      | ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) cerr<<#x<<":"<<(x)<<endl;

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

  int ans = 0;
  map<string,int> mp;
  map<string,int> mem;
  for(int i=n-1;i>=0;--i){
    string tmp = "";
    for(int j=i; j<n; ++j) {
      tmp += s[j];

      if (mp.count(tmp) && mem[tmp] <= j) {
        continue;
      }
      mp[tmp]++;
      mem[tmp] = i;
      
      if (mp[tmp] <= 1) continue;
      ans = max(ans, tmp.size());
    }
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:16: error: no matching function for call to 'max(int64&, std::__cxx11::basic_string<char>::size_type)'
   26 |       ans = max(ans, tmp.size());
      |             ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:26:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   26 |       ans = max(ans, tmp.size());
      |             ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:26:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |       ans = max(ans, tmp.size());
      |             ~~~^~~~~~~~~~~~~~~~~
Language: Java

package abc.abc141;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Z-Algorithm or ローリングハッシュが想定解？
 * http://drken1215.hatenablog.com/entry/2019/09/16/014600
 * LCP(Longest Common Prefix)配列をどう求めるかで方針が異なる．
 * LCP Array: https://blog.shibayu36.org/entry/2017/01/06/103956
 */
public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "YES";
    private static final String NO = "NO";

    public static void main(String[] args) {
        test();
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String S = sc.next();

        int ans = solveDP(N, S);

        System.out.println(ans);
    }
  
      private static int solveDP(int N, String S) {
        int count = 0;
        // dp[i][j]: i文字目からとj文字目からとで一致する文字列長
        int[][] dp = new int[N+1][N+1];


        for (int i=N-1; i>=0; i--) {
            for (int j=N-1; j>i; j--) {
                if (S.charAt(i) == S.charAt(j)) {
                    dp[i][j] = Math.max(dp[i][j], dp[i+1][j+1]+1);
                }

                count = Math.max(count, Math.min(dp[i][j], j-i));
            }
        }


        return count;
    }
}

Compiler output:
Main.java:19: error: cannot find symbol
        test();
        ^
  symbol:   method test()
  location: class Main
1 error
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
constexpr ll mod[2] = {1000000007,998244353};
struct rolling_hash{
	ll z = 100,ex[2][100010];
	vector<ll> v,w[2];
	rolling_hash(string &s){
		int i,j,n = s.size();
		for(i=0;i<n;i++){
			v.push_back(s[i] - 'a' + 1);
		}
		w[0].assign(n + 1,0),w[1].assign(n + 1,0);
		ex[0][0] = 1,ex[1][0] = 1;
		for(i=0;i<n;i++){
			for(j=0;j<2;j++){
				w[j][i + 1] = (w[j][i]*z + v[i])%mod[j];
				ex[j][i + 1] = ex[j][i]*z%mod[j];
			}
		}
	}
	inline ll get(int l, int r){//[l,r)
		//ll x = (w[0][r] - ex[0][r - l]*w[0][l]%mod[0] + mod[0])%mod[0];
		ll y = (w[1][r] - ex[1][r - l]*w[1][l]%mod[1] + mod[1])%mod[1];
		return y;
		return {x,y};
	}
};

string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,j,n,ans = 0;
	cin >> n >> s;
	rolling_hash rh(s);
	for(i=0;i<n;i++){
		for(j=i + 1;j<n;j++){
			if(s[i]!=s[j]) continue;
			int l = 0,r = min(j - i,n - j);
			if(rh.get(i,i + r)==rh.get(j,j + r)){
				ans = max(ans,r);
				continue;
			}
			while(r - l>1){
				int mid = (l + r)/2;
				if(rh.get(i,i + mid)==rh.get(j,j + mid)) l = mid;
				else r = mid;
			}
			ans = max(ans,l);
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In member function 'll rolling_hash::get(int, int)':
a.cc:29:25: error: 'x' was not declared in this scope
   29 |                 return {x,y};
      |                         ^
a.cc:29:28: error: cannot convert '<brace-enclosed initializer list>' to 'll' {aka 'long long int'} in return
   29 |                 return {x,y};
      |                            ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
constexpr ll mod[2] = {1000000007,998244353};
struct rolling_hash{
	ll z = 100,ex[2][100010];
	vector<ll> v,w[2];
	rolling_hash(string &s){
		int i,j,n = s.size();
		for(i=0;i<n;i++){
			v.push_back(s[i] - 'a' + 1);
		}
		w[0].assign(n + 1,0),w[1].assign(n + 1,0);
		ex[0][0] = 1,ex[1][0] = 1;
		for(i=0;i<n;i++){
			for(j=0;j<2;j++){
				w[j][i + 1] = (w[j][i]*z + v[i])%mod[j];
				ex[j][i + 1] = ex[j][i]*z%mod[j];
			}
		}
	}
	inline pll get(int l, int r){//[l,r)
		//ll x = (w[0][r] - ex[0][r - l]*w[0][l]%mod[0] + mod[0])%mod[0];
		ll y = (w[1][r] - ex[1][r - l]*w[1][l]%mod[1] + mod[1])%mod[1];
		return y;
		return {x,y};
	}
};

string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,j,n,ans = 0;
	cin >> n >> s;
	rolling_hash rh(s);
	for(i=0;i<n;i++){
		for(j=i + 1;j<n;j++){
			if(s[i]!=s[j]) continue;
			int l = 0,r = min(j - i,n - j);
			if(rh.get(i,i + r)==rh.get(j,j + r)){
				ans = max(ans,r);
				continue;
			}
			while(r - l>1){
				int mid = (l + r)/2;
				if(rh.get(i,i + mid)==rh.get(j,j + mid)) l = mid;
				else r = mid;
			}
			ans = max(ans,l);
		}
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In member function 'pll rolling_hash::get(int, int)':
a.cc:28:24: error: could not convert 'y' from 'll' {aka 'long long int'} to 'pll' {aka 'std::pair<long long int, long long int>'}
   28 |                 return y;
      |                        ^
      |                        |
      |                        ll {aka long long int}
a.cc:29:25: error: 'x' was not declared in this scope
   29 |                 return {x,y};
      |                         ^
a.cc:29:28: error: could not convert '{<expression error>, y}' from '<brace-enclosed initializer list>' to 'pll' {aka 'std::pair<long long int, long long int>'}
   29 |                 return {x,y};
      |                            ^
      |                            |
      |                            <brace-enclosed initializer list>
Language: C++

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

int dp[5005][5005];

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = n-1; i >= 0; --i) {
        for (int j = n - 1; j >= 0; --j) {
            if (s[i] != s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1] + 1;
        }
    }
    int ans = 0;
    rep (i, n) rep (j, n) {
        if (i >= j) continue;
        int now = min(dp[i][j], j - i);
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:14: error: 'i' was not declared in this scope
    3 | #define rep (i, n) for (int i = 0; i < (n); ++i)
      |              ^
a.cc:20:5: note: in expansion of macro 'rep'
   20 |     rep (i, n) rep (j, n) {
      |     ^~~
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef int ll;
typedef pair<ll,ll> pll;
constexpr ll mod[2] = {10007,10009},z = 100;
map<pll,int> mp;
string s;
vector<ll> trans(string t){
	int i,n = t.size();
	vector<ll> v;
	for(i=0;i<n;i++){
		v.push_back(t[i] - 'a' + 1);
	}
	return v;
}
vector<vector<ll>> pre(string t){
	int i,j,n;
	vector<ll> v = trans(t);
	n = v.size();
	vector<vector<ll>> w(2,vector<ll>(n + 1,0));
	for(i=1;i<=n;i++){
		for(j=0;j<2;j++){
			w[j][i] = (w[j][i-1]*z + v[i-1])%mod[j];
		}
	}
	return w;
}
ll ex[5010][2];
vector<vector<ll>> v;
ll rolling_hash(int l, int r){//[l,r]
	ll x = (v[0][r] - ex[r - l + 1][0]*v[0][l - 1]%mod[0] + mod[0])%mod[0];
	ll y = (v[1][r] - ex[r - l + 1][1]*v[1][l - 1]%mod[1] + mod[1])%mod[1];
	return {x,y};
}
int n;
int ch(int i,int j){
	int l = 0,r = min(n - j,j - i - 1);
	if(rolling_hash(i,i + r)==rolling_hash(j,j + r)) return r + 1;
	while(r - l>1){
		int mid = (l + r)/2;
		if(rolling_hash(i,i + mid)==rolling_hash(j,j + mid)) l = mid;
		else r = mid;
	}
	return r;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,j,ans = 0;
	cin >> n >> s;
	v = pre(s);
	ex[0][0] = 1; ex[0][1] = 1;
	for(i=0;i<n;i++){
		for(j=0;j<2;j++){
			ex[i + 1][j] = 100*ex[i][j]%mod[j];
		}
	}
	for(i=0;i<n;i++){
		for(j=i + 1;j<n;j++){
			if(s[i]==s[j]) ans = max(ans,ch(i,j));
		}
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'll rolling_hash(int, int)':
a.cc:36:20: error: cannot convert '<brace-enclosed initializer list>' to 'll' {aka 'int'} in return
   36 |         return {x,y};
      |                    ^
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(){
  int i,j,n,len = 0;
  char str[5001];
  cin>>str;
  n = strlen(str);
  for(i=0; i<(n-len); i++){
    int count = 0;
    for(j = i+1; j<n;j++){
      if(str[i] == str[j]){
        count++;
        if(count>len)
          len = count;
      }
      else
          count = 0;
    }
  }
  cout<<len<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'strlen' was not declared in this scope
   10 |   n = strlen(str);
      |       ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>
Language: C++

#include <iostream>
#include <queue>

using namespace std;

int main(){
  int i,j,n,len = 0;
  char str[5001];
  cin>>str;
  n = strlen(str);
  for(i=0; i<(n-len); i++){
    int count = 0;
    for(j = i+1; j<n;j++){
      if(str[i] == str[j]){
        count++;
        if(count>len)
          len = count;
        else
          count = 0;
    }
  }
  cout<<len<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'strlen' was not declared in this scope
   10 |   n = strlen(str);
      |       ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | 
a.cc:23:2: error: expected '}' at end of input
   23 | }
      |  ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <queue>

using namespace std;

int main(){
  int i,n,len = 0;
  char str[5001];
  cin>>str;
  n = strlen(str);
  for(i=0; i<(n-len); i++){
    int count = 0;
    for(j = i+1; j<n;j++){
      if(str[i] == str[j]){
        count++;
        if(count>len)
          len = count;
        else
          count = 0;
    }
  }
  cout<<len<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'strlen' was not declared in this scope
   10 |   n = strlen(str);
      |       ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | 
a.cc:13:9: error: 'j' was not declared in this scope
   13 |     for(j = i+1; j<n;j++){
      |         ^
a.cc:23:2: error: expected '}' at end of input
   23 | }
      |  ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#include <queue>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int maxi=0;
	rep(i,1,n){ //単語同士の文字の幅
		int c=0,a=0;
		for(int i=0,j=w;j<n;i++,j++){
			if(s[i] == s[j]) a = max(a,++c);
			else c=0;
			maxi = max(maxi,min(a,w));
			}
		}
	cout << maxi << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:31: error: 'w' was not declared in this scope
   28 |                 for(int i=0,j=w;j<n;i++,j++){
      |                               ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#include <queue>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int maxi=0;
	rep(i,1,n){ //単語同士の文字の幅
		int c=0,a=0;
		for(int i=0,j=w;j<n;i++,j++){
			if(s[i] == s[j]) a = max(a,++c);
			else c=0;
			maxi = max(maxi,min(a,w));
			}
		}
	}
	cout << maxi << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:31: error: 'w' was not declared in this scope
   28 |                 for(int i=0,j=w;j<n;i++,j++){
      |                               ^
a.cc: At global scope:
a.cc:35:9: error: 'cout' does not name a type
   35 |         cout << maxi << endl;
      |         ^~~~
a.cc:36:1: error: expected declaration before '}' token
   36 | }
      | ^
Language: C++

let input_line: Int? = readLine()
let S = Array(readLine()!.characters)



var ng:Int = N
var ok:Int = 0
let mod = 1000000007
let x = 998244353
while(ng - ok > 1){
    var l:Bool = false
    var hashTable = [Int]()
    var mid:Int = (ok + ng) / 2
    
    var hash:Int = 0
    for i in 0..<mid {
        hash = (hash * x + Int(S[i])) % mod
    }
    
    var used:Set = [hash]
    var pow:Int = 1
    for _ in 0..<mid {
        pow *= x;
        pow %= mod
    }
    for i in mid..<N {
        hash = ((hash * x + Int(S[i]) - S[] * pow) % mod + mod) % mod
        if(used.contains(hash)) l = true
        used.insert(hash)
    }
    
    if(l){
        ok = mid
    }else{
        ng = mid
    }
    
}
print(ok)


Compiler output:
a.cc:16:14: error: too many decimal points in number
   16 |     for i in 0..<mid {
      |              ^~~
a.cc:22:14: error: too many decimal points in number
   22 |     for _ in 0..<mid {
      |              ^~~
a.cc:1:1: error: 'let' does not name a type
    1 | let input_line: Int? = readLine()
      | ^~~
a.cc:39:6: error: expected constructor, destructor, or type conversion before '(' token
   39 | print(ok)
      |      ^
Language: C++

#include <bits\stdc++.h>

#define NMAX 5001

using namespace std;

int dp[NMAX][NMAX];
int n, ans, lim;
char str[NMAX];

int solve(int l1, int l2)
{
    if(l1 > lim) return 0;
    if(l2 >= n) return 0;

    if(dp[l1][l2] != -1)
        return dp[l1][l2];

    if(str[l1] != str[l2])
    {
        dp[l1][l2] = 0;
        return 0;
    }

    int res = 1 + solve(l1 + 1, l2 + 1);
    dp[l1][l2] = res;
    
    return res;
}

int main()
{
    memset(dp, -1, sizeof(dp));

    cin >> n;

    cin.get();
    cin.getline(str, n + 1);

    for(int i = 0; i < n - 1; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            lim = j - 1;
            ans = max(ans, solve(i, j));
        }
    }

    cout << ans << '\n';

    return 0;
}

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

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <chrono>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int dp[5010][5010];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	auto start = chrono::system_clock::now();
	auto split = chrono::system_clock::now();

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	// 3分探索
	int lb = 0, ub = N, ans = 0;
	while (chrono::duration_cast<chrono::milliseconds>(split-start).count() < 1920) {

		int t1 = (2.5 * lb + ub) / 3.5;
		int t2 = ceil((lb + 2.5 * ub) / 3.5);

		int c1 = check(t1);
		int c2 = check(t2);
		if (c1 < c2) lb = t1;
		else ub = t2;

		chmax(ans, max(c1, c2));
		split = chrono::system_clock::now();
	}

	DMP(ub, lb);
	cout << ans << "\n";

	return 0;
}



Compiler output:
a.cc: In lambda function:
a.cc:59:17: error: 'memset' was not declared in this scope
   59 |                 memset(dp, 0, sizeof(dp));
      |                 ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include <chrono>
  +++ |+#include <cstring>
   14 |
Language: C++

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <chrono>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int dp[5010][5010];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	auto start = chrono::system_clock::now();
	auto split = chrono::system_clock::now();

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		memset(dp, 0, 5010 * 5010 * sizeof(int));
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	// 3分探索
	int lb = 0, ub = N, ans = 0;
	while (chrono::duration_cast<chrono::milliseconds>(split-start).count() < 1920) {

		int t1 = (2.5 * lb + ub) / 3.5;
		int t2 = ceil((lb + 2.5 * ub) / 3.5);

		int c1 = check(t1);
		int c2 = check(t2);
		if (c1 < c2) lb = t1;
		else ub = t2;

		chmax(ans, max(c1, c2));
		split = chrono::system_clock::now();
	}

	DMP(ub, lb);
	cout << ans << "\n";

	return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:59:17: error: 'memset' was not declared in this scope
   59 |                 memset(dp, 0, 5010 * 5010 * sizeof(int));
      |                 ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include <chrono>
  +++ |+#include <cstring>
   14 |
Language: C++

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

//グローバルなので初期化されている
int dp[5005][5005];

int main(void){
    int n;
    string s;
    cin >> n >> s;
    //後ろからforループを回す
    for(int i=n-1; i >= 0; --i) {
        for(int j=n-1; j>=0 --j) {
            if(s[i]!=s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1]+1; //範囲外があるけど初期化あるので大丈夫
        }
    }
    int ans=0;
    rep(i,n)rep(j,n){
        if(i>=j) continue; // i < j
        int now=min(dp[i][j], j-i);
        ans=max(ans,now);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:27: error: lvalue required as decrement operand
   15 |         for(int j=n-1; j>=0 --j) {
      |                           ^
a.cc:15:31: error: expected ';' before 'j'
   15 |         for(int j=n-1; j>=0 --j) {
      |                               ^
      |                               ;
Language: C++

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

//グローバルなので初期化されている
int dp[5005][5005];

int main(void){
    int n;
    string s;
    cin >> n >> s;
    //後ろからforループを回す
    for(int i=n-1; i >= 0; --i) {
        for(int j=n-1; j>=0 --j;) {
            if(s[i]!=s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1]+1; //範囲外があるけど初期化あるので大丈夫
        }
    }
    int ans=0;
    rep(i,n)rep(j,n){
        if(i>=j) continue; // i < j
        int now=min(dp[i][j], j-i);
        ans=max(ans,now);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:27: error: lvalue required as decrement operand
   15 |         for(int j=n-1; j>=0 --j;) {
      |                           ^
a.cc:15:31: error: expected ';' before 'j'
   15 |         for(int j=n-1; j>=0 --j;) {
      |                               ^
      |                               ;
a.cc:15:32: error: expected ')' before ';' token
   15 |         for(int j=n-1; j>=0 --j;) {
      |            ~                   ^
      |                                )
a.cc:15:33: error: expected primary-expression before ')' token
   15 |         for(int j=n-1; j>=0 --j;) {
      |                                 ^
Language: C++

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int maxN = 5 * 1e5 + 5;
int dp[maxN][maxN];

signed main() {
  int n = read();
  string s = readString();
  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      if (s[i] == s[j])
        dp[i][j] = dp[i + 1][j + 1] + 1;
    }
  }
  int ans = 0;
  REP(i, n) REP(j, n) {
    if (i >= j)
      continue;
    int now = min(dp[i][j], j - i);
    chmax(ans, now);
  }
  print(ans);
}


Compiler output:
/tmp/ccRL5vBY.o: in function `readString[abi:cxx11]()':
a.cc:(.text+0xa1): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0xd1): relocation truncated to fit: R_X86_64_PC32 against `.bss'
/tmp/ccRL5vBY.o: in function `readCharArray()':
a.cc:(.text+0x11f): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x129): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x15e): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x16c): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
vector<int> Z_algorithm(const string &S) {
    int N = (int)S.size();
    vector<int> lcp(N);
    lcp[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        lcp[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+lcp[k] < j) lcp[i+k] = lcp[k], ++k;
        i += k, j -= k;
    }
    return lcp
}

int main () {
    int N;
    string S;
    cin >> N >> S;
    
    int ans = 0;
    // Z_algorithmを部分文字列に適用してlcp(i, j)を求める
    for (int i = 0; i < N; ++i) {
        stirng T = S.substr(i);
        auto l = Z_algorithm(T);
      
        for (int j = 0; j < N; ++j) {
            int num = min(lcp[j], j);
            ans = max(ans, num);
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'std::vector<int> Z_algorithm(const std::string&)':
a.cc:19:15: error: expected ';' before '}' token
   19 |     return lcp
      |               ^
      |               ;
   20 | }
      | ~              
a.cc: In function 'int main()':
a.cc:30:9: error: 'stirng' was not declared in this scope
   30 |         stirng T = S.substr(i);
      |         ^~~~~~
a.cc:31:30: error: 'T' was not declared in this scope
   31 |         auto l = Z_algorithm(T);
      |                              ^
a.cc:34:27: error: 'lcp' was not declared in this scope
   34 |             int num = min(lcp[j], j);
      |                           ^~~
Language: C++

#define MOD 1000000007 
#define MOD2 998244353
#include <vector>
#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)

int main() {
	ll power[2501];
	power[0] = 1;
	REP(i, 2500) power[i + 1] = (power[i] * 26) % MOD;

	ll power2[2501];
	power2[0] = 1;
	REP(i, 2500) power2[i + 1] = (power2[i] * 26) % MOD2;

	int n;
	cin >> n;
	char s[5001];
	cin >> s;

	vll hash_list;
	ll ha=0;
	hash_list.push_back(0);
	REP(i, n) {
		ha *= 26;
		ha += s[i] - 'a';
		ha %= MOD;
		hash_list.push_back(ha);
	}

	vll hash_list2;
	ll ha2 = 0;
	hash_list2.push_back(0);
	REP(i, n) {
		ha2 *= 26;
		ha2 += s[i] - 'a';
		ha2 %= MOD2;
		hash_list2.push_back(ha2);
	}

	RFOR(j, n/2, 0) {
		map<ll, int> ma;
		REP(i, n - j + 1) {
			ll x = (hash_list[i]*power[j])%MOD;
			x = (hash_list[i + j]+MOD-x)%MOD;
			if (ma.find(x) == ma.end()) ma[x] = i;
			else if (i >= ma[x] + j) {
				ll xx = (hash_list2[i]*power2[j])%MOD2;
				xx = (hash_list2[i + j]+MOD2-xx)%MOD2;
				ll xxx = (hash_list2[ma[x]]*power2[j])%MOD2;
				xxx = (hash_list2[ma[x] + j]+MOD2-xxx)%MOD2;
				if(xx==xxx){
					cout << j;
					return 0;
				}
			}
		}
	}
	cout << "0";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:17: error: 'map' was not declared in this scope
   49 |                 map<ll, int> ma;
      |                 ^~~
a.cc:6:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    5 | #include <unordered_map>
  +++ |+#include <map>
    6 | using namespace std;
a.cc:49:23: error: expected primary-expression before ',' token
   49 |                 map<ll, int> ma;
      |                       ^
a.cc:49:25: error: expected primary-expression before 'int'
   49 |                 map<ll, int> ma;
      |                         ^~~
a.cc:53:29: error: 'ma' was not declared in this scope; did you mean 'ha'?
   53 |                         if (ma.find(x) == ma.end()) ma[x] = i;
      |                             ^~
      |                             ha
Language: C++

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		int dp[5010][5010] = {};
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	// 3分探索
	int lb = 0, ub = N, ans = 0;;
	for (int i = 0; i < 25; i++) {

		int t1 = (2 * lb + ub) / 3;
		int t2 = (lb + 2 * ub) / 3;

		int c1 = check(t1);
		int c2 = check(t2);
		if (c1 < c2) lb = t1;
		else ub = t2;
		DMP(c1, c2, t1, t2);
		if(i==24){
          for(j=t1;j<=t2;j++)
          chmax(ans, check(j));
        }
	}

	DMP(ub, lb);
	cout << ans << "\n";

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:15: error: 'j' was not declared in this scope
   83 |           for(j=t1;j<=t2;j++)
      |               ^
Language: C++

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <chrono>

#include <boost/math/tools/minima.hpp>
using boost::math::tools::brent_find_minima

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	auto start = chrono::system_clock::now();
	auto split = chrono::system_clock::now();

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		int dp[5010][5010] = {};
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	//// 3分探索
	//int lb = 0, ub = N, ans = 0;
	//while (chrono::duration_cast<chrono::milliseconds>(split-start).count() < 1920) {

	//	int t1 = (2 * lb + ub) / 3;
	//	int t2 = ceil((lb + 2 * ub) / 3.0);

	//	int c1 = check(t1);
	//	int c2 = check(t2);
	//	if (c1 < c2) lb = t1;
	//	else ub = t2;

	//	chmax(ans, max(c1, c2));
	//	split = chrono::system_clock::now();
	//}
	
	auto ans = brent_find_minima(check, 0, N, numeric_limits<int>::digits);
	cout << ans.second << endl;

	//DMP(ub, lb);
	//cout << ans << "\n";

	return 0;
}


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

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <chrono>

#include <boost/math/tools/minima.hpp>
using boost::math::tools::brent_find_minima

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	auto start = chrono::system_clock::now();
	auto split = chrono::system_clock::now();

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		int dp[5010][5010] = {};
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	//// 3分探索
	//int lb = 0, ub = N, ans = 0;
	//while (chrono::duration_cast<chrono::milliseconds>(split-start).count() < 1920) {

	//	int t1 = (2 * lb + ub) / 3;
	//	int t2 = ceil((lb + 2 * ub) / 3.0);

	//	int c1 = check(t1);
	//	int c2 = check(t2);
	//	if (c1 < c2) lb = t1;
	//	else ub = t2;

	//	chmax(ans, max(c1, c2));
	//	split = chrono::system_clock::now();
	//}

	auto ans = brent_find_minima(check, 0, N);
	cout << ans.second << endl;

	//DMP(ub, lb);
	//cout << ans << "\n";

	return 0;
}


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

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <chrono>

#include <boost/math/tools/minima.hpp>
using boost::math::tools::brent_find_minima

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	auto start = chrono::system_clock::now();
	auto split = chrono::system_clock::now();

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int cut) {
		int res = 0;
		int dp[5010][5010] = {};
		for (int i = 0; i < cut; i++) {
			for (int j = cut; j < N; j++) {
				if (s[i] == s[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
				chmax(res, dp[i + 1][j + 1]);
			}
		}
		return res;
	};

	//// 3分探索
	//int lb = 0, ub = N, ans = 0;
	//while (chrono::duration_cast<chrono::milliseconds>(split-start).count() < 1920) {

	//	int t1 = (2 * lb + ub) / 3;
	//	int t2 = ceil((lb + 2 * ub) / 3.0);

	//	int c1 = check(t1);
	//	int c2 = check(t2);
	//	if (c1 < c2) lb = t1;
	//	else ub = t2;

	//	chmax(ans, max(c1, c2));
	//	split = chrono::system_clock::now();
	//}

	cout << brent_find_minima(check, 0, N).second << endl;

	//DMP(ub, lb);
	//cout << ans << "\n";

	return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/math/tools/minima.hpp: No such file or directory
   15 | #include <boost/math/tools/minima.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.