stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#define lowbit(i) ((i)&(-(i)))

#define lson(i) ((i)<<1)

#define rson(i) ((i)<<1|1)

#define sqr(x) ((x)*(x))

#define fi first

#define se second

#define mp(x,y) make_pair((x),(y))

#define pb push_back

using namespace std;



typedef long long ll;

typedef unsigned long long ul;

typedef pair<int,int> pii;

typedef vector<int> vii;

typedef vector<pii> vpi;

typedef queue<int> qii;



const int inf=0x3f3f3f3f;

const int maxn=2e6+5;

const long long MOD=1e9+7;



char s[maxn],t[maxn];

int fail[maxn],refail[maxn];



void getfail(int *fail,char *s){

	fail[0]=-1;

	int i=0,j=-1;

	while(s[i]){

		if(j==-1 || s[i]==s[j]){

			fail[i+1]=j+1;

			i++;

			j++;

		}

		else{

			j=fail[j];

		}

	}

}



int main(){

	scanf("%s",&s);

	ll ans=0;

	int len=strlen(s);

	for(int i=0;s[i];i++){

		t[i]=s[len-i-1];

	}

	t[len]='\0';

	getfail(fail,s);

	getfail(refail,t);

	int m;

	if(fail[len]==0 || len%(len-fail[len])){

		m=1;

	}

	else{

		m=2;

	}

	bool flag=1;

	for(int i=1;s[i];i++){

		if(s[i]!=s[i-1]){

			flag=0;

		}

	}

	if(flag){

		m=len;

	}

	if(m==1 || flag){

		ans=1;

	}

	else{

		for(int i=0;i<len-1;i++){

			int k=len-i-1;

			if((fail[i+1]==0 || (i+1)%(i+1-fail[i+1])) && (refail[k]==0 || k%(k-refail[k]))){

				ans++;

				ans%=MOD;

			}

		}

	}

	cout<<m<<endl<<ans%MOD<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.226774398378968x):
#include <cmath>

#include <cstdio>

#include <cstring>

#include <algorithm>

using std::min; using std::max;

using std::swap; using std::sort;

typedef long long ll;



template<typename T>

void read(T &x) {

	int flag = 1; x = 0; char ch = getchar();

	while(ch < '0' || ch > '9') { if(ch == '-') flag = -flag; ch = getchar(); }

	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();

	x *= flag;

}



const int _ = 5e5 + 10, P = 1e9 + 7;

int n, p[_], s[_]; char c[_];



int chk0(int r) {

	int len = r, now = len % (len - p[r]);

	if(!now) return len / (len - p[r]) == 1;

	return 1;

}



int chk1(int l) {

	int len = n - l + 1, now = len % (len - s[l]);

	if(!now) return len / (len - s[l]) == 1;

	return 1;

}



