Language: C++

#include<iostream>
#include<string.h>

using namespace std;

long long pow[4000],pow1[4000];
long long hash[4000],hash1[4000];

int base=31;
int len;
#define Mod 1000000007
#define Nod 998244353

long long gethash(int l,int r){
//	cout<<hash[r]<<" "<<hash[l]<<" "<<pow[r-l]<<" "<<(hash[r]-hash[l]&pow[r-l]%Mod)%Mod<<endl;
	return (hash[r]-hash[l]*pow[r-l]%Mod)%Mod;
}
long long gethash1(int l,int r){
	return (hash1[r]+Nod-hash1[l]*pow1[r-l]%Nod)%Nod;
}

void solve(int &left,int &right,int &Len){
	for(int i=1;i<=len/2;i++){
		for(int j=0;j+2*i<=len;j++){
			for(int k=j+i;k+i<=len;k++){
	//		 	cout<<i<<" "<<j<<" "<<k<<" "<<endl;
	//		 	cout<<gethash(j,j+i)<<" "<<gethash(k,k+i)<<endl;
				if(gethash(j,j+i)==gethash(k,k+i)&&gethash1(j,j+i)==gethash1(k,k+i)){
					
					left=j;
					right=k;
					Len=i;	
				}	
			}				
		}
	}
	return ;
}


int main()
{
	char s[4000]; 
	pow[0]=1,pow1[0]=1;
	int N;
	cin>>N;
	scanf("%s",s+1);
	len=strlen(s+1);
	int left=0,right=0,Len=0;
	for(int i=1;i<=len;i++){
		pow[i]=(pow[i-1]*base)%Mod;
		pow1[i]=(pow1[i-1]*base)%Nod;
	}
	for(int i=1;i<=len;i++){
		hash[i]=(hash[i-1]*base+s[i]-'a'+1)%Mod;
		hash1[i]=(hash1[i-1]*base+s[i]-'a'+1)%Nod;
	}
//	cout<<gethash(2,3)<<"&&"<<endl;
//	for(int i=0;i<=len;i++) cout<<hash[i]<<" ";
	solve(left,right,Len);
	cout<<Len;
	return 0;
}

Compiler output:
a.cc:6:11: warning: built-in function 'pow' declared as non-function [-Wbuiltin-declaration-mismatch]
    6 | long long pow[4000],pow1[4000];
      |           ^~~
a.cc: In function 'long long int gethash(int, int)':
a.cc:16:17: error: reference to 'hash' is ambiguous
   16 |         return (hash[r]-hash[l]*pow[r-l]%Mod)%Mod;
      |                 ^~~~
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: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:7:11: note:                 'long long int hash [4000]'
    7 | long long hash[4000],hash1[4000];
      |           ^~~~
a.cc:16:25: error: reference to 'hash' is ambiguous
   16 |         return (hash[r]-hash[l]*pow[r-l]%Mod)%Mod;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:11: note:                 'long long int hash [4000]'
    7 | long long hash[4000],hash1[4000];
      |           ^~~~
a.cc: In function 'int main()':
a.cc:55:17: error: reference to 'hash' is ambiguous
   55 |                 hash[i]=(hash[i-1]*base+s[i]-'a'+1)%Mod;
      |                 ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:11: note:                 'long long int hash [4000]'
    7 | long long hash[4000],hash1[4000];
      |           ^~~~
a.cc:55:26: error: reference to 'hash' is ambiguous
   55 |                 hash[i]=(hash[i-1]*base+s[i]-'a'+1)%Mod;
      |                          ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:11: note:                 'long long int hash [4000]'
    7 | long long hash[4000],hash1[4000];
      |           ^~~~