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

#c
n = int(input())
stringsA = 0
stringsB = 0
both = 0
ans = 0
if n == 1:
    string = input()
    print(string.count("AB"))
else:
    for i in range(n):
        string = input()
        ans += string.count("AB")
        if string[-1] == 'A' and string[0] == 'B':
            both += 1
        elif string[-1] == 'A':
            stringsA += 1
        elif string[0] == 'B':
            stringsB += 1
    if both == 0:
		print(ans + min(stringsA,stringsB))
    elif stringsA + stringsB == 0 and both > 1:
        both -= 1
    elif stringsA == stringsB and both == 1:
        both = 0
    else:
    	print(ans + min(stringsA,stringsB) + both)



Compiler output:
a.cc:1:2: error: invalid preprocessing directive #c
    1 | #c
      |  ^
a.cc:2:1: error: 'n' does not name a type
    2 | n = int(input())
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;
ll b;
ll a;
ll ans=0;

void addedge(ll u, ll v)

	{
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

bool dfs(ll node)
	{
		cout<<node<<endl;
		mark[node]=1;
		

		for(auto i:adj[node])
		{	
			if(!mark[i])
				dfs(i);
		}			

			
	}

void substring(string s,int n)
	{ 
		for(auto i=0;i<n;i++)
			{
				for(auto len=1;len<=n-i;len++)
					{	if(len==2)
						{
							string j="AB";
						if(s.substr(i,len).compare(j)==0)
							ans++;
						}
					}
			}
	}	

int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n;
string s;

ll a=0,b=0,c=0;
ll mark[10]={0};
cin>>n;

for(auto i=1;i<=n;i++)
	{	
		cin>>s;
		ll z=s.length();
		
		
			if(s[0]=='B')
			{	
				b++;
				mark[0]++;
			}
			if(s[z-1]=='A')
			{	
				a++;
				mark[z-1]++;
			}
		
		substring(s,z);

	}

	for(i=2;i<=9;i++)
	{
		if(mark[i]!=0)
			c++;

	}

	if(c==0)
		cout<<ans+min(a,b)-1<<endl;

		
	if(min(a,b)==n)
		cout<<ans+n-1<<endl;

	else
	cout<<ans + min(a,b)<<endl;
	

}		





Compiler output:
a.cc: In function 'bool dfs(long long int)':
a.cc:39:9: warning: no return statement in function returning non-void [-Wreturn-type]
   39 |         }
      |         ^
a.cc: In function 'int main()':
a.cc:95:13: error: 'i' was not declared in this scope
   95 |         for(i=2;i<=9;i++)
      |             ^
Language: C++

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

int main(){
	int n;
	std::cin>>n;

	std::vector<std::string> sList;
	sList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>sList[i];

	int numBottomA=0;
	int numTopB=0;
	int numBtATpB=0;

	int numAB=0;

	for(int i=0; i<n; i++){
		int bottom= sList[i].size()-1;

		if(sList[i][bottom]=='A')
			numBottomA++;

		if(sList[i][0]=='B')
			numTopB++;

		if(sListp[i][0]=='B' && sList[i][bottom]=='A')
			numBtATpB++;

		for(int j=0; j<bottom; j++)
			if(sList[i][j]=='A' && sList[i][j+1]=='B')
				numAB++;
	}


	if(std::min(numBottomA, numTopB)==0)
		std::cout<< numAB + numBtATpB-1 <<std::endl;
	else
		std::cout<< numAB + std::min(numBottomA, numTopB)<<std::endl;
	


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:20: error: 'sListp' was not declared in this scope; did you mean 'sList'?
   31 |                 if(sListp[i][0]=='B' && sList[i][bottom]=='A')
      |                    ^~~~~~
      |                    sList
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	char s[11];
	int i,j,cnt_AB = 0, cnt_A = 0, cnt_B = 0,cnt2=0,n;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", s);
		for (j = 0; s[j + 1] != '\0'; j++) {
			if (s[j] == 'A'&&s[j + 1] == 'B') {
				cnt_AB++;
				j++;
				if (s[j + 1] == '\0')
					break;
			}
		}
		if (s[0] == 'B')
			cnt_B++;
		if (s[j] == 'A')
			cnt_A++;
		if (s[0] == 'B'&&s[j] == 'A')
			cnt2++;
	}
	if (cnt_A > cnt_B) {
		if(cnt_A)
			cnt_AB += cnt_B;
	}
	else{
		if (cnt_B) {
			cnt_AB += cnt_A;
		}
	if (cnt_A + cnt_B == cnt2 && cnt2)
		cnt_AB--;
	printf("%d\n", cnt_AB);
	return 0;
}

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

N = int(input())
str_list = [input() for i in range(N)]

_a_cnt = 0
b__cnt = 0
b_a_cnt = 0
other_cnt = 0

ans = 0
for s in str_list:
    if s[0] == "B" and s[-1] == "A":
        b_a_cnt += 1
    elif s[-1] == "A":
        _a_cnt += 1
    elif s[0] == "B":
        b__cnt += 1
    else:
        other_cnt += 1
    ans += s.count("AB")

