Language: C++

#include<bits/stdc++.h>
#define N 500005
#define mod 1000000007
#define base 37
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
char s[N];
int n,a[N];
unsigned int mul[N],hash[N];
inline bool check(int len,int dis){
	int l=1,r=len;
	if(dis==len)return false;
	for(;l<=dis&&r<=dis;l+=len,r+=len)if(hash[r]-hash[l-1]!=hash[len]*mul[l-1])return false;
	return true;
}
inline int calc(int len){
	int ret=n/len*(len-1);
	if(n&1)return ret;
	if(check(len,n/2))return ret;
	return ret+1;
}
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	for(int i=1;i<=n;++i)a[i]=s[i]-'a';
	bool f=true;
	for(int i=2;i<=n;++i)if(a[i]!=a[i-1]){f=false;break;}
	if(f){printf("%d\n1",n);return 0;}
	mul[0]=1;
	for(int i=1;i<=n;++i)mul[i]=mul[i-1]*base;
	for(int i=1;i<=n;++i)hash[i]=hash[i-1]*base+a[i];
	for(int len=2;len<n;++len){
		if(n%len)continue;
		if(check(len,n)){printf("2\n%d",calc(len));return 0;}
	}
	printf("1\n1");
	return 0;
}

Compiler output:
a.cc: In function 'bool check(int, int)':
a.cc:19:46: error: reference to 'hash' is ambiguous
   19 |         for(;l<=dis&&r<=dis;l+=len,r+=len)if(hash[r]-hash[l-1]!=hash[len]*mul[l-1])return false;
      |                                              ^~~~
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/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 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:15:21: note:                 'unsigned int hash [500005]'
   15 | unsigned int mul[N],hash[N];
      |                     ^~~~
a.cc:19:54: error: reference to 'hash' is ambiguous
   19 |         for(;l<=dis&&r<=dis;l+=len,r+=len)if(hash[r]-hash[l-1]!=hash[len]*mul[l-1])return false;
      |                                                      ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:15:21: note:                 'unsigned int hash [500005]'
   15 | unsigned int mul[N],hash[N];
      |                     ^~~~
a.cc:19:65: error: reference to 'hash' is ambiguous
   19 |         for(;l<=dis&&r<=dis;l+=len,r+=len)if(hash[r]-hash[l-1]!=hash[len]*mul[l-1])return false;
      |                                                                 ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:15:21: note:                 'unsigned int hash [500005]'
   15 | unsigned int mul[N],hash[N];
      |                     ^~~~
a.cc: In function 'int main()':
a.cc:36:30: error: reference to 'hash' is ambiguous
   36 |         for(int i=1;i<=n;++i)hash[i]=hash[i-1]*base+a[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:15:21: note:                 'unsigned int hash [500005]'
   15 | unsigned int mul[N],hash[N];
      |                     ^~~~
a.cc:36:38: error: reference to 'hash' is ambiguous
   36 |         for(int i=1;i<=n;++i)hash[i]=hash[i-1]*base+a[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:15:21: note:                 'unsigned int hash [500005]'
   15 | unsigned int mul[N],hash[N];
      |                     ^~~~