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

using namespace std;



int n;

const int maxn=5000;

int a[maxn];

int sum,mx;



int main()

{

	scanf("%d",&n);

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

	scanf("%d",&a[i]),sum+=a[i],mx=max(mx,a[i]);

	if(sum-mx>mx) printf("Yes\n");else printf("No\n"); 

	return 0;

}

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

int main ()

{

	int a, result{0}, max{0}, n;

	cin>>n;

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

	{

		cin>>a;

		result+=a;

		if (max<a) max=a;

	}

	if (max<result-max) cout<<"Yes"<<endl;

	else cout<<"No"<<endl;

	return 0;

}

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

int main()

{

	int n = 0,ans = 0,max = 0,s = 0;

	cin >> n;

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

	{

		cin >> s;

		max = max > s ? max : s;

		ans += s;

	}

	if(ans > 2 * max)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

}

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;

int main()

{

	int n,ans = 0,max = 0,s;

	cin >> n;

	while(n --)

	{

		cin >> s;

		max = max > s ? max : s;

		ans += s;

	}

	if(ans > 2 * max)

		printf("Yes\n");

	else

		printf("No\n");

	return 0;

}

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

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

#define ll long long

using namespace std;

int main()

{

	int n;

	cin>>n;

	vector<int>v(n);

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

	{

		cin>>v[i];

	}

	sort(v.rbegin(),v.rend());

	int sum=0;

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

	{

		sum=sum+v[i];

	}

	if(sum>v[0])

	{

		cout<<"Yes"<<endl;

	}

	else

	{

		cout<<"No"<<endl;

	}

	return 0;

}

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;



int main()

{

    int n = 0;

    int edge = 0;

    int max,count = 0;

    cin >> n;

    while(n > 0)

    {

        cin >> edge;

        if(edge > max)

            max = edge;

        count += edge;

        --n;

    }

    if(count > (max << 1))

        cout << "Yes" << endl;

    else

        cout << "No" << endl;

}

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

	int n,temp,m=0,sum=0;

	cin >> n;

	while(n)

	{

		cin >> temp;

		sum += temp;

		m = max(m, temp);

		n--;

	}

	sum -= m;

	m<sum ? cout << "Yes" : cout << "No";

	return 0;

} 

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main()

{

	int n, in, sum, max;

	max = sum=0;

	cin >> n;

	while (n--)

	{

		cin >> in;

		sum += in;

		if (in > max) max = in;

	}

	sum -= max;

	if (max < sum) cout << "Yes" << endl;

	else cout << "No" << endl;

	return 0;

}


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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



using std::cout;    using std::cin;

using std::endl;	using std::max;



int main() {

	

	int N;

	cin >> N;

	

	int m = 0, sum = 0;

	

	for (int i = 0; i != N; ++i) {

		

		int x;

		cin >> x;

		

		sum += x;

		m = max(m, x);

	}

	

	if (sum > 2 * m)

		cout << "Yes" << endl;

	else

		cout << "No" << endl;

		

	return 0;

}

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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

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

#include<iostream>

using namespace std;

int main()

{

    int b;

    int temp=0;

    cin>>b;

    int a[b];

    long long int sum=0;

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

        cin>>a[i];

    }

    //cout<<a[0];

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

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

            if(a[i]<a[j]){

                temp=a[i];

                a[i]=a[j];

                a[j]=temp;

            }

        }

    }

    //cout<<a[0]<<endl;

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

        sum=sum+a[i];

    }

    if(a[0]<sum){

        cout<<"Yes\n";

    }

    else{

        cout<<"No\n";

    }

    return 0;

}


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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

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

#include <stdlib.h>

#define size 1000000



int main()

{

    int n,i,c = 0,a[size],b = 0;



    scanf("%d",&n);

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



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



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

        {

        c += a[i];

        if(a[i]>b)

           b = a[i];

        }



      if((c-b)>b)printf("Yes\n");

      else printf("No\n");

    return 0;

}


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

#define size 115

int main()