if _a_cnt > 0 and b__cnt > 0:
    ans += b_a_cnt + 1 + min(_a_cnt - 1, b__cnt - 1)
elif _a_cnt > 0 or b__cnt > 0:
    ans += b_a_cnt
else:
    ans += b_a_cnt - 1

print(ans)


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

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,cntB=0,cntA=0,cnt=0,cntAB=0;
  cin >> n;
  string s;
  for(int i=0; i<n; i++) {
    cin >> s;
    if(s[0]=='B'&&s[s.size()-1]=='A') {
      cntAB++;
    }
    else if(s[0]=='B') {
      cntB++;
    }
    else if(s[s.size()-1]=='A') {
      cntA++;
    }
    for(int j=0; j<s.size()-1; j++) {
      if(s[j]=='A'&&s[j+1]=='B') {
        cnt++;
      }
    }
  }
  if(cntAB==0) {
    cout << cnt+min(cntB,cntA) << endl;
    return 0;
  }
  if(cntAB!=0&&cntA+cntB>0) {
    cout << cnt+cntAB+min(cntA,cntB) << endl;
    return 0;
  }
  if(cntAB!=0&&cntA+cntB=0) {
    cout << cnt+cntAB-1 << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:14: error: lvalue required as left operand of assignment
   34 |   if(cntAB!=0&&cntA+cntB=0) {
      |      ~~~~~~~~^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h> 

using namespace std;

int main() {
  int n, cnt = 0, endA = 0, startB = 0;
  vector<string> s(n);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (size_t p = s[i].find("AB"); p != string::npos; p = s[i].find("AB", p + 1)) {
      cnt++;
    }
    if (s[i][-1] == "A") endA++;
    if (s[i][0] == "B") startB++;
  }
  cout << cnt + min(endA, startB) << endl;
  
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |     if (s[i][-1] == "A") endA++;
a.cc:15:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   15 |     if (s[i][0] == "B") startB++;
Language: C++

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

int main(void){
  int N;
  int A = 0; // xxxxxA
  int B = 0; // Bxxxxxx
  int AB = 0; // BxxxxxxA
  int out = 0;

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

}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: expected primary-expression before '+=' token
   27 |   out = += c;
      |         ^~
Language: C++

int main()
{
//    uint64_t N;
//    cin >> N;

//    for(int N = 1; N < 100; N++){
////        ct(6);
//        int c = calc(N);
//        int d = ct(N);
//        if(c != d){
//            cout << N << "\t" << c << "\t" << d << endl;
//        }
////        cout << calc(N) << "\t" << ct(N) << endl;
//    }

    cout << probC();

    return 0;
}

int probC(){
    int a = 0, b = 0, ab = 0, c = 0;
    std::string line;
    while (getline(std::cin, line))
    {
        if(line.back() == 'A'){
            if(line.front() == 'B'){
                ab += 1;
            }else{
                a += 1;
            }
        }else{
            if(line.front() == 'B'){
                b += 1;
            }
        }
        int i = 0;
        while((i = line.find("AB", i)) == string::npos)
            c++;
    }
    if(a == 0 && b == 0){
        return (ab > 1 ? ab - 1 : 0) + c;
    }else{
        return (a > b ? b : a) + ab + c;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'cout' was not declared in this scope
   16 |     cout << probC();
      |     ^~~~
a.cc:16:13: error: 'probC' was not declared in this scope
   16 |     cout << probC();
      |             ^~~~~
a.cc: In function 'int probC()':
a.cc:23:10: error: 'string' is not a member of 'std'
   23 |     std::string line;
      |          ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | int main()
a.cc:24:25: error: 'cin' is not a member of 'std'
   24 |     while (getline(std::cin, line))
      |                         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | int main()
a.cc:24:30: error: 'line' was not declared in this scope
   24 |     while (getline(std::cin, line))
      |                              ^~~~
a.cc:24:12: error: 'getline' was not declared in this scope
   24 |     while (getline(std::cin, line))
      |            ^~~~~~~
a.cc:38:43: error: 'string' has not been declared
   38 |         while((i = line.find("AB", i)) == string::npos)
      |                                           ^~~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>s(N);
  string S;
  
  for(int i=0;i<N;i++){
    cin>>s.at(i);
    S+=s.at(i); 
  }
  int count=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i,i+1)=="AB"){
      cout++;
    }
  }
  cout<<count<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:12: error: no matching function for call to 'std::__cxx11::basic_string<char>::at(int&, int)'
   17 |     if(S.at(i,i+1)=="AB"){
      |        ~~~~^~~~~~~
In file included from /usr/include/c++/14/string:54,
                 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/basic_string.h:1287:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::at(size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_reference = const char&; size_type = long unsigned int]'
 1287 |       at(size_type __n) const
      |       ^~
/usr/include/c++/14/bits/basic_string.h:1287:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/basic_string.h:1309:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::at(size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
 1309 |       at(size_type __n)
      |       ^~
/usr/include/c++/14/bits/basic_string.h:1309:7: note:   candidate expects 1 argument, 2 provided
a.cc:18:11: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   18 |       cout++;
      |       ~~~~^~
Language: C

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

using namespace std;

int main() {
	int n, i, ab = 0, b = 0,a = 0, btoa = 0;
	string in;
	vector<string> s;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> in;
		s.push_back(in);
		if (*in.begin() == 'B' && (in[in.size() - 1] == 'A')) {
			b++;
			a++;
			btoa++;
		}
		else if (*in.begin() == 'B') {
			b++;
		}
		else if (in[in.size() - 1] == 'A') {
			a++;
		}

		for (int j = 0; j < (int)in.length()-1; j++) {
			if (in.substr(j, 2) == "AB") {
				ab++;
			}
		}
	}

	if (a == btoa && b == btoa) {
		a = max(a-1,0);
	}
	cout << ab + min(a, b) << endl;

	return 0;
}

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

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>s(N);
  
  for(int i=0;i<N;i++){
    cin>>s.at(i);
  }
  string S=s.at(0);
  for(int i=1;i<N;i++){
    S+=s.at(i);
  }
  
  int count=0;
  for(int i=0;i<s.size();i++){
    if(S.at(i,i+1)=="AB"){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: conversion from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   13 |   string S=s.at(0);
      |            ~~~~^~~
a.cc:20:12: error: no matching function for call to 'std::__cxx11::basic_string<char>::at(int&, int)'
   20 |     if(S.at(i,i+1)=="AB"){
      |        ~~~~^~~~~~~
In file included from /usr/include/c++/14/string:54,
                 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/basic_string.h:1287:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::at(size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_reference = const char&; size_type = long unsigned int]'
 1287 |       at(size_type __n) const
      |       ^~
/usr/include/c++/14/bits/basic_string.h:1287:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/basic_string.h:1309:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::at(size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
 1309 |       at(size_type __n)
      |       ^~
/usr/include/c++/14/bits/basic_string.h:1309:7: note:   candidate expects 1 argument, 2 provided
Language: C++

#include<iostream>
#include<string>

using namespace std;

int main(void){
	
	int N,len,numA=0,numB=0,numAB=0,num=0;
	char *ret;
	
	//std::string s;
	
	cin>>N;
	
	string s;
	
	
	for(int i=0;i<N;i++){
		
		cin>>s;
		
		len=strlen(s);
		
		for(int j=0;j<N;j++){
			if(s[j]=='A' && s[j+1]=='B')
				num++;
		}
		if(s[0]=='B' && s[len-1]=='A')
			numAB++;
		if(s[0]=='B')
			numB++;
		if(s[len-1]=='A')
			numA++;
	}
	
	if(numA==numB)
		cout<<numA+numB+numAB-1+num;
	else if(numA>numB){
		if(numA-numB==numAB)
			cout<<num+numB+numAB;
		else if(numA-numB>numAB)
			cout<<num+numB+numAB;
		else
			cout<<num+numB+numA;
	}else{
		if(numB-numA==numAB)
			cout<<num+numA+numAB;
		else if(numB-numA>numAB)
			cout<<num+numA+numAB;
		else
			cout<<num+numB+numA;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:21: error: 'strlen' was not declared in this scope
   22 |                 len=strlen(s);
      |                     ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #include<string>
Language: C++

#include<iostream>
#include<string>
#define SIZE 10005
using namespace std;

char str[SIZE];

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  int a = 0, b = 0, ba = 0;
  for (int i = 0; i < n; i++) {
    cin >> str;
    int L = strlen(str);
	for (int j = 0; j + 1 < L; j++) {
	  if (str[j] == 'A' && str[j + 1] == 'B') cnt++;
	}
	if (str[0] == 'B') b++;
	if (str[L - 1] == 'A') a++;
	if (str[0] == 'B' && str[L - 1] == 'A') ba++;
  }
  cnt += min(a,b);
  if (a == ba && b == ba && b > 0) cnt--;
  cout << cnt << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: 'strlen' was not declared in this scope
   15 |     int L = strlen(str);
      |             ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #include<string>
Language: C++

#include<iostream>
#define SIZE 10005
using namespace std;

char str[SIZE];

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  int a = 0, b = 0, ba = 0;
  for (int i = 0; i < n; i++) {
    cin >> str;
    int L = strlen(str);
	for (int j = 0; j + 1 < L; j++) {
	  if (str[j] == 'A' && str[j + 1] == 'B') cnt++;
	}
	if (str[0] == 'B') b++;
	if (str[L - 1] == 'A') a++;
	if (str[0] == 'B' && str[L - 1] == 'A') ba++;
  }
  cnt += min(a,b);
  if (a == ba && b == ba && b > 0) cnt--;
  cout << cnt << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'strlen' was not declared in this scope
   14 |     int L = strlen(str);
      |             ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | #define SIZE 10005
Language: C++

#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N;
	string s[10010];
	cin >> N;
	int a = 0, b = 0, ab = 0, ba = 0;
	for (int i = 1; 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')ab++;
		}
		if (s[i][0] == 'B') {
			if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A')ba++;
			else b++;
		}
		if (s[i][s[i].length() - 1] == 'A') {
				if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A')ba++;
				else a++;
		}
	}
	ba = ba / 2;
	if (ba == 0)cout << ab + min(a, b);
	else if (b == 0 && a == 0)cout << ab + ba - 1;
	else cout << ab + ba + min(a, b);
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin >> N;
      |         ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<vector>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:25:21: error: 'cout' was not declared in this scope
   25 |         if (ba == 0)cout << ab + min(a, b);
      |                     ^~~~
a.cc:25:21: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:35: error: 'cout' was not declared in this scope
   26 |         else if (b == 0 && a == 0)cout << ab + ba - 1;
      |                                   ^~~~
a.cc:26:35: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:27:14: error: 'cout' was not declared in this scope
   27 |         else cout << ab + ba + min(a, b);
      |              ^~~~
a.cc:27:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: Java

import java.io.*;

public class Main{
  public static void main(String... args) throws IOException {
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String line = stdin.readLine();
    String[] in = line.split(" ");
    int n = Integer.parseInt(in[0]);
    System.err.println(n);
    int beginB = 0;
    int endA = 0;
    int naka = 0;
	for (int i=0; i<n; i++) {
	    line = stdin.readLine();
      	if (line.charAt(0) == 'B') {
          beginB++;
        }
      	if (line.charAt(line.size()-1) == 'A') {
          endE++;
        }
        naka += line.replace("AB");
    }
    System.err.println(beginB);
    System.err.println(endA);
    System.err.println(naka);
    
    System.out.println(naka + Math.min(beginB, endA));
  }
}

Compiler output:
Main.java:18: error: cannot find symbol
      	if (line.charAt(line.size()-1) == 'A') {
      	                    ^
  symbol:   method size()
  location: variable line of type String
Main.java:19: error: cannot find symbol
          endE++;
          ^
  symbol:   variable endE
  location: class Main
Main.java:21: error: no suitable method found for replace(String)
        naka += line.replace("AB");
                    ^
    method String.replace(char,char) is not applicable
      (actual and formal argument lists differ in length)
    method String.replace(CharSequence,CharSequence) is not applicable
      (actual and formal argument lists differ in length)
3 errors
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') {
      c++;
    } 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 (a==0 && b==0 && c>0) {
    d= c-1
  } else {
    d= min(a+c,b+c)+e;
  }
  cout << d << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:11: error: expected ';' before '}' token
   27 |     d= c-1
      |           ^
      |           ;
   28 |   } else {
      |   ~
Language: C++

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

int main(){
    int N;
    string S[10010];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    
    //まず内部のBAを数える
    int inside_BA=0;

    for(int i=0; i<N; i++){
        for(int j=0; j< ( S[i].size()-1 );j++){
            if(S[i].at(j)=='A' && S[i].at(j+1)=='B') inside_BA++;
        }
    }

    int B_A=0;
    int B_hoge=0;
    int hoge_A=0;

    for(int i=0; i<N; i++){
        if(S[i].at(0)=='B' && S[i].at(S[i].size()-1)=='A'){
            B_A++; continue;
        }
        if(S[i].at(0)=='B'){
            B_hoge++; 
        }
        if(S[i].at(S[i].size()-1)=='A'){
            hoge_A++;
        }
    }

    if(B_hoge>0 || hoge_A>0){
        cout << inside_BA + B_A + min(B_hoge, hoge_A)  << endl;
    }
    else{
        cout << inside_BA  + man(B_A,1) -1 << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:30: error: 'man' was not declared in this scope; did you mean 'tan'?
   41 |         cout << inside_BA  + man(B_A,1) -1 << endl;
      |                              ^~~
      |                              tan
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,both=0;
  rep(i,n){
    rep(j,s[i].length()-1){
      if(s[i].substr(j,2)=="AB"){
        ab++;
      }
    }
    if(s[i][0]=='B'){
      startb++;
    }
    if(s[i][s[i].length()-1]=='A'){
      enda++;
    }
    if(s[i][0]=='B' && s[i][s[i].length()-1]=='A'){
      startb--; enda--; both++;
  }
  if(startb==0 && enda==0 && both!=0){
    cout<<ab+both-1;
  }else{
    cout<<ab+min(enda,startb)+both;
  }
}


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

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

int max(int a,int b,int c,int n){
	if(b == n) b--;
	if(a == n) a--;
	if(startb==both && enda==both && both>0) b--;
	if(b < a) return b;
	else return a;
}

int main()
{
	int sums = 0,suma = 0,sumb = 0,both = 0;
	int n;
	char c[10005][11];
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%s",c[i]);
		for(int j = 0;j < strlen(c[i]) - 1;j++){
			if(c[i][j] == 'A' && c[i][j + 1] == 'B') sums++;
		}
		if(c[i][0] == 'B') sumb++;
		if(c[i][strlen(c[i]) - 1] == 'A') suma++;
		if(s[0]=='B' && s[strlen(s)-1]=='A') both++;
	}
	sums += max(suma,sumb,,both,n);
	printf("%d",sums);
	return 0;
}

Compiler output:
main.c: In function 'max':
main.c:7:12: error: 'startb' undeclared (first use in this function)
    7 |         if(startb==both && enda==both && both>0) b--;
      |            ^~~~~~
main.c:7:12: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:20: error: 'both' undeclared (first use in this function)
    7 |         if(startb==both && enda==both && both>0) b--;
      |                    ^~~~
main.c:7:28: error: 'enda' undeclared (first use in this function)
    7 |         if(startb==both && enda==both && both>0) b--;
      |                            ^~~~
main.c: In function 'main':
main.c:25:20: error: 's' undeclared (first use in this function)
   25 |                 if(s[0]=='B' && s[strlen(s)-1]=='A') both++;
      |                    ^
main.c:27:31: error: expected expression before ',' token
   27 |         sums += max(suma,sumb,,both,n);
      |                               ^
main.c:27:17: error: too many arguments to function 'max'
   27 |         sums += max(suma,sumb,,both,n);
      |                 ^~~
main.c:4:5: note: declared here
    4 | int max(int a,int b,int c,int n){
      |     ^~~
Language: C++

#include<cstdio>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
    char a[12];
    int n,i,x1=0,x2=0,x3=0,x4=0,sum=0,j;
    scanf("%d",&n);
    getchar();
    for(i=0;i<n;i++)
    {
        gets(a);
        int len=strlen(a);
        if(a[0]=='B'&&a[len-1]=='A')
            x1++;
        else if(a[0]=='B')
            x2++;
        else if(a[len-1]=='A')
            x3++;
        for(j=1;j<len;j++)
        {
            if(a[j]=='B'&&a[j-1]=='A')
                sum++;
        }
    }
    if(x1==0)
        sum+=min(x2,x3);
    else if(x2+x3==0)
        sum+=x1-1;
    else
    {
        sum+=x1+min(x2,x3);
    }
    printf("%d\n",sum);

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   13 |         gets(a);
      |         ^~~~
      |         getw
Language: C++

#include<iostream>
using namespace std;
 
int main(){
 
  int n;
  cin >> n;
  string s[n+1];
  int cnt = 0;
  int start = 0;
  int end = 0;
  int both = 0;
 
  for(int i=0; i<n; ++i){
  	cin >> s[i];
  }
  
  for(int i=0; i<n; ++i){
  	if(s[i][0] == 'B'){
     	start++;
    }
    if(s[i][s[i].length()-1] == 'A'){
     	end ++; 
    }
    if(s[i][0] == 'B' && s[i][s[i].length()-1] == 'A'){
    	both ++;
    }
  }
  
  for(int i=0; i<n; ++i){
  	while(s[i].find("AB") != -1){
      int num = s[i].find("AB");
      s[i][num] = 'C';
      cnt ++;
    }
  }
  if(both == start && both == end){
  	cnt += both - 1;
    cout << cnt << endl:
  }
  else if(min(start,end)  != n){
    cnt += min(start,end);
    cout << cnt <<endl;
  }else{
    cnt += min(start,end);
    cout << cnt-1 <<endl;  
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:24: error: expected ';' before ':' token
   39 |     cout << cnt << endl:
      |                        ^
      |                        ;
Language: C++

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

int fact(int n);
int nCr(int n, int r) { return fact(n) / (fact(r) * fact(n - r)); }

// Returns factorial of n
int fact(int n)
{
  int res = 1;
  for (int i = 2; i <= n; i++) res = res * i;
  return res;
}

int countAB(string s)
{
  int cnt;
  for (int i = 0; s[i] != '\0'; ++i) {
    if (s[i] == 'A') {
      if (s[i + 1] == 'B') {
        cnt++;
      }
    };
  }
  return cnt;
}

int main(void)
{
  int n;
  scanf("%d", &n);

  string s;

  int ans = 0;
  int sb = 0, ea = 0;  // num of start a & end b
  int both = 0;

  for (int i = 0; i < n; ++i) {
    cin >> s;
    int cnt = countAB(s);
    ans += cnt;
    if (s[0] == 'B' && *(s.end() - 1) == 'A') {
      ++both;
    }
    else if (s[0] == 'B') {
      ++sb;
    }
    else if (*(s.end() - 1) == 'A') {
      ++ea;
    }
  }

  int part = 0;
  for (int i = 0; i <= both; ++i) {
    part = max({part, nCr((sb + i), (ea + (both - i))),
                nCr((ea + i), (sb + (both - i)))});
  }

  printf("ans: %d\n", ans + part);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:15: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   58 |     part = max({part, nCr((sb + i), (ea + (both - i))),
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   59 |                 nCr((ea + i), (sb + (both - i)))});
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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:3:
/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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
Language: C++

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int n;
    //int pos;
    cin >> n;
    vector<string> s(n);
    bool flag;
    int ans = 0;
    int Akey = 0;
    int Bkey = 0;
    int minus = 0;
    rep(i,n)
    {
        cin >> s[i];
    }
    rep(i,n)
    {
        /*
        flag = false;
        rep(j,s[i].size())
        {
            if(flag)
            {
                if(s[i][j] == 'B')
                {
                    ans++;
                    //cout << "i is " << i << " and j is " << j << endl;
                }
                flag = false;
            }
            else if(s[i][j] == 'A') flag = true;
            else flag = false;
        }
        */
        string::size_type pos = s[i].find("AB");
        while (pos != std::string::npos)
        {
            pos = s[i].find("AB", pos + 2 );
            ans++;
        }
        if(s[i][s[i].size()-1] == 'A' && s[i][0] == 'B') minus++;
        else if(s[i][s[i].size()-1] == 'A') Akey++;
        else(s[i][0] == 'B') Bkey++;
    }
    //cout << "ans is" << ans << " and Akey is " << Akey << " and Bkey is " << Bkey << endl;
    //if(min(Akey,Bkey) <= minus) cout << ans + min(Akey,Bkey) - minus + 1 << endl;
    if(Akey + Bkey == 0 && minus != 0) cout << ans + minus - 1 << endl;
    else cout << ans + min(Akey,Bkey) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:29: error: expected ';' before 'Bkey'
   51 |         else(s[i][0] == 'B') Bkey++;
      |                             ^~~~~
      |                             ;
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(){
  int N; cin >> N;
  int a=0, b=0, ba = 0, ans=0;
  for(int i=0; i<N; i++) {
    string s_hold;
    cin >> s_hold;
    if (s_hold[0] == 'B') {
      b++;
    }
    for (int p = 0; p < s_hold.length() - 1; p++) {
      if (s_hold[p] == 'A') {
        if (s_hold[p+1] == 'B') {
          ans++;
        }
      }
    }
    if (s_hold[s_hold.length() - 1] == 'A') {
      a++;
    }
    if (s_hold[s_hold.length() - 1] == 'A' && s_hold[0] == 'B') ba++;
  }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:28:22: error: 'ab' was not declared in this scope; did you mean 'ba'?
   28 |   }else if(ba>0&&a+b-ab==0) ans = ans + ba - 1;
      |                      ^~
      |                      ba
Language: C++

#include<iostream>
using namespace std;
int main()
{
	int N;
	int ans = 0;
	int A = 0;
	int B = 0;
	cin >> N;
	char* str = new char;
	for (int i = 0; i < N; i++) {
		cin >> str;
		for (int j = 0; j < strlen(str); j++) {
			if (str[j] == 'A' && str[j + 1] == 'B')
				ans++;
		}
		if (str[strlen(str) - 1] == 'A')
			A++;
		if (str[0] == 'B')
			B++;
	}
	if (A <= B)
		ans += A;
	else
		ans += B;

	cout << ans;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:37: error: 'strlen' was not declared in this scope
   13 |                 for (int j = 0; j < strlen(str); j++) {
      |                                     ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc:17:25: error: 'strlen' was not declared in this scope
   17 |                 if (str[strlen(str) - 1] == 'A')
      |                         ^~~~~~
a.cc:17:25: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C

#include<stdio.h>
 
int main() {
	int i, j, k, n, t, m, b, h, w, r, g;
	long long int ab = 0, a1 = 0, b1 = 0;
	char s[15];
	long long int f = 0;
	h = 0;
 
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		scanf("%s", s);
		if (s[0] == 'B') {
			b1++;
		}
		for (j = 0;j < 12;j++) {
			if (s[j] == 'A') {
				if (s[j + 1] == 'B') {
					ab++;
				}
				else if (s[j + 1] == '\0') {
					a1++;
					break;
				}
			}
			else if (s[j] == '\0');
				break;
			}
		}
	}
	
	if (a1 < b1) {
		f = ab + a1;
	}
	else if(a1 > b1){
		f = ab + b1;
	}
	else if (a1 == b1) {
		if (a1 == n) {
			f = ab + a1 - 1;
		}
		else {
			f = ab + a1;
		}
	}
 
	printf("%lld",f);
 
 
	return 0;
}

Compiler output:
main.c:32:9: error: expected identifier or '(' before 'if'
   32 |         if (a1 < b1) {
      |         ^~
main.c:35:9: error: expected identifier or '(' before 'else'
   35 |         else if(a1 > b1){
      |         ^~~~
main.c:38:9: error: expected identifier or '(' before 'else'
   38 |         else if (a1 == b1) {
      |         ^~~~
main.c:47:16: error: expected declaration specifiers or '...' before string constant
   47 |         printf("%lld",f);
      |                ^~~~~~
main.c:47:23: error: unknown type name 'f'
   47 |         printf("%lld",f);
      |                       ^
main.c:50:9: error: expected identifier or '(' before 'return'
   50 |         return 0;
      |         ^~~~~~
main.c:51:1: error: expected identifier or '(' before '}' token
   51 | }
      | ^
Language: C++

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int n;
    //int pos;
    cin >> n;
    vector<string> s(n);
    bool flag;
    int ans = 0;
    int Akey = 0;
    int Bkey = 0;
    int minus = 0;
    rep(i,n)
    {
        cin >> s[i];
    }
    rep(i,n)
    {
        flag = false;
        rep(j,s[i].size())
        {
            /*
            if(flag)
            {
                if(s[i][j] == 'B')
                {
                    ans++;
                    //cout << "i is " << i << " and j is " << j << endl;
                }
                flag = false;
            }
            else if(s[i][j] == 'A') flag = true;
            else flag = false;
        }
        */
        string::size_type pos = s[i].find("AB");
        while (pos != std::string::npos)
        {
            pos = s[i].find("AB", pos + 2 );
            ans++;
        }
        if(s[i][s[i].size()-1] == 'A') Akey++;
        if(s[i][0] == 'B') Bkey++;
        if(s[i][s[i].size()-1] == 'A' && s[i][0] == 'B') minus++;
    }
    //cout << "ans is" << ans << " and Akey is " << Akey << " and Bkey is " << Bkey << endl;
    //if(min(Akey,Bkey) <= minus) cout << ans + min(Akey,Bkey) - minus + 1 << endl;
    if(Akey + Bkey == 0 && minus != 0) cout << ans + minus - 1 << endl;
    else cout << ans + min(Akey,Bkey) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:2: error: expected '}' at end of input
   57 | }
      |  ^
a.cc:10:1: note: to match this '{'
   10 | {
      | ^
Language: Java

import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt=0;
        int c1=0,c2=0,c3=0;
        int ans = 0;
        for(int i=0; i<n; i++){
            char[] s = sc.next().toCharArray();
            for(int j=0; j< s.length-1; j++){
                if(s[j]=='A' && s[j+1]=='B') cnt++;
            }
            if(s[0] == 'B' && s[s.length-1]=='A') c1++;
            else if(s[0]=='B') c2++;
            else if(s[s.length-1]) c3++;
        }
        if(c1 != 0){
            if(c2+c3 > 0){
                ans = Math.min(c2,c3) + c1;
            }else{
                ans = c1 - 1;
            }
        }else{
            ans = Math.min(c2,c1);
        }
        System.out.println(ans);
    }
}


Compiler output:
Main.java:16: error: incompatible types: char cannot be converted to boolean
            else if(s[s.length-1]) c3++;
                     ^
1 error
Language: C++

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

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

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

	long long int a = 0, b = 0, ba = 0;

	for (int i = 0; i < N; i++) {
		if (s[i][0] == 'B' && s[i][s[i].size() - 1] != 'A') {
			b++;
		}

		if (s[i][s[i].size() - 1] == 'A' && s[i][0] != 'B') {
			a++;
		}

		if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') {
			ba++;
		}
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: lvalue required as left operand of assignment
   36 |         else if (a + b = 0) cout << ans + b - 1 << endl;
      |                  ~~^~~
Language: Java

import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int a = 0;
    int b = 0;
    int ab = 0;
    int l = 0;
    int flg = 0;
    int ans = 0;
    
    for (int i=0; i<n; i++) {
	  String s = sc.next();
      l = s.length();
      if (s.substring(0,1).equals("B")) {
        b++;
      }
      if (s.substring(l-1,l).equals("A")) {
        a++;
      }
      if ( !((s.substring(0,1).equals("B") && (s.substring(l-1,l).equals("A")) ) {
        flg = 1;
      }
      for (int j=0; j<l-1; j++) {
	    if (s.substring(j, j+2).equals("AB")) {
          ab++;
        }
      }
    }
   
    if (a == b && flg == 0) {
	  ans = ab + Math.min(a,b) - 1;
    } else {
      ans = ab + Math.min(a,b);
    }
    
    System.out.println(ans);
  }
}


Compiler output:
Main.java:23: error: ')' expected
      if ( !((s.substring(0,1).equals("B") && (s.substring(l-1,l).equals("A")) ) {
                                                                                ^
1 error
Language: C++

#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	int ans = 0;
	int acnt = 0, bcnt = 0, gachiryoto = 0;
	while(n--)
	{
		string s;
		cin >> s;
		if (s.front() == 'B' && s.back()  == 'A') gachiryoto++;
		else if (s.front() == 'B') bcnt++;
		else if (s.back()  == 'A') acnt++;
		for (int i = 0; i < s.size()-1; i++)
		{
			if (s[i] == 'A' && s[i+1] == 'B') ans++;
		}
	}
	int x = min(acnt, gachiryoto);
	ans += x;
	gachiryoto -= x;
	int y = min(bcnt, gachiryoto)
	ans += y;
	gachiryoto -= y;
	ans += gachiryoto / 2;
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:27:9: error: expected ',' or ';' before 'ans'
   27 |         ans += y;
      |         ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
string a[10005];
int check[10005],n;
void DFS(int i,int &res,int start){
	int chon=0;
    for(int j=1;j<=n;j++){
        if(check[j]==0){

            if(start==0){
            	if((a[i][a[i].size()-1]=='A')&&((a[j][0]=='B'))){
                    res++;
                    check[j]=1;
	                chon=j;
	                break;
                }


            }
            else{
                if((a[i][0]=='B')&&((a[j][a[j].size()-1]=='A'))){
                    res++;
                    check[j]=1;
	                chon=j;
	                break;
                }
            }
        }
    }
    if(chon!=0){
    	//cout<<i<<" "<<chon<<endl;
    	DFS(chon,res,start);
    }
}
int main()
{
    long long ans=0;
    cin>>n;
    vector<int>v;
    int start=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if((a[i][a[i].size()-1]=='A')||(a[i][0]=='B')){
            v.push_back(i);
        }
        for(int j=1;j<a[i].size();j++){
            if((a[i][j]=='B')&&(a[i][j-1]=='A')){
                ans++;
            }
        }
    }
    //cout<<start<<endl;
	for(int i=0;i<v.size();i++){
		int start=v[i];
        if(check[start]==0){
        	check[start]=1;
	    	if(a[start][a[start].size()-1]=='A'){
	            DFS(start,ans,0);
	        }
	    	if(a[start][0]=='B'){
	            DFS(start,ans,1);
	        }
        }
    }
    cout<<ans<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:59:31: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   59 |                     DFS(start,ans,0);
      |                               ^~~
a.cc:6:21: note:   initializing argument 2 of 'void DFS(int, int&, int)'
    6 | void DFS(int i,int &res,int start){
      |                ~~~~~^~~
a.cc:62:31: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   62 |                     DFS(start,ans,1);
      |                               ^~~
a.cc:6:21: note:   initializing argument 2 of 'void DFS(int, int&, int)'
    6 | void DFS(int i,int &res,int start){
      |                ~~~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin>>N;
  int a=0,b=0,c=0,d=0;
  int ans=0;
  string s;
  for(int i=0;i<N;i++){
    cin>>s;
    if(s.at(s.size()-1)=='A') a++;
    if(s.at(0)=='B') b++;
    if(s.at(s.size()-1)=='A' && s.at(0)=='B') c++;
    for(int j=0;j<s.size()-1;j++)
      if(s.at(j)=='A' && s.at(j+1)=='B') d++;
  }
  a-=c;b-=c;
  if(a==0&&b==0&&C!=0) ans=c+d-1;
  else if(a==0&&b==0&&C==0) ans=d;
  else if((a!=0&&b==0) or (a==0&&b!=0)) ans=c+d;
  else ans=c+d+min(a,b);
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:18: error: 'C' was not declared in this scope
   17 |   if(a==0&&b==0&&C!=0) ans=c+d-1;
      |                  ^
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class MainC {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        int bsizea = 0;
        int sizea = 0;
        int bsize = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            String s = reader.readLine();
            for (int idx = s.indexOf("AB"); idx > -1; idx = s.indexOf("AB", idx + 2)) {
                count++;
            }
            if (s.startsWith("B") && s.endsWith("A")) {
                bsizea++;
            } else if (s.endsWith("A")) {
                sizea++;
            } else if (s.startsWith("B")) {
                bsize++;
            }
        }
        System.out.println(count + Integer.min(sizea, bsize)
                + ((sizea + bsize == 0) ? Integer.max(bsizea - 1, 0) : bsizea));
    }
}


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

N = int(input())
res = 0
both = 0
head = 0
last = 0
for i in range(N):
  inp = input()
  if 'AB' in inp:
    res += 1
  if 'B'==inp[0] and 'A'==inp[-1]:
    both+=1
  elif 'B'==inp[0]:
    head+=1
  elif 'A'==inp[-1]:
    last += 1
 
res += max(0,both -1)
if both !=0:
  res += 1 + min(head,last)
else:
  res += min(head,last)
print(res)

Compiler output:
a.cc:8:6: warning: multi-character character constant [-Wmultichar]
    8 |   if 'AB' in inp:
      |      ^~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, x,n,k;
    cin >>N;
  x=0;
  n=0;
  k=0;
  for(int i=0;i<N;i++){
    string s;
    cin >>s;
    int size;
    size = s.size();
    for(int t=0;t-1<size;t++){
      if(s.at(t)="A"){
        if(s.at(t+1)="B"){
          x++;}}
      
      if(s.at(0)="B"){
        k++;}
      if(s.at(size-1)="A"){
        n++;}
      
          
    
    
    
    
    
    
  }
    if(n>k){
    cout <<x+k;
    }else{
      cout <<x+n;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:18: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   17 |       if(s.at(t)="A"){
      |                  ^~~
      |                  |
      |                  const char*
a.cc:18:22: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   18 |         if(s.at(t+1)="B"){
      |                      ^~~
      |                      |
      |                      const char*
a.cc:21:18: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   21 |       if(s.at(0)="B"){
      |                  ^~~
      |                  |
      |                  const char*
a.cc:23:23: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   23 |       if(s.at(size-1)="A"){
      |                       ^~~
      |                       |
      |                       const char*
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^