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

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

int main() {
  stack<char> w;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    switch (s.at(i)) {
    case '0':
      w.push('0');
      break;
    case '1':
      w.push('1');
      break;
    default:
      w.pop();
    }
  }
  string ans;
  while (w.size() > 0) {
    ans += w.top();
    w.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

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

int main() {
  stack<char> w;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    switch (s.at(i)) {
    case '0':
      w.push('0');
      break;
    case '1':
      w.push('1');
      break;
    default:
      if (w.size() > 0)
        w.pop();
    }
  }
  string ans;
  while (w.size() > 0) {
    ans += w.top();
    w.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

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

#define int long long

string S;

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

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

#define int long long

string S;

signed main() {
  string ans;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'B') {
      if (ans.size() > 0)
        ans.pop_back();
    } else
      ans.push_back(S[i]);
  }
  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.length(); i++) {
    if (s.at(i) == '1')
      ans += '1';
    else if (s.at(i) == '0')
      ans += '0';
    else if (!s.empty())
      ans.pop_back();
  }

  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++) {
    if (s.at(i) == '1')
      ans += '1';
    else if (s.at(i) == '0')
      ans += '0';
    else if (!ans.empty())
      ans.pop_back();
  }

  cout << ans << endl;

  return 0;
}
Problem p04030 (C++)

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

int main() {
  string s;
  cin >> s;
  vector<char> t;
  int count = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != 'B') {
      t.push_back(s[i]);
    } else {
      if (t.size() >= 0) {
        t.pop_back();
      }
    }
  }
  for (int i = 0; i < t.size() - count; i++) {
    cout << t[i];
  }
  cout << endl;
  return 0;
}

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

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

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

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

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  // Your code here!
  string s;
  cin >> s;

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

  cout << str << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  // Your code here!
  string s;
  cin >> s;

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

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

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

using namespace std;

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

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

using namespace std;

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

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

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

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

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

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;

const i64 INF = 1e18 + 7;

signed main() {
  int a, b, c, d, n, x, y;
  string s, t;

  auto Yes = [&](bool t) { cout << (t ? "Yes" : "No") << endl; };
  auto YES = [&](bool t) { cout << (t ? "YES" : "NO") << endl; };
  auto tri = [&](bool t, string a, string b) { cout << (t ? a : b) << endl; };

  cin >> s;
  for (auto &x : s) {
    if (x == '1')
      t.push_back('1');
    else if (x == '0')
      t.push_back('0');
    else
      t.pop_back();
  }
  cout << t << endl;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;

const i64 INF = 1e18 + 7;

signed main() {
  int a, b, c, d, n, x, y;
  string s, t;

  auto Yes = [&](bool t) { cout << (t ? "Yes" : "No") << endl; };
  auto YES = [&](bool t) { cout << (t ? "YES" : "NO") << endl; };
  auto tri = [&](bool t, string a, string b) { cout << (t ? a : b) << endl; };

  cin >> s;
  for (auto &x : s) {
    if (x == '1')
      t.push_back('1');
    else if (x == '0')
      t.push_back('0');
    else if (t.size())
      t.pop_back();
  }
  cout << t << endl;
}
Problem p04030 (C++)

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

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

  return 0;
}

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

int main() {
  string s;
  string ans;
  cin >> s;
  int i;
  for (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.pop_back();
    }
  }
  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] == 'B') {
      if (s.size())
        ans.pop_back();
    } else
      ans.push_back(s[i]);
  }
  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.size(); i++) {
    if (s[i] == 'B') {
      if (ans.size())
        ans.pop_back();
    } else
      ans.push_back(s[i]);
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

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

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

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define clr(a, b) memset((a), (b), sizeof(a))
#define ctos(d) string(1, d)
#define print(x) cout << #x << " = " << x << endl;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  string s1;
  rep(i, 0, s.sz) {
    if (s[i] != 'B') {
      s1 += s[i];
    } else {
      s1.erase(s1.begin() + s1.sz - 1);
    }
  }
  cout << s1 << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define clr(a, b) memset((a), (b), sizeof(a))
#define ctos(d) string(1, d)
#define print(x) cout << #x << " = " << x << endl;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  string s1;
  rep(i, 0, s.sz) {
    if (s[i] != 'B') {
      s1 += s[i];
    } else {
      if (s1.sz != 0) {
        s1.erase(s1.begin() + s1.sz - 1);
      }
    }
  }
  cout << s1 << 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' && ans != "")
      ans.erase(i - 1, 1);
    else if (s[i] == '0')
      ans += '0';
    else if (s[i] == '1')
      ans += '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 != "")
      ans.pop_back();
    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>
using namespace std;
int main() {
  string s, r = "";
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '0') {
      r += '0';
    }
    if (s[i] == '1') {
      r += '1';
    }
    if (s[i] == 'B' && s.length() != 0) {
      r.pop_back();
    }
  }
  for (int i = 0; i < r.length(); ++i) {
    cout << r[i];
  }
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, r = "";
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '0') {
      r += '0';
    }
    if (s[i] == '1') {
      r += '1';
    }
    if (s[i] == 'B' && r.length() != 0) {
      r.pop_back();
    }
  }
  for (int i = 0; i < r.length(); ++i) {
    cout << r[i];
  }
  cout << endl;
}
Problem p04030 (C++)

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

