criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

int main(){
    string s; cin >> s;
    int n = s.size()
    int beg,end;
    for(int i = 0; i < n; i++){
        if(s[i] == 'A'){
            beg = i;
            break;
        }
    }
    for(int i = n-1; i >= 0; i--){
        if(s[i] == 'Z'){
            end = i;
            break;
        }
    }
    cout << end - beg << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: expected ',' or ';' before 'int'
    8 |     int beg,end;
      |     ^~~
a.cc:11:13: error: 'beg' was not declared in this scope
   11 |             beg = i;
      |             ^~~
a.cc:17:19: error: overloaded function with no contextual type information
   17 |             end = i;
      |                   ^
a.cc:21:19: error: 'beg' was not declared in this scope
   21 |     cout << end - beg << endl;
      |                   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int start = 0;
  int end = s.size();
  for (int i = 0; i < end; i++) {
    if (S[i] == 'A') {
      start = i;
      break;
    }
  }
  for (int i = end - 1; i >= 0; i--) {
    if (S[i] == 'Z') {
      end = i;
      break;
    }
  }
  int ans = end - start + 1;
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'S' was not declared in this scope
    9 |     if (S[i] == 'A') {
      |         ^
a.cc:15:9: error: 'S' was not declared in this scope
   15 |     if (S[i] == 'Z') {
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int start = 0;
  int end = s.size();
  for (int i = 0; i < end; i++) {
    if (s[i] == 'A') {
      start = i;
      break;
    }
  }
  for (int i = end - 1; i >= 0; i--) {
    if (S[i] == 'Z') {
      end = i;
      break;
    }
  }
  int ans = end - start + 1;
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'S' was not declared in this scope
   15 |     if (S[i] == 'Z') {
      |         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(void)
{
	string s; cin>>s;
	int len = s.size();
	
	int start = 0, end = 0;
	int s_flag = 0;
	for(int i = 0; i < len; i++){
		if(s[i] == 'A' && s_flag == 0){
			s_flag = 1;
			start = i;
		}
		else if(s[i] == 'Z' && e_flag == 0){
			end = i;
		}
	}
	
	cout<<end+1-start<<endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:40: error: 'e_flag' was not declared in this scope; did you mean 's_flag'?
   17 |                 else if(s[i] == 'Z' && e_flag == 0){
      |                                        ^~~~~~
      |                                        s_flag
Language: Java


public class Sample{
	String s;
	public Sample(String str){
		s = str;
	}

	public int searchA(){
		return s.indexOf("A");
	}
	public int searchZ(){
		return s.lastIndexOf("Z") + 1;
	}

	public static void main(String[] args){
		Sample sample = new Sample(args[0]);
		int start = sample.searchA();
		int end = sample.searchZ();
		System.out.println(end - start);

	}
}



Compiler output:
Main.java:2: error: class Sample is public, should be declared in a file named Sample.java
public class Sample{
       ^
1 error
Language: C++

//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  int a,b;
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      a=i;
      break;
      }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='Z'){
      b=i;
      break;
    }
  }
    cout<<b-a+1<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'n' was not declared in this scope
   15 |   for(int i=0;i<n;i++){
      |                 ^
a.cc:21:13: error: 'n' was not declared in this scope
   21 |   for(int i=n-1;i>=0;i--){
      |             ^
Language: C++

//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  sring s;
  cin>>s;
  int a,b;
  for(int i=0;i<n;i++){
    if(s[i]=='A'){
      a=i;
      break;
      }
  }
  for(int i=n-1;i>=0;i--){
    if(s[i]=='Z'){
      b=i;
      break;
    }
  }
    cout<<b-a+1<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'sring' was not declared in this scope
   12 |   sring s;
      |   ^~~~~
a.cc:13:8: error: 's' was not declared in this scope
   13 |   cin>>s;
      |        ^
a.cc:15:17: error: 'n' was not declared in this scope
   15 |   for(int i=0;i<n;i++){
      |                 ^
a.cc:21:13: error: 'n' was not declared in this scope
   21 |   for(int i=n-1;i>=0;i--){
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  int an,zn;
  an=-1;
  zn=-1;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){
      an=i;
      break;
    }
  }
  for(int i=s.size-1;i>=0;i--){
    if(s.at(i)=='Z'){
      zn=i;
      break;
    }
  }
  cout << zn-an+1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   16 |   for(int i=s.size-1;i>=0;i--){
      |             ~~^~~~
      |                   ()
Language: C++

#include<iostream>
using namespace std;
string s;
int main(){
int l,r;
cin>>s;
for(int i=0;i<s.size();i++)
if(s[i]=='A'){
l=i;
break;}
for(int i=0;i<s.size();i++)
if(a[i]=='Z'){
r=i;
break;}
cout<<r-l+1<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:4: error: 'a' was not declared in this scope
   12 | if(a[i]=='Z'){
      |    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	int fst = -1,ed = -1;
	for(int i = 0;i < s.size();i++)
	{
		if(s.at(i) == 'A' && fst == -1)
		{
			fst = i;
		}
		if(s.at(s.size() - i - 1) == 'Z' && ed == -1)
		{
			ed = s.size() - i
		}
		if(fst >= 0 && ed >= 0)
		{
			break;
		}
	}
    cout << ed - fst << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:42: error: expected ';' before '}' token
   16 |                         ed = s.size() - i
      |                                          ^
      |                                          ;
   17 |                 }
      |                 ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a) //追加//
#define pp() pop_back() //削除//
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())

signed main(){
  string s;
  cin>>s;
  
  for(int i=0; i<s.size()-1; i++){
    if(s[i]!='A')
      s.size()--;
    else
      break;
  }
  for(int i=s.size()-1; i>0; i--){
    if(s[i]!='Z')
      s.size()--;
    else
      break;
  }
  cout<<s.size()<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:13: error: lvalue required as decrement operand
   29 |       s.size()--;
      |       ~~~~~~^~
a.cc:35:13: error: lvalue required as decrement operand
   35 |       s.size()--;
      |       ~~~~~~^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a) //追加//
#define pp() pop_back() //削除//
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())

signed main(){
  string s;
  cin>>s;
  for(int i=0; i<s.size()-1; i++){
    if(s[i]!='A')
      pp(s[i]);
    else
      break;
  }
  for(int i=s.size()-1; i>0; i--){
    if(s[i]!='Z')
      pp(s[i]);
    else
      break;
  }
  cout<<s.size()<<endl;
}


Compiler output:
a.cc:28:14: error: macro "pp" passed 1 arguments, but takes just 0
   28 |       pp(s[i]);
      |              ^
a.cc:14:9: note: macro "pp" defined here
   14 | #define pp() pop_back() //削除//
      |         ^~
a.cc:34:14: error: macro "pp" passed 1 arguments, but takes just 0
   34 |       pp(s[i]);
      |              ^
a.cc:14:9: note: macro "pp" defined here
   14 | #define pp() pop_back() //削除//
      |         ^~
a.cc: In function 'int main()':
a.cc:28:7: error: 'pp' was not declared in this scope
   28 |       pp(s[i]);
      |       ^~
a.cc:34:7: error: 'pp' was not declared in this scope
   34 |       pp(s[i]);
      |       ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(void)
{
  string s;
  int farst, last;
  cin >> s;
  for(int i = 0;i < s.size();i++) {
    if(s.at(i) == 'A')
    farst = i;
  }
  for(int i = s.size - 1;i > 0;i--) {
    if (s.at(i) == 'Z')
    last = i;
  }
  cout << last - farst << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   13 |   for(int i = s.size - 1;i > 0;i--) {
      |               ~~^~~~
      |                     ()
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(void) {
  string s;
  int ans = 0;
  cin >> s;
  for(int i = 0;;i++) {
    if(s.at(i) == 'a') {
      for(int j = i;;j++) {
        ans+++
        if(s.at(j) == 'z') {
          cout << ans << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: expected primary-expression before 'if'
   12 |         if(s.at(j) == 'z') {
      |         ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin>>s;
  int a, b;
  for (int i=0;i<s.size();i++){
    if(s[i]=='A') {
      a=i;
      break;
    }
  }
    for (int i=s.size-1;i>=0;i--){
    if(s[i]=='Z') {
      b=i;
      break;
    }
  }
  cout<<b-a+1<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   14 |     for (int i=s.size-1;i>=0;i--){
      |                ~~^~~~
      |                      ()
Language: C++

#include <iostream>
using namespace std;
int main(void){
    
    string s;
    int start, gool;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A') start = i;
        break;
    }
    
    for(int i = s.size(); j >= 0; j--){
        if(s[j] == 'Z') gool = j;
        break;
    }
    
    cout << gool - start + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:27: error: 'j' was not declared in this scope
   14 |     for(int i = s.size(); j >= 0; j--){
      |                           ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
string s;
int main() {
  cin>>s;
  int i = 0;
  int j = s.size()-1;
  while(i < n && s[i] != 'A') i++;
  while(j >= 0 && s[j] != 'Z') j--;
  cout<<j-i+1<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: 'n' was not declared in this scope
   12 |   while(i < n && s[i] != 'A') i++;
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main()
{

	string s;
	int maxLength = 0;

	cin >> s;
	
	while(true) { 
		
		if ( s[i] == 'A' && maxLength == 0 ) {	
			maxLength = 1;
		}

		else if (s[i] == 'Z') { 
			maxLength++; 
			break;
		}

		else {
			maxLength++;
		}

	}
	
	cout << maxLength << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:24: error: 'i' was not declared in this scope
   14 |                 if ( s[i] == 'A' && maxLength == 0 ) {
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  char s[200099];
  cin >> s;
  
  int a_position = 0;
  int z_position = 0;
  for (int i = 0; i < strlen(s); i++) {
    if (s.at(i)=='A') {
      a_position = i;
      break;
    }
  }

  for (int i = strlen(s)-1; a_position < i; i--) {
    if (s.at(i)=='Z') {
      z_position = i;
      break;
    }
  }

  cout << z_position-a_position+1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: request for member 'at' in 's', which is of non-class type 'char [200099]'
   11 |     if (s.at(i)=='A') {
      |           ^~
a.cc:18:11: error: request for member 'at' in 's', which is of non-class type 'char [200099]'
   18 |     if (s.at(i)=='Z') {
      |           ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  char s[200099];
  cin >> s;
  
  int a_position = 0;
  int z_position = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i)=='A') {
      a_position = i;
      break;
    }
  }

  for (int i = s.size()-1; a_position < i; i--) {
    if (s.at(i)=='Z') {
      z_position = i;
      break;
    }
  }

  cout << z_position-a_position+1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:25: error: request for member 'size' in 's', which is of non-class type 'char [200099]'
   10 |   for (int i = 0; i < s.size(); i++) {
      |                         ^~~~
a.cc:11:11: error: request for member 'at' in 's', which is of non-class type 'char [200099]'
   11 |     if (s.at(i)=='A') {
      |           ^~
a.cc:17:18: error: request for member 'size' in 's', which is of non-class type 'char [200099]'
   17 |   for (int i = s.size()-1; a_position < i; i--) {
      |                  ^~~~
a.cc:18:11: error: request for member 'at' in 's', which is of non-class type 'char [200099]'
   18 |     if (s.at(i)=='Z') {
      |           ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int n,m,s;
	cin>>a;
	for(int i=0;i<s.size();i++)
		if(a[i]=='a')
		{
			n=i;
			break;
		}
	for(int i=a.size()-1;i>=0;i++)
		if(a[i]=='z')
		{
			m=i;
			break;
		}
	s=m-n+1;
	if(s>0)
		cout<<s<<endl;
	else
		cout<<"0";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:25: error: request for member 'size' in 's', which is of non-class type 'int'
    8 |         for(int i=0;i<s.size();i++)
      |                         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  int max;
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++){
    int count=0;
    if(s.at(i) == 'A'){
      while(s.at(i) == 'Z'){
        count++;
        i++;
      }
    }
    if(count>max){
      max = count;
    }
  }
  cout << max << endl;
  retun 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:3: error: 'retun' was not declared in this scope
   21 |   retun 0;
      |   ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  string s;cin>>s;
  int ans=0;
  rep(i,s.size()){
    if(s[i]=="A"){
      int tmp=1;
      repi(j,i+1,s.size()){
        tmp++;
        if(s[j]=="Z")ans=max(ans,tmp);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |     if(s[i]=="A"){
a.cc:14:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |         if(s[j]=="Z")ans=max(ans,tmp);
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  string s;cin>>s;
  int ans=0;
  rep(i,s.size()){
    if(s[i]=="A"){
      int tmp=1;
      repi(j,i+1,s.size()){
        tmp++;
        if(s[j]=="Z")break;
      }
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |     if(s[i]=="A"){
a.cc:14:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |         if(s[j]=="Z")break;
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	string str;
	cin >> str;

	int maxLen = 0;
	int a = 0;
	int b = str.size()-1;
	
	while(str[a] != 'A')
	    a++;
	while(str[b] != 'Z')
	   b--;
	cout << b-a+1;
	return 0;
}//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	string str;
	cin >> str;

	int maxLen = 0;
	int a = 0;
	int b = str.size()-1;
	
	while(str[a] != 'A')
	    a++;
	while(str[b] != 'Z')
	   b--;
	cout << b-a+1;
	return 0;
}

Compiler output:
a.cc:47:5: error: redefinition of 'int main()'
   47 | int main()
      |     ^~~~
a.cc:16:5: note: 'int main()' previously defined here
   16 | int main()
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
int main(){
  string s;
  int a=0,b;
  cin>>s;
  size_t size=s.length();
  for(int i=0;i<size;i++){
    if(s[i]=='A') a=i+1;
    if(s[i]=='Z' && a!=0) b=i+1;
  }
  cout<<b-a<<"\n";
  return(0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'string' was not declared in this scope
    3 |   string s;
      |   ^~~~~~
a.cc:3:3: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 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/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   cin>>s;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:5:8: error: 's' was not declared in this scope
    5 |   cin>>s;
      |        ^
a.cc:11:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   11 |   cout<<b-a<<"\n";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++


int main() {
    string s;
    int index1 = 0;
    int res;
    int index2 = 0;
    int flag = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == 'A' && flag == 0) {
            index1 = i;
            flag = 1;
        }
        if(s[i] == 'Z' && flag == 1) {
            index2 = i;
            break;
        }
    }
    res = index2 - index1 + 1;
    cout << res << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'string' was not declared in this scope
    3 |     string s;
      |     ^~~~~~
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin >> s;
      |     ^~~
a.cc:8:12: error: 's' was not declared in this scope
    8 |     cin >> s;
      |            ^
a.cc:20:5: error: 'cout' was not declared in this scope
   20 |     cout << res << endl;
      |     ^~~~
a.cc:20:20: error: 'endl' was not declared in this scope
   20 |     cout << res << endl;
      |                    ^~~~
Language: C++



int main() {
    string s;
    int index1;
    int res;
    int index2;
    int flag = 0;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == 'A' && flag == 0) {
            index1 = i;
            flag = 1;
        }
        if(s[i] == 'Z' && flag == 1) {
            index2 = i;
            flag = 2;
        }
    }
    res = index2 - index1 + 1;
    cout << res << endl;

} 

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'string' was not declared in this scope
    4 |     string s;
      |     ^~~~~~
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin >> s;
      |     ^~~
a.cc:9:12: error: 's' was not declared in this scope
    9 |     cin >> s;
      |            ^
a.cc:21:5: error: 'cout' was not declared in this scope
   21 |     cout << res << endl;
      |     ^~~~
a.cc:21:20: error: 'endl' was not declared in this scope
   21 |     cout << res << endl;
      |                    ^~~~
Language: C++

#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	string s;
  	cin >> s;
  	int left, right;
  	rep(i,s.size()){
    	if(s[i] == 'A'){
        	left = i;
          	break;
        }	
    }
  	rep3rev(j,s.size()-1,0){
    	if(s[i] == 'Z'){
        	right = j;
          	break;
        }	
    }
  	cout << right - left + 1 << endl;
  
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Compiler output:
a.cc:2:9: fatal error: boost/multi_array.hpp: No such file or directory
    2 | #include<boost/multi_array.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  
  int a, b;
  
  for(int i = 0; i < s.size(); i ++){
    if(s[i] == 'A');
      a = i;
      break;
    }
  }

  for(int i = a; i < s.size(); i ++){
    if(s[i] == 'A'){
      b = i;
      break;
    }
  }
  cout << b - a + 1 << endl;
}
        

Compiler output:
a.cc:16:3: error: expected unqualified-id before 'for'
   16 |   for(int i = a; i < s.size(); i ++){
      |   ^~~
a.cc:16:18: error: 'i' does not name a type
   16 |   for(int i = a; i < s.size(); i ++){
      |                  ^
a.cc:16:32: error: 'i' does not name a type
   16 |   for(int i = a; i < s.size(); i ++){
      |                                ^
a.cc:22:3: error: 'cout' does not name a type
   22 |   cout << b - a + 1 << endl;
      |   ^~~~
a.cc:23:1: error: expected declaration before '}' token
   23 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  
  int a, b;
  
  for(int i = 0; i < s.size(); i ++){
    if(s[i] == 'A');
      a = i;
      break;
    }
  }

  for(int i = a; i < s.size(); i ++){
    if(s[i] == 'A');
      b = i;
      break;
    }
  }
  cout << b - a + 1 << endl;
}
        

Compiler output:
a.cc:16:3: error: expected unqualified-id before 'for'
   16 |   for(int i = a; i < s.size(); i ++){
      |   ^~~
a.cc:16:18: error: 'i' does not name a type
   16 |   for(int i = a; i < s.size(); i ++){
      |                  ^
a.cc:16:32: error: 'i' does not name a type
   16 |   for(int i = a; i < s.size(); i ++){
      |                                ^
a.cc:21:3: error: expected declaration before '}' token
   21 |   }
      |   ^
a.cc:22:3: error: 'cout' does not name a type
   22 |   cout << b - a + 1 << endl;
      |   ^~~~
a.cc:23:1: error: expected declaration before '}' token
   23 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i = 0; i < s.size(); i ++){
    int count = 0;
    if(s[i] == 'A'){
      while(true){
        int a = i;
        count++;
        a++;
        if(s[a] == 'Z'){
          if(ans< count) ans = count;
          break;
        }
        else if(a == s.size()-1){
          break;
        }
      }
    }
  }
  cout << ans << ensl;
}
        

Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: 'ensl' was not declared in this scope
   25 |   cout << ans << ensl;
      |                  ^~~~
Language: C++

#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int idxa,idxb;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            idxa=i;
            break;
        }
    }
    for(int i=0;i<s.size();i++){
        if(s[s.size()-i-1]=='Z'){
            idxb=i;
            break;
        }
    }
    
    ans = idxb-idxa+1;;
    //cout << (flag ? "Yes" : "No") << endl;
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |     ans = idxb-idxa+1;;
      |     ^~~
      |     abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

int main(){
  string s;
  cin >> s;
  int pa, pz;
  rep(i,n){if(s.at(i)=='A');pa=i;break;}
  reverse(s.begin(),s.end());
  rep(i,n){if(s.at(i)=='Z');pz=i;break;}
  cout << s.size()-pa-pz << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'n' was not declared in this scope
    9 |   rep(i,n){if(s.at(i)=='A');pa=i;break;}
      |         ^
a.cc:3:41: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (int i=0; i<(int)(n); i++)
      |                                         ^
a.cc:11:9: error: 'n' was not declared in this scope
   11 |   rep(i,n){if(s.at(i)=='Z');pz=i;break;}
      |         ^
a.cc:3:41: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (int i=0; i<(int)(n); i++)
      |                                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s;
    int max = 0;
    int ans = 0;
    bool flag = false;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A') {
            flag = true;
        }
        if (flag) {
            max++;
        }
        if (s.at(i) == 'Z') {
            flag = false;
        }
        ans = max(ans, max);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:18: error: 'max' cannot be used as a function
   21 |         ans = max(ans, max);
      |               ~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main(void){
 string s;
 cin >> s;
  int start, end;
  for (int i = 0; i<s.length();i++){
    if (s[i] == 'A') start = i; break;
  }
  for (int i = s.length-1; i>=start;i--){
    if (s[i] == 'Z') start = i; break;
  }
  cout << (long long)end -start + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   12 |   for (int i = s.length-1; i>=start;i--){
      |                ~~^~~~~~
      |                        ()
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main(void){
 string s;
 cin >> s;
  int start end;
  for (int i = 0; i<s.length();i++){
    if (s[i] == 'A') start = i; break;
  }
  for (int i = s.length-1; i>=start;i--){
    if (s[i] == 'Z') start = i; break;
  }
  cout << (long long)end -start + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: expected initializer before 'end'
    8 |   int start end;
      |             ^~~
a.cc:10:22: error: 'start' was not declared in this scope
   10 |     if (s[i] == 'A') start = i; break;
      |                      ^~~~~
a.cc:12:18: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   12 |   for (int i = s.length-1; i>=start;i--){
      |                ~~^~~~~~
      |                        ()
a.cc:12:31: error: 'start' was not declared in this scope
   12 |   for (int i = s.length-1; i>=start;i--){
      |                               ^~~~~
a.cc:15:22: error: overloaded function with no contextual type information
   15 |   cout << (long long)end -start + 1 << endl;
      |                      ^~~
a.cc:15:27: error: 'start' was not declared in this scope
   15 |   cout << (long long)end -start + 1 << endl;
      |                           ^~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



char S[300000];
int A[300000], Z[300000];

int main() {


	scanf("%s", S);

	int inA = 0;
	int inZ = 0;


	for (int i = 0; i < strlen(S); i++) {
		if (S[i] == 'A') {
			A[inA] = i;
			inA++;
		}
		else if (S[i] == 'Z') {
			Z[inZ] = i;
			inZ++;
		}
	}

	int ans = 0;
	for (int i = 0; i < inA; i++) {
		for (int j = 0; j < inZ; j++) {
			if (Z[j] > A[i]) {
				ans = max(Z[j] - A[i] + 1, ans);
			


		}
	}

	printf("%d", ans);




}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:2: error: expected '}' at end of input
   59 | }
      |  ^
a.cc:23:12: note: to match this '{'
   23 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++){
    for (int j = s.size(); j > i; j--){
      if (i == 'A' && j == 'Z'){
        int k = j - i + 1;
      }
    }
  }
  cout << k << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: 'k' was not declared in this scope
   15 |   cout << k << endl;
      |           ^
Language: C++

S = input()
first = 0
last = 0

for i in range(0, len(S)):
    if S[i] == 'A':
        first = i
        break

for i in range(len(S)-1, -1, -1):
    if S[i] == 'Z':
        last = i
        break

print(last - first + 1)

Compiler output:
a.cc:1:1: error: 'S' does not name a type
    1 | S = input()
      | ^
Language: C++

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	string s;
	int a, b;
	a = b = 0;
	cin >> s;

	for (int i = 0;i < s.length();i++)
	{
		if (a == 0 && s[i] == 'A')
		{
			a = i;
			break;
		}
	}
	for (int i = s.length()-1;i >=0;i--)
	{
		if (b == 0 && s[i] == 'Z')
		{
			b = i;
			break;
		}
	}
	cout << b - a+1;

Compiler output:
a.cc: In function 'int main()':
a.cc:33:25: error: expected '}' at end of input
   33 |         cout << b - a+1;
      |                         ^
a.cc:11:1: note: to match this '{'
   11 | {
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0;
  for(int i=0; i < s.size(); i++){
    if(s[i]　==　"A"){
      int b=0;
      for(int j=s.at(i); j < s.size(); j++){
        b++;
        if(s.at[i]　==　"Z"){
          if(a < b) b=a;
          break;
        }
      }
    }
  }
  cout << a << endl;
}

Compiler output:
a.cc:8:12: error: extended character 　 is not valid in an identifier
    8 |     if(s[i]　==　"A"){
      |            ^
a.cc:8:16: error: extended character 　 is not valid in an identifier
    8 |     if(s[i]　==　"A"){
      |                ^
a.cc:12:19: error: extended character 　 is not valid in an identifier
   12 |         if(s.at[i]　==　"Z"){
      |                   ^
a.cc:12:23: error: extended character 　 is not valid in an identifier
   12 |         if(s.at[i]　==　"Z"){
      |                       ^
a.cc: In function 'int main()':
a.cc:8:12: error: expected ')' before '\U00003000'
    8 |     if(s[i]　==　"A"){
      |       ~    ^~
      |            )
a.cc:12:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   12 |         if(s.at[i]　==　"Z"){
      |                ^
a.cc:12:19: error: expected ')' before '\U00003000'
   12 |         if(s.at[i]　==　"Z"){
      |           ~       ^~
      |                   )
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0;
  for(int i=0; i < s.size(); i++){
    if(s.at(i)　==　"A"){
      int b=0;
      for(int j=s.at(i); j < s.size(); j++){
        b++;
        if(s.at(i)　==　"Z"){
          if(a < b) b=a;
          break;
        }
      }
    }
  }
  cout << a << endl;
}

Compiler output:
a.cc:8:15: error: extended character 　 is not valid in an identifier
    8 |     if(s.at(i)　==　"A"){
      |               ^
a.cc:8:19: error: extended character 　 is not valid in an identifier
    8 |     if(s.at(i)　==　"A"){
      |                   ^
a.cc:12:19: error: extended character 　 is not valid in an identifier
   12 |         if(s.at(i)　==　"Z"){
      |                   ^
a.cc:12:23: error: extended character 　 is not valid in an identifier
   12 |         if(s.at(i)　==　"Z"){
      |                       ^
a.cc: In function 'int main()':
a.cc:8:15: error: expected ')' before '\U00003000'
    8 |     if(s.at(i)　==　"A"){
      |       ~       ^~
      |               )
a.cc:12:19: error: expected ')' before '\U00003000'
   12 |         if(s.at(i)　==　"Z"){
      |           ~       ^~
      |                   )
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0;
  for(int i=0; i < s.size(); i++){
    if(s.at(i)=="A"){
      int b=0;
      for(int j=s.at(i); j < s.size(); j++){
        b++;
        if(s.at(i)=="Z"){
          if(a < b) b=a;
          break;
        }
      }
    }
  }
  cout << a << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |     if(s.at(i)=="A"){
      |        ~~~~~~~^~~~~
a.cc:12:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |         if(s.at(i)=="Z"){
      |            ~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0;
  for(int i=0; i < s.size(); i++){
    if(s.at(i)==A){
      int b=0;
      for(int j=s.at(i); j < s.size(); j++){
        b++;
        if(s.at(i)==Z){
          if(a < b) b=a;
          break;
        }
      }
    }
  }
  cout << a << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'A' was not declared in this scope
    8 |     if(s.at(i)==A){
      |                 ^
a.cc:12:21: error: 'Z' was not declared in this scope
   12 |         if(s.at(i)==Z){
      |                     ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>


using namespace std;

int main() {
	bool flag = false;
	string s;
	cin >> s;

	int i = 0;
	int n = 1;
	while (s[i] != 'Z') {

Compiler output:
a.cc: In function 'int main()':
a.cc:16:30: error: expected '}' at end of input
   16 |         while (s[i] != 'Z') {
      |                             ~^
a.cc:16:30: error: expected '}' at end of input
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

int main() {
    string s;
    cin >> s;
    vector<int> As, Zs;
    for (int i = 0; i < s.length(); i++){
        if (s[i] == 'A'){
            As.push_back(i);
        }
        else if (s[i] == 'Z') {
            Zs.push_back(i);
        }
    }
    cout << Zs[Zs.length() - 1] - As[0] + 1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: 'class std::vector<int>' has no member named 'length'
   19 |     cout << Zs[Zs.length() - 1] - As[0] + 1 << endl;
      |                   ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int A,Z;
  for (int i = 0; i < s.size(); i++){
    if (s[i]=='A'){
      A = i;
      break;
    }
  }
  for (int i = s.size - 1; i >= 0; i--){
    if (s[i]=='Z'){
      Z = i;
      break;
    }
  }
  cout << Z-A+1;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   13 |   for (int i = s.size - 1; i >= 0; i--){
      |                ~~^~~~
      |                      ()
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char s[200001];
    cin >> s;
 	
  	int len = strlen(s)
    int a_idx, z_idx;
 
    for(int i = 0; i < len; ++i){
 
        if(s[i] == 'A'){
            a_idx = i;
            break;
        }
    }
 
    for(int i = 0; i < len; ++i){
 
        if(s[i] == 'Z'){
            z_idx = i;
        }
    }
 
    cout << z_idx - a_idx + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: expected ',' or ';' before 'int'
    9 |     int a_idx, z_idx;
      |     ^~~
a.cc:14:13: error: 'a_idx' was not declared in this scope
   14 |             a_idx = i;
      |             ^~~~~
a.cc:22:13: error: 'z_idx' was not declared in this scope
   22 |             z_idx = i;
      |             ^~~~~
a.cc:26:13: error: 'z_idx' was not declared in this scope
   26 |     cout << z_idx - a_idx + 1 << endl;
      |             ^~~~~
a.cc:26:21: error: 'a_idx' was not declared in this scope
   26 |     cout << z_idx - a_idx + 1 << endl;
      |                     ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    char s[200001];
    cin >> s;
 
    int a_idx, z_idx;
 
    for(int i = 0; i < s.length(); ++i){
 
        if(s[i] == 'A'){
            a_idx = i;
            break;
        }
    }
 
    for(int i = 0; i < s.length(); ++i){
 
        if(s[i] == 'Z'){
            z_idx = i;
        }
    }
 
    cout << z_idx - a_idx + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:26: error: request for member 'length' in 's', which is of non-class type 'char [200001]'
   10 |     for(int i = 0; i < s.length(); ++i){
      |                          ^~~~~~
a.cc:18:26: error: request for member 'length' in 's', which is of non-class type 'char [200001]'
   18 |     for(int i = 0; i < s.length(); ++i){
      |                          ^~~~~~
Language: Java

static Scanner sc = new Scanner(System.in);public static void main(String args[]){String s = sc.next();System.out.println(s.lastIndexOf('Z')-s.indexOf('A')+1);}}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
static Scanner sc = new Scanner(System.in);public static void main(String args[]){String s = sc.next();System.out.println(s.lastIndexOf('Z')-s.indexOf('A')+1);}}
       ^
  (use --enable-preview to enable unnamed classes)
Main.java:1: error: class, interface, enum, or record expected
static Scanner sc = new Scanner(System.in);public static void main(String args[]){String s = sc.next();System.out.println(s.lastIndexOf('Z')-s.indexOf('A')+1);}}
                                                                                                                                                                ^
2 errors
Language: C++

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    string s;
    cin >> s;

    int foundA = 0;
    int mini = 0;
    int maxi = 0;
    int length = s.length()
    for (int i = 0; i < length; i++)
    {
        if (s[i] == 'A' && foundA == 0)
        {
            mini = i;
            foundA = 1;
        }
        if (s[i] == 'Z')
        {
            maxi = i;
        }
    }
    cout << maxi - mini;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: expected ',' or ';' before 'for'
   14 |     for (int i = 0; i < length; i++)
      |     ^~~
a.cc:14:21: error: 'i' was not declared in this scope
   14 |     for (int i = 0; i < length; i++)
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s; cin >> s;
  int a, b; a = b = 0;
  for (int i = 0; i < N; i++) {
    if (s.at(i) = 'A') {
      a = i;
      break;
    }
  }
  for (int i = 0; i < N; i++) {
    if (s.at(s.size() - 1 - i) = 'Z') {
      b = i;
      break;
    }
  }
  cout << s.size() - a - b << endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:23: error: 'N' was not declared in this scope
    7 |   for (int i = 0; i < N; i++) {
      |                       ^
a.cc:13:23: error: 'N' was not declared in this scope
   13 |   for (int i = 0; i < N; i++) {
      |                       ^
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using std::cout;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int s;
  string s;
  int a=0,z =0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      a =i;
      break;
    }
  }
  for(int i=s.size()-1 ; i >=0 ; i--){
    if(s[i]=='Z'){
      z =i;
      break;
    }
  }
  cout << z-a+1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:10: error: conflicting declaration 'std::string s'
   39 |   string s;
      |          ^
a.cc:38:7: note: previous declaration as 'int s'
   38 |   int s;
      |       ^
a.cc:41:19: error: request for member 'size' in 's', which is of non-class type 'int'
   41 |   for(int i=0;i<s.size();i++){
      |                   ^~~~
a.cc:42:9: error: invalid types 'int[int]' for array subscript
   42 |     if(s[i]=='A'){
      |         ^
a.cc:47:15: error: request for member 'size' in 's', which is of non-class type 'int'
   47 |   for(int i=s.size()-1 ; i >=0 ; i--){
      |               ^~~~
a.cc:48:9: error: invalid types 'int[int]' for array subscript
   48 |     if(s[i]=='Z'){
      |         ^
a.cc: In function 'int ab(int, int)':
a.cc:36:1: warning: control reaches end of non-void function [-Wreturn-type]
   36 | }
      | ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin>>s
  int numA,numZ;
  for(numA=0;;numA++){
    if(s[numA]=='A') break;
  }

  for(numZ=(int)s.size()-1;;numZ--){
    if(s[numZ]=='Z') break;
  }

  cout<<numZ-numA<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: expected ';' before 'int'
   17 |   cin>>s
      |         ^
      |         ;
   18 |   int numA,numZ;
      |   ~~~    
a.cc:19:7: error: 'numA' was not declared in this scope
   19 |   for(numA=0;;numA++){
      |       ^~~~
a.cc:23:7: error: 'numZ' was not declared in this scope
   23 |   for(numZ=(int)s.size()-1;;numZ--){
      |       ^~~~
a.cc:27:9: error: 'numZ' was not declared in this scope
   27 |   cout<<numZ-numA<<endl;
      |         ^~~~
a.cc:27:14: error: 'numA' was not declared in this scope
   27 |   cout<<numZ-numA<<endl;
      |              ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int a,z;
    if(n==1){printf("0"); return 0;}
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    for(int i=0;i<n;i++){
        if(s[i]=='Z'){
            z=i;
        }
    }
    printf("%d",z-a+1);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:8: error: 'n' was not declared in this scope
   10 |     if(n==1){printf("0"); return 0;}
      |        ^
a.cc:11:19: error: 'n' was not declared in this scope
   11 |     for(int i=0;i<n;i++){
      |                   ^
a.cc:17:19: error: 'n' was not declared in this scope
   17 |     for(int i=0;i<n;i++){
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

string s;

int main () {
  cin >> s;
  int number_a = 0, number_b = 0;
  for (int i = 0; i < s.length(); i++){
    if (s[i] == 'A'){
      number_a = i;
      break;
    }
  }
  for (int i = s.length(); i>=0; i--){
    if (s[i] == 'Z'){
      number_z = i;
      break;
    }
  }
  cout << number_z - number_a + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'number_z' was not declared in this scope; did you mean 'number_b'?
   17 |       number_z = i;
      |       ^~~~~~~~
      |       number_b
a.cc:21:11: error: 'number_z' was not declared in this scope; did you mean 'number_b'?
   21 |   cout << number_z - number_a + 1 << endl;
      |           ^~~~~~~~
      |           number_b
Language: C++

#include<iostream>
#include<string>
using namespace std;
index_a=0, index_z=0;
int main(){
  string s;cin>>s;
  for(int i=0;i<s.size();i++){if(s[i]=='A'){index_a=i;break;}}
  for(int i=0;i<s.size();i++){if(s[i]=='Z')index_z=i;}
  cout<<index_z-index_a+1<<endl;
}

Compiler output:
a.cc:4:1: error: 'index_a' does not name a type
    4 | index_a=0, index_z=0;
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:45: error: 'index_a' was not declared in this scope
    7 |   for(int i=0;i<s.size();i++){if(s[i]=='A'){index_a=i;break;}}
      |                                             ^~~~~~~
a.cc:8:44: error: 'index_z' was not declared in this scope
    8 |   for(int i=0;i<s.size();i++){if(s[i]=='Z')index_z=i;}
      |                                            ^~~~~~~
a.cc:9:9: error: 'index_z' was not declared in this scope
    9 |   cout<<index_z-index_a+1<<endl;
      |         ^~~~~~~
a.cc:9:17: error: 'index_a' was not declared in this scope
    9 |   cout<<index_z-index_a+1<<endl;
      |                 ^~~~~~~