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

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
 
  int main(){
 lint N,ans=0,a=0,b=0,count=0;
 string s;
 cin >>N;
    rep(i,N){
        cin>>s;
        if(s[0]=='B'&&s[s.size()-1]=='A'){
            count++;
        }
        rep(j,s.size()-1){
            if(j==0&&s[j]=='B')b++;
             if(j==(s.size()-2)&&s[j+1]=='A')a++;
            if(s[j]=='A'&&s[j+1]=='B')ans++;
          
        }
     
    }
    ans+=min(a,b);
  if(a+b>0)ans+=count;
  if(a+b==0)ans+=count-1
    cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:25: error: expected ';' before 'cout'
   82 |   if(a+b==0)ans+=count-1
      |                         ^
      |                         ;
   83 |     cout<<ans;
      |     ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}

int main(){
	int n;
	cin >>n;	
	vector<string>s(n+1,"");
	int both=0;
	int A=0;
	int B=0;
	int flag=0;
	int ans=0;
	char last='\0';
	for(int i=0;i<n;i++){
		flag=0;
		last='\0';
		cin >>s[i];
		for(int j=0;j<s[i].size();j++){
			if(j==0 and s[i].at(j)=='B'){
				flag+=1;
			}
			if(j==s[i].size()-1 and s[i].at(j)=='A'){
				flag+=2;
			}
			if(last =='A' and s[i].at(j)=='B'){
				ans++;
			}
			last=s[i].at(j);
		}
		switch(flag){
			case 1:
			B++;
			break;
			case 2:
			A++;
			break;
			case 3:
			A++;
			B++;
			both++;
			break;
		}

	}
//	cout<<ans<<endl;
	if(both==A and both==B){
		A--;
	}
	ans+=min(n-1,(min(A,B));
	//cout<<both<<" "<<A<<" "<<B<<" ";
	cout <<ans<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:32: error: expected ')' before ';' token
   55 |         ans+=min(n-1,(min(A,B));
      |                 ~              ^
      |                                )
Language: C++

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
#define and && 
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n;
  cin >> n;
  vector<string>v(n);
  rep(i,n)cin >> v[i];
  vector<int>count_EA,count_FB;
  ll ans = 0;
  ll tmp = 0;
  rep(i,n){
    int s = v[i].size();
    if(v[i][s - 1] == 'A')count_EA.push_back(i);
    if(v[i][0] == 'B')count_FB.push_back(i);
    if(v[i][0] == 'B' and v[i][s - 1] == 'A')tmp++;
    rep(j,s - 1){
      if(v[i].substr(j,2) == "AB")ans++;
    }
  }
  if(tmp == count_EA.size() and count_FB.size() == tmp){
    cout << ans + min(count_EA.size(),count_FB.size()) - 1<< endl;
    return 0;
  }
  cout << ans + min(count_EA.size(),count_FB.size()) << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Compiler output:
a.cc:8:9: error: "and" cannot be used as a macro name as it is an operator in C++
    8 | #define and &&
      |         ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    vector<string> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int ret = 0;
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < vec[i].size() - 1;j++) {
            if(vec[i].at(j) == 'A' && vec[i].at(j + 1) == 'B') {
                ret++;
            }
        }
    }
    int A = 0;
    int B = 0;
    int C = 0;
    for(int i = 0;i < N;i++) {
        if(vec[i].at(0) == 'B' && vec[i].at(vec[i].size() - 1) == 'A') {
            A++;
        }
        else if(vec[i].at(0) != 'B' && vec[i].at(vec[i].size() - 1) == 'A') {
            B++;
        }
        else if(vec[i].at(0) == 'B' && vec[i].at(vec[i].size() - 1) != 'A') {
            C++;
        }
    }
    if(A == 0) {
        ret += min(B,C);
    }
    else {
        if(B + C > 0) {
            ret += A + min(B + C);
        }
        else {
            ret += A - 1;
        }
    }
    cout << ret << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:27: error: no matching function for call to 'min(int)'
   44 |             ret += A + min(B + C);
      |                        ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:44:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   44 |             ret += A + min(B + C);
      |                        ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

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