Fixed submission:
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  string ans;
  int i;
  for (i = 0; i < (int)(s.length()); i++) {
    if (s[i] == '0') {
      ans += "0";
    }
    if (s[i] == '1') {
      ans += "1";
    }
    if (s[i] == 'B') {
      if ((int)(ans.length()) != 0)
        ans.erase(ans.end() - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

Buggy submission (status: Runtime Error):

#include <iostream>
using namespace std;

int main() {
  string input, answer = {};
  cin >> input;
  for (int i = 0; i < input.size(); i++) {
    switch (input[i]) {
    case '0':
      answer += input[i];
      break;
    case '1':
      answer += input[i];
      break;
    case 'B':
      answer.pop_back();
    }
  }
  cout << answer << endl;
  return 0;
}


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  string input, answer = {};
  cin >> input;
  for (int i = 0; i < input.size(); i++) {
    switch (input[i]) {
    case '0':
      answer += input[i];
      break;
    case '1':
      answer += input[i];
      break;
    case 'B':
      if (answer.size())
        answer.pop_back();
    }
  }
  cout << answer << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
// https://atcoder.jp/contests/abc043/tasks/abc043_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s;
  for (auto &x : s) {
    if (x == '0') {
      t.push_back('0');
    } else if (x == '1') {
      t.push_back('1');
    } else {
      t.pop_back();
    }
  }
  cout << t << endl;

  return 0;
}


Fixed submission:
// https://atcoder.jp/contests/abc043/tasks/abc043_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s;
  for (auto &x : s) {
    if (x == '0') {
      t.push_back('0');
    } else if (x == '1') {
      t.push_back('1');
    } else {
      if (t.size() > 0) {
        t.pop_back();
      }
    }
  }
  cout << t << 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 repf(i, a, b) for (int i = (a); i < (b); i++)
#define repi(i, a, b) for (int i = (a); i <= (b); i++)
#define repr(i, a, b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string s;
  cin >> s;
  string ans;
  for (auto c : s) {
    if (c == '0') {
      ans.push_back('0');
    } else if (c == '1') {
      ans.push_back('1');
    } else if (c == 'B' && s != "") {
      ans.pop_back();
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, a, b) for (int i = (a); i < (b); i++)
#define repi(i, a, b) for (int i = (a); i <= (b); i++)
#define repr(i, a, b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string s;
  cin >> s;
  string ans;
  for (auto c : s) {
    if (c == '0') {
      ans.push_back('0');
    } else if (c == '1') {
      ans.push_back('1');
    } else if (c == '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') {
      if (ans.empty() != 0) {
        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.size(); i++) {
    if (s[i] == 'B') {
      if (ans.empty() != 1) {
        ans.erase(ans.size() - 1);
      }
    } else {
      ans += s[i];
    }
  }

  cout << ans << endl;

  return (0);
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  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.pop_back();
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'B' && ans.size() == 0)
      continue;

    else if (s[i] == '0' || s[i] == '1') {
      ans += s[i];
    } else {
      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, ans1;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      string temp = "0";
      ans += temp;
    } else if (s[i] == '1') {
      string temp = "1";
      ans += temp;
    } else if (s[i] == 'B') {
      ans1 = "";
      for (int j = 0; j < ans.size() - 1; j++) {
        ans1 += ans[j];
      }
      ans = ans1;
    }
  }
  cout << ans;
  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, ans, ans1;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      string temp = "0";
      ans += temp;
    } else if (s[i] == '1') {
      string temp = "1";
      ans += temp;
    } else if (s[i] == 'B') {
      if (ans.size() == 0) {
        continue;
      }
      ans1 = "";
      for (int j = 0; j < ans.size() - 1; j++) {
        ans1 += ans[j];
      }
      ans = ans1;
    }
  }
  cout << ans;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

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

Fixed submission:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

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

Buggy submission (status: Runtime Error):
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for (int __x = __start; __x < __end; __x++)
void solve();
int main() {
  solve();
  return 0;
}

void solve() {
  string s, t = "";
  cin >> s;
  int n = s.size();
  loop(i, 0, n) {
    if (s[i] == '0')
      t += '0';
    else if (s[i] == '1')
      t += '1';
    else
      t.pop_back();
  }
  cout << t << endl;
}


Fixed submission:
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for (int __x = __start; __x < __end; __x++)
void solve();
int main() {
  solve();
  return 0;
}

void solve() {
  string s, t = "";
  cin >> s;
  int n = s.size();
  loop(i, 0, n) {
    if (s[i] == '0')
      t += '0';
    else if (s[i] == '1')
      t += '1';
    else if (t.size() > 0)
      t.pop_back();
  }
  cout << t << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

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

  cout << res << endl;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int a, int b) {
  if (a % b == 0) {
    return b;
  } else {
    return (gcd(b, a % b));
  }
}
ll lcm(int a, int b) { return a * b / gcd(a, b); }
const int INF = 1e9;
const ll INFS = 1e18;
const int MOD = INF + 7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const double PI = acos(-1);

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

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int a, int b) {
  if (a % b == 0) {
    return b;
  } else {
    return (gcd(b, a % b));
  }
}
ll lcm(int a, int b) { return a * b / gcd(a, b); }
const int INF = 1e9;
const ll INFS = 1e18;
const int MOD = INF + 7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const double PI = acos(-1);

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define vv(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vll vector<ll>
#define rep(c, a, b) for (ll c = a; c < b; c++)
#define re(c, b) for (ll c = 0; c < b; c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  deque<char> d;
  string s;
  std::cin >> s;
  re(i, s.size()) {
    if (s[i] == '1')
      d.push_back('1');
    else if (s[i] == '0')
      d.push_back('0');
    else
      d.pop_back();
  }
  while (!d.empty()) {
    std::cout << d.front();
    d.pop_front();
  }
  std::cout << '\n';
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define vv(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vll vector<ll>
#define rep(c, a, b) for (ll c = a; c < b; c++)
#define re(c, b) for (ll c = 0; c < b; c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  deque<char> d;
  string s;
  std::cin >> s;
  re(i, s.size()) {
    if (s[i] == '1')
      d.push_back('1');
    else if (s[i] == '0')
      d.push_back('0');
    else if (!d.empty())
      d.pop_back();
  }
  while (!d.empty()) {
    std::cout << d.front();
    d.pop_front();
  }
  std::cout << '\n';
}
Problem p04030 (C++)

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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (char c : s) {
    if (c == 'B')
      ans.pop_back();
    else
      ans += c;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (char c : s) {
    if (c == 'B') {
      if (!ans.empty())
        ans.pop_back();
    } else
      ans += c;
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define rrep0(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define rep1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define rrep1(i, n) for (ll(i) = (n); (i) >= 1; --(i))
#define nfor(i, a, b) for (ll(i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(), (x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

ll factorial(ll n) {
  ll t = 1;
  rep1(i, n) {
    t *= i;
    t %= mod;
  }
  return t;
}

ll power(ll a, ll b) {
  a %= mod;
  if (b == 0) {
    return 1;
  }
  ll ans = power(a, b / 2);
  ans = ans * ans % mod;
  if (b % 2 == 1) {
    ans = ans * a % mod;
  }
  return ans;
}

ll combination(ll a, ll b) {
  if ((a == b) || (b == 0)) {
    return 1;
  }
  if (a < b)
    return 0;
  ll ans = 1;
  for (ll i = 0; i < b; i++) {
    ans *= (a - i);
    ans /= (i + 1);
    ans %= mod;
  }
  return ans;
}

int main() {

  string s, ans;
  cin >> s;
  rep0(i, s.size()) {
    if (s[i] != 'B')
      ans.push_back(s[i]);
    else {
      if (s.empty())
        continue;
      else
        ans.pop_back();
    }
  }
  pf(ans);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define rrep0(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define rep1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define rrep1(i, n) for (ll(i) = (n); (i) >= 1; --(i))
#define nfor(i, a, b) for (ll(i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(), (x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

ll factorial(ll n) {
  ll t = 1;
  rep1(i, n) {
    t *= i;
    t %= mod;
  }
  return t;
}

ll power(ll a, ll b) {
  a %= mod;
  if (b == 0) {
    return 1;
  }
  ll ans = power(a, b / 2);
  ans = ans * ans % mod;
  if (b % 2 == 1) {
    ans = ans * a % mod;
  }
  return ans;
}

ll combination(ll a, ll b) {
  if ((a == b) || (b == 0)) {
    return 1;
  }
  if (a < b)
    return 0;
  ll ans = 1;
  for (ll i = 0; i < b; i++) {
    ans *= (a - i);
    ans /= (i + 1);
    ans %= mod;
  }
  return ans;
}

int main() {

  string s, ans;
  cin >> s;
  rep0(i, s.size()) {
    if (s[i] != 'B')
      ans.push_back(s[i]);
    else if (ans.size() > 0)
      ans.pop_back();
  }
  pf(ans);
  return 0;
}
Problem p04030 (C++)

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

void solve() {
  string s, ans;
  cin >> s;
  for (char c : s) {
    if (c == '0')
      ans += "0";
    else if (c == '1')
      ans += "1";
    else
      ans.pop_back();
  }
  cout << ans << "\n";
}

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

  bool multitest = false;
  //    multitest = true;
  if (multitest) {
    int t;
    cin >> t;
    while (t--)
      solve();
  } else
    solve();
}


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

void solve() {
  string s, ans;
  cin >> s;
  for (char c : s) {
    if (c == '0')
      ans += "0";
    else if (c == '1')
      ans += "1";
    else if (!ans.empty())
      ans.pop_back();
  }
  cout << ans << "\n";
}

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

  bool multitest = false;
  //    multitest = true;
  if (multitest) {
    int t;
    cin >> t;
    while (t--)
      solve();
  } else
    solve();
}
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[i] == '0')
      a += '0';
    else if (s[i] == '1')
      a += '1';
    else
      a = a.erase(a.size() - 1);
  }
  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[i] == '0')
      a += '0';
    else if (s[i] == '1')
      a += '1';
    else {
      if (a.size() != 0)
        a = a.erase(a.size() - 1);
    }
  }
  cout << a << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

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;
    case 'B':
      if (ans.empty())
        ans.pop_back();
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

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;
    case 'B':
      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 in, out = "";

  cin >> in;

  for (const char &u : in) {
    if (u == '0' | u == '1')
      out += u;
    else
      out.pop_back();
  }
  cout << out;

  return 0;
}

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

