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

Buggy submission (status: Runtime Error):
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))

using namespace std;

typedef long long ll;

int group(int n) {
  if (n == 2)
    return 2;
  else if (n == 4 || n == 6 || n == 9 || n == 11)
    return 1;
  else
    return 0;
}

int main() {
  // insert code here...    return 0;
  //////
  // input from txt
  /*
   std::ifstream in("input.txt");
   std::cin.rdbuf(in.rdbuf());
   std::ofstream out("output.txt");
   std::cout.rdbuf(out.rdbuf());
   ////
   */
  string s;
  cin >> s;
  string ans;
  repeat(i, s.length()) {
    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:
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))

using namespace std;

typedef long long ll;

int group(int n) {
  if (n == 2)
    return 2;
  else if (n == 4 || n == 6 || n == 9 || n == 11)
    return 1;
  else
    return 0;
}

int main() {
  // insert code here...    return 0;
  //////
  // input from txt
  /*
   std::ifstream in("input.txt");
   std::cin.rdbuf(in.rdbuf());
   std::ofstream out("output.txt");
   std::cout.rdbuf(out.rdbuf());
   ////
   */
  string s;
  cin >> s;
  string ans;
  repeat(i, s.length()) {
    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 <algorithm>
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>
using namespace std;

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

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

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

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

using namespace std;
int main() {
  string a, b;
  cin >> a;
  int n = a.size();
  for (int i = 0; i < n; i++) {
    if (a[i] != 'B') {
      b += a[i];
    } else {
      b.pop_back();
    }
  }
  cout << b << endl;
  return 0;
}

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

using namespace std;
int main() {
  string a, b;
  cin >> a;
  int n = a.size();
  for (int i = 0; i < n; i++) {
    if (a[i] != 'B') {
      b += a[i];
    } else if (b != "") {
      b.pop_back();
    }
  }
  cout << b << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char s[15];
int a[15];
int main() {
  while (scanf("%s", s)) {
    int len = strlen(s);
    int cnt = 0;
    for (int i = 0; i < len; i++) {
      if (s[i] != 'B')
        a[++cnt] = s[i] - '0';
      else {
        if (cnt >= 1)
          --cnt;
      }
    }
    for (int i = 1; i <= cnt; i++)
      printf("%d", a[i]);
    printf("\n");
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
char s[15];
int a[15];
int main() {
  while (~scanf("%s", s)) {
    int len = strlen(s);
    int cnt = 0;
    for (int i = 0; i < len; i++) {
      if (s[i] != 'B')
        a[++cnt] = s[i] - '0';
      else {
        if (cnt >= 1)
          --cnt;
      }
    }
    for (int i = 1; i <= cnt; i++)
      printf("%d", a[i]);
    printf("\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 a;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      a.push_back('0');
    else if (s[i] == '1')
      a.push_back('1');
    else if (s[i] == 'B' && a.size() >= 0)
      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[i] == '0')
      a.push_back('0');
    else if (s[i] == '1')
      a.push_back('1');
    else if (s[i] == 'B' && a.size() > 0)
      a.pop_back();
  }
  cout << a << endl;
}
Problem p04030 (C++)

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

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


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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  vector<char> ans(0);
  for (int i = 0; i < N; i++) {
    if (s[i] == '0')
      ans.push_back('0');
    if (s[i] == '1')
      ans.push_back('1');
    if (s[i] == 'B') {
      if (!ans.empty()) {
        ans.pop_back();
      }
    }
  }
  for (char c : ans) {
    cout << c;
  }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  string s;
  cin >> s;
  string ans;

  rep(i, s.length()) {
    if (s[i] == '0') {
      ans += '0';
    }
    if (s[i] == '1') {
      ans += '1';
    }
    if (s[i] == 'B') {
      if (ans[0] != '\n') {
        ans.erase(ans.length() - 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
  string s;
  cin >> s;
  string ans;

  rep(i, s.length()) {
    if (s[i] == '0') {
      ans += '0';
    }
    if (s[i] == '1') {
      ans += '1';
    }
    if (s[i] == 'B') {
      if (!ans.empty()) {
        ans.erase(ans.length() - 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;
  cin >> s;
  vector<char> C;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      C.push_back('0');
    } else if (s.at(i) == '1') {
      C.push_back('1');
    } else {
      C.erase(C.begin() + (C.size() - 1));
    }
  }
  for (int i = 0; i < C.size(); i++) {
    cout << C.at(i);
  }
  cout << endl;
}

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

int main() {
  string s;
  cin >> s;
  vector<char> C;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      C.push_back('0');
    } else if (s.at(i) == '1') {
      C.push_back('1');
    } else {
      if (C.size() != 0) {
        C.erase(C.begin() + (C.size() - 1));
      }
    }
  }
  for (int i = 0; i < C.size(); i++) {
    cout << C.at(i);
  }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string commands;
  cin >> commands;
  string output = "";
  for (int i = 0; i < commands.length(); i++) {
    if (commands[i] != 'B')
      output.push_back(commands[i]);
    else
      output.pop_back();
  }
  cout << output;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string commands;
  cin >> commands;
  string output = "";
  for (int i = 0; i < commands.length(); i++) {
    if (commands[i] != 'B')
      output.push_back(commands[i]);
    else {
      if (!output.empty())
        output.pop_back();
      else
        continue;
    }
  }
  cout << output;
  return 0;
}
Problem p04030 (C++)

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

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 += s[i];
    else {
      ans.pop_back();
    }
  }
  cout << ans;
}

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

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 += s[i];
    else {
      if (ans.size() > 0)
        ans.pop_back();
    }
  }
  cout << ans;
}
Problem p04030 (C++)

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

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


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

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

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

using namespace std;

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

  return 0;
}


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

using namespace std;

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

  return 0;
}
Problem p04030 (C++)

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

int main() {
  string S, ans;
  cin >> S;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '0') {
      ans.push_back('0');
    } else if (S[i] == '1') {
      ans.push_back('1');
    } else {
      ans.pop_back();
    }
  }
  cout << ans;
}

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

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s, ans;
  cin >> s;
  for (auto the : s) {
    switch (the) {
    case '0':
      ans.append("0");
      break;
    case '1':
      ans.append("1");
      break;
    case 'B':
      ans.pop_back();
      break;
    }
  }
  cout << ans << '\n';
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s, ans;
  cin >> s;
  for (auto the : s) {
    switch (the) {
    case '0':
      ans.append("0");
      break;
    case '1':
      ans.append("1");
      break;
    case 'B':
      if (ans.length())
        ans.pop_back();
      break;
    }
  }
  cout << ans << '\n';
}
Problem p04030 (C++)

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

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

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0')
      a.push_back('0');
    else if (s.at(i) == '1')
      a.push_back('1');
    else if (s.at(i) == 'B' && s.size() > 0)
      a.pop_back();
  }
  for (int i = 0; i < a.size(); i++)
    cout << a.at(i);
}


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

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

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0')
      a.push_back('0');
    else if (s.at(i) == '1')
      a.push_back('1');
    else if (s.at(i) == 'B' && a.size() > 0)
      a.pop_back();
  }
  for (int i = 0; i < a.size(); i++)
    cout << a.at(i);
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)

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

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)