int main() {
  int n;
  cin >> n;
  int nab=0,nea=0,nfb=0,eafb=0;
  for(int i=0;i<n;i++) {
    string s;
    cin >> s;
    if(*s.begin()=="B"&&*s.end()!="A") nfb++;
    if(*s.begin()!="B"&&*s.end()=="A") nea++;
    if(*s.begin()=="B"&&*s.end()=="A") eafb++;
    for(int j=0;j<s.size()-1;j++) {
      if(s.substr(j,2)=="AB") nab++;
    }
  }
  int temp;
  if(nea+nfb==0) {
    temp=max(eafb-1,0);
  }
  else {
    temp=eafb+min(nea,nfb);
  }
  cout << nab + temp << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 |     if(*s.begin()=="B"&&*s.end()!="A") nfb++;
      |        ~~~~~~~~~~^~~~~
a.cc:11:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 |     if(*s.begin()=="B"&&*s.end()!="A") nfb++;
      |                         ~~~~~~~~^~~~~
a.cc:12:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |     if(*s.begin()!="B"&&*s.end()=="A") nea++;
      |        ~~~~~~~~~~^~~~~
a.cc:12:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |     if(*s.begin()!="B"&&*s.end()=="A") nea++;
      |                         ~~~~~~~~^~~~~
a.cc:13:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if(*s.begin()=="B"&&*s.end()=="A") eafb++;
      |        ~~~~~~~~~~^~~~~
a.cc:13:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if(*s.begin()=="B"&&*s.end()=="A") eafb++;
      |                         ~~~~~~~~^~~~~
Language: C++

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

int main() {
  int n;
  cin >> n;
  int nab=0,nea=0,nfb=0,eafb=0;
  for(int i=0;i<n;i++) {
    string s;
    cin >> s;
    if(s[0]=='B'&&) nfb++;
    if(s[s.size()-1]=='A') nea++;
    if(s[0]=='B'&&s[s.size()-1]=='A') eafb=1;
    for(int j=0;j<s.size()-1;j++) {
      if(s.substr(j,2)=="AB") nab++;
    }
  }
  cout << nab + min(nea,nfb)-eafb << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: expected primary-expression before ')' token
   11 |     if(s[0]=='B'&&) nfb++;
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,ans=0; cin>>N;
  int a=0,b=0,c=0;
  rep(_,0,N){
    string S; cin>>S;
    rep(i,1,S.size()){
      if(S[i]=='B'&&S[i-1]=='A')
        ans++;
    }
    if(S[S.size()-1]=='A'){
      if(S[0]=='B')
        c++;
      a++;
    }
    if(S[0]=='B')
      b++;
  }
  int K=min(a,b);
  if(A==B&&B==C)
    K--;
  cout<<ans+K<<endl;
  }




Compiler output:
a.cc: In function 'int main()':
a.cc:33:6: error: 'A' was not declared in this scope
   33 |   if(A==B&&B==C)
      |      ^
a.cc:33:9: error: 'B' was not declared in this scope
   33 |   if(A==B&&B==C)
      |         ^
a.cc:33:15: error: 'C' was not declared in this scope
   33 |   if(A==B&&B==C)
      |               ^
Language: C++

/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0,A=0,B=0;
  bool BA=false;
  cin>>n;
  vector<string> v(n);
  rep(i,n) cin>>v[i];
  rep(i,n){
    if(v[i][0]=='B') B++;
    if(v[i][v[i].size()-1]=='A') A++;
    if(v[i][0]=='B' && v[i][v[i].size()-1]=='A') BA=true;
    ans+=count(ALL(s[i]),"AB");
  }
  if(A==B && BA){
    cout<<ans+A-1<<endl;
  }else{
    cout<<ans+min(A,B)<<endl;
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:135:20: error: 's' was not declared in this scope
  135 |     ans+=count(ALL(s[i]),"AB");
      |                    ^
a.cc:9:18: note: in definition of macro 'ALL'
    9 | #define ALL(a)  (a).begin(),(a).end()
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
ll N;

ll count(const string& s)
{
    ll res = 0;
    rep(i, s.size()-1) {
        if (s[i] == 'A' && s[i+1] == 'B') {
            ++res;
        }
    }
    return res;
}

signed main()
{
    cin >> N;
    ll a = 0, b = 0, c = 0, cnt = 0;
    rep(i, N)
    {
        string s;
        cin >> s;
        cnt += count(s);
        if (s.front() == 'B' && s.back() == 'A') {
            ++a;
        } else if (s.back() == 'A') {
            ++b;
        } else if (s.front() == 'B') {
            ++c;
        }
        ll add = 0;
        if (b + c == 0) {
            add = max(0, a - 1);
        } else {
            add = a + min(b, c);
        }
        cnt += add;
        cout << cnt << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:22: error: no matching function for call to 'max(int, ll)'
   41 |             add = max(0, a - 1);
      |                   ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:41:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   41 |             add = max(0, a - 1);
      |                   ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:41:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |             add = max(0, a - 1);
      |                   ~~~^~~~~~~~~~
Language: C++

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

int main(){
  int n; cin>>n;
  string s="";
  int ba=0,a=0,b=0;
  for(int i=0;i<n;i++){
    string t; cin>>t;
    if(t[0]=='B' && t[t.size()-1]=='A'){
      t=t.substr(1,t.size()-2);
      ba++;
    }else if(t[0]=='B'){
      t=t.substr(1,t.size()-1);
      b++;
    }else if(t[t.size()-1]=='A'){
      t=t.substr(0,t.size()-1);
      a++;
    }
    s+=t;
  }
  int ans=0;
  if(ab>0){
    ans+=ab-1;
    if(a>0){
      a--; ans++;
    }if(b>0){
      b--; ans++;
    }
  }
  ans+=min(a,b);
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      i++;
      if(i!=s.size()){
        if(s[i]=='B'){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:6: error: 'ab' was not declared in this scope; did you mean 'b'?
   23 |   if(ab>0){
      |      ^~
      |      b
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef struct binode{
    char data;
    struct binode *lchild,*rchild;
}binode,*bitree;
bitree T;
typedef struct stacknode{
    bitree data;
    struct stacknode *next;
}stacknode,*linkstack;
linkstack st,p;
//ABD##E##CF#G###
void initstack(linkstack &st){
    st=NULL;
    return ;
}
void push(linkstack &st,bitree e)
{
    p=new stacknode;
    p->data=e;
    p->next=st;
    st=p;
    return ;
}
void pop(linkstack &st,bitree &e){
    if(st==NULL){
        cout<<"栈内元素为空,删除无效"<<endl;
        return ;
    }
    e=st->data;
    p=st;
    st=st->next;
    free(p);
    return;
}
bitree gettop(linkstack st){
    if(st!=NULL)    return st->data;
}
bool stack_empty(linkstack st){
    if(st==NULL) return 1;
    return 0;
}
void creatbitree(bitree &T){
    char c;
    cin>>c;
    if(c=='#') T=NULL;
    else {
        T=new binode;
        T->data=c;
        creatbitree(T->lchild);
        creatbitree(T->rchild);
    }
}
void preorderdfs(bitree T){
    if(T==NULL) return ;
    else {
        cout<<T->data<<" ";
        preorderdfs(T->lchild);
        preorderdfs(T->rchild);
    }
}
void inorderdfs(bitree T){
    if(T==NULL) return ;
    else {
        inorderdfs(T->lchild);
        cout<<T->data<<" ";
        inorderdfs(T->rchild);
    }
}
void postorderdfs(bitree T){
    if(T==NULL) return ;
    else {
        postorderdfs(T->lchild);
        postorderdfs(T->rchild);
        cout<<T->data<<" ";
    }

}
void preorder(bitree T){
    linkstack stpre;
    initstack(stpre);
    bitree t1,q;
    t1=T;
    q=new binode;
    while(t1||!stack_empty(stpre)){
        if(t1){
            push(stpre,t1);
            cout<<t1->data<<" ";
            t1=t1->lchild;
        }
        else {
            pop(stpre,q);
            t1=q->rchild;
        }
    }
}

void inorder(bitree T){
    linkstack stin;
    initstack(stin);
    bitree p,q;
    p=T;
    q=new binode;
    while(p||!stack_empty(stin)){
        if(p){
            push(stin,p);
            p=p->lchild;
        }
        else {
            pop(stin,q);
            cout<<q->data<<" ";
            p=q->rchild;
        }
    }
}
void postorder(bitree T){
    linkstack stpost;
    initstack(stpos);
    bitree p,q;
    p=T;
    q=new binode;
    while(p||!stack_empty(stpost)){
        if(p){
            push(stpost,p);
            p=p->lchild;
        }
        
    }
    
}


int main()
{
    //创建二叉树
    creatbitree(T);
//    preorderdfs(T);
//    inorderdfs(T);
//    cout<<endl;
//    postorderdfs(T);
//    inorder(T);
//    preorder(T);

    return 0;
}


Compiler output:
a.cc: In function 'void postorder(bitree)':
a.cc:119:15: error: 'stpos' was not declared in this scope; did you mean 'stpost'?
  119 |     initstack(stpos);
      |               ^~~~~
      |               stpost
a.cc: In function 'binode* gettop(linkstack)':
a.cc:39:1: warning: control reaches end of non-void function [-Wreturn-type]
   39 | }
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

int main(){
    cin >> n;
    ll ans = 0;
    int A = 0,B = 0,BA = 0;
    rep(i,n){
        string s;
        cin >> s;
        rep(j,s.size()-1){
            if(s[j] == 'A' && s[j+1] == 'B')ans++;
        }
        if(s[0] == 'B' && s.back() == 'A')BA++;
        else if(s[0] == 'B')B++;
        else if(s.back() == 'A')A++;
    }
    ll ans = 0;
    if(BA != 0){
        ans += BA - 1;
        if(A > 0){
            ans++;
            A--;
        }
        if(B > 0){
            ans++;
            B--;
        }
    }
    ans += min(A,B);
    cout << ans << endl;        
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:8: error: redeclaration of 'll ans'
   45 |     ll ans = 0;
      |        ^~~
a.cc:33:8: note: 'll ans' previously declared here
   33 |     ll ans = 0;
      |        ^~~
Language: C++

/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

    vector<string> s(n);

    for(int i = 0; i < n; i++) cin >> s[i];

    ll abcnt = 0;
    ll afin = 0;
    ll bsta = 0;

    for(int i = 0; i < n; i++){
        if(s[i][s[i].size() - 1] == 'A'){
            afin++;
        }
        if(s[i][0] == 'B'){
            bsta++;
        }
        for(int j = 1; j < s[i].size(); j++){
            if(s[i][j - 1] == 'A' && s[i][j] == 'B'){
                abcnt++;
            }
        }
    }

    if(afin == n){
        afin--;
    }

    if(bfin == n){
        bsta--;
    }

    cout << abcnt + min(afin, bsta) << endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:94:8: error: 'bfin' was not declared in this scope; did you mean 'afin'?
   94 |     if(bfin == n){
      |        ^~~~
      |        afin
Language: C++

/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

    vector<string> s(n);

    for(int i = 0; i < n; i++) cin >> s[i];

    ll abcnt = 0;
    ll afin = 0;
    ll bsta = 0;

    for(int i = 0; i < n; i++){
        if(s[i][s[i].size() - 1] == 'A'){
            afin++;
        }
        if(s[i][0] == 'B'){
            bsta++;
        }
        for(int j = 1; j < s[i].size(); j++){
            if(s[i][j - 1] == 'A' && s[i][j] == 'B'){
                abcnt++;
            }
        }
    }

    if(afin == n){
        afin--:
    }

    if(bfin == n){
        bsta--;
    }

    cout << abcnt + min(afin, bsta) << endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:91:15: error: expected ';' before ':' token
   91 |         afin--:
      |               ^
      |               ;
a.cc:94:8: error: 'bfin' was not declared in this scope; did you mean 'afin'?
   94 |     if(bfin == n){
      |        ^~~~
      |        afin
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] s = new String[n];
    int start = 0;
    int last = 0;
    int both = 0;
    int cnt = 0;
    for(int i = 0;i < n;i++){
      s[i]=sc.next();
      if(s[i].contains("AB"))cnt++;
      if(s[i].charAt(0)=='B'&&s[i].charAt(s[i].length()-1)=='A')both++;
      else if(s[i].charAt(0)=='B')start++;
      else if(s[i].charAt(s[i].length()-1)=='A')last++;
    }
    ccnt+=both+Math.min(start,last);
    System.out.println(cnt);
  }
}


Compiler output:
Main.java:18: error: cannot find symbol
    ccnt+=both+Math.min(start,last);
    ^
  symbol:   variable ccnt
  location: class Main
1 error
Language: C

#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define REPR(i, n) for(int i = int(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

int main() {
    int n; cin >> n;
    int cnt = 0;
    int cntA = 0, cntB = 0;
    bool onlyA = false, onlyB = false;
    REP(i, n) {
        string s; cin >> s;
        REP(j, s.size()-1) {
            if (s[j] == 'A' && s[j + 1] == 'B') cnt++;
        }
        if (s[0] == 'B') cntB++;
        if (s[s.size() - 1] == 'A') cntA++;
        if (s[0] == 'B' && s[s.size() - 1] != 'A') onlyB = true;
        if (s[0] != 'B' && s[s.size() - 1] == 'A') onlyA = true;
    }
    if (!onlyA) cntB--;
    if (!onlyB) cntA--;
    cout << cnt + min(cntA, cntB) << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include "bits/stdc++.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
//

int N;
vector<string> S;

int count(const string &str) {
    int res = 0;
    for (int i = 0; i+1 < str.size(); ++i) {
        if (str[i] == 'A' && str[i+1] == 'B'){
            ++res;
        }
    }
    return res;
}

long long solve() {
    long long res = 0;
    for (int i = 0; i < N; ++i) res += count(S[i]);

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i][0] == 'B' && S[i].back() == 'A') ++a;
        else if (S[i].back() == 'A') ++b;
        else if (S[i][0] == 'B') ++c;
    }
    long long add = 0;
    if (b + c == 0) add = max(0, a-1);
    else add = a + min(b, c);

    res += add;
    return res;
}


int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N;
    S.resize(N);
    for (int i = 0; i < N; ++i) cin >> S[i];
    cout << solve() << endl;

    cout << ans << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   56 |     cout << ans << '\n';
      |             ^~~
      |             abs
Language: C++

class diverta2019C:
    def __init__(self):
        self.N = int(input())
        self.s = [input() for i in range(self.N)]
        self.ans = 0
    
    def solve(self):
        a, b = 0, 0
        for i in range(self.N):
            if(self.s[i].count('AB')):
                self.ans += self.s[i].count('AB')
            if(self.s[i][-1] == 'A'):
                a += 1
            if(self.s[i][0] == 'B'):
                b += 1
        self.ans += min(a, b)
        print(self.ans)

if __name__ == '__main__':
    problem = diverta2019C()
    problem.solve()

Compiler output:
a.cc:10:32: warning: multi-character character constant [-Wmultichar]
   10 |             if(self.s[i].count('AB')):
      |                                ^~~~
a.cc:11:45: warning: multi-character character constant [-Wmultichar]
   11 |                 self.ans += self.s[i].count('AB')
      |                                             ^~~~
a.cc:19:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   19 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:2:9: error: expected class-name before '__init__'
    2 |     def __init__(self):
      |         ^~~~~~~~
a.cc:2:9: error: expected '{' before '__init__'
a.cc:2:18: error: 'self' was not declared in this scope
    2 |     def __init__(self):
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
string s[10100];
int main()
{
     int n;
     cin>>n;
     int couts=0;
     int a=0;
     int b=0;
     int c=0;
     for(int i=0;i<n;i++)
     {
          cin>>s[i];
          int len=s[i].size();
         if(s[i][0]=='B'&&s[i][len-1]=='A')
           c++;
           else if(s[i][0]=='B')
            b++;
           else if(s[i][len-1]=='A')
            a++;
            for(int j=0;j<len-1;j++)
            {

                if(s[i][j]=='A'&&s[i][j+1]=='B')
                    couts++;
            }
     }
  //  cout<<couts<<endl;
  //  cout<<a<<' '<<b<<' '<<c<<endl;
      if(c>=a)
      {
          if(a==0)
          {
              if(b==0)
                ans+=c-1;
              else
                ans+=max(c-1+1,min(c,b));
          }
          else
          {
              ans+=(a);
               if(b==0)
                ans+=c-2;
               else
                ans+=max(c-2+1,min(c,b));
          }
      }
      else
      {
           couts+=c;
          couts+=min(b,a);
      }
      cout<<couts<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |                 ans+=c-1;
      |                 ^~~
      |                 abs
a.cc:38:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   38 |                 ans+=max(c-1+1,min(c,b));
      |                 ^~~
      |                 abs
a.cc:42:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |               ans+=(a);
      |               ^~~
      |               abs
Language: C++

#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  V<string> s(n);
  REP(i, n) cin >> s.at(i);
  ll ans = 0, ea = 0, sb = 0;
  REP(i, n) {
    rep(si, 1, s.at(i).size()) {
      if (s.at(i).at(si-1) == 'A' && s.at(i).at(si) == 'B') ans++;
    }
    if (s.at(i).at(0) == 'B') sb++;
    if (s.at(i).at(s.at(i).size()-1) == 'A') ea++;
  }
  if (ea == sb && ea == n) ea--;
  cout << ans + min(ea, sb) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'cin' was not declared in this scope
   22 |   ll n; cin >> n;
      |         ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    5 | #include <utility>
  +++ |+#include <iostream>
    6 | using namespace std;
a.cc:34:3: error: 'cout' was not declared in this scope
   34 |   cout << ans + min(ea, sb) << endl;
      |   ^~~~
a.cc:34:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:34:32: error: 'endl' was not declared in this scope
   34 |   cout << ans + min(ea, sb) << endl;
      |                                ^~~~
a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    5 | #include <utility>
  +++ |+#include <ostream>
    6 | using namespace std;
Language: C++

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

int main(){
    int N, ab{}, a{}, b{};
    cin >> N;
    vector<string> s(N);
    for(int i{}; i<N; i++){
        cin >> s.at(i);
        for(int j{}; j<s.at(i).size()-1; j++){
            if(s.at(i).at(j) == 'A' && s.at(i).at(j+1) == 'B'){
                ab ++;
            }
        }
        if(s.at(i).at(0) == 'B'){
            b ++;
        }
        if(s.at(i).at(s.at(i).size()-1) == 'A'){
            a ++;
        }
    }
    int sum = min(a, b) + ab;
    if(a==b) sum --
    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: expected ';' before 'cout'
   23 |     if(a==b) sum --
      |                    ^
      |                    ;
   24 |     cout << sum << endl;
      |     ~~~~
Language: C++

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

int main(){
  int n; cin>>n;
  int ab=0,a=0,b=0;
  for(int i=0;i<n;i++){
    string s; cin>>s;
    int l=s.length();
    for(int j=0;j<l-1;j++){
      string t=s.substr(j,2);
      if(t=="AB")ab++;
    }
    if(s[l-1]=='A')a++;
    if(s[0]=='B')b++;
  }
  cout<<ab+min(a,b)<<endl;
}

Compiler output:
a.cc:1:23: error: missing terminating > character
    1 | #include<bits/stdc++.h
      |                       ^
Language: C

#include <stdio.h>
#include <string.h>

int main( int argc , char *argv[] )
{
  char buf[20];
  int n;
  int i;
  int ans = 0;
  
  int inner = 0;
  int lastA = 0;
  int firstB = 0;
  int AXB = 0;
  
  scanf( "%d\n" , &n );
  
  for( i = 0 ; i < n ; i++ ) {
    int l,j;
    
    scanf( "%s\n" , buf );
    l = strlen( buf );
    
    if( buf[0] == 'B' && buf[l-1] == 'A' ) {
      AXB++;
    } else if( buf[0] = 'B' ) {
      firstB++;
    } else if( buf[l-1] == 'A' ) {
      lastA++;
    }
    
    for( j = 0 ; j < l-1 ; j++ ) {
      if( buf[j] == 'A' && buf[j+1] =='B' ) {
        inner++;
      }
    }
  }
  
  ans = inner;
  
  if( lastA > firstB ) {
    ans += firstB;
    lastA -= firstB;
    firstB = 0;
  } else {
    ans += lastA;
    firstB -= lastA;
    lastA = 0;
  }
  
  ans += AXB;
  
  if( lastA != 0 || firstB != 0 ) {
    ans++;
  }
  
  pritnf( "%d\n" , ans );
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:57:3: error: implicit declaration of function 'pritnf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   57 |   pritnf( "%d\n" , ans );
      |   ^~~~~~
      |   printf
Language: C++

#include <iosteam>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s[n];
  int ans = 0,a=0,b=0,w=0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    for(int j=0;j<s[i].length()-1;j++){
      if(s[i][j]=='A'&&s[i][j+1]=='B'){
        ans++;
      }
    }
    if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A') w++;
    else if(s[i][0]=='B') b++;
    else if(s[i][s[i].length()-1]=='A') a++;
  }
  cout << ans+min(a+w,b+w) << endl;
}

Compiler output:
a.cc:1:10: fatal error: iosteam: No such file or directory
    1 | #include <iosteam>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
    int N;
    cin >> N;
    string s[N];
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    int count = 0;
    int b_count = 0;
    int a_count = 0;
    int ba_count = 0;
    for(int j = 0; j < N; j++){
        for(int i = 0; i < s[j].size() - 1; i++){
            if(s[j].substr(i, 2) == "AB"){
                count++;
            }
        }
        if(s[j].find_first_of('B') == 0){
                b_count++;
        }
        if(s[j].find_last_of('A') == s[j].size() - 1){
                a_count++;
        }
        if(s[j].find_first_of('B') == 0 && s[j].find_last_of('A') == s[j].size() - 1){
                ba_count++;
        }
    }

    if(b_count == ba_count && a_count == ba_count && ba_count != 0){
        count += a-1;
    }else{
        count = count + min(b_count, a_count);
    }

    cout << count << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:18: error: 'a' was not declared in this scope
   34 |         count += a-1;
      |                  ^
Language: C++

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

vector<string> a,b,c,d;
string ans;

int main() {
  int n;
  cin >> n;
  for(int i = 1 ; i <= n ; ++i) {
    string s;
    cin >> s;
    int x = s[0],y = s[s.size()-1];
    if(x != 'B' && y != 'A') a.push_back(s);
    if(x != 'B' && y == 'A') b.push_back(s);
    if(x == 'B' && y != 'A') c.push_back(s);
    if(x == 'B' && y == 'A') d.push_back(s);
  }
  for(auto v : a) ans += v;
  if(b.size()) {
    ans += b[b.size()-1];
    b.pop_back();
  }
  for(auto v : d) ans += v;
  if(c.size()) {
    ans += c[c.size()-1];
    c.pop_back();
  }
  while(b.size() || c.size()) {
    ans += b[b.size()-1];
    b.pop_back();
    ans += c[c.size()-1];
    c.pop_back();
  }
  for(auto v : b.size()) ans += v;
  for(auto v : c.size()) ans += v;
  int tot = 0;
  for(int i = 0 ; i < ans.size()-1 ; ++i) 
    if(ans[i] == 'A' && ans[i+1] == 'B')
      ++tot;
  cout << tot << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:23: error: 'begin' was not declared in this scope
   35 |   for(auto v : b.size()) ans += v;
      |                       ^
a.cc:35:23: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:35:23: error: 'end' was not declared in this scope
   35 |   for(auto v : b.size()) ans += v;
      |                       ^
a.cc:35:23: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:36:23: error: 'begin' was not declared in this scope
   36 |   for(auto v : c.size()) ans += v;
      |                       ^
a.cc:36:23: note: suggested alternatives:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:36:23: error: 'end' was not declared in this scope
   36 |   for(auto v : c.size()) ans += v;
      |                       ^
a.cc:36:23: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int count(const string &S) {
    int res = 0;
    for (int i = 0; i + 1 < S.size(); ++i) {
        if (S[i] == 'A' && S[i + 1] == 'B' ++res);
    }
    return res;
}

int N;
vector<string> S;

ll solve() {
    ll res = 0;
    for (int i = 0; i < N; i++) res += count(S[i]);

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < N; i++) {
        if (S[i][0] == 'B' && S[i].back() == 'A') ++a;
        else if(S[i].back() == 'A') ++b;
        else if(S[i][0] == 'B') ++c;
    }
    ll add = 0;
    if (b + c == 0) add = max(0, a - 1);
    else add = a + min(b, c);

    res += add;
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    while(cin >> N) {
        S.resize(N);
        for (int i = 0; i < N; i++) cin >> S[i];
        cout << solve() << endl;
    }
}

Compiler output:
a.cc: In function 'int count(const std::string&)':
a.cc:44:40: error: lvalue required as increment operand
   44 |         if (S[i] == 'A' && S[i + 1] == 'B' ++res);
      |                                        ^~~
a.cc:44:46: error: expected ')' before 'res'
   44 |         if (S[i] == 'A' && S[i + 1] == 'B' ++res);
      |            ~                                 ^~~
      |                                              )
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	string s[n];
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	
	int frontB = 0, backA = 0, insideAB = 0;
	
	for(int i = 0; i < n; i++) {
		if(*begin(s[i]) == 'B') frontB++;
		if(*(end(s[i])-1) == 'A') backA++;
		
		if(s[i].length < 2) break;
		for(auto itr = begin(s[i]); itr != end(s[i]); itr++) {
			if(*itr == 'A' && *(itr+1) == 'B') insideAB++;
		}
	}
	
	int combinedAB = min(frontB, backA);
	if(combinedAB >= n) combinedAB = n-1;
	
	cout << insideAB + combinedAB << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: 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 '()' ?)
   18 |                 if(s[i].length < 2) break;
      |                    ~~~~~^~~~~~
      |                               ()
Language: C++

#include<bits/stdc++.h>

using namespace std;

string s[114514];
int n;
int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> s[i];
  
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j+1<s[i].size();j++){
	  if (s[i][j]=='A' && s[i][j+1]=='B') ans++;  
    }
  }
  
  int cnt_a = 0, cnt_b = 0, cnt_ba = 0;
  for(int i=0;i<n;i++){
    if (s[i][0]=='B' && s[i][s[i].size()-1]=='A') cnt_ba++;
    else if (s[i][0]=='B') cnt_b++;
    else if (s[i][s[i].size()-1]=='A') cnt_a++;
  }
  
  ans += min(cnt_a, cnt_b) + cnt_ab;
  if (cnt_a==0 && cnt_b==0) ans--;
  cout << ans << endl;  
  
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:30: error: 'cnt_ab' was not declared in this scope; did you mean 'cnt_ba'?
   25 |   ans += min(cnt_a, cnt_b) + cnt_ab;
      |                              ^~~~~~
      |                              cnt_ba
Language: C++

def count(a):
    k = 0
    for i in range(len(a)-1):
        if a[i]=='A' and a[i+1]=='B':
            k = k+1
    return k
def Substrings(n,S):   
    res = 0
    m = 0
    y = 0
    t = 0
    if list(set(S))==['BA']:
        return n-1 
    else:
        for i in range(len(S)):
            res = count(S[i]) + res
            if S[i][-1:]=='A':
                m = m+1
            if S[i][:1]=='B':
                y = y+1  
            return res+min(m,y)
    
n = int(input())
S = [input() for i in range(n)]
print(Substrings(n,S))

Compiler output:
a.cc:12:23: warning: multi-character character constant [-Wmultichar]
   12 |     if list(set(S))==['BA']:
      |                       ^~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def count(a):
      | ^~~
Language: C++

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

int main() {
	int x,y,z,n,a;
  	cin>>n;
  	x=y=z=a=0;
  	for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      int m = s.length();
      if (s[0]=='B' && s[m-1]=='A')
        z++;
      else if (s[0]=='B')
        x++;
      else if (s[m-1]=='A')
        y++;
      for (int j = 1; j < m; j++)
        if (s[j-1]=='A'&&s[j]=='B')
          a++;
    }
  	if (z) {
    	ans += z-1;
      	if (x) x--,a++;
      	if (y) y--,a++;
    }
  	cout << a + min(x,y) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |         ans += z-1;
      |         ^~~
      |         abs