criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <functional>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
 int n,wr=0,er=0; cin >> n;
 string s; cin >> s;
 rep(i,n){
   if(s[i] == 'W'){
     wr++;
   } else {
     er++;
   }
 }
 int ans;
 char keep; keep = s[0];
 if(s[0] == 'W'){
   ans = min(wr-1,er);
   wr -= 1;
 } else {
   ans = min(wr,er-1);
   er -= 1;
 }
 int wl = 0, el = 0;
 for(int j=1;j<n;j++){
   if(keep == 'W' && s[i] == 'W'){
     wl++;
     wr--;
   }
   if(keep == 'W' && s[i] == 'E'){
     wl++;
     er--;
   }
   if(keep == 'E' && s[i] == 'W'){
     el--;
     wr--;
   }
   if(keep == 'E' && s[i] == 'E'){
     el++;
     er--;
   }
   keep = s[i];
   ans = min(ans,wl+er);
 }
  
 cout << ans;
     
 
 
 return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:24: error: 'i' was not declared in this scope
   38 |    if(keep == 'W' && s[i] == 'W'){
      |                        ^
a.cc:42:24: error: 'i' was not declared in this scope
   42 |    if(keep == 'W' && s[i] == 'E'){
      |                        ^
a.cc:46:24: error: 'i' was not declared in this scope
   46 |    if(keep == 'E' && s[i] == 'W'){
      |                        ^
a.cc:50:24: error: 'i' was not declared in this scope
   50 |    if(keep == 'E' && s[i] == 'E'){
      |                        ^
a.cc:54:13: error: 'i' was not declared in this scope
   54 |    keep = s[i];
      |             ^
Language: Java

import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  String[]s=sc.next().split("",0);
  int min=0;
  for(int i=1;i<n;i++){
  	if(s[i].equals("E"))min++;
  }
  int now=min
	for(int i=0;i<n-1;i++){
      int m=now;
    	if(s[i].equals("W"))m++;
      	if(s[i+1].equals("E"))m--;
     	now=m;
       min=Math.min(m,min);
    }
  System.out.println(min);


}

}

Compiler output:
Main.java:11: error: ';' expected
  int now=min
             ^
1 error
Language: C++

#include <bits/stdc++.h>
#include <ctype.h>
#include <math.h>
using namespace std;


int main(){
    long N;
    string S;
    cin>>N>>S;

    int ans=N;
    for(long i=0;i<N;i++){
        long s=0;
        for(long j=0;j<i;j++)if(S[j]=='W')s++;
        for(long j=i+1;j<N;j++)if(S[j]=='E')s++;
        ans=min(s,ans);
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: no matching function for call to 'min(long int&, int&)'
   17 |         ans=min(s,ans);
      |             ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:17:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   17 |         ans=min(s,ans);
      |             ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: '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:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: '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:5696:5: note:   template argument deduction/substitution failed:
a.cc:17:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   17 |         ans=min(s,ans);
      |             ~~~^~~~~~~
Language: C++

#include <iostream>
using namespace std;

int main () {
  int N;
  string S;
  cin >> N >> S;
  int num_w[300010] = {0};
  if(S[0] == 'w') num_w[0] = 1;
  for (int i = 1; i < N; ++i) {
    if (S[i] == 'w'){
      num_w[i] = num_w[i-1] + 1;
    }
    else {
      num_w[i] = num_w[i-1];
    }
  }
  int ans = (N - 1) - (num_w[N-1] - num_w[0]);
  for (int i = 1; i < N; ++i) {
    int count = num_w[i-1] + (N - num_w[N-1]) - (i + 1 - num[i]);
    if (count < ans) ans = count;
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:58: error: 'num' was not declared in this scope; did you mean 'enum'?
   20 |     int count = num_w[i-1] + (N - num_w[N-1]) - (i + 1 - num[i]);
      |                                                          ^~~
      |                                                          enum
Language: C++

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  int n; cin>>n;
  std::vector<char> v;
  rep(i,0,n){
    cin >> v[i]
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:16: error: expected ';' before '}' token
   26 |     cin >> v[i]
      |                ^
      |                ;
   27 |   }
      |   ~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,ans=1145141,count;
  scanf("%d",&N);
  char we[N];
  int w[N],e[N];
  for(int i=0;i<N;i++){
    w[i]=0;e[i]=0;
  }
  scanf("%s",we);
  for(int i=0;i<N;i++){
    if(we[i]=='W'){
      w[i+1]=w[i]+1; e[i+1]=e[i];
    }
    if(we[i]='E'){
      e[i+1]=e[i]+1; w[i+1]=w[i];
    }
  }
  for(int i=1;i<=N;i++){
    ans = min(ans,e[n]-e[i]+w[i-1]);
  }
  printf("%d",ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:50:21: error: 'n' undeclared (first use in this function)
   50 |     ans = min(ans,e[n]-e[i]+w[i-1]);
      |                     ^
main.c:50:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main(){
    int N,M;
    cin >> N;
    char a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i] ;
    }

    for (int i=0; i<N; ++i){
        int sum=0;
        for (int j=0; j<i; ++j){
            if(a[j]=="W") sum += 1;
        }
        for (int j=i+1; j<N; ++j){
            if(a[j]=="E") sum += 1;
        }
        M=min(M,sum);
    }

    cout << M  << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |             if(a[j]=="W") sum += 1;
      |                ~~~~^~~~~
a.cc:19:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   19 |             if(a[j]=="E") sum += 1;
      |                ~~~~^~~~~
Language: C++

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

int main(){
    int N,M;
    cin >> N;
    char a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i] ;
    }

    for (int i=0; i<N; ++i){
        sum=0;
        for (int j=0; j<i; ++j){
            if(a[j]=='W') sum += 1;
        }
        for (int j=i+1; j<N; ++j){
            if(a[j]=='E') sum += 1;
        }
        M=max(M,sum);
    }

    cout << M  << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'sum' was not declared in this scope
   14 |         sum=0;
      |         ^~~
Language: C++

#include <stdio.h>
int main()
{
    int i, j, k, n;
    char s[10000];
    int cnt, cnt1, cnt2;

    scanf("%d", &n);
    getchar();
    gets(s);

    cnt = 10000;
    for (i = 0; i < n; i++)
    {
        cnt1 = cnt2 = 0;
        for (j = 0; j < i; j++)
        {
            if (s[j] == 'W')
                cnt1++;
        }
        for (k = i; k < n; k++)
        {
            if (s[k] == 'E')
                cnt2++;
        }
        cnt = cnt < (cnt1 + cnt2) ? cnt : (cnt1 + cnt2);
    }
    printf("%d\n", cnt);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   10 |     gets(s);
      |     ^~~~
      |     getw
Language: C++

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

int main()
{
    char s[10000];
    int n;
    int sum,minn = 99999;
    cin >> n;
    cin >> s;
    for(int i = 0 ; i < n ; i ++)
    {
        sum = 0;
        for(int j = 0 ; j < i ; j ++)
        {
            if(s[j] == 'W')
            {
                sum ++;
            }
        }
        for(int j = i + 1 ; j < n ; j ++)
        {
            if(s[j] == 'E')
            {
                sum ++;
            }
        }
        minn = min(mi,sum);
    }
    cout << minn << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:20: error: 'mi' was not declared in this scope; did you mean 'i'?
   29 |         minn = min(mi,sum);
      |                    ^~
      |                    i
Language: C++

#include<stdio.h>
#include<string.h>

int main()
{
    int T, str[9999], leader, min1 = 99999, cou = 0;
    char S[9999];

    scanf("%d", &T);

    getchar();

    gets(S);

    for(int i = 0; i < T; i++)
    {
        if(S[i] == 'W')
            str[i] = 0;
        else
            str[i] = 1;
    }
    for(leader = 0; leader < T; leader++)
    {
        for(int i = 0; i < T; i++)
        {
            if(i < leader && str[i] == 0)                      //在领导人左边而且向左边看
                cou++;
            if(i > leader && str[i] == 1)                      //在领导人右边而且向右边看
                cou++;
            if(i == leader)
                continue;
            //printf("%d\n", cou);
        }
        if(cou < min1)
            min1 = cou;
        cou = 0;
    }
    printf("%d\n", min1);
    return 0;                                             // 0 / W ←, 1 / E →
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   13 |     gets(S);
      |     ^~~~
      |     getw
Language: C++

#include<stdio.h>
#include<string.h>

int main()
{
    int T, str[1000000], leader, min1 = 1000000, cou = 0;
    char S[1000000];

    scanf("%d", &T);

    getchar();

    gets(S);

    for(int i = 0; i < T; i++)
    {
        if(S[i] == 'W')
            str[i] = 0;
        else
            str[i] = 1;
    }
    for(leader = 0; leader < T; leader++)
    {
        for(int i = 0; i < T; i++)
        {
            if(i < leader && str[i] == 0)                      //在领导人左边而且向左边看
                cou++;
            if(i > leader && str[i] == 1)                      //在领导人右边而且向右边看
                cou++;
            if(i == leader)
                continue;
            //printf("%d\n", cou);
        }
        if(cou < min1)
            min1 = cou;
        cou = 0;
    }
    printf("%d\n", min1);
    return 0;                                             // 0 / W ←, 1 / E →
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'gets' was not declared in this scope; did you mean 'getw'?
   13 |     gets(S);
      |     ^~~~
      |     getw
Language: C

#include <iostream>
#include <cstring>
using namespace std;
 
int main()
{
    char s[300005];
    int n;
 
    cin >> n;
    cin >> s;
 
    int sum[300005];
    for(int i = 1 ; i <= n ; i ++)
    {
       if(s[i-1]=='W')
       {
           sum[i]=sum[i-1] + 1;
       }
       else
       {
           sum[i]=sum[i-1];
       }
    }
 
    int minn=999999999;
    for(int i = 1 ; i <= n  ; i ++)
    {
        int cw=sum[i-1];
        int ce=(n-i)-(sum[n]-sum[i]);
        int ans=cw+ce;
        if(ans<minn)
             minn=ans;
    }
 
    cout << minn << endl;
    return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include<algorithm>
using namespace std;

char s[N];
int main()
{
    int n;
    string s;
    cin>>n>>s;
    int l=0,r=0;
    for(int i=1;i<n;i++){
        if(s[i]=='W') r++;
    }
    int ans=n-r-1;
    for(int i=1;i<n;i++){
        if(s[i-1]=='E')  l++;
        if(s[i]=='W') r--;
        ans=min(ans,n-l-r-1);
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc:7:8: error: 'N' was not declared in this scope
    7 | char s[N];
      |        ^
Language: C++

#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void) {
  int n;
  char s[300000];
  cin >> n >> s;

  int wcount[300000] = { 0 };
  for (int i = 1; i < n; i++) {
    if (i == 0) {
      continue;
    } else if (i == 1 and s[i - 1] == 'W') {
      wcount[i] = 1;
    } else if (i > 1 and s[i - 1] == 'W') {
      wcount[i] = 1 + wcount[i - 1];
    } else {
      wcount[i] = wcount[i - 1];
    }
  }

  int ecount[300000] = { 0 };
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      continue;
    } else if (i == n - 2 and s[i + 1] == 'E') {
      ecount[i] = 1;
    } else if (i < n - 2 and s[i + 1] == 'E') {
      ecount[i] = 1 + ecount[i + 1];
    } else {
      ecount[i] = ecount[i + 1];
    }
  }

  int res[300000] = { 0 };
  for (int i = 0; i < n; i++) {
    res[i] = wcount[i] + ecount[i];
  }
  sort(res, res + n);
  cout << res[0] << endl;
  return EXIT_SUCCESS;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'cin' was not declared in this scope
    9 |   cin >> n >> s;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 | 
a.cc:42:3: error: 'cout' was not declared in this scope
   42 |   cout << res[0] << endl;
      |   ^~~~
a.cc:42:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:42:21: error: 'endl' was not declared in this scope
   42 |   cout << res[0] << endl;
      |                     ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <algorithm>
  +++ |+#include <ostream>
    3 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 1000000005
#define NIL -1
ll mod = 1e9+7;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int E_cnt[n] = {0}, W_cnt[n] = {0};
    if(s[0] == 'E'){
        E_cnt[0] = 1;
        W_cnt[0] = 0;
    } else if(s[0] == 'W'){
        W_cnt[0] = 1;
        E_cnt[0] = 0;
    }
    for(int i = 1; i < n; i++){
        if(s[i] == 'E'){
            E_cnt[i] = E_cnt[i-1] + 1;
            W_cnt[i] = W_cnt[i-1];
        } else if(s[i] == 'W'){
            W_cnt[i] = W_cnt[i-1] + 1;
            E_cnt[i] = E_cnt[i-1];
        }
    }
    int mx = 0;
    mx = max(mx, E_cnt[n-1] E_cnt[0]);
    for(int i = 1; i < n; i++){
        int cnt;
        cnt = W_cnt[i-1] + E_cnt[n-1] - E_cnt[i];
        mx = max(mx, cnt);
    }
    cout << mx << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:28: error: expected ')' before 'E_cnt'
   33 |     mx = max(mx, E_cnt[n-1] E_cnt[0]);
      |             ~              ^~~~~~
      |                            )
Language: C++

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int A[N];
    A[0] = 0;

    for(int i = 1; i < N; i++){
        if(S[i] == 'E') A[0]++;
    }
    for(int i = 1; i < N; i++){
        A[i] = A[i-1];
        if(S[i-1] == 'W') A[i]++;

        if(S[i] == 'E') A[i]--;
    }

    int ans = INT_MAX;
    for(int i = 0; i < N; i++){
        // cout << A[i] << endl;
        ans = min(A[i], ans);
    }

    cout << ans << endl;
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:15: error: 'INT_MAX' was not declared in this scope
   23 |     int ans = INT_MAX;
      |               ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | #include <string>
Language: C++

N = int(input())
S = input()

w = 0
e = S[1:].count('E')
score = w + e

for i in range(1, N):
    if S[i] == 'E':
        e -= 1
    if S[i-1] == 'W':
        w += 1
    score = min(score, w + e)

print(score)

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,e=0,w=0;
  cin>>n
  char c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(c[i]=='E')
      e++;
    else
      w++;
  }
  int dp[n];
  if(c[0]=='E'){
    dp[0]=e-1;
  }else{
    dp[0]=e;
  }
  int m=dp[0];
  for(int i=1;i<n;i++){
    if(c[i]=='E'&&c[i-1]=='E'){
      dp[i]=dp[i-1]-1;
    }else if(c[i]=='E'&&c[i-1]=='W'){
      dp[i]=dp[i-1];
    }else if(c[i]=='W'&&c[i-1]=='E'){
      dp[i]=dp[i-1];
    }else{
      dp[i]=dp[i-1]+1;
    }
    m=min(m,dp[i]);
  }
  cout<<m;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: expected ';' before 'char'
    5 |   cin>>n
      |         ^
      |         ;
    6 |   char c[n];
      |   ~~~~   
a.cc:8:10: error: 'c' was not declared in this scope
    8 |     cin>>c[i];
      |          ^
a.cc:15:6: error: 'c' was not declared in this scope
   15 |   if(c[0]=='E'){
      |      ^
a.cc:22:8: error: 'c' was not declared in this scope
   22 |     if(c[i]=='E'&&c[i-1]=='E'){
      |        ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
int n,c = 0;
int c_min = 0;
string w,tmp1,tmp2;

int main(){
  int i,j=0;
  cin >> n;
  cin >> w;
  for(i=0;i<n;++i){
    c = 0;
    for(j=0;j<n;++j){
      if(i<j){
        if(w[j]=="E")++c;
      }else if(i>j){
        if(w[j]=="W")++c;
      }
    }
    if(c_min == 0 || c_min > c){
      c_min = c;
    }
  }
  cout << c_min << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |         if(w[j]=="E")++c;
a.cc:18:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   18 |         if(w[j]=="W")++c;
Language: C++

#include <iostream>
using namespace std;
int main() {
    int a=0,b=0,c=0,N,i;
    char *S;
	cin >> N >> S;
    for( i = 0; i < N; i++){
     if(strcmp("W",S)){
       a++; //西を向いてる人
     } else {
       b++; //東を向いている人
     }
   }
   if(a <= b){
    c = b - a;
   } else {
     c = a - b;
   }
  cout << c << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'strcmp' was not declared in this scope
    8 |      if(strcmp("W",S)){
      |         ^~~~~~
a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
int main() {
    int a=0,b=0,c=0,N,i;
    std::string S;
	cin >> N >> S;
    for( i = 0; i < N; i++){
     if( "W" == *S){
       a++; //西を向いてる人
     } else {
       b++; //東を向いている人
     }
   }
   if(a <= b){
    c = b - a;
   } else {
     c = a - b;
   }
  cout << c << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: no match for 'operator*' (operand type is 'std::string' {aka 'std::__cxx11::basic_string<char>'})
    8 |      if( "W" == *S){
      |                 ^~
Language: C++

#include <iostream>
using namespace std;
int main() {
    int a=0,b=0,c=0,N,S,R;
	cin >> N >> S;
  　for ( int i = 0; i < N; i++){
     if( "W" == S[i]){
       a++; //西を向いてる人
     } else {
       b++; //東を向いている人
     }
   }
   if(a <= b){
    c = b - a;
   } else {
     c = a - b;
   }
  cout << c << endl;
  return 0;
}

Compiler output:
a.cc:6:3: error: extended character 　 is not valid in an identifier
    6 |   　for ( int i = 0; i < N; i++){
      |   ^
a.cc: In function 'int main()':
a.cc:6:11: error: expected primary-expression before 'int'
    6 |   　for ( int i = 0; i < N; i++){
      |           ^~~
a.cc:6:22: error: 'i' was not declared in this scope
    6 |   　for ( int i = 0; i < N; i++){
      |                      ^
Language: C++

/*
    TASK:	Attention
	Tech:	Struct
    LANG: 	CPP
    AUTHOR: Ninnin
    SCHOOL: KVIS
*/
#include<bits/stdc++.h>
#include<conio.h>
#define iseast(x) ((x=='E')?1:0)
bool showinput=false,debug=false,processshow=false;
using namespace std;
struct near{
	int amount=0;
	int face = 0;
}a[30000];
int main()
{
	int N,k=0,min;
	char c;
	scanf("%d",&N);
	min=N;
	if(N!=0)
	{
		scanf(" %c",&c);
		if(iseast(c))
		{
			a[0].amount=1;
		}
		else
		{
			a[0].amount=1;
			a[0].face=1;
			a[1].amount=1;
			k=1;
		}
	}else
	{
		printf("0");
		return 0;
	}
	for(int i=1;i<N;i++)
	{
		scanf(" %c",&c);
		if(iseast(c)==a[k].face)
		{
			a[k].amount++;
		}else
		{
			k++;
			a[k].face=iseast(c);
			a[k].amount=1;
		}
	}
	bool isendE=(k+1)%2;
	if(showinput)
	{
		printf("k is %d\n",k);
		for(int i=0;i<=k;i++)
		{
			printf("%d %d\n",a[i].face,a[i].amount);
		}
		if(isendE)	printf("this end with east\n");
		else		printf("this end with west\n");
	}
	int j;
	int s=0;
	if(a[0].face==1)
	{
		int l;
		l=((isendE)?(k):(k-1));
		for(j=1;j<=l;j+=2)
		{
			s+=a[j].amount;
		}
		if(debug)	printf("%d %d \n",s,j);
		if(min>s)
		{
			min=s;
		}
		
		for(int i=l;i>0;i-=2)
		{
			s+=a[i].amount-a[i-1].amount;
			if(debug)
			{
				printf("%d %d %d",s,i,l);
			}
			if(min>s)
			{
				min=s;
				if(debug)	printf("yes");
			}
			//printf("\n");
		}
	}
	printf("%d ",min);
	getch();
    return 0;
}


Compiler output:
a.cc:9:9: fatal error: conio.h: No such file or directory
    9 | #include<conio.h>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

/*
    TASK:	Attention
	Tech:	Struct
    LANG: 	CPP
    AUTHOR: Ninnin
    SCHOOL: KVIS
*/
#include<bits/stdc++.h>
#include<conio.h>
#define iseast(x) ((x=='E')?1:0)
bool showinput=false,debug=false;
using namespace std;
struct near{
	int amount=0;
	int face = 0;
}a[30000];
int main()
{
	int N,k=0,min;
	char c;
	scanf("%d",&N);
	min=N;
	if(N!=0)
	{
		scanf(" %c",&c);
		a[0].face=iseast(c);
		a[0].amount = 1;
	}else
	{
		printf("0");
		return 0;
	}
	for(int i=1;i<N;i++)
	{
		scanf(" %c",&c);
		if(iseast(c)==a[k].face)
		{
			a[k].amount++;
		}else
		{
			k++;
			a[k].face=iseast(c);
			a[k].amount=1;
		}
	}
	if(showinput)
	{
		for(int i=0;i<=k;i++)
		{
			printf("%d %d\n",a[i].face,a[i].amount);
		}
	}
	int j;
	if(a[0].face==1)
	{
		for(int i=-1;i<=k;i+=2)
		{
			int s=0;
			
			for(j=1;j<=i;j+=2)
			{
				s+=a[j].amount;
			}
			if(debug)	printf("%d %d ",s,j);
			for(j=i+3;j<=k;j+=2)
			{
				s+=a[j].amount;
			}
			if(debug)	printf("%d %d\n",s,j);
			if(min>s)
			{
				min=s;
			}
		}
	}else{
		for(int i=-2;i<=k;i+=2)
		{
			int s=0;
			for(j=0;j<=i;j+=2)
			{
				s+=a[j].amount;
			}
			if(debug)	printf("%d %d",s,j);
			for(j=i+3;j<=k;j+=2)
			{
				s+=a[j].amount;
			}
			if(debug)	printf("%d %d\n",s,j);
			if(min>s)
			{
				min=s;
			}
		}
	}
	printf("%d ",min);
	//getch();
    return 0;
}


Compiler output:
a.cc:9:9: fatal error: conio.h: No such file or directory
    9 | #include<conio.h>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>

using namespace std;

main()
{
	int n, w = 0, e = 0;
	int p[n];
	for(int i = 0; i < n; i ++)
	{
		p[i] = 0;
	}
	string str;
	cin >> n >> str;
	for(int i = 0; i < n; i ++)
	{
		p[i] += e;
		if(str[i] == 'E')
		{
			e ++;
		}
	}
	for(int i = n-1; i >= 0; i --)
	{
		p[i] += w;
		if(str[i] == 'W')
		{
			w ++;
		}
	}
	int max_ = 0;
	for(int i = 0; i < n; i ++)
	{
		max_ = max(p[i], max);
	}
	cout << n-1-max_;

}


Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:34:27: error: no matching function for call to 'max(int&, <unresolved overloaded function type>)'
   34 |                 max_ = max(p[i], max);
      |                        ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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/stl_algobase.h:257:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:36: note:   no known conversion for argument 2 from '<unresolved overloaded function type>' to 'const int&'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |                         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <bits/stdc++.h>

// max, min, log, input is defined

using namespace std; 

int main(){
	int n, cou=0;
	int mini = 20000;
	char s[300100];
	cin >> n;
	cin >> s;
	for (int i = 0; i < n; ++i)
	{
		cou = 0;
		for (int j = 0; j < i; ++j)
		{
			if (s[j]!='E') cou++;
		}
		for (int j = i; j < n; ++j)
		{
			if (s[j]!='W') cou++;
		}
		mini = min(cou, mini)
	}
	cout << mini;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:38: error: expected ';' before '}' token
   24 |                 mini = min(cou, mini)
      |                                      ^
      |                                      ;
   25 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int k[300005];
int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 1; i < n; i++){
		if (s[i] == 'E') {
			k[0]++;
		}

	}
	
	for (int t = 1; t<n; t++) {
		if (s[t - 1] == 'W' && s[t] == 'W') {
			k[t] = k[t - 1] + 1;
		}
		else if (s[t - 1] == 'E'&& s[t] == 'E') {
			k[t] = k[t - 1] - 1;
		}
		else {
			k[t] = k[t - 1];
		}
	}
	int mon = 1000000;
	for (int t = 0; t<n; t++) {
      mon=min(k[t],mon)
	}

	cout << mon << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:24: error: expected ';' before '}' token
   28 |       mon=min(k[t],mon)
      |                        ^
      |                        ;
   29 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int k[300005];
int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 1; i < n; i++){
		if (s[i] == 'E') {
			k[0]++;
		}

	}
	
	for (int t = 1; t<n; t++) {
		if (s[t - 1] == 'W' && s[t] == 'W') {
			k[t] = k[t - 1] + 1;
		}
		else if (s[t - 1] == 'E'&& s[t] == 'E') {
			k[t] = k[t - 1] - 1;
		}
		else {
			k[t] = k[t - 1];
		}
	}
	int min = 1000000;
	for (int t = 0; t<n; t++) {
      k[t]=min(k[t],min)
	}

	cout << min << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:15: error: 'min' cannot be used as a function
   28 |       k[t]=min(k[t],min)
      |            ~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int n,hoge,an=400000;
char s[330000];

int main() {
    cin >> n >> s;
    for (x=0 ; x<n ; x++) if (s[x] == 'E') hoge++;

    an = hoge;

    for (x=0 ; x<n ; x++) {
        if (s[x] == 'E') hoge--;
        if (s[x] == 'W') hoge++;
        if (hoge < an) an = hoge;
    }
    cout << an << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:10: error: 'x' was not declared in this scope
   10 |     for (x=0 ; x<n ; x++) if (s[x] == 'E') hoge++;
      |          ^
a.cc:14:10: error: 'x' was not declared in this scope
   14 |     for (x=0 ; x<n ; x++) {
      |          ^
Language: C++

#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <list>

#define ll long long

using namespace std;
int a[300005];

int main() {
	int n;
	string s;
	
	cin >> n >> s;

	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'E') {
			a[0]++;
		}

	}
	
	for (int t = 1; t<n; t++) {
		if (s[t - 1] == 'W' && s[t] == 'W') {
			a[t] = a[t - 1] + 1;
		}
		else if (s[t - 1] == 'E'　&& s[t] == 'E') {
			a[t] = a[t - 1] - 1;
		}
		else {
			a[t] = a[t - 1];
		}
	}
	
	int min = 1000000;
	for (int t = 0; t<n; t++) {
		if (a[t]<min)min = a[t];
	}

	cout << min << "\n";
	return 0;
}


Compiler output:
a.cc:36:38: error: extended character 　 is not valid in an identifier
   36 |                 else if (s[t - 1] == 'E'　&& s[t] == 'E') {
      |                                      ^
a.cc: In function 'int main()':
a.cc:36:38: error: unable to find character literal operator 'operator""\U00003000' with 'char' argument
   36 |                 else if (s[t - 1] == 'E'　&& s[t] == 'E') {
      |                                      ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n;
  cin>>s;
  int a=0;
  int mi;
  for(int i=1;i<n;i++){
    if(s[i]=="E") a++;
  }
  mi=a;
  for(int i=0;i<n;i++){
    int b=0;
    for(int j=0;j<i;j++)
      if(s[i]=="W") b++;
    for(int j=i+1;j<n;j++)
      if(s[i]=="E") b++;
    mi=min(mi,b);
  }
  cout<<mi<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 |     if(s[i]=="E") a++;
a.cc:17:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |       if(s[i]=="W") b++;
a.cc:19:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   19 |       if(s[i]=="E") b++;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include "../cxx-prettyprint/prettyprint.hpp"

int main() {
    int N;
    std::string S;
    std::cin >> N;
    std::cin >> S;

    std::vector<int> east_bits(N);
    std::vector<int> west_bits(N);
    for (int i = 0; i < N; i ++) {
        east_bits[i] = S[i] == 'E';
        west_bits[i] = S[i] == 'W';
    }
    std::vector<int> east_cumsum;
    std::partial_sum(east_bits.begin(), east_bits.end(), std::back_inserter(east_cumsum));
    std::vector<int> west_cumsum;
    std::partial_sum(west_bits.begin(), west_bits.end(), std::back_inserter(west_cumsum));

    int min_changes = N;
    for (int i = 0; i < N; i ++) {
        if (i == 0) {
            int changes = east_cumsum[N - 1] - east_cumsum[0];
            min_changes = std::min(min_changes, changes);
        } else if (i == N - 1) {
            int changes = west_cumsum[N - 2];
            min_changes = std::min(min_changes, changes);
        } else {
            int changes_r = east_cumsum[N - 1] - east_cumsum[i];
            int changes_l = west_cumsum[i - 1];
            min_changes = std::min(min_changes, changes_r + changes_l);
        }
    }
    std::cout << min_changes << std::endl;
}


Compiler output:
a.cc:5:10: fatal error: ../cxx-prettyprint/prettyprint.hpp: No such file or directory
    5 | #include "../cxx-prettyprint/prettyprint.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++


#include "stdafx.h"
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;


int Init(string S) {
	int count = 0;
	for (int i = 1; i < S.length(); i++) {
		if (S[i] == 'E')count++;
	}
	return count;
}

int Slide(string S, int index,int prev) {//右へ右へ切れ目をずらす。
	if (S[index - 1] == 'E'&&S[index] == 'E')return prev - 1;
	if (S[index - 1] == 'W'&&S[index] == 'W')return prev + 1;
	return prev;
}

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int Min = Init(S);
	int prev = Min, next;
	for (int i = 1; i < N; i++) {
		next = Slide(S, i, prev);
		Min = min(next, Min);
		prev = next;
	}
	cout << Min<< endl;
	return 0;
}

Compiler output:
a.cc:2:10: fatal error: stdafx.h: No such file or directory
    2 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<btis/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;i++)
	{
		se[i]=0;
		sw[i]=0;
	}
	if(a[0]=='E')
	{
		se[0]=1;
	}
	else
	{
		sw[0]=1;
	}
	for(int i=1;i<n;i++)
	{
		if(a[i]=='E')
		{
			se[i]=se[i-1]=1;
			sw[i]=sw[i-1]; 
		}
		else
		{
			sw[i]=sw[i-1]+1;
			sw[i]=se[i-1];
		}
	}
	int minv=300005;
	for(int i=0;i<n;i++)
	{
		int sum=0;
		if(i==0)
		{
			sum=se[n-1]-se[0];
		}
		else if(i==n-1)
		{
			sum=sw[n-2];
		}
		else
		{
			sum=sw[i-1]+(se[n-1]-se[i]);
		}
		minv=min(minv,sum);
	}
	cout<<minv;
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: btis/stdc++.h: No such file or directory
    1 | #include<btis/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;i++)
	{
		se[i]=0;
		sw[i]=0;
	}
	
	if )(a[0]=='E')
	    se[0]=1;
	else
	    sw[0]=1;
	for(int i=0;i<n;i+)
	{
		if(a[i]=='E')  {
		    se[i]=s[i-1]+1;
		    sw[i]=sw[i-1];
		}
		else {
		    sw[i]=sw[i-1]+1;
		    se[i]=se[i-1];
		}
	}
	
	int minv = 300005;
	
	for(int i=0;i<n;i++)
	{
		int sum=0;
		if(i==0)
		   sum=se[n-1]-se[0];
	    else if(i==n-1)
	       sum= sw[n-2];
	    else
	       sum=sw[i-1]+(se[n-1]-se[i]);
	    
	    minv =min(minv,sum);
	}
	
	cout<<minv;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:12: error: expected '(' before ')' token
   16 |         if )(a[0]=='E')
      |            ^
      |            (
a.cc:18:9: error: 'else' without a previous 'if'
   18 |         else
      |         ^~~~
a.cc:20:27: error: expected primary-expression before ')' token
   20 |         for(int i=0;i<n;i+)
      |                           ^
a.cc:23:27: error: 's' was not declared in this scope
   23 |                     se[i]=s[i-1]+1;
      |                           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;++i){
		se[i]=0;
		sw[i]=0;
	}
	for(int i=0;i<n;i++){
		if(a[i]=='E')se[i]=s[i-1]+1;
		else sw[i-1]+1;
	}
	int minv=300000000;
	for(int i=0;i<n;++i){
		int mmm=0;
		if(i==0)
			mmm=se[n-1]-se[i];
		else if(i==n-1)
			mmm=sw[n-2];
		mmm=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,mmm);
	}
	cout<<minv<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:36: error: 's' was not declared in this scope
   14 |                 if(a[i]=='E')se[i]=s[i-1]+1;
      |                                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;++i){
		se[i]=0;
		sw[i]=0;
	}
	for(int i=0;i<n;i++){
		if(a[i]=='E')se[i]++;
		else sw[i]++;
	}
	int minx=300000000;
	for(int i=0;i<n;++i){
		int mmm=0;
		if(i==0)
			mmm=se[n-1]-se[i];
		else if(i==n-1)
			mmm=sw[n-2];
		mmm=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,mmm);
	}
	cout<<minv<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:17: error: 'minv' was not declared in this scope; did you mean 'minx'?
   25 |                 minv=min(minv,mmm);
      |                 ^~~~
      |                 minx
a.cc:27:15: error: 'minv' was not declared in this scope; did you mean 'minx'?
   27 |         cout<<minv<<endl;
      |               ^~~~
      |               minx
Language: C++

#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>

#include <tuple>
#include <functional>
#include <map>
using namespace std;

int n; string s;
vector<int> d;

// j, j+1
tuple<int, int, int , int > cnt(int j) {
    int lw = d[j];
    int le = j-lw;
    int rw = d[n] - d[j];
    int re = n-j-rw;
    assert(lw + le + rw + re == n);
    return make_tuple(lw,le,rw, re);
}

int main() {
    cin >> n>>s;
    d.resize(n+1);
    d[0] = 0;
    for (int i = 1; i <= n; ++i) {
        int p = 0;
        if (s[i-1] == 'W') p = 1;
        d[i] = d[i-1] + p;
    }
    int m = INT_MAX/3;
    for (int j = 1; j <=n ; ++j) {
        int ans = get<0>(cnt(j-1)) + get<3>(cnt(j));
        m = min(m, ans);
    }
    cout << m <<endl;

    return 0;
}


Compiler output:
a.cc: In function 'std::tuple<int, int, int, int> cnt(int)':
a.cc:23:5: error: 'assert' was not declared in this scope
   23 |     assert(lw + le + rw + re == n);
      |     ^~~~~~
a.cc:12:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   11 | #include <map>
  +++ |+#include <cassert>
   12 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>

#include <tuple>
#include <functional>
#include <map>
using namespace std;

int n; string s;
vector<int> d;

// j, j+1
tuple<int, int, int , int > cnt(int j) {
    int lw = d[j];
    int le = j-lw;
    int rw = d[n] - d[j];
    int re = n-j-rw;
    assert(lw + le + rw + re == n);
    return make_tuple(lw,le,rw, re);
}

int main() {
    cin >> n>>s;
    d.resize(n+1);
    d[0] = 0;
    for (int i = 0; i <= n; ++i) {
        int p = 0;
        if (s[i+1] == 'W') p = 1;
        d[i+1] = d[i] + p;
    }
    int m = INT_MAX/3;
    for (int j = 1; j <=n ; ++j) {
        int ans = get<0>(cnt(j-1)) + get<3>(cnt(j));
        m = min(m, ans);
    }
    cout << m <<endl;

    return 0;
}


Compiler output:
a.cc: In function 'std::tuple<int, int, int, int> cnt(int)':
a.cc:23:5: error: 'assert' was not declared in this scope
   23 |     assert(lw + le + rw + re == n);
      |     ^~~~~~
a.cc:12:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   11 | #include <map>
  +++ |+#include <cassert>
   12 | using namespace std;
Language: Java

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		// 人数Nの入力
        int N = sc.nextInt();

        // 文字列Sの入力
        String S = sc.next();

        // ループ
        int min = N;

        for (int i = 0; i < S.length(); i++)
        {
            int tmp = 0; // 振り向く人数

            // リーダーで列を分ける
            String left = S.substring(0, i);
            String right = S.substring(i + 1);

            // leftに含まれるWの数
            tmp += left.length() - left.replace("W", "").length();

            // rightに含まれるEの数
            tmp += right.length() - right.replace("E", "").length();

            // 最小値の更新
            if (tmp <= min)
            {
                min = tmp;
            }
        }

        // 出力
        System.out.println(min);

	}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
	public static void main(String[] args) {
	              ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: C++

#include <bits/stdc++.h>
#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    string s;
    cin >> s;
    
    int minimum = n;
    int count;
    
    //iteration iはリーダーの位置とみなす。
    rep(i, n){
        count = 0;
        rep(j, n){
            if(j < i){
                if(s[j] == 'W') count++;
            }
            if(i < j){
                if(s[j] == 'E') count++;
            }
        }
        minimum = min(minimum, count);
    }
    
    cout << minimum << endl;
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: mylib.h: No such file or directory
    2 | #include <mylib.h>
      |          ^~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>

int main(void){
    int n;scanf("%d",&n);
    char str[300000];
    int r[300000],l[300000];
    scanf("%s",str);
    int i;
    int cnt=0;
    for(i=0;i<n;i++){
        if(str[i]=='W')
            cnt++;
        r[i]=cnt;
    }
    cnt=0;
    for(i=n-1;i>=0;i--){
       if(str[i]=='E')
           cnt++;
        l[i]=cnt;
    }
    //k  r[k-1]+l[k+1]
    int min=r[n];
    for(i=0;i<n;i++){
        int a;
        if(i==0)
            a=l[1];
        else if(i==n-1)
            a=r[n-2];
        else
            a=r[i-1]+l[i+1];
        if(min>a)
            min=a;
    }
    
    
    

Compiler output:
main.c: In function 'main':
main.c:33:5: error: expected declaration or statement at end of input
   33 |     }
      |     ^
Language: C++

#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  cin>>N;
  string S;
  cin>>S;
  ll sum=0;
  for(ll i=1; i<N; ++i){
    if(S[i]=='E') ++sum;
  }
  ll ans = c;
  for(ll i=1; i<N; ++i){
    if(S[i]=='E') --sum;
    if(S[i-1]=='W') ++sum;
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}
  
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:12: error: 'c' was not declared in this scope
   29 |   ll ans = c;
      |            ^
a.cc: At global scope:
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	for(int i=0;i<n;i++)cin >>s[i];
	int c =0;
	for(int i=1;i<n;i++){
		if(s[i]=='E')c++
	}
	int ans = c;
	for(int i=1;i<n;i++){
		if(s[i]=='E')c--;
		if(s[i-1]=='W')c++;
		ans = min(ans,c);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:33: error: expected ';' before '}' token
   11 |                 if(s[i]=='E')c++
      |                                 ^
      |                                 ;
   12 |         }
      |         ~
Language: Java

import java.util.Scanner;

public class Main {

	static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		int N = s.nextInt();
		String str = str.nextLine();
		int[] w = new int[N];
		int[] e = new int[N];

		w[0] = str.charAt(0) == 'W' ? 1 : 0;
		for (int i = 1; i < N; i++) {
			w[i] = w[i - 1] + (str.charAt(i) == 'W' ? 1 : 0);
		}

		e[N - 1] = str.charAt(N - 1) == 'E' ? 1 : 0;
		for (int i = N - 2; 0 <= i; i--) {
			e[i] = e[i + 1] + (str.charAt(i) == 'E' ? 1 : 0);
		}

		int min = Math.min(w[N - 1], e[0]);
		for (int i = 1; i < N - 1; i++) {
			min = Math.min(min, w[i - 1] + e[i + 1]);
		}
		System.out.println(min);
	}
}

Compiler output:
Main.java:10: error: cannot find symbol
		String str = str.nextLine();
		                ^
  symbol:   method nextLine()
  location: variable str of type String
1 error
Language: C++

#include <cstdio>

int N;
char S[3*100000];

int res = 1 << 30;
int w[3*100000];
int e[3*100000];
int w=0;
int e=0;

int main() {
  scanf("%d", &N);
  scanf("%s",S);

  for (int i=1; i<N; i++) {
    if (S[i] == 'E'){
      e[i] = ++e;
      w[i] = w;
    } else {
      e[i] = e;
      w[i] = ++w;
    }
  }

  for (int i=1; i<N; i++) {
    int count = 0;
    count += w[i-1];
    count += e[N-1] - e[i];
    if (count < res) res = count;
  }

  printf("%d", res);
}


Compiler output:
a.cc:9:5: error: conflicting declaration 'int w'
    9 | int w=0;
      |     ^
a.cc:7:5: note: previous declaration as 'int w [300000]'
    7 | int w[3*100000];
      |     ^
a.cc:10:5: error: conflicting declaration 'int e'
   10 | int e=0;
      |     ^
a.cc:8:5: note: previous declaration as 'int e [300000]'
    8 | int e[3*100000];
      |     ^
a.cc: In function 'int main()':
a.cc:18:16: error: lvalue required as increment operand
   18 |       e[i] = ++e;
      |                ^
a.cc:19:14: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   19 |       w[i] = w;
      |              ^
      |              |
      |              int*
a.cc:21:14: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   21 |       e[i] = e;
      |              ^
      |              |
      |              int*
a.cc:22:16: error: lvalue required as increment operand
   22 |       w[i] = ++w;
      |                ^
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> array = new ArrayList<String>();
		int a = sc.nextInt();
		int E = a - 1;
		int W = 0;
		int sum = a;
		int countE = 0;
		int countW = 0;
		for (int i = 0; i < a; i++) {
			array.add(sc.next());
		}
		for (int j = 0; j < a; j++) {
			for (int k = 0; k < a; k++) {
				if (array.get(k).equals("E")) {
					countE++;
				}
				if (array.get(k).equals("W")) {
					countW++;
				}
			}
			countE = E - countE;
			countW = W - countW;
			if (sum > Math.abs(countE) + Math.abs(countW)) {
				sum = Math.abs(countE) + Math.abs(countW);
			}
			if (j == a - 1) {
				System.out.println(sum);
				return;
			}
			countE = 0;
			countW = 0;
			E--;
			W++;
		}
	}
}


Compiler output:
Main.java:4: error: class main is public, should be declared in a file named main.java
public class main {
       ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> array = new ArrayList<String>();
		int a = sc.nextInt();
		int E = a - 1;
		int W = 0;
		int sum = a;
		int countE = 0;
		int countW = 0;
		for (int i = 0; i < a; i++) {
			array.add(sc.next());
		}
			for (int k = 0; k < a; k++) {
				if (array.get(k).equals("E")) {
					countE++;
				}
				if (array.get(k).equals("W")) {
					countW++;
				}
			}
			countE = E - countE;
			countW = W - countW;
			if (sum > Math.abs(countE) + Math.abs(countW)) {
				sum = Math.abs(countE) + Math.abs(countW);
			}
			if (j == a - 1) {
				System.out.println(sum);
				return;
			}
			countE = 0;
			countW = 0;
			E--;
			W++;
		}
	}
}


Compiler output:
Main.java:41: error: class, interface, enum, or record expected
}
^
1 error