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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class AlterAltar
{
    public static void main(String[] args) throws IOException
    {
        int N = readInt();
        char[] chs = br.readLine().toCharArray();

        int left = 0;
        int right = N - 1;
        int count = 0;

        while (left < right)
        {
            if (chs[left] == 'W')
            {
                if (chs[right] == 'R')
                {
                    left++;
                    right--;

                    count++;
                }
                else
                    right--;
            }
            else
                left++;
        }

        System.out.println(count);
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static int readInt() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Integer.parseInt(st.nextToken());
    }
}

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

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

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

    vector<char> d = c;

    sort(d.begin(),d.end());
    for (int i = 0; i < N; i++)  {
        ans += c[i]!=d[i];
    }
    cout << ans/2 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:12: error: 'N' was not declared in this scope
    7 |     cin >> N;
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define lli long long int

int main()
{
 std::ios_base::sync_with_stdio(false );
  cin.tie(0);
  
  lli n,ctr=0,res=0;
  string s;
  cin>>s;
  for(auto it:s)
  {
   	if(it=='R')ctr++; 
  }
  for(lli i=0;i<ctr;i++)
    if(s[i]=='W')
      ans++;
  
  cout<<ans;
  return 0;
}

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

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main()
{
  int stoneNum;
  string stones;
  cin >> stoneNum >> stones;
  
  int iterW,iterR;
  int cntR = 0;
  int ans = 0;
  
  rep(i,stoneNum)
  {
    if(stones[i] == 'R')　++cntR;
  }
  rep(i,cntR)
  {
    if(stones[i] == 'W') ++ans;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:17:25: error: extended character 　 is not valid in an identifier
   17 |     if(stones[i] == 'R')　++cntR;
      |                         ^
a.cc: In function 'int main()':
a.cc:17:25: error: '\U00003000' was not declared in this scope
   17 |     if(stones[i] == 'R')　++cntR;
      |                         ^~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main()
{
  int stoneNum;
  string stones;
  cin >> stoneNum >> stones;
  
  int iterW,iterR;
  int cntR = 0;
  int ans = 0;
  
  rep(i,stoneNum)
  {
    if(stones[i] == 'R')　cntR;
  }
  rep(i,cntR)
  {
    if(stones[i] == 'W') ans++;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:17:25: error: extended character 　 is not valid in an identifier
   17 |     if(stones[i] == 'R')　cntR;
      |                         ^
a.cc: In function 'int main()':
a.cc:17:25: error: '\U00003000cntR' was not declared in this scope; did you mean 'cntR'?
   17 |     if(stones[i] == 'R')　cntR;
      |                         ^~~~~~
      |                         cntR
Language: C++

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

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

  int R_right = 0;
  int W_left = 0;
  for (int i = 0; i < N; i++) {oi
    if (s[i] == 'R') R_right++;
  }

  int b = 0;
  int min_ans = N;
  for (int i = 0; i < N + 1; i++) {
    min_ans = min(min_ans, max(R_right, W_left));
    if (i == N) continue;
    if (s[i] == 'R')
      R_right -= 1;
    else
      W_left += 1;
  }

  cout << min_ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:32: error: 'oi' was not declared in this scope; did you mean 'i'?
   11 |   for (int i = 0; i < N; i++) {oi
      |                                ^~
      |                                i
Language: C++

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

int main() {
    ll N;
    char c[20000];
    cin>>N;
    cin>>c;
    int rs=0,ws=0;
    rep(i,n)
    {
      if(c[i]=='R')rs++;
      else ws++;
    }
    int diff=0;
    for(int i=0;i<rs;i++)
    {
      if(c[i]!='R')diff++;
    }
    for(int i=rs;i<N;i++)
    {
      if(c[i]!='W')diff++;
    }
    cout<<diff/2<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'n' was not declared in this scope
   13 |     rep(i,n)
      |           ^
a.cc:2:34: note: in definition of macro 'rep'
    2 | #define rep(i,n) for (int i=0;i<(n);++i)
      |                                  ^
Language: Java

import java.util.Scanner;

public class AlterAltar {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = Integer.parseInt(sc.next());
		//色の入力
		String c = sc.next();
		char[] C = new char[N];
		for (int i = 0; i < N; i++) {
			C[i] = c.charAt(i);
		}
		//左から白を探す→その白より右側に赤がある場合、一番右側にある赤とその白を入れ替える
		int check = 0;
//		int n = 0;
//		for (int j = 0; j < N; j++) {
//			if (C[j] == 'W') {
//				n++;
//			}
//		}
		for (int j = 0; j < 20; j++) {
			//白を検索
			int wn = 0;//ホワイトナンバー
			for (int i = 0; i < N; i++) {
				if (C[i] == 'W') {
					wn = i;
					break;
				} else {//ない場合
					wn = N;
				}
			}
			//赤を探す
			int rn = 0;//レッドナンバー
			for (int i = N - 1; i >= 0; i--) {
				if (C[i] == 'R') {
					rn = i;
					break;
				} else {//ない場合
					rn = N;
				}
			}
			//白と赤の場所比較して、場所入れ替え
			if (wn < rn && !(wn == 0 && rn == N)) {
				C[wn] = 'R';
				C[rn] = 'W';
				check++;
			}
		}
		//

		System.out.println(check);
	}

}


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

#include <iostream>
#include <string>
#define all(v) (v).begin(),(v).end()

using namespace std;

int main(){
  	int N;
  	cin >> N;
  	string s;
  	cin >> s;
  	int Nw = 0;
  	int Nr = count(all(s), 'R');
  	count = 0;
  	for(int i=0;i<s.size();i++){
      	if(s[i] == 'W') Nw++;
      	else Nr--;
      	int Cmax = Nw < Nr ? Nr : Nw;
      	count = Cmax < count ? Cmax : count;
    }
  	cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: 'count' was not declared in this scope
   13 |         int Nr = count(all(s), 'R');
      |                  ^~~~~
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(){
  	int N;
  	cin >> N;
  	string s;
  	cin >> s;
  	int counter = 0;
  	while(1){
      	wi = s.find_first_of('W');
  		ri = s.find_last_of('R');
      	if(wi >= ri) break;
  		else{
          	s[wi] = 'R';
          	s[ri] = 'W';
        }
        counter++;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'wi' was not declared in this scope
   13 |         wi = s.find_first_of('W');
      |         ^~
a.cc:14:17: error: 'ri' was not declared in this scope
   14 |                 ri = s.find_last_of('R');
      |                 ^~
Language: C++

#include <iostream>
#include <string>

using namespace std;

int main(){
  	int N;
  	cin >> N;
  	sring s;
  	cin >> s;
  	int counter = 0;
  	while(1){
      	wi = s.find_first_of('W');
  		ri = s.find_last_of('R');
      	if(wi >= ri) break;
  		else{
          	s[wi] = 'R';
          	s[ri] = 'W';
        }
        counter++;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'sring' was not declared in this scope
    9 |         sring s;
      |         ^~~~~
a.cc:10:16: error: 's' was not declared in this scope
   10 |         cin >> s;
      |                ^
a.cc:13:9: error: 'wi' was not declared in this scope
   13 |         wi = s.find_first_of('W');
      |         ^~
a.cc:14:17: error: 'ri' was not declared in this scope
   14 |                 ri = s.find_last_of('R');
      |                 ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

int main() {
    int N;
    cin >> N;
    string C;
    cin >> C;
    int mid = N/2;
    int cntW = 0;
    int cntR = 0;
    rep(i, mid) {
        if(C[i]=='W') ++cntW;
    }
    xrep(j, mid+1, N) {
        if(C[i]=='R') ++ cntR;
    }
    print(max(cntW, cntR));
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:14: error: 'i' was not declared in this scope
   45 |         if(C[i]=='R') ++ cntR;
      |              ^
Language: C++

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
	a[i]=(s[i]=='R');
    }
    int z = std::count(a.begin(), a.end(), 0);
    
    vector<int> g = a;
    sort(g.rbegin(), g.rend());

    
    int diffs=0;
    for (int i=0; i<n; i++) {
	diffs += (a[i]!=g[i]);
    }

    assert(diffs%2==0);
    int ans1 = diffs/2;
    out(ans2);
    // int ans2 = min(z, n-z);
    // //assert(ans1<=ans2);

    // cout<<min(ans1,ans2)<<endl;    
    
    return 0;
}


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

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

int main() {
  string c;
  int n, a=0, b=0, i, ans;
  cin >> n;
  cin >> c;
  
  for(int i=0; i<N; i++) {
    if(c[i] == 'R')a++;
  }
  if(a==0||a==n)cout << 0;
  else {
    for(int i=0;i<r;i++) {
      if(c[i] == 'W')b++;
    }
    cout << b;
  }
}

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

#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<stdlib.h>
#include<queue>
#include <windows.h>
#include<utility>
#include<string>
using namespace std;
int main() {
	int n,memo,ans=0;
	string str;
	cin >> n >> str;
	memo = str.size() - 1;
	for (int i = 0; i < str.size(); ++i) {
		if (str[i] == 'W') {
			for (int j = memo; j > i; --j) {
				if (str[j] == 'R') {
					str[i] = 'R';
					str[j] = 'W';
					memo = j-1;
					ans++;
					break;
				}
			}
		}
		if (i >= memo)break;
	}
	cout << ans << endl;
	return 0;
}

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

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

int main(){
  int n,atob=0,btoa=0;
  string s;
  cin >> n >> s;
  for(i=0;i<n;i++){
    if(s[i]=='R') atob++;
  }
  int ans=atob,now;
  for(i=0;i<n;i++){
    if(s[i]=='R') atob--;
    else btoa++;
    now=max(atob,btoa);
    ans=min(ans,now);
  }
  return 0;
}

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

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

int n,s1=0,s2=0;
string s;
int main(){
	cin>>n;
	cin>>s;
	for(int i=1;i<n;i++)
	    if(s[i]!='R')
	       s1++;
	for(int n-s1;i<n;i++)
	    if(s[i]!='W')
	       s2++;
	    
	cout<<s2;
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: expected ';' before '-' token
   12 |         for(int n-s1;i<n;i++)
      |                  ^
      |                  ;
a.cc:12:22: error: 'i' was not declared in this scope
   12 |         for(int n-s1;i<n;i++)
      |                      ^
a.cc:12:25: error: expected ')' before ';' token
   12 |         for(int n-s1;i<n;i++)
      |            ~            ^
      |                         )
a.cc:12:26: error: 'i' was not declared in this scope
   12 |         for(int n-s1;i<n;i++)
      |                          ^
Language: C++

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int a=0,b=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') a++;
  }
  int ans = max(a,b);
  for(int i=0;i<n;i+){
    if(s[i]=='R') a--;
    else b++;
    int now = max(a,b);
    ans = min(ans,now);
  }
  cout << ans << endl;
  return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: expected primary-expression before ')' token
   13 |   for(int i=0;i<n;i+){
      |                     ^
Language: C++

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int a=0,b=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') a++;
  }
  int ans = max(a,b);
  for(int i=0;i<n;i+){
    if(s[i]=='R') a--;
    else b++;
    int now = max(a,b);
    ans = min(ans,now);
  }
  cout << ans << endl;
  return 0;
}
    

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

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
      	sc.nextLine();
		String s=sc.nextLine();
		char[] c=s.toCharArray();
		int[] r=new int[n+1];
		for(int i=0;i<n;i++){
			if(c[i]=='R'){
				r[i+1]=r[i]+1;
			}else{
				r[i+1]=r[i];
			}
		}
		int min=n;
		int cost;
		int r2w;
		int w2r;
		for(int i=0;i<=n;i++){
			r2w=r[n]-r[i];
			w2r=i-r[i];
			if(r2w<w2r){
				cost=w2r;
			}else{
				cost=r2w;
			}			
			if(cost<min){
				min=cost;
			}
		}		
		System.out.println(min);
	}
}import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
      	sc.nextLine();
		String s=sc.nextLine();
		char[] c=s.toCharArray();
		int[] r=new int[n+1];
		for(int i=0;i<n;i++){
			if(c[i]=='R'){
				r[i+1]=r[i]+1;
			}else{
				r[i+1]=r[i];
			}
		}
		int min=n;
		int cost;
		int r2w;
		int w2r;
		for(int i=0;i<=n;i++){
			r2w=r[n]-r[i];
			w2r=i-r[i];
			if(r2w<w2r){
				cost=w2r;
			}else{
				cost=r2w;
			}			
			if(cost<min){
				min=cost;
			}
		}		
		System.out.println(min);
	}
}

Compiler output:
Main.java:35: error: class, interface, enum, or record expected
}import java.util.*;
 ^
1 error
Language: C++

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=2e5+50;
const ll mod=1e9+7;
using namespace std;
int n,s[nmax],p[nmax],rs,i,lst[nmax];
char c[nmax];
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)cin>>c[i];
    for(i=1;i<=n;i++)
    {
        p[i]=p[i-1]+(c[i]=='W');
        l[i]=l[i-1];
        if(c[i]=='R')l[i]=i;
    }
    for(i=n;i>=1;i--)s[i]=s[i+1]+(c[i]=='R');
    rs=n;
    for(i=0;i<=n;i++)
    {
        rs=min(rs,p[i]+s[i+1]);
        if(s[i+1]>=p[lst[i]])rs=min(rs,s[i+1]);
    }
    cout<<rs<<'\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'l' was not declared in this scope
   35 |         l[i]=l[i-1];
      |         ^
Language: C++

r#include <iostream>
using namespace std;

char a[300000];
int main(){
    int n;
    char s;
    scanf("%d", &n);
    
    scanf("%c", &s);
    int rs = 0;
    for(int i=0; i<n; i++){
        scanf("%c", &a[i]);
        if(a[i] == 'R') rs++;
    }
    int ans = 0;
    for(int i=0; i<rs; i++){
        if(a[i] == 'W') ans++;
    }
    cout << ans;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | r#include <iostream>
      |  ^
a.cc:1:1: error: 'r' does not name a type
    1 | r#include <iostream>
      | ^
a.cc: In function 'int main()':
a.cc:8:5: error: 'scanf' was not declared in this scope
    8 |     scanf("%d", &n);
      |     ^~~~~
a.cc:20:5: error: 'cout' was not declared in this scope
   20 |     cout << ans;
      |     ^~~~
Language: C++

#include <iostream>
#include <string>
#include <array>
 
int main()
{
	int n;
  	std::cin >> n;
  	std::string s;
  	std::cin >> s;
  	int reds{0};
  	int whites{0};
  	for(char ch : s)
    {
    	if(ch == 'R')
        	++reds;
      	else
          	++whites;
    }
  	if(reds == 0 || reds = s.size())
    {
    	std::cout << 0;
      	return 0;
    }
  	int res1{0};
  	for(int i = 0; i < s.size(); ++i)
    {
    	if(s[i] == 'W')
          	++res1;
      	else
          	--res1;
    }
  	std::cout << res1;
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:22: error: lvalue required as left operand of assignment
   20 |         if(reds == 0 || reds = s.size())
      |            ~~~~~~~~~~^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <array>
 
int main()
{
	int n;
  	std::cin >> n;
  	std::string s;
  	std::cin >> s;
  	int reds{0};
  	int whites{0};
  	for(char ch : s)
    {
    	if(ch == 'R')
        	++reds;
      	else
          	++whites;
    }
  	int res1{0};
  	for(int i = 0; i < s.size(); ++i)
    {
    	if(s[i] == 'W')
          	++res1;
      	else
          	--res1;
    }
  	std::cout << std::min(res1, n - reds, n - whites);
  	return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:28:25:   required from here
   28 |         std::cout << std::min(res1, n - reds, n - whites);
      |                      ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <array>

int main()
{
	int n;
  	std::cin >> n;
  	std::string s;
  	std::cin >> s;
  	int reds{0};
  	int whites{0};
  	for(char ch : s)
    {
    	if(ch == 'R')
        	++reds;
      	else
          	++whites;
    }
  	int res1{0};
  	int res2{0};
  	for(int i = 0; i < s.size(); ++i)
    {
    	if(s[i] == 'W')
          	++res1;
      	else
          	++res2
    }
  	std::cout << std::min(res1, res2);
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:23: error: expected ';' before '}' token
   27 |                 ++res2
      |                       ^
      |                       ;
   28 |     }
      |     ~
Language: C++

#include <iostream>
#include <string>
#include <array>

constexpr int white = 0;
constexpr int red = 1;

int main()
{
	int n;
  	std::cin >> n;
  	std::string s;
  	std::cin >> s;
  	int reds{0};
  	for(char ch : s)
    {
    	if(ch == 'R')
        	++reds;
    }
  	int res{0};
  	for(int i = 0; i < s.size() - reds; ++i)
    {
    	if(ch == 'W')
          	++res;
    }
  	return res;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:12: error: 'ch' was not declared in this scope
   23 |         if(ch == 'W')
      |            ^~
Language: C++

#include <iostream>
using namespace std;
 
int main(){
	int N,Wcnt=0,Rcnt=0;
	string s;
	cin>>N;
    cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='W'){
          Wcnt++;
        }
	for(int i=N-1;i>=N-Wcnt;i--){
		if(s[i]=='R'){
			Rcnt++;
        }
	printf("%d\n",Rcnt);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:9:36: note: to match this '{'
    9 |         for(int i=0;i<s.size();i++){
      |                                    ^
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--) #define FOR(i,n) for((i)=(0);(i)<(n);(i)++) #define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--) #define MOD 1000000007
signed main(){
   int N;
   string c;
   cin>>N;
   cin>>c;
   int wc=0;
   for(int i=0;i<N;i++){
       if(c[i]=='W') wc++;
   }
   int n=0;
   for(int i=N-1;i>N-1-wc;i--){
       if(c[i]=='R') n++;
   }
   cout<<n<<endl;
}

Compiler output:
a.cc:8:19: error: '#' is not followed by a macro parameter
    8 | #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--) #define FOR(i,n) for((i)=(0);(i)<(n);(i)++) #define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--) #define MOD 1000000007
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--) #define FOR(i,n) for((i)=(0);(i)<(n);(i)++) #define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--) #define MOD 1000000007
signed main(){
   int N;
   string c;
   cin>>N;
   cin>>c;
   int wc=0;
   for(int i=0;i<N;i++){
       if(c[i]=='W') wc++;
   }
   int n=0;
   for(int i=N-1;i>N-1-wc;i--){
       if(c[i]=='R') n++;
   }
   cout<<n<<endl;
}

Compiler output:
a.cc:7:18: error: '#' is not followed by a macro parameter
    7 | #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--) #define FOR(i,n) for((i)=(0);(i)<(n);(i)++) #define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--) #define MOD 1000000007
      |                  ^
Language: C++

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

int main() {
  string c;
  int N;
  cin >> N;
  cin >> c;
  
  for(int i=0; i<N; i++) {
    if (c.size(4)) {
      cout << "2" << endl;
    }
    else if(c.size(2)) {
      cout << "0" << endl;
    }
    else if(c.size(8)) {
      cout << "3" << endl;
    }
    break;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:15: error: no matching function for call to 'std::__cxx11::basic_string<char>::size(int)'
   11 |     if (c.size(4)) {
      |         ~~~~~~^~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1076:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1076 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
/usr/include/c++/14/bits/basic_string.h:1076:7: note:   candidate expects 0 arguments, 1 provided
a.cc:14:19: error: no matching function for call to 'std::__cxx11::basic_string<char>::size(int)'
   14 |     else if(c.size(2)) {
      |             ~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1076:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1076 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
/usr/include/c++/14/bits/basic_string.h:1076:7: note:   candidate expects 0 arguments, 1 provided
a.cc:17:19: error: no matching function for call to 'std::__cxx11::basic_string<char>::size(int)'
   17 |     else if(c.size(8)) {
      |             ~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1076:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1076 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
/usr/include/c++/14/bits/basic_string.h:1076:7: note:   candidate expects 0 arguments, 1 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string a;
  cin>>a;
  int a1=0;
  int a2=n-1;
  
  while(a1!=a2 || abs(a2-a1))
  {
   if(a[a1]=='R' && a[a2]=='W')
     swap(a[a1],a[a2])
     a1++;
    a2--;
    
  }
  cout<<a;
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:23: error: expected ';' before 'a1'
   15 |      swap(a[a1],a[a2])
      |                       ^
      |                       ;
   16 |      a1++;
      |      ~~
Language: C

#include<stdio.h>
int main(){
  int n;
  char c[200000];
  int r,w,s,x;
  r=0;w=0;s=0;x=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%c",&c[i]);
    if(c[i]=='R'){
      r++;
    }else{
      w++;
    }
  }
  for(int i=0;i<r;i++){
    if(c[i]=='w'){
      s++:
    }
  }
  for(int i=r;i<n;i++){
    if(c[i]=='R'){
      x++;
    }
  }
  if(s<=x){
    printf("%d\n",x);
  }else{
    printf("%d\n",s);
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:10: error: expected ';' before ':' token
   18 |       s++:
      |          ^
      |          ;
Language: C

#include<stdio.h>
int main(){
  int n;
  char c[200000];
  int r,w,s,x;
  r=0;w=0;s=0;x=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&c[i]);
    if(c[i]=='R'){
      r++;
    }else{
      w++;
    }
  }
  for(int i=0;i<r;i++){
    if(c[i]=='w'){
      s++:
    }
  }
  for(int i=r;i<n;i++){
    if(c[i]=='R'){
      x++;
    }
  }
  if(s<=x){
    printf("%d\n",x);
  }else{
    printf("%d\n",s);
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:10: error: expected ';' before ':' token
   18 |       s++:
      |          ^
      |          ;
Language: C

#include <stdio.h>

int main()
{
  int n;
  scanf("%d", &n);
  
  char s[n+1];
  scanf("%s", s);
  
  cnt = 0;
  for (int i = 0, j = 0; i < n; i++)
    s[i] == 'R' && s[j++] == 'W' & cnt++;
  
  printf("%d", cnt);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:3: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
   11 |   cnt = 0;
      |   ^~~
      |   int
main.c:11:3: note: each undeclared identifier is reported only once for each function it appears in
Language: Java

import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      String str = br.readLine();
      int numR = 0
      for(int i = 0; i < n; i++)
        	if(str.charAt(i) == 'R')
              numR++;
     int ans = 0;
     for(int i = 0; i < numR; i++)
       if(str.charAt(i) == 'W')
         ans++;
     out.println(ans);
      out.close();
   }
}

Compiler output:
Main.java:10: error: ';' expected
      int numR = 0
                  ^
1 error
Language: Java

import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      str = br.readLine();
      int numR = 0
      for(int i = 0; i < n; i++)
        	if(str.charAt(i) == 'R')
              numR++;
     int ans = 0;
     for(int i = 0; i < numR; i++)
       if(str.charAt(i) == 'W')
         ans++;
     out.println(ans);
      out.close();
   }
}

Compiler output:
Main.java:10: error: ';' expected
      int numR = 0
                  ^
1 error
Language: Java

import java.util.*;
import java.io.*;
public class template1{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int n = Integer.parseInt(st.nextToken());
      str = br.readLine();
      int numR = 0
      for(int i = 0; i < n; i++)
        	if(str.charAt(i) == 'R')
              numR++;
     int ans = 0;
     for(int i = 0; i < numR; i++)
       if(str.charAt(i) == 'W')
         ans++;
     out.println(ans);
      out.close();
   }
}

Compiler output:
Main.java:10: error: ';' expected
      int numR = 0
                  ^
1 error
Language: C

#include <bits/stdc++.h>
using namespace std;
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define rep1(i,n) Rep(i,1,n)
#define rep(i,n) Rep(i,0,n-1)
bool a[222222];
int n,r,w,maxn;
int main(){
	cin>>n;
	rep(i,n){
		char p;
		cin>>p;
		if(p=='r'){
			a[i]=1;
			r++;
		}
	}
	maxn=r;
	rep(i,n){
		if(a[i]==0)
			w++;
		else
			r--;
		maxn=min(maxn,max(r,w));
	}
	cout<<maxn<<endl;
	return 0;
}

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

#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll N;
    string c;
    cin >> N >> c;
    ll red = count(c.begin(), c.end(), 'R');
    ll white = 0;
    ll ans=N;
    rep(s, N+1) {
        ans = min(ans, max(white,red));
        if (s == N)
            break;
        if (c[s] == 'R') {
            --red;
        } else {
            ++white;
        }
    }

    cout << ans << endl;
   

Compiler output:
a.cc: In function 'int main()':
a.cc:34:25: error: expected '}' at end of input
   34 |     cout << ans << endl;
      |                         ^
a.cc:16:12: note: to match this '{'
   16 | int main() {
      |            ^
Language: C++

#include<bist/stdc++.h>

int main()
{
	int n;
  	string s;
  	cin>>n>>s;
  	int cnt=0;
  	for(int i=0;i<s.size();i++)
    {
      if(s[i]=='R')
        cnt++;
    }
  	n=cnt;
  	for(int i=0;i<n;i++)
    {
    	if(s[i]=='R')
          cnt--;
    }
  	cout<<cnt<<endl;
}

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

    #include <bits/stdc++.h>
    using namespace std;
    typedef unsigned long long ull;
    typedef long long ll;
    typedef long double ld;
    #define FOR(type,a,b,c,d) for(type i = a;i b c;i += d)
    #define QUICK ios_base::sync_with_stdio(0);cout << fixed;
    #define MOD 1000000007

    string upper(string);
    string lower(string);
    bool isalup(string);
    bool isalow(string);

    int main(){

        int a,ans = 0;;
        cin >> a;
        string b;
        cin >> b;int i = 0;
        while(i<j-1){
            if(b[i]=='R')
                i++;
            else if(b[j]=='W')
                j--;
            else
                ans++,i++,j--;
        }
        cout << ans;

        return 0;
    }









                string upper(string a){
                    for(char& c:a){
                        if(islower(c))
                            c -= 32;
                       }
                    return a;
                }
                    string lower(string a){
                        for(char& c : a){
                            if(isupper(c))
                                c += 32;
                        }
                        return a;
                    }
                    bool isalup(string a){
                        for(char& c: a){
                            if(islower(c))
                                return false;
                        }
                        return true;
                    }
                    bool isalow(string a){
                        for(char& c:a){
                            if(isupper(c))
                                return false;
                        }
                       return true;
                    }


Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'j' was not declared in this scope
   21 |         while(i<j-1){
      |                 ^
Language: C++

#include<iostream>

using namespace std;

int main(){
  int n,i,count=0; 
   cin >> n;
  char ch[n];
    for(int i=0;i<n;i++)
        cin >> ch[i];
    i=0;
    int j=n-1;
    while(i<j){
      while(ch[i]!='W' && i<n)
        i++;
      while(ch[j]!='R' && j>=0) j++;
      if(i<j){
        count++;
        char temp;
        temp = c[i];
        c[i]= c[j];
        i++, j--;
      }
    }
  cout<< count<< "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:16: error: 'c' was not declared in this scope
   20 |         temp = c[i];
      |                ^
Language: C++

#include<iostream>

using namespace std;

int main(){
  int n,i,count=0; 
   cin >> n;
  char ch[n];
    for(int i=0;i<ch.size();i++)
        cin >> ch[i];
    i=0;
    int j=n-1;
    while(i<j){
      while(ch[i]!='W' && i<n)
        i++;
      while(ch[j]!='R' && j>=0) j++;
      if(i<j){
        count++;
        char temp;
        temp = c[i];
        c[i]= c[j];
        i++, j--;
      }
    }
  cout<< count<< "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: request for member 'size' in 'ch', which is of non-class type 'char [n]'
    9 |     for(int i=0;i<ch.size();i++)
      |                      ^~~~
a.cc:20:16: error: 'c' was not declared in this scope
   20 |         temp = c[i];
      |                ^
Language: C++

#include<iostream>

using namespace std;

int main(){
  int n,count=0;
  char ch[n+1];
   cin >> n;
    for(int i=0;i<ch.size();i++)
        cin >> ch[i];
    i=0;
    int j=ch.size()-1;
    while(i<j){
      while(ch[i]!='W' && i<=ch.size()-1)
        i++;
      while(ch[j]!='R' && j>=0) j++;
      if(i<j){
        count++;
        char temp;
        temp = c[i];
        c[i]= c[j];
        i++, j--;
      }
    }
  cout<< count<< "\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: request for member 'size' in 'ch', which is of non-class type 'char [(n + 1)]'
    9 |     for(int i=0;i<ch.size();i++)
      |                      ^~~~
a.cc:11:5: error: 'i' was not declared in this scope
   11 |     i=0;
      |     ^
a.cc:12:14: error: request for member 'size' in 'ch', which is of non-class type 'char [(n + 1)]'
   12 |     int j=ch.size()-1;
      |              ^~~~
a.cc:14:33: error: request for member 'size' in 'ch', which is of non-class type 'char [(n + 1)]'
   14 |       while(ch[i]!='W' && i<=ch.size()-1)
      |                                 ^~~~
a.cc:20:16: error: 'c' was not declared in this scope
   20 |         temp = c[i];
      |                ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class AlterAltar {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			int n = in.ni(), ans = 0;
			char[] stones = in.n().toCharArray();
			int l = 0, r = n - 1;
			while (l < r) {
				while (l < n && stones[l] == 'R')
					++l;
				while (r >= 0 && stones[r] == 'W')
					--r;
				if (l < r) {
					++ans;
					++l;
					--r;
				}
			}
			out.println(ans);
		}
	}

	private static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		private InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private String n() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		private int ni() {
			return Integer.parseInt(n());
		}
	}
}

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

Copy
#include <cstdio>

const int MAX = 2e5+10;
char s[MAX];
int n;

int main(){
    scanf("%d%s\n", &n, s);
    int ans = 0, cnt = 0;
    for (int i = 0; i < n; i++) if (s[i] == 'R') cnt++;
    for (int i = 0; i < cnt; i++) if (s[i] == 'W') ans++;
    printf("%d\n", ans);
    return 0;
}

Compiler output:
a.cc:1:1: error: 'Copy' does not name a type
    1 | Copy
      | ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=int (a);i<int (n);i++)
#define OUT  freopen("output.txt", "w", stdout)
#define IN  freopen("input.txt", "r", stdin)
#define mem(a,b) memset((a),(b),sizeof(a))
#define NumofDigits(n) ((int)log10(n)+1)
#define NumofBits(n) ((int)log2(n)+1)
#define PI 3.14159265358979323846264
#define vii vector<pair<int,int>>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi  vector<int>
#define nl  cout<<"\n"
#define pb  push_back
#define mp  make_pair
#define ll  long long 
#define ss  second 
#define ff  first
#define endl "\n"
#define sp  " "
using namespace std;
	
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int t=1; //cin>>t;
while(t--)
{
	
  ll n,cnt=0,ans=0; cin>>n;
  string s;cin>>s;
  rep(i,0,n)if(s[i]=='R')cnt++;
  rep(i,0,cnt)if(s[i]=='W')ans++
  cout<<ans;
  
}

}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:33: error: expected ';' before 'cout'
   33 |   rep(i,0,cnt)if(s[i]=='W')ans++
      |                                 ^
      |                                 ;
   34 |   cout<<ans;
      |   ~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define ll long long


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

    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
	char s[n];
    cin>>s;
    int ans=0;
	int j=n-1;
	for(int i=0;i<j){
		if(s[i]=='W'&&s[j]=='W'){
			j--;
		}
		else if(s[i]=='R'&&s[j]=='R'||s[i]=='R'&&s[i]=='W')
			i++;
		else
			ans++,j--,i++;
	}
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: expected ';' before ')' token
   23 |         for(int i=0;i<j){
      |                        ^
      |                        ;
Language: C++

#include <bits/stdc++.h>

int main() {
  int n;
  int a = 0;    // R->Wの数
  int b = 0;    // W->Rの数
  int n_change; // 交換する回数
  std::string s;
  
  std::cin >> n >> s;


  for (int i = 0; i < n; i++)
    if (s[i] == 'R') a++; // 赤の数でaを初期化(交換回数は赤の数)

  // 境界を一番左においた時の交換回数
  n_change = max(a, b);

  // はじめの完成形はすべて白. 境界を左から右に移動させ左から赤色していく
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') b++; // b(W->R)が一つ増える
    else a--;             // a(R->W)がひとつ減る

    // 最小の交換回数を更新
    if (n_change > std::max(a, b)) n_change = std::max(a, b);
  }

  std::cout << n_change << std::endl;
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:14: error: 'max' was not declared in this scope; did you mean 'std::max'?
   17 |   n_change = max(a, b);
      |              ^~~
      |              std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

int main(){
    int n;
    cin>>n;
    vector<char> c(n);
    bool flag = false;
    int a=0; int b=0;
    for(int i=0;i<n;i++){
        cin>>c[i];
        if(c[i]=='R') a++;
        if(c[i] =='R' && c[i-1] == 'W'){
            flag = true;
        }
    } 
    if(!flag){
        cout<<0<<endl;
        return 0;
    }
    int ans=a;
    for(int i=0;i<n;i++){
        if(c[i]=='W'){
            b++; 
        }
        else{
            a--;
        }
        ans=min(max(a,b),ans);
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin>>n;
      |     ^~~
a.cc:4:5: error: 'vector' was not declared in this scope
    4 |     vector<char> c(n);
      |     ^~~~~~
a.cc:4:12: error: expected primary-expression before 'char'
    4 |     vector<char> c(n);
      |            ^~~~
a.cc:8:14: error: 'c' was not declared in this scope
    8 |         cin>>c[i];
      |              ^
a.cc:15:9: error: 'cout' was not declared in this scope
   15 |         cout<<0<<endl;
      |         ^~~~
a.cc:15:18: error: 'endl' was not declared in this scope
   15 |         cout<<0<<endl;
      |                  ^~~~
a.cc:20:12: error: 'c' was not declared in this scope
   20 |         if(c[i]=='W'){
      |            ^
a.cc:26:17: error: 'max' was not declared in this scope
   26 |         ans=min(max(a,b),ans);
      |                 ^~~
a.cc:26:13: error: 'min' was not declared in this scope; did you mean 'main'?
   26 |         ans=min(max(a,b),ans);
      |             ^~~
      |             main
a.cc:28:5: error: 'cout' was not declared in this scope
   28 |     cout<<ans<<endl;
      |     ^~~~
a.cc:28:16: error: 'endl' was not declared in this scope
   28 |     cout<<ans<<endl;
      |                ^~~~
Language: C++

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

int main(){
  int n;
  char str[n+1];
  cin>>str;
  int a=0,b=0;
  for(int i=0;i<n;i++){
    if(str[i]=='R')a++;
  }
  ans=max(a,b);
  for(int i=0;i<n;i++){
    if(str[i]=='R')a--;
    if(str[i]=='W')b++;
    ans=min(ans,max(a,b));
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |   ans=max(a,b);
      |   ^~~
      |   abs
Language: C

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

int main(){
	//Code here bby
  int n;
  cin>>n;
  string s;
  cin>>s;
  int wTotal, rTotal;
  wTotal = rTotal = 0;
  for(char idx : s){
    if(idx == 'W'){
      wTotal++;
    } else {
      rTotal++;
    }
  }
  int wCurr, rCurr;
  wCurr = rCurr = 0;
  if(s[0] == 'W'){
    wCurr++;
  } else {
    rCurr++;
  }
  int res = -1;
  for(int idx = 1; idx < n; idx++){
    int swap = min((rTotal - rCurr), wCurr);
    int ops = wCurr + (rTotal - rCurr) - swap;
    if(res == -1){
      res = ops;
    } else {
      res = min(res, ops);
    }
    if(s[idx] == 'W'){
      wCurr++;
    } else {
      rCurr++;
    }
  }
  cout<<res<<endl;
}


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

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int cnt=0=;
  vector<int>v1,v2;
for(int i=1;i<=n;i++)
   {
    char ch ;
    cin>>ch;
    if(ch=='W')
      v1.push_back(i);
    else
      v2.push_back(i);
   }
  ll i =0,j=v2.size()-1;
 
  while(i<v1.size() && j>=0 )
  {
   // cout<<v1[i]<< " " <<v2[j]<<endl;
    if(v1[i]<v2[j])
    cnt++;
    i++;
    j--;
  }
  cout<<cnt<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: expected primary-expression before ';' token
    7 |   int cnt=0=;
      |             ^
a.cc:18:3: error: 'll' was not declared in this scope
   18 |   ll i =0,j=v2.size()-1;
      |   ^~
a.cc:20:9: error: 'i' was not declared in this scope
   20 |   while(i<v1.size() && j>=0 )
      |         ^
a.cc:20:24: error: 'j' was not declared in this scope
   20 |   while(i<v1.size() && j>=0 )
      |                        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
long N,count=0;
  string stones;
  cin>>N;
  cin>>stones;
 long i=0;j=stones.length()-1;
  while(i<=j)
  {
    while(i<=j && stones[i]=='R')
    i++;
    while(i<=j && stones[j]=='W')
      j--;

     i++;
     j--;
     count++;
  }
  cout<<count;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: 'j' was not declared in this scope
    9 |  long i=0;j=stones.length()-1;
      |           ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: 'j' was not declared in this scope
    9 |   int i=0;j=stones.length()-1;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    
    string s;
    cin>>s;
    ll ans=0,ans1=0,countr=0,countw=0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            countr++;
        }
        else
        {
            countw++;
        }
    }
 
    for(ll i=0;i<n;i++)
    {
        if(i<countr && s[i]!='R')
        {
            ans++;
        }
        else if(i>=countr && s[i]!='W')
        {
            ans1++;
        }
    }
  
    cout<<(ans1+ans2)/2<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:17: error: 'ans2' was not declared in this scope; did you mean 'ans1'?
   39 |     cout<<(ans1+ans2)/2<<endl;
      |                 ^~~~
      |                 ans1