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

Buggy submission (status: Runtime Error):
// atc.cpp : This file contains the 'main' function. Program execution begins
// and ends there.
//

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

int main() {
  string s, o;

  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    char c;
    c = s[i];
    switch (c) {
    case '0':
      o.push_back('0');
      break;
    case '1':
      o.push_back('1');
      break;

    case 'B':
      if (o.size() > 0) {
        o.erase(i - 1);
      }
      break;
    default:
      break;
    }
  }

  cout << o;

  return 0;
}


Fixed submission:
// atc.cpp : This file contains the 'main' function. Program execution begins
// and ends there.
//

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

int main() {
  string s, o;

  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    char c;
    c = s[i];
    switch (c) {
    case '0':
      o.push_back('0');
      break;
    case '1':
      o.push_back('1');
      break;

    case 'B':
      if (o.size() > 0) {
        o.erase(o.size() - 1);
      }
      break;
    default:
      break;
    }
  }

  cout << o;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

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
      ans.pop_back();
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

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 (!ans.empty())
        ans.pop_back();
    }
  }
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ll long long int
#define ld long double

using namespace std;

int main() {
  fastio;

  string a, b;
  cin >> a;

  for (ll i = 0; i < a.length(); i++) {
    if (a[i] == '0')
      b.push_back('0');
    else if (a[i] == '1')
      b.push_back('1');
    else if (a[i] == 'B')
      b.pop_back();
  }

  cout << b;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define ll long long int
#define ld long double

using namespace std;

int main() {
  fastio;

  string a, b;
  cin >> a;

  for (ll i = 0; i < a.length(); i++) {
    if (a[i] == '0')
      b.push_back('0');
    else if (a[i] == '1')
      b.push_back('1');
    else if (a[i] == 'B')
      if (b.size() != 0)
        b.pop_back();
  }

  cout << b;

  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] == '0')
      ans += "0";
    else if (s[i] == '1')
      ans += "1";
    else if (s[i] == 'B') {
      if (!ans.empty())
        ans.erase(i - 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] == '0')
      ans += "0";
    else if (s[i] == '1')
      ans += "1";
    else if (s[i] == 'B') {
      if (!ans.empty())
        ans.pop_back();
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p04030 (C++)

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

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map

int main() {
  string s;
  cin >> s;
  deque<char> q;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B')
      q.pop_back();
    else
      q.push_back(s[i]);
  }
  while (!q.empty()) {
    cout << q.front();
    q.pop_front();
  }
  cout << endl;
}

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

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map

int main() {
  string s;
  cin >> s;
  deque<char> q;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B') {
      if (!q.empty())
        q.pop_back();
    } else
      q.push_back(s[i]);
  }
  while (!q.empty()) {
    cout << q.front();
    q.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;

  char char0 = '0', char1 = '1';
  string ans = "";

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

  cout << ans << endl;
}


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

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

  char char0 = '0', char1 = '1';
  string ans = "";

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

  cout << ans << 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 X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

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


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

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

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

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

using namespace std;

#define rep(i, x) for (int i = 0; i < x; ++i)

int main() {
  vector<char> S;
  string s;
  cin >> s;
  rep(i, s.size()) {
    char c = s[i];
    if (c == 'B')
      S.pop_back();
    else
      S.push_back(c);
  }
  rep(i, S.size()) cout << S[i];
  cout << endl;
}


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

using namespace std;

#define rep(i, x) for (int i = 0; i < x; ++i)

int main() {
  vector<char> S;
  string s;
  cin >> s;
  rep(i, s.size()) {
    char c = s[i];
    if (c == 'B') {
      if (S.size())
        S.pop_back();
    } else
      S.push_back(c);
  }
  rep(i, S.size()) cout << S[i];
  cout << endl;
}
Problem p04030 (C++)

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

using namespace std;

typedef int in;
#define int long long

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


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

using namespace std;

typedef int in;
#define int long long

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

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

