Language: C++

#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define PB push_back
#define MP make_pair
#define MOD (int)1e8
#define maxn (int)1e9
#define inf (int) 1e17
#define int long long
#define ll long long
#define vi vector<int> 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

int sumdigits (int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
signed main() {	
	start_routine;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
		
	int n;
	cin >> n;

	int east[n], west[n];

	string s;
	cin >> s;

	if (s[0]=='E') east[0]=1, west[0]=1;
	else east[0]=0, west[0]=1;

	for (int i = 1; i < n; i += 1) {
		east[i]=east[i-1]+signed(s[i]=='E');
		west[i]=west[i-1]+signed(s[i]=='W');
	}

	int mn = east[n-1]-east[0];
	for (int i = 1; i < n; i += 1) {
		int delta = west[i-1]+east[n-1]-east[i];
		mn = min(delta, mn);
	}
	cout << mn;
	end_routine;
}
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define PB push_back
#define MP make_pair
#define MOD (int)1e8
#define maxn (int)1e9
#define inf (int) 1e17
#define int long long
#define ll long long
#define vi vector<int> 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

int sumdigits (int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
signed main() {	
	start_routine;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
		
	int n;
	cin >> n;

	int east[n], west[n];

	string s;
	cin >> s;

	if (s[0]=='E') east[0]=1, west[0]=1;
	else east[0]=0, west[0]=1;

	for (int i = 1; i < n; i += 1) {
		east[i]=east[i-1]+signed(s[i]=='E');
		west[i]=west[i-1]+signed(s[i]=='W');
	}

	int mn = east[n-1]-east[0];
	for (int i = 1; i < n; i += 1) {
		int delta = west[i-1]+east[n-1]-east[i];
		mn = min(delta, mn);
	}
	cout << mn;
	end_routine;
}
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define PB push_back
#define MP make_pair
#define MOD (int)1e8
#define maxn (int)1e9
#define inf (int) 1e17
#define int long long
#define ll long long
#define vi vector<int> 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

int sumdigits (int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
signed main() {	
	start_routine;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
		
	int n;
	cin >> n;

	int east[n], west[n];

	string s;
	cin >> s;

	if (s[0]=='E') east[0]=1, west[0]=1;
	else east[0]=0, west[0]=1;

	for (int i = 1; i < n; i += 1) {
		east[i]=east[i-1]+signed(s[i]=='E');
		west[i]=west[i-1]+signed(s[i]=='W');
	}

	int mn = east[n-1]-east[0];
	for (int i = 1; i < n; i += 1) {
		int delta = west[i-1]+east[n-1]-east[i];
		mn = min(delta, mn);
	}
	cout << mn;
	end_routine;
}


Compiler output:
a.cc:73:5: error: redefinition of 'long long int sumdigits(long long int)'
   73 | int sumdigits (int n) {
      |     ^~~~~~~~~
a.cc:18:5: note: 'long long int sumdigits(long long int)' previously defined here
   18 | int sumdigits (int n) {
      |     ^~~~~~~~~
a.cc:81:8: error: redefinition of 'int main()'
   81 | signed main() {
      |        ^~~~
a.cc:26:8: note: 'int main()' previously defined here
   26 | signed main() {
      |        ^~~~
a.cc:128:5: error: redefinition of 'long long int sumdigits(long long int)'
  128 | int sumdigits (int n) {
      |     ^~~~~~~~~
a.cc:18:5: note: 'long long int sumdigits(long long int)' previously defined here
   18 | int sumdigits (int n) {
      |     ^~~~~~~~~
a.cc:136:8: error: redefinition of 'int main()'
  136 | signed main() {
      |        ^~~~
a.cc:26:8: note: 'int main()' previously defined here
   26 | signed main() {
      |        ^~~~