Language: C++

#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  set<ll> frontB, bottomA, both;
  vector<string> s(N);
  ll ans = 0;
  rep(i, N){
    cin >> s[i];
    ll cnt = 0;
    ll len = s[i].size();
    if(s[i][0]=='B'){
      frontB.insert(i);
      cnt++;
    }
    if(s[i][s[i].size()-1]=='A'){
      bottomA.insert(i);
      cnt++;
    }
    rep(j, len-1){
      ans += (s[i].substr(j, 2)=="AB"?1:0);
    }
    if(cnt==2)both.insert(i);
  }

  if(bottomA.size()==frontB.size() and both.size() == frontB.size()){
    ans += max(bottomA.size()-1, 0);
  }else{
    ll tmp  = min(bottomA.size(), frontB.size());
    ans += min(tmp, N-1);
  }
  /*
  if(both.empty()){
    ans += min(bottomA.size(), frontB.size());
  }else if(both.size()==1 and bottomA.size()==1){
    ans += 1;
  }else if(both.size()==1 and frontB.size()==1){
    ans += 1;
  }else{
    ans += min(bottomA.size(), frontB.size());
  }
  */
  cout << ans;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:15: error: no matching function for call to 'max(std::set<long long int>::size_type, int)'
   87 |     ans += max(bottomA.size()-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: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:87:15: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   87 |     ans += max(bottomA.size()-1, 0);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~
/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:87:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   87 |     ans += max(bottomA.size()-1, 0);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~