int main() {
  vector<char> b;

  string keys;
  cin >> keys;

  for (char cmd : keys) { // for each key pressed
    switch (cmd) {
    case '0':
      b.push_back('0');
      break;
    case '1':
      b.push_back('1');
      break;
    case 'B':
      b.pop_back();
      break;
    }
  }

  string output(b.begin(), b.end());
  cout << output;

  return 0;
}

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

int main() {
  vector<char> b;

  string keys;
  cin >> keys;

  for (char cmd : keys) { // for each key pressed
    switch (cmd) {
    case '0':
      b.push_back('0');
      break;
    case '1':
      b.push_back('1');
      break;
    case 'B':
      if (!b.empty()) {
        b.pop_back();
        break;
      }
    }
  }

  string output(b.begin(), b.end());
  cout << output;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;
}
const long long INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  deque<char> deq;
  int ssize = s.size();
  for (int i = 0; i < ssize; i++) {
    if (s.at(i) == 'B')
      deq.pop_back();
    else
      deq.push_back(s.at(i));
  }
  while (deq.size()) {
    cout << deq.front();
    deq.pop_front();
  }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;
}
const long long INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  deque<char> deq;
  int ssize = s.size();
  for (int i = 0; i < ssize; i++) {
    if (s.at(i) == 'B') {
      if (deq.size() > 0)
        deq.pop_back();
    } else
      deq.push_back(s.at(i));
  }
  while (deq.size()) {
    cout << deq.front();
    deq.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 document;

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      document.append("0");
    }
    if (s.at(i) == '1') {
      document.append("1");
    }
    if (s.at(i) == 'B') {
      if (document.empty() == 0)
        document.erase(i - 1, 1);
    }
  }
  cout << document;
}

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

int main() {

  string s;

  cin >> s;

  string document;

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      document.append("0");
    }
    if (s.at(i) == '1') {
      document.append("1");
    }
    if (s.at(i) == 'B') {
      if (document.empty() == 0)
        document.erase(document.end() - 1, document.end());
      else {
      }
    }
  }
  cout << document;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ll long long int
#define ALL(x) x.begin(), x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/

int main() {
  cin >> s;
  n = s.size();
  REP(i, n) {
    if (s[i] == '0') {
      k = 0;
      v.push_back(k);
    } else if (s[i] == '1') {
      k = 1;
      v.push_back(k);
    } else if (s[i] == 'B' && v.size() != 0) {
      k = i - 1;
      v.erase(v.begin() + k);
    }
  }
  REP(i, v.size()) { cout << v[i]; }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ll long long int
#define ALL(x) x.begin(), x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;
/*--------------------template--------------------*/

int main() {
  cin >> s;
  n = s.size();
  REP(i, n) {
    if (s[i] == '0') {
      k = 0;
      v.push_back(k);
    } else if (s[i] == '1') {
      k = 1;
      v.push_back(k);
    } else if (s[i] == 'B' && v.size() != 0) {
      v.pop_back();
    }
  }
  REP(i, v.size()) { cout << v[i]; }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  string s;
  string ans;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0' || s[i] == '1') {
      ans.push_back(s[i]);
    } else {
      if (!s.empty())
        ans.pop_back();
    }
  }

  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  string s;
  string ans;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0' || s[i] == '1') {
      ans.push_back(s[i]);
    } else {
      if (!ans.empty())
        ans.pop_back();
    }
  }

  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 S = "";
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      S = S + '0';
    }

    else if (s.at(i) == '1') {
      S = S + '1';
    }

    else {
      S.pop_back();
    }
  }

  cout << S << endl;
}


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

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

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      S = S + '0';
    }

    else if (s.at(i) == '1') {
      S = S + '1';
    }

    else {

      if (S.size() != 0) {
        S.pop_back();
      }
    }
  }

  cout << S << 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();
  vector<string> vec(1);
  for (int i = 0; i < size; i++) {
    if (s.at(i) == '0') {
      vec.push_back("0");
    } else if (s.at(i) == '1') {
      vec.push_back("1");
    } else {
      if (i == 0)
        continue;
      else {
        vec.pop_back();
      }
    }
  }
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
  }
}


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