int main() {
  string in, out = "";

  cin >> in;

  for (const char &u : in) {
    if (u == '0' | u == '1')
      out += u;
    else if (out.size() > 0)
      out.pop_back();
  }
  cout << out;

  return 0;
}
Problem p04030 (C++)

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

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

  vector<char> v;

  for (int i = 0; i < s.size(); ++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 < v.size(); ++i)
    cout << v[i];

  cout << endl;
}

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

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

  vector<char> v;

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

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

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

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


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

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

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

int main() {
  string a, b;
  cin >> a;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] != 'B')
      b.push_back(a[i]);
    else
      b.pop_back();
  }
  cout << b;
  return 0;
}


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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  string s;
  cin >> s;
  stack<ll> st;
  rep(i, s.size()) {
    if (s.at(i) == '0')
      st.push(0);
    else if (s.at(i) == '1')
      st.push(1);
    else
      st.pop();
  }
  vector<ll> v;
  ll n = st.size();
  rep(i, n) {
    v.push_back(st.top());
    st.pop();
  }
  rep(i, v.size()) cout << v.at(v.size() - 1 - i);
  cout << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  string s;
  cin >> s;
  stack<ll> st;
  rep(i, s.size()) {
    if (s.at(i) == '0')
      st.push(0);
    else if (s.at(i) == '1')
      st.push(1);
    else if (st.size())
      st.pop();
  }
  vector<ll> v;
  ll n = st.size();
  rep(i, n) {
    v.push_back(st.top());
    st.pop();
  }
  rep(i, v.size()) cout << v.at(v.size() - 1 - i);
  cout << endl;
}
Problem p04030 (C++)

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

