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


#include<bits/stdc++.h>
using namespace std;
char a[200111];
int main()
{
    int c=0,i;

    gets(a);
    for(i=0;i<strlen(a);i++)
    {
        if(a[i]=='B'&&a[i+1]=='W' || a[i]=='W'&&a[i+1]=='B' )
            {c= c+2;
            i=i+1;}
    }
    cout<< c;
    return 0;
}


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

#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<string.h>
using namespace std ;
int main ()
{
    long int i , n  , count = 0 ;
    char a[1000001] ;
    gets(a) ;
    for ( i= 0 ; i < strlen(a) ; i ++)
    {
        if (a[i] != a[i+1])
            count++;
    }
    cout<<count<<endl ;
}


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

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

int main(){
    string s;
    cin>>s;
    ll b=0,sum=0;
    int n=(int)s.size()-1;
    for(int i=n;i>=0;i--){
        if(s[i]=='B'){
            sum+=n;
            sum-=i;
            n--;
        }
    }
    cout<<sum<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'll' was not declared in this scope
    7 |     ll b=0,sum=0;
      |     ^~
a.cc:11:13: error: 'sum' was not declared in this scope
   11 |             sum+=n;
      |             ^~~
a.cc:16:11: error: 'sum' was not declared in this scope
   16 |     cout<<sum<<endl;
      |           ^~~
Language: C++

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

int main(){
  string s; cin >>s;
  ll ans = 0;
  int cnt = 0;
  int n = s.size();
  rep(i,n){
    if(s[i]=='B') cnt++;
    else ans += cnt;
  cout << ans << endl;
  return 0; 
}

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

#include<iostream>
#include<string>

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'string' was not declared in this scope
    6 |   string s;
      |   ^~~~~~
a.cc:6:3: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> s;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:7:10: error: 's' was not declared in this scope
    7 |   cin >> s;
      |          ^
a.cc:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   cout << ans << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:16:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   16 |   cout << ans << endl;
      |                  ^~~~
      |                  std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

int main() {
    string s; cin >> s;
    bool debug = true;
    string s; cin >>s;
    int w=0;
    for (auto c: s) if(c=='W'){w++;}
    if (debug) cout << s << endl << "----" << endl;

    int left_white = 0, t;
    long long ret = 0;
    for (int i = 0; i < w; i++) {
        t = s.substr(left_white, s.size()).find('W');
        if (t==0) {
            // do nothing
        }
        else {
            s[left_white] = 'W';
            if (t>0) s[left_white+t] = 'B';
            ret += t;
        }
        if (debug) cout << s << " " << t << endl;
        left_white++;
    }
    if (debug) cout << "----" << endl << s << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:12: error: redeclaration of 'std::string s'
    7 |     string s; cin >>s;
      |            ^
a.cc:5:12: note: 'std::string s' previously declared here
    5 |     string s; cin >> s;
      |            ^
Language: C++

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

int main(){
  string s;
  cin >> s;
  
  reverse(s.begin()s.end());
  
  int k=0;
  long long ans=0;
  
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='B'){
      ans+=i-k;
      k++;
    }
  }
  
  cout << ans << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:20: error: expected ')' before 's'
    8 |   reverse(s.begin()s.end());
      |          ~         ^
      |                    )
a.cc:8:10: error: no matching function for call to 'reverse(std::__cxx11::basic_string<char>::iterator)'
    8 |   reverse(s.begin()s.end());
      |   ~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:1083:5: note: candidate: 'template<class _BIter> void std::reverse(_BIter, _BIter)'
 1083 |     reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1083:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: candidate: 'template<class _ExecutionPolicy, class _BidirectionalIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::reverse(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator)'
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note:   candidate expects 3 arguments, 1 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  cout << str.size() << endl;
  int count = 0;
  int black=0;
  int ans = 0;
  bool check=true;
  if(int i=0;i<str.size();i++){
    if((str.at(i)=='W')&&(black>0)){
      ans+=i-count-black;
      count++;
    }else if((str.at(i)=='B')&&(check)){
      black=i;
      check=false;
    }
  }
  cout << ans << endl;    

}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:26: error: expected ')' before ';' token
   11 |   if(int i=0;i<str.size();i++){
      |     ~                    ^
      |                          )
a.cc:11:27: error: 'i' was not declared in this scope
   11 |   if(int i=0;i<str.size();i++){
      |                           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  cout << str.size() << endl;
  int count = 0;
  int black=0;
  int ans = 0;
  bool check=true;
  if(int i=0;i<((int)str.size());i++){
    if((str.at(i)=='W')&&(black>0)){
      ans+=i-count-black;
      count++;
    }else if((str.at(i)=='B')&&(check)){
      black=i;
      check=false;
    }
  }
  cout << ans << endl;    

}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:33: error: expected ')' before ';' token
   11 |   if(int i=0;i<((int)str.size());i++){
      |     ~                           ^
      |                                 )
a.cc:11:34: error: 'i' was not declared in this scope
   11 |   if(int i=0;i<((int)str.size());i++){
      |                                  ^
Language: C++

#include <iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  long long ans=0;
  long long cnt=0;
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    if(s[i]=='W'){
      cnt++;
    }else{
      ans+=cnt;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'reverse' was not declared in this scope
    8 |   reverse(s.begin(),s.end());
      |   ^~~~~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  int cnt=0;
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    if(s[i]=='W'){
      cnt++;
    }else{
      ans+=cnt;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'reverse' was not declared in this scope
    8 |   reverse(s.begin(),s.end());
      |   ^~~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  vector<int> b;
  for(int i=0;i<n;i++){
    if(s[i]=='B'){
       b.push_back(i);
    }
  }
  if(b.size()==n){
    cout<<0<<endl;
  }else{
    for(int i=0;i<b.size();i++){
      ans+=(n-1-i-b[b.size()-1-i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> b;
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | #include <string>
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> b;
      |          ^~~
a.cc:12:8: error: 'b' was not declared in this scope
   12 |        b.push_back(i);
      |        ^
a.cc:15:6: error: 'b' was not declared in this scope
   15 |   if(b.size()==n){
      |      ^
Language: C++


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

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



int main() {
	string S;
	cin >> S;

	int N = S.length()
	int getted = 0;
	int cnt = 0;
	rep(i,N){
		if(S[i] == 'B'){
			cnt += (N-1-i-getted);
			getted++;
		}
	}

	cout << cnt << endl;
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: expected ',' or ';' before 'int'
   20 |         int getted = 0;
      |         ^~~
a.cc:24:39: error: 'getted' was not declared in this scope; did you mean 'gettid'?
   24 |                         cnt += (N-1-i-getted);
      |                                       ^~~~~~
      |                                       gettid
Language: C++

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    int Bcount = 0;
    rep(i,n){
        if(s[i] == 'B')Bcount++;
        else cnt += Bcount;
    }
    cout << cnt << endl;
}


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

#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0,num = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == "W") {
            ans += num;
        } else {
            ++num;
        }
    }
    cout << ans << endl;
}


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

#include <bits/stdc++.h>

int w, cnt;

int main()
{
    string s;
    std::cin >> s;
    
    for (int i = s.size() - 1; i >= 0; --i)
        if (s[i] == 'W')
            ++w;
        else
            cnt += w;
    
    std::cout << cnt;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'string' was not declared in this scope
    7 |     string s;
      |     ^~~~~~
a.cc:7:5: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:8:17: error: 's' was not declared in this scope
    8 |     std::cin >> s;
      |                 ^
Language: C++

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

int main () {
  string s;
  cin >> s ;
  int count_b = 0;
  int sum = 0;
  for (int i = 0; i < (int)s.length(); i++){
    if (s[i]=='B'){
      count_b++;
    }else{
      sum += count_b;
    }
  }
  cout  sum;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:7: error: expected ';' before 'sum'
   18 |   cout  sum;
      |       ^ ~~~
      |       ;
Language: C++

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

int main () {
  string s;
  cin >> s ;
  int count_b = 0;
  int sum = 0;
  for (int i = 0; i < (int)s.length(); i++){
    if (s[i]=='B'){
      count_b++;
    }else{
      sum += count_b;
    }
  }
  cout  sum;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: expected ';' before 'sum'
   19 |   cout  sum;
      |       ^ ~~~
      |       ;
Language: C++

#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  string s;
  cin >> s ;
  int count_b = 0;
  int sum = 0;
  for (int i = 0; i < (int)s.length(); i++){
    if (s[i]=='B'){
      count_b++;
    }else{
      sum += count_b;
    }
  }
  cout  sum;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:7: error: expected ';' before 'sum'
   27 |   cout  sum;
      |       ^ ~~~
      |       ;
Language: C++

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

int main(){

  string S;
  cin>>S;
	
	
  int countB=0;
  int sum=0;
  rep(i,S.length()){

    if(S[i]=="W")sum+=countB;
    countB++;
    
  }
  cout<<sum<<endl;
  
  

}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |     if(S[i]=="W")sum+=countB;
Language: C++

#include<bits/stdc++.h>
#define rep(i, c) for (int i = 0; i < (c);i++)
using namespace std;
using ll = long long;
int main()
{
  string s;
  cin >> s;
  ll int white_num = 0;
  ll int cnt = 0;
  rep(i,s.size()){
    if(s.at(i)=='W')
    {
      cnt += i;
      white_num++;
    }
  }
  ll int max = 0;
  rep(i, white_num)
  {
    max += i;
  }
  
  cout <<cnt - max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: two or more data types in declaration of 'white_num'
    9 |   ll int white_num = 0;
      |   ^~
a.cc:10:3: error: two or more data types in declaration of 'cnt'
   10 |   ll int cnt = 0;
      |   ^~
a.cc:14:7: error: 'cnt' was not declared in this scope; did you mean 'int'?
   14 |       cnt += i;
      |       ^~~
      |       int
a.cc:15:7: error: 'white_num' was not declared in this scope
   15 |       white_num++;
      |       ^~~~~~~~~
a.cc:18:3: error: two or more data types in declaration of 'max'
   18 |   ll int max = 0;
      |   ^~
a.cc:19:10: error: 'white_num' was not declared in this scope
   19 |   rep(i, white_num)
      |          ^~~~~~~~~
a.cc:2:40: note: in definition of macro 'rep'
    2 | #define rep(i, c) for (int i = 0; i < (c);i++)
      |                                        ^
a.cc:21:12: error: overloaded function with no contextual type information
   21 |     max += i;
      |            ^
a.cc:24:10: error: 'cnt' was not declared in this scope; did you mean 'int'?
   24 |   cout <<cnt - max << endl;
      |          ^~~
      |          int
Language: C++

/*test*/
#include<bits/stdc++.h>

using namespace std;

int main() {
    int i = 0, bko = 0;
    long long int sum = 0; b=0;
    string s;
    cin >> s;
    for (i = 0; i < s.size(); i++) {
        if (s[i] == 'B') {
            b += bko;
            bko += 1;
            sum += s.size() - 1 - i;
        }
    }
    cout << sum - b << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:28: error: 'b' was not declared in this scope
    8 |     long long int sum = 0; b=0;
      |                            ^
Language: C++

#include<bits/stdc++.h>
#include"Templates/libraries.h"
using namespace std;
int main(){
  string s;
  cin >> s;
  lli num=0, ans=0, wnum=0;
  while(wnum!=s.length() && num < s.length()){
    while(s[num]=='W' && num < s.length())num++;
    while(s[wnum]!='W' && wnum < s.length())wnum++;
    if(!(wnum!=s.length() && num < s.length()))break;
    ans+=wnum-num;
    char c = s[wnum];
    s[wnum]=s[num];
    s[num] = c;
    num++;
  }
  cout << ans;

}

Compiler output:
a.cc:2:9: fatal error: Templates/libraries.h: No such file or directory
    2 | #include"Templates/libraries.h"
      |         ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  ll ans=0;
  ll part=0;
  rep(i,n){
    if(s[i]=='B')part++;
    if(s[i]=='W')ans+=part;
  }
  cout<<ans<<endl;
}

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

#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s ;
  cin >> s ;
  ll bcnt = 0 ;
  ll ans = 0 ;
  REP(i,n){
    if(s[i]=='B'){
      bcnt++ ;
    }
    else{
      ans += bcnt ;
    }
  }
  cout << ans <<endl ;
  
  
  
  return 0 ;
}




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

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0, cnt = 0; i < S.size(); i++) {
    if (S.at(i) == 'B') cnt++;
    else ans += cnt
  }
  cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: expected ';' before '}' token
   10 |     else ans += cnt
      |                    ^
      |                    ;
   11 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  string s;cin>>s;
  int result=0, c=0;
   s.size()){
    if(s[i]=='B')c++;
    else result+=c;
  }
  cout<<result;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: expected ';' before ')' token
   11 |    s.size()){
      |            ^
      |            ;
a.cc:11:10: warning: ignoring return value of '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]', declared with attribute 'nodiscard' [-Wunused-result]
   11 |    s.size()){
      |    ~~~~~~^~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1076:7: note: declared here
 1076 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~
Language: C

#include <stdio.h>
#include <string>
#define N 6
int main(){
	char a[N]={};
	char c[N]={};
	int n=0;
	int j=0;
	int i=0;
	for(int i=0;i<N;i++){
		scanf("%c",&a[i]);
		j++;
	}
	a[j+1]='\0';
	if(a[0]=1){
		i=0;
		while(i<j){
			c[i]='1';
			if(i>=j){
				break;
			}
			i+=2;
		}
		i=1;
		while(i<j){
			c[i]='0';
			if(i>=j){
				break;
			}
			i+=2;
		}
	}
	if(a[0]=0){

		for(int i=0;i<N;i=i+2){
			c[i]='0';
		}

		for(int i=1;i<N;i=i+2){
			c[i]='1';
		}
	}
	for(int i=0;i<N;i++){
		if(a[i]!=c[i]){
			n++;
		}
	}
	puts(c);
	printf("%d",n);
	getchar();
}

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

#include <stdio.h>
#include <stdlib.h>

int main()
{
int i=0;
char s[i];
scanf("%d",&i);
for(i=0,i<10001,i++)
{
if(i%2==0)
s[i]=1;
else
s[i]=0;
}
if (s[i]=0)
printf('B');
else
printf('W');
if(s[i]!==s[i+1])
{
    printf("%d\n,i")

}
for(i=0,i<10001,i++)
{
if(i%2==0)
s[i]=0;
else
s[i]=1;
}
if (s[i]=0)
printf('B');
else
printf('W');
if(s[i]!==s[i+1])
{
    printf("%d\n,i")
    }
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:9:20: error: expected ';' before ')' token
    9 | for(i=0,i<10001,i++)
      |                    ^
      |                    ;
main.c:9:20: error: expected expression before ')' token
main.c:17:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   17 | printf('B');
      |        ^~~
      |        |
      |        int
In file included from main.c:1:
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:19:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   19 | printf('W');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:20:10: error: expected expression before '=' token
   20 | if(s[i]!==s[i+1])
      |          ^
main.c:22:21: error: expected ';' before '}' token
   22 |     printf("%d\n,i")
      |                     ^
      |                     ;
   23 | 
   24 | }
      | ~                    
main.c:25:20: error: expected ';' before ')' token
   25 | for(i=0,i<10001,i++)
      |                    ^
      |                    ;
main.c:25:20: error: expected expression before ')' token
main.c:33:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   33 | printf('B');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:35:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   35 | printf('W');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:36:10: error: expected expression before '=' token
   36 | if(s[i]!==s[i+1])
      |          ^
main.c:38:21: error: expected ';' before '}' token
   38 |     printf("%d\n,i")
      |                     ^
      |                     ;
   39 |     }
      |     ~
Language: C

#include <stdio.h>
#include <stdlib.h>

int main()
{
int i=0;
char s[i];
scanf("%d",&i);
for(i=0,i<10001,i++)
{
if(i%2==0)
s[i]=1;
else
s[i]=0;
}
if (s[i]=0)
printf('B');
else
printf('W');
if(s[i]!==s[i+1])
{
    printf("%d\n,i")

}
for(i=0,i<10001,i++)
{
if(i%2==0)
s[i]=0;
else
s[i]=1;
}
if (s[i]=0)
printf('B');
else
printf('W');
if(s[i]!==s[i+1])
{
    printf("%d\n,i")
return 0
}


Compiler output:
main.c: In function 'main':
main.c:9:20: error: expected ';' before ')' token
    9 | for(i=0,i<10001,i++)
      |                    ^
      |                    ;
main.c:9:20: error: expected expression before ')' token
main.c:17:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   17 | printf('B');
      |        ^~~
      |        |
      |        int
In file included from main.c:1:
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:19:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   19 | printf('W');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:20:10: error: expected expression before '=' token
   20 | if(s[i]!==s[i+1])
      |          ^
main.c:22:21: error: expected ';' before '}' token
   22 |     printf("%d\n,i")
      |                     ^
      |                     ;
   23 | 
   24 | }
      | ~                    
main.c:25:20: error: expected ';' before ')' token
   25 | for(i=0,i<10001,i++)
      |                    ^
      |                    ;
main.c:25:20: error: expected expression before ')' token
main.c:33:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   33 | printf('B');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:35:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   35 | printf('W');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:36:10: error: expected expression before '=' token
   36 | if(s[i]!==s[i+1])
      |          ^
main.c:38:21: error: expected ';' before 'return'
   38 |     printf("%d\n,i")
      |                     ^
      |                     ;
   39 | return 0
      | ~~~~~~               
main.c:40:1: error: expected declaration or statement at end of input
   40 | }
      | ^
Language: C

#include <stdio.h>
#include <stdlib.h>

int main()
{
int i=0;
char s[i];
scanf("%d",&i);
for(i=0,i<10001,i++)
{
if(i%2==0)
s[i]=1;
else
s[i]=0;
}
if (s[i]=0)
printf('B');
else
printf('W');
if(s[i]!==s[i+1])
{
    printf("%d\n,i")

}
for(i=0,i<10001,i++)
{
if(i%2==0)
s[i]=0;
else
s[i]=1;
}
if (s[i]=0)
printf('B');
else
printf('W');
if(s[i]!==s[i+1])
{
    printf("%d\n,i")

}

Compiler output:
main.c: In function 'main':
main.c:9:20: error: expected ';' before ')' token
    9 | for(i=0,i<10001,i++)
      |                    ^
      |                    ;
main.c:9:20: error: expected expression before ')' token
main.c:17:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   17 | printf('B');
      |        ^~~
      |        |
      |        int
In file included from main.c:1:
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:19:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   19 | printf('W');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:20:10: error: expected expression before '=' token
   20 | if(s[i]!==s[i+1])
      |          ^
main.c:22:21: error: expected ';' before '}' token
   22 |     printf("%d\n,i")
      |                     ^
      |                     ;
   23 | 
   24 | }
      | ~                    
main.c:25:20: error: expected ';' before ')' token
   25 | for(i=0,i<10001,i++)
      |                    ^
      |                    ;
main.c:25:20: error: expected expression before ')' token
main.c:33:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   33 | printf('B');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:35:8: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
   35 | printf('W');
      |        ^~~
      |        |
      |        int
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
main.c:36:10: error: expected expression before '=' token
   36 | if(s[i]!==s[i+1])
      |          ^
main.c:38:21: error: expected ';' before '}' token
   38 |     printf("%d\n,i")
      |                     ^
      |                     ;
   39 | 
   40 | }
      | ~                    
main.c:40:1: error: expected declaration or statement at end of input
   40 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
char x[maxn];

int main()
{
    scanf("%s", x);
    ll ans = 0;
    ll cur = 0;
    int len = strlen(x);
    for (int i = 0; i < n; i++) {
        if (x[i] == 'B')
            cur++;
        else
            ans += cur;
    }
    printf("%d", ans);
}

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

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

int main（）
{
    ios::sync_with_stdio(false);
    int ans=0,sum=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='B') sum++;
        else ans+=sum;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc:6:32: error: expected '}' before ';' token
    6 |     ios::sync_with_stdio(false);
      |                                ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
a.cc:9:5: error: 'cin' does not name a type
    9 |     cin>>s;
      |     ^~~
a.cc:10:5: error: expected unqualified-id before 'for'
   10 |     for(int i=0;i<s.size();i++){
      |     ^~~
a.cc:10:17: error: 'i' does not name a type
   10 |     for(int i=0;i<s.size();i++){
      |                 ^
a.cc:10:28: error: 'i' does not name a type
   10 |     for(int i=0;i<s.size();i++){
      |                            ^
a.cc:14:5: error: 'cout' does not name a type
   14 |     cout<<ans<<endl;
      |     ^~~~
a.cc:15:5: error: expected unqualified-id before 'return'
   15 |     return 0;
      |     ^~~~~~
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^
Language: C++

int main() {
    string s;cin >> s;
    long long c=0,g=0;
    for (auto z:s) {
        if (z=='B') c+=1;
        else g += c;
    }
    cout << g << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:5: error: 'string' was not declared in this scope
    2 |     string s;cin >> s;
      |     ^~~~~~
a.cc:2:14: error: 'cin' was not declared in this scope
    2 |     string s;cin >> s;
      |              ^~~
a.cc:2:21: error: 's' was not declared in this scope
    2 |     string s;cin >> s;
      |                     ^
a.cc:8:5: error: 'cout' was not declared in this scope
    8 |     cout << g << endl;
      |     ^~~~
a.cc:8:18: error: 'endl' was not declared in this scope
    8 |     cout << g << endl;
      |                  ^~~~
Language: C++

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

int main(){
  int N,s,j,u,ans,c;
  string S;
  ans=0;
  cin>>S;
  t=0;
  N=S.size();
  for(int i=0;i<N;i++){
    if(S[i]='W'){
      ans+=i-j;
      j++;
    }
    }
  j=N-1;
  for(int i=0;i<N;i++){
    if(S[N-i-1]='B'){
      ans+=j-N+1+i;
      j--;
    }
    }
 cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 't' was not declared in this scope
    9 |   t=0;
      |   ^
Language: C++

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

int main(){
  int N,s,t,u,ans,c;
  string S;
  ans=0;
  cin>>S;
  t=0;
  N=S.size();
  for(int i=0;i<N;i++){
    if(S[i]='W'){
      ans+=i-j;
      j++;
    }
    }
  j=N-1;
  for(int i=0;i<N;i++){
    if(S[N-i-1]='B'){
      ans+=j-N+1+i;
      j--;
    }
    }
 cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:14: error: 'j' was not declared in this scope
   13 |       ans+=i-j;
      |              ^
a.cc:17:3: error: 'j' was not declared in this scope
   17 |   j=N-1;
      |   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define int long long
using P = pair<int, int>;		//P.first, P.second
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

void main() {
	string S;
	cin>>S;
	int N = S.size();
	int ans = 0;
	int cntw = 0;
	for (int i = N-1; i >= 0; i--){
		if(S[i] == 'W')cntw++;
		else{
			ans+= cntw;
		}
	}
	int ans2 = 0;
	int cntb = 0;
	for (int i = 0; i < N; ++i){
		if(S[i] == 'B')cntb++;
		else{
			ans2 += cntb;
		}
	}
	cout<<max(ans,ans2)<<endl;
}

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define int long long
using P = pair<int, int>;		//P.first, P.second
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	int N = S.size();
	int ans = 0;
	int cntw = 0;
	for (int i = N-1; i >= 0; i--){
		if(S[i] == 'W')cntw++;
		else{
			ans+= cntw;
		}
	}
	int ans2 = 0;
	int cntb = 0;
	for (int i = 0; i < N; ++i){
		if(S[i] == 'B')cntb++;
		else{
			ans2 += cntb;
		}
	}
	cout<<max(ans,ans2)<<endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define int long long
using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	int N = S.size();
	int ans = 0;
	int cntw = 0;
	for (int i = N-1; i >= 0; i--){
		if(S[i] == 'W')cntw++;
		else{
			ans+= cntw;
		}
	}
	int ans2 = 0;
	int cntb = 0;
	for (int i = 0; i < N; ++i){
		if(S[i] == 'B')cntb++;
		else{
			ans2 += cntb;
		}
	}
	cout<<max(ans,ans2)<<endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

int main() {
  string s; cin >> s;
  int cnt = 0, sum = 0;
  for (int i = 0; i <s.size(), i++) {
    if (s[i] == 'B')
      cnt++;
    else
      sum += cnt;
  }
  cout << sum << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:35: error: expected ';' before ')' token
    7 |   for (int i = 0; i <s.size(), i++) {
      |                                   ^
      |                                   ;
Language: C++

#include<cstdio>
#include<cstring>

char s[300000];

int main(void) {
    scanf("%s", s);
    int l = strlen(s);

    int r=0;

    int i=0, j=l-1;
    while(i<j) {
        while(j>=0 && s[j] == 'B') j--;
        while(i<n && s[i] == 'W') i++;
        if(i>=j) break;
        r += j-i;
        i++, j--;
    }
    printf("%d\n", r);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'n' was not declared in this scope
   15 |         while(i<n && s[i] == 'W') i++;
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int solve(string S){
    int sum=0;
    bool flag=1;
    for(int i=0;flag;i++){
        flag=0;
        for(int j=S.size()-1;j>=i+1;j--){
            if(S[j]=='W'&&S[j-1]=='B'){
                swap(S[j],S[j-1]);
                flag=1;
                sum++;
            }
        }
    }
    return sum;
}#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int sum=0,count=0,W=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='W'){
            sum++;
        }
        else{
          break;
        }
    }
    for (int i=sum;i<S.size();i++){
           if(S[i]=='W'){
              W+=i-sum-count;
              count++;
           }
    }
    cout<<W<<endl;
}

int main(){
    string S;
    cin>>S;
    cout<<solve(S)<<endl;
}

Compiler output:
a.cc:17:2: error: stray '#' in program
   17 | }#include <bits/stdc++.h>
      |  ^
a.cc:17:3: error: 'include' does not name a type
   17 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:40:5: error: redefinition of 'int main()'
   40 | int main(){
      |     ^~~~
a.cc:19:5: note: 'int main()' previously defined here
   19 | int main(){
      |     ^~~~
Language: C++

int main(int, char**) {
    string in;
    cin >> in;
    int w_count = 0, w_pos = 0;
    for (int i = 0; i < in.length(); i++) {
        if (in[i] == 'W')  {
            w_count++;
            w_pos += i; 
        }
    }
    cout << w_pos - (w_count-1)*w_count/2 << endl;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:2:5: error: 'string' was not declared in this scope
    2 |     string in;
      |     ^~~~~~
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> in;
      |     ^~~
a.cc:3:12: error: 'in' was not declared in this scope; did you mean 'int'?
    3 |     cin >> in;
      |            ^~
      |            int
a.cc:11:5: error: 'cout' was not declared in this scope
   11 |     cout << w_pos - (w_count-1)*w_count/2 << endl;
      |     ^~~~
a.cc:11:46: error: 'endl' was not declared in this scope
   11 |     cout << w_pos - (w_count-1)*w_count/2 << endl;
      |                                              ^~~~
Language: C++

int main(int, char**) {
    string in;
    cin >> in;
    int w_count = 0, w_pos = 0;
    for (int i = 0; i < in.length(); i++) {
        if (in[i] == 'W')  {
            w_count++;
            w_pos += i; 
        }
    }
    cout << w_pos - (w_count+1)*w_count/2 << endl;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:2:5: error: 'string' was not declared in this scope
    2 |     string in;
      |     ^~~~~~
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> in;
      |     ^~~
a.cc:3:12: error: 'in' was not declared in this scope; did you mean 'int'?
    3 |     cin >> in;
      |            ^~
      |            int
a.cc:11:5: error: 'cout' was not declared in this scope
   11 |     cout << w_pos - (w_count+1)*w_count/2 << endl;
      |     ^~~~
a.cc:11:46: error: 'endl' was not declared in this scope
   11 |     cout << w_pos - (w_count+1)*w_count/2 << endl;
      |                                              ^~~~
Language: C++

    std::string str;
    std::cin >> str;

    int num_of_W = 0;
    int sum_of_W = 0;
    for(int i=0; i<str.length(); i++){
        if(str[i] == 'W'){
            num_of_W++;
            sum_of_W += i;
        }
    }

    std::cout << sum_of_W - (num_of_W-1)*num_of_W/2 << std::endl;

Compiler output:
a.cc:1:10: error: 'string' in namespace 'std' does not name a type
    1 |     std::string str;
      |          ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 |     std::string str;
a.cc:2:10: error: 'cin' in namespace 'std' does not name a type
    2 |     std::cin >> str;
      |          ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 |     std::string str;
a.cc:6:5: error: expected unqualified-id before 'for'
    6 |     for(int i=0; i<str.length(); i++){
      |     ^~~
a.cc:6:18: error: 'i' does not name a type
    6 |     for(int i=0; i<str.length(); i++){
      |                  ^
a.cc:6:34: error: 'i' does not name a type
    6 |     for(int i=0; i<str.length(); i++){
      |                                  ^
a.cc:13:10: error: 'cout' in namespace 'std' does not name a type
   13 |     std::cout << sum_of_W - (num_of_W-1)*num_of_W/2 << std::endl;
      |          ^~~~
a.cc:13:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   13 |     std::cout << sum_of_W - (num_of_W-1)*num_of_W/2 << std::endl;
      |     ^~~
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <time.h>     
using namespace std;
typedef long long int ll;
char S_c[1000000];

  scanf("%s", S_c);
  size_t N = sizeof(S_c) / sizeof(S_c[0]);
  string S(S_c, N);
  vector<int> black_left{0};
  for (int i = 1; i < N; i++) {
    if (S[i - 1] == 'B') {
      black_left.push_back(black_left[i-1]+1);
    }else{
      black_left.push_back(black_left[i-1]);
    }
  }
  ll ans=0;
  for (int i = 1; i < N; i++) {
    if (S[i] == 'W') {
      ans+=black_left[i];
    }
  }
  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc:13:8: error: expected constructor, destructor, or type conversion before '(' token
   13 |   scanf("%s", S_c);
      |        ^
a.cc:17:3: error: expected unqualified-id before 'for'
   17 |   for (int i = 1; i < N; i++) {
      |   ^~~
a.cc:17:19: error: 'i' does not name a type
   17 |   for (int i = 1; i < N; i++) {
      |                   ^
a.cc:17:26: error: 'i' does not name a type
   17 |   for (int i = 1; i < N; i++) {
      |                          ^
a.cc:25:3: error: expected unqualified-id before 'for'
   25 |   for (int i = 1; i < N; i++) {
      |   ^~~
a.cc:25:19: error: 'i' does not name a type
   25 |   for (int i = 1; i < N; i++) {
      |                   ^
a.cc:25:26: error: 'i' does not name a type
   25 |   for (int i = 1; i < N; i++) {
      |                          ^
a.cc:30:3: error: 'cout' does not name a type
   30 |   cout << ans << endl;
      |   ^~~~
a.cc:32:3: error: expected unqualified-id before 'return'
   32 |   return 0;
      |   ^~~~~~
a.cc:33:1: error: expected declaration before '}' token
   33 | }
      | ^
Language: C

#include <stdio.h>
#include <string.h>
int main() {
  char str[300000];
  char ans[300000];
  scanf("%s",str);
  int size = strlen(str);
  int answer = 0;

  int i;
  int count = 0;

  for (i = 0; i < size; ++i) {
    if (str[i] == 'B') {
      count += 1;
      ans[i] = 0;
    } else if (str[i] == 'W')
      ans[i] = count;
    }
  }

  for (i = 0; i < size; ++i) {
    answer += ans[i];
  }

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

Compiler output:
main.c:22:3: error: expected identifier or '(' before 'for'
   22 |   for (i = 0; i < size; ++i) {
      |   ^~~
main.c:22:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   22 |   for (i = 0; i < size; ++i) {
      |                 ^
main.c:22:25: error: expected identifier or '(' before '++' token
   22 |   for (i = 0; i < size; ++i) {
      |                         ^~
main.c:26:10: error: expected declaration specifiers or '...' before string constant
   26 |   printf("%d\n",answer);
      |          ^~~~~~
main.c:26:17: error: unknown type name 'answer'
   26 |   printf("%d\n",answer);
      |                 ^~~~~~
main.c:27:3: error: expected identifier or '(' before 'return'
   27 |   return 0;
      |   ^~~~~~
main.c:28:1: error: expected identifier or '(' before '}' token
   28 | }
      | ^