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

Buggy submission (status: Runtime Error):
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
using namespace std;

set<int> v;
bool hai(int n) {
  if (v.find(n) != v.end()) {
    return false;
  }
  return true;
}

bool valid(int n) {
  while (n) {
    if (!(hai(n % 10))) {
      return false;
    }
    n /= 10;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  string res = "";
  string a;
  cin >> a;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == '0') {
      res.push_back('0');
    } else if (a[i] == '1') {
      res.push_back('1');
    } else {
      if (res.length() != 0) {
        res.pop_back();
      }
    }
  }
  cout << res << endl;
}

Fixed submission:
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
using namespace std;

set<int> v;
bool hai(int n) {
  if (v.find(n) != v.end()) {
    return false;
  }
  return true;
}

bool valid(int n) {
  while (n) {
    if (!(hai(n % 10))) {
      return false;
    }
    n /= 10;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  string res = "";
  string a;
  cin >> a;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == '0') {
      res.push_back('0');
    } else if (a[i] == '1') {
      res.push_back('1');
    } else {
      if (res.length() != 0) {
        res.pop_back();
      }
    }
  }
  cout << res << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

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

Buggy submission (status: Runtime Error):
//===================== Author Info ==================
//  Khaled Alam (Ninjo)   ~   khaledalam.net@gmail.com
//====================================================
#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long int
#define ones __builtin_popcount
#define all(a) (a).begin(), (a).end()
#define iFile(a) freopen(#a, "r", stdin)
#define oFile(a) freopen(#a, "w", stdout)
#define rep(i, a, z) for (auto i = (a); i < (z); i++)
#define ios ios_base::sync_with_stdio(false)
#define tm fprintf(stderr, "%.3f s\n", (float)clock() / 1000);

int main() {
  // iFile(input.txt);
  // oFile(output.txt);
  string s, ans;
  cin >> s;
  for (auto c : s) {
    if (c == '0') {
      ans += '0';
    } else if (c == '1') {
      ans += '1';
    } else {
      ans.pop_back();
    }
  }
  cout << ans;
}


Fixed submission:
//===================== Author Info ==================
//  Khaled Alam (Ninjo)   ~   khaledalam.net@gmail.com
//====================================================
#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long int
#define ones __builtin_popcount
#define all(a) (a).begin(), (a).end()
#define iFile(a) freopen(#a, "r", stdin)
#define oFile(a) freopen(#a, "w", stdout)
#define rep(i, a, z) for (auto i = (a); i < (z); i++)
#define ios ios_base::sync_with_stdio(false)
#define tm fprintf(stderr, "%.3f s\n", (float)clock() / 1000);

int main() {
  // iFile(input.txt);
  // oFile(output.txt);
  string s, ans;
  cin >> s;
  for (auto c : s) {
    if (c == '0') {
      ans += '0';
    } else if (c == '1') {
      ans += '1';
    } else {
      if (ans.sz > 0)
        ans.pop_back();
    }
  }
  cout << ans;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(std::string s) {
  string ans;
  REP(i, s.size()) {
    if (s[i] == '0')
      ans.push_back('0');
    else if (s[i] == '1')
      ans.push_back('1');
    else if (s[i] == 'B') {
      if (i == 0)
        continue;
      ans.pop_back();
    }
  }
  cout << ans << '\n';
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::string s;
  std::cin >> s;
  solve(s);
  return 0;
}


Fixed submission:
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(std::string s) {
  string ans;
  REP(i, s.size()) {
    if (s[i] == '0')
      ans.push_back('0');
    else if (s[i] == '1')
      ans.push_back('1');
    else if (s[i] == 'B') {
      if (ans.size() == 0)
        continue;
      ans.pop_back();
    }
  }
  cout << ans << '\n';
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::string s;
  std::cin >> s;
  solve(s);
  return 0;
}
Problem p04030 (C++)

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

using namespace std;

string s;
vector<char> v1;

int main() {

  cin >> s;

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

  string str1(v1.begin(), v1.end());
  cout << str1 << "\n";

  return 0;
}

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

using namespace std;

string s;
vector<char> v1;

int main() {

  cin >> s;

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

  string str1(v1.begin(), v1.end());
  cout << str1 << "\n";

  return 0;
}
Problem p04030 (C++)

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

using namespace std;

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

  string s, ans;

  cin >> s;

  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '0' || s[i] == '1') {
      ans.push_back(s[i]);
    } else if (s[i] == 'B') {
      ans.pop_back();
    }
  }

  cout << ans << endl;
}


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