using namespace std;
using ll = long long;

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

Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      ans += '1';
    } else if (s[i] == '0') {
      ans += '0';
    } else if (ans.size() != 0 && s[i] == 'B') {
      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, ans = "";
  cin >> s;
  vector<char> vc;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'B')
      vc.pop_back();
    else
      vc.push_back(s[i]);
  }
  for (auto j : vc)
    cout << j;
  return 0;
}


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

int main() {
  string s, ans = "";
  cin >> s;
  vector<char> vc;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'B') {
      if (vc.size() > 0)
        vc.pop_back();
    } else
      vc.push_back(s[i]);
  }
  for (auto j : vc)
    cout << j;
  return 0;
}
Problem p04030 (C++)

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

int main() {
  string a, b;
  cin >> a;
  int c, d;
  c = a.size();
  while (c > d) {
    if (a.substr(0, 1) == "0") {
      b = b + '0';
    } else if (a.substr(0, 1) == "1") {
      b = b + '1';
    } else if (a.substr(0, 1) == "B") {
      b.erase(b.size() - 1);
    }
    d = d + 1;
    a.erase(a.begin());
  }
  cout << b << endl;
}

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

int main() {
  string a, b;
  cin >> a;
  int c, d;
  c = a.size();
  while (c > d) {
    if (a.substr(0, 1) == "0") {
      b = b + '0';
    } else if (a.substr(0, 1) == "1") {
      b = b + '1';
    } else if (b.size() != 0 && a.substr(0, 1) == "B") {
      b.erase(b.size() - 1);
    }
    d = d + 1;
    a.erase(a.begin());
  }
  cout << b << endl;
}
Problem p04030 (C++)

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

