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

#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
typedef long long ll;
signed main(){
  string s;
  cin>>s;
  ll s_size=sizeof(s);
  ll ans=0;
  bool flag=true;
  while(flag){
    flag=false;
    rep(i,1,s_size){
      if(s[i]=="W"&&s[i-1]=="B"){
        swap(s[i],s[i-1]);
        ans++;
        flag=true;
      }
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |       if(s[i]=="W"&&s[i-1]=="B"){
a.cc:14:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |       if(s[i]=="W"&&s[i-1]=="B"){
Language: C++

#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#define pi 3.1415926536
using namespace std;

int sb[200005],sw[200005];
int main()
{
	char s[200005];
	int nw = 0,nb = 0;
	int sum = 0;
	scanf("%s",s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++){
		if(s[i] == 'W'){ 
			nw++;
			sum += nb;
			sw[nw] = nb;
		}
		if(s[i] == 'B') nb++;
	}
	/*for(int i = 1; i <= nw; i++){
		sum += sw[i]; 
	}*/
	printf("%d",sum);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'n' was not declared in this scope; did you mean 'nb'?
   18 |         n = strlen(s + 1);
      |         ^
      |         nb
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
typedef long long ll;
signed main(){
  string s;
  cin>>s;
  ll s_size=sizeof(s);
  ll ans=0;
  bool flag=true;
  while(flag){
    flag=false;
    rep(i,1,s_size){
      if(s[i]!=s[i-1]){
        swap(s[i],s[i-1]);
        ans++;
        flag=true;
      }
    }
    cout<<ans<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:21:4: error: expected '}' at end of input
   21 |   }
      |    ^
a.cc:5:14: note: to match this '{'
    5 | signed main(){
      |              ^
Language: C

#include <stdio.h>

int main(void)
{
	char S[200000];//1<=S<=2*10^5
	int i,count=0,f=0;
	
	scanf("%s",&S);
		for(i=0;i<200000;i++){//いったんすべて確かめる
			if(S[i]=='B'&&S[i+1]=='W'){
				while(S[i]=='B'&&S[i+1]='B'){
					S[i]='W';
					S[i+1]='B';
					count+=1;
					i-=1;
				}
			}
		}
    printf("%d\n",count);
}

Compiler output:
main.c: In function 'main':
main.c:11:56: error: lvalue required as left operand of assignment
   11 |                                 while(S[i]=='B'&&S[i+1]='B'){
      |                                                        ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
typedef long long ll;
signed main(){
  string s;
  cin>>s;
  ll s_size=sizeof(s);
  ll ans=0;
  bool flag=true;
  while(flag){
    flag=false
    rep(i,1,s_size){
      if(s[i]!=s[i-1]){
        swap(s[i],s[i-1]);
        ans++;
        flag=true;
      }
    }
    cout<<ans<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: expected ';' before 'for'
   12 |     flag=false
      |               ^
      |               ;
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     rep(i,1,s_size){
      |         ^
a.cc:3:31: note: in definition of macro 'rep'
    3 | #define rep(i,a,n) for(ll i=a;i<n;i++)
      |                               ^
a.cc:21:4: error: expected '}' at end of input
   21 |   }
      |    ^
a.cc:5:14: note: to match this '{'
    5 | signed main(){
      |              ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;

int main()
{
	char s[200000];

	cin >> s;

	int len = strlen(s);

	bool f = true;
	int cnt = 0;
	while (f)
	{
		f = false;
		for (size_t i = 0; i < len - 1; i++)
		{
			if (s[i] == 'B' && s[i + 1] == 'W')
			{
				s[i] = 'W';
				s[i + 1] = 'B';
				f = true;
				cnt++;
			}
		}
	}
	cout << cnt << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: 'strlen' was not declared in this scope
   14 |         int len = strlen(s);
      |                   ^~~~~~
a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <numeric>
  +++ |+#include <cstring>
    5 | #include <string>
Language: C++

#include <iostream>
#include <cmath>
#include <cstdio>
#define MAX 200005
using namespace std;
char S[MAX];
int b = 0,w = 0;
bool wTrue();
int main() {
  scanf("%s", S);
  int l = strlen(S);
  for (int i = 0; i < l; i++) {
    if(S[i] == 'W') w++;
    else b++;
  }
  if(b == 0 || w == 0) {
    printf("0\n");
    return 0;
  }
  int counter = 0;
  while(1) {
    for (int i = 0; i < l; i++) {
      if(S[i] == 'B' && S[i+1] == 'W') {
        counter++;
        S[i] = 'W';
        S[i+1] = 'B';
      }
    }
    if(wTrue()) break;
  }
  printf("%d\n", counter);
}

bool wTrue() {
  for (int i = 0; i < w; i++) {
    if(S[i] == 'B') return false;
  }
  return true;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: 'strlen' was not declared in this scope
   11 |   int l = strlen(S);
      |           ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdio>
  +++ |+#include <cstring>
    4 | #define MAX 200005
Language: C++

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
int main()
{
	string a;
	bool b;
	int c = 0;
	cin >> a;
	do {
		b = false;
		for (int i = a.length()-1; i > 0; i--) {
			if (a[i] == 'W' && a[i - 1] == 'B') {
				a[i] = 'B'; a[i - 1] = 'W';
				b = true;
				c++;
			}
		}
	} while (b);
	cout << c;
    return 0;
}

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

#include <iostream>
using namespace std;



int main()
{
	char S[20002];

	scanf("%s", S);

	int N = strlen(S);


	int count = 0;

	for(;;){
		bool updated = false;

		int i = 0;
		while(i < N - 1){
			if(S[i] == 'B' && S[i+1] == 'W'){
				S[i  ] = 'W';
				S[i+1] = 'B';
				count++;
				updated = true;
				break;
			}
			else{
				i++;
			}
		}

		if(!updated)
			break;
	}

	printf("%d\n", count);

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: 'strlen' was not declared in this scope
   12 |         int N = strlen(S);
      |                 ^~~~~~
a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C

#include <stdio.h>

int main()
{
  int i, cont = 1;, count = 0;
  char data[200001];
  
  scanf("%s", &data);
  
  while(cont) {
    for (i = 0; data[i] != '\0'; i++) {
      if (data[i] == 'B' && data[i + 1] == 'W') {
        data[i] = 'W';
        data[i + 1] = 'B';
        count++;
        break;
      }
    }
    
    cont = 0;
  }
  
  printf("%d\n", &count);
  
  return 0;
}
  

Compiler output:
main.c: In function 'main':
main.c:5:19: error: expected expression before ',' token
    5 |   int i, cont = 1;, count = 0;
      |                   ^
main.c:5:21: error: 'count' undeclared (first use in this function); did you mean 'cont'?
    5 |   int i, cont = 1;, count = 0;
      |                     ^~~~~
      |                     cont
main.c:5:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

int reverce(const std::string &S) 
{
  int count = 0;
  // B,Wの並びを調べる
  std::string::size_type i = S.find("BW");
  while (i != std::string::npos) {
    std::string s(S);
   	s[i] = 'W';
   	s[i+1] = 'B';
    count = std::max(reverce(s), count + 1);
    i = S.find("BW", i+1);
  }
  return count;
}

int main()
{
  	std::string S;
    std::cin >> S;
  
    // 出力
    std::cout << reverce(S) << std::endl;
    return 0;
}

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

#include<cstdio>
#include<cstring>
int main()
{
	int n, i, ans = 1, cnt = 1;
	char s[200005];
	gets(s);
	n = strlen(s);
	for(i = 1; i < n; i++)
	{
		if(s[i] != s[i - 1])cnt++;
		else
		{
			if(ans < cnt) ans = cnt;
			cnt = 1;
		}
	}
	if(ans < cnt)ans = cnt;
	printf("%d\n", ans);
	return 0;
}

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

s = input()

counter = 0
while 'BW' in s:
    counter += s.count('BW')
    s = s.replace('BW', 'WB')

print(counter)

Compiler output:
a.cc:4:7: warning: multi-character character constant [-Wmultichar]
    4 | while 'BW' in s:
      |       ^~~~
a.cc:5:24: warning: multi-character character constant [-Wmultichar]
    5 |     counter += s.count('BW')
      |                        ^~~~
a.cc:6:19: warning: multi-character character constant [-Wmultichar]
    6 |     s = s.replace('BW', 'WB')
      |                   ^~~~
a.cc:6:25: warning: multi-character character constant [-Wmultichar]
    6 |     s = s.replace('BW', 'WB')
      |                         ^~~~
a.cc:1:1: error: 's' does not name a type
    1 | s = input()
      | ^
Language: C++

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

int main() {
string s;
cin >> s;
int b = 0;
int w = 0;
for (int i = 0; i < s.size(); i++) {
if (s.at(i) == 'B')
b++;
else
w++;
}
int sum = 0;
for (int i = 0; i < s.size(); i++) {
if (s.at(i) == 'B') {
b--;
sum += s.size - b - i;
}
}
cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   19 | sum += s.size - b - i;
      |        ~~^~~~
      |              ()
Language: C++

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

int main(void){
  char str[400000],temp;int ans=0;
  gets(str);
  
  for(int i;i<strlen(str);i++){
  	if(str[i]=='B' && str[i+1]=='W'){
      temp=str[i];
      str[i]=str[i+1];
      str[i+1]=temp;
      ans++;
      i=-1;
    }
  }
  
  printf("%d\n",ans);
  return 0;
}

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

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

string a;
int ans,w;
int main(){
    cin>>a;

    for(int i=0;i<a.length()+1;i++){
        if(a[i]=='B'&&a[i+1]=='W'){
            ans++;
            a[i]='W';
            a[i+1]='B';
            i=-1;
        }#include<bits/stdc++.h>
using namespace std;

string a;
int ans,w;
int main(){
    cin>>a;

    for(int i=0;i<a.length()+1;i++){
        if(a[i]=='B'&&a[i+1]=='W'){
            ans++;
            a[i]='W';
            a[i+1]='B';
            i-=2;
        }
    }
    cout<<ans<<endl;

}

    }
    cout<<ans<<endl;

}


Compiler output:
a.cc:15:10: error: stray '#' in program
   15 |         }#include<bits/stdc++.h>
      |          ^
a.cc: In function 'int main()':
a.cc:15:11: error: 'include' was not declared in this scope
   15 |         }#include<bits/stdc++.h>
      |           ^~~~~~~
a.cc:15:19: error: 'bits' was not declared in this scope
   15 |         }#include<bits/stdc++.h>
      |                   ^~~~
a.cc:15:24: error: 'stdc' was not declared in this scope; did you mean 'std'?
   15 |         }#include<bits/stdc++.h>
      |                        ^~~~
      |                        std
a.cc:16:1: error: expected primary-expression before 'using'
   16 | using namespace std;
      | ^~~~~
a.cc:20:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   20 | int main(){
      |         ^~
a.cc:20:9: note: remove parentheses to default-initialize a variable
   20 | int main(){
      |         ^~
      |         --
a.cc:20:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:20:11: error: a function-definition is not allowed here before '{' token
   20 | int main(){
      |           ^
Language: C++

#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<cstdlib>
using namespace std;

char s[200005];
int pos[200005];

int main(){
	scanf("%s", s);
	int len = strlen(s);
	int sum = 0;
	memset(pos, -1, sizeof(pos));
	int ans = 0;
	/*
	for(int i = 0; i <= len - 1; i++){
		if(s[i] == 'B' && s[i + 1] == 'W'){
			sum++;
			i += 1;
		}
	}
	for(int i = sum; i >= 1; i--){
		ans = ans + i;
	}
	*/
	int cnt = 0;
	for(int i = 0; i <= len - 1; i++){
		if(s[i] == 'B') cnt++;
		if(s[i] == 'W') {
			sum++;
			pos[sum] = cnt;
		}
	}
	for(int i = 1; pos[i] >= 0; i++){
		ans = ans + pos[i];
	}
	printf("%d\n", ans);
	return 0;
}
/*	BWBWBW
	WBBWBW
	WBWBBW
	WBWBWB
	WWBWBB
	WWWBBB

	BWBWBWBW
	WBWBWBWB 4
	WWBWBWBB 3
	WWWBWBBB 2
	WWWWBBBB 1

	BBBW
	BBWB
	BWBB
	WBBB;
	*

Compiler output:
a.cc:46:1: error: unterminated comment
   46 | /*      BWBWBW
      | ^
Language: C++

#include <stdio.h>
#define MAX(A, B) (((A) > (B)) ? (A) : (B))
#define MIN(A, B) (((A) < (B)) ? (A) : (B))
#define ABS(A) (((A) > 0) ? (A) : 0 - (A))

int main () {
  char* s = malloc(200000 * sizeof(char));
  scanf("%s", s);
  int len=0;
  for (int i=0; *(s+i); i++) {len++;}
  
  int b=0;
  int j=0;
  for (int i=0; i<len; i++) {
    if (*(s+i) == 'W') {
      b += i - j;
      j++;
    }
  }
  printf("%d", b);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: 'malloc' was not declared in this scope
    7 |   char* s = malloc(200000 * sizeof(char));
      |             ^~~~~~
a.cc:2:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    1 | #include <stdio.h>
  +++ |+#include <cstdlib>
    2 | #define MAX(A, B) (((A) > (B)) ? (A) : (B))
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<iomanip>
#include<cmath>
#include<conio.h>

using namespace std;

int main(void) {
	string s; cin >> s;
	int sum = 0;
	int i;
	int a = s.size() - 1;

	for (i = a; i >= 0; i--) {
		if (s[i] == 'B') {
			sum += a - i;
			a--;
		}
	}



	cout << sum << endl;

	return 0;
}


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

#include <vector>
#include <iostream>
#include <fstream>
#include <cstddef>
#include <string>

namespace {

size_t Merge(std::vector<size_t>& a, size_t i, size_t chunk_size, std::vector<size_t>& tmp) {
     std::vector<size_t>::iterator a1 = a.begin() + i;
     size_t l1 = chunk_size;
     std::vector<size_t>::iterator a2 = a1 + l1;
     size_t l2 = (a.size() > i + chunk_size * 2) ? chunk_size : a.size() - i - chunk_size;

     tmp.clear();
     size_t res = 0;

     for (size_t i1 = 0, i2 = 0; i1 != l1 || i2 != l2; ) {
          if (i1 == l1) {
               tmp.push_back(a2[i2++]);
          } else if (i2 == l2) {
               tmp.push_back(a1[i1++]);
          } else if (a1[i1] < a2[i2]) {
               tmp.push_back(a1[i1++]);
          } else if (a2[i2] < a1[i1]) {
               tmp.push_back(a2[i2++]);
               res += l1 - i1;
          } else {
               std::cerr << "Oops" << std::endl;
          }
     }

     for (size_t di = 0; di < tmp.size(); ++di)
          a[i + di] = tmp[di];

     return res;
}

size_t CountCross(std::vector<size_t>& a) {
     size_t res = 0;
     std::vector<size_t> tmp(a.size());

     for (size_t chunk_size = 1; chunk_size < a.size(); chunk_size *= 2)
          for (size_t i = 0; i + chunk_size < a.size(); i += chunk_size * 2)
               res += Merge(a, i, chunk_size, tmp);
     
     return res;
}

}

int main(int argc, char **argv) { 
     std::vector<size_t> a;
     std::string line;
     cin >> line;
     a.push_back(atoi(line.c_str()));
     std::cout << CountCross(a) << std::endl;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:55:6: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   55 |      cin >> line;
      |      ^~~
      |      std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: C++

#include<stdio.h>
#include<cstring>
using namespace std;
char s[1000000];
main(){
int n,ans = 0;
gets(s);
n = strlen(s);
for(int x = 0;x < n;x++){
if(s[x] == 'B' && s[x + 1] == 'W' ) ans++;
}
printf("%d\n",ans*2);
}

Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:7:1: error: 'gets' was not declared in this scope; did you mean 'getw'?
    7 | gets(s);
      | ^~~~
      | getw
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin>>a;
  long long d=a.size();
  int b=0;
  for(int l=0;l<d*d;l++){
    for(int i=0;i<d();i++){
      if(a[i-1]=='B'&&a[i]=='W'){
        swap(a[i-1],a[i]);
        b++;
      }
      else{
      }
    }
  }
  cout<<b<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:20: error: 'd' cannot be used as a function
    9 |     for(int i=0;i<d();i++){
      |                   ~^~
Language: C

#include<stdio.h>
#include<cstring>
using namespace std;
char s[1000000];
main(){
int n,ans = 0;
gets(s);
n = strlen(s);
for(int x = 0;x < n;x++){
if(s[x] == 'B' && s[x + 1] == 'W' ) ans++;
}
printf("%d\n",ans*2);
}

Compiler output:
main.c:2:9: fatal error: cstring: No such file or directory
    2 | #include<cstring>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
    string s;
    cin >> s;
    int count=0;
    int b=0;int w=0;
    int counts=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            count+=i-counts;
            counts++;
            w++;    
        }
        else{
            b++;
        }
        
    }
    if(b==0){
        cout << 0 << endl;
        return 0;
    }
    if(w==0{
        cout << 0 << endl;
        return 0;
    }
    cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:12: error: expected ';' before '{' token
   25 |     if(w==0{
      |            ^
      |            ;
a.cc:29:26: error: expected ')' before ';' token
   29 |     cout << count << endl;
      |                          ^
      |                          )
a.cc:25:7: note: to match this '('
   25 |     if(w==0{
      |       ^
Language: C++

package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)
	values := strings.Split(str, "")

	sum := 0
	nth := 0
	for i := 0; i < len(values); i++ {
		if values[len(values)-i-1] == "B" {
			sum = sum + (i - nth)
			nth++
		}
	}
	fmt.Println(sum)
}


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

#include<stdio.h>
int main(){
 int c=0,b=0,w=0,n,wc=0;
 int be,af;
 char s[200000];
 scanf("%s",s);
 while(s[c]!=0){
  c++;
  if(s[c]=='b')b=b+c;
  if(s[c]=='w')w=w+c,wc++;
 }
 n=c;
 be=abs(b-w);
 b=0,w=0;
 for(c=0;c<n;c++){
  if(c<wc)w=c+w;
  else b=b+c;
 }
 af=abs(w-b);
 if(af-be>0)printf("%d\n",af-be);
 else printf("0\n");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'abs' was not declared in this scope
   13 |  be=abs(b-w);
      |     ^~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  ll B=0;
  ll ans=0;
  REP(i,S.size()){
    if(S[i]=='B'){
      B++;
    }
    if(S[i]=='W'){
      ans += B;
    }
  }c
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:4: error: 'c' was not declared in this scope
   35 |   }c
      |    ^
Language: C++

#include <iostream>
#include <string>

using namespace std;
int main()
{
	string a;
	bool b;
	int c = 0;
	cin >> a;
	do {
		b = false;
		for (int i = a.size; i > 0; i--) {
			if (a[i] == 'W' && a[i - 1] == 'B') {
				a[i] = 'W'; a[i - 1] = 'B';
				b = true;
				c++;
			}
		}
	} while (b);
	cout << c;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:32: error: cannot convert 'std::__cxx11::basic_string<char>::size' 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'
   13 |                 for (int i = a.size; i > 0; i--) {
      |                                ^~~~
Language: C++

#include <bits\stdc++.h>



#define sqre(x) (x)*(x)

using namespace std;

int main()
{
	int ans = 0 ;
	string s; cin >> s;
	int len = s.length();
	for(int i = 0 ; i < len - 1; i++)
	{
		string a = "";
		a += s[i];a += s[i + 1];
		if(a == "BW")ans++;
		}
	cout << ans*2 << endl;
	return 0;
}

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

#include <iostream>
#include <cctype>tz122
#9170
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<29)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main() {
    string s;
    ll c1 = 0, c2 = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'W') {
            c1 += i;
            c2++;
        }
    }
    if (c2 == 0)cout << 0 << endl;
    else cout << c1 - (c2 - 1)*c2 / 2 << endl;
}


Compiler output:
a.cc:2:10: fatal error: cctype>tz12: No such file or directory
    2 | #include <cctype>tz122
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <stdio.h>
#define moji 1000000

int main(){
    char s[moji];
    int i=0;
    int l;
    
    scanf("%s",&s);

    for(l=1;l<moji;l++){
        if(s[l]==B&&s[l-1]==W) i++;
        if(s[l]==W&&s[l-1]==B) i++;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: 'B' was not declared in this scope
   12 |         if(s[l]==B&&s[l-1]==W) i++;
      |                  ^
a.cc:12:29: error: 'W' was not declared in this scope
   12 |         if(s[l]==B&&s[l-1]==W) i++;
      |                             ^
a.cc:13:18: error: 'W' was not declared in this scope
   13 |         if(s[l]==W&&s[l-1]==B) i++;
      |                  ^
a.cc:13:29: error: 'B' was not declared in this scope
   13 |         if(s[l]==W&&s[l-1]==B) i++;
      |                             ^
Language: C++

#include<stdio.h>
#include<string.h>
char a[1000000];
int main()
{
	gets(a);
	int len=strlen(a);
	int b_cnt=0;
	int sum=0;
	for(int i=0;i<len;i++)
	{
		if(a[i]=='B')
		{
			b_cnt++;
		}
		if(a[i]=='W')
		{
			sum+=b_cnt;
		}
	}
	printf("%d",sum);
 } 

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

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define inf 100100100

int main(){
    string s;
    cin >> s;
    longlong a = 0;
    longlong b = 0;
    rep(i,s.length()){
        if(s[i]=='B'){
            a++;
        }else{
            b+=a;
        }
    }
    cout << b << endl;;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:5: error: 'longlong' was not declared in this scope
   21 |     longlong a = 0;
      |     ^~~~~~~~
a.cc:22:13: error: expected ';' before 'b'
   22 |     longlong b = 0;
      |             ^~
      |             ;
a.cc:25:13: error: 'a' was not declared in this scope
   25 |             a++;
      |             ^
a.cc:27:13: error: 'b' was not declared in this scope
   27 |             b+=a;
      |             ^
a.cc:27:16: error: 'a' was not declared in this scope
   27 |             b+=a;
      |                ^
a.cc:30:13: error: 'b' was not declared in this scope
   30 |     cout << b << endl;;
      |             ^
Language: C++

#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
char S[404040];
LL ans;
int main(){
	scanf("%s",S+1);
	int n=strlen(S+1);
	LL Cur=0;
	for (int i=1;i<=n;i++)
		if (S[i]=='B') Cur++;
		else ans+=Cur;
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:15: error: 'strlen' was not declared in this scope
    9 |         int n=strlen(S+1);
      |               ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<cstdio>
  +++ |+#include <cstring>
    3 | #define LL long long
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int i = 0;
	long long cnt = 0;
	string s ;
	cin >> s;
	int n = s.size();#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	
	
	return 0;
}
	while(i < n - 1) {

		if(s[i] == 'B' && s[i + 1] == 'W' ) {

			cnt += 1;
			swap(s[i], s[i + 1]);
			if(i > 0)
				i--;
			
		}
		else
			i++;


	}
	cout << cnt;

	return 0;
}

Compiler output:
a.cc:14:26: error: stray '#' in program
   14 |         int n = s.size();#include <bits/stdc++.h>
      |                          ^
a.cc: In function 'int main(int, const char**)':
a.cc:14:27: error: 'include' was not declared in this scope
   14 |         int n = s.size();#include <bits/stdc++.h>
      |                           ^~~~~~~
a.cc:14:36: error: 'bits' was not declared in this scope
   14 |         int n = s.size();#include <bits/stdc++.h>
      |                                    ^~~~
a.cc:14:41: error: 'stdc' was not declared in this scope; did you mean 'std'?
   14 |         int n = s.size();#include <bits/stdc++.h>
      |                                         ^~~~
      |                                         std
a.cc:16:1: error: expected primary-expression before 'using'
   16 | using namespace std;
      | ^~~~~
a.cc:19:1: error: a function-definition is not allowed here before '{' token
   19 | {
      | ^
Language: C++


using namespace std;

#define sz(a) ((int)a.size())

string s;

void trans() {
    cin >> s;
    long long ans = 0, cnt = 0;
    for (int i = 0; i < sz(s); i++) {
        if (s[i] == 'W') {
            ans += cnt;
        } else cnt++;
    }
    cout << ans;
}

int main() {
    trans();

    return 0;
}


Compiler output:
a.cc:6:1: error: 'string' does not name a type
    6 | string s;
      | ^~~~~~
a.cc: In function 'void trans()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin >> s;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:9:12: error: 's' was not declared in this scope; did you mean 'sz'?
    9 |     cin >> s;
      |            ^
      |            sz
a.cc:16:5: error: 'cout' was not declared in this scope
   16 |     cout << ans;
      |     ^~~~
a.cc:16:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#map(int,input().split())
s=input()
times=1
sum=0
for i in range(len(s)):
    if s[i]=='W':
        sum+=i+1-times
        times+=1
print(sum)   


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #map
    1 | #map(int,input().split())
      |  ^~~
a.cc:2:1: error: 's' does not name a type
    2 | s=input()
      | ^
Language: C++

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

#define int long long

int32_t main() {
    string s; cin >> s;
    int a = 0, s = 0;
    for(char x: s) {
        if(x == 'B') a++;
        else s += a;    
    }
    cout << s << endl;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:8:16: error: conflicting declaration 'long long int s'
    8 |     int a = 0, s = 0;
      |                ^
a.cc:7:12: note: previous declaration as 'std::string s'
    7 |     string s; cin >> s;
      |            ^
Language: C++

#include<iostream>
#include<algorithm>
#include<multiset>

signed main(){
  int n;
  std::cin>>n;
  std::vector<int64_t> a(n);
  for(auto& ai:a)std::cin>>ai;
  std::sort(std::rbegin(a),std::rend(a));
  std::multiset<int64_t> st(std::begin(a),std::end(a));
  int ans = 0;
  for(int i=0;i<n;++i){
    if(st.find(a[i])==std::end(st))continue;
    st.erase(st.find(a[i]));
    for(int p2=40;p2-->0;){
      if(auto itr=st.find(p2-a[i]);itr!=std::end(st)){
        ans++;
        st.erase(itr);
      }
    }
  }
  std::cout<< ans <<std::endl;
}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  int P = 21;
  vector<int> pow_2;
  for (int i = 0; i <= P; i++)
  {
    pow_2.push_back(pow(2,i));
  }
  
  int N;cin>>N;
  vector<int> vec(N+1);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  vec[N] = INF;
  sort(ALL(vec));
  vector<int> used(2000000,0);
  
  int ANS = 0;
  
  for (int i = N-1; i >= 0; i--) 
  {
    // int X = vec[i];
    // int T = *lower_bound(ALL(pow_2),X);
    // T -= X;

    // if(used[T] == 0 && *lower_bound(ALL(vec),T) == T)
    // {
    //   used[T] = 1;
    //   used[X] = 1;
    //   ANS++;
    //   // DEBUG(X,T);
    }
  }
  cout<<ANS<<endl;



  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Compiler output:
a.cc:85:3: error: 'cout' does not name a type
   85 |   cout<<ANS<<endl;
      |   ^~~~
a.cc:90:3: error: expected unqualified-id before 'return'
   90 |   return;
      |   ^~~~~~
a.cc:91:1: error: expected declaration before '}' token
   91 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll INF = 100000000000;

int main(){ 
    ll N; cin >> N;
    vector<long double> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    for(int i=0; i<40; i++){
        B.emplace_back(pow(2,i));
    }
    ll count = 0;
    for(int i=N-1; i>=0; i--){
        double k;
        for(auto x: B){
            if(x>A[i]){
                k = x;
                break;
            }
        }
        double p = k - A[i];
        if(upper_bound(A.begin(), A.end()-(N-i), p)-lower_bound(A.begin(), A.end()-(N-i), p)>0){

            *(upper_bound(A.begin(), A.end(), p)-1) += 0.1;
            A[i] += 0.1;
            count++;
            
        }
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'B' was not declared in this scope
   22 |         B.emplace_back(pow(2,i));
      |         ^
a.cc:27:21: error: 'B' was not declared in this scope
   27 |         for(auto x: B){
      |                     ^
Language: C++

#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll INF = 100000000000;

int main(){ 
    ll N; cin >> N;
    vector<long double> A(N);
    vb(N, false);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vll B(0);
    for(int i=0; i<33; i++){
        B.emplace_back(pow(2,i));
    }
    ll count = 0;
    for(int i=N-1; i>=1; i--){
        long double k;
        for(auto x: B){
            if(x>A[i]){
                k = x;
                break;
            }
        }
        long double p = k - A[i];
        if(upper_bound(A.begin(), A.end()-(N-i), p)-lower_bound(A.begin(), A.end()-(N-i), p)>0){

            *(upper_bound(A.begin(), A.end(), p)-1) += 0.1;
            A[i] += 0.1;
            count++;
            
        }
    }
    cout << count << endl;
}#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll INF = 100000000000;

int main(){ 
    ll N; cin >> N;
    vector<long double> A(N);
    vb(N, false);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vll B(0);
    for(int i=0; i<33; i++){
        B.emplace_back(pow(2,i));
    }
    ll count = 0;
    for(int i=N-1; i>=1; i--){
        long double k;
        for(auto x: B){
            if(x>A[i]){
                k = x;
                break;
            }
        }
        long double p = k - A[i];
        if(upper_bound(A.begin(), A.end()-(N-i), p)-lower_bound(A.begin(), A.end()-(N-i), p)>0){

            *(upper_bound(A.begin(), A.end(), p)-1) += 0.1;
            A[i] += 0.1;
            count++;
            
        }
    }
    cout << count << endl;
}

Compiler output:
a.cc:45:2: error: stray '#' in program
   45 | }#include <bits/stdc++.h>
      |  ^
a.cc:45:3: error: 'include' does not name a type
   45 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:56:4: error: redefinition of 'll INF'
   56 | ll INF = 100000000000;
      |    ^~~
a.cc:12:4: note: 'll INF' previously defined here
   12 | ll INF = 100000000000;
      |    ^~~
a.cc:58:5: error: redefinition of 'int main()'
   58 | int main(){
      |     ^~~~
a.cc:14:5: note: 'int main()' previously defined here
   14 | int main(){
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
multiset<int>s;
int main(){
    int n=0;
    cin>>n;
    long long a;
    for(int i=0;i<n;i++){
        cin>>a;
        s.insert(a);
    }
    long long tmp=2;
    int i=0,j=1,cnt=0,b=2;
    while(tmp<=s[i]+s[j]){
        if(s[i]+s[j]==tmp){
            cnt++;
            s.erase(s[i]);
            s.erase(s[j]);
            i++;
            j=i+1;
        }
        if(j=s.size()-1){
            s.erase(s[i]);
            i++;
            j=i+1;
        }
        if(i=s.size()-1)break;
        tmp=pow(2,b);
        b++;
        j++;
    }
    cout<<cnt;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: no match for 'operator[]' (operand types are 'std::multiset<int>' and 'int')
   14 |     while(tmp<=s[i]+s[j]){
      |                 ^
a.cc:14:22: error: no match for 'operator[]' (operand types are 'std::multiset<int>' and 'int')
   14 |     while(tmp<=s[i]+s[j]){
      |                      ^
a.cc:15:13: error: no match for 'operator[]' (operand types are 'std::multiset<int>' and 'int')
   15 |         if(s[i]+s[j]==tmp){
      |             ^
a.cc:15:18: error: no match for 'operator[]' (operand types are 'std::multiset<int>' and 'int')
   15 |         if(s[i]+s[j]==tmp){
      |                  ^
a.cc:17:22: error: no match for 'operator[]' (operand types are 'std::multiset<int>' and 'int')
   17 |             s.erase(s[i]);
      |                      ^
a.cc:18:22: error: no match for 'operator[]' (operand types are 'std::multiset<int>' and 'int')
   18 |             s.erase(s[j]);
      |                      ^
a.cc:23:22: error: no match for 'operator[]' (operand types are 'std::multiset<int>' and 'int')
   23 |             s.erase(s[i]);
      |                      ^
Language: C++

#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
template <typename T> void chmax(T& a, T b) {
	a = max(a, b);
}
template <typename T> void chmin(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
int pow2[40];

int32_t main() {
    IAMSPEED
    int n; cin >> n;
    gp_hash_table<ll,ll>mp;
    pow2[0]=1;
    FOR(i,1,32) {
        pow2[i]=2*pow2[i-1];
    }
    FOR(i,1,n){
        int x; cin >> x;
        FOR(i,0,32) {
            ll diff = abs(pow2[i]-x);
            ans+=mp[diff];
        }
        mp[x]++;
    }
    cout<<ans;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:55:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   55 |             ans+=mp[diff];
      |             ^~~
      |             abs
a.cc:59:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   59 |     cout<<ans;
      |           ^~~
      |           abs
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	map<lli,lli> d;
	
	REP(i,0,n){
		lli a;
		cin>>a;
		d[-a]++;
	}

	lli cnt=0;
	for(auto e:d){
		lli num = -e.first;
		d[-num]--;
		if(d[-num]==0)d.erase(-num);

		lli bi=1;
		while(bi<=num)bi*=2;
		lli target = bi-num;
		if(d.count(-target)){
			cnt++;
			d[-target]--;
			if(d[-target]==0)m.erase(-target);
		}
	}
	cout<<cnt<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:42: error: 'm' was not declared in this scope
   41 |                         if(d[-target]==0)m.erase(-target);
      |                                          ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	map<lli,lli> d;
	
	REP(i,0,n){
		lli a;
		cin>>a;
		d[-a]++;
	}

	lli cnt=0;
	for(auto e:d){
		lli num = -e.first;
		d[-num]--;
		if(d[-num]==0)d.erase(-num);

		lli bi=1;
		while(bi<=num)bi*=2;
		lli target = bi-num;
		if(d.count(-target)){
			cnt++;
			m[-target]--;
			if(m[-target]==0)m.erase(-target);
		}
	}
	cout<<cnt<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:25: error: 'm' was not declared in this scope
   40 |                         m[-target]--;
      |                         ^
Language: C++

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n;cin>>n;
  vector<ll>a(n);
  multiset<ll>set;
  rep(i,n){
    cin>>a[i];
    set.insert(a[i]);
  }

  vector<ll>v(40);
  for(int i=0;i<40++i)v[i]=(1LL<<i);
  
  sort(all(v),greater<ll>());
  ll ans=0;
  rep(i,n){
    for(auto&&p:v){
      auto itr=set.find(a[i]);
      if(itr==set.end())continue;
      set.erase(itr);
      auto itr2=set.find(p-a[i]);
      if(itr2!=set.end()){
        ans++;
        set.erase(itr2);
      }else set.insert(a[i]);
    }
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Compiler output:
a.cc: In function 'bool solve()':
a.cc:101:17: error: lvalue required as increment operand
  101 |   for(int i=0;i<40++i)v[i]=(1LL<<i);
      |                 ^~
a.cc:101:21: error: expected ';' before 'i'
  101 |   for(int i=0;i<40++i)v[i]=(1LL<<i);
      |                     ^
      |                     ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin>>n;
    vl beki;
    multiset<ll> A;
    beki.push_back(1);
    rep(i,40){
        beki.push_back(beki.back()*2);
    }
    rep(i,n){
        cin>>x;
        A.insert(x);
    }

    while(!A.empty()){
        auto ite=A.end();
        ite--;
        x=*ite;
        k=upper_bound(all(beki),x*2)-beki.begin()-1;
        if(A.count(beki[k]-x)>0){
            auto ite2=A.lower_bound(beki[k]-x);
            A.erase(ite2);
            ans++;
        }
      	auto ite=A.end();
    	ite--;
        A.erase(ite);
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:14: error: conflicting declaration 'auto ite'
   37 |         auto ite=A.end();
      |              ^~~
a.cc:28:14: note: previous declaration as 'std::_Rb_tree_const_iterator<long long int> ite'
   28 |         auto ite=A.end();
      |              ^~~
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
const int MAXN = 100000 + 10;
int a[MAXN];

int main(){
    std::ios::sync_with_stdio(false);
    int n;
        for(int i = 0; i < n; ++i){
            std::cin >> a[i];
        }
        std::sort(a, a + n);
        ll ans = 0;
        int k = log(a[n - 1] + a[n - 2]) / log(2) + 1;
        for(int i = 0; i < n; ++i){
            for(int j = 0; j <= k; ++j){
                int t = (1 << j) - a[i];
                if(t > 0){
                    int l = std::lower_bound(a + i + 1, a + n, t) - a;
                    int r = std::upper_bound(a + i + 1, a + n, t) - a;
                    if(r > l){
                        ans += r - l;
                    }
                }
            }
        }
        cout << ans << std::endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |         cout << ans << std::endl;
      |         ^~~~
      |         std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~