int main() {
  string s;
  cin >> s;
  int size = s.size();
  vector<string> vec(15);
  for (int i = 0; i < size; i++) {
    if (s.at(i) == '0') {
      vec.push_back("0");
    } else if (s.at(i) == '1') {
      vec.push_back("1");
    } else {
      if (i == 0)
        continue;
      else {
        vec.pop_back();
      }
    }
  }
  for (int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
  }
}
Problem p04030 (C++)

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

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

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

  cout << t << endl;
}


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

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

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

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

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

int main() {
  string S;
  cin >> S;
  int N;
  N = S.size();
  string ans;

  for (int i = 0; i < N; i++) {
    if (S.at(i) == '0')
      ans += '0';
    else if (S.at(i) == '1')
      ans += '1';
    else if (S.at(i) == 'B') {
      ans.pop_back();
    }
  }
  cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int N;
  N = S.size();
  string ans;

  for (int i = 0; i < N; i++) {
    if (S.at(i) == '0')
      ans += '0';
    else if (S.at(i) == '1')
      ans += '1';
    else if (S.at(i) == 'B' && ans != "") {
      ans.pop_back();
    }
  }
  cout << ans << endl;
}
Problem p04030 (C++)

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

int main() {
  string s;
  cin >> s;
  string a = "";
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != 'B') {
      a += s.at(i);
    } else if (s.size() > 0 && s.at(i) == 'B') {
      int j = a.length() - 1;
      a.erase(j);
    }
  }
  cout << a << endl;
}


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

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

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

int main() {
  string s;
  cin >> s;
  string out;
  for (auto &c : s) {
    switch (c) {
    case '0':
      out += "0";
      break;
    case '1':
      out += "1";
      break;
    case 'B':
      out.pop_back();
      break;
    }
  }
  cout << out << endl;
}

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

int main() {
  string s;
  cin >> s;
  string out;
  for (auto &c : s) {
    switch (c) {
    case '0':
      out += "0";
      break;
    case '1':
      out += "1";
      break;
    case 'B':
      if (out.size() > 0)
        out.pop_back();
      break;
    }
  }
  cout << out << endl;
}
Problem p04030 (C++)

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

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  cin >> s;

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

  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  cin >> s;

  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0' || s[i] == '1') {
      ans += s[i];
    } else if (ans.size() > 0) {
      ans.erase(ans.end() - 1);
    }
  }

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

Buggy submission (status: Runtime Error):

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  for (int i = 0; i < (int)s.size(); i++) {
    auto c = s[i];
    if (c == 'B' && s.size() != 0) {
      ans.pop_back();
      continue;
    }
    ans += c;
  }
  cout << ans << endl;
}


Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  for (int i = 0; i < (int)s.size(); i++) {
    auto c = s[i];
    if (c == 'B') {
      if (ans.size() != 0) {
        ans.pop_back();
      }
      continue;
    }
    ans += c;
  }
  cout << ans << endl;
}
Problem p04030 (C++)

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

using namespace std;

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <iomanip>
#include <math.h>
#include <numeric>
#include <stdio.h>

using namespace std;

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

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

using namespace std;

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

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

using namespace std;

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N>> &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T>> &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}

int main() {

  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  string s;
  cin >> s;

  string displayed = "";
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == '0') {
      displayed.push_back('0');
    } else if (s[i] == '1') {
      displayed.push_back('1');
    } else {
      if (!displayed.size()) {
        displayed.pop_back();
      }
    }
  }

  cout << displayed << "\n";

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N>> &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T>> &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}

