Language: C++

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define print(x) (cout << x << endl)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  int n, cnt = 0, endA = 0, startB = 0, both = 0;
  cin >> n;
  vector<string> s(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].back() == 'A' && s[i].front() == 'B') both++;
    else if (s[i].back() == 'A') endA++;
    else if (s[i].front() == 'B') startB++;
  }
  
  // When c1 = 0, we can make additional min(c2, c3) ABs. When c1 ̸= 0, we can make additional c1 + min(c2, c3) ABs if c2 + c3 > 0, and additional c1 − 1 ABs if c2 + c3 = 0.
  
  if (both == 0) {
    cout << min(endA, startB) << endl;
  } else{
    if (endA + startB == 0) {
      cout << both - 1 << endl;
    } else {
      cout << both + min(endA + startB) << endl;
    }
  }
  
  
  // cout << "Case #" << C++ << ": " << cur_max << endl;  


}



Compiler output:
a.cc: In function 'int main()':
a.cc:72:25: error: no matching function for call to 'min(int)'
   72 |       cout << both + min(endA + startB) << endl;
      |                      ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:72:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   72 |       cout << both + min(endA + startB) << endl;
      |                      ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided