Language: C++

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef long long LL;
const ll M=1000000007;
int n,m,i,j,d[505],len,l,r,lt,ls;
ll hash[2000005],h[2000005],m26[2000005];
char s[2000005],t[2000005];
bool check(int m)
{
	int j;
	for(j=m;j<=ls;j++)
		if(((h[j]-h[j-m]*m26[m])%M+M)%M==hash[m])
			return true;
	return false;
}
int main(){
	scanf("%s",s+1);
	len=strlen(s+1);
	ls=2000000/len*len;
	for(i=len+1;i<=2000000/len*len;i++)
		s[i]=s[i-len];
	scanf("%s",t+1);
	lt=strlen(t+1);
	for(j=lt+1;j<=2000000/lt*lt;j++)
		t[j]=t[j-lt];
	for(j=1;j<=ls;j++)
		if(j!=0)
		{
			hash[j]=(hash[j-1]*26+t[j]-'a')%M;
			h[j]=(h[j-1]*26+s[j]-'a')%M;
		}
		else
		{
			hash[j]=t[j]-'a';
			h[j]=s[j]-'a';
		}
	m26[0]=1;
	for(i=1;i<=2000000;i++)
		m26[i]=m26[i-1]*26%M;
	l=1;
	r=2000000/lt;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(check(mid*lt))
			l=mid+1;
		else
			r=mid;
	}
	if((l-1)*lt>=1000000)
		printf("-1");
	else
		printf("%d\n",l-1);
}


Compiler output:
a.cc: In function 'bool check(int)':
a.cc:17:50: error: reference to 'hash' is ambiguous
   17 |                 if(((h[j]-h[j-m]*m26[m])%M+M)%M==hash[m])
      |                                                  ^~~~
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:11:4: note:                 'll hash [2000005]'
   11 | ll hash[2000005],h[2000005],m26[2000005];
      |    ^~~~
a.cc: In function 'int main()':
a.cc:34:25: error: reference to 'hash' is ambiguous
   34 |                         hash[j]=(hash[j-1]*26+t[j]-'a')%M;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:11:4: note:                 'll hash [2000005]'
   11 | ll hash[2000005],h[2000005],m26[2000005];
      |    ^~~~
a.cc:34:34: error: reference to 'hash' is ambiguous
   34 |                         hash[j]=(hash[j-1]*26+t[j]-'a')%M;
      |                                  ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:11:4: note:                 'll hash [2000005]'
   11 | ll hash[2000005],h[2000005],m26[2000005];
      |    ^~~~
a.cc:39:25: error: reference to 'hash' is ambiguous
   39 |                         hash[j]=t[j]-'a';
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:11:4: note:                 'll hash [2000005]'
   11 | ll hash[2000005],h[2000005],m26[2000005];
      |    ^~~~