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

#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char a[n];
  int cnt = 0;
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for(int i = n - 1; i > 0; i++)
  {if(a[i] == 'W' && a[i + 1] != 'R' || i + 1 >= n)
     a[i] = '0';
  }
  for(int i = n - 1; i > 0; i++)
  {if(a[i] == 'W'; cnt++;}
      cout << cnt << endl;
      return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: expected ')' before ';' token
   16 |   {if(a[i] == 'W'; cnt++;}
      |      ~                  ^
      |                         )
Language: C++

#include <iostream>
#include <cstdio>
using namespace std;
int stones[200000];
int N;
int op = 0;
int check(int t){
	while(t < N){
		if(stones[t] == 0){
			stones[t] = 1;
			op++;
			return t;
		}
		t++;
	}
	return -1;
}
int main(){
	
	for(int i = 0; i < N; i++){
		char temp = cin.get();
		if(temp == "W")
			stones[i] = 1;
		else
			stones[i] = 0;
	}
	for(int i = 0; i < N; i++){
		if(stones[i] == 1){
			int temp;
			temp = check(i);
			if(temp == -1)
				break;
		}
	}
	printf("%d", op);

}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   22 |                 if(temp == "W")
      |                    ~~~~~^~~~~~
Language: C++

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  int n;
  string s;
  int countS = 0, countR = 0;
  cin >> n >> s;
  for (int i = 0; i < strlen(s); i++)
  {
    if (s[i] == 'R') countR++;
  }
  int countW = n - countR;
  if (countW < countR) countS = countW;
  	else countS = countR;
  for (int i = 0; i < countS + 1; i++)
  {
    if (s[i] == 'R') countS--;
  }
  cout << countS << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:30: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   10 |   for (int i = 0; i < strlen(s); i++)
      |                              ^
      |                              |
      |                              std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
Language: C++

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  string s;
  int countS = 0, countR = 0;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] == 'R') countR++;
  }
  int countW = n - countR;
  if (countW < countR) countS = countW;
  	else countS = countR;
  for (int i = 0; i < countS + 1; i++)
  {
    if (s[i] == 'R') countS--;
  }
  cout << countS << endl;
  return 0;
}
    if 
  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: 'n' was not declared in this scope
   13 |   int countW = n - countR;
      |                ^
a.cc: At global scope:
a.cc:23:5: error: expected unqualified-id before 'if'
   23 |     if
      |     ^~
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  N = 2, RR;
  cout << N << 0 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'RR' was not declared in this scope
    8 |   N = 2, RR;
      |          ^~
Language: Java

import java.util.Scanner;

public class Main2{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
   int n=kbd.nextInt();
   String c=kbd.next();
   String r="W";
   int num=0;
   int a=0;
   for(int i=0;i<n;i++){
   if(c.charAt(i)==r.charAt(0)){
     num++;
   }
 }
 for(int i=0;i<num;i++){
 if(c.charAt(i)==r.charAt(0)){
   a++;
 }
}
 System.out.println(a);
}
}