int main () {

	scanf("%s", c + 1), n = strlen(c + 1);

	for(int i = 2; i <= n; ++i) {

		int j = p[i - 1];

		while(j && c[j + 1] != c[i]) j = p[j];

		j += c[j + 1] == c[i], p[i] = j;

	}

	std::reverse(c + 1, c + n + 1);

	for(int i = 2; i <= n; ++i) {

		int j = s[i - 1];

		while(j && c[j + 1] != c[i]) j = s[j];

		j += c[j + 1] == c[i], s[i] = j;

	}

	std::reverse(s + 1, s + n + 1);

	std::reverse(c + 1, c + n + 1);

	int now = n - p[n];

	if(now == 1) return printf("%d\n%d\n", n, 1), 0;

	if(n % now == 0 && n / now > 1) {

		printf("%d\n", 2);

		int ret = 0;

		for(int i = 1; i < n; ++i)

			if(chk0(i) && chk1(i + 1)) ++ret;

		printf("%d\n", ret);

	} else printf("%d\n%d\n", 1, 1);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int maxn = 550000;

const int unit = 29;

const int mod = 1e9 + 7;



char w[maxn];

long long state[maxn];

long long pw[maxn];

bool f[maxn], g[maxn];



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	cin >> w;

	int n = strlen(w);

	pw[0] = 1;

	for(int i = 1; i < maxn; ++ i) pw[i] = pw[i - 1] * unit % mod;

	for(int i = 0; i < n; ++ i) {

		state[i] = ((i == 0 ? 0 : state[i - 1]) + (w[i] - 'a' + 1) * pw[i]) % mod;

	}

	for(int i = 1; i <= n; ++ i) f[i] = true;

	int len = n;

	for(int i = 1; i < n; ++ i) {

		long long cs = state[i - 1];

		for(int j = i + i; j <= n; j += i) {

			long long ns = (state[j - 1] - state[j - i - 1] + mod) % mod;

			cs = (cs * pw[i]) % mod;

			if(ns == cs) f[j] = false;

			else break;

		}

		if(n % i == 0) {

			long long ns = (state[n - i - 1] * pw[i]) % mod;

			long long cs = (state[n - 1] - state[i - 1] + mod) % mod;

			if(ns == cs) {

				if(len > i) len = i;

			}

		}

	}

	reverse(w, w + n);

	for(int i = 0; i < n; ++ i) {

		state[i] = ((i == 0 ? 0 : state[i - 1]) + (w[i] - 'a' + 1) * pw[i]) % mod;

	}

	for(int i = 1; i <= n; ++ i) g[i] = true;

	for(int i = 1; i < n; ++ i) {

		long long cs = state[i - 1];

		for(int j = i + i; j <= n; j += i) {

			long long ns = (state[j - 1] - state[j - i - 1] + mod) % mod;

			cs = (pw[i] * cs) % mod;

			if(ns == cs) g[j] = false;

			else break;

		}

	}

	if(len == 1) {

		cout << n << "\n" << 1 << "\n";

		return 0;

	}

	if(len == n) {

		cout << 1 << "\n" << 1 << "\n";

		return 0;

	}

	cout << 2 << "\n";

	int pos = 0;

	for(int i = 1; i < n; ++ i) {

		if(f[i] && g[n - i]) ++ pos;

	}

	cout << pos << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.6177478605325435x):
#include <bits/stdc++.h>

#define maxn 500086



using namespace std;



const int p = 1e9 + 7;



inline void getNext(char *s, int *nxt){

	int n = strlen(s);

	for(int i = 1;i < n;i++){

		int j = nxt[i - 1];

		while(j && s[j] != s[i]) j = nxt[j - 1];

		if(s[j] == s[i]) j++;

		nxt[i] = j;

	} 

}



int n;

char s[2][maxn];

int nxt[2][maxn];

int ans;



