Language: C++

#include<bits/stdc++.h>
using namespace std;
int N,min=3333333,ans=0,w[100001]={0},e[100001]={0},p,l,r;
int main(){
	
	string S;
	cin>>N>>S;
	if(S[0]=='W') w[0]=1;
	else e[0]=1;
	for(p=1;p<N;p++){
		if(S[p]=='W') w[p]=w[p-1]+1;
		else w[p]=w[p-1];
		if(S[p]=='E') e[p]=e[p-1]+1;
		else e[p]=e[p-1];
	}
	/*
	for(p=0;p!=N;p++){
		cout<<w[p]<<" ";
	}
	cout<<endl;
	for(p=0;p!=N;p++){
		cout<<e[p]<<" ";
	}
	*/
//--------------------
	for(p=0;p<N;p++){
		if(p==0){l=0;r=e[N-1]-e[p];}
		if(p==N-1){l=w[N-2];r=0;}
		if(p!=0&&p!=N-1){l=w[p-1];r=e[N-1]-e[p];}
		ans=l+r;
		if(ans<min) min=ans;
	}
	cout<<min;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:24: error: reference to 'min' is ambiguous
   31 |                 if(ans<min) min=ans;
      |                        ^~~
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:5696:5: note: candidates are: '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:5686:5: note:                 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:                 '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:7: note:                 'int min'
    3 | int N,min=3333333,ans=0,w[100001]={0},e[100001]={0},p,l,r;
      |       ^~~
a.cc:31:29: error: reference to 'min' is ambiguous
   31 |                 if(ans<min) min=ans;
      |                             ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidates are: '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:5686:5: note:                 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:                 '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:7: note:                 'int min'
    3 | int N,min=3333333,ans=0,w[100001]={0},e[100001]={0},p,l,r;
      |       ^~~
a.cc:33:15: error: reference to 'min' is ambiguous
   33 |         cout<<min;
      |               ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidates are: '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:5686:5: note:                 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:                 '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:7: note:                 'int min'
    3 | int N,min=3333333,ans=0,w[100001]={0},e[100001]={0},p,l,r;
      |       ^~~