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

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

int b[2001], w[2001];
int cb[2001][2001], cw[2001][2001], f[2001][2001];

int main(){
  memset(cb, 0, sizeof(cb));
  memset(cw, 0, sizeof(cb));
  memset(f, 0, sizeof(f));
  
  int N;cin>>N;
  for (int i=1;i<=2*N;++i){
    char c;cin>>c;int a;cin>>a;
    if(c=='W') w[a]=i;
    else b[a]=i;
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<i;++j){
      cb[i][0]+=(b[j]>b[i]);
    }

    for (int j=1;j<=N;++j){
      cb[i][j]=cb[i][j-1]+(b[i]<w[j]);
    }
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<i;++j){
      cw[0][i]+=(w[j]>w[i]);
    }

    for (int j=1;j<=N;++j){
      cw[j][i]=cw[j-1][i]+(w[i]<b[j]);
    }
  }

  for (int i=1;i<=N;++i){
    f[0][i]=f[0][i-1]+cw[i];
    f[i][0]=f[i-1][0]+cb[i];
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<=N;++j){
      f[i][j]=min(f[i-1][j]+cb[i][j],f[i][j-1]+cw[i][j]);
    }
  }
  cout << f[N][N] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:22: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   40 |     f[0][i]=f[0][i-1]+cw[i];
      |             ~~~~~~~~~^~~~~~
      |                      |
      |                      int*
a.cc:41:22: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   41 |     f[i][0]=f[i-1][0]+cb[i];
      |             ~~~~~~~~~^~~~~~
      |                      |
      |                      int*
Language: C++

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

int b[2001], w[2001];
int cb[2001], cw[2001], f[2001][2001];

int main(){
  memset(cb, 0, sizeof(cb));
  memset(cw, 0, sizeof(cb));
  memset(f, 0, sizeof(f));
  
  int N;cin>>N;
  for (int i=1;i<=2*N;++i){
    char c;cin>>c;int a;cin>>a;
    if(c=='W') w[a]=i;
    else b[a]=i;
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<i;++j){
      cb[i][0]+=(b[j]>b[i]);
    }

    for (int j=1;j<=N;++j){
      cb[i][j]=cb[i][j-1]+(b[i]<w[j]);
    }
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<i;++j){
      cw[0][i]+=(w[j]>w[i]);
    }

    for (int j=1;j<=N;++j){
      cw[j][i]=cw[j-1][i]+(w[i]<b[j]);
    }
  }

  for (int i=1;i<=N;++i){
    f[0][i]=f[0][i-1]+cw[i];
    f[i][0]=f[i-1][0]+cb[i];
  }

  for (int i=1;i<=N;++i){
    for (int j=1;j<=N;++j){
      f[i][j]=min(f[i-1][j]+cb[i][j],f[i][j-1]+cw[i][j]);
    }
  }
  cout << f[N][N] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: invalid types 'int[int]' for array subscript
   21 |       cb[i][0]+=(b[j]>b[i]);
      |            ^
a.cc:25:12: error: invalid types 'int[int]' for array subscript
   25 |       cb[i][j]=cb[i][j-1]+(b[i]<w[j]);
      |            ^
a.cc:25:21: error: invalid types 'int[int]' for array subscript
   25 |       cb[i][j]=cb[i][j-1]+(b[i]<w[j]);
      |                     ^
a.cc:31:12: error: invalid types 'int[int]' for array subscript
   31 |       cw[0][i]+=(w[j]>w[i]);
      |            ^
a.cc:35:12: error: invalid types 'int[int]' for array subscript
   35 |       cw[j][i]=cw[j-1][i]+(w[i]<b[j]);
      |            ^
a.cc:35:23: error: invalid types 'int[int]' for array subscript
   35 |       cw[j][i]=cw[j-1][i]+(w[i]<b[j]);
      |                       ^
a.cc:46:34: error: invalid types 'int[int]' for array subscript
   46 |       f[i][j]=min(f[i-1][j]+cb[i][j],f[i][j-1]+cw[i][j]);
      |                                  ^
a.cc:46:53: error: invalid types 'int[int]' for array subscript
   46 |       f[i][j]=min(f[i-1][j]+cb[i][j],f[i][j-1]+cw[i][j]);
      |                                                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
int f[2001][2001], w[2001], b[2001];
int cw[2001][2001], cb[2001][2001];