Compiler output:
Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2{
       ^
1 error
Language: C++

#include <iostream>
#include <cstring>
using namespace std;
int main()
{
  string s;
  int countS = 0, countR = 0;
  cin >> s;
  for (int i = 0; i < strlen(s); i++)
  {
    if (s[i] == 'R') countR++;
  }
  int countW = n - countR;
  if (countW < countR) countS = countW;
  	else countS = countR;
  for (int i = 0; i < countS + 1; i++)
  {
    if (s[i] == 'R') countS--;
  }
  cout << countS << endl;
  return 0;
}
    if 
  

Compiler output:
a.cc: In function 'int main()':
a.cc:9:30: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
    9 |   for (int i = 0; i < strlen(s); i++)
      |                              ^
      |                              |
      |                              std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:13:16: error: 'n' was not declared in this scope
   13 |   int countW = n - countR;
      |                ^
a.cc: At global scope:
a.cc:23:5: error: expected unqualified-id before 'if'
   23 |     if
      |     ^~
Language: C++

#include <iostream>
using namespace std;

int main(){
  int N;
  string s;
  cin >> N >> s;
  int T_W= 0;
  for (int i=0; i<N; i++){if (s.at(i) == 'W'){T_W += 1;}}
  int T_R= N-T_W;
  int t_w = 0;
  int t_r = T_R;
  while (t_w < t_r){
    if (s.at(i) == 'W'){t_w += 1;} else{t_r -= 1;}
  }
  cout << t_w;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: 'i' was not declared in this scope
   14 |     if (s.at(i) == 'W'){t_w += 1;} else{t_r -= 1;}
      |              ^
Language: Java

import java.util.Scanner;

public class Main{
	public static void main(String[] arg){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      List mojiretsu = Arrays.asList(sc.next().sprit(""));

      for (int i=0;i<n;i++){
        if (mojiretsu.get(i)="W" || mojiretsu.get(i+1)="R"){
          if (mojiretsu.get(i-1)="W"){
            
          System.out.println(count);
        
    }
}

Compiler output:
Main.java:16: error: reached end of file while parsing
}
 ^
1 error
Language: Java

import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
Scanner s = new Scanner(System.in);
		int N = Integer.valueOf(s.next());
		char[] c = s.next().toCharArray();
		int[] C = new int[N];
		int left_one = N + 1;
		int right_zero = -1;
		for(int i = 0; i < N; i++) {
			if(c[i] == 'W') {
				C[i] = 1;
				left_one = Integer.min(left_one, i);
			}else {
				C[i] = 0;
				right_zero = Integer.max(right_zero, i);
			}
		}
		
		int cnt = 0;
		while(left_one < right_zero) {
			C[left_one] = 0;
			C[right_zero] = 1;
			left_one = nextOne(C, left_one);
			right_zero = nextZero(C, right_zero);
			cnt++;
		}
		System.out.println(cnt);
	}
}

Compiler output:
Main.java:26: error: cannot find symbol
			left_one = nextOne(C, left_one);
			           ^
  symbol:   method nextOne(int[],int)
  location: class Main
Main.java:27: error: cannot find symbol
			right_zero = nextZero(C, right_zero);
			             ^
  symbol:   method nextZero(int[],int)
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
#include <bitset>
#include <cmath>
#include <cstring>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

int main() {
    int n,w,r;
    string c;
    cin >>n>>c;
    for(int i=0;i<n;i++){
        if(strncmp("W",&c[i],1)==0){w++;}else{r++;}
    }
    int w1=w/2;
    int w2,r2,k;
    k=0;r2=0;w2=0;
    while(k<=w1){
        if(strncmp("W",&c[k],1)==0){w2++;}else{r2++;}
        k++;
    }
    int l=w2+r2;
    int f=l;
    while(strncmp("W",&c[f-1],1)==0){
        f--;
    }
    int d=l-f;
    int lw,rr;
    lw=w2-d;
    rr=r-lr;
    int ans=max(lw,rr);
    cout <<ans;

}

    

Compiler output:
a.cc: In function 'int main()':
a.cc:51:10: error: 'lr' was not declared in this scope; did you mean 'rr'?
   51 |     rr=r-lr;
      |          ^~
      |          rr
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  string s;
  cin>>n>>s;
  int i=0,j=n-1,count=0;
  while(i<=j)
  {
    while(s[i]=='R' && i<=j)
      i++;
    while(s[j]=='W' && i<=j)
      j++;
    if(s[i]=='W' && s[j]=='R')
    {  swap(s[i],s[j])
      count++;
    }
  }
  cout<<count;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: expected ';' before 'count'
   16 |     {  swap(s[i],s[j])
      |                       ^
      |                       ;
   17 |       count++;
      |       ~~~~~
Language: C++

//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin(N);

    vector<char> c(N);
    REP(i,N) cin(c.at(i));

    int count =0;
    bool tf = true;

while(tf){
    for(int i =0; i < c.size(); i++){
        if(c.at(i) == "W" && c.at(i+1) == "R")
        {
            c.at(i) = R;
            c.at(i+1) = R+1;
            count ++;
            continue;
        }
    }
}

    //vll X(N)
    //REP(i,N) cin(X.at(i));




    //出力
    cout << count << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   88 |         if(c.at(i) == "W" && c.at(i+1) == "R")
      |            ~~~~~~~~^~~~~~
a.cc:88:40: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   88 |         if(c.at(i) == "W" && c.at(i+1) == "R")
      |                              ~~~~~~~~~~^~~~~~
a.cc:90:23: error: 'R' was not declared in this scope
   90 |             c.at(i) = R;
      |                       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void lomuto(char s[],long &l,long &r,int &flag){
	while(s[l]!='W')
		l++;
	while(s[r]!='R')
		r--;
	if(l>=r){flag=1;return;}
	swap(s[l],s[r]);l++;r--;
}
bool isSafe(char s[],long n){
	for(long i=0;i<n-1;i++)
		if(s[i]=='W'&& s[i+1]=='R')
			return false;
	return true;
}
long solve(char s[],long n){
	if(isSafe(s,n))
		return 0;
	long l=0,r=n-1;
	long c=0;int flag=0
	while(r>l){
		lomuto(s,l,r,flag);
		if(flag==0)
		c++;
	}
	return c;

}

int main(){
	long n;char s[200000]="";
	cin>>n;
	cin>>s;
	cout<<solve(s,n);
	return 0;
}

Compiler output:
a.cc: In function 'long int solve(char*, long int)':
a.cc:22:9: error: expected ',' or ';' before 'while'
   22 |         while(r>l){
      |         ^~~~~
Language: Java

import java.util.Scanner;

public class D {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = Integer.parseInt(scan.nextLine());
		String s = scan.nextLine();

		int w = s.indexOf('W');
		int r = s.lastIndexOf('R');
		int count = 0;

		if(w < 0 || r < 0) {
			System.out.println(0);
		}else {
			while(w < r){
				StringBuilder sb = new StringBuilder(s);
				sb.setCharAt(w, 'R');
				sb.setCharAt(r, 'W');
				s = sb.toString();
				count++;
				w = s.indexOf('W');
				r = s.lastIndexOf('R');
			}
			System.out.println(count);
		}



		scan.close();
	}
}


Compiler output:
Main.java:3: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: C++

#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
#include <bitset>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

int main() {
    int n,w,r;
    string c;
    cin >>n>>c;
    for(int i=0;i<n;i++){
        if(strncmp("W",&c[i],1)==0){w++;}else{r++;}
    }
    int w1=w/2;
    int w2,r2,k;
    while(k<=w1){
        if(strncmp("W",&c[k],1)==0){w2++;}else{r2++;}
        k++;
    }
    int l=w2+r2;
    int f=l;
    while(strncmp("W",&c[f-1],1)==0){
        f--;
    }
    int d=l-f;
    int lw,lr,rw,rr;
    lw=w2-d;lr=r2;
    rw=w-lw;rr=r-lr;
    int ans=max(lw,rr);
    cout <<ans;

}

    

Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: 'strncmp' was not declared in this scope
   33 |         if(strncmp("W",&c[i],1)==0){w++;}else{r++;}
      |            ^~~~~~~
a.cc:16:1: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   15 | #include <cmath>
  +++ |+#include <cstring>
   16 | using namespace std;
a.cc:38:12: error: 'strncmp' was not declared in this scope
   38 |         if(strncmp("W",&c[k],1)==0){w2++;}else{r2++;}
      |            ^~~~~~~
a.cc:38:12: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:43:11: error: 'strncmp' was not declared in this scope
   43 |     while(strncmp("W",&c[f-1],1)==0){
      |           ^~~~~~~
a.cc:43:11: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
#include <bitset>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

int main() {
    int n,w,r;
    string c;
    cin >>n>>c;
    for(int i=0;i<n;i++){
        if(strncmp("W",&c[i],1)==0){w++;}else{r++;}
    }
    int w1=w/2;
    int w2,r2,k;
    while(k<=w1){
        if(strncmp("W",&c[k],1)==0){w2++;}else{r2++;}
        k++;
    }
    cout << w2<<r2;
    int l=w2+r2;
    int f=l;
    while(strncmp("W",&c[f-1],1)==0){
        f--;
    }
    int d=l-f;
    int lw,lr,rw,rr;
    lw=w2-d;lr=r2;
    rw=w-lw;rr=r-lr;
    int ans=max(lw,rr);
    cout <<ans;

}

    

Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: 'strncmp' was not declared in this scope
   33 |         if(strncmp("W",&c[i],1)==0){w++;}else{r++;}
      |            ^~~~~~~
a.cc:16:1: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   15 | #include <cmath>
  +++ |+#include <cstring>
   16 | using namespace std;
a.cc:38:12: error: 'strncmp' was not declared in this scope
   38 |         if(strncmp("W",&c[k],1)==0){w2++;}else{r2++;}
      |            ^~~~~~~
a.cc:38:12: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:44:11: error: 'strncmp' was not declared in this scope
   44 |     while(strncmp("W",&c[f-1],1)==0){
      |           ^~~~~~~
a.cc:44:11: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
  int N;
  cin >>N;
  
  vector<char> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int M =0;
  for (int i = 0; i < N; i++) {
    if(vec.at(i)=="R"){
      M ++;
    }
    else{
      M +=0;
    }
  }
  
  int P =0;
  for (int i = 0; i < M; i++) {
    if(vec.at(i)=="W"){
      P ++;
    }
    else{
      P +=0;
    }
  }
  
  cout << P <<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |     if(vec.at(i)=="R"){
      |        ~~~~~~~~~^~~~~
a.cc:27:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |     if(vec.at(i)=="W"){
      |        ~~~~~~~~~^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
  int N;
  cin >>N;
  
  vector<char> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  int M =0;
  for (int i = 0; i < N; i++) {
    if(vec.at(i)==R){
      M ++;
    }
    else{
      M +=0;
    }
  }
  
  int P =0;
  for (int i = 0; i < M; i++) {
    if(vec.at(i)==W){
      P ++;
    }
    else{
      P +=0;
    }
  }
  
  cout << P <<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: 'R' was not declared in this scope
   17 |     if(vec.at(i)==R){
      |                   ^
a.cc:27:19: error: 'W' was not declared in this scope
   27 |     if(vec.at(i)==W){
      |                   ^
Language: C++

#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<char> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];

	int strt = 0;
	int counter = 0;
	while (true) {
		vector<char>::iterator itr;
		int rnum = count(c.begin(), c.end(), 'R');
		itr = find(c.begin()+strt, c.end(),'R');
		if (itr == c.end())
			break;
		if (c.begin()+strt != itr&&distance(c.begin(),itr)>=rnum) {
			iter_swap(c.begin() + strt, itr);
			counter++;
		}
		strt++;
	}
	cout << counter;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:28: error: 'count' was not declared in this scope; did you mean 'counter'?
   16 |                 int rnum = count(c.begin(), c.end(), 'R');
      |                            ^~~~~
      |                            counter
a.cc:17:27: error: no matching function for call to 'find(__gnu_cxx::__normal_iterator<char*, std::vector<char> >, std::vector<char>::iterator, char)'
   17 |                 itr = find(c.begin()+strt, c.end(),'R');
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:17:27: note:   '__gnu_cxx::__normal_iterator<char*, std::vector<char> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   17 |                 itr = find(c.begin()+strt, c.end(),'R');
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  N = 8, WRWWRWRR;
  cout << N << 3 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'WRWWRWRR' was not declared in this scope
    8 |   N = 8, WRWWRWRR;
      |          ^~~~~~~~
Language: C

include <stdio.h>
int main(){
  int is_red=0,count=0;
    char a[200000]={};
  scanf("%s",&a);
  for(int i=0;i<200000;i++){
      if(a[i]=='R')is_red++;
  }
  count=is_red;
  for(int i=0;i<is_red;i++){
      if(a[i]=='R')count--;
  }
  printf("%d",count);
  return 0;
}


Compiler output:
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include <stdio.h>
      |         ^
Language: C

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

int main(){
  int N;
  int count = 0;
  int i,j;
  char tmp;
  
  scanf("%d",&N);
  char G[D];
  for(i=0;i<N;i++){
    scanf("%c",G[i]);
  }
  
  i = 0;
  j = N-1;
  while(i<j){
    while(G[i] != 'W') i++;
    while(G[j] != 'R') j--;
    if(i<j){
      tmp = G[i];
      G[i] = G[j];
      G[j] = tmp;
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:10: error: 'D' undeclared (first use in this function)
   11 |   char G[D];
      |          ^
main.c:11:10: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>
using namespace std;
     
    int main(){
      int N, tmp;
      int lw = 0, rn = 0, j = 0, n = 0;
      cin >> N;
      int c[200100];
      string color;
      cin >> color;
      for (int i=0; i<N; i++){
        if (color[i] == "R"){
          c[i] = 1;
          rn ++;
        }
        else{
          c[i] = 0;
          lw = i;
        }
      }
      while(lw + rn > N){
        while(c[j] != 1){
          j++;
        }
        while(c[lw] != 0){
          lw--;
        }
        tmp = c[j];
        c[j] = c[lw];
        c[lw] = tmp;
        n++;
      }
      cout << n << endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |         if (color[i] == "R"){
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  N = 4, WWRR;
  cout << N << 2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'WWRR' was not declared in this scope
    8 |   N = 4, WWRR;
      |          ^~~~
Language: C

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
//using ll = long long; using ld = long double;
//using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int slen = s.length();
  int las = slen - 1;
  int ans = 0;
  for (int i = 0; i < slen; i++) {
    if (i < las && s.at(i) == 'R') continue;
    if (i >= las) break;
    while (las >= 0) {
      if (s.at(las) == 'R') {
        las--;
        break;
      }
      else {
        las--;
      }
    }
    if (i > las) {ans++; break;}
    ans++;
  }
  cout << ans << endl;
  return 0;
}



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

#include <bits/stdc++.h>
//#define rep(i,a,b) for(int i=a;i<b;i++)
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
const ll maxn=2e5+10;
//pedef unsigned long long ull;
int main()
{
    ll n;
    scanf("%lld",&n);
    char c[maxn];
    ll cnt=0,ans=0;
    scanf("%s",c);
    for(ll i=0;i<strlen(c);i++)
    {
        if(c[i]=='R')
        {
            cnt++;
        }
    }
    for(ll i=0;i<r;i++)
    {
        if(c[i]=='W')
            ans++;
    }
    cout<<ans<<endl;
}


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

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

int main() {
  int N;
  cin >> N;
  
  N = 4
WWRR;
  cout << N << 2 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:8: error: expected ';' before 'WWRR'
    8 |   N = 4
      |        ^
      |        ;
    9 | WWRR;
      | ~~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n;
	cin>>n;
	scanf("%s",s+1);
	int cnt=0,ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='R')cnt++;
	}
	for(int i=1;i<=cnt;i++){
		if(s[i]=='W')ans++;
	}
	cout<<ans<<endl;
 	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:20: error: 's' was not declared in this scope
    8 |         scanf("%s",s+1);
      |                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long n;
    string ff;
    cin >> n >> ff;
    vector <int> re;
    vector <int> qw (n);
    vector <int> qw1 (n);
    for (int i=0; i<n; ++i)
        if (ff[i]=='R')
        {
            re.push_back(i);
            qw[i]=1;
        }
    int t=0;
    int tt=min(re.size(), n-re.size());
    for (int i=0; i<re.size(); ++i)
        qw1[i]=1;
    for (int i=0; i<n; ++i)
        if (qw[i]!=qw1[i])
            t+=1;
    cout << min(t/2, tt) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: no matching function for call to 'min(std::vector<int>::size_type, long long unsigned int)'
   18 |     int tt=min(re.size(), n-re.size());
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
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:18:15: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')
   18 |     int tt=min(re.size(), n-re.size());
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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:18:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   18 |     int tt=min(re.size(), n-re.size());
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)	
#define T int t ;cin >> t;while(t--)
using namespace std ;
typedef long long ll;
typedef unsigned long long ull;
inline ll gcd(ll a,ll b){return b == 0? a:gcd(b, a % b);}
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-11;
const ll mod = 1e9 + 7;

int main()
{
	int n;
	cin>>n;
	scanf("%s",s+1);
	int cnt=0,ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='R')cnt++;
	}
	for(int i=1;i<=cnt;i++){
		if(s[i]=='W')ans++;
	}
	cout<<ans<<endl;
 	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:20: error: 's' was not declared in this scope
   17 |         scanf("%s",s+1);
      |                    ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 200010
using namespace std;

ll n, ans, a[N];

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read();
	REP(i, 1, n){
		char ch = getchar();
		if (ch == 'R') a[i] = 1;
		else a[i] = 2;
	}
	REP(i, 1, n){
		if (a[i] == 1 && a[i - 1] == 2 && a[i + 1] != 1) a[i] = 2, ans++;
		else if (a[i] == 2 && a[i + 1] == 1 && a[i + 2] != 1) a[i + 1] = 2, ans++;
	}
	print("%lld\n", ans);
}

int main(){
	work();
	return 0;
}

Compiler output:
a.cc: In function 'void work()':
a.cc:28:9: error: 'print' was not declared in this scope; did you mean 'rint'?
   28 |         print("%lld\n", ans);
      |         ^~~~~
      |         rint
Language: C++


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cstdio>
#include <cinttypes>


int main()
{
	int N;
	cin >> N;
	std::vector<int> table;
	table.resize(N);

	for (int i = 0; i < N; ++i) {
		char c;
		cin >> c;
		if (c == 'W') {
			table[i] = 1;
		}
	}
	//r = 0
	//w = 1
	int r = 0;
	int last = N-1;
	for (int i = 0; i < N; ++i) {
		if (table[i] == 0) {
			continue;
		}
		bool b = false;
		for (int j = last; i < j; --j) {
			if (table[j] == 0) {
				table[j] = 1;
				table[i] = 0;
				b = true;
				last = j;
				++r;
				break;
			}
		}
		if (b) {
			continue;
		}

		break;
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:66:18: error: expected '}' at end of input
   66 |         return 0;
      |                  ^
a.cc:26:1: note: to match this '{'
   26 | {
      | ^
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 stone = sc.next();
		
		int sta = 0;
		int count = 0;
		
		for(int i = 0; i < stone.length(); i++){
			if(stone.charAt(i) == "W"){
				count++;
			}
		}
		
		if((stone.charAt(0)) == "R" && (stone.charAt(stone.length() -1)) =="W"){
				count--;
		}
		
		System.out.println(count);
	}
}

Compiler output:
Main.java:12: error: bad operand types for binary operator '=='
			if(stone.charAt(i) == "W"){
			                   ^
  first type:  char
  second type: String
Main.java:17: error: bad operand types for binary operator '=='
		if((stone.charAt(0)) == "R" && (stone.charAt(stone.length() -1)) =="W"){
		                     ^
  first type:  char
  second type: String
Main.java:17: error: bad operand types for binary operator '=='
		if((stone.charAt(0)) == "R" && (stone.charAt(stone.length() -1)) =="W"){
		                                                                 ^
  first type:  char
  second type: String
3 errors
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>

using std::cin;using std::cout;using std::cerr;using std::endl;

#define rep(i,a,b) for(int i = a;i <= b;++i)
#define per(i,a,b) for(int i = a;i >= b;--i)

const int mmax = 200000;
int n,ans1,ans2;
bool f;
char t[mmax + 10];

int main(){

	std::ios::sync_with_stdio(0);
	cin.tie(0);

	cin>>n;
	cin>>(t + 1);

	per(i,n,1){
		if(t[i]=='R' && (!f)){
			ans1++;
		}
		else if(t[i]=='W' && (!f)){
			f = 1;
		}
		else if(t[i]=='W'){
			ans2++;
		}
	}
	if(f)cout<<std::max(ans1,ans2);
	else cout<<0
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:21: error: expected ';' before 'return'
   43 |         else cout<<0
      |                     ^
      |                     ;
   44 |         return 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();
		String stone = sc.next();
		
		int sta = 0;
		int count = 0;
		
		for(int i = 0; i < stone.length(); i++){
			if(stone.charAt(i) == W){
				count++;
			}
		}
		
		if((stone.charAt(0)).equals("R") && (stone.charAt(stone.length() -1)).equals("W")){
				count--;
		}
		
		System.out.println(count);
	}
}

Compiler output:
Main.java:12: error: cannot find symbol
			if(stone.charAt(i) == W){
			                      ^
  symbol:   variable W
  location: class Main
Main.java:17: error: char cannot be dereferenced
		if((stone.charAt(0)).equals("R") && (stone.charAt(stone.length() -1)).equals("W")){
		                    ^
Main.java:17: error: char cannot be dereferenced
		if((stone.charAt(0)).equals("R") && (stone.charAt(stone.length() -1)).equals("W")){
		                                                                     ^
3 errors
Language: Java

import java.util.*;
public class MainD{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String stone = sc.next();
		
		int sta = 0;
		int count = 0;
		
		for(int i = 0; i < stone.length(); i++){
			if(stone.charAt(i) == W){
				count++;
			}
		}
		
		if((stone.charAt(i)).equals("R") && (stone.charAt(stone.length() -1)).equals("W")){
				count--;
		}
		
		System.out.println(count);
	}
}

Compiler output:
Main.java:2: error: class MainD is public, should be declared in a file named MainD.java
public class MainD{
       ^
Main.java:12: error: cannot find symbol
			if(stone.charAt(i) == W){
			                      ^
  symbol:   variable W
  location: class MainD
Main.java:17: error: cannot find symbol
		if((stone.charAt(i)).equals("R") && (stone.charAt(stone.length() -1)).equals("W")){
		                 ^
  symbol:   variable i
  location: class MainD
Main.java:17: error: char cannot be dereferenced
		if((stone.charAt(i)).equals("R") && (stone.charAt(stone.length() -1)).equals("W")){
		                                                                     ^
4 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();
		String stone = sc.next();
		
		int sta = 0;
		count = 0;
		
		if(stone.charAt(0).equals("R") && stone.charAt(stone.length() -1).equals("W")){
				sta++;
		}
		
		for(int i = 0; i < stone.length(); i++){
			if(stone.charAt(i) == W){
				count++;
			}
		}
		
		if(stone.charAt(i).equals("R") && stone.charAt(stone.length() -1).equals("W")){
				count--;
		}
		
		System.out.println(count);
	}
}

Compiler output:
Main.java:9: error: cannot find symbol
		count = 0;
		^
  symbol:   variable count
  location: class Main
Main.java:11: error: char cannot be dereferenced
		if(stone.charAt(0).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                  ^
Main.java:11: error: char cannot be dereferenced
		if(stone.charAt(0).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                                                                 ^
Main.java:16: error: cannot find symbol
			if(stone.charAt(i) == W){
			                      ^
  symbol:   variable W
  location: class Main
Main.java:17: error: cannot find symbol
				count++;
				^
  symbol:   variable count
  location: class Main
Main.java:21: error: cannot find symbol
		if(stone.charAt(i).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                ^
  symbol:   variable i
  location: class Main
Main.java:21: error: char cannot be dereferenced
		if(stone.charAt(i).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                                                                 ^
Main.java:22: error: cannot find symbol
				count--;
				^
  symbol:   variable count
  location: class Main
Main.java:25: error: cannot find symbol
		System.out.println(count);
		                   ^
  symbol:   variable count
  location: class Main
9 errors
Language: Java

import java.util.*;
public class MainD{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String stone = sc.next();
		
		int sta = 0;
		count = 0;
		
		if(stone.charAt(0).equals("R") && stone.charAt(stone.length() -1).equals("W")){
				sta++;
		}
		
		for(int i = 0; i < stone.length(); i++){
			if(stone.charAt(i) == W){
				count++;
			}
		}
		
		if(stone.charAt(i).equals("R") && stone.charAt(stone.length() -1).equals("W")){
				count--;
		}
		
		System.out.println(count);
	}
}

Compiler output:
Main.java:2: error: class MainD is public, should be declared in a file named MainD.java
public class MainD{
       ^
Main.java:9: error: cannot find symbol
		count = 0;
		^
  symbol:   variable count
  location: class MainD
Main.java:11: error: char cannot be dereferenced
		if(stone.charAt(0).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                  ^
Main.java:11: error: char cannot be dereferenced
		if(stone.charAt(0).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                                                                 ^
Main.java:16: error: cannot find symbol
			if(stone.charAt(i) == W){
			                      ^
  symbol:   variable W
  location: class MainD
Main.java:17: error: cannot find symbol
				count++;
				^
  symbol:   variable count
  location: class MainD
Main.java:21: error: cannot find symbol
		if(stone.charAt(i).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                ^
  symbol:   variable i
  location: class MainD
Main.java:21: error: char cannot be dereferenced
		if(stone.charAt(i).equals("R") && stone.charAt(stone.length() -1).equals("W")){
		                                                                 ^
Main.java:22: error: cannot find symbol
				count--;
				^
  symbol:   variable count
  location: class MainD
Main.java:25: error: cannot find symbol
		System.out.println(count);
		                   ^
  symbol:   variable count
  location: class MainD
10 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
     
    int main(){
      int N, n;
      cin >> N;
      int c[200100];
      int lr = 0, wn = 0;
      string color;
      for (int i=0; i<N; i++){
        cin >> color;
        if (color == "R"){
          c[i] = 1;
          lr = i;
        }
        else{
          c[i] = 0;
        }
        if (lr != 0){
          for (int i=0; i<lr-1; i++){
            if (c[i]==0){
              wn ++;
            }
          }
        }
        n = wn/2 + wn%2;
        cout << n << endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:28:6: error: expected '}' at end of input
   28 |     }
      |      ^
a.cc:4:15: note: to match this '{'
    4 |     int main(){
      |               ^
Language: C++

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

int main() {
  int n, S = 0, r = 0;
  cin >> n;
  vector<char> v(n);
  for(int i = 0;i < n;i++) {
    cin >> v[i];
    if(v[i] == 'R') {
      r++;
    }
  }
  for(int i = 0;i < r;i++) {
    if(v[i] == 'R') S++;
  cout << r - S << endl;
}



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

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <bitset>
#include <cassert>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <fstream>

using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast_io;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    string str;
    cin >> n >> str;

    int x = 0, y = 0, c = 0;
    for (int i = 0; i < n; ++i)
    {
        if (str[i] == 'W')
            y++;
        else
            x++;
    }

    int res = min(x, y);

    for (int i = 0; i < n; ++i)
    {
        if (str[i] == 'W')
        {
            for (int j = n - 1; j > i; --j)
            {
                if (str[j] == 'R')
                {
                    str[j] = 'W';
                    c++;
                    break;
                }
            }
        }
    }

    res = min(res, c);
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   64 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

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

int main() {
	int n;
  	string s;
  	cin >> n >> s;
  
  	vector<int> prefix;
  	int now = 0;
  	s = '#' + s;
  	prefix.push_back(0);
  	for(int i=1;i<=n;i++) {
    	if(s[i] == 'W') {
        	now++;
        }
      	prefix[i].push_back(now);
    }
  
  	int ans = n - prefix[n];
  	ans = min(ans , prefix[n]);
  
  	for(int i=1;i<=n;i++) {
    	int numR = i - prefix[i];
      	int numW = prefix[i];
      	
      	int numW1 = prefix[n] - prefix[i];
      
      	int numR1 = n - (numR+numW+numW1);
      
      	// white and red exchange.
      	// remaining color the rest
      
      	int itne = min(numW,numR1);
      	
      	int rest = numW + numR1 - 2*itne;
      
      	ans = min(ans , itne + rest);
      
    }
  
  	cout << ans << endl;
  
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: request for member 'push_back' in 'prefix.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   17 |         prefix[i].push_back(now);
      |                   ^~~~~~~~~
Language: C++

//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin(N);

    string c;
    cin(c);

    int count =0;
    bool tf = true;

while(tf){
    for(int i =0; i < c.size(); i++){
        if(c.at(i) == "W" && c.at(i+1) == "R")
        {
            c.at(i) = R;
            c.at(i+1) = R+1;
            count ++;
            continue;
        }
    }
}

    //vll X(N)
    //REP(i,N) cin(X.at(i));




    //出力
    cout << count << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   88 |         if(c.at(i) == "W" && c.at(i+1) == "R")
      |            ~~~~~~~~^~~~~~
a.cc:88:40: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   88 |         if(c.at(i) == "W" && c.at(i+1) == "R")
      |                              ~~~~~~~~~~^~~~~~
a.cc:90:23: error: 'R' was not declared in this scope
   90 |             c.at(i) = R;
      |                       ^
Language: C++

import collections
def main():
    N = int(input())
    S = list(input())
    if len(set(S))==1:
        print(0)
        return
    for i in range(N):
        if S[i] == 'W':
            break
    S = S[i:]
    # print(S)
    cnt = 0
    left = 0
    right = len(S)-1
    while left<right:
        if S[left] == 'W':
            cnt +=1
            left += 1
            right -=1
        else:
            # S[left] == 'R'
            left += 1
            if S[right] =='W':
                right -=1
    print(cnt)
    return 0
if __name__ == "__main__":
    main()

Compiler output:
a.cc:12:7: error: invalid preprocessing directive #print
   12 |     # print(S)
      |       ^~~~~
a.cc:22:15: error: invalid preprocessing directive #S
   22 |             # S[left] == 'R'
      |               ^
a.cc:1:1: error: 'import' does not name a type
    1 | import collections
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'