using namespace std;

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

  for (auto it = dst.begin(); it != dst.end(); ++it) {
    cout << *it;
  }
  cout << endl;

  return 0;
}

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

using namespace std;

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

  for (auto it = dst.begin(); it != dst.end(); ++it) {
    cout << *it;
  }
  cout << endl;

  return 0;
}
Problem p04030 (C++)

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

int main() {
  string s, res = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      res += '0';
    else if (s[i] == '1')
      res += '1';
    else {
      if (res.size() != 0)
        res.erase(res.begin() + i);
    }
  }
  cout << res << "\n";
  return 0;
}

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

int main() {
  string s, res = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      res += '0';
    else if (s[i] == '1')
      res += '1';
    else {
      if (res.size() != 0)
        res.pop_back();
    }
  }
  cout << res << "\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 ans = "";
  for (int i = 0; s.size(); i++) {
    if (s.at(i) == '0')
      ans += '0';
    if (s.at(i) == '1')
      ans += '1';
    if (s.at(i) == 'B' && ans.size() > 0)
      ans.pop_back();
  }
  cout << ans << endl;
  return 0;
}

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.size() > 0)
      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;
  cin >> s;
  string t;

  for (int i = 0; i < s.size(); i++) {
    switch (s.at(i)) {
    case '0':
      t = t + '0';
      break;
    case '1':
      t = t + '1';
      break;
    case 'B':
      t.pop_back();
    }
  }

  cout << t << endl;
}

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

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

  for (int i = 0; i < s.size(); i++) {
    switch (s.at(i)) {
    case '0':
      t = t + '0';
      break;
    case '1':
      t = t + '1';
      break;
    case 'B':
      if (!t.empty()) {
        t.pop_back();
      }
    }
  }

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

Buggy submission (status: Runtime Error):
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)

#define INF INT_MAX / 3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#define SET(a, c) memset(a, c, sizeof a)
#define CLR(a) memset(a, 0, sizeof a)
#define PII pair<int, int>
#define PCC pair<char, char>
#define PIC pair<int, char>
#define Pci pair<char, int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout << #x << ": " << x << endl
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define PI 2 * acos(0.0)
#define INFILE() freopen("in0.txt", "r", stdin)
#define OUTFILE() freopen("out0.txt", "w", stdout)
#define IN scanf
#define OUT(x) cout << x << endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second

#include <iostream>

using namespace std;
int main() {
  string r = "";
  // 入力
  string a;
  cin >> a;

  REP(i, a.size()) {
    switch (a[i]) {
    case 'B':
      r.pop_back();
      break;
    default:
      r += a[i];
      break;
    }
  }
  OUT(r);
  return 0;
}


Fixed submission:
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)

#define INF INT_MAX / 3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#define SET(a, c) memset(a, c, sizeof a)
#define CLR(a) memset(a, 0, sizeof a)
#define PII pair<int, int>
#define PCC pair<char, char>
#define PIC pair<int, char>
#define Pci pair<char, int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout << #x << ": " << x << endl
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define PI 2 * acos(0.0)
#define INFILE() freopen("in0.txt", "r", stdin)
#define OUTFILE() freopen("out0.txt", "w", stdout)
#define IN scanf
#define OUT(x) cout << x << endl
#define LL long long
#define ll long long
#define ULL unsigned long long
#define EPS 1e-14
#define FST first
#define SEC second

#include <iostream>

using namespace std;
int main() {
  string r = "";
  // 入力
  string a;
  cin >> a;

  REP(i, a.size()) {
    switch (a[i]) {
    case 'B':
      if (r.size() != 0)
        r.pop_back();
      break;
    default:
      r += a[i];
      break;
    }
  }
  OUT(r);
  return 0;
}