criyle/codenet-compile-errors huggingface dataset:
Language: Java

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		//		String line = reader.readLine();
		String[] str = reader.readLine().split(" ");
		int[] ab = new int[str.length];
		for (int i = 0; i < str.length; i++) {
			ab[i] = Integer.parseInt(str[i]);
		}
		
		int ans = 0;
//		for (int r = 0; r <= ab[3]/ab[0]; r++)
//			for (int g = 0; g <= ab[3]/ab[1]; g++)
//				for (int b= 0; b <= ab[3]/ab[2]; b++) {
//					if (ab[0] * r + ab[1] * g + ab[2] * b == ab[3]) {
//						ans++;
//					}
//				}
		
//		for (int r = 0; r <= ab[3]/ab[0]; r++) {
//			if (ab[0] * r == ab[3]) {
//				ans++;
//				break;
//			}
//			for (int g = 0; g <= ab[3]/ab[1] - ab[0] * r; g++) {
//				if (ab[0] * r + ab[1] * g == ab[3]) {
//					ans++;
//					break;
//				}
//				for (int b= 0; b <= ab[3]/ab[2] - ab[0] * r - ab[1] * g; b++) {
//					if (ab[0] * r + ab[1] * g + ab[2] * b == ab[3]) {
//						ans++;
//					}
//				}
//			}
//		}
		
		
		for (int r = 0; r <= ab[3]/ab[0]; r++) {
			for (int g = 0; g <= (ab[3] - ab[0] * r)/ab[1]; g++) {
				for (int b= 0; b <= (ab[3] - ab[0] * r - ab[1] * g)/ab[2]; b++) {
					if (ab[0] * r + ab[1] * g + ab[2] * b == ab[3]) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Compiler output:
Main.java:3: error: cannot find symbol
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		^
  symbol:   class BufferedReader
  location: class Main
Main.java:3: error: cannot find symbol
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		                            ^
  symbol:   class BufferedReader
  location: class Main
Main.java:3: error: cannot find symbol
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		                                               ^
  symbol:   class InputStreamReader
  location: class Main
3 errors
Language: C++

#include <iostream>
using namespace std;

int main(){
  int R,G,B,N;
  cin >> R >> G >> B >> N;
  ans = 0;
  sumV = 0;
  for (int i=0; i<=R; ++i) {
    for (int j=0; j<=G; ++j) {
      for (int k=0; k<=B; ++k) {
        sumV = i*R + J*G + k*B;
        if (sumV == N) {
          ++ans;
        }
      }
    }
  }
  cout >> ans >> "\n";
  return 0;
}
        
  

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
    7 |   ans = 0;
      |   ^~~
      |   abs
a.cc:8:3: error: 'sumV' was not declared in this scope
    8 |   sumV = 0;
      |   ^~~~
a.cc:12:22: error: 'J' was not declared in this scope
   12 |         sumV = i*R + J*G + k*B;
      |                      ^
Language: C++

#include <iostream>
using namespace std;

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int sum = 0, c = 0;
	for (int i = 0; i <= n / r; i++) {
		sum += r * i;
		for (int j = 0; j <= n / g; j++) {
			sum += g * j;
			for (int k = 0; k <= n / b; k++) {
				sum += b : k;
				if (sum == n)
					c++;
				sum = 0;
			}
		}
	}
	cout << c;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:42: error: found ':' in nested-name-specifier, expected '::'
   13 |                                 sum += b : k;
      |                                          ^
      |                                          ::
a.cc:13:40: error: 'b' is not a class, namespace, or enumeration
   13 |                                 sum += b : k;
      |                                        ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
  int R, G, B, N;
  
  cin >> R >> G >> B >> N;

  /* R*r + G*g + B*b = N */
  int tem1 = N/R;
  int tem2 = N/G;
  int tem3 = N/B;

  int count = 0;

  for(int i = 0;i<=tem1;i++){
    for(int j = 0;i<=tem2;j++){
      for(int k = 0;i<=tem3;k++){
        if(N == (R*i + G*j + B*k){
          count++;
        }
      }
    }
  }

  cout << count << endl;
  
}



Compiler output:
a.cc: In function 'int main()':
a.cc:20:34: error: expected ')' before '{' token
   20 |         if(N == (R*i + G*j + B*k){
      |           ~                      ^
      |                                  )
a.cc:23:7: error: expected primary-expression before '}' token
   23 |       }
      |       ^
Language: C++

#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    long long int ctr =0 ;
    for(int i=0;i<=n/r+1;i++)
    {
        for(int j=0;j<=n/g+1;j++)
        {
            for(int k=0;k<=n/b+1;k++)
            {
                if(i*r+j*g+b*k==n)
                    ctr++;
            }
        }
    }
    cout<<ctr
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:14: error: expected ';' before '}' token
   57 |     cout<<ctr
      |              ^
      |              ;
   58 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
int r,g,b,n;
cin>>r>>g>>b>>n;
for(int i=0;i<n/r;i++){
for(int j=0;j<n/g;j++){
if(n-(I*r+j*g)%b==0){
counter++;
}
}
}
cout<<counter<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'I' was not declared in this scope
    8 | if(n-(I*r+j*g)%b==0){
      |       ^
a.cc:9:1: error: 'counter' was not declared in this scope
    9 | counter++;
      | ^~~~~~~
a.cc:13:7: error: 'counter' was not declared in this scope
   13 | cout<<counter<<endl;
      |       ^~~~~~~
Language: Java

import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int r = sc.nextInt();
        // スペース区切りの整数の入力
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();
        int ans = 0;
        //for文
        for(int i = 0; i < r; i++){
            for(int j = 0; i < g; i++){
                for(int k = 0; i < b; i++){
                    if(i+j+k == n) ans++
                }
            }
        }
        // 出力
        System.out.println(ans);

    }

}


Compiler output:
Main.java:20: error: ';' expected
                    if(i+j+k == n) ans++
                                        ^
1 error
Language: C++

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

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int count = 0;
	for (int r = 0; r < N / R + 1:r++) {
		for (int g = 0; g < N / G + 1:r++) {
			for (int b = 0; b < N / B + 1:r++) {
				if (N == r*R + g*G + b*B) {
					count++;
				}
			}
		}
	}
	cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:25: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
    8 |         for (int r = 0; r < N / R + 1:r++) {
      |                         ^
a.cc:8:38: error: expected ';' before ':' token
    8 |         for (int r = 0; r < N / R + 1:r++) {
      |                                      ^
      |                                      ;
a.cc:18:1: error: expected primary-expression before '}' token
   18 | }
      | ^
a.cc:17:31: error: expected ')' before '}' token
   17 |         cout << count << endl;
      |                               ^
      |                               )
   18 | }
      | ~                              
a.cc:8:13: note: to match this '('
    8 |         for (int r = 0; r < N / R + 1:r++) {
      |             ^
a.cc:18:1: error: expected primary-expression before '}' token
   18 | }
      | ^
Language: C++

 <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll R, G, B, N;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> R >> G >> B >> N;

  ll cnt = 0;
  for (ll r = 0; r <= N / R; r++) {
    ll rem = N - r * R;
    for (ll g = 0; g <= rem / G; g++) {
      ll rem2 = rem - g * G;
      if (rem2 % B == 0)  cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}



Compiler output:
a.cc:1:2: error: expected unqualified-id before '<' token
    1 |  <bits/stdc++.h>
      |  ^
a.cc: In function 'int main()':
a.cc:20:3: error: 'ios_base' has not been declared
   20 |   ios_base::sync_with_stdio(false);
      |   ^~~~~~~~
a.cc:23:3: error: 'cin' was not declared in this scope
   23 |   cin >> R >> G >> B >> N;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <cassert>
  +++ |+#include <iostream>
    3 | typedef long long int ll;
a.cc:33:3: error: 'cout' was not declared in this scope
   33 |   cout << cnt << endl;
      |   ^~~~
a.cc:33:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:33:18: error: 'endl' was not declared in this scope
   33 |   cout << cnt << endl;
      |                  ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <cassert>
  +++ |+#include <ostream>
    3 | typedef long long int ll;
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int n = sc.nextInt();
    int ans = 0;
    for(int i = 0; i <= Max.min(r, n); i++) {
      for(int j = 0; j <= Max.min(g, n); j++) {
        if((n - i - j) <= b) ans++;
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:11: error: cannot find symbol
    for(int i = 0; i <= Max.min(r, n); i++) {
                        ^
  symbol:   variable Max
  location: class Main
Main.java:12: error: cannot find symbol
      for(int j = 0; j <= Max.min(g, n); j++) {
                          ^
  symbol:   variable Max
  location: class Main
2 errors
Language: C++

#include <iostream>

int main()
{
    int r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;
    for (int i = 0; i <= n / r; i++)
    {
        for (int j = 0; j <= n / g; j++)
        {
            for (int k = 0; k <= n / b; k++)
            {
                if (i * r + j * g + k * b == n)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |     cin >> r >> g >> b >> n;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:20:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |     cout << ans << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:20:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   20 |     cout << ans << endl;
      |                    ^~~~
      |                    std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, a = 0, b = 0;
    long long ans = 0
    cin >> len;
    for(int i = 0; i < len; i++) {
        string s;
        cin >> s;
        int l = s.length();
        for(int j = 0; j < l - 1; j++) {
            if(s[j] == 'A' && s[j + 1] == 'B')
                ans++;
        }
        if(s[l - 1] == 'A')
            a++;
        if(s[0] == 'B')
            b++;
    }
    ans += min(a, b);
    if(min(a, b) == len)
        cout << ans - 1;
    else
        cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: expected ',' or ';' before 'cin'
   28 |     cin >> len;
      |     ^~~
Language: C++

#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;


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




Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[std::__cxx11::basic_string<char>::size_type {aka long unsigned int}]' for array subscript
   33 |     if(s[i][s.size()-1]=='A')a++;
      |            ^
Language: C++

#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;

int a;
int b;
int c;
int sum=0;
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        char s[11];
        cin>>s;
        int len=strlen(s);
        if(s[0]=='B'&&s[len-1]!='A')
        {
            b++;
        }
        if(s[0]!='B'&&s[len-1]=='A')
        {
            a++;
        }
        if(s[0]=='B'&&s[len-1]=='A')
        {
            c++;
        }
        for(int j=0; j<len-1; j++)
        {
            if(s[j]=='A'&&s[j+1]=='B')
            {
                sum++;
            }
        }
    }
     if(c)
    {
        sum+=c-1;
        if(a)a--,ans++;
        if(b)b--,ans++;
    }
    sum+=min(a,b);
    cout<<sum<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   58 |         if(a)a--,ans++;
      |                  ^~~
      |                  abs
a.cc:59:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   59 |         if(b)b--,ans++;
      |                  ^~~
      |                  abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<string> v(n);
	rep(i,n) cin >> v[i];
	ll cab = 0;
	ll ca = 0;
	ll cb = 0;
	ll c = 0;
	rep(i,n) {
		string s = v[i];
		if (s[0] == 'B' && s[s.size() - 1] == 'A') c++;
		else if (s[0] == 'B') cb++;
		else if (s[s.size() - 1] == 'A') ca++;
		for (int j = 0; j < s.size() - 1; j++) {
			string t = s.substr(j, 2);
			if (t == "AB") cab++;
		}
	}
	if (cb == 0 && ca == 0) {
		cout << cab + max(0, c - 1) << endl;
	} else {
		cout << cab + min(ca + c, cb + c) << endl;
	}
}

int main() {
	solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:33:34: error: no matching function for call to 'max(int, ll)'
   33 |                 cout << cab + max(0, c - 1) << endl;
      |                               ~~~^~~~~~~~~~
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:33:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   33 |                 cout << cab + max(0, c - 1) << endl;
      |                               ~~~^~~~~~~~~~
/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:33:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |                 cout << cab + max(0, c - 1) << endl;
      |                               ~~~^~~~~~~~~~
Language: C++

def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    s_table = [0]*3
    ans = 0
    for i in range(n):
        s = input()
        ans += s.count('AB')
        if s[0]=='B' and s[-1] == 'A':
            s_table[0] += 1
        elif s[0] == 'B' and s[-1] != 'A':
            s_table[1] += 1
        elif s[0] != 'B' and s[-1] == 'A':
            s_table[2] += 1
    
    m = min(s_table[1:])
    s_table[0] += m
    s_table[1] -= m
    s_table[2] -= m
    ans += s_table[0]-1 + min(1, sum(s_table[1:])) 
    print(ans)
        
    
if __name__ == '__main__':
    main()

Compiler output:
a.cc:11:24: warning: multi-character character constant [-Wmultichar]
   11 |         ans += s.count('AB')
      |                        ^~~~
a.cc:27:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   27 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vstr s(n);
    int a=0,b=0,ab=0;
    rep(i,n){
        cin >> s[i];
        if(s[i][0]=='B' && (s[i][s[i].size()-1]=='A') ab++;
        else if(s[i][0]=='B') b++;
        else if(s[i][s[i].size()-1]=='A') a++;
    }
    int res=0;
    rep(i,n){
        rep(j,s[i].size()-1){
            if(s[i].substr(j,2)=="AB") res++;
        }
    }
    if(ab==0) cout<<res+min(a,b)<<endl;
    else if(a+b>0) cout<<res+ab+min(a,b)<<endl;
    else if(a+b==0) cout<<res+ab-1<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:54: error: expected ';' before 'ab'
   53 |         if(s[i][0]=='B' && (s[i][s[i].size()-1]=='A') ab++;
      |                                                      ^~~
      |                                                      ;
a.cc:54:9: error: expected primary-expression before 'else'
   54 |         else if(s[i][0]=='B') b++;
      |         ^~~~
a.cc:53:60: error: expected ')' before 'else'
   53 |         if(s[i][0]=='B' && (s[i][s[i].size()-1]=='A') ab++;
      |           ~                                                ^
      |                                                            )
   54 |         else if(s[i][0]=='B') b++;
      |         ~~~~
Language: C++

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  int cnt_a=0, cnt_b=0, cnt0=0, ans=0;
  for(int i=0;i<n;i++) {
    for(int j=0;j<(int)s[i].size()-1;j++) {
      if(s[i][j]=='A' && s[i][j+1]=='B') { ans++; }
    }
    if(s[i][0] == 'B') { cnt_b++; }
    if(s[i][(int)s[i].size()-1] == 'A') { cnt_a++; }
    if(s[i][0] == 'B' && s[i][(int)s[i].size()-1] == 'A') { cnt0++; }
  }

  if(cnt0 == cnt_a && cnt_0 == cnt_b)) { ans--; }
  cout << ans + min(cnt_a,cnt_b) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:23: error: 'cnt_0' was not declared in this scope; did you mean 'cnt0'?
   40 |   if(cnt0 == cnt_a && cnt_0 == cnt_b)) { ans--; }
      |                       ^~~~~
      |                       cnt0
a.cc:40:38: error: expected primary-expression before ')' token
   40 |   if(cnt0 == cnt_a && cnt_0 == cnt_b)) { ans--; }
      |                                      ^
Language: C

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n;
    cin>>n;
    map<ll,ll>mp;
    ll ans = 0;
    for (ll i = 0; i < n; i++){
        string s;
        cin >> s;
        for (ll t = 0; t < s.size() - 1;t++){
            if (s.substr(t, 2) == "AB") ans++;
        }
            if (s[0] == 'B' and s[s.size() - 1] == 'A')
                mp[0]++;
            else if (s[0] == 'B')
                mp[1]++;
            else if (s[s.size() - 1] == 'A')
                mp[2]++;
    }
    if (!mp[0]) ans += min(mp[2], mp[1]);
    else if(!mp[2] and !mp[1])
        ans += mp[0] - 1;
    else ans+=mp[0]+min(mp[2], mp[1]);
    cout << ans << 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;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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



Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: 'a' was not declared in this scope; did you mean 'ba'?
   22 |   int ba=0;a=0;b=0;
      |            ^
      |            ba
a.cc:22:16: error: 'b' was not declared in this scope; did you mean 'ba'?
   22 |   int ba=0;a=0;b=0;
      |                ^
      |                ba
Language: C++

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

int main() {
  int N;
  cin >> N;
  string s[N];
  int a = 0;
  int b = 0;
  int c = 0;
  int ans = 0;
  for (int i= 0; i < N; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < N; i++) {
    if (s[i][0] == 'B' && s[i][s[i].size()-1] == 'A') {
      c++;
    } else if (s[i][0] == 'B') {
      b++;
    } else if (s[i][s[i].size()-1] == 'A') {
      a++;
    }
    for (int j = 1; j < s[i].size(); j++) {
      if (s[i][j-1] == 'A' && s[i][j] == 'B') {
        ans++;
      }
    }
  }
  int ab = min(a,b);
  if (ab > 1) {
    ans += ab + c;
  } else if (a == 0 && b != 0) {
    ans += c;
  } else if (a != 0 && b == 0) {
    ans += c;
  } else (a == 0 && b == 0) {
    ans += c-1;
  } 
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:28: error: expected ';' before '{' token
   39 |   } else (a == 0 && b == 0) {
      |                            ^~
      |                            ;
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;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N; cin >> N;
    int ab = 0, a = 0, b = 0, cnt = 0;
    vector<string> s(N);
    rep(i, N) cin >> s[i];
    rep(i, N) {
        if (s[i][0] == 'B' && s[i][s[i].length()-1] == 'A') ab++;
        else if (s[i][0] == 'B') b++;
        else if (s[i][s[i].length()-1] == 'A') a++;
        rep(j, s[i].length()-1) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') cnt++;
        }
    }
    if (ab == 0) {
        cout << min(a, b) + cnr << endl;
        return 0;
    }
    if (a + b == 0) {
        cout << cnt + ab - 1 << endl;
    }
    else cout << cnt + min(a, b) + ab << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:29: error: 'cnr' was not declared in this scope; did you mean 'cnt'?
   26 |         cout << min(a, b) + cnr << endl;
      |                             ^~~
      |                             cnt
Language: C++

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


int main(){

 int n,cnt=0,cnt1=0,cnt2=0,cnt3=0;
  cin>>n;

 while(n--){

  string das; cin>>das;

   for(int i=0;i<das.length();i++){
       if(das[i] == 'A' && das[i+1] == 'B')
        cnt++;
   }

   if(das[0] == 'B' && das[das.length()-1] == 'A')
    cnt1++;
    else if( das[0] == 'A' && das[das.length()-1] != 'B')
    cnt2++;
    else(das[0] != 'A' && das[das.length()-1] == 'B')
    cnt3++;

 }

 if(cnt1 == 0 )
    cout<<cnt+cnt1+min(cnt2,cnt3)<<endl;
 else if(cnt1 != 0 && cnt2+cnt3 > 0)
    cout<<cnt+ cnt1 + min(cnt2,cnt3)<<endl;
 else if(cnt1 != 0 && cnt2+cnt3 == 0)
    cout<<cnt + cnt1-1<<endl;

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:54: error: expected ';' before 'cnt3'
   24 |     else(das[0] != 'A' && das[das.length()-1] == 'B')
      |                                                      ^
      |                                                      ;
   25 |     cnt3++;
      |     ~~~~
Language: C++

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


int main(){

 int n,cnt=0,cnt1=0,cnt2=0,cnt3=0;
  cin>>n;

 while(n--){

  string das; cin>>das;

   for(int i=0;i<das.length();i++){
       if(das[i] == 'A' && das[i+1] == 'B')
        cnt++;
   }

   if(das[0] == 'B' && das[das.length()-1] == 'A')
    cnt1++;
    else if( das[0] == 'A' && das[das.length()-1] != 'B')
    cnt2++;
    else(das[0] != 'A' && das[das.length()-1] == 'B')

 }

 if(cnt1 == 0 )
    cout<<cnt+cnt1+min(cnt2,cnt3)<<endl;
 else if(cnt1 != 0 && cnt2+cnt3 > 0)
    cout<<cnt+ cnt1 + min(cnt2,cnt3)<<endl;
 else if(cnt1 != 0 && cnt2+cnt3 == 0)
    cout<<cnt + cnt1-1<<endl;

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:54: error: expected ';' before '}' token
   24 |     else(das[0] != 'A' && das[das.length()-1] == 'B')
      |                                                      ^
      |                                                      ;
   25 | 
   26 |  }
      |  ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  string a;
  ll cnt=0;
  ll A=0,B=0,both=0
  rep(i,n){
    cin >> a;
    ll k=a.size();
    rep(i,k-1){
      if(a[i]=='A'&&a[i+1]=='B'){
        cnt++;
      }
    }
    if(a[0]=='B'&&a[k-1]=='A'){
      both++;
    }
    else if(a[k-1]=='A'){
      A++;
    }
    else if(a[0]=='B'){
      B++;
    }
  }
  ll ans=cnt;
  ans+=min(A,B);
  ans+=both;
  if(min(A,B)==0){
    ans--;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: expected ',' or ';' before 'for'
   10 | #define FOR(i,a,b) for(ll i=a;i<b;i++)
      |                    ^~~
a.cc:11:18: note: in expansion of macro 'FOR'
   11 | #define rep(i,n) FOR(i,0,n)
      |                  ^~~
a.cc:21:3: note: in expansion of macro 'rep'
   21 |   rep(i,n){
      |   ^~~
a.cc:21:7: error: 'i' was not declared in this scope
   21 |   rep(i,n){
      |       ^
a.cc:10:31: note: in definition of macro 'FOR'
   10 | #define FOR(i,a,b) for(ll i=a;i<b;i++)
      |                               ^
a.cc:21:3: note: in expansion of macro 'rep'
   21 |   rep(i,n){
      |   ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  int fb=0, ea=0, n=0;
  string s;
  int ans = 0;
  rep(i, 0, N) {
    cin >> s;
    if(s[0] == 'B') {
      fb++;
    }
    if(s[s.size()-1] == 'A') {
      ea++;
    }
    if(s[s.size()-1] == 'A' || s[0] == 'B') {
      n++;
    }
    rep(j, 0, s.size()-1) {
      if(s[j] == 'A' && s[j+1] == 'B') ans++;
    }
  }
  ans += min(min(fb, ea), max(0, n-1));
  cout << ans << endl;
      
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:30: error: no matching function for call to 'max(int, long long int)'
   28 |   ans += min(min(fb, ea), max(0, n-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:28:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   28 |   ans += min(min(fb, ea), max(0, n-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:28:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |   ans += min(min(fb, ea), max(0, n-1));
      |                           ~~~^~~~~~~~
Language: C++

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

signed main(){
  lint N; cin >> N;
  lint ans = 0, ca = 0, cb = 0, cab = 0;
  for(lint i = 0; i < N; i++){
    string s; cin >> s;
    for(lint i = 1; i < s.size(); i++){
      if(s[i - 1] == 'A' && s[i] == 'B') ans++;
    }
    if(s[0] == 'B') cb++;
    if(s[s.size() - 1] == 'A') ca++;
    if(s[0] == 'B' && s[s.size() - 1] == 'A') cab++;
  }
  if(cab == a && cab == b && cab != 0) ans--;
  ans += min(ca, cb);
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'a' was not declared in this scope; did you mean 'ca'?
   17 |   if(cab == a && cab == b && cab != 0) ans--;
      |             ^
      |             ca
a.cc:17:25: error: 'b' was not declared in this scope; did you mean 'cb'?
   17 |   if(cab == a && cab == b && cab != 0) ans--;
      |                         ^
      |                         cb
Language: C++

#include <bits/stdc++.h>

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007

using namespace std;

int main(){
    int n,a=0,b=0,ans=0;
    cin>>n;
    string s; 
    pan(i,n){
        cin>>s;
        pan(i,(int)s.size()-1){
            if(s[i]=='A'&& s[i+1]=='B') ans++;
        }
        if(s[0]=='B' && ) b++;
        if(s[(int)s.size()-1]=='A') a++;
    }
    ans+=min(a,b);
    cout<<ans;
}   

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

//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//vector<ll> cue: キューの宣言
//n重ループ：初期化の位置に注意
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

ll a(ll n, ll x) {
	ll r = pow(10, x);
	n = (n % r);
	n /= pow(10, x - 1);
	return n;
}

int main() {
	ll N; cin >> N;
	string s[N]; rep(i, N)cin >> s[i];

	ll a = 0, b = 0, ab = 0;
	rep(i, N) {
		if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') ab++;
		else if (s[i][s[i].size() - 1] == 'A')a++;
		else if (s[i][0] == 'B')b++;
	}

	ll ans = 0;
	rep(i, N) {
		for (int j = 0; j <= s[i].size() - 2; j++) {
			if (s[i][j] == 'A' && s[i][j+1] == 'B')ans++;
		}
	}

	if (ab == 0) cout << ans + min(a, b) << endl;
	else if (a == b) cout << ans + a << endl;
	else if cout << ans + min(a, b) + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:17: error: expected '(' before 'cout'
   75 |         else if cout << ans + min(a, b) + 1 << endl;
      |                 ^~~~
      |                 (
Language: C++

//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//vector<ll> cue: キューの宣言
//n重ループ：初期化の位置に注意
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

ll a(ll n, ll x) {
	ll r = pow(10, x);
	n = (n % r);
	n /= pow(10, x - 1);
	return n;
}

int main() {
	ll N; cin >> N;
	string s[N]; rep(i, N)cin >> s[i];

	ll a = 0, b = 0, ab = 0;
	rep(i, N) {
		if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') ab++;
		else if (s[i][s[i].size() - 1] == 'A')a++;
		else if (s[i][0] == 'B')b++;
	}

	ll ans = 0;
	rep(i, N) {
		for (int j = 0; j <= s[i].size() - 2; j++) {
			if (s[i][j] == 'A' && s[i][j+1] == 'B')ans++;
		}
	}

	if (ab == 0) cout << ans + min(a, b) << endl;
	else if (a + b > 0) cout << ans + ba + min(a, b) << endl;
	else cout << ans + ba - 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:43: error: 'ba' was not declared in this scope; did you mean 'ab'?
   74 |         else if (a + b > 0) cout << ans + ba + min(a, b) << endl;
      |                                           ^~
      |                                           ab
a.cc:75:28: error: 'ba' was not declared in this scope; did you mean 'ab'?
   75 |         else cout << ans + ba - 1 << endl;
      |                            ^~
      |                            ab
Language: C++

#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,c=0,d=0,e=0,f=0,g=0;cin>>>a;
  string b;
  rep(i,a){
    cin>>b;
     if(b.at(b.size()-1)=='A')e++;
    if(b.at(0)=='B')f++;
    for(int o=0;o<b.size()-1;o++){
      if(b.at(o)=='A'&&b.at(o+1)=='B')c++;
    }
  }
  cout<<c+min(e,f);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:34: error: expected primary-expression before '>' token
    6 |   int a,c=0,d=0,e=0,f=0,g=0;cin>>>a;
      |                                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a=0,b=0,c=0,ans=0;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
        int k = s[i].size()-1;
        if(s[i][0]=='B') a++;
        if(s[i][k]=='A') b++;
        if(s[i][0]=='B'&&s[i][k]=='A') c++;
        for(int j=0;j<k;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
        }
    }
    a-= c;
    b-= c;
        if(a>0&&b>0) ans += c+1+min(a-1,b-1);
        else if((a==0&&b>0)||(a>0&&b==0)) ans += c;
        else ans += max(0,c-1);
    } 
    cout << ans << endl;
}


Compiler output:
a.cc:23:5: error: 'cout' does not name a type
   23 |     cout << ans << endl;
      |     ^~~~
a.cc:24:1: error: expected declaration before '}' token
   24 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,a=0,b=0,c=0,ans=0;
    cin >> n;
    string s[n];
    for(long i=0;i<n;i++){
        cin >> s[i];
        long k = s[i].size()-1;
        if(s[i][0]=='B') a++;
        if(s[i][k]=='A') b++;
        if(s[i][0]=='B'&&s[i][k]=='A') c++;
        for(int j=0;j<k;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B') ans++;
        }
    }
    a -= c;
    b -= c;
    if(a>0&&b>0) ans += c+1+min(a-1,b-1);
    if(a==0||b==0) ans += c;
    if(a==0&&b==0) ans += max(0,c-1);
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:30: error: no matching function for call to 'max(int, long int)'
   21 |     if(a==0&&b==0) ans += max(0,c-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:21:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   21 |     if(a==0&&b==0) ans += max(0,c-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:21:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |     if(a==0&&b==0) ans += max(0,c-1);
      |                           ~~~^~~~~~~
Language: C++

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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 ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vector<string>s(n);
	int cnt=0,a=0,b=0,ba=0;
	rep(i,n){
		cin>>s[i];
		int x=s[i].size();
		if(s[i][0]=='B'&&s[i][x-1]!='A')b++;
		if(s[i][x-1]=='A'&&s[i][0]!='B')a++;
		if(s[i][0]=='B'&&s[i][x-1]=='A')ba++;
		rep(j,x-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B')cnt++;
		}
	}
	int ans=0;
	if(ba>0){
		ans+=ba-1;
	}
	if(a!=b&&ab>0){
		ans++;
	}
	ans+=min(a,b);
    ans+=cnt;
	cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:18: error: 'ab' was not declared in this scope; did you mean 'ba'?
   64 |         if(a!=b&&ab>0){
      |                  ^~
      |                  ba