Language: C++

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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ans = 9999999;
  for (int i = 0; i < N; ++i) {
    int west = 0;
    int east = 0;
    for (int j = 0; j < N; ++j) {
      if (i != j) {
        if (i > j) {
          if (! S.compare(j, 1, 'W')) {
            east += 1;
          }
        }
        else {
          if (! S.compare(j, 1,'E')) {
            west += 1;
          }
        }
      }
    }
    if (west < east) {
      if (west < ans) {
        ans = west;
      }
    }
    else {
      if (east < ans) {
        ans = east;
      }
    }
  }
  cout << ans << "\n";
}

  

Compiler output:
a.cc: In function 'int main()':
a.cc:17:26: error: no matching function for call to 'std::__cxx11::basic_string<char>::compare(int&, int, char)'
   17 |           if (! S.compare(j, 1, 'W')) {
      |                 ~~~~~~~~~^~~~~~~~~~~
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:3428:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const _CharT*) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (near match)
 3428 |       compare(size_type __pos, size_type __n1, const _CharT* __s) const
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3428:7: note:   conversion of argument 3 would be ill-formed:
a.cc:17:33: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   17 |           if (! S.compare(j, 1, 'W')) {
      |                                 ^~~
      |                                 |
      |                                 char
/usr/include/c++/14/bits/basic_string.h:3249:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, int> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const _Tp&) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3249 |         compare(const _Tp& __svt) const
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3249:9: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/basic_string.h:3274:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, int> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const _Tp&) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3274 |         compare(size_type __pos, size_type __n, const _Tp& __svt) const
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3274:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = int]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = int; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:3274:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, int> std::__cxx11::basic_string<char>::compare(size_type, size_type, const _Tp&) const [with _Tp = char]'
 3274 |         compare(size_type __pos, size_type __n, const _Tp& __svt) const
      |         ^~~~~~~
a.cc:17:26:   required from here
   17 |           if (! S.compare(j, 1, 'W')) {
      |                 ~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, int>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3294:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, int> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const _Tp&, size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3294 |         compare(size_type __pos1, size_type __n1, const _Tp& __svt,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3294:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:3228:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3228 |       compare(const basic_string& __str) const
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3228:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/basic_string.h:3325:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 3325 |       compare(size_type __pos, size_type __n, const basic_string& __str) const
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3325:67: note:   no known conversion for argument 3 from 'char' to 'const std::__cxx11::basic_string<char>&'
 3325 |       compare(size_type __pos, size_type __n, const basic_string& __str) const
      |                                               ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:3362:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 3362 |       compare(size_type __pos1, size_type __n1, const basic_string& __str,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3362:7: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:3393:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const _CharT*) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3393 |       compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3393:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/basic_string.h:3467:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const _CharT*, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 3467 |       compare(size_type __pos, size_type __n1, const _CharT* __s,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3467:7: note:   candidate expects 4 arguments, 3 provided
a.cc:22:26: error: no matching function for call to 'std::__cxx11::basic_string<char>::compare(int&, int, char)'
   22 |           if (! S.compare(j, 1,'E')) {
      |                 ~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3428:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const _CharT*) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (near match)
 3428 |       compare(size_type __pos, size_type __n1, const _CharT* __s) const
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3428:7: note:   conversion of argument 3 would be ill-formed:
a.cc:22:32: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   22 |           if (! S.compare(j, 1,'E')) {
      |                                ^~~
      |                                |
      |                                char
/usr/include/c++/14/bits/basic_string.h:3249:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, int> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const _Tp&) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3249 |         compare(const _Tp& __svt) const
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3249:9: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/basic_string.h:3274:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, int> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const _Tp&) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3274 |         compare(size_type __pos, size_type __n, const _Tp& __svt) const
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3274:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/basic_string.h:3294:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, int> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(size_type, size_type, const _Tp&, size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 3294 |         compare(size_type __pos1, size_type __n1, const _Tp& __svt,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3294:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:3228:7: note: candidate: 'int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::compare(const std::__cxx11::basic_string