Language: C++

#include <iostream>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
/*
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
/*
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
*//* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  int cnt = 0;
  for (int i = s.size(); i >= 0; i--){
    if (s[i] == 'B') cnt++;
    else if (cnt){
      s[i] = 'B';
      cnt--;
    }
  }

  REP(i, s.size()) if (s[i] != 'B') cout << s[i];
  cout << endl;

  return (0);
}



Compiler output:
a.cc: In function 'int main()':
a.cc:61:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   61 |   cin.tie(0);
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:62:3: error: 'ios' has not been declared
   62 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:64:3: error: 'string' was not declared in this scope
   64 |   string s;
      |   ^~~~~~
a.cc:64: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:
/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:65:10: error: 's' was not declared in this scope
   65 |   cin >> s;
      |          ^
a.cc:76:7: error: 'i' was not declared in this scope
   76 |   REP(i, s.size()) if (s[i] != 'B') cout << s[i];
      |       ^
a.cc:76:3: error: 'REP' was not declared in this scope
   76 |   REP(i, s.size()) if (s[i] != 'B') cout << s[i];
      |   ^~~
a.cc:77:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   77 |   cout << 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:77:11: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   77 |   cout << endl;
      |           ^~~~
      |           std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~