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

n = int(input())
s = n*[""]
count = 0
nn = 0
bn = 0
na = 0
ba = 0
for i in range(n):
    s[i] = input()
    count += s[i].count("AB")
    if(s[i][0] == "B" and s[i][-1] == "A"): ba += 1
    elif(s[i][0] == "B"): bn += 1
    elif(s[i][-1] == "A"): na += 1


while(sum([ba,na,bn]) > 1):
    if(na > 0 and ba > 0 and bn > 0):
        count += ba+1
        ba = 0
        na -= 1
        bn -= 1
    elif(na > 0 and bn > 0):
        count += min([na, bn])
        na -= min([na, bn])
        bn -= min([na, bn])
    elif(na > 0 and ba > 0):
        count += ba
        na -= 1
        ba = 0
    elif(bn > 0 and ba > 0):
        count += ba
        bn -= 1
        ba = 0
    else: break


print(count)

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | n = int(input())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:1:5: error: expected expression before 'int'
    1 | n = int(input())
      |     ^~~
Language: C++

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

int main(){
  int N,result = 0;
  string k,s;
  cin >> N ;
  for(int i = 0; i<N; ++i){
    cin >> k; s += k;
  }
  for(int i = 0; i<N-1; ++i){
    a = s[i] + s[i+1] ;
    if(a == 'AB'){++result;}
  }
  cout << result << endl;
}

Compiler output:
a.cc:14:13: warning: multi-character character constant [-Wmultichar]
   14 |     if(a == 'AB'){++result;}
      |             ^~~~
a.cc: In function 'int main()':
a.cc:13:5: error: 'a' was not declared in this scope
   13 |     a = s[i] + s[i+1] ;
      |     ^
Language: C++

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

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  int frntA = 0, frntB = 0, backA = 0, backB = 0, ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> s[i];
    if(s[i][0] == "A") ++frntA;
    else if(s[i][0] == "B") ++frntB;
    if(s[i][s[i].size() - 1] == "A") ++backA;
    else if(s[i][s[i].size() - 1] == "B") ++backB;
    for(int k = 0; k < s[i].size() - 1; ++k)
    {
      if(s[i] == "A" && s[i + 1] == "B")
      {
        ++ans;
        ++k;
      }
    }
  }
  cout << ans + min(max(frntA, frntB), max(backA, backB)) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if(s[i][0] == "A") ++frntA;
a.cc:14:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |     else if(s[i][0] == "B") ++frntB;
a.cc:15:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   15 |     if(s[i][s[i].size() - 1] == "A") ++backA;
a.cc:16:35: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     else if(s[i][s[i].size() - 1] == "B") ++backB;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin>>N;
  vector<string>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  int count=0,before=0,after=0;
  for(int i=0;i<N;i++){
    string str =vec.at(i);
    for(int i=0;i<str.size();i++){
      if(str.at(i)==A && str.at(i+1)==B){
        count++;
      }
    }
    
    if(str.at(0)==B){
      before++;
    }
    if(str.at(str.size())=A){
      after++;
    }
  }
  cout<< count+=min(before,after) <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:35: error: invalid operands of types 'const int' and '<unresolved overloaded function type>' to binary 'operator<<'
   27 |   cout<< count+=min(before,after) <<endl;
      |                 ~~~~~~~~~~~~~~~~~~^~~~~~
Language: C++

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

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  int frntA = 0, frntB = 0, backA = 0, backB = 0, ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> s[i];
    if(s[i].front() == "A") ++frntA;
    else if(s[i].front() == "B") ++frntB;
    if(s[i].back() == "A") ++backA;
    else if(s[i].back() == "B") ++backB;
    for(int k = 0; k < s[i].size() - 1; ++k)
    {
      if(s[i] == "A" && s[i + 1] == "B")
      {
        ++ans;
        ++k;
      }
    }
  }
  cout << ans + min(max(frntA, frntB), max(backA, backB)) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |     if(s[i].front() == "A") ++frntA;
      |        ~~~~~~~~~~~~~^~~~~~
a.cc:14:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |     else if(s[i].front() == "B") ++frntB;
      |             ~~~~~~~~~~~~~^~~~~~
a.cc:15:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   15 |     if(s[i].back() == "A") ++backA;
      |        ~~~~~~~~~~~~^~~~~~
a.cc:16:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     else if(s[i].back() == "B") ++backB;
      |             ~~~~~~~~~~~~^~~~~~
