Language: C++

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline
    #define re register
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
#define N 5005
#define base 233
#define ull unsigned long long
int n;
char s[N];
ull power[N],hash[N];
ull cal(int l,int r){
	ull x=hash[r]-hash[l-1]*power[r-l+1];
	return x;
}
int main(){
	read(n);
	scanf("%s",s+1);
	power[0]=1;
	for(re int i=1;i<=n;i++) power[i]=power[i-1]*base;
	for(re int i=1;i<=n;i++) hash[i]=hash[i-1]*base+s[i];
	int len=1;
	bool flag=0;
	for(re int i=1;i+len-1<=n;i++){
		for(re int j=i+len;j+len-1<=n;j++){
			while(i+len-1<=n&&j>i+len-1&&j+len-1<=n&&cal(i,i+len-1)==cal(j,j+len-1)) flag=1,len++;
		}
	}
	if(!flag) len=0;
	printf("%d",len-1);
	return 0;
}

Compiler output:
a.cc: In function 'long long unsigned int cal(int, int)':
a.cc:35:15: error: reference to 'hash' is ambiguous
   35 |         ull x=hash[r]-hash[l-1]*power[r-l+1];
      |               ^~~~
In file included from /usr/include/c++/14/bits/stl_bvector.h:65,
                 from /usr/include/c++/14/vector:67,
                 from /usr/include/c++/14/queue:63,
                 from a.cc:4:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:33:14: note:                 'long long unsigned int hash [5005]'
   33 | ull power[N],hash[N];
      |              ^~~~
a.cc:35:23: error: reference to 'hash' is ambiguous
   35 |         ull x=hash[r]-hash[l-1]*power[r-l+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:33:14: note:                 'long long unsigned int hash [5005]'
   33 | ull power[N],hash[N];
      |              ^~~~
a.cc: In function 'int main()':
a.cc:42:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   42 |         for(re int i=1;i<=n;i++) power[i]=power[i-1]*base;
      |                    ^
a.cc:43:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         for(re int i=1;i<=n;i++) hash[i]=hash[i-1]*base+s[i];
      |                    ^
a.cc:43:34: error: reference to 'hash' is ambiguous
   43 |         for(re int i=1;i<=n;i++) hash[i]=hash[i-1]*base+s[i];
      |                                  ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:33:14: note:                 'long long unsigned int hash [5005]'
   33 | ull power[N],hash[N];
      |              ^~~~
a.cc:43:42: error: reference to 'hash' is ambiguous
   43 |         for(re int i=1;i<=n;i++) hash[i]=hash[i-1]*base+s[i];
      |                                          ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:33:14: note:                 'long long unsigned int hash [5005]'
   33 | ull power[N],hash[N];
      |              ^~~~
a.cc:46:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   46 |         for(re int i=1;i+len-1<=n;i++){
      |                    ^
a.cc:47:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   47 |                 for(re int j=i+len;j+len-1<=n;j++){
      |                            ^