int main() {

  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  string s;
  cin >> s;

  string displayed = "";
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == '0') {
      displayed.push_back('0');
    } else if (s[i] == '1') {
      displayed.push_back('1');
    } else {
      if (displayed.size()) {
        displayed.pop_back();
      }
    }
  }

  cout << displayed << "\n";

  return 0;
}
Problem p04030 (C++)

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

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

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

int main() {
  string s;
  cin >> s;
  deque<int> n;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0')
      n.push_back(0);
    else if (s.at(i) == '1')
      n.push_back(1);
    else if (!n.empty())
      n.pop_back();
  }
  for (int i = 0; i < n.size(); i++)
    cout << n.at(i);
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define PI acos(-1.0)
#define FOR(I, A, B) for (int I = (A); I < (B); ++I)

int main() {
  stack<char> sc;
  string s;
  cin >> s;
  FOR(i, 0, s.length()) {
    if (s[i] != 'B')
      sc.push(s[i]);
    else
      sc.pop();
  }
  string ans;
  while (!sc.empty()) {
    ans.push_back(sc.top());
    sc.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define PI acos(-1.0)
#define FOR(I, A, B) for (int I = (A); I < (B); ++I)

int main() {
  stack<char> sc;
  string s;
  cin >> s;
  FOR(i, 0, s.length()) {
    if (s[i] != 'B')
      sc.push(s[i]);
    else if (!sc.empty())
      sc.pop();
  }
  string ans;
  while (!sc.empty()) {
    ans.push_back(sc.top());
    sc.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <deque>
#include <iostream>
#include <map>
#include <string>
using namespace std;
#define REP(i, b, e) for (int i = (int)b; i < (int)e; i++)
#define Rep(i, n) REP(i, 0, n)
typedef long long ll;

string s, ans;

int main() {
  cin >> s;

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

Fixed submission:
#include <algorithm>
#include <cctype>
#include <deque>
#include <iostream>
#include <map>
#include <string>
using namespace std;
#define REP(i, b, e) for (int i = (int)b; i < (int)e; i++)
#define Rep(i, n) REP(i, 0, n)
typedef long long ll;

string s, ans;

int main() {
  cin >> s;

  Rep(i, s.size()) {
    if (s[i] != 'B') {
      ans += s[i];
    } else {
      if (ans.size()) {
        ans.pop_back();
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

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

int main() {
  string s;
  cin >> s;
  vector<char> v;

  for (int i = 0; i < s.size(); i++) {
    char tmp = s[i];

    if (tmp == '0') {
      v.push_back('0');
    } else if (tmp == '1') {
      v.push_back('1');
    } else if (tmp == 'B') {
      v.pop_back();
    }
  }

  for (auto &ch : v) {
    cout << ch;
  }

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<char> v;

  for (int i = 0; i < s.size(); i++) {
    char tmp = s[i];

    if (tmp == '0') {
      v.push_back('0');
    } else if (tmp == '1') {
      v.push_back('1');
    } else if (tmp == 'B') {
      if (v.size() != 0) {
        v.pop_back();
      }
    }
  }

  for (auto &ch : v) {
    cout << ch;
  }

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;
}
template <class T> T GCD(T a, T b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
template <class T> inline T LCM(T a, T b) { return (a * b) / GCD(a, b); }

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;
}
template <class T> T GCD(T a, T b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
template <class T> inline T LCM(T a, T b) { return (a * b) / GCD(a, b); }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

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

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

  string A;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '0') {
      A += '0';
    } else if (S.at(i) == '1') {
      A += '1';
    } else {
      A.pop_back();
    }
  }

  cout << A << endl;
}


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

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

  string A;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '0') {
      A += '0';
    } else if (S.at(i) == '1') {
      A += '1';
    } else {
      if (A.size() == 0) {
        continue;
      }
      A.pop_back();
    }
  }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <thread>
#include <vector>

using namespace std;

int main(void) {
  string s;
  string ret;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s.at(i) == '0') {
      ret += '0';
    } else if (s.at(i) == '1') {
      ret += '1';
    } else {
      if (!(i == 0)) {
        ret.pop_back();
      }
    }
  }

  cout << ret << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <thread>
#include <vector>

using namespace std;

int main(void) {
  string s;
  string ret;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s.at(i) == '0') {
      ret += '0';
    } else if (s.at(i) == '1') {
      ret += '1';
    } else {
      if (!(ret.empty() == true)) {
        ret.pop_back();
      }
    }
  }

  cout << ret << endl;
  return 0;
}
Problem p04030 (C++)

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

int main() {
  string s, t;
  cin >> s;
  for (char x : s) {
    if (x == '0' || x == '1')
      t.pb(x);
    if (x == 'B')
      t.pop_back();
  }
  cout << t << endl;
}

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

int main() {
  string s, t;
  cin >> s;
  for (char x : s) {
    if (x == '0' || x == '1')
      t.pb(x);
    if (x == 'B' && !t.empty())
      t.pop_back();
  }
  cout << t << endl;
}
Problem p04030 (C++)

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

string s, ans;

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

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

string s, ans;

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

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

int int_len(int n) {
  int s = 0;
  while (n != 0)
    s++, n /= 10;
  return s;
}

int int_sum(int n) {
  int m = 0, s = 0, a = n;
  while (a != 0)
    s++, a /= 10;
  for (int i = s - 1; i >= 0; i--)
    m += n / ((int)pow(10, i)) - (n / ((int)pow(10, i + 1))) * 10;
  return m;
}

long long int fac(long long int n) {
  long long int m = 1;
  while (n >= 1)
    m *= n, m %= 1000000007, n--;
  return m;
}

int vec_sum(vector<int> v) {
  int n = 0;
  for (int i = 0; i < v.size(); i++)
    n += v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin >> s;
  vector<char> v;
  for (char i : s) {
    if (i == 'B') {
      v.pop_back();
    } else {
      v.push_back(i);
    }
  }
  rep(i, v.size()) cout << v[i];
  cout << endl;
}
///////////////////////////


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

int int_len(int n) {
  int s = 0;
  while (n != 0)
    s++, n /= 10;
  return s;
}

int int_sum(int n) {
  int m = 0, s = 0, a = n;
  while (a != 0)
    s++, a /= 10;
  for (int i = s - 1; i >= 0; i--)
    m += n / ((int)pow(10, i)) - (n / ((int)pow(10, i + 1))) * 10;
  return m;
}

long long int fac(long long int n) {
  long long int m = 1;
  while (n >= 1)
    m *= n, m %= 1000000007, n--;
  return m;
}

int vec_sum(vector<int> v) {
  int n = 0;
  for (int i = 0; i < v.size(); i++)
    n += v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin >> s;
  vector<char> v;
  for (char i : s) {
    if (i == 'B') {
      if (v.size() > 0) {
        v.pop_back();
      }
    } else {
      v.push_back(i);
    }
  }
  rep(i, v.size()) cout << v[i];
  cout << endl;
}
///////////////////////////
Problem p04030 (C++)

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

deque<char> d;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  freopen("input.txt", "rt", stdin);
  string str;
  cin >> str;

  for (int i = 0; i < str.size(); i++) {
    if (str[i] != 'B')
      d.push_back(str[i]);
    else if (str[i] == 'B' && !d.empty())
      d.pop_back();
  }
  while (!d.empty()) {
    cout << d.front();
    d.pop_front();
  }
  cout << endl;

  return 0;
}

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

deque<char> d;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "rt", stdin);
  string str;
  cin >> str;

  for (int i = 0; i < str.size(); i++) {
    if (str[i] != 'B')
      d.push_back(str[i]);
    else if (str[i] == 'B' && !d.empty())
      d.pop_back();
  }
  while (!d.empty()) {
    cout << d.front();
    d.pop_front();
  }
  cout << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s = "";
  string u;
  cin >> u;
  int len = u.length();
  for (int i = 0; i < len; i++) {
    int l = s.length();
    if (u[i] == '0') {
      s += "0";
    } else if (u[i] == '1') {
      s += "1";
    } else {
      s.erase(s.begin() + l - 1);
    }
  }
  cout << s << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s = "";
  string u;
  cin >> u;
  int len = u.length();
  for (int i = 0; i < len; i++) {
    int l = s.length();
    if (u[i] == '0') {
      s += "0";
    } else if (u[i] == '1') {
      s += "1";
    } else {
      if (l > 0) {
        s.erase(s.begin() + l - 1);
      }
    }
  }
  cout << s << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<char> ans;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      ans.push_back('0');
      count++;
    }
    if (s[i] == '1') {
      ans.push_back('1');
      count++;
    }
    if (ans.size() >= 1, s[i] == 'B') {
      ans.pop_back();
      count--;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<char> ans;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      ans.push_back('0');
      count++;
    }
    if (s[i] == '1') {
      ans.push_back('1');
      count++;
    }
    if (ans.size() >= 1 && s[i] == 'B') {
      ans.pop_back();
      count--;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << endl;
}
Problem p04030 (C++)

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