Language: C++

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    int count = 0;
    int A_count = 0;
    int B_count = 0;
    int dup = 0;
    for(int i=0;i<N;i++){
        cin >> S.at(i);
        for(int k=0;k<S..at(i).size()-1;k++){
            if(S.at(i).at(k) == 'A' && S.at(i).at(k+1) == 'B' ) count++;
        }
        if(S.at(i).at(0) == 'B') B_count++;
        if(S.at(i).at(S.at(i).size()-1) =='A') A_count++;
        if(S.at(i).at(0) == 'B' && S.at(i).at(S.at(i).size()-1) =='A') dup++;
    }
    if(A_count != B_count){
    int n = max(A_count,B_count);
    int ans = count + n;
    }
    if(A_count == B_count){
    int n = A_count-1
    int ans = count + n
    } 
    cout << ans << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:25: error: expected unqualified-id before '.' token
   14 |         for(int k=0;k<S..at(i).size()-1;k++){
      |                         ^
a.cc:27:5: error: expected ',' or ';' before 'int'
   27 |     int ans = count + n
      |     ^~~
a.cc:29:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

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

int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  int frntA, frntB, backA, backB, ans;
  frntA = frntB = backA = backB = ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> s[i];
    if(s[i].front() == "A") ++frntA;
    else if(s[i].front() == "B") ++frntB;
    if(s[i].back() == "A") ++backA;
    else if(s[i].back() == "B") ++backB;
    for(int k = 0; k < s[i].size() - 1; ++k)
    {
      if(s[i] == "A" && s[i + 1] == "B")
      {
        ++ans;
        ++k;
      }
    }
  }
  cout << ans + min(max(frntA, frntB), max(backA, backB)) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |     if(s[i].front() == "A") ++frntA;
      |        ~~~~~~~~~~~~~^~~~~~
a.cc:15:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   15 |     else if(s[i].front() == "B") ++frntB;
      |             ~~~~~~~~~~~~~^~~~~~
a.cc:16:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |     if(s[i].back() == "A") ++backA;
      |        ~~~~~~~~~~~~^~~~~~
a.cc:17:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |     else if(s[i].back() == "B") ++backB;
      |             ~~~~~~~~~~~~^~~~~~
Language: C++

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

using namespace std;

vector<int> find_all(const string str, const string subStr) {
    std::vector<int> result;
 
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
 
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
 
    return result;
}

