stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ll long long 

const int maxn=2e6+20;

const ll MOD=1e9+7;

char s[maxn],t[maxn];

int fail[maxn],suf[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(){

	//freopen(".in","r",stdin);

	//freopen(".out","w",stdout);

	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(suf,t);

	int m;

	if (fail[len]==0||len%(len-fail[len])) m=1;

	else m=2;

	bool flag=true;

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

		if (s[i]!=s[i-1]) flag=false; 

	}

	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])) && (suf[k]==0||(k)%(k-suf[k]))) ans++;

		}

	}

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

	return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int N(5e5 + 10);

char s[N]; int n, pre[N], nxt[N], ans;

int check(int x)

{

	int p = pre[x], t = n + 1 - nxt[x + 1];

	return ((!p || (x % (x - p))) && (!t || ((n - x) % (n - x - t))));

}



int main()

{

	scanf("%s", s + 1), n = strlen(s + 1), nxt[n] = n + 1;

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

	{

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

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

	}

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

	{

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

		if (s[j - 1] == s[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;

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

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

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <sstream>

#include <algorithm>

#include <cstdio>

#include <cmath>

#include <set>

#include <map>

#include <queue>

#include <string>

#include <cstring>

#include <bitset>

#include <functional>

#include <random>

#define REP(i,a,n) for(int i=a;i<=n;++i)

#define PER(i,a,n) for(int i=n;i>=a;--i)

#define hr putchar(10)

#define pb push_back

#define lc (o<<1)

#define rc (lc|1)

#define mid ((l+r)>>1)

#define ls lc,l,mid

#define rs rc,mid+1,r

#define x first

#define y second

#define io std::ios::sync_with_stdio(false)

#define endl '\n'

#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

const int P = 1e9+7, INF = 0x3f3f3f3f;

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}

ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}

inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}

//head







const int N = 1e6+50;

int n;

char s[N], t[N];

int pre[N], suf[N];

void getfail(char *s, int *f, int n) {

	int j = 0;

	REP(i,1,n-1) {

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

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

		f[i+1] = j;

	}

}



int main() {

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

	n = strlen(s+1);

	REP(i,1,n) t[i] = s[n-i+1];

	getfail(s+1,pre,n);

	getfail(t+1,suf,n);

	int len = n%(n-pre[n])==0?n/(n-pre[n]):1;

	if (len==n||len==1) return printf("%d\n1\n",len),0;

	int ans = 0;

	REP(i,1,n-1) {

		int x = i%(i-pre[i])==0?i/(i-pre[i]):1;

		int y = (n-i)%(n-i-suf[n-i])==0?(n-i)/(n-i-suf[n-i]):1;

		if (x==1&&y==1) ++ans;

	}

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

}














// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



const int N(5e5 + 10);

char s[N]; int n, pre[N], nxt[N], ans;

int check(int x)

{

	int p = pre[x], t = n + 1 - nxt[x + 1];

	return ((!p || (x % (x - p))) && (!t || ((n - x) % (n - x - t))));

}



int main()

{

	scanf("%s", s + 1), n = strlen(s + 1), nxt[n] = n + 1;

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

	{

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

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

	}

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

	{

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

		if (s[j - 1] == s[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;

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

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

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

} 


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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; 

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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; 

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

#include <cstdio>

#define M 100010



using namespace std;



long long num[M];

long long n,a,b;



bool cheak(long long x)

{

    long long cn=a-b;

    long long gl=0;

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

    {

        long long re=num[i]-b*x;

        if(re<=0)

            continue;

        else

        {

            gl+=re/cn;

            gl+=(re%cn!=0);

            if(gl>x)

                return false;

        }

    }

    if(gl>x)

        return false;

    return true;

}

int main()

{

    long long l=0,r=1e9;

    long long ans=r;

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

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

    {

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

    }

    while(l<=r)

    {

        long long mid=(l+r)/2;

        if(cheak(mid))

        {

            r=mid-1;

            ans=min(mid,ans);

        }

        else

            l=mid+1;

    }

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

    return 0;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<cstring>

#include<cstdio>

#include<map>

#include<queue>

#define inf1 1000000009

#define inf -1

using namespace std;

long long A,B,N;

long long s[100006];

bool cool(int a){

long long t=a;long long s1[100006];

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

    s1[i]=s[i];

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

   { s1[i]-=a*B;

    if(s1[i]<=0)continue;

      int y;

      if(s1[i]%(A-B)==0)y=s1[i]/(A-B);

      else y=s1[i]/(A-B)+1;

       t-=y;

   }//cout<<endl;

 if(t>=0)return true;

 return false;

}

int main(){



 cin>>N>>A>>B;

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

  cin>>s[i];

  long long l=0,L=inf1,s1;s1=inf1;

  while(l<L){

   long long man=(l+L)/2;

    if(cool(man)) L=man,s1=min(s1,man);

    else l=man+1;

    //cout<<L<<" "<<l<<endl;

  }

  cout<<s1<<endl;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<stdio.h>

#include<algorithm>

#include<algorithm>

#define L long long

#include<string.h>

#include <math.h>

long long  array1[100002];

using namespace std;

int n;

long long a,b;

int judge(int x)

{

    long long sum=0;

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

      {

          long long num=array1[i]-x*b;

          if(num>0)

          {

              sum+= ceil((num*1.0)/(a-b));



          }

          if(sum>x||sum<0)

                return 0;



      }

      return 1;

}



int main()

{   int i;

   cin>>n>>a>>b;

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

        {

        cin>>array1[i];

        }

            sort(array1,array1+n);

        long long l=0,r=array1[n-1];

         while(l<r)

         {

             long long mind=(l+r)>>1;

             if(judge(mind)==1)  r=mind;

             else

                 l=mind+1;

         }

         cout<<r<<endl;





       return 0;

}












// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <algorithm>



using namespace std;

typedef long long ll;

const int maxN=1e5+5;



ll a[maxN],n,A,B;



bool check(ll x)

{

    ll k,sum=0;

    for(k=1;k<=n;k++)

    {

        if(a[k]-x*B<=0)continue;

        sum+=(a[k]-x*B)/(A-B);

        if((a[k]-x*B)%(A-B)!=0)sum++;

    }

    return sum<=x;

}



int main()

{

    ll k,l,r,mid;

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

    for(k=1;k<=n;k++)

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

    l=1;r=1e9;

    while(r-l>5)

    {

        mid=(l+r)>>1;

        if(check(mid))r=mid;

        else l=mid;

    }

    for(;l<=r;l++)

        if(check(l))break;

    printf("%lld",l);

    return 0;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem: