alexjercan/bugnet huggingface dataset:
Problem p00434 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int h, num, count;
  vector<int> v;
  vector<int> ans;

  num = 1;
  count = 0;

  for (int i = 0; i < 28; ++i) {
    cin >> h;
    v.push_back(h);
  }

  sort(v.begin(), v.end());

  for (int e : v) {
    if (e == num) {
      ++num;
    } else {
      ans.push_back(num);
      ++num;
      ++count;

      if (e == num) {
        ++num;
      } else {
        ans.push_back(num);
        ++num;
        ++count;
      }
    }
    if (count == 2) {
      break;
    }
  }

  if (count == 0) {
    ans.push_back(num);
    ++num;
    ++count;
  }

  if (count == 1) {
    ans.push_back(num);
  }

  for (int f : ans) {
    cout << f << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, h, num, count, m, sum;
  vector<int> v;
  vector<int> ans;

  n = 30;
  num = 1;
  count = 0;

  for (int i = 0; i < n; ++i) {
    cin >> h;
    v.push_back(h);
  }

  sort(v.begin(), v.end());

  for (int e : v) {
    if (e == num) {
      ++num;
    } else {
      ans.push_back(e);
      ++num;
      ++count;

      if (e == num) {
        ++num;
      } else {
        ans.push_back(e);
        ++count;
      }
    }
    if (count == 2) {
      break;
    }
  }

  for (int f : ans) {
    cout << f << endl;
  }

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

#include <stdio.h>
#define N 30

int main(void) {
  int flg[N + 1];
  int id;

  for (int i = 1; i <= N; i++)
    flg[i] = 0;
  while (scanf("%d", &id) != EOF) {
    flg[id] = 1;
  }

  for (int i = 1; i <= N; i++) {
    if (flg[i] == 0)
      printf("%d\\n", i);
  }

  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <stdio.h>
#define N 10

int main(void) {
  int flg[N + 1];
  int id;

  for (int i = 1; i <= N; i++)
    flg[i] = 0;
  while (scanf("%d", &id) != EOF) {
    flg[id] = 1;
  }

  for (int i = 1; i <= N; i++) {
    if (flg[i] == 0)
      printf("%d\\n", i);
  }

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

#include <iostream>
using namespace std;

int main() {
  int student;
  bool judge[31] = {false};

  for (int i = 0; i < 28; i++) {
    cin >> student;
    judge[student] = true;
  }

  for (int i = 1; i <= 30; i++) {
    if (judge[i] == false) {
      cout << i << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int student;
  bool judge[30] = {false};

  for (int i = 0; i < 28; i++) {
    cin >> student;
    judge[student] = true;
  }

  for (int i = 1; i <= 30; i++) {
    if (judge[i] == false) {
      cout << i << endl;
    }
  }
  return (0);
}
Problem p00434 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {

  int t[31] = {0};
  int n;
  for (int i = 0; i < 28; i++) {
    cin >> n;
    t[n] = 1;
  }

  for (int i = 1; i < 31; i++) {
    if (t[i] == 0) {
      cout << i << endl;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  while (true)
    ;
  int a[30] = {0};
  for (int i = 0; i < 30; i++) {
    cin >> a[i];
  }
  sort(a, a + 30);
  for (int i1 = 0; i1 < 30; i1++) {
    if (i1 != 1) {
      if (a[i1 + 1] - a[i1] == 2) {
        cout << a[i1] + 1 << endl;
      }
      if (a[i1 + 1] - a[i1] == 3) {
        cout << a[i1] + 1 << endl << a[i1] + 2 << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p00434 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int d[31] = {0}, t;
  rep(i, 28) cin >> t, d[t] = 1;
  for (int i = 1; i <= 30; i++) {
    if (!d[i])
      cout << i << endl;
  }
}

Error: TLE

Fixed submission:

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

set<vector<int>> data;

void rec(vector<int> d, int last) {
  data.insert(d);
  for (int i = 0; i < last; i++) {
    if (i && d[i] + 1 > d[i - 1])
      continue;
    d[last]--, d[i]++;
    if (data.find(d) == data.end())
      rec(d, d[last] == 0 ? last - 1 : last);
    d[last]++, d[i]--;
  }
}
int main() {
  int n;
  while (cin >> n, n) {
    vector<int> d(n, 1);
    set<vector<int>> emp;
    data = emp;
    rec(d, n - 1);
    for (set<vector<int>>::reverse_iterator it = data.rbegin();
         it != data.rend(); ++it) {
      for (int j = 0; j < (*it).size(); j++)
        if ((*it)[j])
          cout << (j ? " " : "") << (*it)[j];
      cout << endl;
    }
  }
}
Problem p00434 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int i, n[30] = {0};
  while (cin >> i) {
    n[i]++;
  }
  for (int j = 1; j < 30; j++) {
    if (n[j] == 0)
      cout << j << endl;
  }
  if (n[30] == 0)
    cout << "30" << endl;
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int i, n[30] = {0};
  while (cin >> i) {
    n[i]++;
  }
  for (int j = 1; j < 31; j++) {
    if (n[j] == 0)
      cout << j << endl;
  }
  return 0;
}
Problem p00434 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int m[30];
  int number;
  for (int i = 0; i < 30; i++) {
    m[i] = 0;
  }

  for (int i = 0; i < 28; i++) {
    cin >> number;
    for (int j = 0; j < 30; j++) {
      if (number - 1 == j)
        m[number - 1]++;
    }
  }
  for (int i = 0; i < 30; i++) {
    if (m[i] == 0)
      cout << i + 1 << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

  int n[30], t[30];
  int x = 0;

  for (int i = 1; i <= 30; i++) {
    n[i] = 0;
  }

  for (int i = 1; i <= 28; i++) {
    cin >> t[i];

    x = t[i];
    n[x] = x;
    t[i] = n[x];
  }
  for (int i = 1; i <= 30; i++) {

    if (n[i] == 0)
      cout << i << endl;
  }

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

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int d;
  int a[30] = {};
  for (int i = 1; i <= 30; i++) {
    cin >> d;
    a[d] = d;
  }
  for (int j = 1; j <= 30; j++) {
    if (a[j] != j) {
      cout << j << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, num[29];
  for (int i = 0; i < 28; i++) {
    cin >> n;
    num[i] = n;
  }
  sort(num, num + 28);
  int o = 1;
  for (int j = 1; j < 31; j++) {
    if (num[j - 1] != o) {
      cout << o << endl;
      j = j - 1;
    }
    o++;
  }
  return 0;
}
Problem p00434 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int s[31] = {};
  int n;
  for (int i = 0; i < 28; i++) {
    cin >> n;
    s[n] = 1;
  }
  for (int i = 1; i < 31; i++) {
    if (s[i] == 0) {
      cout << i << endl;
    }
  }
  // your code goes here
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int s[30] = {};
  for (int i = 1; i <= 28; i++) {
    int count;
    s[count] = 1;
  }
  for (int i = 1; i <= 30; i++) {
    if (s[i] == 0) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p00434 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int i, t;
bool data[31];
int main() {
  for (i = 0; i < 31; i++) {
    data[i] = 0;
  }
  for (i = 0; i < 28; i++) {
    cin >> t;
    data[t] = 1;
  }
  for (i = 1; i < 31; i++) {
    if (data[i] == 0) {
      cout << i << endl;
    }
  }
  cin >> t;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
bool i, t, data[30];
int main() {
  for (i = 0; i < 30; i++) {
    data[i] = 0;
  }
  for (i = 0; i < 28; i++) {
    cin >> t;
    data[t] = 1;
  }
  for (i = 0; i < 30; i++) {
    if (data[i] == 0) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p00434 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>

using namespace std;

int main(void) {
  int a[28];
  for (int i = 0; i < 28; i++) {
    cin >> a[i];
  }

  sort(a, a + 28);

  int p[2];
  p[0] = 0;
  p[1] = 0;
  int co = 0;
  for (int i = 0; i < 28; i++) {
    if (a[i] != i + 1 + co) {
      p[co] = i + 1 + co;
      co++;
    }
  }
  if (p[1] == 0) {
    p[1] = 30;
  }
  cout << p[0] << endl << p[1] << endl;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <vector>

using namespace std;

int main(void) {
  int n, a[30];

  for (int i = 0; i < 29; i++) {
    cin >> n;
    a[n] = 1;
  }

  for (int i = 0; i < 31; i++) {
    cout << a[i] << endl;
    if (a[i] == 0) {
      cout << i << endl;
    }
  }
}
Problem p00434 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main(void) {
  int temp, a;
  int t[30];
  a = 0;
  for (int i = 0; i < 31; i++) {
    t[i] = 0;
  }
  for (int i = 0; i < 29; i++) {
    cin >> temp;
    t[temp] = 1;
  }
  for (temp = 1; temp <= 30; temp++) {
    if (t[temp] == 0) {
      cout << temp << endl;
    }
  }
}


Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int temp, a;
  int t[31];
  t[temp] = 0;
  a = 0;
  for (int i = 0; i < 31; i++) {
    t[i] = 0;
  }
  for (int i = 0; i < 29; i++) {
    cin >> temp;
    t[temp] = 1;
  }
  for (temp = 1; temp <= 30; temp++) {
    if (t[temp] == 0) {
      cout << temp << endl;
    }
  }
}
Problem p00434 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  int count[31] = {0}, n, i;
  for (i = 1; i <= 28; i++) {
    cin >> n;
    count[n] = 1;
  }
  for (i = 1; i <= 30; i++) {
    if (count[i] == 0) {
      cout << i << endl;
    }
  }
  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int t[30], n[30], i, j, h;
  for (i = 0; i < 28; i++) {
    cin >> t[i];
  }
  for (j = 1; j <= 30; j++) {
    n[j] = j;
  }
  for (i = 0; i < 28; i++) {
    for (h = 1; h <= 30; h++) {
      if (t[i] == n[h])
        n[h] = 0;
    }
  }
  for (i = 1; i <= 30; i++) {
    if (n[i] != 0) {
      cout << n[i] << endl;
    }
  }
  return 0;
}
Problem p00435 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

char *f(char *s) {
  char *a = s;
  for (; *s; s++)
    *s = (*s - 42) % 26 + 65;
  return a;
}

int main() {
  char s[1001];
  scanf("%s", s);
  printf("%s\\n", f(s));
}

Error: 0

Fixed submission:

#include <stdio.h>

char *f(char *s) {
  char *a = s;
  for (; *s; s++)
    *s = (*s - 42) % 26 + 65;
  return a;
}

int main() {
  char *s;
  scanf("%s", s);
  printf("%s\\n", f(s));
}
Problem p00435 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <string>
using namespace std;

int main() {
  string str;
  char tmp[1001];
  scanf("%s", tmp);
  str = tmp;

  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'A' || str[i] == 'B' || str[i] == 'C') {
      str[i] += 23;
    } else {
      str[i] -= 3;
    }
  }

  printf("%s\\n", str.c_str());

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  char s[1001];
  cin >> s;
  int i = 0;
  while (s[i] != 0) {
    if (s[i] == 'X') {
      s[i] = 'A';
    } else if (s[i] == 'Y') {
      s[i] = 'B';
    } else if (s[i] == 'Z') {
      s[i] = 'C';
    } else {
      s[i] += 3;
    }
  }
  printf("%s\\n", s);
}
Problem p00435 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

int main() {
  while (true) {
    char a;
    scanf("%c", &a);
    if ('A' <= a && a <= 'Z') {
      a = (a + 23 - 'A') % 26 + 'A';
      printf("%c", a);
    } else {
      printf("%c", a);
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;

int main() {
  while (true) {
    char a;
    scanf("%c", &a);
    if ('A' <= a && a <= 'Z') {
      a = (a + 23 - 'A') % 26 + 'A';
      printf("%c", a);
    } else {
      printf("%c", a);
    }
  }
  return 0;
}
Problem p00435 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int num;
  char a[1000], b[1000];
  int i, j;
  for (i = 0;; i++) {
    scanf("%c", &a[i]);
    if (a[i] == '\\n') {
      break;
    }
    if (a[i] >= 'A' && a[i] <= 'C') {
      b[i] = a[i] + 23;
    } else {
      b[i] = a[i] - 3;
    }
    printf("%c", b[i]);
  }
  cout << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int num;
  char a[100], b[100];
  int i, j;
  for (i = 0;; i++) {
    scanf("%c", &a[i]);
    if (a[i] == '\\n') {
      break;
    }
    if (a[i] >= 'A' && a[i] <= 'C') {
      b[i] = a[i] + 23;
    } else {
      b[i] = a[i] - 3;
    }
    printf("%c", b[i]);
  }
  cout << endl;
  return 0;
}
Problem p00435 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  char c;
  while (1) {
    scanf("%c", &c);
    if (c == '\\n')
      break;
    if (c < 'D')
      c = c + 26;
    printf("%c", c - 3);
  }
  printf("\\n");
  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>

int main() {
  char a[1000];
  scanf("%s", &a);
  for (int i = 0; a[i] != EOF; i++)
    a[i] = 'A' + ((a[i] - 'A' + 3) % 26);
  printf("%s", a);
  return 0;
}
Problem p00435 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  char ch;

  while (scanf("%c", &ch) != EOF) {
    if (ch >= 'D' && ch <= 'Z')
      ch -= 3;
    else if (ch <= 'C' && ch >= 'A')
      ch += 23;
    printf("%c", ch);
  }
  // printf("\\n");
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  char ch;

  while (scanf("%c", &ch) != '\\n') {
    if (ch >= 'D' && ch <= 'Z')
      ch -= 3;
    else if (ch <= 'C' && ch >= 'A')
      ch += 23;
    printf("%c", ch);
  }
  printf("\\n");
  return 0;
}
Problem p00435 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  char a;
  char b;
  while (cin >> a) {
    b = a - 3;
    if (b < 'A') {
      b = b + 26;
    }
    cout << b;
  }
  cout << endl;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int m;
  cin >> m;
  int n;
  cin >> n;
  int k;
  cin >> k;
  int a[m][n]; // 上からm 左からnまでにあるJの個数
  int b[m][n]; // O
  int c[m][n]; // I
  int j;       // ある行においてマスまでに何個Jがあるか
  int o;
  int i;
  char d;
  int e;
  int f;
  e = 0;
  j = 0;
  o = 0;
  i = 0;
  while (e < n) {
    cin >> d;
    if (d == 'J') {
      j = j + 1;
    }
    if (d == 'O') {
      o = o + 1;
    }
    if (d == 'I') {
      i = i + 1;
    }
    a[0][e] = j;
    b[0][e] = o;
    c[0][e] = i;
    e = e + 1;
  }
  f = 1;
  while (f < m) {
    e = 0;
    j = 0;
    o = 0;
    i = 0;
    while (e < n) {
      cin >> d;
      if (d == 'J') {
        j = j + 1;
      }
      if (d == 'O') {
        o = o + 1;
      }
      if (d == 'I') {
        i = i + 1;
      }
      a[f][e] = a[f - 1][e] + j;
      b[f][e] = b[f - 1][e] + o;
      c[f][e] = c[f - 1][e] + i;
      e = e + 1;
    }
    f = f + 1;
  }
  int p;
  int q;
  int r;
  int s;
  int t;
  int u;
  int v;
  e = 0;
  while (e < k) {
    cin >> p;
    cin >> q;
    cin >> r;
    cin >> s;
    t = a[r - 1][s - 1] - a[r - 1][q - 2] - a[p - 2][s - 1] + a[p - 2][q - 2];
    u = b[r - 1][s - 1] - b[r - 1][q - 2] - b[p - 2][s - 1] + b[p - 2][q - 2];
    v = c[r - 1][s - 1] - c[r - 1][q - 2] - c[p - 2][s - 1] + c[p - 2][q - 2];
    cout << t << " " << u << " " << v << endl;
    e = e + 1;
  }
}
Problem p00435 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  string str;
  cin >> str;
  int i;
  for (i = 0; i < str.size(); i++) {
    if (str[i] < 'D')
      str[i] = str[i] + 23;
    else
      str[i] = str[i] - 3;
  }
  cout << str << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string str;
  cin >> str;
  int i;
  for (i = 0; i < str.size(); i++) {
    if (str[i] < 'D')
      str[i] = str[i] + 23;
    else
      str[i] = str[i] - 3;
  }
  for (i = 0; str.size(); i++)
    cout << str[i];
  cout << endl;
  return 0;
}
Problem p00435 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  string alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";

  for (int i = 0; i < A.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (alph[j + 3] == A[i]) {
        cout << alph[j];
      }
    }
  }

  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

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

  string A = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";

  for (int i = 0; i < S.size(); i++) {
    while (true) {
      int j = 0;
      if (S[i] == A[j]) {
        cout << A[j + 3];
        break;
      }
      j++;
    }
    i++;
  }

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

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

int main() {
  int n, m, k;

  cin >> n >> m;
  int card[200], num[200];

  for (int i = 0; i < 2 * n; i++)
    card[i] = i;

  while (m--) {
    for (int i = 0; i < 2 * n; i++)
      num[i] = card[i];
    cin >> k;

    if (k == 0) {
      for (int i = 0; i < n * 2; i++) {
        if (i % 2 == 0) {
          card[i] = num[i / 2];
        } else {
          card[i] = num[i / 2 + n];
        }
      }
    } else {
      for (int i = 0; i < 2 * n - k; i++) {
        card[i] = num[k + i];
      }
      for (int i = 0; i < k; i++) {
        card[i + 2 * n - k] = num[i];
      }
    }
  }

  for (int i = 0; i < 2 * n; i++) {
    cout << card[i] + 1 << endl;
  }
}

Error: 0

Fixed submission:

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

int card[101], n;

void kat(int k) {
  int num[101];
  for (int i = 1; i < n - k + 1; i++) {
    num[i] = card[i + k];
  }
  for (int i = 1; i < k + 1; i++) {
    num[i + n - k] = card[i];
  }
  for (int i = 1; i < n + 1; i++) {
    card[i] = num[i];
  }
}

void shuf() {
  int num[101];

  for (int i = 0; i < n / 2 + 1; i++) {
    num[i * 2] = card[n / 2 + i];
    num[i * 2 + 1] = card[i + 1];
  }

  for (int i = 1; i < n + 1; i++) {
    card[i] = num[i];
  }
}

int main() {
  int m;
  cin >> n >> m;
  n = 2 * n;

  for (int i = 1; i < n + 1; i++) {
    card[i] = i;
  }

  while (m--) {
    int a;
    cin >> a;
    if (a == 0) {
      shuf();

    } else {
      kat(a);
    }
  }

  for (int i = 1; i < n + 1; i++) {
    cout << card[i] << endl;
  }
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

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

void shuffle(vector<int> &stock);
void cut(int k, vector<int> &stock);
int main() {
  int n, m, k;
  cin >> n;
  cin >> m;
  int size = 2 * n;
  vector<int> stock;
  for (int i = 0; i < size; i++)
    stock.push_back(i + 1);
  for (int i = 0; i < m; i++) {
    cin >> k;
    if (k == 0)
      shuffle(stock);
    else
      cut(k, stock);
  }
  for (int i = 0; i < size; i++)
    cout << stock[i] << endl;
  return 0;
}
void shuffle(vector<int> &stock) {
  int size = stock.size();
  vector<int> res;
  for (int i = 0; i < size / 2; i++) {
    res.push_back(stock[i]);
    res.push_back(stock[i + size / 2]);
  }
  for (int i = 0; i < size; i++)
    stock[i] = res[i];
}
void cut(int k, vector<int> &stock) {
  int size = stock.size();
  vector<int> res;
  for (int i = k; i < size; i++)
    res.push_back(stock[i]);
  for (int i = 0; i < k; i++)
    res.push_back(stock[i]);
  for (int i = 0; i < size; i++)
    stock[i] = res[i];
}

Error: -11

Fixed submission:

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

void shuffle(int n, vector<int> stock);
void cut(int n, int k, vector<int> stock);
int main() {
  int n, m, k;
  vector<int> stock;
  cin >> n;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    if (k == 0)
      shuffle(n, stock);
    else
      cut(n, k, stock);
  }
  for (int i = 0; i < n; i++) {
    cout << stock[i] << endl;
  }
  return 0;
}
void shuffle(int n, vector<int> stock) {
  vector<int> res;
  for (int i = 0; i < n / 2; i++) {
    res.push_back(stock[i]);
    res.push_back(stock[i + n / 2]);
  }
  for (int i = 0; i < n; i++)
    stock[i] = res[i];
}
void cut(int n, int k, vector<int> stock) {
  vector<int> res;
  for (int i = k; i < n; i++)
    res.push_back(stock[i]);
  for (int i = 0; i < k; i++)
    res.push_back(stock[i]);
  for (int i = 0; i < n; i++)
    stock[i] = res[i];
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

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

int N, M;

vector<int> rifuru(vector<int> card) {
  vector<int> ret;
  int ac[256];
  int bc[256];
  for (int i = 0; i < N; i++) {
    ac[i] = card[i];
    bc[i] = card[i + N];
  }
  for (int i = 0; i < N; i++) {
    ret.push_back(ac[i]);
    ret.push_back(bc[i]);
  }
  return ret;
}

vector<int> cat(vector<int> card, int k) {
  vector<int> ret;
  int ac[256];
  int bc[256];
  for (int i = 0; i < k; i++) {
    ac[i] = card[i];
  }
  for (int i = 0; i < 2 * N - k; i++) {
    bc[i] = card[i + k];
  }
  for (int i = 0; i < 2 * N - k; i++) {
    ret.push_back(bc[i]);
  }
  for (int i = 0; i < k; i++) {
    ret.push_back(ac[i]);
  }
  return ret;
}

int main() {
  cin >> N;
  vector<int> card;
  for (int i = 0; i < 2 * N; i++) {
    card.push_back(i + 1);
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    if (t == 0)
      card = rifuru(card);
    else
      card = cat(card, t);
  }

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

Error: 0

Fixed submission:

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

int N, M;

vector<int> rifuru(vector<int> card) {
  vector<int> ret;
  int ac[100];
  int bc[100];
  for (int i = 0; i < N; i++) {
    ac[i] = card[i];
    bc[i] = card[i + N];
  }
  for (int i = 0; i < N; i++) {
    ret.push_back(ac[i]);
    ret.push_back(bc[i]);
  }
  return ret;
}

vector<int> cat(vector<int> card, int k) {
  vector<int> ret;
  int ac[100];
  int bc[100];
  for (int i = 0; i < k; i++) {
    ac[i] = card[i];
  }
  for (int i = 0; i < 2 * N - k; i++) {
    bc[i] = card[i + k];
  }
  for (int i = 0; i < 2 * N - k; i++) {
    ret.push_back(bc[i]);
  }
  for (int i = 0; i < k; i++) {
    ret.push_back(ac[i]);
  }
  return ret;
}

int main() {
  cin >> N;
  vector<int> card;
  for (int i = 0; i < 2 * N; i++) {
    card.push_back(i + 1);
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    int t;
    cin >> t;
    if (t == 0)
      card = rifuru(card);
    else
      card = cat(card, t);
  }

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