int main() {
	int N;
	cin >> N;
	string s;
	int fb = 0;
	int ba = 0;
	int count = 0;
	for(int i = 0; i < N; i++) {
		cin >> s;
		vector<int> findVec = find_all(s, "AB");
		count += findVec.size();
		if (s[0] == 'B')
			fb++;
		if (s[s.length()-1] == 'A')
			ba++;
	}
	if (fb == N && ba == N)
		count += (fb - 1);
	else if (fb > ba)
		count += ba;
	else
		count += fb;

	cout << count << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:44:31: error: expected '}' at end of input
   44 |         cout << count << endl;
      |                               ^
a.cc:21:12: note: to match this '{'
   21 | int main() {
      |            ^
Language: C++

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

int main(void) {
  int n; cin >> n;
  vector<string> s(n);
  for (auto && vec : s) { 
    cin >> vec;
  }
  
  int a=0,b=0,c=0,d=0,e=0;
  for(int i=0;i<n;i++) {
    if(s.at(i).front() == 'B' && s.at(i).back() =='A') {
      a++;
      b++;
    } else if (s.at(i).front() == 'B' && s.at(i).back() !='A') {
      b++;
    } else if (s[i].front() != 'B' && s[i].back() =='A') {
      a++;
    }
    for(int j=0;j<s[i].length()-2;j++) {
    	if(s[i].substr(j,2) == "AB") {
      		e++;
        }
    }
  }
  if (2c<a && 2c<b) {
    d= (2*c + b + a) /2 +e;
  } else {
    d= c-1 + min(a-1,b-1)+e;
  }
  cout << d << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:7: error: unable to find numeric literal operator 'operator""c'
   27 |   if (2c<a && 2c<b) {
      |       ^~
a.cc:27:15: error: unable to find numeric literal operator 'operator""c'
   27 |   if (2c<a && 2c<b) {
      |               ^~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:32:22: error: no match for 'operator+=' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int')
   32 |                 cout += twin - 1;
      |                 ~~~~~^~~~~~~~~~~
a.cc:44:22: error: no match for 'operator+=' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int')
   44 |                 cout += count += min(begin, end);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

N = int(input())
s = [0 for i in range(N)]
cnt = 0
chance = False
A_cnt = 0
B_cnt = 0
BA_cnt = 0
for i in range(N):
    s[i] = str(input())
    cnt += s[i].count("AB")
    if s[i][0] == "B" and s[i][-1]=="A":
        BA_cnt += 1
    elif s[i][0] == "B":
        B_cnt += 1
    elif s[i][-1] == "A":
        A_cnt += 1


if BA_cnt != 0 and A_cnt == 0:
    plus = BA_cnt-1
else:
    plus = min(BA_cnt+A_cnt,BA_cnt+B_cnt)

cnt += plus

print(cnt)


Compiler output:
a.cc:1:3: error: invalid preprocessing directive #encoding
    1 | # encoding:utf-8
      |   ^~~~~~~~
a.cc:4:15: error: stray '#' in program
    4 | import bisect #bisect_left　これで二部探索の大小検索が行える
      |               ^
a.cc:4:16: error: extended character 　 is not valid in an identifier
    4 | import bisect #bisect_left　これで二部探索の大小検索が行える
      |                ^
a.cc:5:18: error: stray '#' in program
    5 | import fractions #最小公倍数などはこっち
      |                  ^
a.cc:2:1: error: 'import' does not name a type
    2 | import copy
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <stdafx.h>
#include <string>
#include <iostream>

using namespace std;

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

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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<string>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  int count=0,before=0,after=0;
  for(int i=0;i<N;i++){
    string str =vec.at(i);
    for(int i=0;i<str.size();i++){
      if(str.at(i)==A && str.at(i+1)==B){
        count++;
      }
    }
    
    if(str.at(0)==B){
      before++;
    }
    if(str.at(str.size())=A){
      after++;
    }
  }
  cout<< count+=min(befor,after) <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'A' was not declared in this scope
   15 |       if(str.at(i)==A && str.at(i+1)==B){
      |                     ^
a.cc:15:39: error: 'B' was not declared in this scope
   15 |       if(str.at(i)==A && str.at(i+1)==B){
      |                                       ^
a.cc:20:19: error: 'B' was not declared in this scope
   20 |     if(str.at(0)==B){
      |                   ^
a.cc:23:27: error: 'A' was not declared in this scope
   23 |     if(str.at(str.size())=A){
      |                           ^
a.cc:27:21: error: 'befor' was not declared in this scope; did you mean 'before'?
   27 |   cout<< count+=min(befor,after) <<endl;
      |                     ^~~~~
      |                     before
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int n;cin>>n;
  int ans=0;
  string s[0];cin>>s[0];
for(int i=1;i<n;i++)
{
  string s[i];cin>>s[i];
  if(s[i]=="AB")
  {
    ans++;
  }
}
  for(int i=0;i<n;i++)
  {
  if(s[i-1].at.(size())=="A"&&s[i].at(0)=="B")
  {
    ans++;
  }
  }
  cout<<ans<<endl;
}
    
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: invalid use of member function 'std::__cxx11::basic_string<char>::at' (did you forget the '()' ?)
   18 |   if(s[i-1].at.(size())=="A"&&s[i].at(0)=="B")
      |      ~~~~~~~^~
a.cc:18:21: error: no matching function for call to 'size()'
   18 |   if(s[i-1].at.(size())=="A"&&s[i].at(0)=="B")
      |                 ~~~~^~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   candidate expects 1 argument, 0 provided
a.cc:18:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   18 |   if(s[i-1].at.(size())=="A"&&s[i].at(0)=="B")
      |                               ~~~~~~~~~~^~~~~
Language: C++

N = int(input())
ss = [input() for _ in range(N)]

a = 0
b = 0
ba = 0
n = 0
for s in ss:
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    if s[0] == 'B':
        b += 1
    if s[-1] == 'A':
        a += 1
    n += s.count("AB")

if ba == 1:
    if a < b:
        b -= 1
    else:
        a -= 1
print(n + min(a,b))

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

#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int n;
    cin >> n;
    vector<string> s(n);

    int ans=0;
    rep(i,n)
    {
        cin >> s[i];
        rep(j,s[i].size()-1)
        {
            if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
        }
    }

    int lasta,fib;
    lasta=fib=0;
    int doublecount=0;
    int a=0;
    rep(i,n)
    {
        //if(s[i][0]=="A")fia++;
        if(s[i][n-1]=='A')
        {
            lasta++;
            a++;
        }
        if(s[i][0]=='B')
        {
        fib++;
        a++;
        }
        if(a==2)doublecount++;
        a=0;
        //if(s[i][n-1]=="B")lastb++;
    }
    if(doublecount)
    {
     lasta-=doublecount-1;
     fib-=doublecount-1;
     ans+=doublecount-1;
    }
    if(lasta&&doublecount&&fib>=2)
    {
        ans++;
        lasta--;
        fib--;
    }
    if(doublecount&&fib&&last>=2)
    {
        ans++;
        lasta--;
        fib--;
    }

    ans+=min(lasta,fib);

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:77:26: error: 'last' was not declared in this scope; did you mean 'lasta'?
   77 |     if(doublecount&&fib&&last>=2)
      |                          ^~~~
      |                          lasta
Language: C++

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

int main() {
	int N;
	cin >> N;
	vector<string> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	int count = 0;
	int twin = 0;
	int begin = 0;
	int end = 0;
	for (int i = 0; i < N; i++) {
		if(vec.at(i).at(0) == 'C' && vec.at(i).at(vec.at(i).size() - 1) == 'A'){
			twin++;
		}
		if (vec.at(i).at(0) == 'C' && vec.at(i).at(vec.at(i).size() - 1) != 'A') {
			begin++;
		}
		if (vec.at(i).at(0) != 'C' && vec.at(i).at(vec.at(i).size() - 1) == 'A') {
			end++;
		}
		for (int k = 0; k < vec.at(i).size() - 1; k++) {
			if (vec.at(i).at(k) == 'A' && vec.at(i).at(k + 1) == 'B') {
				count++;
			}
		}
	}
	cout += twin - 1;
	if (begin != 0) {
		count++;
	}
	if (end != 0) {
		count++;
	}
	cout << count << endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:31:14: error: no match for 'operator+=' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int')
   31 |         cout += twin - 1;
      |         ~~~~~^~~~~~~~~~~
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
string s[10000];
int sl[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++) {
        cin>>s[i];
        sl[i]=s[i].length();
        s[i]=s[i].c_str();
    }
    int countab=0;
    int counta=0;
    int countb=0;
    int m=0;
    for(int i=0;i<n;i++){
        bool a=false;
        bool b=false;
        if(s[i][0]=='B'){
            countb++;
            b=true;
        }
        if(s[i][sl[i]-1]=='A') {
            counta++;
            a=true;
        }
        if(a==true&&b==true)m++;
        for(int j=0;j<sl[i]-1;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B'){
                countab++;
            }
        }
    }
    int ans=countab+min(counta,countb);
    if(counta==countb&&m==counta&&counta>0){
        ans--;
    }
    if()
    cout <<ans<< "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:73:8: error: expected primary-expression before ')' token
   73 |     if()
      |        ^
Language: C++

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

int main() {
	int N;
	cin >> N;
	vector<string> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	int count = 0;
	int twin = 0;
	int begin = 0;
	int end = 0;
	for (int i = 0; i < N; i++) {
		if(vec.at(i).at(0) == 'C' && vec.at(i).at(vec(i).size() - 1) == 'A'){
			twin++;
		}
		if (vec.at(i).at(0) == 'C' && vec.at(i).at(vec(i).size() - 1) != 'A') {
			begin++;
		}
		if (vec.at(i).at(0) != 'C' && vec.at(i).at(vec(i).size() - 1) == 'A') {
			end++;
		}
		for (int k = 0; k < vec(i).size() - 1; k++) {
			if (vec.at(i).at(k) == 'A' && vec.at(i).at(k + 1) == 'B') {
				count++;
			}
		}
	}
	cout += twin - 1;
	if (begin != 0) {
		count++;
	}
	if (end != 0) {
		count++;
	}
	cout << count << endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:16:62: error: no match for call to '(std::vector<std::__cxx11::basic_string<char> >) (int&)'
   16 |                 if(vec.at(i).at(0) == 'C' && vec.at(i).at(vec(i).size() - 1) == 'A'){
      |                                                           ~~~^~~
a.cc:19:63: error: no match for call to '(std::vector<std::__cxx11::basic_string<char> >) (int&)'
   19 |                 if (vec.at(i).at(0) == 'C' && vec.at(i).at(vec(i).size() - 1) != 'A') {
      |                                                            ~~~^~~
a.cc:22:63: error: no match for call to '(std::vector<std::__cxx11::basic_string<char> >) (int&)'
   22 |                 if (vec.at(i).at(0) != 'C' && vec.at(i).at(vec(i).size() - 1) == 'A') {
      |                                                            ~~~^~~
a.cc:25:40: error: no match for call to '(std::vector<std::__cxx11::basic_string<char> >) (int&)'
   25 |                 for (int k = 0; k < vec(i).size() - 1; k++) {
      |                                     ~~~^~~
a.cc:31:14: error: no match for 'operator+=' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int')
   31 |         cout += twin - 1;
      |         ~~~~~^~~~~~~~~~~
Language: C++

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

int main() {
	long long n,m,r,g,b,i,j,k,cur,ans=0,res;

	cin >> n;
	vector<string> s(n);
	for(i=0; i<n; i++){
		cin >> s[i];
	}
	
	long long cura=0,curb=0,flag=0;
	for(i=0; i<n; i++){
		if(s[i][0]=='B'){
			curb++;
		}
		if(s[i][s[i].size()-1]=='A'){
			cura++;
			if(s[i][0]!='B'){
				flag++;
			}
		}
		for(j=1; j<s[i].size(); j++){
			if(s[i][j-1]=='A' && s[i][j]=='B'){
				ans++;
			}
		}
	}
	if(flag==0){
		curb=min(curb-1,0);
	}
	cout << ans+min(cura,curb);

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:25: error: no matching function for call to 'min(long long int, int)'
   31 |                 curb=min(curb-1,0);
      |                      ~~~^~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:31:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |                 curb=min(curb-1,0);
      |                      ~~~^~~~~~~~~~
/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, 2 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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:31:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |                 curb=min(curb-1,0);
      |                      ~~~^~~~~~~~~~
Language: C++

import sys
input = sys.stdin.readline

S = [input() for _ in range(int(input()))]
AB = 0
end_A = 0
start_B = 0
sB_eA = 0

for s in S:
    AB += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        sB_eA += 1
    elif s[0] == 'B':
        start_B += 1
    elif s[-1] == 'A':
        end_A += 1
amari = abs(start_B-end_A)
print(AB+min(start_B,end_A)+min(amari,sB_eA))

Compiler output:
a.cc:11:19: warning: multi-character character constant [-Wmultichar]
   11 |     AB += s.count('AB')
      |                   ^~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

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

int main(){
	int N;
	cin >> N;
	vector<string> s(N);
	for(int i = 0; i < N; i++)
		cin >> s.at(i);
	int sum = 0;
	for(string st : s)
		for(int i = 0; i < len(st)-1; i++)
			if(st.substr(i, 2) == "AB"){
				st.erase(i);
				st.erase(i);
				i -= 2;
				sum++;
			}
	int frontB = 0, backA = 0, both = 0;
	for(string str : s){
		if(str[0] == 'B' && str[len(str)-1] == 'A')
			both++;
		else if(str[0] == 'B')
			frontB++;
		else if(str[len(str)-1] == 'A')
			backA++;
	}
	if(backA == frontB)
		sum += both;
	else
		sum += both+1;
	sum += min(backA, frontB);

	cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:36: error: 'len' was not declared in this scope
   12 |                 for(int i = 0; i < len(st)-1; i++)
      |                                    ^~~
a.cc:21:41: error: 'len' was not declared in this scope
   21 |                 if(str[0] == 'B' && str[len(str)-1] == 'A')
      |                                         ^~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int n;cin>>n;
  int ans=0;
for(int i=0;i<n;i++)
{
  string s[i];cin>>s[i];
  if(s[i]=="AB")
  {
    ans++;
  }
}
  for(int i=0;i<n;i++)
  {
  if(s[i-1].at.(length())=="A"&&s[i].at(0)=="B")
  {
    ans++;
  }
  }
  cout<<ans<<endl;
}
    
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:17:6: error: 's' was not declared in this scope
   17 |   if(s[i-1].at.(length())=="A"&&s[i].at(0)=="B")
      |      ^
a.cc:17:16: error: expected unqualified-id before '(' token
   17 |   if(s[i-1].at.(length())=="A"&&s[i].at(0)=="B")
      |                ^
a.cc:17:17: error: 'length' was not declared in this scope
   17 |   if(s[i-1].at.(length())=="A"&&s[i].at(0)=="B")
      |                 ^~~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  string s[n];
  for (int i=0;i<n;i++) cin >> s[i];
  ll tot=0;
  int enda=0,firb=0,bothn=0;
  
  for (int i =0;i<n;i++){
    int len=s[i].length();
    if (s[i][0] == 'B'){
      firb += 1;
    }
    if (s[i][len] == 'A'){
      enda += 1;
    }
    if (s[i][0] == 'B' && s[i][len] == 'A') bothn += 1;
    for (int j =0;j<len-1;j++){
      if (s[i][j] == 'A' && s[i][j+1] == 'B'){
	tot += 1;
      }
    }
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:29:4: error: expected '}' at end of input
   29 |   }
      |    ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main() {
  int n;
  cin >> n;
  string s[10000];
  REP(i,n) {
    cin >> s[i];
  }

  ll ra = 0;
  ll lb = 0;
  ll po = 0;
  ll ans = 0;

  REP(i,n) {
    if (s[i][0] == 'B' && s[i][s[i].length() - 1] != 'A') {
      lb++;
    }
    if (s[i][s[i].length() - 1] == 'A' && s[i][0] != 'B') {
      ra++;
    }
    if (s[i][s[i].length() - 1] == 'A' && s[i][0] == 'B') {
      po++;
    }

      FOR(j, 1, s[i].length())
      {
        if (s[i][j - 1] == 'A' && s[i][j] == 'B')
        {
          ans++;
        }
      }
  }


  ans += min(lb, ra) + max(0,(po-1));
  if(abs(lb-ra) >= 1) {
    ans++;
  }

  cout << ans << endl;

}


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

#include <iostream>

using namespace std;

int find(string s){
  int ans = 0,flag = 0;
  for(int i = 0 ; i < s.size(); i++){
    if(flag){
      if(s[i] == 'B')
         ans++;
      flag = 0;
    }
    if(s[i] == 'A') flag = 1;
  }
  return ans;
}

void dp(int mas[10],int n,int m){
  if(n == 0){
    temp =
  }
  for(int i=0;i<n;i++){
    if(mas[i] == 0)
  }
}

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


Compiler output:
a.cc: In function 'void dp(int*, int, int)':
a.cc:20:5: error: 'temp' was not declared in this scope; did you mean 'tm'?
   20 |     temp =
      |     ^~~~
      |     tm
a.cc:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
a.cc:24:3: error: expected primary-expression before '}' token
   24 |   }
      |   ^
Language: C++

#include <iostream>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:37: error: request for member 'length' in 's', which is of non-class type 'std::string [n]' {aka 'std::__cxx11::basic_string<char> [n]'}
   14 |         if(s[i][0] == 'B' && s[i][s.length() - 1] == 'A') m++;
      |                                     ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  int BA[3];
  int len;
  int ans=0;
  BA[0]=BA[1]=BA[2]=0;
  
  REP(i,n){
    cin>>s[i];
    len = s[i].size();
    REP(j,len-1){
      if(s[i][j]=='A' && s[i][j+1]=='B'){
        ans++;
      }
    }
    if(s[i][0]=='B'){
      BA[0]++;
    }
    if(s[i][len-1]=='A'){
      BA[1]++;
    }
    if(s[i][0]=='B' && s[i][len-1]=='A'){
      BA[2]++;
    }
  }
  
  int a,b,c;
  b = BA[0]-BA[2];
  a = BA[1]-BA[2];
  c = BA[2];
  if(a==0 && b==0){
    d = max(0,c-1);
  }else{
    d = min(a,b)+c;
  }
  ans += d;
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:122:5: error: 'd' was not declared in this scope
  122 |     d = max(0,c-1);
      |     ^
a.cc:124:5: error: 'd' was not declared in this scope
  124 |     d = min(a,b)+c;
      |     ^
a.cc:126:10: error: 'd' was not declared in this scope
  126 |   ans += d;
      |          ^
Language: C++

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

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vchar vector<char>
#define vool vector<bool>
#define pb() pushback
#define elif else if
#define all(x) x.begin(),x.end()

void call(int);
main(){
    int N,b,count=0,count2=0,H=0,W=0;
    double r;
    int C='A'-'a';
    char op;
    str S,T;
    cin>>N;
    vector<string> v(N);
    rep(0,N){
      cin>>v.at(i);
    }
    rep(0,N){
      if(v.at(i).at(0)=='B'&&v.at(i).at(v.at(i).size()-1)=='A')W+=1;
      elif(v.at(i).at(0)=='B')count2+=1;
      elif(v.at(i).at(v.at(i).size()-1)=='A')H+=1;
      REP(0,v.at(v.at(i).at(0)=='B'i).size()-1){
        if(v.at(i).at(j)=='A'&&v.at(i).at(j+1)=='B')count+=1;
      }
    }
    if(count2>0&&H>0)cout<<count+min(count2,H)+W-1<<endl;
    else cout<<count+max(count2,H)+W-1<<endl;
}


Compiler output:
a.cc:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:31:33: error: unable to find character literal operator 'operator""i' with 'char' argument
   31 |       REP(0,v.at(v.at(i).at(0)=='B'i).size()-1){
      |                                 ^~~~
a.cc:6:32: note: in definition of macro 'REP'
    6 | #define REP(x,y) for(int j=x;j<y;j++)
      |                                ^
Language: C++

#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    int ab=0;
    int lb=0;
    int ra=0;
    int inab=0;

    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='B'&&s[s.size()-1]=='A'){
            ab++;
        }else if(s[0]=='B'){
            lb++;
        }else if(s[s.size()-1]=='A'){
            ra++;
        }

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


    int ans=0;
    ans+=inab;

    if(ab==0){
        ans+=min(lb,ra);

    }else {

        int k=min(lb,ra);
        ans+=k;
        lb-=k;ra-=k;

       if(k=>ab){ans+=ab;}else{ans+=ab-1;}

    }


    cout<<ans<<endl;


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:13: error: expected primary-expression before '>' token
   63 |        if(k=>ab){ans+=ab;}else{ans+=ab-1;}
      |             ^
Language: C++

#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n;
  cin>>n;
  string s[n];
  rep(i,n){
    cin>>s[i];
  }
  int ab=0,enda=0,startb=0;
  rep(i,n){
    rep(i,s[i].length()-1){
      if(s[i].substr(i,2)=="AB"){
        ab++;
      }
    }
    if(s[i][0]=='B'){
      startb++;
    }
    if(s[i][s[i].length()-1])=='A'){
      enda++;
    }
  }
  cout<<ab+min(enda,startb);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:30: error: expected primary-expression before '==' token
   31 |     if(s[i][s[i].length()-1])=='A'){
      |                              ^~
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n; cin>>n;
  string s[11000];
  int k=0;
  int a[11000],b[11000];

  rep(i,n){
    cin>>s[i];
    int m=s[i].length();
    if(s[i][0]=='B') a[i];
    if(s[i][m-1]=='A') b[i];
    rep(j,m-1){
      if(s[i][j]=='A' && s[i][j+1]=='B') k++;
    }
  }
  int aa=0,bb=0,ab++;
  rep(i,n){
   if(a[i]==1 && b[i]!=1) aa++;
   else if(a[i]==0 && b[i]==1) bb++;
   else if(a[i]==1 && b[i]==1) ab++;
  }
  if(l>)
  cout<<k+min(min(l,c),n-1)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:19: error: expected initializer before '++' token
   31 |   int aa=0,bb=0,ab++;
      |                   ^~
a.cc:35:32: error: 'ab' was not declared in this scope; did you mean 'bb'?
   35 |    else if(a[i]==1 && b[i]==1) ab++;
      |                                ^~
      |                                bb
a.cc:37:6: error: 'l' was not declared in this scope
   37 |   if(l>)
      |      ^
a.cc:37:8: error: expected primary-expression before ')' token
   37 |   if(l>)
      |        ^
a.cc:38:21: error: 'c' was not declared in this scope
   38 |   cout<<k+min(min(l,c),n-1)<<endl;
      |                     ^
Language: C++

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

int main() {
	int n, i, j, c = 0, s = 0, e = 0;
	cin >> n;
	vector<string> s(n);
	for (i = 0; i < n; i++)
		cin >> s[i];
	string st;
	for (i = 0; i < n; i++) {
		for (j = 0; j < (int)(s[i].length()); j++) {
			if (s[i].substr(j, 2) == "AB")
				c++;
		}
		if (s[i].substr(1, 1) == "B")
			s++;
		if (s[i].substr((int)(s[i].length()) - 1, 1) == "A")
			e++;
	}
	if (s <= e)
		c += s;
	else
		c += e;
	if (s == i && e == i)
		c--;
	cout << c;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:24: error: conflicting declaration 'std::vector<std::__cxx11::basic_string<char> > s'
    7 |         vector<string> s(n);
      |                        ^
a.cc:5:29: note: previous declaration as 'int s'
    5 |         int n, i, j, c = 0, s = 0, e = 0;
      |                             ^
a.cc:9:25: error: invalid types 'int[int]' for array subscript
    9 |                 cin >> s[i];
      |                         ^
a.cc:12:40: error: invalid types 'int[int]' for array subscript
   12 |                 for (j = 0; j < (int)(s[i].length()); j++) {
      |                                        ^
a.cc:13:30: error: invalid types 'int[int]' for array subscript
   13 |                         if (s[i].substr(j, 2) == "AB")
      |                              ^
a.cc:16:22: error: invalid types 'int[int]' for array subscript
   16 |                 if (s[i].substr(1, 1) == "B")
      |                      ^
a.cc:18:22: error: invalid types 'int[int]' for array subscript
   18 |                 if (s[i].substr((int)(s[i].length()) - 1, 1) == "A")
      |                      ^
a.cc:18:40: error: invalid types 'int[int]' for array subscript
   18 |                 if (s[i].substr((int)(s[i].length()) - 1, 1) == "A")
      |                                        ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }

  int a = 0, b = 0, ba = 0, count = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i).at(0) == 'B') b++;
    if (S.at(i).at(S.at(i).size()-1) == 'A') a++;
    if (S.at(i).at(0) == 'B' && S.at(i).at(S.at(i).size()-1) == 'A') ba++;
    for (int j = 1; j < S.at(i).size(); j++) {
      if (S.at(i).at(j-1) == 'A' && S.at(i).at(j) == 'B') {
        count++;
      }
    }
  }

  else if (a > b) {
    count += b;
  }
  else {
    count += a;
  }
  if (a == ba && b == ba) {
    count--;
  }

  cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:3: error: 'else' without a previous 'if'
   24 |   else if (a > b) {
      |   ^~~~
Language: C++

#include <vector>
#include <iostream>
#include <cstring>

using namespace std;

int GetMaxCombination(int left, int right, int both) {
    // 000
    if(left + right + both == 0) { return 0; }
    // 001
    if(left == 0 && right == 0 && both > 0) { return both - 1; }
    // 010
    if(left == 0 && right > 0 && both == 0) { return 0; }
    // 100
    if(left > 7 && right == 0 && both == 0) { return 0; }
    // 011
    if(left == 0 && right > 0 && both > 0) { return both; }
    // 101
    if(left > 0 && right == 0 && both > 0) { return both; }
    // 110
    if(left > 0 && right > 0 && both == 0) { return min(left, right); }
    // 111
    if(left > 0 && right > 0 && both > 0) {
        if(left == 1 && right == 1) {
            return both + 1;
        }
        if(left > 1 && right == 1) {
            return both;
        }
        if(left == 1 && right > 1) {
            return both;
        }
        if(left > 1 && right > 1) {
            if(left == right) {
                return left + both;
            }
            return max(min(left - 1, right - 1) + both + 1, min(left, right) + both);
        }
    }
    return 0;
}

int MaxCombination(vector<string>& words) {
    int ret = 0;
    int left = 0;
    int right = 0;
    int both = 0;
    for(int i = 0; i < words.size(); ++i) {
        for(int j = 0; j < words[i].size(); ++j) {
            if(words[i][j] == 'A' && j + 1 < words[i].size() && words[i][j + 1] == 'B') {
                ret += 1;
            }
        }
        string c;
        if(words[i][0] == 'B') {
            c.push_back(')');
        }
        int len = int(words[i].size());
        if(words[i][len - 1] == 'A') {
            c.push_back('(');
        }
        if(c.length() > 0) {
            if(c.length() == 2) {
                both += 1;
            } else if(c.length() == 1) {
                if(c[0] == '(') {
                    left += 1;
                } else {
                    right += 1;
                }
            }
        }
    }
    return ret + GetMaxCombination(left, right, both);
}

int main() {
    int n = 7;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        string w;
        cin >> w;
        words.push_back(w);
    }
    int res = MaxCombination(words);
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:9: error: 'words' was not declared in this scope
   83 |         words.push_back(w);
      |         ^~~~~
a.cc:85:30: error: 'words' was not declared in this scope
   85 |     int res = MaxCombination(words);
      |                              ^~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:1: error: 'counter1' was not declared in this scope; did you mean 'counter'?
   14 | counter1++;
      | ^~~~~~~~
      | counter