int main(){

	scanf("%s", s[0]);

	int n = strlen(s[0]);

	strcpy(s[1], s[0]);

	reverse(s[1], s[1] + n);

	getNext(s[0], nxt[0]), getNext(s[1], nxt[1]);

	if(!nxt[0][n - 1] || n % (n - nxt[0][n - 1])) return printf("1\n1"), 0;

	if(n - nxt[0][n - 1] == 1) return printf("%d\n1", n), 0;

	for(int i = 0;i < n - 1;i++){

		if((!nxt[0][i] || (i + 1) % (i + 1 - nxt[0][i])) && (!nxt[1][n - i - 2] || (n - i - 1) % (n - i - 1 - nxt[1][n - i - 2]))) ans++;

	}

	printf("2\n%d", ans);

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define int long long



const int mod = 1e9 +7, MAX = 5e5 + 5;

int has1[MAX], has2[MAX], n, pow27[MAX];

bool pre[MAX], suf[MAX], same = 1;

string s;



int gethas1(int i, int j) {

    return (has1[j] - (has1[i - 1] * pow27[j - i + 1]) % mod + mod) % mod;

}



int gethas2(int i, int j) {

    return (has2[i] - (has2[j + 1] * pow27[j - i + 1]) % mod + mod) % mod;

}



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> s;

    n = s.size(); s = '*' + s;

    pow27[0] = 1; for (int i = 1; i < MAX; ++i) pow27[i] = (pow27[i - 1] * 27) % mod;

    for (int i = 1; i <= n; ++i) {

        if(s[i] != s[1]) same = 0;

    }

    if(same) {

        cout << n << '\n' << 1;

        return 0;

    }

    for (int i = 1; i <= n; ++i) has1[i] = (has1[i - 1] * 27 + s[i] - 'a' + 1) % mod;

    for (int i = n; i > 0; --i) has2[i] = (has2[i + 1] * 27 + s[i] - 'a' + 1) % mod;

    for (int i = 1; i <= n; ++i) {

        for (int j = i + 1; j + i - 1 <= n; j += i) {

            if(has1[i] != gethas1(j, j + i - 1) ) break;

            pre[j + i - 1] = 1;

        }

    }



    for (int i = n; i > 0; --i) {

        for (int j = n - i; j - i + 1 > 0; j -= i) {

            if(gethas2(n - i + 1, n) != gethas2(j - i + 1, j) ) break;

            suf[j - i + 1] = 1;

        }

    }



    if(!pre[n]) cout << "1\n1";

    else {

        cout << 2 << '\n';

        int cnt = 0;

        for (int i = 1; i < n; ++i) if(!pre[i] && !suf[i + 1]) cnt ++;

        cout << cnt;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.095542274466379x):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<string>

#include<iostream>

using namespace std;



typedef long long ll;

const ll MOD=1e9+7;

const ll base=1123;

const int MAXN=5e5+5;



string s;

int n;

ll pow[MAXN],Hash[MAXN];

bool l[MAXN],r[MAXN];



void Init(){

    s=' '+s;

    pow[0]=1;

    for(int i=1;i<=n;i++) pow[i]=(1ll*pow[i-1]*base)%MOD;

    for(int i=1;i<=n;i++) Hash[i]=(1ll*Hash[i-1]*base+s[i]-'a')%MOD;

}



ll get(int l,int r){

    return ((1ll*Hash[r]-1ll*Hash[l-1]*pow[r-l+1])%MOD+MOD)%MOD;

}



int main(){

    cin >> s;

    n=s.length();

    bool same=1;

    for(int i=1;i<s.length();i++) if(s[i]!=s[i-1]){same=0;break;}

    if(same) return printf("%d\n1",s.length()),0;

    Init();

    for(int i=1;i<=n;i++)

        for(int j=i*2;j<=n;j+=i){

            if(get(1,i)==get(j-i+1,j)) l[j]=1;

            else break;

        }

    for(int i=1;i<=n;i++)

        for(int j=n-i*2+1;j>=1;j-=i){

            if(get(j,j+i-1)==get(n-i+1,n)) r[j]=1;

            else break;

        }

    if(!l[n]) return printf("1\n1"),0;

    int ans=0;

    for(int i=1;i<n;i++) if(!l[i]&&!r[i+1]) ans++;

    printf("2\n%d",ans);

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define int long long

#define For(i, a, b) for(int i = a; i <= b; ++ i)

const int N = 5e5 + 5, mod = 1e9 + 7;



int l, q;

string s;

int _hash[N], Hash[N], Pow[N];

bool pre[N], suf[N];



int get_hash(int l, int r){

	return (_hash[r] - _hash[l - 1] * Pow[r - l + 1] + mod * mod ) % mod;

}

int get_hash2(int l, int r){

	return (Hash[l] - Hash[r + 1] * Pow[r - l + 1] + mod * mod ) % mod;

}

signed main(){

	ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

	cin >> s;

	int len = s.length();

	s = "." + s;

	int ok = 0;

	For(i, 1, len) if(s[i] != s[1]){ ok = 1; break; }

	if(!ok){ cout << len << "\n" << 1; return 0; }

	Pow[0] = 1;

	For(i, 1, N - 1) Pow[i] = Pow[ i - 1] * 27 % mod;

	

	For(i, 1, len) _hash[i] = (_hash[i - 1] * 27 + s[i] - 'a' + 1) % mod;

	for(int i = len; i > 0; -- i) Hash[i] = (Hash[i + 1] * 27 + s[i] - 'a' + 1) % mod;

	

	For(i, 1, len){

		for(int j = i + 1; j + i - 1 <= len; j += i){

			if(_hash[i] != get_hash(j, j + i - 1)) break;

			pre[j + i - 1] = true;

		}

	}

	for(int i = len ; i > 0; -- i){

		int val = get_hash2(len - i + 1, len);

		for(int j = len - i; j - i + 1 > 0; j -= i){

			if(val != get_hash2(j - i + 1, j)) break;

			suf[j - i + 1] = true;

		}

	}

	if(!pre[len]){ cout << 1 << "\n" << 1; return 0; }

	int dem = 0;

	For(i, 1, len - 1) if(!pre[i] && !suf[i + 1]) dem ++;

	cout << 2 << "\n" << dem;

}

// Faster C++ solution for the same problem (measured speedup: 4.981193467888208x):
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<string>

#include<iostream>

using namespace std;



typedef long long ll;

const ll MOD=1e9+7;

const ll base=1123;

const int MAXN=5e5+5;



string s;

int n;

ll pow[MAXN],Hash[MAXN];

bool l[MAXN],r[MAXN];



void Init(){

    s=' '+s;

    pow[0]=1;

    for(int i=1;i<=n;i++) pow[i]=(1ll*pow[i-1]*base)%MOD;

    for(int i=1;i<=n;i++) Hash[i]=(1ll*Hash[i-1]*base+s[i]-'a')%MOD;

}



ll get(int l,int r){

    return ((1ll*Hash[r]-1ll*Hash[l-1]*pow[r-l+1])%MOD+MOD)%MOD;

}



int main(){

    cin >> s;

    n=s.length();

    bool same=1;

    for(int i=1;i<s.length();i++) if(s[i]!=s[i-1]){same=0;break;}

    if(same) return printf("%d\n1",s.length()),0;

    Init();

    for(int i=1;i<=n;i++)

        for(int j=i*2;j<=n;j+=i){

            if(get(1,i)==get(j-i+1,j)) l[j]=1;

            else break;

        }

    for(int i=1;i<=n;i++)

        for(int j=n-i*2+1;j>=1;j-=i){

            if(get(j,j+i-1)==get(n-i+1,n)) r[j]=1;

            else break;

        }

    if(!l[n]) return printf("1\n1"),0;

    int ans=0;

    for(int i=1;i<n;i++) if(!l[i]&&!r[i+1]) ans++;

    printf("2\n%d",ans);

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define int long long



const int mod = 1e9 +7, MAX = 5e5 + 5;

int has1[MAX], has2[MAX], n, pow27[MAX];

bool pre[MAX], suf[MAX], same = 1;

string s;



int gethas1(int i, int j) {

    return (has1[j] - (has1[i - 1] * pow27[j - i + 1]) % mod + mod) % mod;

}



int gethas2(int i, int j) {

    return (has2[i] - (has2[j + 1] * pow27[j - i + 1]) % mod + mod) % mod;

}



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> s;

    n = s.size(); s = '*' + s;

    pow27[0] = 1; for (int i = 1; i < MAX; ++i) pow27[i] = (pow27[i - 1] * 27) % mod;

    for (int i = 1; i <= n; ++i) {

        if(s[i] != s[1]) same = 0;

    }

    if(same) {

        cout << n << '\n' << 1;

        return 0;

    }

    for (int i = 1; i <= n; ++i) has1[i] = (has1[i - 1] * 27 + s[i] - 'a' + 1) % mod;

    for (int i = n; i > 0; --i) has2[i] = (has2[i + 1] * 27 + s[i] - 'a' + 1) % mod;

    for (int i = 1; i <= n; ++i) {

        for (int j = i + 1; j + i - 1 <= n; j += i) {

            if(has1[i] != gethas1(j, j + i - 1) ) break;

            pre[j + i - 1] = 1;

        }

    }



    for (int i = n; i > 0; --i) {

        for (int j = n - i; j - i + 1 > 0; j -= i) {

            if(gethas2(n - i + 1, n) != gethas2(j - i + 1, j) ) break;

            suf[j - i + 1] = 1;

        }

    }



    if(!pre[n]) cout << "1\n1";

    else {

        cout << 2 << '\n';

        int cnt = 0;

        for (int i = 1; i < n; ++i) if(!pre[i] && !suf[i + 1]) cnt ++;

        cout << cnt;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.187567004831139x):
#include <iostream> 

#include <cstdio> 

#include <cstdlib> 

#include <cstring> 

#include <cmath> 

#include <algorithm> 

using namespace std; 



const int MAX_N = 5e5 + 5; 

char a[MAX_N]; 

int N, pre[MAX_N], nxt[MAX_N]; 

bool check(int pos) { 

	bool f1 = (!pre[pos]) || (pos % (pos - pre[pos])); 

	bool f2 = (nxt[pos + 1] == N + 1) || (N - pos) % (N - pos - (N - nxt[pos + 1] + 1)); 

	if (f1 && f2) return 1; 

	else return 0; 

} 

int main () { 

	scanf("%s", a + 1); 

	N = strlen(a + 1);

	pre[1] = 0; 

	for (int i = 2, j = 0; i <= N; i++) { 

		while (j && a[j + 1] != a[i]) j = pre[j]; 

		if (a[j + 1] == a[i]) ++j; 

		pre[i] = j; 

	} 

	nxt[N] = N + 1; 

	for (int i = N - 1, j = N + 1; i; i--) { 

		while (j <= N && a[j - 1] != a[i]) j = nxt[j]; 

		if (a[j - 1] == a[i]) --j; 

		nxt[i] = j; 

	} 

	if (!pre[N] || N % (N - pre[N])) return puts("1\n1") & 0; 

	if (pre[N] == N - 1) return printf("%d\n1\n", N) & 0; 

	int ans = 0; 

	for (int i = 1; i < N; i++) ans += check(i); 

	printf("2\n%d\n", ans); 

    return 0; 

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define int long long

#define For(i, a, b) for(int i = a; i <= b; ++ i)

const int N = 5e5 + 5, mod = 1e9 + 7;



int l, q;

string s;

int _hash[N], Hash[N], Pow[N];

bool pre[N], suf[N];



int get_hash(int l, int r){

	return (_hash[r] - _hash[l - 1] * Pow[r - l + 1] + mod * mod ) % mod;

}

int get_hash2(int l, int r){

	return (Hash[l] - Hash[r + 1] * Pow[r - l + 1] + mod * mod ) % mod;

}

signed main(){

	ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

	cin >> s;

	int len = s.length();

	s = "." + s;

	int ok = 0;

	For(i, 1, len) if(s[i] != s[1]){ ok = 1; break; }

	if(!ok){ cout << len << "\n" << 1; return 0; }

	Pow[0] = 1;

	For(i, 1, N - 1) Pow[i] = Pow[ i - 1] * 27 % mod;

	

	For(i, 1, len) _hash[i] = (_hash[i - 1] * 27 + s[i] - 'a' + 1) % mod;

	for(int i = len; i > 0; -- i) Hash[i] = (Hash[i + 1] * 27 + s[i] - 'a' + 1) % mod;

	

	For(i, 1, len){

		for(int j = i + 1; j + i - 1 <= len; j += i){

			if(_hash[i] != get_hash(j, j + i - 1)) break;

			pre[j + i - 1] = true;

		}

	}

	for(int i = len ; i > 0; -- i){

		int val = get_hash2(len - i + 1, len);

		for(int j = len - i; j - i + 1 > 0; j -= i){

			if(val != get_hash2(j - i + 1, j)) break;

			suf[j - i + 1] = true;

		}

	}

	if(!pre[len]){ cout << 1 << "\n" << 1; return 0; }

	int dem = 0;

	For(i, 1, len - 1) if(!pre[i] && !suf[i + 1]) dem ++;

	cout << 2 << "\n" << dem;

}

// Faster C++ solution for the same problem (measured speedup: 5.071153075931125x):
#include <iostream> 

#include <cstdio> 

#include <cstdlib> 

#include <cstring> 

#include <cmath> 

#include <algorithm> 

using namespace std; 



const int MAX_N = 5e5 + 5; 

char a[MAX_N]; 

int N, pre[MAX_N], nxt[MAX_N]; 

bool check(int pos) { 

	bool f1 = (!pre[pos]) || (pos % (pos - pre[pos])); 

	bool f2 = (nxt[pos + 1] == N + 1) || (N - pos) % (N - pos - (N - nxt[pos + 1] + 1)); 

	if (f1 && f2) return 1; 

	else return 0; 

} 

int main () { 

	scanf("%s", a + 1); 

	N = strlen(a + 1);

	pre[1] = 0; 

	for (int i = 2, j = 0; i <= N; i++) { 

		while (j && a[j + 1] != a[i]) j = pre[j]; 

		if (a[j + 1] == a[i]) ++j; 

		pre[i] = j; 

	} 

	nxt[N] = N + 1; 

	for (int i = N - 1, j = N + 1; i; i--) { 

		while (j <= N && a[j - 1] != a[i]) j = nxt[j]; 

		if (a[j - 1] == a[i]) --j; 

		nxt[i] = j; 

	} 

	if (!pre[N] || N % (N - pre[N])) return puts("1\n1") & 0; 

	if (pre[N] == N - 1) return printf("%d\n1\n", N) & 0; 

	int ans = 0; 

	for (int i = 1; i < N; i++) ans += check(i); 

	printf("2\n%d\n", ans); 

    return 0; 

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define int long long



const int mod = 1e9 +7, MAX = 5e5 + 5;

int has1[MAX], has2[MAX], n, pow27[MAX];

bool pre[MAX], suf[MAX], same = 1;

string s;



int gethas1(int i, int j) {

    return (has1[j] - (has1[i - 1] * pow27[j - i + 1]) % mod + mod) % mod;

}



int gethas2(int i, int j) {

    return (has2[i] - (has2[j + 1] * pow27[j - i + 1]) % mod + mod) % mod;

}



signed main () {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> s;

    n = s.size(); s = '*' + s;

    pow27[0] = 1; for (int i = 1; i < MAX; ++i) pow27[i] = (pow27[i - 1] * 27) % mod;

    for (int i = 1; i <= n; ++i) {

        if(s[i] != s[1]) same = 0;

    }

    if(same) {

        cout << n << '\n' << 1;

        return 0;

    }

    for (int i = 1; i <= n; ++i) has1[i] = (has1[i - 1] * 27 + s[i] - 'a' + 1) % mod;

    for (int i = n; i > 0; --i) has2[i] = (has2[i + 1] * 27 + s[i] - 'a' + 1) % mod;

    for (int i = 1; i <= n; ++i) {

        for (int j = i + 1; j + i - 1 <= n; j += i) {

            if(has1[i] != gethas1(j, j + i - 1) ) break;

            pre[j + i - 1] = 1;

        }

    }



    for (int i = n; i > 0; --i) {

        for (int j = n - i; j - i + 1 > 0; j -= i) {

            if(gethas2(n - i + 1, n) != gethas2(j - i + 1, j) ) break;

            suf[j - i + 1] = 1;

        }

    }



    if(!pre[n]) cout << "1\n1";

    else {

        cout << 2 << '\n';

        int cnt = 0;

        for (int i = 1; i < n; ++i) if(!pre[i] && !suf[i + 1]) cnt ++;

        cout << cnt;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.184583404634551x):
#include <bits/stdc++.h>

using namespace std;

#define N 500005

char s[N];

int n, Pi1[N], Pi2[N];

void kmp(int* Pi) {

    int j = Pi[0] = -1;

    for (int i = 0; i < n; i++) {

        while (~j && s[j] != s[i]) j = Pi[j];

        Pi[i + 1] = ++j;

    }

}

bool check(int a, int b) { return a % (a - b) || !b; }

int main() {

    scanf("%s", s);

    n = strlen(s);

    kmp(Pi1);

    if (check(n, Pi1[n])) return printf("1\n1\n"), 0;

    if (n - Pi1[n] == 1) return printf("%d\n1\n", n), 0;

    reverse(s, s + n);

    kmp(Pi2);

    int ans = 0;

    for (int i = 1; i < n; i++)

        if (check(i, Pi1[i]) && check(n - i, Pi2[n - i])) ans++;

    printf("%d\n%d\n", 2, ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define int long long

#define For(i, a, b) for(int i = a; i <= b; ++ i)

const int N = 5e5 + 5, mod = 1e9 + 7;



int l, q;

string s;

int _hash[N], Hash[N], Pow[N];

bool pre[N], suf[N];



int get_hash(int l, int r){

	return (_hash[r] - _hash[l - 1] * Pow[r - l + 1] + mod * mod ) % mod;

}

int get_hash2(int l, int r){

	return (Hash[l] - Hash[r + 1] * Pow[r - l + 1] + mod * mod ) % mod;

}

signed main(){

	ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

	cin >> s;

	int len = s.length();

	s = "." + s;

	int ok = 0;

	For(i, 1, len) if(s[i] != s[1]){ ok = 1; break; }

	if(!ok){ cout << len << "\n" << 1; return 0; }

	Pow[0] = 1;

	For(i, 1, N - 1) Pow[i] = Pow[ i - 1] * 27 % mod;

	

	For(i, 1, len) _hash[i] = (_hash[i - 1] * 27 + s[i] - 'a' + 1) % mod;

	for(int i = len; i > 0; -- i) Hash[i] = (Hash[i + 1] * 27 + s[i] - 'a' + 1) % mod;

	

	For(i, 1, len){

		for(int j = i + 1; j + i - 1 <= len; j += i){

			if(_hash[i] != get_hash(j, j + i - 1)) break;

			pre[j + i - 1] = true;

		}

	}

	for(int i = len ; i > 0; -- i){

		int val = get_hash2(len - i + 1, len);

		for(int j = len - i; j - i + 1 > 0; j -= i){

			if(val != get_hash2(j - i + 1, j)) break;

			suf[j - i + 1] = true;

		}

	}

	if(!pre[len]){ cout << 1 << "\n" << 1; return 0; }

	int dem = 0;

	For(i, 1, len - 1) if(!pre[i] && !suf[i + 1]) dem ++;

	cout << 2 << "\n" << dem;

}

// Faster C++ solution for the same problem (measured speedup: 5.068236430555715x):
#include <bits/stdc++.h>

using namespace std;

#define N 500005

char s[N];

int n, Pi1[N], Pi2[N];

void kmp(int* Pi) {

    int j = Pi[0] = -1;

    for (int i = 0; i < n; i++) {

        while (~j && s[j] != s[i]) j = Pi[j];

        Pi[i + 1] = ++j;

    }

}

bool check(int a, int b) { return a % (a - b) || !b; }

int main() {

    scanf("%s", s);

    n = strlen(s);

    kmp(Pi1);

    if (check(n, Pi1[n])) return printf("1\n1\n"), 0;

    if (n - Pi1[n] == 1) return printf("%d\n1\n", n), 0;

    reverse(s, s + n);

    kmp(Pi2);

    int ans = 0;

    for (int i = 1; i < n; i++)

        if (check(i, Pi1[i]) && check(n - i, Pi2[n - i])) ans++;

    printf("%d\n%d\n", 2, ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long 

#define ll long long

using namespace std;

int n,a,b;

ll h[100010];

bool check(int x)

{

	int cnt=x;ll nw,tp;

	nw=(ll)x*b;

	for(int i=1;i<=n;i++)

	{

		if(h[i]<=nw)continue;

		else tp=h[i]-nw,cnt-=(tp/a)+(tp%a?1:0);

	}

	return cnt>=0;

}

main()

{

	scanf("%lld%lld%lld",&n,&a,&b);

	a-=b;

	for(int i=1;i<=n;i++)

		scanf("%lld",&h[i]);

	int l=1,r=1e9,mid,ans=1e9;

	while(l<=r)

	{

		mid=(l+r)>>1;

		if(check(mid))ans=mid,r=mid-1;

		else l=mid+1;

	}

	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 5.174477850458826x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define LL long long

LL n,A,B;

LL a[1000005];

bool judge(LL x){

    LL temp=x*B;

    LL sub=A-B;

    LL sum=0;

    for(LL i=n;i>=1;i--){

        if(a[i]>temp){

            if((a[i]-temp)%sub)

                sum+=(a[i]-temp)/sub+1;

            else

                sum+=(a[i]-temp)/sub;

        }

    }

    if(sum<=x)

        return true;

    return false;

}

int main() {

    scanf("%lld%lld%lld",&n,&A,&B);

    LL right=0;

    for(LL i=1;i<=n;i++){

        scanf("%lld",&a[i]);

        right+=a[i]/B+1;

    }

    sort(a+1,a+1+n);

    LL left=1;

    while(left<right){

        LL mid=(left+right)>>1;

        if(judge(mid))

            right=mid;

        else

            left=mid+1;

    }

    printf("%lld\n",left);

    return 0;

}