prithivMLmods/Coder-Stat huggingface dataset:
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      ans = ans + "1";
    }
    if (s[i] == '0') {
      ans = ans + "0";
    }
    if (s[i] == 'B') {
      ans.pop_back();
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      ans = ans + "1";
    }
    if (s[i] == '0') {
      ans = ans + "0";
    }
    if (s[i] == 'B' && ans.size() != 0) {
      ans.pop_back();
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
// #include <stdio.h>
using namespace std;

int main() {
  string S;

  cin >> S;
  list<char> ans;
  for (int i = 0; i < S.size(); i++) {

    if (S[i] == '1' or S[i] == '0') {
      ans.push_back(S[i]);
    }

    else if (S[i] == 'B') {

      ans.pop_back();
    }
  }

  list<char>::iterator itr;

  for (itr = ans.begin(); itr != ans.end(); ++itr) {
    std::cout << *itr;
  }

  return 0;
}

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
// #include <stdio.h>
using namespace std;

int main() {
  string S;

  cin >> S;
  list<char> ans;
  for (int i = 0; i < S.size(); i++) {

    if (S[i] == '1' or S[i] == '0') {
      ans.push_back(S[i]);
    }

    else if (S[i] == 'B' && ans.size() >= 1) {

      ans.pop_back();
    }
  }

  list<char>::iterator itr;

  for (itr = ans.begin(); itr != ans.end(); ++itr) {
    std::cout << *itr;
  }

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
struct edge {
  ll to, cost;
};

static const double EPS = 1e-8;
static const double PI = 3.141592653589;
static ll INF = 999999999999;
int mod = 1000000007;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define MP(a, b) make_pair((a), (b))
#define ABS(a) ((a) > 0 ? (a) : -(a))
#define MIN(a, b) (a) < (b) ? (a) : (b)
#define MAX(a, b) (a) > (b) ? (a) : (b)
#define debug(x) cerr << #x << " = " << x << endl;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};

using namespace std;

int main() {
  string ans;
  cin >> ans;
  string hen = "";

  REP(i, ans.size()) {
    if (ans[i] == '1') {
      hen = hen + '1';
    } else if (ans[i] == '0') {
      hen = hen + '0';
    } else {
      hen.erase(hen.size() - 1);
    }
  }

  cout << hen << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
struct edge {
  ll to, cost;
};

static const double EPS = 1e-8;
static const double PI = 3.141592653589;
static ll INF = 999999999999;
int mod = 1000000007;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define MP(a, b) make_pair((a), (b))
#define ABS(a) ((a) > 0 ? (a) : -(a))
#define MIN(a, b) (a) < (b) ? (a) : (b)
#define MAX(a, b) (a) > (b) ? (a) : (b)
#define debug(x) cerr << #x << " = " << x << endl;
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};

using namespace std;

int main() {
  string ans;
  cin >> ans;
  string hen = "";

  REP(i, ans.size()) {
    if (ans[i] == '1') {
      hen = hen + '1';
    } else if (ans[i] == '0') {
      hen = hen + '0';
    } else {
      if (hen.size() != 0)
        hen.erase(hen.size() - 1);
    }
  }

  cout << hen << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, ans = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B' && s.size() != 0)
      ans.pop_back();
    else if (s[i] == '0')
      ans.push_back('0');
    else if (s[i] == '1')
      ans.push_back('1');
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, ans = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B' && ans.size() != 0)
      ans.pop_back();
    else if (s[i] == '0')
      ans.push_back('0');
    else if (s[i] == '1')
      ans.push_back('1');
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d", &x);
int main() {
  string s, ans;
  cin >> s;
  int len = s.size();
  REP(i, len) {
    if (s[i] == '0')
      ans += '0';
    else if (s[i] == '1')
      ans += '1';
    else
      ans.erase(ans.size() - 1);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d", &x);
int main() {
  string s, ans;
  cin >> s;
  int len = s.size();
  REP(i, len) {
    if (s[i] == '0')
      ans += '0';
    else if (s[i] == '1')
      ans += '1';
    else if (ans.size() > 0)
      ans.erase(ans.size() - 1);
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>

using namespace std;

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

  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      ans.push_back('0');
    if (s[i] == '1')
      ans.push_back('1');
    if (s[i] == 'B' && !s.empty())
      ans.pop_back();
  }

  cout << ans << endl;
}


Fixed submission:
#include <iostream>
#include <string>

using namespace std;

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

  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      ans.push_back('0');
    if (s[i] == '1')
      ans.push_back('1');
    if (s[i] == 'B' && !ans.empty())
      ans.pop_back();
  }

  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>

using namespace std;

int main() {

  string s;
  cin >> s;

  string a = "";

  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B') {
      a += s[i];
    } else {
      if (!a.empty()) {
        a.erase(i - 1);
      }
    }
  }

  cout << a << endl;

  return 0;
}


Fixed submission:
#include <iostream>
#include <string>

using namespace std;

int main() {

  string s;
  cin >> s;

  string a = "";

  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B') {
      a += s[i];
    } else {
      if (!a.empty()) {
        a.erase(a.size() - 1);
      }
    }
  }

  cout << a << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  string str;
  cin >> str;
  int length = str.length();
  string ans(10, '5');
  int t = 0;
  int i;
  for (i = 0; i < length; i++) {
    if (str[i] == 'B') {
      if (t != 0) {
        t--;
      }
      ans[t] = 'm';

    } else if (str[i] == '0') {
      ans[t] = '0';
      t++;

    } else if (str[i] == '1') {
      ans[t] = '1';
      t++;
    }
  }

  for (i = 0; ans[i] != '5'; i++) {
    if (ans[i] == 'm') {
      continue;
    }
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  string str;
  cin >> str;
  int length = str.length();
  string ans(11, '5');
  int t = 0;
  int i;
  for (i = 0; i < length; i++) {
    if (str[i] == 'B') {
      if (t != 0) {
        t--;
      }
      ans[t] = 'm';

    } else if (str[i] == '0') {
      ans[t] = '0';
      t++;

    } else if (str[i] == '1') {
      ans[t] = '1';
      t++;
    }
  }

  for (i = 0; ans[i] != '5'; i++) {
    if (ans[i] == 'm') {
      continue;
    }
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

signed main(void) {
  string s, ans;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == 'B') {
      ans.pop_back();
    } else if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    }
  }
  cout << ans << endl;
  return 0;
}


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