int main(){
  memset(f, 0, sizeof(f));
  memset(cw, 0, sizeof(cw));
  memset(cb, 0, sizeof(cb));
  
  int N;cin>>N;
  for (int i=0;i<2*N;++i){
    char c;cin>>c;
    int a_;cin>>a_;
    if(c=='W') w[a_-1]=i;
    else b[a_-1]=i;
  }


  for (int i=0;i<N;++i){
    for (int j=0;j<i;++j){
      cw[i][0]+=(w[i]<w[j]);
    }
    //j以下の番号で、w[i]よりも右にあるb[k]の数をたす
    for (int j=0;j<N;++j){
      cw[i][j]=cw[i][j-1]+(b[j]>w[i]);
    }
  }

  for (int i=0;i<N;++i){
    for (int j=0;j<i;++i){
      cb[0][i]+=(b[j]>b[i]);
    }
    for (int j=0;j<N;++j){
      cb[j][i]=cb[j-1][i]+(w[j]>b[i]);
    }
  }

  for (int i=0;i<N;++i){
    f[i][0]=f[i-1][0]+cw[i][0]:
  }
  for (int j=0;j<N;++j){
    f[0][j]=f[0][j-1]+cb[0][j];
  }
  for (int i=0;i<N;++i){
    for (int j=0;j<N;++j){
      f[i][j]=min(f[i-1][j]+cw[i][j], f[i][j-1]+cb[i][j]);
    }
  }

  cout << f[N-1][N-1] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:31: error: expected ';' before ':' token
   41 |     f[i][0]=f[i-1][0]+cw[i][0]:
      |                               ^
      |                               ;
Language: C


//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

//#include <vector>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define swap(p,q) r=(p);(p)=(q);(q)=r
#define INF 1000000000000//10^12

int compare_int(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main(void)
{
	//変数の宣言
	int n;
	char color;
	int c[4010];
	int a[4010];
	int b,w;
	int r;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
//	scanf("%d",&n);
	scanf_s("%d",&n);

	for(i=0;i<2*n;i++){
		scanf("\n%c %d",&color,&a[i]);
//		scanf_s("\n");
//		scanf_s("%c",&color);
//		scanf_s("%d",&a[i]);
		if(color=='W'){
			c[i]=0;
		}else{
			c[i]=1;
		}
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	w=1;b=1;
	i=0;
	while(flag==0){
		if(c[i]==0){
			if(a[i]==w){
				w++;
			}else{
				flag=1;
			}
		}else{
			if(a[i]==b){
				b++;
			}else{
				flag=1;
			}
		}
		i++;
	}
	while(w<=n||b<=n){
		flag=0;
		i=w+b-2;
		while(flag==0){
			if((c[i]==0&&a[i]==w)||(c[i]==1&&a[i]==b)){
				flag=1;
			}else{
				i++;
			}
		}

		temp=i;
		for(i=temp;i>w+b-2;i--){
			swap(c[i],c[i-1]);
			swap(a[i],a[i-1]);
			ans++;
		}

		flag=0;
		i=w+b-2;
		while(flag==0&&(w<=n||b<=n)){
			if(c[i]==0){
				if(a[i]==w){
					w++;
				}else{
					flag=1;
				}
			}else{
				if(a[i]==b){
					b++;
				}else{
					flag=1;
				}
			}
			i++;
		}
	
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%d",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:49:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   49 |         scanf_s("%d",&n);
      |         ^~~~~~~
      |         scanf
Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______ 
 * |\  \|\  \  |\  ___ \  |\  ___ \
 * \ \  \/  /|_\ \   __/| \ \   __/|
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

const int mxN = 2010;
const int inf = 10000010;
int BIT[mxN];
void upd(int ind, int val) {
	while (ind < mxN) {
		BIT[ind] += val;
		ind |= ind + 1;
	}
}

int get(int ind) {
	int res = 0;
	while (ind >= 0) {
		res += BIT[ind];
		ind = (ind & (ind + 1)) - 1;
	}
	return res;
}

int W[mxN],B[mxN];
int dp[mxN][mxN];
int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N,x;
	string s;
	cin >> N;
	for(int i = 0;i < (N<<1);i++) {
		cin>>s>>x;
		x--;
		if(s[0] == 'W') {
			W[x] = i;
		} else {
			B[x] = i;
		}
	}
	dp[N][N] = 0;
	for(int i = N;i >= 0;i--) {
		if(i < N) upd(B[i],1);
		for(int j = N - (i == N);j >= 0;j--) {
			dp[i][j] = inf;
			if(j < N) {
				upd(W[j],1);
				dp[i][j] = min(dp[i][j],dp[i][j+1] + get(W[j]-1));
			}
			if(i < N) {
				dp[i][j] = min(dp[i][j],dp[i+1][j] + get(B[i]-1));
			}
//			cerr<<dp[i][j]<<" \n"[j == 0];
		}
		for(int j = 0;j < N;j++) upd(W[j],-1);
	}
	cout<<dp[0][0]<<'\n';
	return 0;
}



Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~
Language: C++

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int FB[2048][2048];
int FW[2048][2048];
int dp[2048][2048];
int balls[4096];
int main() {
	int N; cin >> N;
	for (int i = 0; i < 2 * N; i++) {
		string s; cin >> s;
		int x; cin >> x;
		if (s == "B") balls[i] = -x;
		else balls[i] = x;
	}

	// Build all black
	for (int i = 0; i < 2 * N; i++) {
		if (balls[i] > 0) continue;
		int x = -balls[i];
		for (int j = 0; j < i; j++) if (balls[j] > 0) FB[x][balls[j]] = 1;
		for (int j = N; j >= 0; j--) FB[x][j] += FB[x][j + 1];
	}

	// Build all while
	for (int i = 0; i < 2 * N; i++) {
		if (balls[i] < 0) continue;
		int x = balls[i];
		for (int j = 0; j < i; j++) if (balls[j] < 0) FW[x][-balls[j]] = 1;
		for (int j = N; j >= 0; j--) FW[x][j] += FW[x][j + 1];
	}

	int base = 0;
	for (int i = 0; i < 2 * N; i++) {
		if (balls[i] < 0){
			for (int j = 0; j < i; j++) if (balls[j] < 0 && balls[j] < balls[i])  base += 1;
		}
		else{
			for (int j = 0; j < i; j++) if (balls[j] > 0 && balls[j] > balls[i])  base += 1;
		}
	}

	for (int i = N; i >= 1; i--) for (int j = N; j >= 1; j--) {
		dp[i][j] = min(FB[i][j] + dp[i + 1][j], FW[j][i] + dp[i][j + 1]);
	}
	cout << dp[1][1] + base << endl;
}

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

#include<iostream>
#include<utility>
#include<vector>
#include<climit>

using namespace std;

typedef pair<int, int> Pii;

class BIT {
    public:
    int n;
    int bit[1000001];
    
    BIT(int n){
        this->n = n;
        fill(bit, bit+n, 0);
    }

    void add(int idx, int x){
        for(int i=idx;i<=this->n;i+=i&-i) bit[i] += x;
    }

    //bit[1]からbit[end]までの和 (閉区間)
    int sum(int end){
        int ret = 0;
        for(int i=end;i>=1;i-=i&-i) ret += bit[i];
        return ret;
    }
};


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;

    int mp[2][n+1];
    char c;
    int num;
    for(int i=1;i<=2*n;++i){
        cin >> c >> num;
        mp[(c=='W'?0:1)][num] = i;
    }

    vector< vector<int> > dp(n+1, vector<int>(n+1, INT_MAX));
    dp[0][0] = 0;
    BIT tree = BIT(2*n+1);

    for(int i=0;i<=n;++i){
        if(i) tree.add(mp[0][i], 1);

        for(int j=0;j<=n;++j){
            if(j) tree.add(mp[1][j], 1);
            if(i != n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (i+j-tree.sum(mp[0][i+1])));
            if(j != n) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (i+j-tree.sum(mp[1][j+1])));
        }

        for(int j=1;j<=n;++j) tree.add(mp[1][j], -1);
    }

    cout << dp[n][n] << endl;
}

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

#include<iostream>
#include<utility>
#include<vector>

using namespace std;

typedef pair<int, int> Pii;

class BIT {
    public:
    int n;
    int bit[1000001];
    
    BIT(int n){
        this->n = n;
        fill(bit, bit+n, 0);
    }

    void add(int idx, int x){
        for(int i=idx;i<=this->n;i+=i&-i) bit[i] += x;
    }

    //bit[1]からbit[end]までの和 (閉区間)
    int sum(int end){
        int ret = 0;
        for(int i=end;i>=1;i-=i&-i) ret += bit[i];
        return ret;
    }
};


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;

    int mp[2][n+1];
    char c;
    int num;
    for(int i=1;i<=2*n;++i){
        cin >> c >> num;
        mp[(c=='W'?0:1)][num] = i;
    }

    vector< vector<int> > dp(n+1, vector<int>(n+1, INT_MAX));
    dp[0][0] = 0;
    BIT tree = BIT(2*n+1);

    for(int i=0;i<=n;++i){
        if(i) tree.add(mp[0][i], 1);

        for(int j=0;j<=n;++j){
            if(j) tree.add(mp[1][j], 1);
            if(i != n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (i+j-tree.sum(mp[0][i+1])));
            if(j != n) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (i+j-tree.sum(mp[1][j+1])));
        }

        for(int j=1;j<=n;++j) tree.add(mp[1][j], -1);
    }

    cout << dp[n][n] << endl;
}

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