int main() {
  string S, answer;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '1') {
      answer += '1';
    }
    if (S.at(i) == '0') {
      answer += '0';
    }
    if (S.at(i) == 'B') {
      if (S.size() > 0)
        answer.pop_back();
    }
  }
  cout << answer << endl;
}

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

int main() {
  string S, answer;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '1') {
      answer += '1';
    }
    if (S.at(i) == '0') {
      answer += '0';
    }
    if (S.at(i) == 'B') {
      if (answer.size() > 0)
        answer.pop_back();
    }
  }
  cout << answer << endl;
}
Problem p04030 (C++)

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

int main() {

  string s;
  cin >> s;
  vector<char> L(0);

  if (s.at(0) == '0') {
    L.push_back('0');
  }
  if (s.at(0) == '1') {
    L.push_back('1');
  }

  for (int i = 1; i < s.size(); i++) {
    if (s.at(i) == '0') {
      L.push_back('0');
    }
    if (s.at(i) == '1') {
      L.push_back('1');
    }
    if (s.at(i) == 'B') {
      L.pop_back();
    }
  }

  for (int i = 0; i < L.size(); i++) {
    cout << L.at(i);
  }
}

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

int main() {

  string s;
  cin >> s;
  vector<char> L(0);

  if (s.at(0) == '0') {
    L.push_back('0');
  }
  if (s.at(0) == '1') {
    L.push_back('1');
  }

  for (int i = 1; i < s.size(); i++) {
    if (s.at(i) == '0') {
      L.push_back('0');
    }
    if (s.at(i) == '1') {
      L.push_back('1');
    }
    if (s.at(i) == 'B') {
      if (L.size() == 0) {
        continue;
      } else {
        L.pop_back();
      }
    }
  }

  for (int i = 0; i < L.size(); i++) {
    cout << L.at(i);
  }
}
Problem p04030 (C++)

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

int main() {
  string s, ans;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] != 'B')
      ans.push_back(s[i]);
    else
      ans.pop_back();
  }
  cout << ans << endl;
}

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

int main() {
  string s, ans;
  cin >> s;
  rep(i, s.size()) {
    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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for (int i = 0; i < a; i++)
#define arep(i, x) for (auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
  string s;
  cin >> s;
  string v;
  rep(i, (int)s.size()) {
    if (s[i] != 'B')
      v += s[i];
    else {
      if (v.size() > 0)
        v.erase((i - 1));
    }
  }
  cout << v;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for (int i = 0; i < a; i++)
#define arep(i, x) for (auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
  string s;
  cin >> s;
  string v;
  rep(i, (int)s.size()) {
    if (s[i] != 'B')
      v += s[i];
    else {
      if (v.size() > 0)
        v.erase((v.size() - 1));
    }
  }
  cout << v;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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