signed main(void) {
  string s, ans;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == 'B') {
      ans = ans.substr(0, ans.size() - 1);
    } else if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <string>

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for (int i = 0; i < n; ++i)
long long H, W, K, N, D;
long long A = 0;
int main() {
  string a;
  int l = 0, c = 0;
  vector<int> s;
  cin >> a;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '0')
      s.push_back(0);
    if (a[i] == '1')
      s.push_back(1);
    if (a[i] == 'B')
      s.pop_back();
  }
  REP(i, s.size()) cout << s[i];

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <string>

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for (int i = 0; i < n; ++i)
long long H, W, K, N, D;
long long A = 0;
int main() {
  string a;
  int l = 0, c = 0;
  vector<int> s;
  cin >> a;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == '0')
      s.push_back(0);
    if (a[i] == '1')
      s.push_back(1);
    if (a[i] == 'B')
      if (!s.empty())
        s.pop_back();
  }
  REP(i, s.size()) cout << s[i];

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string in;
  string ans;

  cin >> in;

  for (int i = 0; i < in.size(); i++) {
    if (in.substr(i, 1) == "0")
      ans += "0";
    else if (in.substr(i, 1) == "1")
      ans += "1";
    else if (in.substr(i, 1) == "B" && ans.empty() == 0) {
      ans.erase(i - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string in;
  string ans;

  cin >> in;

  for (int i = 0; i < in.size(); i++) {
    if (in[i] == '0')
      ans += '0';
    else if (in[i] == '1')
      ans += '1';
    else if (in[i] == 'B' && ans.empty() == 0) {
      ans.pop_back();
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll MOD = (1e9 + 7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll factorial(ll n, ll m = 2) {
  // calculate nPm
  m = max(2LL, m);
  ll rtn = 1;
  for (ll i = m; i <= n; i++) {
    rtn = (rtn * i) % MOD;
  }
  return rtn;
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  string ans = "";
  rep(i, s.size()) {
    if (s[i] == 'B') {
      if (ans.size() == 0)
        continue;
      else
        ans.erase(i - 1);
    } else {
      ans += s[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll MOD = (1e9 + 7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll factorial(ll n, ll m = 2) {
  // calculate nPm
  m = max(2LL, m);
  ll rtn = 1;
  for (ll i = m; i <= n; i++) {
    rtn = (rtn * i) % MOD;
  }
  return rtn;
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  string ans = "";
  rep(i, s.size()) {
    if (s[i] == 'B') {
      if (ans != "")
        ans.pop_back();
    } else {
      ans += s[i];
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

string s, sol;

int main() {
  cin >> s;
  int len = s.size();
  for (int i = 0; i < len; i++) {
    if (s[i] != 'B')
      sol += s[i];
    else
      sol.pop_back();
  }
  cout << sol;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

string s, sol;

int main() {
  cin >> s;
  int len = s.size();
  for (int i = 0; i < len; i++) {
    if (s[i] != 'B')
      sol += s[i];
    else if (!sol.empty())
      sol.pop_back();
  }
  cout << sol;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <cmath>
using namespace std;

int main() {

  string s;

  cin >> s;

  string out;

  for (auto a : s) {

    if (a == '0' || a == '1') {
      out.push_back(a);
    } else {
      out.pop_back();
    }
  }

  cout << out << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <cmath>
using namespace std;

int main() {

  string s;

  cin >> s;

  string out;

  for (auto a : s) {

    if (a == '0' || a == '1') {
      out.push_back(a);
    } else {
      if (out.size() == 0)
        continue;
      out.pop_back();
    }
  }

  cout << out << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

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

  std::vector<int> v;
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == '0')
      v.push_back(0);
    else if (s[i] == '1')
      v.push_back(1);
    else
      v.pop_back();
  }
  for (int i = 0; i < (int)v.size(); i++)
    cout << v[i];
  cout << endl;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

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

  std::vector<int> v;
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == '0')
      v.push_back(0);
    else if (s[i] == '1')
      v.push_back(1);
    else if (v.size() > 0)
      v.pop_back();
  }
  for (int i = 0; i < (int)v.size(); i++)
    cout << v[i];
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

// create arrays outside of main()
int N = 10;
int steps[100] = {};

string input;
stack<char> s;
stack<char> d;

int main() {

  cin >> input;

  for (int i = 0; i < input.length(); i++) {
    if (input[i] == '0' || input[i] == '1') {
      s.push(input[i]);
    } else if (input[i] == 'B') {
      if (!s.empty()) {
        s.pop();
      }
    }
  }

  while (!s.empty()) {
    d.push(s.top());
    s.pop();
  }

  while (!d.empty()) {
    cout << d.top();
  }

  return 0;
}

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

// create arrays outside of main()
int N = 10;
int steps[100] = {};

string input;
stack<char> s;
stack<char> d;

int main() {

  cin >> input;

  for (int i = 0; i < input.length(); i++) {
    if (input[i] == '0' || input[i] == '1') {
      s.push(input[i]);
    } else if (input[i] == 'B') {
      if (!s.empty()) {
        s.pop();
      }
    }
  }

  while (!s.empty()) {
    d.push(s.top());
    s.pop();
  }

  while (!d.empty()) {
    cout << d.top();
    d.pop();
  }

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, ans;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (!s.empty() && s[i] == 'B') {
      ans.pop_back();
    } else {
      ans += s[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, ans;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'B') {
      if (!ans.empty())
        ans.pop_back();
    } else {
      ans += s[i];
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  string ans;
  cin >> s;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else {
      if (!ans.empty())
        ans.erase(i - 1);
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  string ans;
  cin >> s;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else {
      if (!ans.empty()) {
        ans.erase(ans.end() - 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans;
  REP(i, s.size()) {
    if (s[i] == 'B') {
      if (!ans.empty())
        ans.pop_back();
    } else {
      ans += s[i];
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <math.h>
#include <unordered_map>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main() {
  string S;

  cin >> S;

  string codes;

  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'B') {
      codes.pop_back();
    } else {
      codes.push_back(S[i]);
    }
  }

  cout << codes << endl;
}


Fixed submission:
#include <iostream>
#include <math.h>
#include <unordered_map>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main() {
  string S;

  cin >> S;

  string codes;

  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'B') {
      if (codes.length() != 0) {
        codes.pop_back();
      }
    } else {
      codes.push_back(S[i]);
    }
  }

  cout << codes << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B')
      ans += s[i];
    else {
      if (i > 0)
        ans.erase(ans.size() - 1);
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B')
      ans += s[i];
    else {
      if (ans.size())
        ans.erase(ans.size() - 1);
    }
  }
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

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

  int size = s.size();
  string ans;

  for (int i = 0; i < size; i++) {
    if (s[i] != 'B') {
      ans += s[i];
    } else if (s[i] == 'B') {
      ans.pop_back();
    }
  }

  size = ans.size();

  for (int i = 0; i < size; i++)
    cout << ans[i];

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

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

  int size = s.size();
  string ans;

  for (int i = 0; i < size; i++) {
    if (s[i] != 'B') {
      ans += s[i];
    } else if (s[i] == 'B') {
      if (ans.size() > 0) {
        ans.pop_back();
      }
    }
  }

  size = ans.size();

  for (int i = 0; i < size; i++)
    cout << ans[i];

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

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

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    switch (s[i]) {
    case '0':
      ans += "0";
      break;
    case '1':
      ans += "1";
      break;
    case 'B':
      ans.pop_back();
      break;
    default:
      break;
    }
  }
  cout << ans << endl;
}


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

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

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    switch (s[i]) {
    case '0':
      ans += "0";
      break;
    case '1':
      ans += "1";
      break;
    case 'B':
      if (!ans.empty()) {
        ans.pop_back();
      }
      break;
    default:
      break;
    }
  }
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define ALL(x) (x).begin(), (x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  deque<char> D;
  for (int i = 0; i < N; i++) {
    if (S[i] == '0' || S[i] == '1') {
      D.push_back(S[i]);
    } else {
      D.pop_back();
    }
  }
  while (!D.empty()) {
    cout << D.front();
    D.pop_front();
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define ALL(x) (x).begin(), (x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  deque<char> D;
  for (int i = 0; i < N; i++) {
    if (S[i] == '0' || S[i] == '1') {
      D.push_back(S[i]);
    } else {
      if (D.empty()) {
        continue;
      } else {
        D.pop_back();
      }
    }
  }
  while (!D.empty()) {
    cout << D.front();
    D.pop_front();
  }
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<char> ans;
  for (int unsigned i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      ans.pop_back();
      continue;
    }
    ans.emplace_back(s[i]);
  }
  for (int unsigned i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<char> ans;
  for (int unsigned i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      if (ans.size())
        ans.pop_back();
      continue;
    }
    ans.emplace_back(s[i]);
  }
  for (int unsigned i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>

int main() {

  std::string inputString;
  std::cin >> inputString;

  std::vector<char> charVec;

  for (char &c : inputString) {
    if (c == '0' || c == '1') {
      charVec.push_back(c);
    } else {
      charVec.pop_back();
    }
  }

  for (char &d : charVec) {
    std::cout << d;
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>

int main() {

  std::string inputString;
  std::cin >> inputString;

  std::vector<char> charVec;

  for (char &c : inputString) {
    if (c == '0' || c == '1') {
      charVec.push_back(c);
    } else {
      if (charVec.size() == 0) {
        continue;
      } else {
        charVec.pop_back();
      }
    }
  }

  for (char &d : charVec) {
    std::cout << d;
  }

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s, ans;
  cin >> s;

  for (char x : s) {
    if (x == '0')
      ans += "0";
    if (x == '1')
      ans += "1";
    if (x == 'B')
      ans.pop_back();
  }

  cout << ans << endl;
}

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

int main() {
  string s, ans;
  cin >> s;

  for (char x : s) {
    if (x == '0')
      ans += "0";
    if (x == '1')
      ans += "1";
    if (x == 'B' && !ans.empty())
      ans.pop_back();
  }

  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll INF = 1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  cin >> s;
  stack<char> a;
  int n = s.size();
  rep(i, 0, n) {
    if (s[i] == 'B') {
      a.pop();
    } else {
      a.push(s[i]);
    }
  }
  string ans = "";
  while (a.size() > 0) {
    ans += a.top();
    a.pop();
  }
  reverse(all(ans));
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll INF = 1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  cin >> s;
  stack<char> a;
  int n = s.size();
  rep(i, 0, n) {
    if (s[i] == 'B') {
      if (a.size() != 0)
        a.pop();

    } else {
      a.push(s[i]);
    }
  }
  string ans = "";
  while (a.size() > 0) {
    ans += a.top();
    a.pop();
  }
  reverse(all(ans));
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

void PrintStack(stack<int> s) {
  if (s.empty()) {
    return;
  }
  int x = s.top();
  s.pop();
  PrintStack(s);
  cout << x;
  s.push(x);
}

int main() {
  string x;
  stack<int> v;
  cin >> x;
  for (int i = 0; i < x.size(); i++) {
    if (x[i] == 'B') {
      v.pop();
    } else if (x[i] == '0') {
      v.push(0);
    } else if (x[i] == '1') {
      v.push(1);
    }
  }

  PrintStack(v);
}

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

void PrintStack(stack<int> s) {
  if (s.empty()) {
    return;
  }
  int x = s.top();
  s.pop();
  PrintStack(s);
  cout << x;
  s.push(x);
}

int main() {
  string x;
  stack<int> v;
  cin >> x;
  for (int i = 0; i < x.size(); i++) {
    if (x[i] == 'B') {
      if (v.size()) {
        v.pop();
      }
    } else if (x[i] == '0') {
      v.push(0);
    } else if (x[i] == '1') {
      v.push(1);
    }
  }

  PrintStack(v);
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  string s, s1 = "";
  cin >> s;

  for (int i = 0; i < s.length(); i++) {
    switch (s[i]) {

    case '0':
      s1 += '0';
      break;
    case '1':
      s1 += '1';
      break;
    case 'B':
      s1.erase(s1.length() - 1, 1);
      break;
    }
  }

  cout << s1 << "\n";

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  string s, s1 = "";
  cin >> s;

  for (int i = 0; i < s.length(); i++) {
    switch (s[i]) {

    case '0':
      s1 += '0';
      break;
    case '1':
      s1 += '1';
      break;
    case 'B':
      if (s1 != "") {
        s1.erase(s1.length() - 1, 1);
      }

      break;
    }
  }

  cout << s1 << "\n";

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  string res;
  for (char c : s) {
    if (c == 'B') {
      res.pop_back();
    } else {
      res += c;
    }
  }
  cout << res << '\n';
}

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

int main() {
  string s;
  cin >> s;
  string res;
  for (char c : s) {
    if (c == 'B') {
      if (not res.empty()) {
        res.pop_back();
      }
    } else {
      res += c;
    }
  }
  cout << res << '\n';
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, h;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '0')
      h += "0";
    else if (s[i] == '1')
      h += "1";
    else
      h.erase(--h.end());
  }

  cout << h << endl;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, h;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '0')
      h += "0";
    else if (s[i] == '1')
      h += "1";
    else if (s[i] == 'B' && h.length() != 0)
      h.erase(--h.end());
  }

  cout << h << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  string a, b = "", c = "0", d = "1", e = "b";
  cin >> a;

  for (int i = 0; i < a.size(); i++) {
    a[i] == c[0]   ? b += "0"
    : a[i] == d[0] ? b += "1"
                   : b = b.erase(b.size() - 1);
  }
  cout << b << endl;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  string a, b = "", c = "0", d = "1", e = "b";
  cin >> a;

  for (int i = 0; i < a.size(); i++) {
    a[i] == c[0]   ? b += "0"
    : a[i] == d[0] ? b += "1"
    : b.size() > 0 ? b = b.erase(b.size() - 1)
                   : a = a;
  }
  cout << b << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#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++)
typedef long long ll;

int main() {
  vector<char> ans;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0' || s[i] == '1') {
      ans.push_back(s[i]);
    } else {
      ans.pop_back();
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;
}


Fixed submission:
#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++)
typedef long long ll;

int main() {
  vector<char> ans;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0' || s[i] == '1') {
      ans.push_back(s[i]);
    } else if (ans.size() > 0) {
      ans.pop_back();
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define ll long long
using namespace std;

int main() {
  string s;
  cin >> s;
  vector<char> x(s.size());
  for (ll i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      x[i] = '0';
    } else if (s[i] == '1') {
      x[i] = '1';
    } else {
      x[i - 1] = ' ';
      x[i] = ' ';
    }
  }
  for (ll i = 00; i < s.size(); i++) {
    if (x[i] != ' ') {
      cout << x[i];
    }
  }
  cout << endl;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define ll long long
using namespace std;

int main() {
  string s;
  cin >> s;
  vector<char> x(s.size());
  for (ll i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      x[i] = '0';
    } else if (s[i] == '1') {
      x[i] = '1';
    } else {
      if (i > 0) {
        for (ll j = i - 1; j >= 0; j--) {
          if (x[j] != ' ') {
            x[j] = ' ';
            x[i] = ' ';
            break;
          }
        }
      }

      x[i] = ' ';
    }
  }
  for (ll i = 00; i < s.size(); i++) {
    if (x[i] != ' ') {
      cout << x[i];
    }
  }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9 + 7
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // input
  string s;
  cin >> s;
  int sz = s.size();
  int i;
  deque<char> a;
  for (i = 0; i < sz; i++) {
    if (s.at(i) == '0') {
      a.pb('0');
    } else if (s.at(i) == '1') {
      a.pb('1');
    } else {
      a.pop_back();
    }
  }
  // caricurate
  // output
  while (!a.empty()) {
    cout << a.front();
    a.pop_front();
  }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9 + 7
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // input
  string s;
  cin >> s;
  int sz = s.size();
  int i;
  deque<char> a;
  for (i = 0; i < sz; i++) {
    if (s.at(i) == '0') {
      a.pb('0');
    } else if (s.at(i) == '1') {
      a.pb('1');
    } else {
      if (!a.empty()) {
        a.pop_back();
      }
    }
  }
  // caricurate
  // output
  while (!a.empty()) {
    cout << a.front();
    a.pop_front();
  }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans;
  ans.clear();

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else {
      string tmp = ans;
      ans.clear();
      for (int j = 0; j < tmp.size() - 1; j++) {
        ans += tmp[j];
      }
    }
  }

  cout << ans;

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  string ans;
  ans.clear();

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else {
      if (ans.size() == 0)
        continue;
      string tmp = ans;
      ans.clear();
      for (int j = 0; j < tmp.size() - 1; j++) {
        ans += tmp[j];
      }
    }
  }

  cout << ans;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;
#define loop(i, n) for (int i = 0; i < (n); i++)
#define loops(i, f, n) for (int i = (f); i < (n); i++)
#define INF 9999999

int main() {
  vector<char> ans;
  string s;
  cin >> s;
  loop(i, s.size()) {
    if (s[i] == '0')
      ans.push_back('0');
    else if (s[i] == '1')
      ans.push_back('1');
    else
      ans.pop_back();
  }
  loop(i, ans.size()) { cout << ans[i]; }
  cout << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;
#define loop(i, n) for (int i = 0; i < (n); i++)
#define loops(i, f, n) for (int i = (f); i < (n); i++)
#define INF 9999999

int main() {
  vector<char> ans;
  string s;
  cin >> s;
  loop(i, s.size()) {
    if (s[i] == '0')
      ans.push_back('0');
    else if (s[i] == '1')
      ans.push_back('1');
    else {
      if (ans.size())
        ans.pop_back();
      else
        continue;
    }
  }
  loop(i, ans.size()) { cout << ans[i]; }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string a;
  string b;
  cin >> b;
  for (int i = 0; i < b.size(); i++) {
    if (b[i] != 'B') {

      a += b[i];
    } else if (b[i] == 'B') {
      a.pop_back();
    }
  }
  cout << a << "\n";
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string a;
  string b;
  cin >> b;
  for (int i = 0; i < b.size(); i++) {
    if (b[i] != 'B') {

      a += b[i];
    } else if (b[i] == 'B' && a.size()) {
      a.pop_back();
    }
  }
  cout << a << "\n";
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    switch (s[i]) {
    case '0':
      ans += '0';
      break;
    case '1':
      ans += '1';
      break;
    default:
      ans.pop_back();
      break;
    }
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    switch (s[i]) {
    case '0':
      ans += '0';
      break;
    case '1':
      ans += '1';
      break;
    default:
      if (!ans.empty()) {
        ans.pop_back();
      }
      break;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0')
      ans += '0';
    if (s.at(i) == '1')
      ans += '1';
    else {
      if (s != "")
        ans.pop_back();
    }
  }
  cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0')
      ans += '0';
    if (s.at(i) == '1')
      ans += '1';
    if (s.at(i) == 'B' && ans != "")
      ans.pop_back();
  }
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, ans = "";
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B') {
      ans.push_back(s[i]);
    } else {
      if (s.size() > 0) {
        ans.pop_back();
      }
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, ans = "";
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B') {
      ans.push_back(s[i]);
    } else {
      if (ans.size() > 0) {
        ans.pop_back();
      }
    }
  }

  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  string input;
  vector<int> output(0);
  cin >> input;

  for (int i = 0; i < input.size(); i++) {
    switch (input.at(i)) {
    case '0':
      output.push_back(0);
      break;
    case '1':
      output.push_back(1);
      break;
    case 'B':
      output.pop_back();
      break;
    }
  }
  for (int i : output)
    cout << i;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  string input;
  vector<int> output(0);
  cin >> input;

  for (int i = 0; i < input.size(); i++) {
    switch (input.at(i)) {
    case '0':
      output.push_back(0);
      break;
    case '1':
      output.push_back(1);
      break;
    case 'B':
      if (output.empty())
        ;
      else
        output.pop_back();
      break;
    }
  }
  for (int i : output)
    cout << i;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {

  char a[10];
  vector<char> b;

  cin >> a;

  for (int i = 0; i <= 9; i++) {
    if (a[i] == '0') {
      b.push_back('0');
    }
    if (a[i] == '1') {
      b.push_back('1');
    }

    if (a[i] == 'B') {
      if (i > 0) {
        b.pop_back();
      }
    }
  }
  for (int i = 0; i < b.size(); i++) {
    cout << b[i];
  }
  cout << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {

  char a[10];
  vector<char> b;

  cin >> a;

  for (int i = 0; i <= 9; i++) {
    if (a[i] == '0') {
      b.push_back('0');
    }
    if (a[i] == '1') {
      b.push_back('1');
    }

    if (a[i] == 'B') {
      if (i > 0 && b.size() > 0) {
        b.pop_back();
      }
    }
  }
  for (int i = 0; i < b.size(); i++) {
    cout << b[i];
  }
  cout << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

void insert(string &text, char ch) { text += ch; }
void backkey(string &text) { text.pop_back(); }

void edit(string &text, char ch) {
  if (ch == 'B')
    backkey(text);
  else
    insert(text, ch);
}

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

  for (auto s : S) {
    edit(ans, s);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;

void insert(string &text, char ch) { text += ch; }
void backkey(string &text) {
  if (text.length() == 0)
    return;
  text.pop_back();
}

void edit(string &text, char ch) {
  if (ch == 'B')
    backkey(text);
  else
    insert(text, ch);
}

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

  for (auto s : S) {
    edit(ans, s);
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

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

  string ans = "";

  REP(i, s.size()) {
    if (s[i] == '0')
      ans += '0';
    else if (s[i] == '1')
      ans += '1';
    else if (s[i] == 'B')
      ans.pop_back();
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

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

  string ans = "";

  REP(i, s.size()) {
    if (s[i] == '0')
      ans += '0';
    else if (s[i] == '1')
      ans += '1';
    else if (s[i] == 'B') {
      if (ans.size() > 0)
        ans.pop_back();
    }
  }
  cout << ans << endl;
  return 0;
}