Language: C++

#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
#define per(i,a,b) for(register int i=(a),i##_st=(b);i>=i##_st;--i)
#define rpg(i,x) for(register int i=fir[x];i;i=e[i].nxt)
#define ull unsigned long long
#define fi first
#define se second
#define pb push_back
#define bin(i) (1<<i)
#define cls(x,y) memset(x,y,sizeof x)
typedef pair<int,int> pa;
typedef long long LL;
const int INF = 0x7fffffff;
const int oo = 0x3f3f3f3f;
/*const int _L = 1e6+5;
char ibuf[_L],*ih=ibuf+_L;
inline char gc(){return (ih==ibuf+_L?fread(ibuf,1,_L,stdin),ih=ibuf:0),*ih++;}
#define  getchar() gc() //*/
template <typename T>
inline void rd(T &x) {
    x = 0; int f = 1; char CH = getchar();
    while(!isdigit(CH)) {if(CH=='-')f=0;CH=getchar();}
    while(isdigit(CH)) {x=((x+(x<<2))<<1)+(CH-48);CH=getchar();}
    x=(f==1)?x:-x;  return;
}
const int MXN = 3e5 + 5;
int n,a[MXN],ans=INF_MAX,b[MXN];
char str[MXN];
int main()
{
#ifdef iloi
	   freopen("test.in","r",stdin);
#endif
	cin>>n; cin>>str+1;
	rep(i,1,n) if(str[i]=='W') a[i]=a[i-1]+1; else a[i]=a[i-1];
	per(i,n,1) if(str[i]=='E') b[i]=a[i+1]+1; else b[i]=b[i+1];
	rep(i,1,n) ans=min(ans,a[i-1]+b[i+1]);
	cout<<ans;
#ifdef iloi
	debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}


Compiler output:
a.cc:31:18: error: 'INF_MAX' was not declared in this scope; did you mean 'INT_MAX'?
   31 | int n,a[MXN],ans=INF_MAX,b[MXN];
      |                  ^~~~~~~
      |                  INT_MAX
a.cc: In function 'int main()':
a.cc:39:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |         rep(i,1,n) if(str[i]=='W') a[i]=a[i-1]+1; else a[i]=a[i-1];
      |             ^
a.cc:6:37: note: in definition of macro 'rep'
    6 | #define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
      |                                     ^
a.cc:39:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |         rep(i,1,n) if(str[i]=='W') a[i]=a[i-1]+1; else a[i]=a[i-1];
      |             ^
a.cc:6:43: note: in definition of macro 'rep'
    6 | #define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
      |                                           ^
a.cc:40:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   40 |         per(i,n,1) if(str[i]=='E') b[i]=a[i+1]+1; else b[i]=b[i+1];
      |             ^
a.cc:7:37: note: in definition of macro 'per'
    7 | #define per(i,a,b) for(register int i=(a),i##_st=(b);i>=i##_st;--i)
      |                                     ^
a.cc:40:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   40 |         per(i,n,1) if(str[i]=='E') b[i]=a[i+1]+1; else b[i]=b[i+1];
      |             ^
a.cc:7:43: note: in definition of macro 'per'
    7 | #define per(i,a,b) for(register int i=(a),i##_st=(b);i>=i##_st;--i)
      |                                           ^
a.cc:40:36: error: 'b' was not declared in this scope
   40 |         per(i,n,1) if(str[i]=='E') b[i]=a[i+1]+1; else b[i]=b[i+1];
      |                                    ^
a.cc:40:56: error: 'b' was not declared in this scope
   40 |         per(i,n,1) if(str[i]=='E') b[i]=a[i+1]+1; else b[i]=b[i+1];
      |                                                        ^
a.cc:41:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |         rep(i,1,n) ans=min(ans,a[i-1]+b[i+1]);
      |             ^
a.cc:6:37: note: in definition of macro 'rep'
    6 | #define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
      |                                     ^
a.cc:41:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |         rep(i,1,n) ans=min(ans,a[i-1]+b[i+1]);
      |             ^
a.cc:6:43: note: in definition of macro 'rep'
    6 | #define rep(i,a,b) for(register int i=(a),i##_end=(b);i<=i##_end;++i)
      |                                           ^
a.cc:41:39: error: 'b' was not declared in this scope
   41 |         rep(i,1,n) ans=min(ans,a[i-1]+b[i+1]);
      |                                       ^