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

#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,l,r,c=0;
  scanf("%d",&n);
  string s;
  cin>>s;
  l=0,r=n-1;
  while(l<r)
  {
    if(s[l]=='W'&&s[r]=='R')
    {
      c++;
      l++;
      r--;
    }
    else
    { 
    	if(s[l]=='R'&&s[r]=='W)
       	{
        	 l++;
         	r--;
       	}
          else{
            if(s[l]=='W'&&s[r]=='R')
              r--;
            else
              l++;
          }
     }
  }
   cout<<c;
  
  return 0;
}

Compiler output:
a.cc:21:29: warning: missing terminating ' character
   21 |         if(s[l]=='R'&&s[r]=='W)
      |                             ^
a.cc:21:29: error: missing terminating ' character
   21 |         if(s[l]=='R'&&s[r]=='W)
      |                             ^~~
a.cc: In function 'int main()':
a.cc:22:9: error: expected primary-expression before '{' token
   22 |         {
      |         ^
a.cc:21:29: error: expected ')' before '{' token
   21 |         if(s[l]=='R'&&s[r]=='W)
      |           ~                 ^
      |                             )
   22 |         {
      |         ~                    
a.cc:32:6: error: expected primary-expression before '}' token
   32 |      }
      |      ^
Language: C++

#include<iostrem>
#include<string>
using namespace std;
int main()
{
  int n,l,r,c=0;
  scanf("%d",&n);
  string s;
  cin>>s;
  l=0,r=n-1;
  while(l<r)
  {
    if(s[l]=='W'&&s[r]=='R')
    {
      c++;
      l++;
      r--;
    }
    else
    { 
    	if(s[l]=='R'&&s[r]=='W)
       	{
        	 l++;
         	r--;
       	}
          else{
            if(s[l]=='W'&&s[r]=='R')
              r--;
            else
              l++;
          }
     }
  }
   cout<<c;
  
  return 0;
}

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

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



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

Compiler output:
a.cc: In function 'int main()':
a.cc:33:5: error: 'now' was not declared in this scope; did you mean 'pow'?
   33 |     now = max(r,w);
      |     ^~~
      |     pow
Language: C++

//============================================================================
// Name        : template.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int A() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

int B() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, d;
	cin >> n >> d;
	int an = 0;
	while (n--) {
		double x, y; cin >> x >> y;
		double dis = (x * x) + (y * y);
		if (dis <= d * d) {
			an++;
		}
	}
	cout << an << "\n";
	return 0;
}

int C() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	ll x = 0;
	ll ct = 0;
	ll lmt = 10e7;
	while(ct < lmt) {
       
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s ; cin >> s;
	string org = s;
	int reds = 0;
	forn(i,n) {
     if(s[i] == 'R') reds++;
	}
     int ans = reds;
	forn(i < reds) {
		if(org[i] == 'W') ans--;
	}
	cout << ans << "\n";
	return 0;
}


Compiler output:
a.cc:93:22: error: macro "forn" requires 2 arguments, but only 1 given
   93 |         forn(i < reds) {
      |                      ^
a.cc:26:9: note: macro "forn" defined here
   26 | #define forn(i,n) \
      |         ^~~~
a.cc: In function 'int C()':
a.cc:79:1: warning: no return statement in function returning non-void [-Wreturn-type]
   79 | }
      | ^
a.cc: In function 'int main()':
a.cc:93:9: error: 'forn' was not declared in this scope
   93 |         forn(i < reds) {
      |         ^~~~
Language: C

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


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;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  int N,r=0,w=0;
  string S;

  cin >> N >> S;

  rep(i,n){
    if(S[i]=='R') r++;
    else w++;
  }

  int ans = min(r,w);
  int w_left = 0, w_right = w, r_left = 0, r_right = r;

  rep(i,n){

    if(S[i]=='W'){
      w_left++; w_right--;
    }

    else{
      r_left++; r_right--;
    }

    if(w_left <= r_right){
      ans = min(ans, r_right);
    }

    if(w_left > r_right){
      ans = min(ans, w_left);
    }

  }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'n' was not declared in this scope
   16 |   rep(i,n){
      |         ^
a.cc:3:43: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i = 0; i < (int) n; i++)
      |                                           ^
a.cc:24:9: error: 'n' was not declared in this scope
   24 |   rep(i,n){
      |         ^
a.cc:3:43: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i = 0; i < (int) n; i++)
      |                                           ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void main()
{
    int N;
    string C;
    cin >> N >> C;
    auto b = C.begin();
    int a = count(b, b + count(b, C.end(), 'R'), 'W');
    cout << a;
}

Compiler output:
a.cc:7:1: error: '::main' must return 'int'
    7 | void main()
      | ^~~~
Language: C++

#include <iostream>
#include <cmath>
#include <string>

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

	int r = std::count(C.begin(), C.end(), 'R');

	int ans = 0;
	for (int i = 0; i < r; i++)
		if (C[i] == 'W')
			ans++;
	std::cout << ans << std::endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: 'count' is not a member of 'std'; did you mean 'cout'?
   12 |         int r = std::count(C.begin(), C.end(), 'R');
      |                      ^~~~~
      |                      cout
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
#define all(a) sort((a).begin(),(a).end()) 
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int n;cin>>n;
    string s;cin>>s;
    string t=all(s);
  
    int c=0;
    rep(i,n)if(s[i]!=t[i])c++;
    cout<<(c/2)<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: conversion from 'void' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   10 | #define all(a) sort((a).begin(),(a).end())
      |                ~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:14: note: in expansion of macro 'all'
   41 |     string t=all(s);
      |              ^~~
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int w = 0;
        int r = 0;
		String s = sc.next();      
        for(int i=0;i<a;i++){if(s.charAt(i)=='R'){r++;}
                            }   
        int ans = r;     
        for(int i=0;i<a;i++){if(s.charAt(i)=='W'){w++;}
                             else{r--;}
                            ans=Math.min(ans,Math.max(w,r);
                            }        
		System.out.println(ans);
	}
}

Compiler output:
Main.java:14: error: ')' or ',' expected
                            ans=Math.min(ans,Math.max(w,r);
                                                          ^
1 error
Language: C++

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string s;
    int N;
    cin >> N >> s;
    int result = 0;
    while (true) {

        // indexの取得
        string re = s;
        reverse(re.begin(), re.end());
        if (s.find("W") == string::npos || r.find("R") == string::npos) break;
        int w = s.find("W");
        int r = N - re.find("R") - 1;
        

        //Wよりも右にRがあるならば入れ替える．
        if (w < r) {
            s[w] = 'R';
            s[r] = 'W';
            result += 1;
            continue; 
        } else {
            break;
        }
    }
    cout << result << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:44: error: 'r' was not declared in this scope; did you mean 're'?
   18 |         if (s.find("W") == string::npos || r.find("R") == string::npos) break;
      |                                            ^
      |                                            re
Language: C++

#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
int n;
int arr[mxN];
int ww = 0;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n;
    string s;
    cin>>s;
    owo(i, 0, n) {
        arr[i] = s[i]=='W';
        ww+=arr[i];
    }
    int ans = 0;
    uwu(i, n, 0) {
        if(ww==0)break;
        if(arr[i]==0)ans++;
        w--;
    }
    cout<<ans<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'w' was not declared in this scope
   45 |         w--;
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,i,numw,startR,endW,a,ans,R,W;
  numw=0;
  cin >> N
  char str[N];
  cin >> str;
  
  for(i=0;i<N;++i)
  {
  if(str[i]=='W') numw++;
  }
  a=0;
  while(str[a]=='R')
  {
  a++;
  }
  startR=a;
  R=N-numw-startR;
  
  
  a=N-1;
  endW=0;
  while(str[a]=='W')
  {
  a--;
  endW++;
  }
  W=numw-endW;
  
  
  if(W<R) ans=W;
  else ans=R;
  
cout << ans << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: expected ';' before 'char'
    7 |   cin >> N
      |           ^
      |           ;
    8 |   char str[N];
      |   ~~~~     
a.cc:9:10: error: 'str' was not declared in this scope; did you mean 'std'?
    9 |   cin >> str;
      |          ^~~
      |          std
Language: C++

cin >> n;
	cin >> s;
	int a = 0;
	int b = s.size()-1;
	int counter = 0;
	while(a <= b){
		if(s[a] == 'W' && s[b] == 'R'){ counter++;swap(s[a],s[b]);}
		else if(s[a] == 'W') b--;
		else if(s[b] == 'R') a++;
		else{
			a++;b--;
		}
	}
	cout << counter << "\n";

Compiler output:
a.cc:1:1: error: 'cin' does not name a type
    1 | cin >> n;
      | ^~~
a.cc:2:9: error: 'cin' does not name a type
    2 |         cin >> s;
      |         ^~~
a.cc:4:17: error: 's' was not declared in this scope
    4 |         int b = s.size()-1;
      |                 ^
a.cc:6:9: error: expected unqualified-id before 'while'
    6 |         while(a <= b){
      |         ^~~~~
a.cc:14:9: error: 'cout' does not name a type
   14 |         cout << counter << "\n";
      |         ^~~~
Language: C++

#include <iostream> 
#include <sstream> // istringstream
#include <string> // 文字列
#include <algorithm> // アルゴリズム
#include <cmath> // 
#include <vector> // vector
#include <set> // set
#include <map> // map

using namespace std;

int main()
{   
    // input sample
    long long N; 
    cin >> N;
    string s;
    cin >> s;

    long long cnt = 0;
    long long i;
    // 時間を節約するために右端を記録
    long long right = N-1;
    long long left = 0
    for (i = 0; i < N-1; ) {
        cout << i << " " << s.substr(i, 2) << " " << s << endl;
        if (s[i] == 'W') {
            left = i;
        }
        if (s.substr(i, 2) == "WR") {
            for (long long j = right; j >= i+1; --j) {
                // これが右端の場合色を変更する
                if (j == i+1) {
                    s[j] = 'W';
                    // s[j-1] = 'R';
                    cnt++;
                    right = j-1;
                    break;
                }
                // 一番右にあるRと交換
                if (s[j] == 'R') {
                    s[left] = 'R';
                    s[j] = 'W';
                    right = j-1;
                    cnt++;
                    break;
                }
            }
            if (i != 0) {
                i -= 1;
            }
        } else {
            i += 1;
        }
    } 

    // 連続したWWRの場合先頭のWと交換すべきだった


    cout << cnt << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: expected ',' or ';' before 'for'
   25 |     for (i = 0; i < N-1; ) {
      |     ^~~
a.cc:25:26: error: expected primary-expression before ')' token
   25 |     for (i = 0; i < N-1; ) {
      |                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
  string s;
  ll n,w=0,r=0;
  cin>>n;
  
 for(int i=0;i<n;i++)
 {
   if(s[i]=='W')
     w+;
   else 
     r++;
 }
  
  if(w)
  {
    w=0;
    for(int i=0;i<r;i++)
    {
      if(s[i]=='W')
        w++;
    }
  }
  
  cout<<w;
  return 0;
}
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:17:8: error: expected primary-expression before ';' token
   17 |      w+;
      |        ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>
#include <queue>

constexpr long long INFLL = 1e18;

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{

    int n;
    cin >> n;
    vector<int> s(n);
    char temp;
    // int checkW = 0;
    // int checkR = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        if (temp == 'R')
        {

            s.at(i) = 1;
        }
        else
        {
            s.at(i) = 0;
        }
    }
    int r = n - 1;
    bool che = false;
    int count = 0;

    for (int i = 0; i < n; i++)
    {
        if (s.at(i) == 0)
        {
            while (s.at(r) == 0)
            {
                if (i >= r)
                {
                    che = true;
                    break;
                }

                r--;
            }
            if (che)
            {
                break;
            }
            r--;
            count++;
        }
    }
    if (che == false && i == 0 && r == 0)
    {
        count = n;
    }

    cout << count << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:25: error: 'i' was not declared in this scope
   66 |     if (che == false && i == 0 && r == 0)
      |                         ^
Language: C++

#include <iostream>
#include <string>
using namespace std;
#define MAX 200000
string str;

int main(void){
    int N, cnt_w, cnt_r;
    cnt_w = 0;
    cnt_r = 0;
    flag = 0;
    
    cin >> N;
    cin >> str;
    
    for(int i = 0; i < N/2; i++){
        if(i == N/2 - 1 && str[i] == str[i + 1]) continue; 
        else if(str[i] == 'W') cnt_w++;
    }
    for(int i = N/2; i < N; i++){
        if(i == N/2 && str[i] == str[i - 1]) continue;
        if(str[i] == 'R') cnt_r++;
    }
    
    if(cnt_w == 0 || cnt_r == 0) cout << 0 << endl;
    else if(cnt_w >= cnt_r) cout << cnt_w << endl;
    else cout << cnt_r << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'flag' was not declared in this scope
   11 |     flag = 0;
      |     ^~~~
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 < s.length(); i++)
  {
    if (s[i] == 'R') countR++;
  }
  int countW = n - countR;
  if (countR < countW)
  {
    int ans = countR;
  	for (int i = 0; i < countR; i++)
  	{
    	if (s[i] == 'R') ans--;
  	}
  	cout << ans << endl;
  }
  else
  {
    int ans = countW;
  	for (int i = s.length; i > s.length - countW; i++)
  	{
    	if (s[i] == 'W') ans--;
  	}
  	cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:24: error: cannot convert 'std::__cxx11::basic_string<char>::length' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'int'
   27 |         for (int i = s.length; i > s.length - countW; i++)
      |                        ^~~~~~
a.cc:27:38: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   27 |         for (int i = s.length; i > s.length - countW; i++)
      |                                    ~~^~~~~~
      |                                            ()
Language: C++

#include<iostream>
using namespace std;
int n,a[200001],x,y;
int zuobiandeling(){
	for(int i=1;i<=n;i++){
		if(a[i]==0){
			x=i;
			return 0;
		}
	}
}
int youbiandeyi(){
	for(int i=n;i>=1;i--){
		if(a[i]==1){
			y=i;
			return 0;
		}
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		char x;
		cin>>x;
		if(x=='R') a[i]=1;
	}
	if(jiancha()){
		cout<<0;
		return 0;
	}
	for(int ans=0;ans<=n;ans++){
		x=y=0;
		zuobiandeling();
		youbiandeyi();
		if(x==0||y==0){
			cout<<ans;
			return 0;
		}
		if(x>y){
			cout<<ans;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:12: error: 'jiancha' was not declared in this scope
   27 |         if(jiancha()){
      |            ^~~~~~~
a.cc: In function 'int zuobiandeling()':
a.cc:11:1: warning: control reaches end of non-void function [-Wreturn-type]
   11 | }
      | ^
a.cc: In function 'int youbiandeyi()':
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<char>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll n;cin >> n;
    stack<ll> q;
    string a;
    cin >> a;
    ll g = 0;ll h == 0;
    if(a.at(0) == 'W'){
        g++;
    }
    if(a.at(n-1) == 'R'){
        h++;
    }
    rep2(i,1,n){
        if(a.at(i) == 'W' && g > 0){
            g++;
        }
        if(a.at(n-i-1)){
            h++;
        }
    }
    for(ll i = 0;i < n;i++){
        if(a.at(i) == 'R'){
            q.push(i);
        }
    }
    ll count = 0;
    for(ll i = 0;i < n-1;i++){
        if(g > h && i == 0){
            rep(i,h){
                a.at(n-1-i) = 'W';
                a.at(i) = 'R';
                count++;
            }
            i = h-1;
            continue;
        }
        if(a[i] == 'W' && a[i+1] == 'R'){
            if(!q.empty()){
                int k = q.top();
                a.at(i) = 'R';
                a.at(k) = 'W';
                q.pop();
                count++;
                if(i-1 >= 0){
                    i = i - 2;

                }
            }else{
                a[i] = 'R';
                count++;
            }
        }
    }
    cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:19: error: expected initializer before '==' token
   16 |     ll g = 0;ll h == 0;
      |                   ^~
a.cc:21:9: error: 'h' was not declared in this scope
   21 |         h++;
      |         ^
a.cc:28:13: error: 'h' was not declared in this scope
   28 |             h++;
      |             ^
a.cc:38:16: error: 'h' was not declared in this scope
   38 |         if(g > h && i == 0){
      |                ^
Language: C++

#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[200000];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n;
    scanf("%s",ss+1);
    for(int i=1;i<=n;i++)
    {
    	if(ss[i]=='R')sum++;
    }
    int ans=sum;
    for(int i=1;i<=sum;i++)
    {
    	if(ss[i]=='R')ans--;
	}pr2(ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:23: error: 'sum' was not declared in this scope
   34 |         if(ss[i]=='R')sum++;
      |                       ^~~
a.cc:36:13: error: 'sum' was not declared in this scope
   36 |     int ans=sum;
      |             ^~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

// ����̕�����𐔂���֐�
size_t count(const string& str, const string& sub, const size_t ini = 0, const size_t fin = string::npos) {
	size_t pos = str.find(sub, ini);
	size_t cnt = 0;
	while (pos < fin) {
		cnt += 1;
		pos = str.find(sub, pos + sub.length());
	}
	return cnt;
}

int main() {

	int N;
	cin >> N;

	string c;
	cin >> c;

	int i1 = 0;
	for (int i = 0; i < N; i++) {
		if (c[i] != 'R') {
			i1 = i;
			break;
		}
	}

	int i2 = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (c[i] != 'W') {
			i2 = i;
			break;
		}
	}

	string str = c.substr(i1, i2 - i1 + 1);
	
	int iW = 0;
	int iR = str.size() - 1;
	size_t bR = count(c, "R");

	if (str.size() != 0 && bR != 0 && bR != c.size();) {
		int ans = 1;
		while (iW < iR) {
			for (int i = iW; i < str.size(); i++) {
				if (str[i] == 'W') {
					iW = i + 1;
					break;
				}
			}
			for (int i = iR; i >= 0; i--) {
				if (str[i] == 'R') {
					iR = i - 1;
					break;
				}
			}
			if (iW < iR) {
				ans += 1;
			}
			else {
				break;
			}
		}

		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:58: error: expected primary-expression before ')' token
   54 |         if (str.size() != 0 && bR != 0 && bR != c.size();) {
      |                                                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    string C;
    cin >> n >> C;
    
    vector<string> c(n);
    for(int i = 0; i < n; i++){
        c[i] = C[i];
    }
    
    int count = 0;
    for(string a: c){
        if(a == "R"){
            count++;
        }
    }
    int count_;
    for(int i = 0; i < count; i++){
        if(c[i] == "R")
            count_++;
        
    }
    
    
    cout << count - cout_ << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:21: error: 'cout_' was not declared in this scope; did you mean 'count_'?
   28 |     cout << count - cout_ << endl;
      |                     ^~~~~
      |                     count_
Language: C++

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main() {
    string s;
    int N;
    cin >> N >> s;
    int result = 0;
    while (true) {

        // indexの取得
        string reverse = s;
        reverse(reverse.begin(), reverse.end())
        int w = s.find("W");
        int r = N - reverse.find("R") + 1;
        if (w == string::npos || r == string::npos) break; 

        //Rよりも右にWがあるならば入れ替える．
        if (r < w) {
            s[w] = 'R';
            s[r] = 'W';
            result += 1;
            continue; 
        } else {
            break;
        }
    }
    cout << result << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: no match for call to '(std::string {aka std::__cxx11::basic_string<char>}) (std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::iterator)'
   16 |         reverse(reverse.begin(), reverse.end())
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:19:13: error: 'w' was not declared in this scope
   19 |         if (w == string::npos || r == string::npos) break;
      |             ^
a.cc:22:17: error: 'w' was not declared in this scope
   22 |         if (r < w) {
      |                 ^
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<char>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll n;cin >> n;
    stack<ll> q;
    string a;
    cin >> a;
    ll g = 0;ll h == 0;
    if(a.at(0) == 'W'){
        g++;
    }
    if(a.at(n-1) == 'R'){
        h++;
    }
    rep(i,1,n){
        if(a.at(i) == 'W' && g > 0){
            g++;
        }
        if(a.at(n-i-1)){
            h++;
        }
    }
    for(ll i = 0;i < n;i++){
        if(a.at(i) == 'R'){
            q.push(i);
        }
    }
    ll count = 0;
    for(ll i = 0;i < n-1;i++){
        if(g > h && i == 0){
            rep(i,h){
                a.at(n-1-i) = 'W';
                a.at(i) = 'R';
                count++;
            }
            i = h-1;
            continue;
        }
        if(a[i] == 'W' && a[i+1] == 'R'){
            if(!q.empty()){
                int k = q.top();
                a.at(i) = 'R';
                a.at(k) = 'W';
                q.pop();
                count++;
                if(i-1 >= 0){
                    i = i - 2;

                }
            }else{
                a[i] = 'R';
                count++;
            }
        }
    }
    cout << count << endl;
}

Compiler output:
a.cc:23:14: error: macro "rep" passed 3 arguments, but takes just 2
   23 |     rep(i,1,n){
      |              ^
a.cc:4:9: note: macro "rep" defined here
    4 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:16:19: error: expected initializer before '==' token
   16 |     ll g = 0;ll h == 0;
      |                   ^~
a.cc:21:9: error: 'h' was not declared in this scope
   21 |         h++;
      |         ^
a.cc:23:5: error: 'rep' was not declared in this scope
   23 |     rep(i,1,n){
      |     ^~~
a.cc:38:16: error: 'h' was not declared in this scope
   38 |         if(g > h && i == 0){
      |                ^
Language: C++

/*
___ is a raging sadist.
*/
//Destroy all WA at test 2
// Stay cool
// Pass the 4th wall..

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 



ll suf[200005];
ll pre[200005];


int main()
{

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

fastio();

    ll n;
    string s;

    cin>>n>>s;

   

    ll ans=0;

    for(int i=0;i<n-1;i++)
    {
        if (s[i]!=s[i+1])
        {
            ans+=1;
        }
    }

    ans1=(ans+1)/2;

    ll ans2=0;

    for(int i=n-1;i>=1;i--)
    {
        if (s[i]!=s[i-1])
        {
            ans2+=1;
        }
    }

    ans2=(ans2+1)/2;

    cout<<min(ans1,ans2);

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:89:5: error: 'ans1' was not declared in this scope; did you mean 'ans'?
   89 |     ans1=(ans+1)/2;
      |     ^~~~
      |     ans
Language: C++

#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORB(i, m, n) for (int i = m; i >= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << #i << "= " << i << endl
using namespace std;

int main()
{
    int n, firstw = -1, firstr = -1;
    int ans;
    string c;
    cin >> n >> c;
    int count[2] = {};
    bool white = false, red = false;
    REP(i, n)
    {
        if (c[i] == 'R')
        {
            if (!red)
            {
                red = true;
                firstr = i;
            }
            count[0]++;
        }
        else
        {
            count[1]++;
            if (!white)
            {
                white = true;
                firstw = i;
            }
        }
    }
    if (firstw == -1)
    {
        cout << 0 << endl;
        return 0;
    }
    //debug(count[0]);
    //debug(count[1]);
    int a = firstw;       //白の左にある赤
    int b = count[0] - a; //最初の白の右にある赤
    int d = firstr;       //赤の左にある白
    int e = count[1] - d; //最初の赤の右にある白
    int k = min(count[0], count[1]);
    //debug(a);
    //debug(b);
    //debug(d);
    //debug(e);
    if (e == 0)
    {
        ans = min(b, d);
    }
    else if (b == 0)
    {
        ans = 0;
    }
    else
    {
        ans = n - (b + d);

        cout << min(ans, k) << endl;
        return 0;
}


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

                break;
            }
        }
        if(l < r) {
            ans++;
            l++;
            r--;
        }
    }
    cout << ans << endl;
}


Compiler output:
a.cc:1:17: error: expected unqualified-id before 'break'
    1 |                 break;
      |                 ^~~~~
a.cc:2:13: error: expected declaration before '}' token
    2 |             }
      |             ^
a.cc:3:9: error: expected declaration before '}' token
    3 |         }
      |         ^
a.cc:4:9: error: expected unqualified-id before 'if'
    4 |         if(l < r) {
      |         ^~
a.cc:9:5: error: expected declaration before '}' token
    9 |     }
      |     ^
a.cc:10:5: error: 'cout' does not name a type
   10 |     cout << ans << endl;
      |     ^~~~
a.cc:11:1: error: expected declaration before '}' token
   11 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define FOR(i,r,l) for(int i=r;i<=l;i++)
#define FOD(i,r,l) for(int i=r;i>=l;i--)
#define ll long long
#define all(x) (x.begin(),x.end())
#define pb push_back
#define mp make_pair
const double PI = 4*atan((ll)1);
using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n, cnt = 0, ans = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n;i++)
		if (s[i] == 'R') cnt++;
	for (int i = 0; i < cnt;i++)
	{
		if (s[i] == 'W')
		{
			for (int j = i + 1;j < n;j++)
			{
				if (s[j] == 'R')
				{
					swap (s[i], s[j]);
					ans++;
					break;
				}
			}
		}
	}
	cout << ans << '\n';
}




Compiler output:
a.cc:10:21: error: 'atan' was not declared in this scope
   10 | const double PI = 4*atan((ll)1);
      |                     ^~~~
a.cc:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main() {
      | ^~~~
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 <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<char> v(n);
    int wsum = 0, rsum = 0;
    for (int i = 0; i < n; i++){
        cin >> v[i];
        if (v[i] == 'W') wsum++;
        else rsum++;
    }

    int w = 0, r = 0;
    for (int i = 0; i < lim; i++){
        if (v[i] == 'W') w++;
        if (v[n-i-1] == 'R') r++;
    }
    cout << min(min(wsum, rsum), max(w, r)) << "\n";
}


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

#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,i,numw,numr,ans,min,a,startR;
  ans=0;
  numw=0;
  cin >> N >> str;
  char str[N];
  
  
  for(i=0;i<N;++i)
  {
  if(str[i]=='W') numw++;
  }
  numr=N-numw;
  
  if(numr==0 || numw==0) printf("0");
  
  
  else{
  int pointW[numw],pointR[numw],j,cc;
  j=0;
  cc=0;
  while(j<numw)
  {
    if(str[cc]=='W') {pointW[j]=cc;
                      j++;}
   cc++;
  }
  j=0;
  cc=0;
  while(j<numr)
  {
    if(str[cc]=='R') {pointR[j]=cc;
                      j++;}
   cc++;
  }
  
  if(numr<numw) min=numr;
  else min=numw;
  
  a=0;
  startR=0;
  while(str[a]=='R') {a++; startR++;}
  
  startR=a+1;
 
  

  for(j=0;j<min && startR<numr;++j)
  {
  str[pointW[j]]='R';
   str[pointR[numr-1-j]]='W';
    ans++;
  a=0;
    startR=0;
  while(str[a]=='R') {a++; startR++;} 
  }
  
cout << ans << endl;}
  
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: 'str' was not declared in this scope; did you mean 'std'?
    8 |   cin >> N >> str;
      |               ^~~
      |               std
Language: C++

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

int main() {
  int N;string S;cin>>N>>>S;string a="";
  int w=0;int r=0;int k=0;
  for(int i=0;i<N;i++){
    if(S[i]=='W'){
      for(int j=N-1+1;j>i;j--){
        if(S[j]=='R'){
          swap(S[i],S[j]);
          k++;
        }
      }
    }
  }cout<<k<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:26: error: expected primary-expression before '>' token
    6 |   int N;string S;cin>>N>>>S;string a="";
      |                          ^
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.at(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:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |         if (color.at(i) == "R"){
      |             ~~~~~~~~~~~~^~~~~~
Language: C++

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

int main() {
double   p,i,r,s,t,x,y,v,w,q,answer;
	cin >>  p;
	q=p-1;
	r=p;
	s=p/2;
	x=0;
	y=0;
  string str;
  cin >> str;
  for (i = 0; i < q; i++) {
  if(str.at(i)=='W'){
	x=x+1;
	}
  }
  for (i = 1; i < r; i++) {
  if(str.at(i)=='R'){
	y=y+1;
	}
  }
  for (i = 0; i < s; i++) {
  if(str.at(i)=='W'){
	v=v+1;
	}
  }
  for (i = s; i < q; i++) {
  if(str.at(i)=='R'){
	w=w+1;
	}
  }
t = max(v, w);
answer = min(x, y,t);
	cout <<answer<< endl;
}

Compiler output:
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: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = double; _Compare = double]':
a.cc:35:13:   required from here
   35 | answer = min(x, y,t);
      |          ~~~^~~~~~~~
/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 <algorithm>
using namespace std;

int main()
{

   int n,k=0,q=0,b;
    cin>>n;
    string a;
    cin>>a;
    
    
    for(int i=0;i<n;i++){

         
    if(a[i]=='R')
        k++;

    }

    for(int i=0;i<k;i++){
        if(a[i]=='R')
        q++;

    }

    cout << std::min(k-q,k,n-k) << "\n";




    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:21:   required from here
   28 |     cout << std::min(k-q,k,n-k) << "\n";
      |             ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: Java


import java.util.Scanner;

public class Task4 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        String s=in.next();
        int i=0,j=s.length()-1;
        int count=0;
        while(i<j){
            if(s.charAt(i)=='W' && s.charAt(j)=='R'){
                count++;
                i++;
                j--;
            }
            else{
                if(s.charAt(i)=='R' && s.charAt(j)=='W'){
                    i++;j--;
                }else{

                    if(s.charAt(i)=='W'){
                        j--;
                    }else{
                        i++;
                    }


                }
            }
        }
        System.out.println(count);
    }
}


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

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
void solve()
  {
    int n,ct=0;
    cin>>n;
    string s;
    cin>>s;
    for (int i = 0; i < n; ++i)
    {
     if(s[i]=="W"&&s[i+1]=="R")
     {
      ct++;
     }}
 cout<<ct;
  
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Pranab
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {solve();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

   return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:12:13: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |      if(s[i]=="W"&&s[i+1]=="R")
a.cc:12:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |      if(s[i]=="W"&&s[i+1]=="R")
Language: C++

typedef long long ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i, n) for(int i = 0; i < (n); ++i)
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

bool pairCompare(const P &firstElof, const P &secondElof) {
    return firstElof.second < secondElof.second;
}

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int r, l;
    l = 0;
    r = s.length() - 1;
    int ans = 0;
    while(l < r) {
        while(s[l] != 'W' or s[r] != 'R') {
            if(s[l] != 'W')
                l++;
            if(s[r] != 'R')
                r--;
        }
        if(l < r) {
            ans++;
            l++;
            r--;
        }
    }
    cout << ans << endl;
}


Compiler output:
a.cc:2:9: error: 'pair' does not name a type
    2 | typedef pair<int, int> P;
      |         ^~~~
a.cc:26:24: error: 'P' does not name a type; did you mean 'PI'?
   26 | bool pairCompare(const P &firstElof, const P &secondElof) {
      |                        ^
      |                        PI
a.cc:26:44: error: 'P' does not name a type; did you mean 'PI'?
   26 | bool pairCompare(const P &firstElof, const P &secondElof) {
      |                                            ^
      |                                            PI
a.cc: In function 'bool pairCompare(const int&, const int&)':
a.cc:27:22: error: request for member 'second' in 'firstElof', which is of non-class type 'const int'
   27 |     return firstElof.second < secondElof.second;
      |                      ^~~~~~
a.cc:27:42: error: request for member 'second' in 'secondElof', which is of non-class type 'const int'
   27 |     return firstElof.second < secondElof.second;
      |                                          ^~~~~~
a.cc: In function 'int main()':
a.cc:32:5: error: 'string' was not declared in this scope
   32 |     string s;
      |     ^~~~~~
a.cc:33:5: error: 'cin' was not declared in this scope
   33 |     cin >> n;
      |     ^~~
a.cc:34:12: error: 's' was not declared in this scope
   34 |     cin >> s;
      |            ^
a.cc:52:5: error: 'cout' was not declared in this scope
   52 |     cout << ans << endl;
      |     ^~~~
a.cc:52:20: error: 'endl' was not declared in this scope
   52 |     cout << ans << endl;
      |                    ^~~~
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

using namespace std;

int main()
{
  long long n;
  cin>>n;
  string s;
  cin>>s;
  vector<char> vec(n);
  long long cnt_r = 0;
  
  for (int i = 0; i < n; i++)
  {
    vec[i]=s[i];
    if (vec[i] == 'R')
      cnt_r++;
  }
  if(cnt_r==0)cout <<"0"<<endl;
  else{
  int cnt_rr = 0;

    int k=0;
  for (int i = 0; i < n; i++)
  {
    if (vec[i] == 'R'){
      cnt_rr++;
      if(cnt_rr==cnt_r)
      k=i;
    }
  
    
  }
  long long cnt_w = 0;
  for (int i = 0; i < k; i++)
  {
    if (vec[i] == 'W')
      cnt_w++;
  }
   int xx= min(cnt_w,min(cnt_r,));
  
    
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:32: error: expected primary-expression before ')' token
   57 |    int xx= min(cnt_w,min(cnt_r,));
      |                                ^
Language: C++

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

int main()
{

   int n,k=0,q=0;
    cin>>n;
    char a[n];
    for(int i=0;i<n;i++){

            cin>>a[i];
    if(a[i]=='R')
        k++;

    }

    for(int i=0;i<k;i++){
        if(a[i]=='R')
        q++;

    }

    cout << std::min(k-q,k,n-k) << "\n";




    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:25:21:   required from here
   25 |     cout << std::min(k-q,k,n-k) << "\n";
      |             ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~