Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
 
    int m;
    cin >> m;
    vector<string> b(m);
    for (int i = 0; i < m; i++)
        cin >> b[i];
 
    vector<string> moji;
    vector<int> mojic;
    for (int i = 0; i < n; i++) {
        if (!(any_of(moji.begin(), moji.end(), [&](string x) { return x == a[i]; }))) {
            moji.push_back(a[i]);
            mojic.push_back(count(a[0], a[n - 1], a[i]));
        }
    }
    for (int i = 0; i < moji.size(); i++) {
        mojic[i] -= count(b.begin(), b.end(), moji[i]);
    }
 
    int answer = *max_element(mojic.begin(), mojic.end());
    if (answer > 0) {
        cout << answer << endl;
    } else {
        cout << 0 << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:34: error: no matching function for call to 'count(__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type&)'
   23 |             mojic.push_back(count(a[0], a[n - 1], a[i]));
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note: candidate: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h: In substitution of 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&) [with _IIter = std::__cxx11::basic_string<char>; _Tp = std::__cxx11::basic_string<char>]':
a.cc:23:34:   required from here
   23 |             mojic.push_back(count(a[0], a[n - 1], a[i]));
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: error: no type named 'difference_type' in 'struct std::iterator_traits<std::__cxx11::basic_string<char> >'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note:   candidate expects 4 arguments, 3 provided