using namespace std;

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

  string s, ans;

  cin >> s;

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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, ans;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0' || s.at(i) == '1') {
      ans += s.at(i);
    } 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.size(); i++) {
    if (s.at(i) == '0' || s.at(i) == '1') {
      ans += s.at(i);
    } else if (ans.size() == 0) {
      continue;
    } else {
      ans.pop_back();
    }
  }
  cout << ans;
}
Problem p04030 (C++)

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

using namespace std;

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

  string ans;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      ans.push_back('0');

    else if (s[i] == '1')
      ans.push_back('1');

    else if (s[i] == 'B')
      ans.pop_back();
  }

  cout << ans << endl;
}


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

using namespace std;

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

  string ans;

  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 (s[i] == 'B' && !ans.empty())
      ans.pop_back();
  }

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

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

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

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0')
      t.push_back('0');
    else if (s.at(i) == '1')
      t.push_back('1');
    else
      t.pop_back();
  }
  cout << t << endl;
}


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

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

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0')
      t.push_back('0');
    else if (s.at(i) == '1')
      t.push_back('1');
    else {
      if (t.size() != 0)
        t.pop_back();
    }
  }
  cout << t << endl;
}
Problem p04030 (C++)

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

int main() {
  std::string s;
  std::cin >> s;
  std::vector<char> a;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1' || s[i] == '0') {
      a.push_back(s[i]);
    } else if (!(a[i - 1] == '\0')) {
      a.pop_back();
    }
  }
  for (int i = 0; i < a.size(); i++) {
    std::cout << a[i];
  }
  return 0;
}


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

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

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

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


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

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

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'B') {
      s.erase(i - 1, 2);
      i -= 2;
    }
  }
  cout << s << endl;
}

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

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

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

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

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

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

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

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


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

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

Buggy submission (status: Runtime Error):
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main() {
  string str, answer;
  cin >> str;
  answer = "";

  for (int i = 0; i < str.length(); ++i) {
    if (str[i] == '1') {
      answer += '1';
    } else if (str[i] == '0') {
      answer += '0';
    } else {
      answer.erase(answer.length() - 1);
    }
  }

  cout << answer << endl;

  return 0;
}


Fixed submission:
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main() {
  string str, answer;
  cin >> str;
  answer = "";

  for (int i = 0; i < str.length(); ++i) {
    if (str[i] == '1') {
      answer += '1';
    } else if (str[i] == '0') {
      answer += '0';
    } else {
      if (answer.length() != 0) {
        answer.erase(answer.length() - 1);
      }
    }
  }

  cout << answer << endl;

  return 0;
}
Problem p04030 (C++)

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

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  string s, ans = "";
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == 'B' && !ans.empty())
      ans.pop_back();
    else if (s[i] != 'B')
      ans += s[i];
  }

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

Buggy submission (status: Runtime Error):
// AtCoder ABC043 B - バイナリハックイージー / Unhappy Hacking (ABC Edit)
#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;

int main() {
  string s;
  cin >> s;
  string out;
  for (const auto &i : s) {
    if (i == '0')
      out.push_back('0');
    else if (i == '1')
      out.push_back('1');
    else if (i == 'B')
      out.pop_back();
  }
  cout << out << endl;
  return 0;
}

Fixed submission:
// AtCoder ABC043 B - バイナリハックイージー / Unhappy Hacking (ABC Edit)
#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;

int main() {
  string s;
  cin >> s;
  string out;
  for (const auto &i : s) {
    if (i == '0')
      out.push_back('0');
    else if (i == '1')
      out.push_back('1');
    else if (i == 'B') {
      if (out.length() > 0)
        out.pop_back();
    }
  }
  cout << out << endl;
  return 0;
}
Problem p04030 (C++)

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

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

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

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
  string s, ans;
  cin >> s;
  int n = s.size();
  REP(i, n) {
    if (s[i] == '0' || s[i] == '1')
      ans += s[i];
    else if (ans.size() > 0)
      ans.pop_back();
  }
  cout << ans << endl;
}
Problem p04030 (C++)

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