int main(void) {
  string s;
  cin >> s;
  string ans;
  int n = s.size();

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

int main() {

  string s;
  string t;
  int a, b, c, d, i, j, k;
  cin >> s;

  for (i = 0; i < s.length(); i++) {
    if (s[i] == '1')
      t += '1';
    if (s[i] == '0')
      t += '0';
    if (s[i] == 'B' && t.length() >= 1)
      t.erase(t.back());
  }

  cout << t << endl;

  return 0;
}


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

int main() {

  string s;
  string t;
  int a, b, c, d, i, j, k;
  cin >> s;

  for (i = 0; i < s.length(); i++) {
    if (s[i] == '1')
      t += '1';
    if (s[i] == '0')
      t += '0';
    if (s[i] == 'B' && t.length() >= 1)
      t.pop_back();
  }

  cout << t << 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<int> v;
  int i;
  for (i = 0; i < s.length(); ++i) {
    if (s[i] == '0' || s[i] == '1')
      v.push_back(s[i] - 48);

    else
      v.pop_back();
  }

  for (i = 0; i < v.size(); ++i)
    cout << v[i];
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> v;
  int i;
  for (i = 0; i < s.length(); ++i) {
    if (s[i] == '0' || s[i] == '1')
      v.push_back(s[i] - 48);

    else {
      if (v.size() > 0)
        v.pop_back();

      else
        continue;
    }
  }

  for (i = 0; i < v.size(); ++i)
    cout << v[i];
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
#define int long long
signed main() {
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      ans += "0";
    else if (s[i] == '1')
      ans += "1";
    else
      ans.erase(ans.size() - 1, 1);
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
#define int long long
signed main() {
  string s;
  cin >> s;
  string ans;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      ans += "0";
    else if (s[i] == '1')
      ans += "1";
    else {
      if (ans.size() != 0)
        ans.erase(ans.size() - 1, 1);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
/*
      author : nishi5451
      created: 12.08.2020 16:12:44
*/

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

int main() {
  string s;
  cin >> s;
  string a;
  rep(i, (int)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.pop_back();
  }
  cout << a << endl;
  return 0;
}

Fixed submission:
/*
      author : nishi5451
      created: 12.08.2020 16:12:44
*/

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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>

using namespace std;

const int mod = 998244353;
const int inf = (int)2e9;
const ll INF = (ll)2e18;
const int N = 100100;

string s, ans;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> s;
  for (int i = 0; i < sz(s); i++) {
    if (s[i] != 'B') {
      ans += s[i];
    } else
      ans.pop_back();
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define ll long long
#define pb push_back
#define vi vector<int>
#define sz(a) (int((a).size()))
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>

using namespace std;

const int mod = 998244353;
const int inf = (int)2e9;
const ll INF = (ll)2e18;
const int N = 100100;

string s, ans;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> s;
  for (int i = 0; i < sz(s); i++) {
    if (s[i] != 'B') {
      ans += s[i];
    } else if (ans != "")
      ans.pop_back();
  }
  cout << ans << endl;

  return 0;
}
Problem p04030 (C++)

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

using namespace std;

int main() {
  string s;
  string st;
  cin >> s;
  for (auto i = s.begin(); i != s.end(); i++) {
    if (*i == 'B')
      st.pop_back();
    else
      st.push_back(*i);
  }
  cout << st << endl;
  return 0;
}

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

using namespace std;

int main() {
  string s;
  string st;
  cin >> s;
  for (auto i = s.begin(); i != s.end(); i++) {
    if (*i == 'B') {
      if (st.size() != 0)
        st.pop_back();
    } else
      st.push_back(*i);
  }
  cout << st << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
using namespace std;
#define M_PI 3.1415926535897932384626433832795
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>

int main() {
  string s, a;
  cin >> s;
  int e = 0;
  a = s;
  string c;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '0') {
      c.insert(e, "0");
      e++;
    } else if (s[i] == '1') {
      c.insert(e, "1");
      e++;
    } else {
      if (s[i]) {
        c.erase(e - 1, 1);
        e--;
      } else {
      }
    }
  }
  cout << c << endl;
}


Fixed submission:
using namespace std;
#define M_PI 3.1415926535897932384626433832795
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>

int main() {
  string s, a;
  cin >> s;
  int e = 0;
  a = s;
  string c;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '0') {
      c.insert(e, "0");
      e++;
    } else if (s[i] == '1') {
      c.insert(e, "1");
      e++;
    } else {
      if (c[0] != '\0') {
        c.erase(e - 1, 1);
        e--;
      } else {
      }
    }
  }
  cout << c << endl;
}
Problem p04030 (C++)

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for (int i = 0; i < (int)n; i++)

void solve() {
  string s;
  cin >> s;
  while (s.find('B') != string::npos) {
    if (s.find('B') != 0) {
      s.erase(s.find('B') - 1, 2);
    }
  }
  cout << s << "\n";
}

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

  int t = 1, i = 1;
  // cin >> t;
  while (t--) {
    // cout << "Case #" << i << ": ";
    solve();
    // i++;
  }
  return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for (int i = 0; i < (int)n; i++)

void solve() {
  string s;
  cin >> s;
  while (s.find('B') != string::npos) {
    if (s.find('B') != 0) {
      s.erase(s.find('B') - 1, 2);
    } else {
      s.erase(s.find('B'), 1);
    }
  }
  cout << s << "\n";
}

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

  int t = 1, i = 1;
  // cin >> t;
  while (t--) {
    // cout << "Case #" << i << ": ";
    solve();
    // i++;
  }
  return 0;
}
Problem p04030 (C++)

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

using namespace std;

int main() {
  string s;
  list<char> l;
  list<char>::iterator itr;
  cin >> s;
  int i;
  for (i = 0; i < s.length(); i++) {
    if (s[i] == '0') {
      l.push_back(s[i]);
    } else if (s[i] == '1') {
      l.push_back(s[i]);
    } else if (s[i] == 'B') {
      l.pop_back();
    }
  }

  for (itr = l.begin(); itr != l.end(); itr++) {
    cout << *itr;
  }
  return 0;
}

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

using namespace std;

int main() {
  string s;
  list<char> l;
  list<char>::iterator itr;
  cin >> s;
  int i;
  for (i = 0; i < s.length(); i++) {
    if (s[i] == '0') {
      l.push_back(s[i]);
    } else if (s[i] == '1') {
      l.push_back(s[i]);
    } else if (s[i] == 'B' && !l.empty()) {
      l.pop_back();
    }
  }

  for (itr = l.begin(); itr != l.end(); itr++) {
    cout << *itr;
  }
  return 0;
}
Problem p04030 (C++)

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

int main(void) {
  string S;
  string out;
  int j;

  j = 0;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (!(S[i] == 'B')) {
      out[j] = S[i];
      j++;
    }
    if (S[i] == 'B')
      j--;
  }
  for (size_t i = 0; i < j; i++)
    cout << out[i];
  cout << endl;
}

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

