Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN = 5e5 + 10;
char s[MAXN];
int next[MAXN] , l;
bool f[MAXN] , e[MAXN];
int main(){
	memset(f , 0 , sizeof f);
	cin >> s + 1;
	l = strlen(s + 1);
	bool same = 1;
	for(int i = 2 ; i <= l ; ++ i)
		if(s[i] != s[1]){
			same = 0;
			break;
		}
	if(same){
		cout << l << endl << 1 << endl;
		return 0;
	}
	next[1] = 0;
	for(int i = 2 ; i <= l ; ++ i){
		int tmp = next[i - 1];
		while(tmp && s[tmp + 1] != s[i])
			tmp = next[tmp];
		if(s[tmp + 1] == s[i])
			tmp ++;
		next[i] = tmp;
		int ll = i - next[i];
		if(next[i] && i % ll == 0)
			f[i] = 1;
	}
	next[l] = 0;
	for(int i = l - 1 ; i >= 1 ; -- i){
		int tmp = next[i + 1];
		while(tmp && s[l - tmp] != s[i])
			tmp = next[l - tmp + 1];
		if(s[l - tmp] == s[i])
			tmp ++;
		next[i] = tmp;
		int ll = l - i + 1 - next[i];
		if(next[i] && (l - i + 1) % ll == 0)
			e[i] = 1;
	}
	if(!f[l]){
		cout << 1 << endl << 1 << endl;
		return 0;
	}
	int ans = 0;
	for(int i = 1 ; i < l ; ++ i)
		if(!f[i] && !e[i + 1])
			ans ++;
	cout << 2 << endl << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: reference to 'next' is ambiguous
   25 |         next[1] = 0;
      |         ^~~~
In file included from /usr/include/c++/14/string:47,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:27:27: error: reference to 'next' is ambiguous
   27 |                 int tmp = next[i - 1];
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:29:31: error: reference to 'next' is ambiguous
   29 |                         tmp = next[tmp];
      |                               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:32:17: error: reference to 'next' is ambiguous
   32 |                 next[i] = tmp;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:33:30: error: reference to 'next' is ambiguous
   33 |                 int ll = i - next[i];
      |                              ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:34:20: error: reference to 'next' is ambiguous
   34 |                 if(next[i] && i % ll == 0)
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:37:9: error: reference to 'next' is ambiguous
   37 |         next[l] = 0;
      |         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:39:27: error: reference to 'next' is ambiguous
   39 |                 int tmp = next[i + 1];
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:41:31: error: reference to 'next' is ambiguous
   41 |                         tmp = next[l - tmp + 1];
      |                               ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:44:17: error: reference to 'next' is ambiguous
   44 |                 next[i] = tmp;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:45:38: error: reference to 'next' is ambiguous
   45 |                 int ll = l - i + 1 - next[i];
      |                                      ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~
a.cc:46:20: error: reference to 'next' is ambiguous
   46 |                 if(next[i] && (l - i + 1) % ll == 0)
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:9:5: note:                 'int next [500010]'
    9 | int next[MAXN] , l;
      |     ^~~~