#include<iostream>
using namespace std;
long long costb[5000][5000],costw[5000][5000],N;
long long memo[5000][5000],barr[2500],warr[2500];

int main(){
	ios::sync_with_stdio(0);
	cin>>N;
	for(long long i=0;i<2500;++i){
		barr[i]=-1;
		warr[i]=-1;
	}
	for(long long i=0;i<2*N;++i){
		char c;
		long long a;
		cin>>c>>a;
		if(c=='W')warr[a]= i;
		else barr[a]=i;
	}
	for(long long i=0;i<=2*N;++i){
		costb[i][N]=0;
		for(long long j=N-1;j>=0;--j){
			costb[i][j]=costb[i][j+1];
			costb[i][j]+=(barr[j+1]<i&&barr[j+1]>=0);
		}
	}
	for(long long i=0;i<=2*N;++i){
		costw[i][N]=0;
		for(long long j=N-1;j>=0;--j){
			costw[i][j]=costw[i][j+1];
			costw[i][j]+=(warr[j+1]<i&&warr[j+1]>=0);
		}
	}
	for(long long i=0;i<=2*N;++i){
		for(long long j=0;j<=2*N;++j){
			memo[i][j]=INT_MAX;
		}
	}
	memo[0][0]=0;
	for(long long i=0;i<=N;++i){
		for(long long j=0;j<=N;++j){
			if(i!=N){
				int x=costb[barr[i+1]][i+1];
				x+=costw[barr[i+1]][j];
				memo[i+1][j]=min(memo[i+1][j],memo[i][j]+x);
			}
			if(j!=N){
				int x=costw[warr[j+1]][j+1];
				x+=costb[warr[j+1]][i];
				memo[i][j+1]=min(memo[i][j+1],memo[i][j]+x);
			}
		}
	}
	cout<<memo[N][N]<<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:36: error: 'INT_MAX' was not declared in this scope
   36 |                         memo[i][j]=INT_MAX;
      |                                    ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

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

const int maxn = 5050, INF = 1e9;
int pos[2][maxn], BIT[maxn], dp[maxn][maxn], n;

void Update(int idx, int val)
{
    for(int i = idx; i < maxn; i += i & -i)
        BIT[i] += val;
}

int Query(int idx)
{
    int ret = 0;
    for(int i = idx; i > 0; i -= i & -i)
        ret += BIT[i];
    return ret;
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= 2 * n; i++) {
        char c;
        int a;
        scanf(" %c %d", &c, &a);
        pos[c == 'B'][a] = i;
    }

    fill((int *) dp, (int *) dp + maxn * maxn, INF);

    dp[0][0] = 0;
    for(int i = 0; i <= n; i ++) {
        for(int j = 0; j <= n; j ++) {
            if(i + 1 <= n) {
                int add = h - Query(pos[0][i + 1]);
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + add);
            }
            if(j + 1 <= n) {
                int add = pos[1][j + 1] - 1 - Query(pos[1][j + 1]);
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + add);
                Update(pos[1][j + 1], 1);
            }
        }
        for(int j = 1; j <= n; j ++)
            Update(pos[1][j], -1);
        if(i + 1 <= n)
            Update(pos[0][i + 1], 1);
    }

    printf("%d\n", dp[n][n]);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:27: error: 'h' was not declared in this scope
   37 |                 int add = h - Query(pos[0][i + 1]);
      |                           ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

const int INF = 1e3;
int dp[2100*2][2100];