using namespace std;

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

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (c == '0')
      ans.push_back('0');
    else if (c == '1')
      ans.push_back('1');
    else if (c == 'B') {
      if (s.size() >= 1)
        ans.pop_back();
      else
        ;
    } else
      ;
  }
  cout << ans;
}


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

using namespace std;

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

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (c == '0')
      ans.push_back('0');
    else if (c == '1')
      ans.push_back('1');
    else if (c == 'B') {
      if (ans.size() >= 1)
        ans.pop_back();
      else
        ;
    } else
      ;
  }
  cout << ans;
}
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.size(); i++) {
    if (s[i] == '0') {
      ans += '0';
    } else if (s[i] == '1') {
      ans += '1';
    } else {
      ans.pop_back();
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int main() {
  string s, ans;

  cin >> s;

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

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

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

void sout(string *a, string *b) {
  if (*a > *b) {
    string c = *a;
    *a = *b;
    *b = c;
  }
}
int main() {
  string s, t;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      t += '0';
    else if (s[i] == '1')
      t += '1';
    else
      t.pop_back();
  }
  cout << t << endl;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

void sout(string *a, string *b) {
  if (*a > *b) {
    string c = *a;
    *a = *b;
    *b = c;
  }
}
int main() {
  string s, t;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      t += '0';
    else if (s[i] == '1')
      t += '1';
    else {
      int c = t.size();
      if (c > 0)
        t.pop_back();
    }
  }
  cout << t << endl;
}
Problem p04030 (C++)

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

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


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

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
char s[10];
int main() {
  cin >> s;
  string ans;
  for (int i = 0; i < 10; ++i) {
    if (s[i] == '0' || s[i] == '1') {
      ans += s[i];
    }
    if (s[i] == 'B') {
      ans.pop_back();
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
char s[10];
int main() {
  cin >> s;
  string ans;
  for (int i = 0; i < 10; ++i) {
    if (s[i] == '0' || s[i] == '1') {
      ans += s[i];
    }
    if (s[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() {
  ios::sync_with_stdio(false);
  string s, res = "";
  cin >> s;
  for (auto el : s) {
    if (el != 'B')
      res += el;
    else
      res.pop_back();
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  string s, res = "";
  cin >> s;
  for (auto el : s) {
    if (el != 'B')
      res += el;
    else if (!res.empty())
      res.pop_back();
  }
  cout << res << endl;
  return 0;
}
Problem p04030 (C++)

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

int main() {
  string s;
  string c;

  cin >> c;

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

  cout << s << endl;

  return 0;
}

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

int main() {
  string s;
  string c;

  cin >> c;

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

  cout << s << endl;

  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
//	cin>>n>>k;
//	cout<<n<<k<<endl;
// string S[100];
// 43

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

  for (int i = 0; i < in.size(); i++) {
    // cout<<"else"<<endl;
    if (in[i] == '1') {

      ans += '1';
    } else if (in[i] == '0') {

      ans += '0';
    } else {

      ans.erase(ans.end() - 1);
    }
  }
  // in.erase(in.begin()+1);
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
//	cin>>n>>k;
//	cout<<n<<k<<endl;
// string S[100];
// 43

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

  for (int i = 0; i < in.size(); i++) {
    // cout<<"else"<<endl;
    if (in[i] == '1') {

      ans += '1';
    } else if (in[i] == '0') {

      ans += '0';
    } else if (in[i] == 'B' && ans.size() != 0) {

      ans.erase(ans.end() - 1);
    }
  }
  // in.erase(in.begin()+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, f;
  cin >> s;

  size_t i;
  for (i = 0; i < s.size(); i++) {

    if (s[i] != 'B') {

      f = f + s[i];

    }

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

      if (f.size() >= 1) {

        f.erase(f.begin() + (i - 1));
      }
    }
  }

  cout << f << endl;

  return 0;
}

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

int main() {

  string s, f;
  cin >> s;

  size_t i;
  for (i = 0; i < s.size(); i++) {

    if (s[i] != 'B') {

      f = f + s[i];

    }

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

      if (f.size() >= 1) {

        f.erase(f.size() - 1, i);
      }
    }
  }

  cout << f << endl;

  return 0;
}
Problem p04030 (C++)

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool cmp(const string &a, const string &b) { return (a + b) < (b + a); }

vector<int> Reversed(const vector<int> &s) {
  vector<int> d = s;
  reverse(all(d));
  return d;
}

void solve() {
  string s, s1 = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      s1 += '0';
    if (s[i] == '1')
      s1 += '1';
    if (s[i] == 'B')
      s1.erase(s1.begin() + (s1.size() - 1));
  }
  cout << s1;
}

// ."ww"w"".ww"""...ww"".

int main() {
  // freopen("lepus.in","r",stdin);
  // freopen("lepus.out","w",stdout);
  // faster();
  int n = 1;
  // cin>>n;
  while (n--) {
    solve();
    // cout << endl;
  }
  // fclose(stdout);
}


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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
bool cmp(const string &a, const string &b) { return (a + b) < (b + a); }

vector<int> Reversed(const vector<int> &s) {
  vector<int> d = s;
  reverse(all(d));
  return d;
}

void solve() {
  string s, s1 = "";
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      s1 += '0';
    if (s[i] == '1')
      s1 += '1';
    if (s[i] == 'B' && !s1.empty())
      s1.erase(s1.begin() + (s1.size() - 1));
  }
  cout << s1;
}

// ."ww"w"".ww"""...ww"".

int main() {
  // freopen("lepus.in","r",stdin);
  // freopen("lepus.out","w",stdout);
  // faster();
  int n = 1;
  // cin>>n;
  while (n--) {
    solve();
    // cout << endl;
  }
  // fclose(stdout);
}
Problem p04030 (C++)

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

int main() {
  string s;
  deque<char> st;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] != 'B')
      st.push_back(s[i]);
    else
      st.pop_back();
  }
  int st_size = st.size();
  rep(i, st_size) {
    cout << st.front();
    st.pop_front();
  }
  return 0;
}


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

int main() {
  string s;
  deque<char> st;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] != 'B')
      st.push_back(s[i]);
    else if (!st.empty())
      st.pop_back();
  }
  int st_size = st.size();
  rep(i, st_size) {
    cout << st.front();
    st.pop_front();
  }
  return 0;
}
Problem p04030 (C++)

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

