alexjercan/bugnet huggingface dataset:
Problem p02429 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  ll A = 0;
  vector<ll> b(k);
  for (ll i = 0; i < k; i++) {
    cin >> b[i];
    A |= (1 << b[i]);
  }
  vector<ll> sb;
  for (ll bit = A;; bit = (bit - 1) & A) {
    sb.push_back(bit);

    if (!bit)
      break;
  }
  sort(sb.begin(), sb.end());

  for (int i = 0; i < sb.size(); i++) {
    cout << sb[i] << ":";
    for (int j = 0; j < n; j++) {
      if (sb[i] & (1 << j)) {
        cout << " " << j;
      }
    }
    cout << endl;
  }
}


Error: 0

Fixed submission:

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

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  ll A = 0;
  vector<ll> b(k);
  for (ll i = 0; i < k; i++) {
    cin >> b[i];
    A |= (1 << b[i]);
  }
  vector<pair<ll, vector<ll>>> sb(pow(2, n + 1));
  ll c = 0;
  for (ll bit = A;; bit = (bit - 1) & A) {
    sb[c].first = bit;
    for (ll i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        sb[c].second.push_back(i);
      }
    }

    c++;

    if (!bit)
      break;
  }
  sort(sb.begin(), sb.end());
  sb.erase(unique(sb.begin(), sb.end()), sb.end());

  for (ll i = 0; i < c; i++) {
    cout << sb[i].first << ":";
    for (ll j = 0; j < sb[i].second.size(); j++) {
      cout << " " << sb[i].second[j];
    }
    cout << endl;
  }
}
Problem p02431 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int q, x, n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    cin >> q;
    if (q == 0) {
      cin >> x;
      a.push_back(x);
    } else if (q == 1) {
      if (a.size() > 0) {
        cin >> x;
        cout << a[x] << endl;
      }
    } else if (q == 2) {
      a.pop_back();
    }
  }
  return 0;
}


Error: -11

Fixed submission:

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

int main() {
  int q, x;
  vector<int> a;
  for (int i = 0; i < q; i++) {
    cin >> q;
    if (q == 0) {
      cin >> x;
      a.push_back(x);
    } else if (q == 1) {
      if (a.size() > 0) {
        cin >> x;
        cout << a[x] << endl;
      }
    } else {
      a.pop_back();
    }
  }
  return 0;
}
Problem p02431 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int q;
  scanf("%d", &q);
  vector<long long int> vi;
  while (q--) {
    long long x, k;
    scanf("%lld", &x);
    if (x == 2) {
      if (!vi.empty())
        vi.pop_back();
    } else if (x == 1) {
      scanf("%lld", &k);
      if (!vi.empty())
        printf("%lld\\n", vi[k]);
    } else {
      scanf("%lld", &k);
      vi.push_back(k);
    }
  }
}


Error: -11

Fixed submission:

#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int q;
  scanf("%d", &q);
  vector<int> vi;
  while (q--) {
    long long x, k;
    scanf("%lld", &x);
    if (x == 2)
      vi.pop_back();
    else if (x == 1 && !vi.empty()) {
      scanf("%lld", &k);
      printf("%lld\\n", vi[k]);
    } else if (!vi.empty()) {
      scanf("%lld", &k);
      vi.push_back(k);
    }
  }
}
Problem p02432 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <fstream>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int q, a, b, c;
deque<int> A;
int main(void) {
  cin >> q;
  rep(i, q) {
    cin >> a >> b;
    switch (a) {
    case 0:
      cin >> c;
      if (b)
        A.push_back(c);
      else
        A.push_front(c);
      break;
    case 1:
      cout << A[b] << endl;
      break;
    case 2:
      if (b)
        A.pop_back();
      else
        A.pop_front();
      break;
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <fstream>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
using namespace std;

int q, num, nume, nunu;
vector<int> A(0, 0);
int main(void) {
  cin >> q;
  repeat(i, q) {
    cin >> num >> nume;
    switch (num) {
    case 0:
      cin >> nunu;
      if (nume)
        A.push_back(nunu);
      else
        A.insert(A.begin(), nunu);
      break;
    case 1:
      cout << A[nume] << endl;
      break;
    case 2:
      if (nume)
        A.pop_back();
      else
        A.erase(A.begin());
      break;
    }
  }
}
Problem p02432 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  deque<int> a;
  int q, query, t, x;

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> query;
    if (query == 0) {
      cin >> x >> t;
      if (x == 1)
        a.push_back(t);
      else
        a.push_front(t);
    } else if (query == 1) {
      cin >> t;
      cout << a[t] << endl;
    } else {
      cin >> t;
      if (t == 1)
        a.pop_back();
      else
        a.pop_front();
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  vector<int> a;
  int q, query, t, x;

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> query;
    if (query == 0) {
      cin >> x >> t;
      if (x == 1)
        a.push_back(t);
      else
        a.insert(a.begin(), t);
    } else if (query == 1) {
      cin >> t;
      cout << a[t] << endl;
    } else {
      cin >> t;
      if (t == 1)
        a.pop_back();
      else
        a.erase(a.begin());
    }
  }

  return 0;
}
Problem p02432 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <deque>
#include <iostream>
using namespace std;

deque<int> deq;

void push(int d, int x) {
  if (d)
    deq.push_back(x);
  else
    deq.push_front(x);
}

int randomAccess(int p) { return deq[p]; }

void pop(int d) {
  if (d)
    deq.pop_back();
  else
    deq.pop_front();
}

int main() {
  int q, com, d, x, p;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> com;
    switch (com) {
    case 0:
      cin >> d >> x;
      push(d, x);
      break;
    case 1:
      cin >> p;
      cout << randomAccess(p) << endl;
      break;
    case 2:
      cin >> d;
      pop(d);
      break;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

vector<int> vec;

void push(int d, int x) {
  if (d)
    vec.push_back(x);
  else
    vec.insert(vec.begin(), x);
}

int randomAccess(int p) { return vec[p]; }

void pop(int d) {
  if (d)
    vec.pop_back();
  else
    vec.erase(vec.begin());
}

int main() {
  int q, com, d, x, p;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> com;
    switch (com) {
    case 0:
      cin >> d >> x;
      push(d, x);
      break;
    case 1:
      cin >> p;
      cout << randomAccess(p) << endl;
      break;
    case 2:
      cin >> d;
      pop(d);
      break;
    }
  }
  return 0;
}
Problem p02432 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef deque<int> D;
int main(void) {
  int q;
  int n, d, x;
  int i;
  D d1;
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> n;
    if (n == 0) {
      cin >> d;
      cin >> x;
      if (d == 0) {
        d1.push_front(x);
      } else {
        d1.push_back(x);
      }
    } else if (n == 1) {
      cin >> x;
      cout << d1[x] << endl;
    } else {
      cin >> d;
      if (d == 0) {
        d1.pop_front();
      } else {
        d1.pop_back();
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> V;
int main(void) {
  int q;
  int n, d, x;
  V v;
  int i;
  cin >> q;
  for (i = 0; i < q; i++) {
    cin >> n;
    if (n == 0) {
      cin >> d;
      cin >> x;
      if (d == 0) {
        v.insert(v.begin(), x);
      } else {
        v.push_back(x);
      }
    } else if (n == 1) {
      cin >> x;
      cout << v[x] << endl;
    } else {
      cin >> d;
      if (d == 0) {
        v.erase(v.begin());
      } else {
        v.pop_back();
      }
    }
  }
  return 0;
}
Problem p02433 (C++) — buggy submission, verdict: Runtime Error

#include <list>
#include <stdio.h>
using namespace std;
int main() {
  list<int> l;
  list<int>::iterator u = l.begin();
  int n, k;
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &k);
    if (k == 0) {
      scanf("%d", &k);
      u = l.insert(u, k);
    } else if (k == 1) {
      scanf("%d", &k);
      if (k > 0)
        while (k--)
          u++;
      else {
        k = -k;
        while (k--)
          u--;
      }
    } else
      u = l.erase(u);
  }
  for (int i : l)
    printf("%d\\n", i);
}


Error: 0

Fixed submission:

#include <list>
#include <stdio.h>
using namespace std;
int main() {
  list<int> l;
  list<int>::iterator u = l.begin();
  int n, k;
  scanf("%d", &n);

  while (n--) {
    scanf("%d", &k);
    if (k == 0) {
      scanf("%d", &k);
      u = l.insert(u, k);
    } else if (k == 1) {
      scanf("%d", &k);
      if (k > 0)
        while (k--)
          u++;
      else {
        k = -k;
        while (k--)
          u--;
      }
    } else
      l.erase(u);
  }
  for (int i : l)
    printf("%d\\n", i);
}
Problem p02433 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef list<int> L;
int main(void) {
  int q;
  int n, d, x;
  L li;
  int p;
  int i, j;
  cin >> q;
  auto itr = li.end();
  for (i = 0; i < q; i++) {
    cin >> n;
    if (n == 0) {
      cin >> x;
      li.insert(itr, x);
      itr--;
    } else if (n == 1) {
      cin >> d;
      if (d >= 0) {
        for (j = 1; j <= d; j++)
          itr++;
      } else {
        for (j = 1; j <= abs(d); j++)
          itr--;
      }
    } else {
      itr = li.erase(itr);
    }
    /*for(auto it=li.begin();it!=li.end();it++){
            cout<<*it<<endl;
    }*/
  }
  for (auto it = li.begin(); it != li.end(); it++) {
    cout << *it << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef list<int> L;
int main(void) {
  int q;
  int n, d, x;
  L li;
  int p;
  int i, j;
  cin >> q;
  auto itr = li.end();
  for (i = 0; i < q; i++) {
    cin >> n;
    if (n == 0) {
      cin >> x;
      li.push_front(x);
      itr--;
    } else if (n == 1) {
      cin >> d;
      if (d >= 0) {
        for (j = 1; j <= d; j++)
          itr++;
      } else {
        for (j = 1; j <= abs(d); j++)
          itr--;
      }
    } else {
      li.erase(itr);
    }
  }
  for (auto it = li.begin(); it != li.end(); it++) {
    cout << *it << endl;
  }
  return 0;
}
Problem p02433 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#define long long long
using namespace std;
typedef pair<int, int> pii;
template <class A, class B> inline bool chmax(A &a, const B &b) {
  return b > a ? a = b, 1 : 0;
}
template <class A, class B> inline bool chmin(A &a, const B &b) {
  return b < a ? a = b, 1 : 0;
}
constexpr int INF = 0x3f3f3f3f;

signed main() {
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int q;
  list<int> ls;
  auto itr = ls.begin();

  cin >> q;
  while (q--) {
    int com, x;
    cin >> com;

    if (com == 0) {
      cin >> x;
      itr = ls.emplace(itr, x);
    } else if (com == 1) {
      cin >> x;
      advance(itr, x);
    } else {
      itr = ls.erase(itr);
    }
  }

  for (int e : ls) {
    cout << e << '\\n';
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#define long long long
using namespace std;
typedef pair<int, int> pii;
template <class A, class B> inline bool chmax(A &a, const B &b) {
  return b > a ? a = b, 1 : 0;
}
template <class A, class B> inline bool chmin(A &a, const B &b) {
  return b < a ? a = b, 1 : 0;
}
constexpr int INF = 0x3f3f3f3f;

signed main() {
  cin.tie(nullptr), ios::sync_with_stdio(false);
  int q;
  list<int> ls;
  int cursor = 0;

  cin >> q;
  while (q--) {
    int com, x;
    cin >> com;

    if (com == 0) {
      cin >> x;
      ls.emplace(next(ls.begin(), cursor), x);
    } else if (com == 1) {
      cin >> x;
      cursor += x;
    } else {
      ls.erase(next(ls.begin(), cursor));
    }
  }

  for (int e : ls) {
    cout << e << '\\n';
  }

  return 0;
}
Problem p02433 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  list<int> a;
  list<int>::iterator it = a.end();
  int q, query, t, x;

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> query;
    if (query == 0) {
      cin >> x;
      it = a.insert(it, x);
    } else if (query == 1) {
      cin >> x;
      if (x > 0)
        for (int i = 0; i < x; i++)
          it++;
      else {
        x *= -1;
        for (int i = 0; i < x; i++)
          it--;
      }
    } else {
      it = a.erase(it);
    } // cout<<" "<<i<<endl;
  }

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

  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  list<int> a;
  list<int>::iterator it = a.end();
  int q, query, t, x;

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> query;
    if (query == 0) {
      cin >> x;
      it = a.insert(it, x);
    } else if (query == 1) {
      cin >> x;
      if (x > 0)
        for (int i = 0; i < x; i++)
          it++;
      else {
        x *= -1;
        for (int i = 0; i < x; i++)
          it--;
      }
    } else {
      a.erase(it);
    } // cout<<" "<<i<<endl;
  }

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

  return 0;
}
Problem p02433 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <list>
using namespace std;

int main() {
  list<int> a;
  list<int>::iterator c = a.end();
  int q;

  cin >> q;

  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;

    if (t == 0) {
      int x;
      cin >> x;

      c = a.insert(c, x);
    } else if (t == 1) {
      int d;
      cin >> d;

      if (d > 0) {
        for (int j = 0; j < d; j++)
          c++;
      } else {
        for (int j = 0; j < -d; j++)
          c--;
      }
    } else if (t == 2) {
      c = a.erase(c);
    }
  }

  for (list<int>::iterator itr = a.begin(); itr != a.end(); itr++)
    cout << *itr << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <list>
using namespace std;

int main() {
  list<int> a;
  list<int>::iterator c = a.end();
  int q;

  cin >> q;

  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;

    if (t == 0) {
      int x;
      cin >> x;

      a.insert(c, x);
      c--;
    } else if (t == 1) {
      int d;
      cin >> d;

      if (d > 0) {
        for (int j = 0; j < d; j++)
          c++;
      } else {
        for (int j = 0; j < -d; j++)
          c--;
      }
    } else if (t == 2)
      a.erase(c);
  }

  for (list<int>::iterator itr = a.begin(); itr != a.end(); itr++)
    cout << *itr << endl;

  return 0;
}
Problem p02433 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  list<int> ls;
  auto it = ls.end();
  int q;
  cin >> q;
  rep(i, q) {
    int a;
    cin >> a;
    if (a == 0) {
      int b;
      cin >> b;
      it = ls.insert(it, b);
    } else if (a == 1) {
      int b;
      cin >> b;
      if (b > 0)
        rep(i, b) it++;
      else
        rep(i, -b) it--;
    } else {
      it = ls.erase(it);
    }
  }
  for (auto i : ls)
    cout << i << endl;
}


Error: 0

Fixed submission:

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

int main() {
  list<int> ls;
  auto it = ls.end();
  int q;
  cin >> q;
  rep(i, q) {
    int a;
    cin >> a;
    if (a == 0) {
      int b;
      cin >> b;
      it = ls.insert(it, b);
    } else if (a == 1) {
      int b;
      cin >> b;
      if (b > 0)
        rep(i, b) it++;
      else
        rep(i, b) it--;
    } else {
      ls.erase(it);
    }
  }
  for (auto i : ls)
    cout << i << endl;
}
Problem p02433 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <fstream>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; (i) < (n); ++(i))
using namespace std;

int main() {
  list<int> a;
  list<int>::iterator c = a.end();
  int q;
  cin >> q;
  rep(i, q) {
    int t;
    cin >> t;
    switch (t) {
    case 0:
      int x;
      cin >> x;
      c = a.insert(c, x);
      break;
    case 1:
      int d;
      cin >> d;
      if (d > 0)
        rep(j, d) c++;
      else
        rep(j, -d) c--;
      break;
    case 2:
      c = a.erase(c);
      break;
    }
  }
  for (list<int>::iterator itr = a.begin(); itr != a.end(); itr++)
    cout << *itr << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <fstream>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; (i) < (n); ++(i))
using namespace std;

int q, a, b, c;
deque<int> A;
int main(void) {
  cin >> q;
  c = 0;
  rep(i, q) {
    cin >> a;
    switch (a) {
    case 0:
      cin >> b;
      A.insert(A.begin() + c, b);
      break;
    case 1:
      cin >> b;
      c += b;
      break;
    case 2:
      A.erase(A.begin() + c);
      break;
    }
  }
  rep(i, A.size()) { cout << A[i] << endl; }
}
Problem p02433 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  list<int> L;
  auto it = L.end();
  int q;
  cin >> q;
  while (q--) {
    int code;
    cin >> code;
    switch (code) {
    case 0: {
      int x;
      cin >> x;
      it = L.insert(it, x);
    } break;
    case 1: {
      int d;
      cin >> d;
      advance(it, d);
    } break;
    case 2: {
      it = L.erase(it);
    } break;
    default:
      break;
    }
  }
  for (auto i : L)
    cout << i << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  list<int> L;
  auto it = L.end();
  int q;
  cin >> q;
  while (q--) {
    int code;
    cin >> code;
    switch (code) {
    case 0: {
      int x;
      cin >> x;
      it = L.insert(it, x);
    } break;
    case 1: {
      int d;
      cin >> d;
      advance(it, d);
    } break;
    case 2: {
      L.erase(it);
    } break;
    }
  }
  for (auto i : L)
    cout << i << endl;
  return 0;
}
Problem p02433 (C++) — buggy submission, verdict: Runtime Error

#include <iterator>
#include <list>
#include <stdio.h>

using namespace std;

int main() {
  list<int> lst;
  list<int>::iterator itr = lst.begin();
  int q;
  long x;
  int t;
  int d;

  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%d", &t);
    if (t == 0) {
      scanf("%ld", &x);
      itr = lst.insert(itr, x);
    } else if (t == 1) {
      scanf("%d", &d);
      advance(itr, d);
    } else if (t == 2) {
      itr = lst.erase(itr);
    }
  }

  for (itr = lst.begin(); itr != lst.end(); ++itr) {
    printf("%d\\n", *itr);
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iterator>
#include <list>
#include <stdio.h>

using namespace std;

int main() {
  list<int> lst;
  list<int>::iterator itr = lst.begin();
  int q;
  long x;
  int t;
  int d;
  const long max_x = 1000000001;

  lst.insert(itr, max_x);
  itr--;

  scanf("%d", &q);

  for (int i = 0; i < q; i++) {
    scanf("%d", &t);
    if (t == 0) {
      scanf("%ld", &x);
      lst.insert(itr, x);
      itr--;
    } else if (t == 1) {
      scanf("%d", &d);
      advance(itr, d);
    } else if (t == 2) {
      lst.erase(itr);
    }
  }

  for (itr = lst.begin(); itr != lst.end(); ++itr) {
    if (*itr != max_x) {
      printf("%d\\n", *itr);
    }
  }

  return 0;
}
Problem p02435 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stack>
using namespace std;
int main() {

  int n, q;
  cin >> n >> q;
  stack<int> a[n];

  for (int i = 0; i < q; i++) {
    int n, t;
    cin >> n >> t;
    if (!n) {
      int x;
      cin >> x;
      a[t].push(x);
    } else if (n == 1 && !a[t].empty())
      cout << a[t].top() << endl;
    else if (!a[t].empty())
      a[t].pop();
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <stack>
using namespace std;
int main() {

  int n, q;
  cin >> n >> q;
  stack<int> a[n];

  for (int i = 0; i < q; i++) {
    int n, t;
    cin >> n >> t;
    if (!n) {
      int x;
      cin >> x;
      a[t].push(x);
    } else if (n == 1 && !a[t].empty())
      cout << a[t].top() << endl;
    else
      a[t].pop();
  }

  return 0;
}
Problem p02435 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
int n, q;
stack<int> s[1010];
int main() {
  cin >> n >> q;
  while (q--) {
    int z, t, x;
    cin >> z >> t;
    if (z == 0) {
      cin >> x;
      s[t].push(x);
    }
    if (z == 1 && !s[t].empty())
      cout << s[t].top() << endl;
    if (z == 2 && !s[t].empty())
      s[t].pop();
  }
  getchar();
  getchar();
  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000
int n, q;
stack<int> s[1010];
int main() {
  cin >> n >> q;
  while (q--) {
    int z, t, x;
    cin >> z >> t;
    if (z == 0) {
      cin >> t;
      s[t].push(x);
    }
    if (z == 1)
      cout << s[t].top() << endl;
    if (z == 2 && !s[t].empty())
      s[t].pop();
  }
  return 0;
}
Problem p02435 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, q;
  cin >> n >> q;
  vector<stack<int>> s(n);
  while (q--) {
    int y;
    cin >> y;
    if (y == 0) {
      int t, x;
      cin >> t >> x;
      s[t].push(x);
    } else if (y == 1) {
      int t;
      cin >> t;
      if (!s[t].empty()) {
        cout << s[t].top() << endl;
      }
    } else {
      int t;
      cin >> t;
      if (!s[t].empty()) {
        s[t].pop();
      }
    }
  }
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int n, q;
  cin >> n >> q;
  vector<stack<int>> s(n);
  while (q--) {
    int y;
    cin >> y;
    if (y == 0) {
      int t, x;
      cin >> t >> x;
      s[t].push(x);
    } else if (y == 1) {
      int t;
      cin >> t;
      if (!s[t].empty()) {
        cout << s[t].top() << endl;
      }
    } else {
      int t;
      cin >> t;
      s[t].pop();
    }
  }
  return 0;
}