struct BIT {
	vector<int> dat;
	int size;
	BIT(int n) {
		this->init(n);
	}
	init(int n) {
		dat.resize(n+1);
		size = n;
		rep(i,dat.size()) dat[i] = 0;
	}
	int sum(int i) {
		i++;
		int s = 0;
		while(i > 0) {
			s += dat[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i) {
		i++;
		while(i < dat.size()) {
			dat[i]++;
			i += i & -i;
		}
	}
};

int main() {
	int N;
	cin >> N;
	vector<int> w(N), b(N);
	vector<BIT> BITs;
	rep(i,2100) BITs.push_back(BIT(N*2+10));
	rep(i,2*N) {
		string c;
		int a;
		cin >> c >> a;
		a--;
		if(c == "B") {
			b[a] = i;
		}
		else {
			w[a] = i;
		}
	}
	rep(i,2100*2)
		rep(j,2100)
			dp[i][j] = INF;
	dp[0][0] = 0;

	FOR(i,1,2*N+1) {
		rep(j, min<ll>(i,N)+1) {
			int ww, bb;
			ww = bb = INF;

			if(0 < i-j && i-j <= min<ll>(i,N))
				ww = i-1 - BITs[j].sum(w[i-j -1]) + dp[i-1][j];
			if(j)
				bb = i-1 - BITs[j-1].sum(b[j -1]) + dp[i-1][j-1];

			dp[i][j] = min(min(ww, bb), INF);

		}
		rep(j, N+1) {
			if(j && j <= N && i <= j) {
				BITs[j].add(b[min(i,j)-1]);
			}
			else if(0 < i-j && i-j <= N) {
				BITs[j].add(w[i-j -1]);
			}
		}
	}
	/*
	rep(i,20) {
		rep(j,10) {
			printf("%5d", i-j <= N && j <= N ? dp[i][j] : INF);
		}
		puts("");
	}
	// */

	cout << dp[2*N][N] << endl;
	return 0;
}


Compiler output:
a.cc:41:9: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive]
   41 |         init(int n) {
      |         ^~~~
a.cc: In member function 'int BIT::init(int)':
a.cc:45:9: warning: no return statement in function returning non-void [-Wreturn-type]
   45 |         }
      |         ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	int a[2020]={},c[2020]={};
	cin>>n;
	FOR(i,0,2n){
		cin>>a[i];
		char tmpccc;
		cin>>tmpccc;
		if(tmp=='W')c[i]=1;
	}
	int c=0;
	int mem[2020]={};
	int b[1010]={};
	int w[1010]={};
	int bi=0,wi=0;
	int mnb=mod,mxw=0;
	FOR(i,0,2n){
		if(c[i]==0){
			mnb=min(mnb,i);
			b[bi++]=a[i];
		}else {
			mxw=max(mxw,i);
			w[wi++]=a[i];
			
		}
	}
	FOR(i,0,n){
		FOR(j,i+1,n){
			if(b[i]>b[j]){
				swap(b[i],b[j]);
				c++;
			}
		}
	}
	FOR(i,0,n){
		FOR(j,i+1,n){
			if(w[i]>w[j]){
				swap(w[i],w[j]);
				c++;
			}
		}
	}
	c+=mxw-mnb-1;
	cout<<c<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: unable to find numeric literal operator 'operator""n'
   42 |         FOR(i,0,2n){
      |                 ^~
a.cc:22:37: note: in definition of macro 'FOR'
   22 | #define FOR(i,b,e) for(int i=(b);i<(e);++i)
      |                                     ^
a.cc:46:20: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   46 |                 if(tmp=='W')c[i]=1;
      |                    ^~~
      |                    tm
a.cc:48:13: error: conflicting declaration 'int c'
   48 |         int c=0;
      |             ^
a.cc:40:24: note: previous declaration as 'int c [2020]'
   40 |         int a[2020]={},c[2020]={};
      |                        ^
a.cc:54:17: error: unable to find numeric literal operator 'operator""n'
   54 |         FOR(i,0,2n){
      |                 ^~
a.cc:22:37: note: in definition of macro 'FOR'
   22 | #define FOR(i,b,e) for(int i=(b);i<(e);++i)
      |                                     ^
a.cc:68:33: error: lvalue required as increment operand
   68 |                                 c++;
      |                                 ^
a.cc:76:33: error: lvalue required as increment operand
   76 |                                 c++;
      |                                 ^
a.cc:80:10: error: incompatible types in assignment of 'int' to 'int [2020]'
   80 |         c+=mxw-mnb-1;
      |         ~^~~~~~~~~~~
Language: C++

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

defin int long long;
int n;
vector<int> a;

int func(int l1, int r1, int l2, int r2, vector<int> v){
//	cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
	int s1 = r1 - l1 + 1;
	int s2 = r2 - l2 + 1;
	if(s1 == 1 && s2 == 1) return 0;
	int res = 1e9;
	int cost = 0;
	int left = 0;
	int right = v.size()-1;
	if(s2 >= 1){
		vector<int> w;
		int p = 0, q = 0;
		for(int i=0; i<v.size(); ++i){
			if(v[i] == l2) p = i;
			if(v[i] == r2) q = i;
		}
		cost = p - left + right - q;
		if(q < p) --cost;
		for(int i=0; i<v.size(); ++i)
			if(i != p && i != q)
				w.push_back(v[i]);
		res = min(res, cost + func(l1, r1, l2+1, r2-1, w));
	}
	if(s1 >= 1){
		vector<int> w;
		int p = 0, q = 0;
		for(int i=0; i<v.size(); ++i){
			if(v[i] == l1) p = i;
			if(v[i] == r1) q = i;
		}
		cost = p - left + right - q;
		if(q < p) --cost;
		for(int i=0; i<v.size(); ++i)
			if(i != p && i != q)
				w.push_back(v[i]);
		res = min(res, cost + func(l1+1, r1-1, l2, r2, w));
	}
	if(s1 >= 1 && s2 >= 1){
		vector<int> w;
		int p = 0, q = 0;
		for(int i=0; i<v.size(); ++i){
			if(v[i] == l1) p = i;
			if(v[i] == r2) q = i;
		}
		cost = p - left + right - q;
		if(q < p) --cost;
		for(int i=0; i<v.size(); ++i)
			if(i != p && i != q)
				w.push_back(v[i]);
		res = min(res, cost + func(l1+1, r1, l2, r2-1, w));
		w.clear();
		p = 0, q = 0;
		for(int i=0; i<v.size(); ++i){
			if(v[i] == l2) p = i;
			if(v[i] == r1) q = i;
		}
		cost = p - left + right - q;
		if(q < p) --cost;
		for(int i=0; i<v.size(); ++i)
			if(i != p && i != q)
				w.push_back(v[i]);
		res = min(res, cost + func(l1, r1-1, l2+1, r2, w));
	}
	return res;
}

int main(){
	cin >> n;
	for(int i=0; i<2*n; ++i){
		char c;
		int t;
		cin >> c >> t;
		if(c == 'W') a.push_back(t);
		else a.push_back(t + n);
	}
/*	for(int i=0; i<2*n; ++i)
		cout << a[i];
	cout << endl;
*/	cout << func(1, n, n+1, 2*n, a) << endl;
}

Compiler output:
a.cc:4:1: error: 'defin' does not name a type
    4 | defin int long long;
      | ^~~~~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+9;
vector<int>y[maxn];
int fa[maxn],col[maxn],ban[maxn],siz[maxn],rt,du[maxn];//siz ÓÐ¼¸¸ö°×É«µÄµã 
void dfs(int x){
	if(!col[x])siz[x]=1;
	for(auto y:y[x]){
		if(y==fa[x])continue;
		fa[y]=x;dfs(y);
		siz[x]+=siz[y];
		if(!siz[y])ban[y]=1,--du[x];
	}
}
int val[maxn],fa[maxn],ans;
void dp(int x){
	int siz=du[x];
	if(!col[x]&&(siz&1)||(col[x]&&!(siz&1)))val[x]=0;
	else val[x]=2,++ans;
	for(auto y:y[x]){
		if(y==fa[x]||ban[y])continue;
		dp(y);ans+=2;
	}
}
char s[maxn];
int n,maxx,pos,dist[maxn];
void dfs2(int x){
	dist[x]+=val[x];
	if(dist[x]>maxx)maxx=dist[x],pos=x;
	for(auto y:y[x]){
		if(y==fa[x]||ban[y])continue;
		dist[y]=dist[x];
		dfs2(y);
	}
}
void dfs3(int x,int fa){
	dist[x]+=val[x];
	if(dist[x]>maxx)maxx=dist[x],pos=x;
	for(auto y:y[x]){
		if(y==fa||ban[y])continue;
		dist[y]=dist[x];
		dfs3(y,x);
	}
}
signed main(){
	cin>>n;
	if(!n)cout<<0,exit(0);
	for(int i=1,x,y;i<n;++i)cin>>x>>y,y[x].push_back(y),y[y].push_back(x),++du[x],++du[y];
	scanf("%s",s+1);
	for(int i=1;i<=n;++i)if(s[i]=='B')col[i]=1;
	for(int i=1;i<=n;++i)if(!col[i]){rt=i;break;}
	if(!rt)cout<<rt,exit(0);
	dfs(rt);
	dp(rt);
	dfs2(rt);
	maxx=0;
	memset(dist,0,sizeof(dist));
	dfs3(pos,0);
	cout<<ans-maxx;
}	

Compiler output:
a.cc:16:15: error: redefinition of 'long long int fa [100009]'
   16 | int val[maxn],fa[maxn],ans;
      |               ^~
a.cc:6:5: note: 'long long int fa [100009]' previously declared here
    6 | int fa[maxn],col[maxn],ban[maxn],siz[maxn],rt,du[maxn];//siz ÓÐ¼¸¸ö°×É«µÄµã
      |     ^~
a.cc: In function 'int main()':
a.cc:49:44: error: invalid types 'long long int[long long int]' for array subscript
   49 |         for(int i=1,x,y;i<n;++i)cin>>x>>y,y[x].push_back(y),y[y].push_back(x),++du[x],++du[y];
      |                                            ^
a.cc:49:62: error: invalid types 'long long int[long long int]' for array subscript
   49 |         for(int i=1,x,y;i<n;++i)cin>>x>>y,y[x].push_back(y),y[y].push_back(x),++du[x],++du[y];
      |                                                              ^
Language: C++

#include<bits/stdc++.h>
#define MAXN 200005
#define LL long long
#define P int(1e4+7)
using namespace std;

int N,N1;
vector<int> adj[MAXN];
int deg[MAXN], c[MAXN];
int dp[MAXN];
bool vis[MAXN];
int ans1, ans2;

void dfs(int u){
	//cout<<"dfs: "<<u<<endl;
	
	vis[u] = 1;
	dp[u] = (c[u]==1) - (c[u]==0);
	
	int v, m1 = -1e9;
	for(int k=0;k<adj[u].size();k++){
		v = adj[u][k];
		if(vis[v]) continue;
		
		
		dfs(v);
		ans2 = max(ans2, m1 + dp[u] + 1 + dp[v]);
		m1 = max(m1, 1 + dp[v]);
	}
	
	if(m1 != -1e9) dp[u] += m1;
	
	ans2 = max(ans2, dp[u]);//cout<<"dp[u]: "<<u<<" "<<dp[u]<<" "<<ans2<<endl;
	return;
}

string s;

void init(){
	cin>>N;
	for(int i=1;i<=N;i++) adj[i].clear();
	
	memset(deg,0,sizeof(deg));
	memset(c,0,sizeof(c));
	memset(vis,0,sizeof(vis));
	memset(dp,0,sizeof(dp));
	ans1 = ans2 = 0;
	
	int u,v;
	for(int i=1;i<N;i++){
		cin>>u>>v;
		
		adj[u].push_back(v);
		adj[v].push_back(u);
		++deg[u]; ++deg[v];
	}
	
	cin>>s;
	s = "$" + s;
	
	N1 = N;
	queue<int> q;
	for(int i=1;i<=N;i++){
		if(s[i]=='1' && deg[i]==1){
			q.push(i);
		}
	}
	
	//
	while(!q.empty()){
		u = q.front(); q.pop();
		--deg[u]; 
		vis[u] = 1; --N1;
		
		
		for(int k=0;k<adj[u].size();k++){
			v = adj[u][k];
			if(vis[v]) continue;
			--deg[v];
			if(deg[v]==1 && s[v]=='1'){
				q.push(v);
			}
		}
	}
}

void work(){
	ans1 = 2*(N1-1);
	for(int i=1;i<=N;i++){
		if(vis[i]) continue;
		
		c[i] = (deg[i] + (s[i]=='1') + 1) % 2;
		ans1 += c[i];
	}
	 
	if(N1==1){
		cout<<ans1<<endl;
		return; + 
	}
	
	//ans2
	for(int i=1;i<=N;i++){
		if(!vis[i]){
			dfs(i);
			break;
		}
	} 
	//cout<<"ans2: "<<ans2<<endl;
	if(ans2 > 0) ans2 = ans1 - ans2 - 1;
	else ans2 = ans1;
	
	cout<<max(0, min(ans1, ans2))<<endl;
}

int main(){
	ios::sync_with_stdio(0);
	//freopen("20.in","r",stdin);
	//freopen("20.out","w",stdout);
	

	

	
		init();
		work();


	return 0;
}

Compiler output:
a.cc: In function 'void work()':
a.cc:99:9: error: expected primary-expression before '}' token
   99 |         }
      |         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
int to[N],next[N],first[N],ecnt;
int n,rt=1,ans,tot;
int c[N],ext[N],nes[N],dp[N];
char temps[N];
void addEdge(int a,int b){
	next[++ecnt]=first[a],first[a]=ecnt,to[ecnt]=b;
}
void readit()
{ 
	scanf("%d",&n);
	for(int a,b,i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		addEdge(a,b);addEdge(b,a);
	}
	scanf("%s",temps+1);
	for(int i=1;i<=n;i++)
		c[i]=temps[i]=='W'?0:1;
}	
void dfs(int k,int f){
	nes[k]=1-c[k];
	int pcnt=0;
	for(int i=first[k];i;i=next[i],pcnt++){
		if(to[i]==f) continue;
		dfs(to[i],k);
		if(ext[to[i]]) ext[k]=1,ans+=2,nes[k]^=1;
	}
	if(f) nes[k]^=1;
	if(!c[k]) ext[k]=1;
	if(ext[k])  	ans+=nes[k];
}
void findp(int k,int f){
	int mx1=0,mx2=0;
	for(int i=first[k];i;i=next[i]){
		if(to[i]==f||!ext[to[i]]) continue;
		findp(to[i],k);
		if(dp[to[i]]>mx1) mx1=dp[to[i]];
		else if(dp[to[i]]>mx2) mx2=dp[to[i]];
	}
	dp[k]=1+(nes[k]?1:-1)+mx1;
	tot=max(tot,dp[k]+mx2);
}
int main()
{
	readit();
	dfs(rt,0);
	findp(rt,0);
	printf("%d",ans-tot);
	return 0;
}
/*
5
1 2
2 3
2 4
4 5
WBBWW
*/


Compiler output:
a.cc: In function 'void addEdge(int, int)':
a.cc:9:9: error: reference to 'next' is ambiguous
    9 |         next[++ecnt]=first[a],first[a]=ecnt,to[ecnt]=b;
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:11: note:                 'int next [400010]'
    4 | int to[N],next[N],first[N],ecnt;
      |           ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:25:32: error: reference to 'next' is ambiguous
   25 |         for(int i=first[k];i;i=next[i],pcnt++){
      |                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:11: note:                 'int next [400010]'
    4 | int to[N],next[N],first[N],ecnt;
      |           ^~~~
a.cc: In function 'void findp(int, int)':
a.cc:36:32: error: reference to 'next' is ambiguous
   36 |         for(int i=first[k];i;i=next[i]){
      |                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:11: note:                 'int next [400010]'
    4 | int to[N],next[N],first[N],ecnt;
      |           ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
int to[N],next[N],first[N],ecnt;
int n,rt=1,ans,tot;
int c[N],ext[N],nes[N],dp[N];
char temps[N];
void addEdge(int a,int b){
	next[++ecnt]=first[a],first[a]=ecnt,to[ecnt]=b;
}
void readit()
{ 
	scanf("%d",&n);
	for(int a,b,i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		addEdge(a,b);addEdge(b,a);
	}
	scanf("%s",temps+1);
	for(int i=1;i<=n;i++)
		c[i]=temps[i]=='W'?0:1;
}	
void dfs(int k,int f){
	nes[k]=1-c[k];
	int pcnt=0;
	for(int i=first[k];i;i=next[i],pcnt++){
		if(to[i]==f) continue;
		dfs(to[i],k);
		if(ext[to[i]]) ext[k]=1,ans+=2,nes[k]^=1;
	}
	if(f) nes[k]^=1;
	if(!c[k]) ext[k]=1;
	if(ext[k])  	ans+=nes[k];
}
void findp(int k,int f){
	int mx1=0,mx2=0;
	for(int i=first[k];i;i=next[i]){
		if(to[i]==f||!ext[to[i]]) continue;
		findp(to[i],k);
		if(dp[to[i]]>mx1) mx1=dp[to[i]];
		else if(dp[to[i]]>mx2) mx2=dp[to[i]];
	}
	dp[k]=1+(nes[k]?1:-1)+mx1;
	tot=max(tot,dp[k]+mx2);
}
int main()
{
	readit();
	dfs(rt,0);
	findp(rt,0);
	printf("%d",ans-tot);
	return 0;
}

Compiler output:
a.cc: In function 'void addEdge(int, int)':
a.cc:9:9: error: reference to 'next' is ambiguous
    9 |         next[++ecnt]=first[a],first[a]=ecnt,to[ecnt]=b;
      |         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:11: note:                 'int next [400010]'
    4 | int to[N],next[N],first[N],ecnt;
      |           ^~~~
a.cc: In function 'void dfs(int, int)':
a.cc:25:32: error: reference to 'next' is ambiguous
   25 |         for(int i=first[k];i;i=next[i],pcnt++){
      |                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:11: note:                 'int next [400010]'
    4 | int to[N],next[N],first[N],ecnt;
      |           ^~~~
a.cc: In function 'void findp(int, int)':
a.cc:36:32: error: reference to 'next' is ambiguous
   36 |         for(int i=first[k];i;i=next[i]){
      |                                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:4:11: note:                 'int next [400010]'
    4 | int to[N],next[N],first[N],ecnt;
      |           ^~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int inf = 1e9;
const int maxN = 1e5 + 5;
int dp[maxN][2][2], ans = inf, f[maxN];
bool ok[maxN];
int N, l[maxN], e;
char c[maxN];
struct edge{
	int v, fa;
}G[maxN << 1];

void add(int u, int v) {
	G[e].v = v; G[e].fa = l[u]; l[u] = e++;
}

void dfs(int u, int p) {
	ok[u] = (c[u] == 'B');
	int siz = 0; int t1 = 0; int t2 = inf;
	for(int i = l[u]; i != -1; i = G[i].fa) {
		int v = G[i].v;
		if(v == p) continue; 
		dfs(v, u); 
		if(ok[v]) continue;
		ok[u] = 0;
		t1 += dp[v][1][0] + 2;
		t2 = min(t2, dp[v][0][0] - 1 - dp[v][1][0]); 
	}
	f[u] = t2;
	if(t2 == inf) {
		dp[u][0][1] = dp[u][1][1] = (c[u] == 'W'); 
		dp[u][0][0] = dp[u][1][0] = (c[u] != 'W');
	} else {
		if((siz + (c[u] == 'W')) & 1 == 0) {
			dp[u][1][1] = t1; dp[u][1][0] = t1 + 1;
			dp[u][0][0] = t1 + t2; dp[u][0][1] = t1 + t2 + 1;
		} else {
			dp[u][1][1] = t1 + 1; dp[u][1][0] = t1;
			dp[u][0][0] = t1 + t2 + 1; dp[u][0][1] = t1 + t2;
		}
	}
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
vi g[125252];
char buf[125252];
int col[125252];
int wcnt[125252];
int root;

int dp[125252][4];

void dfs1(int p,int bef){
  wcnt[p] = col[p];
  for(int to:g[p])if(to!=bef){
    dfs1(to,p);
    wcnt[p] += wcnt[to];
  }
}

void dfs2(int p,int bef){
  int childs = 0;
  int d1sum = 0;
  int d12max = -25252125;
  int d10max = -25252125;
  vector<pii> d10s, d12s;
  for(int to : g[p])if(to!=bef && wcnt[to]>0){
    childs++;
    dfs2(to,p);
    d1sum += dp[to][1];
    CHMAX(d12max, dp[to][1] - dp[to][2]);
    d12s.push_back(pii(dp[to][1] - dp[to][2], to));
    CHMAX(d10max, dp[to][1] - dp[to][0]);
    d10s.push_back(pii(dp[to][1] - dp[to][0], to));
  }
  if(childs == 0){
    d10max = 0;
    d12max = 0;
  }
  // 0
  dp[p][0] = d1sum - d10max + max(2*childs-1, 0) + (col[p]+max(childs-1,0)+1)%2;
  // 1
  dp[p][1] = d1sum + 2*childs + (col[p]+childs+1)%2;
  // 2
  dp[p][2] = d1sum - d12max + max(2*childs-1, 0) + (col[p]+childs)%2;
  // 2'
  CHMIN(dp[p][2], d1sum + 2*childs + (col[p]+childs)%2);
  // 3
  dp[p][3] = dp[p][2];
  // 3'
  sort(ALL(d12s));
  reverse(ALL(d12s));
  sort(ALL(d10s));
  reverse(ALL(d10s));
  int k = min(3,(int)d12s.size());
  REP(i,k)REP(j,k)if(d12s[i].second != d10s[j].second){
    CHMIN(dp[p][3], d1sum - d12s[i].first - d10s[j].first + 2*(childs-1) + (col[p]+childs-1)%2);
  }
  // 3''
  CHMIN(dp[p][3], d1sum - d10max + max(2*childs-1, 0) + (col[p]+max(childs-1,0))%2);

  // printf(">>> %d %d %d %d\n",childs,d1sum,d12max,d10max);
  // printf("%d: %d, %d, %d\n", p,dp[p][0],dp[p][1],dp[p][2]);
}

int main(){
  scanf("%d",&n);
  REP(i,n-1){
    int x,y;
    scanf("%d%d",&x,&y);
    --x;--y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  scanf("%s",buf);
  REP(i,n)col[i] = buf[i]=='W'?1:0;
  vi roots;
  REP(i,n)if(col[i]==1){
    roots.push_back(i);
  }
  if(roots.size()==1){
    puts("0");
    return 0;
  }
  int ans = 25252125;
  random_shuffle(ALL(roots));
  REP(_,min(15,(int)roots.size())){
    root = roots[_];
    dfs1(root, -1);
    dfs2(root, -1);
    CHMIN(ans,dp[root][3]);
  }
  printf("%d\n", ans);
  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<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5;
vector<int> g[N];
string c;

unordered_map<int, int> dp[N][4];
unordered_map<int, bool> allB[N];

bool ab(int i, int p = -1) {
  if(allB[i].count(p)) return allB[i][p];
  allB[i][p] = c[i] == 'B';
  for(int j : g[i]) if(j != p) {
    allB[i][p] &= ab(j, i);
  }
  return allB[i][p];
}

void dfs(int i, int p = -1) {
  if(dp[i][0].count(p)) return;
  int ch = 0;
  int a = 0;
  int b = 1e9;
  for(int j : g[i]) if(j != p) {
    if(ab(j, i)) continue;
    ch ^= 1;
    dfs(j, i);
    int aa = dp[j][((c[j] != 'B')<<1) + 1][i] + 2;
    a += aa;
    b = min(b, - aa + dp[j][((c[j] != 'B')<<1) + 0][i] + 1);
  }
  dp[i][0b11][p] = a + ch;
  dp[i][0b01][p] = a + !ch;
  dp[i][0b10][p] = min(a + ch, a + b + !ch);
  dp[i][0b00][p] = min(a + !ch, a + b + ch);
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  for(int i = 0; i < n - 1; i++) {
    int x, y; cin >> x >> y; x--; y--;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  cin >> c;
  int ans = 1e9;
  for(int i = 0; i < n; i++) {
    dfs(i);
    ans = min(ans, dp[i][c[i] == 'B'][0][-1]);
    ans = min(ans, dp[i][c[i] != 'B'][0][-1] + 1);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:41: error: invalid types 'std::unordered_map<int, int>::mapped_type {aka int}[int]' for array subscript
   52 |     ans = min(ans, dp[i][c[i] == 'B'][0][-1]);
      |                                         ^
a.cc:53:41: error: invalid types 'std::unordered_map<int, int>::mapped_type {aka int}[int]' for array subscript
   53 |     ans = min(ans, dp[i][c[i] != 'B'][0][-1] + 1);
      |                                         ^
Language: C++

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll a, b;
    cin >> a >> b;

    if(a =< b){
        cout << a << endl;
    }else{
        cout << a - 1 << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:11: error: expected primary-expression before '<' token
   29 |     if(a =< b){
      |           ^
Language: C++

#include <iostream>
#include <vector>
//#define rep(i,n) for(int i = 0; i , (n); ++i)
using ll = long long;
using namespace std;

int sum(int n) {
    if (n == 0) {
        return 0;
    }

    int s = sum(n - 1);
    return s + n;
}
void main() {
    int N, W;
        cin >> N >> W;
        vector<vector<char>>A(N, vector<char>(W));
        
        for (int i = 0;i < N;i++) {
            for (int j = 0;j < W;i++) {
                cin >> A.at(i).at(j);
            }
        }
        bool hantei = true;
        for (int i = 0;i < N;i++) {
            for (int j = 0;j < W;j++){
                    if (A.at(i).at(j) == '#'&&A.at(i + 1).at(j) == '.' && A.at(i - 1).at(j) == '.' &&
                        A.at(i).at(j + 1) == '.' && A.at(i).at(j - 1) == '.') {
                         hantei=false;
                             break;
                    }
            //}
            //if (hantei == false) {
                //break;
            //}
        }
        if (hantei) {
            cout << "Yes";
        }
        else {
            cout << "No";
        }
}


Compiler output:
a.cc:15:1: error: '::main' must return 'int'
   15 | void main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:44:2: error: expected '}' at end of input
   44 | }
      |  ^
a.cc:15:13: note: to match this '{'
   15 | void main() {
      |             ^
Language: C++

#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
	
	int a, b;
    cin >> a >> b;
    if (a <= b) {
    	cout << a << endl;    
  	}
  	else {
    	cout << a - 1 << endl;
}
/*
*/

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

#include <iostream>
using namespace std;
int main()
{

   int a,b;
   cin>>a>>b;
   if(a>b)
    {cout<<a-1;}
   else{cout<<x;}
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: 'x' was not declared in this scope
   10 |    else{cout<<x;}
      |               ^
Language: C++

int main() {

    int a , b ;

    int t = 0 ;

    cin >> a >> b ;

    if (b >= a) cout << a ;

    if (b < a) cout << a-1 ;

    return 0 ;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> a >> b ;
      |     ^~~
a.cc:9:17: error: 'cout' was not declared in this scope
    9 |     if (b >= a) cout << a ;
      |                 ^~~~
a.cc:11:16: error: 'cout' was not declared in this scope
   11 |     if (b < a) cout << a-1 ;
      |                ^~~~
Language: C++

#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=b){
		printf("%d\n",a);
	}
	else{
		printf("%d\n"a-1);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: unable to find string literal operator 'operator""a' with 'const char [4]', 'long unsigned int' arguments
   10 |                 printf("%d\n"a-1);
      |                        ^~~~~~~
Language: C++

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

int main()
{
    int a, b;
    cin >> a >> b;

    int count = 0;
    rep(i, 1, a + 1)
    {
        rep(j, 1, 32)
        {
            if (i == a && j == b)
            {
                break;
            }

            if (i == j)
            {
                ++count;
            }
        }
        if (i == a && j == b)
        {
            break;
        }
    }

    cout << count << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:23: error: 'j' was not declared in this scope
   25 |         if (i == a && j == b)
      |                       ^
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b) {
            System.out.println(a - 1);
        }else {
            System.out.println(a);
    }
}


Compiler output:
Main.java:14: error: reached end of file while parsing
}
 ^
1 error
Language: C++

#include <iostream>

using namespace std;

int main()
{
    int a;
    int b;
    int ans = 1;
    cin >> a >> b;
    for (int i = 1 ; i <= a ; i++){
        if (a >= i && b >= i){
            if (a = i){
                if (b > a){
                    ans++;
                }
            }else{
                ans++
            }
        }
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:22: error: expected ';' before '}' token
   18 |                 ans++
      |                      ^
      |                      ;
   19 |             }
      |             ~
Language: C++

#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int result = a-1;
    if (b >= a) {
        result++;
    }
    cout << result << endl;2 1
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:29: error: expected ';' before numeric constant
   10 |     cout << result << endl;2 1
      |                             ^~
      |                             ;
Language: Java

import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a >= b ? a : a-1)
	}
}


Compiler output:
Main.java:8: error: ';' expected
		System.out.println(a >= b ? a : a-1)
		                                    ^
1 error
Language: C++

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

signed main() {
	int m, d;
	cin >> m >> d;
	
	if(d >= m) cout<< m << endl;
	else cout << m-1 << ebdl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:29: error: 'ebdl' was not declared in this scope
   11 |         else cout << m-1 << ebdl;
      |                             ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
	int x,a;
	cin>>x>>a;
	cout<<a-1+(b>=a);
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:20: error: 'b' was not declared in this scope
    8 |         cout<<a-1+(b>=a);
      |                    ^
Language: C++

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

int main() {
   int a, b;
   cin >> a >> b;

   if (a <= b) {
       cout << a << endl:
   } else {
       cout << a - 1 << endl;
   }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: expected ';' before ':' token
   12 |        cout << a << endl:
      |                         ^
      |                         ;