criyle/codenet-compile-errors huggingface dataset:
Language: Java

int N=sc.nextInt();
int[] vec=new int[N];
char[] x=new char[N];
String S=sc.next();
int WL=0,ER=0;
for(int s=0;s<N;s++){
x[s]=S.charAt(s);}
for(int i=0;i<N;i++){
WL=0;ER=0;
for(int t=0;t<i;t++){
if(x[t]=='W')WL+=1;
}
for(int r=(i+1);r<N;r++){
  if(x[r]=='E')ER+=1;
}
vec[i]=(WL+ER);
}
Arrays.sort(vec);
System.out.println(vec[N-1]);
}
}


Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
int N=sc.nextInt();
^
  (use --enable-preview to enable unnamed classes)
Main.java:6: error: class, interface, enum, or record expected
for(int s=0;s<N;s++){
^
Main.java:6: error: class, interface, enum, or record expected
for(int s=0;s<N;s++){
            ^
Main.java:6: error: class, interface, enum, or record expected
for(int s=0;s<N;s++){
                ^
Main.java:7: error: class, interface, enum, or record expected
x[s]=S.charAt(s);}
                 ^
Main.java:8: error: class, interface, enum, or record expected
for(int i=0;i<N;i++){
            ^
Main.java:8: error: class, interface, enum, or record expected
for(int i=0;i<N;i++){
                ^
Main.java:9: error: class, interface, enum, or record expected
WL=0;ER=0;
     ^
Main.java:10: error: class, interface, enum, or record expected
for(int t=0;t<i;t++){
^
Main.java:10: error: class, interface, enum, or record expected
for(int t=0;t<i;t++){
            ^
Main.java:10: error: class, interface, enum, or record expected
for(int t=0;t<i;t++){
                ^
Main.java:12: error: class, interface, enum, or record expected
}
^
Main.java:13: error: class, interface, enum, or record expected
for(int r=(i+1);r<N;r++){
                ^
Main.java:13: error: class, interface, enum, or record expected
for(int r=(i+1);r<N;r++){
                    ^
Main.java:15: error: class, interface, enum, or record expected
}
^
Main.java:17: error: class, interface, enum, or record expected
}
^
Main.java:19: error: class, interface, enum, or record expected
System.out.println(vec[N-1]);
^
Main.java:20: error: class, interface, enum, or record expected
}
^
18 errors
Language: C++

#include <stdio.h>

int main(void)
{
  int N, i, k, error = 0, error_min;
  char s[300001];
  char test[300001];

  scanf("%d", &N);
  scanf("%s", &s);
  error_min = N / 2 + 1;


for(k  = 0; k < N; k+=){
  error = 0;
  for(i = 0; i < k; i++)   test[i] = 'E';
  for(i = k; i < N; i++)   test[i] = 'W';

  for(i = 0; i < N; i++) {
    if(s[i] != test[i]){
      error++;
      if(error > error_min) {
        k++;
        break;
      }
    }
  }

  if(error < error_min) error_min = error;
}

printf("%d\n", error_min);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:23: error: expected primary-expression before ')' token
   14 | for(k  = 0; k < N; k+=){
      |                       ^
Language: C++

#include <stdio.h>

int main(void)
{
  int N, i, k, error = 0, error_min;
  char s[300001];
  char test[300001];

  scanf("%d", &N);
  scanf("%s", &s);
  error_min = N / 2 + 1

for(k  = 0; k < N; k++){
  error = 0;
  for(i = 0; i < k; i++)   test[i] = 'E';
  for(i = k; i < N; i++)   test[i] = 'W';

  for(i = 0; i < N; i++)   if(s[i] != test[i]) error++;

  if(error < error_min) error_min = error;
}

printf("%d\n", error_min);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: expected ';' before 'for'
   11 |   error_min = N / 2 + 1
      |                        ^
      |                        ;
   12 | 
   13 | for(k  = 0; k < N; k++){
      | ~~~                     
a.cc:13:23: error: expected ';' before ')' token
   13 | for(k  = 0; k < N; k++){
      |                       ^
      |                       ;
Language: C++

#include<iostream>
#include <cmath>
#include <set>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int n;
string s;
int east[n];
int west[n];

int main(){
  cin >> n >> s;
  string x,y;
  vector<char> b;
  int num;
  int m = 3*100000;

  FOR(i,1,n){
    if(s[i]=='W') west[i]=west[i-1]+1;
    if(s[i]=='E') east[n-i-1]=east[n-i]+1;
  }

  for(int i=0;i<n;i++){
    num = east[i]+west[i];
    m = min(m,num);
  }

  cout << m << endl;
  return 0;
}

Compiler output:
a.cc:18:10: error: size of array 'east' is not an integral constant-expression
   18 | int east[n];
      |          ^
a.cc:19:10: error: size of array 'west' is not an integral constant-expression
   19 | int west[n];
      |          ^
Language: C++

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

int main(){

string a,b,s;
int n,cou;
int min = 300000;

  cin >> n;
  cin >> s;

  for(int i=0;i<n;i++){

    a = s.substr(0,i);
    b = s.substr(i+1,n-i);



    vector<char> va(a.begin(), a.end());
    vector<char> vb(b.begin(), b.end());


        cou+=count(va.begin(),va.end(),'W');
        cou+=count(vb.begin(),vb.end(),'E');

        if(min>cou){
          min = cou;
        }
        cou = 0;
    }



cout << min << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:14: error: 'count' was not declared in this scope; did you mean 'cou'?
   27 |         cou+=count(va.begin(),va.end(),'W');
      |              ^~~~~
      |              cou
Language: C

#include <stdio.h>
int NUM;
int MIN=0;
char elm[500000];

int main() {
  scanf("%d", &NUM);
  scanf("%S", elm);
  
  for (int leader=0; leader<NUM; leader++) {
    int diff_dir = 0;
    for (int member=0; member<leader; member++) {
      if (elm[leader] == 'E') {
        if (elm[leader] != elm[member])
          diff_dir++;
      }
      else if (elm[leader] == elm[member]))
        diff_dir++;
    }
    for (int member=leader+1; member<NUM; member--) {
      if ((elm[leader] == 'E') {
        if (elm[leader] == elm[member]))
        diff_dir++;
      }
      else if (elm[leader] != elm[member])
        diff_dir++;
    }    
    if (MIN > diff_dir)
      MIN = diff_dir;
  }
  
  printf("%d", MIN);
  
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:17:43: error: expected statement before ')' token
   17 |       else if (elm[leader] == elm[member]))
      |                                           ^
main.c:21:31: error: expected ')' before '{' token
   21 |       if ((elm[leader] == 'E') {
      |          ~                    ^~
      |                               )
main.c:24:7: error: expected expression before '}' token
   24 |       }
      |       ^
main.c:25:7: error: 'else' without a previous 'if'
   25 |       else if (elm[leader] != elm[member])
      |       ^~~~
main.c:25:35: error: 'member' undeclared (first use in this function)
   25 |       else if (elm[leader] != elm[member])
      |                                   ^~~~~~
main.c:25:35: note: each undeclared identifier is reported only once for each function it appears in
main.c:28:15: error: 'diff_dir' undeclared (first use in this function)
   28 |     if (MIN > diff_dir)
      |               ^~~~~~~~
main.c: At top level:
main.c:32:10: error: expected declaration specifiers or '...' before string constant
   32 |   printf("%d", MIN);
      |          ^~~~
main.c:32:16: error: expected declaration specifiers or '...' before 'MIN'
   32 |   printf("%d", MIN);
      |                ^~~
main.c:34:3: error: expected identifier or '(' before 'return'
   34 |   return 0;
      |   ^~~~~~
main.c:35:1: error: expected identifier or '(' before '}' token
   35 | }
      | ^
Language: C++

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

int N;
vector<char> S;

int count(int ii) {
	int ret = 0;

	for (int i = 0; i < ii; ++i) {
		if (S[i] == 'W') {
			++ret;
		}
	}

	for (int i = ii + 1; i < N; ++i) {
		if (S[i] == 'E') {
			++ret;
		}
	}

	return ret;
}

int main() {
	cin >> N;

	S.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
	}

	int ans = INT_MAX;
	for (int i = 0; i < N; ++i) {
		ans = min(ans, count(i));
	}

	cout << ans << endl;
}

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

#include <stdio.h>

int main(){
  int N;
  char s[3*10^5];
 int i;
  scanf("%d", &N);
  scanf("%s", s);
  
  int p;
  int c = 0;
  int x = 0;
  int maxc = 0;
  
  for(i = 1; i < N; i++){
    if(s[i-1] == 'E')
      c -= 1;
    else
      c += 1;
    
    if(c > maxc){
     maxc = c; 
      p = i;
    }          
  }
  
  for(i = 0; i < N; i++){
  if(i < p)
    if(s[i] == 'W')
      x += 1;
    
    if(i > P)
      if(s[i] == 'E')
      x += 1;
  }
  
  printf("%d\n", x);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:32:12: error: 'P' undeclared (first use in this function)
   32 |     if(i > P)
      |            ^
main.c:32:12: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

int main(){
  int N;
  char S[3*10^5];
 int i;
  scanf("%d", &N);
  scanf("%s", S);
  
  int p;
  int c = 0;
  int x = 0;
  int maxc = 0;
  
  for(i = 1; i < N; i++){
    if(s[i-1] == 'E')
      c -= 1;
    else
      c += 1;
    
    if(c > maxc){
     maxc = c; 
      p = i;
    }          
  }
  
  for(i = 0; i < N; i++){
  if(i < p)
    if(s[i] == 'W')
      x += 1;
    
    if(i > P)
      if(s[i] == 'E')
      x += 1;
  }
  
  printf("%d\n", x);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:16:8: error: 's' undeclared (first use in this function)
   16 |     if(s[i-1] == 'E')
      |        ^
main.c:16:8: note: each undeclared identifier is reported only once for each function it appears in
main.c:32:12: error: 'P' undeclared (first use in this function)
   32 |     if(i > P)
      |            ^
Language: C

#include <stdio.h>

int main(){
  int N;
  char S[3*10^5];
 int i;
  scanf("%d", &N);
  scanf("%s", S);
  
  int p;
  int c = 0;
  int maxc = 0;
  
  for(i = 1; i < N; i++){
    if(S[i-1] == W)
     c -= 1;
    else
     c += 1;
    
    if(maxc > c){
     maxc = c;
      p = i;
    }
  }
  printf("%d\n", c);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:15:18: error: 'W' undeclared (first use in this function)
   15 |     if(S[i-1] == W)
      |                  ^
main.c:15:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

    #include <stdio.h>
    #define MAX_NUM 300000
     
    int main() {
      int N;
      char S[MAX_NUM + 1];
      
      scanf("%d", &N);
      scanf("%s", S);
      
      int i;
      int W_all = 0;
      int E_all = 0;
      
      for (i = 0; i < N; i++) {
        if (S[i] == 'W') {
          W_all += 1;
        }
        if (S[i] == 'E') {
          E_all += 1;
        }
      }
      
      int W_count = 0;
      int E_count = 0;
      int scrore = 0;
      int min_score = MAX_NUM;
      
      for (i = 0; i < N; i++) {
        score = W_count + E_all - E_count;
        if (S[i] == 'W') {
          W_count += 1;
        }
        if (S[i] == 'E') {
          E_count += 1;
          score -= 1;
        }
        
        if (score < min_score) {
          min_score = score;
        }
      }
      
      printf("%d\n", min_score);
        
      return 0;
    }

Compiler output:
main.c: In function 'main':
main.c:30:9: error: 'score' undeclared (first use in this function); did you mean 'scrore'?
   30 |         score = W_count + E_all - E_count;
      |         ^~~~~
      |         scrore
main.c:30:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#MAX_NUM 300000

int main() {
  int N;
  char S[MAX_NUM + 1];
  
  scanf("%d", &N);
  scanf("%s", S);
  
  int i;
  int W_all = 0;
  int E_all = 0;
  
  for (i = 0; i < N; i++) {
    if (S[i] == 'W') {
      W_all += 1;
    }
    if (S[i] == 'E') {
      E_all += 1;
    }
  }
  
  int W_count = 0;
  int E_count = 0;
  int scrore = 0;
  int min_score = MAX_NUM;
  
  for (i = 0; i < N; i++) {
    score = W_count + E_all - E_count;
    if (S[i] == 'W') {
      W_count += 1;
    }
    if (S[i] == 'E') {
      E_count += 1;
      score -= 1;
    }
    
    if (score < min_score) {
      min_score = score;
    }
  }
  
  printf("%d\n", min_score);
    
  return 0;
}

Compiler output:
main.c:2:2: error: invalid preprocessing directive #MAX_NUM
    2 | #MAX_NUM 300000
      |  ^~~~~~~
main.c: In function 'main':
main.c:6:10: error: 'MAX_NUM' undeclared (first use in this function)
    6 |   char S[MAX_NUM + 1];
      |          ^~~~~~~
main.c:6:10: note: each undeclared identifier is reported only once for each function it appears in
main.c:30:5: error: 'score' undeclared (first use in this function); did you mean 'scrore'?
   30 |     score = W_count + E_all - E_count;
      |     ^~~~~
      |     scrore
Language: Java

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String S = scan.next();
		int[] atWestToEast = new int[N];
		int[] atEastToWest = new int[N];
		int count = 0;
		int min = Integer.MAX_VALUE;
		for (int i = 1; i < N; i++) {
			if (S.charAt(i - 1) == 'W') {
				atWestToEast[i] = atWestToEast[i - 1] + 1;
			} else {
				atWestToEast[i] = atWestToEast[i - 1];
			}
			if (S.charAt(i) == 'E') {
				count++;
				atEastToWest[i] = atEastToWest[i - 1] - 1;
			} else {
				atEastToWest[i] = atEastToWest[i - 1];
			}
			 min = Math.min(min, atEastToWest[i] + atWestToEast[i]);
		}
		System.out.println(Math.min(0, min) + count);
	}

}

Compiler output:
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>

#define REP(i,n) for(int i = 0; i < (n); i++)
#define REPC(x,c) for(auto x:(c))
#define FOR(i, b, e) for(int i = (b); i < (e); i++)
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

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

	int w = 0;
	int e = 0;

	REPC(c, s) {
		if (c == 'E') {
			++e;
		}
	}

	int val = INT_MAX;
	REPC(c, s) {
		if (c == 'E') {
			--e;
		}

		val = min(val, w + e);

		if (c == 'W') {
			++w;
		}
	}

	cout << val << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:19: error: 'INT_MAX' was not declared in this scope
   32 |         int val = INT_MAX;
      |                   ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <stack>
  +++ |+#include <climits>
    8 |
Language: C

#include<stdio.h>
int main(){
  int N;
  char S[300001];
  int count,i;
  int min;
  
  scanf("%d", &N);
  scanf("%s", S);
  
  if(N<2||30000<N)return (-1);
  
  for(i=1;i<N;i++){
    if(S[i]=='E') count++;
  }
  min = count;
  for(i=1;i<N;i++){
    if(S[i]=='E')count--;
    if(S[i-1]=='W')count++;
    if(min>=count){min=count;}
  }
  printf("%d\n",min);
  return 0;


Compiler output:
main.c: In function 'main':
main.c:23:3: error: expected declaration or statement at end of input
   23 |   return 0;
      |   ^~~~~~
Language: C

#include<stdio.h>
int main(){
  int N;
  char S[300001];
  int count;
  int min;
  
  scanf("%d", &N);
  scanf("%s", S);
  
  if(N<2||30000<N)return (-1);
  
  for(i=1;i<N;i++){
    if(S[i]=='E') count++;
  }
  min = count;
  for(i=1;i<N;i++){
    if(S[i]=='E')count--;
    if(S[i-1]=='W')count++;
    if(min>=count){min=count;}
  }
  printf("%d\n",min);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:7: error: 'i' undeclared (first use in this function)
   13 |   for(i=1;i<N;i++){
      |       ^
main.c:13:7: note: each undeclared identifier is reported only once for each function it appears in
Language: Java

class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int countDiff = 0;

		int permMax = scan.nextInt();
		String perm = scan.next();

		System.out.println(permMax);
		System.out.println(perm);

		//slim
		char pre = '0';
		for(char next : perm.toCharArray()){
			//first time
			if(pre == '0'){
				pre = next;
				countDiff++;
				continue;
			}

			//different arrow
			if(pre != next){
				countDiff++;
			}

			//set next
			pre = next;
		}

		//print
		System.out.println(countDiff / 2);
	}
}

Compiler output:
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  vector<int> left_w(n, 0), right_e(n, 0);
  left_w[0] == (s[i] == 'W') ? 1 : 0;
  right_e[n-1] == (s[n-1] == 'E') ? 1 : 0;
  for(int i = 1; i < n; ++i){
    left_w[i] = left_w[i-1] + ((s[i] == 'W') ? 1 : 0);
    right_e[n-1-i] = right_e[n-i] + ((s[n-1-i] == 'E') ? 1 : 0);
  }
  int min = n;
  for(int i = 0; i < n; ++i){
    int temp = left_w[i] + right_e[i];
    if(temp < min) min = temp;
  }
  cout << min << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: 'i' was not declared in this scope
    9 |   left_w[0] == (s[i] == 'W') ? 1 : 0;
      |                   ^
Language: Java

import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
int[] vec=new int[N];
char[] x=new char[N];
String S=sc.next();
int WL=0,ER=0,Min=N;
for(int s=0;s<N;s++){
x[s]=S.charAt(s);}
for(int i=0;i<N;i++){

for(int t=0;t<i;t++){

if(x[t]=='W'){
    WL+=1;
}
}
for(int r=(i+1);r<N;r++){
  if(x[r]=='E')
    ER+=1;
}}
vec[i]=(WL+ER);
Min=Math.min(Min,vec[i]);
if(Min==0)break;
}


System.out.println(Min);
}
}


Compiler output:
Main.java:30: error: <identifier> expected
System.out.println(Min);
                  ^
Main.java:30: error: <identifier> expected
System.out.println(Min);
                      ^
Main.java:32: error: class, interface, enum, or record expected
}
^
3 errors
Language: Java

import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
int[] vec=new int[N];
char[] x=new char[N];
String S=sc.next();
int WL=0,ER=0,Min=N;
for(int s=0;s<N;s++){
x[s]=S.charAt(s);}
for(int i=0;i<N;i++){

for(int t=0;t<i;t++){

if(x[t]=='W'){
    WL+=1;
}
}
for(int r=(i+1);r<N;r++)
  if(x[r]=='E'){
    ER+=1;
}

    }
vec[i]=(WL+ER);
Min=Math.min(Min,vec[i]);
if(Min==0)break;
}


System.out.println(Min);
}
}


Compiler output:
Main.java:32: error: <identifier> expected
System.out.println(Min);
                  ^
Main.java:32: error: <identifier> expected
System.out.println(Min);
                      ^
Main.java:34: error: class, interface, enum, or record expected
}
^
3 errors
Language: C++

#include "stdafx.h"
#include "cstring"
#include "iostream"

using namespace std;


int main()
{
	int N;
	char s[300000];
	cin >> N;
	cin >> s;
	int t;
	char E[2] = "E";
	char W[2] = "W";
	int Et[300001] = { 0 };
	int Wt[300001] = { 0 };
	int min=10000000;
	for (t = 1; t < N+1; t++) {

		if (s[t - 1] == E[0]) {
			Et[t] = Et[t - 1] + 1;
		}
		else {
			Et[t] = Et[t - 1];
		}

		if (s[t - 1] == W[0]) {
			Wt[t] = Wt[t - 1] + 1;
		}
		else {
			Wt[t] = Wt[t - 1];
		}
	}

	for (t = 1; t < N + 1; t++) {
		if ((Wt[t - 1] + Et[N] - Et[t + 1]) < min) {
			min = Wt[t - 1] + Et[N] - Et[t + 1];
		}
	}

	cout << min;
    return 0;
}

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

#include<stdio.h>
#include <string.h>
#include <stdlib.h>
int compare(char *s,int i,int n){
	int cl=0,cr=0;
	int j;
	for (j=0;j<i;j++)
		if (s[j]=='w')
			cl++;
	for (j=i+1;j<n;j++)
		if (s[j]=='e')		
			cr++;
	return cl+cr;
}
int main(){
	char *s;
	int n,min,minPos,len,i;

	scanf("%d",&n);
	s=(char *)malloc(sizeof(char)*(n+1));
	getchar();
	gets(s);	

	min=n;
	minPos=0;	
	
	for (i=0;i<n;i++){
		if (compare(s,i,n)<min){
			min=compare(s,i,n);
			minPos=i;
		}
	}
	printf("%d\n",min);	
}

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


int main() {

    int N; cin >> N;
    string st; cin >> st;

    vector<int> s(N);
    if (st[0] == 'W') s[0] = 1;
    else s[0] = 0;
    for (int i = 1; i < N; i++) {
        s[i] = s[i-1];
        if (st[i] == 'W') s[i]++;

    }

    int ans = (1<<21);
    for (int i = 0; i < N; i++) {
        
        if (i == 0) {
            ans = min(ans, (N-1-s[N-1]+s[0]) );

        } else if ( i == N-1 ) {

            ans = min(ans, s[N-2]);
        } else {
            ans = min(ans, s[i-1] + (N-i-1 - s[N-1] + s[i]));
        }
    }

    cout << ans << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:4:12: error: 'cin' was not declared in this scope
    4 |     int N; cin >> N;
      |            ^~~
a.cc:5:5: error: 'string' was not declared in this scope
    5 |     string st; cin >> st;
      |     ^~~~~~
a.cc:5:23: error: 'st' was not declared in this scope; did you mean 'std'?
    5 |     string st; cin >> st;
      |                       ^~
      |                       std
a.cc:7:5: error: 'vector' was not declared in this scope
    7 |     vector<int> s(N);
      |     ^~~~~~
a.cc:7:12: error: expected primary-expression before 'int'
    7 |     vector<int> s(N);
      |            ^~~
a.cc:8:23: error: 's' was not declared in this scope
    8 |     if (st[0] == 'W') s[0] = 1;
      |                       ^
a.cc:9:10: error: 's' was not declared in this scope
    9 |     else s[0] = 0;
      |          ^
a.cc:11:9: error: 's' was not declared in this scope
   11 |         s[i] = s[i-1];
      |         ^
a.cc:20:33: error: 's' was not declared in this scope
   20 |             ans = min(ans, (N-1-s[N-1]+s[0]) );
      |                                 ^
a.cc:20:19: error: 'min' was not declared in this scope; did you mean 'main'?
   20 |             ans = min(ans, (N-1-s[N-1]+s[0]) );
      |                   ^~~
      |                   main
a.cc:24:28: error: 's' was not declared in this scope
   24 |             ans = min(ans, s[N-2]);
      |                            ^
a.cc:24:19: error: 'min' was not declared in this scope; did you mean 'main'?
   24 |             ans = min(ans, s[N-2]);
      |                   ^~~
      |                   main
a.cc:26:28: error: 's' was not declared in this scope
   26 |             ans = min(ans, s[i-1] + (N-i-1 - s[N-1] + s[i]));
      |                            ^
a.cc:26:19: error: 'min' was not declared in this scope; did you mean 'main'?
   26 |             ans = min(ans, s[i-1] + (N-i-1 - s[N-1] + s[i]));
      |                   ^~~
      |                   main
a.cc:30:5: error: 'cout' was not declared in this scope
   30 |     cout << ans << endl;
      |     ^~~~
a.cc:30:20: error: 'endl' was not declared in this scope
   30 |     cout << ans << endl;
      |                    ^~~~
Language: C++

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
const int MAXN=300000;
int main()
{
    int n;
    int minn=MAXN;
    char a[MAXN];
    scanf("%d",&n);
    getchar();
    gets(a);
    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=n-1;j>i;j--)
        {
            if(a[j]=='E')
              sum+=1;
        }
        minn=min(minn,sum);
    }
    printf("%d\n",minn);
    return 0;
}


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

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN=300000;
int main()
{
    int n;
    int minn=MAXN;
    char a[MAXN];
    scanf("%d",&n);
    getchar();
    gets(a);
    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=n-1;j>i;j--)
        {
            if(a[j]=='E')
              sum+=1;
        }
        minn=min(minn,sum);
    }
    printf("%d\n",minn);
    return 0;
}


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

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=300000;
int main()
{
    int n;
    int minn=MAXN;
    char a[MAXN];
    scanf("%d",&n);
    getchar();
    gets(a);
    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=n-1;j>i;j--)
        {
            if(a[j]=='E')
              sum+=1;
        }
        minn=min(minn,sum);
    }
    printf("%d\n",minn);
    return 0;
}

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(a);
      |     ^~~~
      |     getw