int main() {
  string a, result;
  cin >> a;
  int str_len = a.length();
  for (int i(0); i < str_len; i++) {
    // cout << (a[i] == '0') << endl;
    if (a[i] == '0' || a[i] == '1') {
      // 文字を追加する
      result = result += a[i];
    } else {
      // 文字を削除する
      result.erase(--result.end());
    }
  }
  cout << result;
  // int a[] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
  // int b,c;
  // cin >> b >> c;
  // cout << (a[b] == a[c] ? "Yes" : "No");
  // cin>>a>>b>>c;
  // cout << a[0] << b[0] << c[0];
  // char d[] = {a[0],b[0],c[0],'\0'};
  // cout << d;
  // const char *a = "dabfab";
  // char a[] = "si";
  // int a[2]={1,4};
  // cout << &a[0]<< &a[1] << &a[2];
  return 0;
}


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

int main() {
  string a, result;
  cin >> a;
  int str_len = a.length();
  for (int i(0); i < str_len; i++) {
    // cout << (a[i] == '0') << endl;
    if (a[i] == '0' || a[i] == '1') {
      // 文字を追加する
      result = result += a[i];
    } else if (result.length() != 0 && a[i] == 'B') {
      // 文字を削除する
      result.erase(--result.end());
    }
  }
  cout << result;
  // int a[] = {0,0,2,0,1,0,1,0,0,1,0,1,0};
  // int b,c;
  // cin >> b >> c;
  // cout << (a[b] == a[c] ? "Yes" : "No");
  // cin>>a>>b>>c;
  // cout << a[0] << b[0] << c[0];
  // char d[] = {a[0],b[0],c[0],'\0'};
  // cout << d;
  // const char *a = "dabfab";
  // char a[] = "si";
  // int a[2]={1,4};
  // cout << &a[0]<< &a[1] << &a[2];
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;
template <typename T> inline void add(T &a, T b) {
  a += b;
  if (a >= MOD)
    a -= MOD;
}

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

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


Fixed submission:
#include <bits/stdc++.h>
#include <numeric>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;
template <typename T> inline void add(T &a, T b) {
  a += b;
  if (a >= MOD)
    a -= MOD;
}

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

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;
int main() {
  vector<char> editor;
  char c;
  while (cin >> c) {
    if (c == '0')
      editor.push_back('0');
    else if (c == '1')
      editor.push_back('1');
    else
      editor.pop_back();
  }
  for (auto x : editor)
    cout << x;
  cout << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;
int main() {
  vector<char> editor;
  char c;
  while (cin >> c) {
    if (c == '0')
      editor.push_back('0');
    else if (c == '1')
      editor.push_back('1');
    else if (editor.size())
      editor.pop_back();
  }
  for (auto x : editor)
    cout << x;
  cout << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define i64 long long
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007

void solve(void) {
  string str;
  cin >> str;
  vector<char> vec;

  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '0') {
      vec.push_back('0');
    } else if (str[i] == '1') {
      vec.push_back('1');
    } else {
      if (str.size() != 0) {
        vec.erase(vec.begin() + vec.size() - 1);
      }
    }
  }

  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i];
  }
  cout << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[]) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

  return 0;
}

Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define i64 long long
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007

void solve(void) {
  string str;
  cin >> str;
  vector<char> vec;

  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '0') {
      vec.push_back('0');
    } else if (str[i] == '1') {
      vec.push_back('1');
    } else {
      if (vec.size() != 0) {
        vec.erase(vec.begin() + vec.size() - 1);
      }
    }
  }

  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i];
  }
  cout << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[]) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

  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 (char c : s) {
    if (c == '1' || c == '0') {
      ans += c;
    } else {
      if (s.size())
        ans = ans.substr(ans.size() - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  cin >> s;
  string ans = "";
  for (char c : s) {
    if (c == '1' || c == '0') {
      ans += c;
    } else {
      if (s.size())
        ans = ans.substr(0, ans.size() - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <ctype.h>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

#define INF 200000000
#define MOD 1000000007

using namespace std;

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

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


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <ctype.h>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

#define INF 200000000
#define MOD 1000000007

using namespace std;

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

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

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


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

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

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

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

  string ans;
  REP(i, s.size()) {
    if (s[i] == 'B') {
      if (i != 0)
        ans.pop_back();
    } else
      ans += s[i];
  }

  cout << ans << endl;
}

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

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

  string ans;
  REP(i, s.size()) {
    if (s[i] == 'B') {
      if (ans.size() != 0)
        ans.pop_back();
    } else
      ans += s[i];
  }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <assert.h>
#include <cstring>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#pragma warning(disable : 4996)

typedef long long ll;
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100];

int main(int argc, char *argv[]) {
  scanf("%s", str);

  long len = strlen(str);
  long curr = 0;
  while (curr < len) {
    if (str[curr] == '0' || str[curr] == '1') {
      curr++;
    } else {
      if (curr > 0) {
        curr--;
        long k;
        for (k = curr; k < len - 2; k++) {
          str[k] = str[k + 2];
        }
        len -= 2;
      } else {
        long k;
        for (k = curr; k < len - 1; k++) {
          str[k] = str[k + 1];
        }
        len--;
        curr--;
      }
    }
  }
  str[len] = '\0';
  printf("%s\n", str);

  return 0;
}


Fixed submission:
#include <algorithm>
#include <assert.h>
#include <cstring>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#pragma warning(disable : 4996)

typedef long long ll;
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100];

int main(int argc, char *argv[]) {
  scanf("%s", str);

  long len = strlen(str);
  long curr = 0;
  while (curr < len) {
    if (str[curr] == '0' || str[curr] == '1') {
      curr++;
    } else {
      if (curr > 0) {
        curr--;
        long k;
        for (k = curr; k < len - 2; k++) {
          str[k] = str[k + 2];
        }
        len -= 2;
      } else {
        long k;
        for (k = curr; k < len - 1; k++) {
          str[k] = str[k + 1];
        }
        len--;
      }
    }
  }
  str[len] = '\0';
  printf("%s\n", str);

  return 0;
}
Problem p04030 (C++)

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

int main() {

  string S, A = "";
  cin >> S;

  if (S.at(0) == '1') {
    A.push_back('1');
  }
  if (S.at(0) == '0') {
    A.push_back('0');
  }
  for (int i = 1; i < S.length(); i++) {
    if (S.at(i) == 'B') {
      A.pop_back();
    }
    if (S.at(i) == '1') {
      A.push_back('1');
    }
    if (S.at(i) == '0') {
      A.push_back('0');
    }
  }

  cout << A << endl;
}

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

int main() {

  string S, A = "";
  cin >> S;

  if (S.at(0) == '1') {
    A.push_back('1');
  }
  if (S.at(0) == '0') {
    A.push_back('0');
  }
  for (int i = 1; i < S.length(); i++) {
    if (S.at(i) == 'B') {
      if (A != "") {
        A.pop_back();
      }
    }
    if (S.at(i) == '1') {
      A.push_back('1');
    }
    if (S.at(i) == '0') {
      A.push_back('0');
    }
  }

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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, t;
  cin >> s;
  for (unsigned int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      t += '0';
    if (s[i] == '1')
      t += '1';
    if (s[i] == 'B' && s.size() != 0)
      t.pop_back();
  }
  cout << t << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, t;
  cin >> s;
  for (unsigned int i = 0; i < s.size(); i++) {
    if (s[i] == '0')
      t += '0';
    if (s[i] == '1')
      t += '1';
    if (s[i] == 'B' && t.size() != 0)
      t.pop_back();
  }
  cout << t << endl;
  return 0;
}
Problem p04030 (C++)

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

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

  string ans = "";
  rep(i, 0, s.size()) {
    if (s[i] == '0')
      ans.append("0");
    else if (s[i] == '1')
      ans.append("1");
    else
      ans.erase(ans.size() - 1, 1);
  }
  cout << ans << endl;
}


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

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

  string ans = "";
  rep(i, 0, s.size()) {
    if (s[i] == '0')
      ans.append("0");
    else if (s[i] == '1')
      ans.append("1");
    else if (ans.size() == 0 and s[i] == 'B')
      continue;
    else
      ans.erase(ans.size() - 1, 1);
  }
  cout << ans << endl;
}
Problem p04030 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const int mod = 1e9 + 7;

int main() {
  string s, ans;

  cin >> s;

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

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

Fixed submission:
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const int mod = 1e9 + 7;

int main() {
  string s, ans;

  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B')
      ans += s[i];
    else if (s[i] == 'B' and ans.size() > 0) {
      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 a;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1')
      a.push_back('1');
    if (s[i] == '0')
      a.push_back('0');
    if (s[i] == 'B')
      a.pop_back();
  }

  cout << a << endl;

  return 0;
}


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

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

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

  cout << a << endl;

  return 0;
}
Problem p04030 (C++)

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

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

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

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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  string c;
  int i;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      c.push_back('0');
    } else if (s[i] == '1') {
      c.push_back('1');
    } else if (s[i] == 'B') {
      c.pop_back();
    } else {
      break;
    }
  }
  cout << c << "\n";
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  string c;
  int i;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '0') {
      c.push_back('0');
    } else if (s[i] == '1') {
      c.push_back('1');
    } else if (s[i] == 'B') {
      if (c.size() == 0)
        continue;
      else
        c.pop_back();
    } else {
      break;
    }
  }
  cout << c << "\n";
  return 0;
}
Problem p04030 (C++)

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

int main() {
  // 入力
  string s;
  cin >> s;

  // 処理
  deque<char> output;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'B') {
      output.pop_back();
    } else {
      output.push_back(s.at(i));
    }
  }
  // 出力
  for (int i = 0; i < output.size(); i++) {
    cout << output.at(i);
  }
  cout << endl;
}

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

int main() {
  // 入力
  string s;
  cin >> s;

  // 処理
  deque<char> output;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'B') {
      if (output.empty() == false)
        output.pop_back();
    } else {
      output.push_back(s.at(i));
    }
  }
  // 出力
  for (int i = 0; i < output.size(); i++) {
    cout << output.at(i);
  }
  cout << endl;
}