int main(void) {
  string S;
  string out;
  int j;

  j = 0;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if (!(S[i] == 'B')) {
      out[j] = S[i];
      j++;
    }
    if (S[i] == 'B' && !(j == 0))
      j--;
  }
  for (size_t i = 0; i < j; i++)
    cout << out[i];
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
vector<char> v;
int main() {
  char str[12];
  scanf("%s", str);
  int len = strlen(str);
  int flag = 0;
  for (int i = 0; i < len; i++) {
    if (str[i] == '0')
      v.push_back('0');
    else if (str[i] == '1')
      v.push_back('1');
    else if (str[i] == 'B')
      v.erase(v.end() - 1);
  }
  for (int i = 0; i < v.size(); i++)
    cout << v[i];
}


Fixed submission:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
vector<char> v;
int main() {
  char str[12];
  scanf("%s", str);
  int len = strlen(str);
  int flag = 0;
  for (int i = 0; i < len; i++) {
    if (str[i] == '0')
      v.push_back('0');
    else if (str[i] == '1')
      v.push_back('1');
    else if (str[i] == 'B' && v.size() > 0)
      v.erase(v.end() - 1);
  }
  for (int i = 0; i < v.size(); i++)
    cout << v[i];
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  size_t n = s.length();
  string t = "\0";
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      t += '0';
      count++;

    } else if (s[i] == '1') {
      t += '1';
      count++;
    } else {
      t.erase(count - 1, 1);
      count--;
      if (count < 0) {
        count = 0;
      }
    }
  }

  cout << t << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  size_t n = s.length();
  string t = "\0";
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      t += '0';
      count++;

    } else if (s[i] == '1') {
      t += '1';
      count++;
    } else {
      if (count != 0) {
        t.erase(count - 1, 1);
        count--;
      }
    }
  }

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

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

int main(void) {
  string str;
  cin >> str;

  string ans = "";

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

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

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

int main(void) {
  string str;
  cin >> str;

  string ans = "";

  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '0')
      ans += '0';
    if (str[i] == '1')
      ans += '1';
    if (str[i] == 'B' and ans != "")
      ans.pop_back();
  }

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

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

string s;
vector<char> ans;

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

  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();
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << '\n';

  return 0;
}

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

string s;
vector<char> ans;

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

  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();
      }
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  cout << '\n';

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL n, m, i, j;
string st, s;
int main() {
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      st += '0';
    if (s[i] == '1')
      st += '1';
    if (s[i] == 'B')
      st.erase(st.size() - 1, 1);
  }
  cout << st;
}

Fixed submission:
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL n, m, i, j;
string st, s;
int main() {
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      st += '0';
    if (s[i] == '1')
      st += '1';
    if (s[i] == 'B')
      if (st.size() > 0)
        st.erase(st.size() - 1, 1);
  }
  cout << st;
}
Problem p04030 (C++)

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

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


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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (auto c : s) {
    if (c == 'B') {
      if (ans.size() > 0)
        ans.pop_back();
    } else
      ans.push_back(c);
  }
  cout << ans;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int, int>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#define mk make_pair
ll MOD = 1000000007;
ll mod = 998244353;
int inf = 1000001000;
ll INF = 1e18 + 5;

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int, int>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#define mk make_pair
ll MOD = 1000000007;
ll mod = 998244353;
int inf = 1000001000;
ll INF = 1e18 + 5;

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long n, k;
string s, kq = "";
int main() {
  cin >> s;
  for (long i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      kq += '0';
    if (s[i] == '1')
      kq += '1';
    if (s[i] == 'B')
      kq.erase(kq.size() - 1, 1);
  }
  cout << kq << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long n, k;
string s, kq = "";
int main() {
  cin >> s;
  for (long i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      kq += '0';
    if (s[i] == '1')
      kq += '1';
    if (s[i] == 'B')
      if (kq.size() != 0)
        kq.erase(kq.size() - 1, 1);
  }
  cout << kq << 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()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void) {
  string s;
  cin >> s;

  vector<int> ans;
  int N = s.length();
  rep(i, N) {
    if (s[i] == '0')
      ans.push_back(0);
    else if (s[i] == '1')
      ans.push_back(1);
    else if (s[i] == 'B')
      ans.pop_back();
  }
  rep(i, ans.size()) cout << ans[i];
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void) {
  string s;
  cin >> s;

  vector<int> ans;
  int N = s.length();
  rep(i, N) {
    if (s[i] == '0')
      ans.push_back(0);
    else if (s[i] == '1')
      ans.push_back(1);
    else if (s[i] == 'B' && ans.size() != 0)
      ans.pop_back();
  }
  rep(i, ans.size()) cout << ans[i];
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define syosu(x) fixed << setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const double pi = acos(-1);
const double eps = 1e-8;

int num = 0;
string str, ans;

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

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <typeinfo>
#include <vector>
#define syosu(x) fixed << setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int, P> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const double pi = acos(-1);
const double eps = 1e-8;

int num = 0;
string str, ans;

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

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

int main() {

  string s;
  cin >> s;

  string ans = "";

  rep(i, s.size()) {
    if (s[i] == 'B') {
      ans.pop_back();
    } else {
      ans.push_back(s[i]);
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {

  string s;
  cin >> s;

  string ans = "";

  rep(i, s.size()) {
    if (s[i] == 'B') {
      if (ans != "") {
        ans.pop_back();
      }
    } else {
      ans.push_back(s[i]);
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p04030 (C++)

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

using namespace std;

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

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


Fixed submission:
#include <iostream>

using namespace std;

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

  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'B') {
      if (ans.size() > 0)
        ans.pop_back();
    } else
      ans += str[i];
  }
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  string S;
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); i++) {
    if (T[i] == '1')
      S.push_back('1');
    if (T[i] == '0')
      S.push_back('0');
    if (T[i] == 'B')
      S.pop_back();
  }
  cout << S;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  string S;
  string T;
  cin >> T;
  for (int i = 0; i < T.size(); i++) {
    if (T[i] == '1')
      S.push_back('1');
    if (T[i] == '0')
      S.push_back('0');
    if (T[i] == 'B' && S.size() > 0)
      S.pop_back();
  }
  cout << S;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1 << 30);
const ll NEGA = -INF * 10000;

int ans = 0;
int n, m;
int cnt = 0;

// 最長増加部分列の長さの計算
int LIS(vector<int> V) {
  int DP[200001] = {0};
  fill(DP, DP + V.size(), INF);
  rep(i, V.size()) { *lower_bound(DP, DP + V.size(), V[i]) = V[i]; }
  return lower_bound(DP, DP + V.size(), INF) - DP;
}

vector<int> p;
int main() {
  char out[10] = {0};
  int len = 0;
  string s;
  cin >> s;
  rep(i, s.length()) {
    if (s[i] == '0') {
      out[len++] = '0';
    } else if (s[i] == '1') {
      out[len++] = '1';
    } else {
      len--;
    }
  }

  rep(i, len) { cout << out[i]; }
  cout << endl;
}


Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1 << 30);
const ll NEGA = -INF * 10000;

int ans = 0;
int n, m;
int cnt = 0;

// 最長増加部分列の長さの計算
int LIS(vector<int> V) {
  int DP[200001] = {0};
  fill(DP, DP + V.size(), INF);
  rep(i, V.size()) { *lower_bound(DP, DP + V.size(), V[i]) = V[i]; }
  return lower_bound(DP, DP + V.size(), INF) - DP;
}

vector<int> p;
int main() {
  char out[10] = {0};
  int len = 0;
  string s;
  cin >> s;
  rep(i, s.length()) {
    if (s[i] == '0') {
      out[len++] = '0';
    } else if (s[i] == '1') {
      out[len++] = '1';
    } else {
      len--;
      if (len < 0)
        len = 0;
    }
  }

  rep(i, len) { cout << out[i]; }
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  string 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' && s.length() > 0) {
      ans.erase(ans.length() - 1, 1);
    }
  }
  cout << ans;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    pbds;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  string 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' && s.length() > 0) {
      ans = ans.substr(0, ans.length() - 1);
    }
  }
  cout << ans;
  return 0;
}
Problem p04030 (C++)

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

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

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

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

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

  string S;
  cin >> S;
  vector<int> A(0);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '0')
      A.push_back(0);
    if (S[i] == '1')
      A.push_back(1);
    if (S[i] == 'B') {
      if (S.size() > 0)
        A.pop_back();
    }
  }
  for (int i = 0; i < A.size(); i++) {
    cout << A[i];
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {

  string S;
  cin >> S;
  vector<int> A(0);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '0')
      A.push_back(0);
    if (S[i] == '1')
      A.push_back(1);
    if (S[i] == 'B') {
      if (A.size() > 0)
        A.pop_back();
    }
  }
  for (int i = 0; i < A.size(); i++) {
    cout << A[i];
  }
}
Problem p04030 (C++)

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

using namespace std;

int main(int argc, char const *argv[]) {
  string s, ans;
  cin >> s;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] == '0' || s[i] == '1')
      ans.push_back(s[i]);
    else
      ans.pop_back();
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  string s, ans;
  cin >> s;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] == '0' || s[i] == '1')
      ans.push_back(s[i]);
    else {
      if (ans.size() == 0)
        continue;
      else
        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++) {
    if (s.at(i) == '0') {
      t.push_back('0');
    }
    if (s.at(i) == '1') {
      t.push_back('1');
    }
    if (s.at(i) == 'B') {
      if (s.size() != 0) {
        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++) {
    if (s.at(i) == '0') {
      t.push_back('0');
    }
    if (s.at(i) == '1') {
      t.push_back('1');
    }
    if (s.at(i) == 'B') {
      if (t.size() == 0) {
      } else {
        t.pop_back();
      }
    }
  }
  cout << t << endl;
}
Problem p04030 (C++)

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

int main() {
  vector<char> a;
  string s;
  cin >> s;
  for (char c : s) {
    if (c == 'B')
      a.pop_back();
    else
      a.push_back(c);
  }
  for (char c : a) {
    cout << c;
  }
  return 0;
}

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

int main() {
  vector<char> a;
  string s;
  cin >> s;
  for (char c : s) {
    if (c == 'B') {
      if (a.size())
        a.pop_back();
    } else
      a.push_back(c);
  }
  for (char c : a) {
    cout << c;
  }
  return 0;
}
Problem p04030 (C++)

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

int main() {
  ios::sync_with_stdio(false);
  string s, a;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
      a += '0';
    else if (s[i] == '1')
      a += '1';
    else
      a.pop_back();
  }
  cout << a;
}


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

int main() {
  ios::sync_with_stdio(false);
  string s, a;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
      a += '0';
    else if (s[i] == '1')
      a += '1';
    else {
      if (a.length() != 0)
        a.pop_back();
    }
  }
  cout << a;
}
Problem p04030 (C++)

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

using namespace std;

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

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


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

using namespace std;

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

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