{

	int N,max=-1,i,l[size],total=0;

	scanf("%d",&N);

	if(N>=3)

	{

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

		{

			scanf("%d",&l[i]);

			total+=l[i];

		}

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

		{

			if(l[i]>max&&l[i]>0)

				{

					max=l[i];

				}

			else

				{

					

				}

			

		}

		total-=max;

	if(max<total)

		{

			printf("Yes\n");

		}

	else

		{

			printf("No\n");

		}

	}

	else

		{

			printf("No\n");

		}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <list>



using namespace std;



int main(){

	int x, n, l = 0, sum = 0;

	list<int> array;

	cin >> n;

	while (cin >> x){

		array.push_back(x);

		if (x > l)

			l = x;

		sum += x;

	}

	list<int>::iterator it;

	if (sum > 2 * l)cout << "Yes" << endl;

	else cout << "No" << endl;

	system("pause");

	return 0;

}

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

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<string.h>



#define size 100005



int main()

{

    int n, i, arr[size], sum=0, max;

    scanf("%d", &n);

    max=0;



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

    {

        scanf("%d", &arr[i]);

        sum = sum + arr[i];

        if(arr[i]>max)

            max = arr[i];

    }



    if((sum-max)>max)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <numeric>



using namespace std;



int main(){

    int sides[10];

    int datalen = 0;

    int largest;

    int sum;

    int n;



    cin >> n;



    while (cin >> sides[datalen++] &&(n-- > 1))

        ;

    largest = *std::max_element(sides, sides+datalen);

    sum = std::accumulate(sides, sides+datalen, 0);



    if ((sum - largest) > largest) {

        cout << "Yes";

    } else {

        cout << "No";

    }



    return 0;



}

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

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<string.h>



#define size 100005



int main()

{

    int n, i, arr[size], sum=0, max;

    scanf("%d", &n);

    max=0;



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

    {

        scanf("%d", &arr[i]);

        sum = sum + arr[i];

        if(arr[i]>max)

            max = arr[i];

    }



    if((sum-max)>max)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

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



using namespace std;



int main()

{

    int n,m,sum=0,s,i;

    cin>>n;

    int arr[n];

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

    {

        cin>>arr[i];

    }

    m=*max_element(arr,arr+n);



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

    {

        sum += arr[i];

    }

    s=sum-m;

    if(s>m)

    {

        cout<<"Yes"<<endl;

    }

    else

    {

        cout<<"No"<<endl;

    }

    return 0;

}


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

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<string.h>



#define size 100005



int main()

{

    int n, i, arr[size], sum=0, max;

    scanf("%d", &n);

    max=0;



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

    {

        scanf("%d", &arr[i]);

        sum = sum + arr[i];

        if(arr[i]>max)

            max = arr[i];

    }



    if((sum-max)>max)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <queue>



#define ll long long



using namespace std;



const int N = 60;

const int mod = 1e9 + 7;



inline int read() {

	int jg = 0, jk = getchar() - '0', f = 1;

	while(jk < 0 || jk > 9) {

	    if(jk == '-' - '0')  f = -1;

		jk = getchar() - '0';

	}

	while(jk >= 0 && jk <= 9)

		jg *= 10, jg += jk, jk = getchar() - '0';

	return jg * f;

}



int n, mx, sum;

 

int main() {

	//freopen("a.txt", "r", stdin);

    n = read();

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

		l = read();

		sum += l;

		mx = max(mx, l);

	}

	if(sum > 2 * mx)  printf("Yes");

	else  printf("No");

    return 0;

}

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

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<string.h>



#define size 100005



int main()

{

    int n, i, arr[size], sum=0, max;

    scanf("%d", &n);

    max=0;



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

    {

        scanf("%d", &arr[i]);

        sum = sum + arr[i];

        if(arr[i]>max)

            max = arr[i];

    }



    if((sum-max)>max)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int main(){

    int N;

    cin>>N;

    int max=0,sum=0;

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

        int temp;

        cin>>temp;

        if(temp>max){

            sum+=max;

            max=temp;

        }

        else{

            sum+=temp;

        }

    }

    if(max<sum)

        cout<<"Yes"<<endl;

    else

    {

        cout<<"No"<<endl;

    }

    return 0;

}

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

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<string.h>



#define size 100005



int main()

{

    int n, i, arr[size], sum=0, max;

    scanf("%d", &n);

    max=0;



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

    {

        scanf("%d", &arr[i]);

        sum = sum + arr[i];

        if(arr[i]>max)

            max = arr[i];

    }



    if((sum-max)>max)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include<iostream>



using namespace std;



int main()

{

	int n, max = 0, sum = 0;

	cin >> n;

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

	{

		cin >> j;

		sum += j;

		if (max < j)

			max = j;

	}

	if (max < sum - max)

		cout << "Yes";

	else

		cout << "No";



	return 0;

}

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

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<string.h>



#define size 100005



int main()

{

    int n, i, arr[size], sum=0, max;

    scanf("%d", &n);

    max=0;



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

    {

        scanf("%d", &arr[i]);

        sum = sum + arr[i];

        if(arr[i]>max)

            max = arr[i];

    }



    if((sum-max)>max)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

using namespace std;

int find_max(vector<int> v)

{

	int max=0;

	for(vector<int>::size_type i=0;i!=v.size();i++)

	{

		if(v[i]>max)

		max=v[i];

	}

	return max;

}

int main()

{

	int n,i=0;

	cin>>n;

	vector<int> body;

	int m;

	while(i<n&&cin>>m)

	{

	body.push_back(m);

	i++;

}

int sum=0;

for(vector<int>::size_type i=0;i!=body.size();i++)

sum+=body[i];

if((sum-find_max(body))>find_max(body))

cout<<"Yes"<<endl;

else

cout<<"No"<<endl;

return 0;

}

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

#include<stdlib.h>

#include<math.h>

#include<ctype.h>

#include<string.h>



#define size 100005



int main()

{

    int n, i, arr[size], sum=0, max;

    scanf("%d", &n);

    max=0;



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

    {

        scanf("%d", &arr[i]);

        sum = sum + arr[i];

        if(arr[i]>max)

            max = arr[i];

    }



    if((sum-max)>max)

        printf("Yes\n");

    else

        printf("No\n");



    return 0;

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

using namespace std;

int main(){

	string str;

	cin>>str;

	int len=str.size();

	int start,end;

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

		if(str[i]=='A'){

			start=i+1;

			break;

		}

	}

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

		if(str[i]=='Z'){

			end=i+1;

			break;

		}

	}

	cout<<end-start+1<<endl;

}

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

#include<string.h>

using namespace std;

char a[200050];

int main()

{

    while(~scanf("%s",a))

    {

        int pre=-1;

        int back=-1;

        int n=strlen(a);

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

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    }

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cstdio>

#include <string>

using namespace std;

#define min(x, y) ((x < y) ? x : y)

#define rep(x, n) for (int x = 1; x <= n; ++x)

#define zrp(x, n) for (int x = n; x; --x)

const int inf = 214748364;

char s[200005];

int n;



int main()

{

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

	n = strlen(s + 1);

	int x, y;

	rep(i, n) if (s[i] == 'A')

	{

		x = i;

		break;

	}

	zrp(i, n) if (s[i] == 'Z')

	{

		y = i;

		break;

	}

	cout << y - x + 1 << endl;

	return 0;

}


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

#include<string.h>

using namespace std;

char a[200050];

int main()

{

    while(~scanf("%s",a))

    {

        int pre=-1;

        int back=-1;

        int n=strlen(a);

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

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    }

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;

template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }

template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }

template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }

template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }



/*

 <url:>

 問題文============================================================

 =================================================================

 解説=============================================================

 ================================================================

 */

int main(void) {

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

    string s; cin >> s;

    cout << s.rfind('Z') - s.find('A') +1 << endl;

    return 0;

}


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

#include<string.h>

using namespace std;

char a[200050];

int main()

{

    while(~scanf("%s",a))

    {

        int pre=-1;

        int back=-1;

        int n=strlen(a);

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

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    }

}
// Slower C++ solution:
#include <iostream>

#include <string>

using namespace std;



int main() {

  int a = 0, z = 0, c = 0;

  string s;

  cin >> s;



  for (int i = 0; i < s.size(); i++) {

    if (s[i] == 'Z') {

      z = i;

    }

    if (!c) {

      if (s[i] == 'A') {

        a = i;

        c = 1;

      }

    }

  }

  cout<< z + 1 - a;

}


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

#include<string.h>

using namespace std;

char a[200050];

int main()

{

    while(~scanf("%s",a))

    {

        int pre=-1;

        int back=-1;

        int n=strlen(a);

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

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    }

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

typedef long long ll;

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

using namespace std;

int n; char ch[200010];

int main() {

	scanf("%s", ch); n = strlen(ch);

	int a = 0, b = 0;

	rep(i, 0, n - 1) if (ch[i] == 'Z') b = i;

	for (int i = n - 1; i >= 0; -- i) if (ch[i] == 'A') a = i;

	printf("%d\n", b - a + 1);

	return 0;

}

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

#include<cstring>

#include<algorithm>

using namespace std;



char s[200005];

int len;

int main(){

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

  len=strlen(s+1);

  int minv=1<<30,maxv=0;

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

    if (s[i]=='A')

      minv=min(minv,i);

    else if (s[i]=='Z')

      maxv=max(maxv,i);

  printf("%d\n",maxv-minv+1);

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

typedef long long ll;

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

using namespace std;

int n; char ch[200010];

int main() {

	scanf("%s", ch); n = strlen(ch);

	int a = 0, b = 0;

	rep(i, 0, n - 1) if (ch[i] == 'Z') b = i;

	for (int i = n - 1; i >= 0; -- i) if (ch[i] == 'A') a = i;

	printf("%d\n", b - a + 1);

	return 0;

}

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

#include<string.h>

using namespace std;

char a[200050];

int main()

{

   scanf("%s",a);

    

        int pre=-1;

        int back=-1;

        int n=strlen(a);

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

        {

            if(a[i]=='A'&&pre==-1)pre=i;

            if(a[i]=='Z')back=i;

        }

        if(pre==-1||back==-1)

        {

            printf("0\n");

        }

        else printf("%d\n",back-pre+1);

    

}