Language: C

#include<stdio.h>
#include<stdlib.h>
#define  MAXN 1000000

char a[MAXN];

int main(void)
{
	
	int n;
	while (scanf("%d",&n)!=EOF)
	{
		int i = 0, j = 0;
		scanf("%s", a);
		int num = 0;
		int max = 100;
		for (int m = 0; m < n; m++)
		{
			
			for (int lo = 0; lo < n; lo++)
			{
				if (lo < m)
				{
					if (a[lo] == 'W')
						num++;

				}
				if (lo > m)
				{
					if (a[lo] == 'E')
						num++;

				}
			}
			if (max > num)
				max = num;
			num = 0;
		}
		
		printf("%d\n", max);
	

Compiler output:
main.c: In function 'main':
main.c:40:17: error: expected declaration or statement at end of input
   40 |                 printf("%d\n", max);
      |                 ^~~~~~
main.c:40:17: error: expected declaration or statement at end of input
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string str;
    vector<int> Enum;
    vector<int> Wnum;
    int n;
    int min;

    cin >> n >> str;

    for (int i = 0; i < (int)str.size(); i++) {
        if (str[i] == 'W') {
            if (i != 0) {
                Wnum.push_back(Wnum[i - 1] + 1);
	    }
            else {
	        Wnum.push_back(1);
            }
        }
        else {
            if (i != 0) {
		Wnum.push_back(Wnum[i-1]);
	    }
            else {
		Wnum.push_back(0);
        }
    }


    for (int i = (int)str.size() - 1; i >= 0; i--) {
	if (str[i] == 'E') {
	    if (i != (int)str.size() - 1) {
		Enum.push_back(Enum[i + 1] + 1);
	    }
	    else {
		Enum.push_back(1);
	    }
	}
	else {
	    if (i != (int)str.size() - 1) {
		Enum.push_back(Enum[i+1]);
	    }
	    else {
		Enum.push_back(0);
	    }
	}
    }

    min = Wnum[0] + Enum[0] - 1;

    for (int i = 1; i < (int)str.size(); i++) {
         if (min > (Wnum[i] + Enum[i] - 1)) {
	    min = Wnum[i] + Enum[i] - 1;
	 }
    }

    cout << min << endl;

    return (0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:2: error: expected '}' at end of input
   66 | }
      |  ^
a.cc:8:1: note: to match this '{'
    8 | {
      | ^
Language: C++

#include <iostream>
using namespace std;

string t = "WE";
int search_str(string a, string b);

int main() {
    string s;
    int n, min_count = 300001, tmp;

    cin >> n >> s;

    for (int i = 0; i < n; ++i) {
        tmp = search_str(s.substr(0, i), s.substr(i+1, n-i-1);
        if(tmp < min_count) min_count = tmp;
    }

    cout << min_count << endl;

    return 0;
}

int search_str(string a, string b) {
    int count = 0;
    for (int i = 0; i < a.size(); ++i) {
        if(a[i] == t[0]) count++;
    }
    for (int i = 0; i < b.size(); ++i) {
        if(b[i] == t[1]) count++;
    }
    return count;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:62: error: expected ')' before ';' token
   14 |         tmp = search_str(s.substr(0, i), s.substr(i+1, n-i-1);
      |                         ~                                    ^
      |                                                              )
Language: C

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

int main(){
  int i,j,k;
  int N;
  int NX=0;
  int NY=0;
  int max=0;
  scanf("%d",&N);
  char S[N];
  char X[N];
  char Y[N];

  scanf("%s",S);
  NX = 0;
  NY = 0;

  for(j=0;j<N;j++){
    if(S[j]=='W')NY++;
  }
  max = NY+NX
  printf("%d %d",NX,NY);
  for(i=2;i<N;i++){
    if(S[i]=='W')NY--;
    if(S[i-1]=='E')NX++;
    if(NY+NX>max)max = NY+NX;
  }

  printf("%d",N-max);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:23:14: error: expected ';' before 'printf'
   23 |   max = NY+NX
      |              ^
      |              ;
   24 |   printf("%d %d",NX,NY);
      |   ~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
char ai[300005];
char qw[300005];
char qe[300005];
int main()
{
    int a;
    scanf("%d",&a);
    scanf("%s",ai);
    int  len = strlen(ai);
    int  e=0,r=0,sum=1100000000;
    for(int i=0;i<a;i++)
    {
        if(ai[i]=='W')
            e++;
        qw[i] = e;
    }
    e=0;
    for(int i = a-1;i>=0;i--)
    {
      if(ai[i]=='E')
            e++;
        qe[i] = e;
    }
    for(int i=0;i<n;i++)
    {
        int su  = qe[i] + qw[i]-1;
        sum = min(su,sum);
    }
    printf("%d\n",sum);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: 'n' was not declared in this scope
   26 |     for(int i=0;i<n;i++)
      |                   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
char ai[300005];
char qw[300005];
char qe[300005];
int main()
{
    int a;
    scanf("%d",&a);
    scanf("%s",ai);
    int  len = strlen(ai);
    int  e=0,r=0,sum=1100000000;
    for(int i = 0;i<n;i++)
    {
        if(ai[i]=='W')
            e++;
        qw[i] = e;
    }
    e=0;
    for(int i = n-1;i>=0;i--)
    {
      if(ai[i]=='E')
            e++;
        qe[i] = e;
    }
    for(int i=0;i<len;i++)
    {
        int su  = qe[i] + qw[i]-1;
        if(su<sum) 
            sum =su;
    }
    printf("%d\n",sum);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'n' was not declared in this scope
   13 |     for(int i = 0;i<n;i++)
      |                     ^
a.cc:20:17: error: 'n' was not declared in this scope
   20 |     for(int i = n-1;i>=0;i--)
      |                 ^
Language: C++

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans=1000000;
  vector<int> flag(N);
  int sum=0;
  for(int i=0;i<N;i++){
    if(i==0){
      for(int j=1;j<N;j++){
        if(S.at(j)=='E'){
          flag.at(j)=1;
        }
      }
      for(int j=0;j<N;j++){
        if(flag.at(j)==1){
          sum++;
        }
      }
    }
    else{
      if(flag.at(i)==1){
        sum--;
      }
      if(S.at(i-1)=='W'){
        flag.at(i-1)=1;
        sum++;
      }
      flag.at(i)=0;
    }
    ans=min(ans,sum);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'string' was not declared in this scope
    3 |   string S;
      |   ^~~~~~
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin >> N >> S;
      |   ^~~
a.cc:4:15: error: 'S' was not declared in this scope
    4 |   cin >> N >> S;
      |               ^
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int> flag(N);
      |   ^~~~~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int> flag(N);
      |          ^~~
a.cc:12:11: error: 'flag' was not declared in this scope
   12 |           flag.at(j)=1;
      |           ^~~~
a.cc:16:12: error: 'flag' was not declared in this scope
   16 |         if(flag.at(j)==1){
      |            ^~~~
a.cc:22:10: error: 'flag' was not declared in this scope
   22 |       if(flag.at(i)==1){
      |          ^~~~
a.cc:26:9: error: 'flag' was not declared in this scope
   26 |         flag.at(i-1)=1;
      |         ^~~~
a.cc:29:7: error: 'flag' was not declared in this scope
   29 |       flag.at(i)=0;
      |       ^~~~
a.cc:31:9: error: 'min' was not declared in this scope; did you mean 'main'?
   31 |     ans=min(ans,sum);
      |         ^~~
      |         main
a.cc:33:3: error: 'cout' was not declared in this scope
   33 |   cout << ans << endl;
      |   ^~~~
a.cc:33:18: error: 'endl' was not declared in this scope
   33 |   cout << ans << endl;
      |                  ^~~~
Language: C++

import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void Main(String[] args) {
		int numberOfperson;//人数
		String direction;//向き
		while(true) {
			Scanner person = new Scanner(System.in);
			try{
				numberOfperson = person.nextInt();
			}catch(InputMismatchException  e) {
				System.out.println("数値を入力して下さい");
				continue;
			}
			break;
		}

		while(true) {
			Scanner dir = new Scanner(System.in);
			direction = dir.nextLine();
			Pattern p = Pattern.compile("[^sw]");
			Matcher m = p.matcher(direction);
			if(direction.length() != numberOfperson) {
				System.out.println("人数と文字数が一致しません。");
				continue;
			}else if(m.find()) {
				System.out.println("不正な文字があります。");
				continue;
			}
			dir.close();
			break;
		}
		int countW = 0;
		int countS = 0;

		for(int i = 0; i <direction.length();i++) {
			if(direction.substring(i, i + 1).equals("w")) {
				countW++;
			}else {
				countS++;
			}
		}
		if(countW <= countS) {
			System.out.println(countW);
		}else {
			System.out.println(countS);
		}
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.InputMismatchException;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.regex.Matcher;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.regex.Pattern;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
int main(){
  int N; cin>>N;
  char x[N]; cin>>x[N];
  int T[N];
  for (int i=0; i<N; i++) {
    int a=0;
    for (int j=0; j<i; j++) {
      if (x[j]=="w") {
        a+=1;
      }
    }
    for (int k=0; k<N-i-1; i++) {
      if (x[k+i+1]=="E") {
        a+=1;
      }
    }
    T[i]=a;
  }
  printf(max(T));
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |       if (x[j]=="w") {
      |           ~~~~^~~~~
a.cc:17:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |       if (x[k+i+1]=="E") {
      |           ~~~~~~~~^~~~~
a.cc:23:13: error: no matching function for call to 'max(int [N])'
   23 |   printf(max(T));
      |          ~~~^~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/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, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:23:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'int*'
   23 |   printf(max(T));
      |          ~~~^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

package May_26;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Nishi_higashi {

	public static void main(String[] args) {
		int numberOfperson;//人数
		String direction;//向き
		while(true) {
			Scanner person = new Scanner(System.in);
			try{
				numberOfperson = person.nextInt();
			}catch(InputMismatchException  e) {
				System.out.println("数値を入力して下さい");
				continue;
			}
			break;
		}

		while(true) {
			Scanner dir = new Scanner(System.in);
			direction = dir.nextLine();
			Pattern p = Pattern.compile("[^sw]");
			Matcher m = p.matcher(direction);
			if(direction.length() != numberOfperson) {
				System.out.println("人数と文字数が一致しません。");
				continue;
			}else if(m.find()) {
				System.out.println("不正な文字があります。");
				continue;
			}
			dir.close();
			break;
		}
		int countW = 0;
		int countS = 0;

		for(int i = 0; i <direction.length();i++) {
			if(direction.substring(i, i + 1).equals("w")) {
				countW++;
			}else {
				countS++;
			}
		}
		if(countW <= countS) {
			System.out.println(countW);
		}else {
			System.out.println(countS);
		}
	}
}


Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package May_26;
      | ^~~~~~~
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.InputMismatchException;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.regex.Matcher;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.regex.Pattern;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
    7 | public class Nishi_higashi {
      | ^~~~~~
Language: C++

#include <stdio.h>
using namespace std;

int main(){
  int N; cin>>N;
  char x[N]; cin>>x[N];
  int T[N];
  for (int i=0; i<N; i++) {
    int a=0;
    for (int j=0; j<i; j++) {
      if (x[j]=="w") {
        a+=1;
      }
    }
    for (int k=0; k<N-i-1; i++) {
      if (x[k+i+1]=="E") {
        a+=1;
      }
    }
    T[i]=a;
  }
  printf(max(T));
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope
    5 |   int N; cin>>N;
      |          ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <stdio.h>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:11:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 |       if (x[j]=="w") {
      |           ~~~~^~~~~
a.cc:16:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |       if (x[k+i+1]=="E") {
      |           ~~~~~~~~^~~~~
a.cc:22:10: error: 'max' was not declared in this scope
   22 |   printf(max(T));
      |          ^~~
Language: C++

#include <stdio.h>
using namespace std;

int main(){
  int N; cin>>N;
  char x; cin>>x;
  int T[N];
  for (int i=0; i<N; i++) {
    int a=0;
    for (int j=0; j<i; j++) {
      if (x[j]=="w") {
        a+=1;
      }
    }
    for (int k=0; k<N-i-1; i++) {
      if (x[k+i+1]=="E") {
        a+=1;
      }
    }
    T[i]=a;
  }
  printf(max(T));
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope
    5 |   int N; cin>>N;
      |          ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <stdio.h>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:11:12: error: invalid types 'char[int]' for array subscript
   11 |       if (x[j]=="w") {
      |            ^
a.cc:16:12: error: invalid types 'char[int]' for array subscript
   16 |       if (x[k+i+1]=="E") {
      |            ^
a.cc:22:10: error: 'max' was not declared in this scope
   22 |   printf(max(T));
      |          ^~~
Language: Java

import java.util.*;

class Main {
    private static Scanner scan = new Scanner(System.in);

    public static void out(int num) {
        System.out.println(num);
    }

    public static void main(String[] args) {

        int n = scan.nextInt();
        String str = scan.next();
        int min = n;
        int  haf = (double)((n/2.0) + 0.5);


        for (int i = 0; i < haf; i++) {
            String cut1 = str.substring(0, i);
            String cut2 = str.substring(i+1);

            ArrayList<String> has1 = new ArrayList<String>();
            for (int j = 0; j < cut1.length(); j++) {
                has1.add((String.valueOf(cut1.charAt(j))));
            }
            Collections.sort(has1);

            ArrayList<String> has2 = new ArrayList<String>();
            for (int j = 0; j < cut2.length(); j++) {
                has2.add((String.valueOf(cut2.charAt(j))));
            }
            Collections.sort(has2);

//            System.out.println(Arrays.toString(has1.toArray()));
//            System.out.println(Arrays.toString(has2.toArray()));

            //has1 is all 'E'
            //has2 is all 'W'
            int ind1 = ((has1.size() - has1.indexOf("W")));
            int ind2 = has2.indexOf("W");

            if(ind1 > has1.size()){ind1 = 0;}
            if(ind2 == (-1)){ind2 = 0;}
            int temp = ind1+ind2;
            if(min > temp){
            min = temp;
        }

        }
        out(min);
    }
}

Compiler output:
Main.java:15: error: incompatible types: possible lossy conversion from double to int
        int  haf = (double)((n/2.0) + 0.5);
                   ^
1 error
Language: C++

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

int count(int n, int m, char a[]){
  int cnt = 0;
  int i;
  for(i = 0; i < m; i++){
    if(!strcmp(a[i],"E")){
      cnt++;
    }
  }
  for(i = m + 1;i < n; i++){
    if(!strcmp(a[i],"W")){
      cnt++;
    }
  }
  return cnt;
}

int main(){
  int n,min;
  int i;
  char *a;
  min = 0;
  scanf("%d",&n);
  a = (char*)malloc(sizeof(char)*n);
  for(i = 0; i < n; i++){
    scanf("%s",&a[i]);
  }
  for(i = 0; i < n; i++){
    if(count(n,i,a)<min){
      min=count(n,i,a);
    }
  }
  printf("%d",min);
  return 0;
}

Compiler output:
a.cc: In function 'int count(int, int, char*)':
a.cc:9:19: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
    9 |     if(!strcmp(a[i],"E")){
      |                ~~~^
      |                   |
      |                   char
In file included from a.cc:3:
/usr/include/string.h:156:32: note:   initializing argument 1 of 'int strcmp(const char*, const char*)'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
a.cc:14:19: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   14 |     if(!strcmp(a[i],"W")){
      |                ~~~^
      |                   |
      |                   char
/usr/include/string.h:156:32: note:   initializing argument 1 of 'int strcmp(const char*, const char*)'
  156 | extern int strcmp (const char *__s1, const char *__s2)
      |                    ~~~~~~~~~~~~^~~~
Language: C++

#include<iostream>
 
using namespace std;
 
int main(){
	long  n;
	strin s;
	cin >> n;
	cin >> s;
	
	int tmp_min,min = 0;
	int x, y = 0;
	for(long  i=1;i<n;i++){
		if(s[i]!='W')y++;
	}
  	tmp_min = y;
  	min = y;
//	cout << "first: " << tmp_min << endl;
	char pre_L = s[0];
	char L;
	for(long i=1;i<n;i++){
		L = s[i];
		if(pre_L=='W')tmp_min++;
		if(L=='E')tmp_min--;
		pre_L=L;
//		cout << "tmp: " << tmp_min  <<"  "<<min<< endl;
		if(min>tmp_min)min=tmp_min;
    }
	
	cout << min;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'strin' was not declared in this scope; did you mean 'stdin'?
    7 |         strin s;
      |         ^~~~~
      |         stdin
a.cc:9:16: error: 's' was not declared in this scope
    9 |         cin >> s;
      |                ^
Language: C++

#include <stdio.h>
using namespace std;

int main(){
  int N; cin>>N;
  char x[]; cin>>x[];
  int T[N];
  for (int i=0; i<N; i++) {
    int a=0;
    for (int j=0; j<i; j++) {
      if (T[j]=="w") {
        a+=1;
      }
    }
    for (int k=0; k<N-i-1; i++) {
      if (T[k+i+1]=="E") {
        a+=1;
      }
    }
    T[i]=a;
  }
  printf(max(T));
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope
    5 |   int N; cin>>N;
      |          ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <stdio.h>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:6:8: error: storage size of 'x' isn't known
    6 |   char x[]; cin>>x[];
      |        ^
a.cc:6:20: error: expected primary-expression before ']' token
    6 |   char x[]; cin>>x[];
      |                    ^
a.cc:11:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   11 |       if (T[j]=="w") {
      |           ~~~~^~~~~
a.cc:16:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   16 |       if (T[k+i+1]=="E") {
      |           ~~~~~~~~^~~~~
a.cc:22:10: error: 'max' was not declared in this scope
   22 |   printf(max(T));
      |          ^~~