Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;
string s;
int ans;
string s1, s2;

signed main() {
	cin >> n >> s;
	s2 = s;
	for (int i = 0; i < n - 1; i++) {
		s1 += s[i];
		s2 = s2.substr(1);
		int maxcase_len = 0;
		for (int off = -(int)s1.size(); off <= (int)s2.size(); off++) {
			int len = 0;
			for (int i = max(off, (int)0); i <= min(s1.size() + off, (int)s2.size()); i++) {
				if (len > maxcase_len) {
					maxcase_len = len;
				}
				if (s1[i - off] != s2[i]) {
					len = 0;
				}
				else {
					len++;
				}
			}
		}
		ans = max(ans, maxcase_len);
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:64: error: no matching function for call to 'min(long long unsigned int, long long int)'
   69 |                         for (int i = max(off, (int)0); i <= min(s1.size() + off, (int)s2.size()); i++) {
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:69:64: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   69 |                         for (int i = max(off, (int)0); i <= min(s1.size() + off, (int)s2.size()); i++) {
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:69:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   69 |                         for (int i = max(off, (int)0); i <= min(s1.size() + off, (int)s2.size()); i++) {
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~