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

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define sz(obj) ((int)(obj).size())
#define pf push_front
#define pb push_back

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

  deque<int> card;
  REP(i, n * 2) { card.pb(i + 1); }
  cin >> m;

  while (m--) {
    deque<int> tmpa, tmpb;
    cin >> k;
    if (k == 0) {
      REP(i, n) {
        tmpa.pb(card.front());
        card.pop_front();
      }
      REP(i, n) {
        tmpb.pb(card.front());
        card.pop_front();
      }
      REP(i, n * 2) {
        if (i % 2 == 0) {
          card.pb(tmpa.front());
          tmpa.pop_front();
        } else {
          card.pb(tmpb.front());
          tmpb.pop_front();
        }
      }
    } else {
      REP(i, k) {
        tmpa.pb(card.front());
        card.pop_front();
      }
      FOR(i, k, n * 2) {
        tmpb.pb(card.front());
        card.pop_front();
      }

      REP(i, n * 2 - k) {
        card.pb(tmpb.front());
        tmpb.pop_front();
      }
      REP(i, k) {
        card.pb(tmpa.front());
        tmpa.pop_front();
      }
    }
  }
  REP(i, n * 2) {
    cout << card.front() << endl;
    card.pop_front();
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
  int k;
  int n;
  int m;
  scanf("%d %d", &n, &m);
  int card[n];
  for (int i = 0; i < 2 * n; i++)
    card[i] = i + 1;

  for (int a = 0; a < m; a++) {
    scanf("%d", &k);
    if (k != 0) {
      int i = 0, j = 0;
      int kk[k];
      for (; i < k; i++) {
        kk[i] = card[i];
      }
      for (; i < 2 * n; i++) {
        swap(card[i - k], card[i]);
      }
      for (; i - k < 2 * n; i++, j++) {
        swap(card[i - k], kk[j]);
      }
    } else {
      int i = 0;
      int kk[n];
      for (; i < n; i++) {
        kk[i] = card[i];
      }
      for (int j = 0, l = 0; i < 2 * n; i++, j++, l++) {
        swap(card[l++], kk[j]);
        swap(card[l], card[i]);
      }
    }
  }

  for (int i = 0; i < 2 * n; i++) {
    printf("%d\\n", card[i]);
  }

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


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

int main() {
  int n, m;
  cin >> n >> m;
  int card1[201], card2[201];
  for (int i = 1; i <= 200; i++) {
    card1[i] = i;
    card2[i] = i;
  }
  int k;
  for (int i = 0; i < m; i++) {
    cin >> k;
    if (k == 0) {
      for (int o = 1; o <= n; o++) {
        card2[2 * o - 1] = card1[o];
      }
      for (int o = 1; o <= n; o++) {
        card2[2 * o] = card1[n + o];
      }
    } else {
      for (int o = 1; o <= 2 * n; o++) {
        if (k >= o) {
          card2[2 * n - k + o] = card1[o];
        } else {
          card2[o - k] = card1[o];
        }
      }
    }
    for (int o = 1; o <= 2 * n; o++) {
      card1[o] = card2[o];
    }
  }
  for (int i = 1; i <= 2 * n; i++) {
    cout << card1[i] << endl;
  }
}

Error: -6
double free or corruption (out)


Fixed submission:


#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> card;
  card.push_back(0);
  for (int i = 1; i <= n * 2; ++i) {
    card.push_back(i);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int j;
    cin >> j;
    vector<int> copycard = card;
    if (j == 0) {
      for (int o = 1; o <= n * 2; ++o) {
        if (o <= n) {
          copycard[2 * o - 1] = card[o];
        } else {
          copycard[o - n * 2] = card[o];
        }
      }
      card = copycard;
    } else {
      for (int o = 0; o <= n * 2; ++o) {
        if (o > j) {
          copycard[o - j] = card[o];
        } else {
          copycard[o + j] = card[o];
        }
      }
      card = copycard;
    }
  }
  for (int i = 1; i < n * 2; ++i) {
    cout << card[i] << endl;
  }
  return 0;
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
void cut(int *cards, int n, int k) {
  int result[200];
  int i;
  for (i = 0; i < k; i++) {
    result[2 * n - k + i] = cards[i];
  }
  for (i = k; i < 2 * n; i++) {
    result[i - k] = cards[i];
  }
  for (i = 0; i < n * 2; i++) {
    cards[i] = result[i];
  }
}

void rf(int *cards, int n) {
  int result[200];
  int i;
  for (i = 0; i < n; i++) {
    result[i * 2] = cards[i];
    result[i * 2 + 1] = cards[i + n];
  }
  for (i = 0; i < n * 2; i++) {
    cards[i] = result[i];
  }
}

int main(void) {
  int cards[200];
  int i, n, m, k;
  cin >> n >> m;
  for (i = 0; i < n * 2; i++)
    cards[i] = i + 1;
  for (i = 0; i < m; i++) {
    cin >> k;
    if (k == 0)
      rf(cards, n);
    else
      cut(cards, n, k);
  }
  for (i = 0; i < n * 2; i++)
    cout << cards[i] << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

void cut(int *card, int k, int n) {
  int i = 0;
  int spare[200];
  for (i = 0; i < k; i++)
    spare[(2 * n) - k + i] = card[i];
  for (i = k; i < (2 * n); i++)
    spare[i - k] = card[i];
  for (i = 0; i < 2 * n; i++)
    card[i] = spare[i];
}
void riffle(int *card, int n) {
  int spare[200];
  int i = 0;
  for (i = 0; i < 2 * n; i++) {
    spare[i * 2] = card[i];
    spare[i * 2 + 1] = card[n + i];
  }
  for (i = 0; i < 2 * n; i++)
    card[i] = spare[i];
}

int main() {
  int n, m, i, k;
  cin >> n >> m;
  int card[200];
  for (i = 0; i < 2 * n; i++)
    card[i] = i + 1;
  for (i = 0; i < m; i++) {
    cin >> k;
    if (k != 0)
      cut(card, k, n);
    else
      riffle(card, n);
  }
  for (i = 0; i < 2 * n; i++)
    cout << card[i] << endl;
  return 0;
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

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

int n;
vector<int> card, t, m;

void cut(int k) {
  for (int i = 1, j = 0; i <= k; i++, j++)
    t[j] = card[i];
  for (int i = k + 1, j = 0; i <= 2 * n; i++, j++)
    m[j] = card[i];

  for (int i = 1, j = 0; i <= 2 * n - k + 1; i++, j++)
    card[i] = m[j];
  for (int i = 2 * n - k + 1, j = 0; i <= 2 * n; i++, j++)
    card[i] = t[j];
}

void r_shuffle() {
  for (int i = 1; i <= n; i++) {
    t[i - 1] = card[i];
    m[i - 1] = card[i + n];
  }
  for (int i = 1, j = 0; i <= 2 * n; i += 2, j++) {
    card[i] = t[j];
    card[i + 1] = m[j];
  }
}

int main() {
  int h, k;
  cin >> n >> h;
  card.resize(1001);
  t.resize(512);
  m.resize(512);
  for (int i = 1; i <= 2 * n; i++)
    card[i] = i;
  for (int i = 0; i < h; i++) {
    cin >> k;
    if (k == 0)
      r_shuffle();
    else
      cut(k);
  }
  for (int i = 1; i <= n * 2; i++)
    cout << card[i] << endl;
}

Error: 0

Fixed submission:

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

int n;
vector<int> card, t, m;

void cut(int k) {
  for (int i = 1, j = 0; i <= k; i++, j++)
    t[j] = card[i];
  for (int i = k + 1, j = 0; i <= 2 * n; i++, j++)
    m[j] = card[i];

  for (int i = 1, j = 0; i <= 2 * n - k + 1; i++, j++)
    card[i] = m[j];
  for (int i = 2 * n - k + 1, j = 0; i <= 2 * n; i++, j++)
    card[i] = t[j];
}

void r_shuffle() {
  for (int i = 1; i <= n; i++) {
    t[i - 1] = card[i];
    m[i - 1] = card[i + n];
  }
  for (int i = 1, j = 0; i <= 2 * n; i += 2, j++) {
    card[i] = t[j];
    card[i + 1] = m[j];
  }
}

int main() {
  int h, k;
  cin >> n >> h;
  card.resize(2 * n + 1);
  t.resize(n + 1);
  m.resize(n + 1);
  for (int i = 1; i <= 2 * n; i++)
    card[i] = i;
  for (int i = 0; i < h; i++) {
    cin >> k;
    if (k == 0)
      r_shuffle();
    else
      cut(k);
  }
  for (int i = 1; i <= n * 2; i++)
    cout << card[i] << endl;
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int cards[300], n, m, k;
  cin >> n >> m;
  for (int i = 0; i < 2 * n; i++)
    cards[i] = i;
  for (int all_counter = 0; all_counter < m; all_counter++) {
    cin >> k;
    if (k == 0) {
      int odd[200], even[200];
      for (int i = 0; i < n; i++)
        odd[i] = cards[i];
      for (int i = n; i < 2 * n; i++)
        even[i - n] = cards[i];
      int j = 0;
      for (int i = 0; i < 2 * n; i += 2) {
        cards[i] = odd[j];
        cards[i + 1] = even[j];
        j++;
      }
    } else {
      int odd[200], even[200];
      for (int i = 0; i < k; i++)
        odd[i] = cards[i];
      for (int i = k; i < 2 * n; i++)
        cards[i - k] = cards[i];
      for (int i = 0; i < k; i++)
        cards[2 * n - k + i] = odd[i];
    }
  }
  for (int i = 0; i < 2 * n; i++)
    cout << cards[i] + 1 << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int cards[100], n, m, k;
  cin >> n >> m;
  for (int i = 0; i < 2 * n; i++)
    cards[i] = i;
  for (int all_counter = 0; all_counter < m; all_counter++) {
    cin >> k;
    if (k == 0) {
      int odd[100], even[100];
      for (int i = 0; i < n; i++)
        odd[i] = cards[i];
      for (int i = n; i < 2 * n; i++)
        even[i - n] = cards[i];
      int j = 0;
      for (int i = 0; i < 2 * n; i += 2) {
        cards[i] = odd[j];
        cards[i + 1] = even[j];
        j++;
      }
    } else {
      int odd[100], even[100];
      for (int i = 0; i < k; i++)
        odd[i] = cards[i];
      for (int i = k; i < 2 * n; i++)
        cards[i - k] = cards[i];
      for (int i = 0; i < k; i++)
        cards[2 * n - k + i] = odd[i];
    }
  }
  for (int i = 0; i < 2 * n; i++)
    cout << cards[i] + 1 << endl;
  return 0;
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <stdio.h>
void Shuffle(void);
void cut(void);
void rifu(void);

int n, k;
int card[200];

using namespace std;

int main() {

  int i, m;

  scanf("%d", &n);
  scanf("%d", &m);

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

  for (i = 0; i < m; i++) {

    scanf("%d", &k);

    Shuffle();
  }

  for (i = 0; i < n * 2; i++) {
    printf("%d\\n", card[i]);
  }

  return 0;
}
void Shuffle() {

  if (k == 0) {
    rifu();
  } else {
    cut();
  }
}

void rifu() {

  int sub[2][200] = {0};
  int i, j, a;

  for (i = 0; i < n; i++) {
    sub[0][i] = card[i];
  }
  j = 0;
  for (i = n; i < 2 * n; i++) {
    sub[1][j] = card[i];
    j++;
  }

  a = 0;
  for (j = 0; j < n; j++) {
    for (i = 0; i < 2; i++) {
      card[a] = sub[i][j];
      a++;
    }
  }
}

void cut() {

  int sub[2][200] = {0};

  int i, j, a = 0;

  for (i = 0; i < k; i++) {
    sub[0][i] = card[i];
  }
  j = 0;
  for (i = k; i < n * 2; i++) {
    sub[1][j] = card[i];
    j++;
  }

  for (j = 0; j < 2 * n - k; j++) {
    card[a] = sub[1][j];
    a++;
  }

  for (i = 0; i < k; i++) {
    card[a] = sub[0][i];
    a++;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <stdio.h>
void Shuffle(void);
void cut(void);
void rifu(void);

int n, k;
int card[100];

using namespace std;

int main() {

  int i, m;

  scanf("%d", &n);
  scanf("%d", &m);

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

  for (i = 0; i < m; i++) {

    scanf("%d", &k);

    Shuffle();
  }

  for (i = 0; i < n * 2; i++) {
    printf("%d\\n", card[i]);
  }

  return 0;
}
void Shuffle() {

  if (k == 0) {
    rifu();
  } else {
    cut();
  }
}

void rifu() {

  int sub[2][100] = {0};
  int i, j, a;

  for (i = 0; i < n; i++) {
    sub[0][i] = card[i];
  }
  j = 0;
  for (i = n; i < 2 * n; i++) {
    sub[1][j] = card[i];
    j++;
  }

  a = 0;
  for (j = 0; j < n; j++) {
    for (i = 0; i < 2; i++) {
      card[a] = sub[i][j];
      a++;
    }
  }
}

void cut() {

  int sub[2][100] = {0};

  int i, j, a;

  for (i = 0; i < k; i++) {
    sub[0][i] = card[i];
  }
  j = 0;
  for (i = k; i < n * 2; i++) {
    sub[1][j] = card[i];
    j++;
  }
  a = 0;
  for (i = 1; i >= 0; i--) {
    j = 0;
    while (sub[i][j] != 0) {
      card[a] = sub[i][j];
      a++;
      j++;
    }
  }
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int card[200], n;

void riffle() {
  int card2[200];
  for (int i = 0; i < 2 * n; i++)
    card2[i] = card[i];
  for (int i = 0; i < n; i++)
    card[2 * i] = card2[i], card[2 * i + 1] = card[n + i];
}

void cut(int k) {
  int card2[200];
  for (int i = 0; i < 2 * n; i++)
    card2[i] = card[i];
  for (int i = k; i < 2 * n; i++)
    card[i - k] = card2[i];
  for (int i = 0; i < k; i++)
    card[2 * n - k + i] = card2[i];
}

int main() {
  int m;
  cin >> n >> m;
  for (int i = 0; i < 2 * n; i++)
    card[i] = i + 1;
  for (int i = 0; i < m; i++) {
    int op;
    cin >> op;
    if (op == 0)
      riffle();
    else
      cut(op);
  }
  for (int i = 0; i < 2 * n; i++)
    cout << card[i] << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int card[200], n;

void riffle() {
  int card2[100];
  for (int i = 0; i < 2 * n; i++)
    card2[i] = card[i];
  for (int i = 0; i < n; i++)
    card[2 * i] = card2[i], card[2 * i + 1] = card[n + i];
}

void cut(int k) {
  int card2[100];
  for (int i = 0; i < 2 * n; i++)
    card2[i] = card[i];
  for (int i = k; i < 2 * n; i++)
    card[i - k] = card2[i];
  for (int i = 0; i < k; i++)
    card[2 * n - k + i] = card2[i];
}

int main() {
  int m;
  cin >> n >> m;
  for (int i = 0; i < 2 * n; i++)
    card[i] = i + 1;
  for (int i = 0; i < m; i++) {
    int op;
    cin >> op;
    if (op == 0)
      riffle();
    else
      cut(op);
  }
  for (int i = 0; i < 2 * n; i++)
    cout << card[i] << endl;

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

#include <stdio.h>
#include <string.h>

void cut(int k, int *cards, int ary_size) {
  int pointer = 0;
  int result[ary_size];

  for (int i = k; i < ary_size; i++) {
    result[pointer] = cards[i];
    pointer++;
  }

  for (int i = 0; i < k; i++) {
    result[pointer] = cards[i];
    pointer++;
  }

  memcpy(cards, result, sizeof result);
}

void shuffle(int *cards, int ary_size) {
  int half_size = ary_size / 2;
  int result[ary_size];
  int pointer = 0;

  int A[half_size];
  for (int i = 0; i < half_size; i++)
    A[i] = cards[i];

  int B[half_size];
  for (int i = half_size; i < ary_size; i++) {
    B[pointer] = cards[i];
    pointer++;
  }

  pointer = 0;
  for (int i = 0; i < ary_size; i += 2) {
    result[i] = A[pointer];
    result[i + 1] = B[pointer];
    pointer++;
  }

  memcpy(cards, result, sizeof result);
}

int main() {
  int cards, operations;
  scanf("%d", &cards);
  scanf("%d", &operations);

  cards = cards * 2;
  int cards_ary[cards];
  for (int i = 0; i < cards; i++)
    cards_ary[i] = i + 1;

  int sort_process[operations];
  for (int i = 0; i < operations; i++) {
    scanf("%d", &sort_process[i]);
  }

  for (int i = 0; i < operations; i++) {
    if (sort_process[i] > 0)
      cut(sort_process[i], cards_ary, cards);
    else
      shuffle(cards_ary, cards);
  }

  for (int i : cards_ary)
    printf("%d\\n", i);
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>

void cut(int k, int *cards, int ary_size) {
  int pointer = 0;
  int result[ary_size];

  for (int i = k; i < ary_size; i++) {
    result[pointer] = cards[i];
    pointer++;
  }

  for (int i = 0; i < k; i++) {
    result[pointer] = cards[i];
    pointer++;
  }

  memcpy(cards, result, sizeof result);
}

void shuffle(int *cards, int ary_size) {
  int half_size = ary_size / 2;
  int result[ary_size];
  int pointer = 0;

  int A[half_size];
  for (int i = 0; i < half_size; i++)
    A[i] = cards[i];

  int B[half_size];
  for (int i = half_size; i < ary_size; i++) {
    B[pointer] = cards[i];
    pointer++;
  }

  pointer = 0;
  for (int i = 0; i < ary_size; i += 2) {
    result[i] = A[pointer];
    result[i + 1] = B[pointer];
    pointer++;
  }

  memcpy(cards, result, sizeof result);
}

int main() {
  int cards, operations;
  scanf("%d", &cards);
  scanf("%d", &operations);

  cards = cards * 2;
  int cards_ary[cards];
  for (int i = 0; i < cards; i++)
    cards_ary[i] = i + 1;

  int sort_process[cards];

  for (int i = 0; i < operations; i++)
    scanf("%d", &sort_process[i]);

  for (int i = 0; i < operations; i++) {
    if (sort_process[i] > 0)
      cut(sort_process[i], cards_ary, cards);
    else
      shuffle(cards_ary, cards);
  }

  for (int i : cards_ary)
    printf("%d\\n", i);
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
void rifl();
void cut(int k);

int n, N;
vector<int> card, CARD;

int main() {
  card.reserve(1010);
  CARD.reserve(1010);
  int m, k;
  cin >> n;
  N = n * 2;
  for (int i = 0; i < N; i++) {
    card[i] = i + 1;
  }

  cin >> m;
  for (int i = 0; i < m; i++) {
    CARD.clear();
    cin >> k;
    if (k == 0)
      rifl();
    else
      cut(k);
  }

  // cout << endl << endl << endl;
  for (int i = 0; i < N; i++) {
    cout << card[i] << endl;
  }
}

void rifl() {
  for (int i = 0, j = 0; i < N; i += 2, j++) {
    CARD[i] = card[j];
    CARD[i + 1] = card[n + j];
  }

  for (int i = 0; i < N; i++) {
    card[i] = CARD[i];
  }
}

void cut(int k) {
  int cnt = 0;
  for (int i = 0; k + i < N; i++, cnt++) {
    CARD[i] = card[k + i];
  }
  for (int i = cnt, j = 0; i < N; i++, j++) {
    CARD[i] = card[j];
  }

  for (int i = 0; i < N; i++) {
    card[i] = CARD[i];
  }
}

Error: WA

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int n, N, m, k;
  string card, CARD;
  cin >> n;
  N = n * 2;
  card.resize(N);
  CARD.resize(N);
  for (int i = 0; i < N; i++) {
    card[i] = i + '1';
  }
  cin >> m;
  for (int t = 0; t < m; t++) {

    CARD.resize(N);

    cin >> k;
    if (k == 0) {
      // リフト
      for (int i = 0, j = 0; i < n; i++, j += 2) {
        CARD[j] = card[i];
        CARD[j + 1] = card[n + i];
      }
      card = CARD;
    } else if (k >= 0 && k < N) {
      int cnt = 0;
      // カット
      for (int i = 0; k + i < N; i++, cnt++) {
        CARD[i] = card[k + i];
        CARD[i + cnt] = card[i];
      }
      card = CARD;
    }
  }
  // cout << endl << endl << endl;
  for (int i = 0; i < N; i++) {
    cout << card[i] - '0' << endl;
  }
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

#include <deque>
#include <iostream>

using namespace std;

int card[201];
int sub1[201];
int sub2[201];

int n, m;

void cut(int k);
void suffle(void);

int main() {
  cin >> n;
  cin >> m;

  deque<int> step(m);

  for (int i = 0; i < m; i++) {
    cin >> step[i];
  }

  for (int i = 0; i < 2 * n; i++) { // ツカツーツドツ渉可甘コツ可サ
    card[i] = i + 1;
  }

  for (int i = 0; i < m; i++) {
    if (step[i] == 0) {
      suffle();
    } else {
      cut(step[i]);
    }
  }

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

void cut(int k) {
  int i;
  int temp;

  for (i = 0; i < k; i++) {
    sub1[i] = card[i];
  }
  temp = i;

  for (int j = 0; j < 2 * n; j++) {
    sub2[j] = card[temp];
    temp++;
  }

  for (i = 0; i < 2 * n - k; i++) {
    card[i] = sub2[i];
  }
  for (int j = 0; i < 2 * n; i++) {
    card[i] = sub1[j];
    j++;
  }
}

void suffle(void) {
  int i, j = 0;

  for (i = 0; i < n; i++) {
    sub1[i] = card[i];
  }

  for (; i < 2 * n; i++) {
    sub2[j] = card[i];
    j++;
  }
  j = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    card[i] = sub1[j];
    j++;
  }
  j = 0;
  for (int i = 1; i < 2 * n; i += 2) {
    card[i] = sub2[j];
    j++;
  }
}

Error: 0

Fixed submission:

#include <deque>
#include <iostream>

using namespace std;

/*
int card[201];
int sub1[201];
int sub2[201];
*/
deque<int> card(201);
deque<int> sub1(201);
deque<int> sub2(201);
int n, m;

void cut(int k);
void suffle(void);

int main() {
  cin >> n;
  cin >> m;

  deque<int> step(m);

  for (int i = 0; i < m; i++) {
    cin >> step[i];
  }

  for (int i = 0; i < 2 * n; i++) { // ツカツーツドツ渉可甘コツ可サ
    card[i] = i + 1;
  }

  for (int i = 0; i < m; i++) {
    if (step[i] == 0) {
      suffle();
    } else {
      cut(step[i]);
    }
  }

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

void cut(int k) {
  int i;
  int temp;

  for (i = 0; i < k; i++) {
    sub1[i] = card[i];
  }
  temp = i;

  for (int j = 0; j < 2 * n; j++) {
    sub2[j] = card[temp];
    temp++;
  }

  for (i = 0; i < 2 * n - k; i++) {
    card[i] = sub2[i];
  }
  for (int j = 0; i < 2 * n; i++) {
    card[i] = sub1[j];
    j++;
  }
}

void suffle(void) {
  int i, j = 0;

  for (i = 0; i < n; i++) {
    sub1[i] = card[i];
  }

  for (; i < 2 * n; i++) {
    sub2[j] = card[i];
    j++;
  }
  j = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    card[i] = sub1[j];
    j++;
  }
  j = 0;
  for (int i = 1; i < 2 * n; i += 2) {
    card[i] = sub2[j];
    j++;
  }
}
Problem p00436 (C++) — buggy submission, verdict: Runtime Error

#include <deque>
#include <iostream>

using namespace std;
/*
deque<int> card(201);
deque<int> sub1(201);
deque<int> sub2(201);
*/

int card[201];
int sub1[201];
int sub2[201];
int n, m;

void cut(int k);
void suffle(void);

int main() {
  cin >> n;
  cin >> m;

  deque<int> step(m);

  for (int i = 0; i < m; i++) {
    cin >> step[i];
  }

  for (int i = 0; i < 2 * n; i++) { // ツカツーツドツ渉可甘コツ可サ
    card[i] = i + 1;
  }

  for (int i = 0; i < m; i++) {
    if (step[i] == 0) {
      suffle();
    } else {
      cut(step[i]);
    }
  }

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

void cut(int k) {
  int i;
  int temp;

  for (i = 0; i < k; i++) {
    sub1[i] = card[i];
  }
  temp = i;

  for (int j = 0; j < 2 * n; j++) {
    sub2[j] = card[temp];
    temp++;
  }

  for (i = 0; i < 2 * n - k; i++) {
    card[i] = sub2[i];
  }
  for (int j = 0; i < 2 * n; i++) {
    card[i] = sub1[j];
    j++;
  }
}

void suffle(void) {
  int i, j = 0;

  for (i = 0; i < n; i++) {
    sub1[i] = card[i];
  }

  for (; i < 2 * n; i++) {
    sub2[j] = card[i];
    j++;
  }
  j = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    card[i] = sub1[j];
    j++;
  }
  j = 0;
  for (int i = 1; i < 2 * n; i += 2) {
    card[i] = sub2[j];
    j++;
  }
}

Error: 0

Fixed submission:

#include <deque>
#include <iostream>

using namespace std;

deque<int> card(201);
deque<int> sub1(201);
deque<int> sub2(201);

int n, m;

void cut(int k);
void suffle(void);

int main() {
  cin >> n;
  cin >> m;

  deque<int> step(m);

  for (int i = 0; i < m; i++) {
    cin >> step[i];
  }

  for (int i = 0; i < 2 * n; i++) { // ツカツーツドツ渉可甘コツ可サ
    card[i] = i + 1;
  }

  for (int i = 0; i < m; i++) {
    if (step[i] == 0) {
      suffle();
    } else {
      cut(step[i]);
    }
  }

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

void cut(int k) {
  int i;
  int temp;

  for (i = 0; i < k; i++) {
    sub1[i] = card[i];
  }
  temp = i;

  for (int j = 0; j < 2 * n; j++) {
    sub2[j] = card[temp];
    temp++;
  }
  /*
  for(int i = 0; i < k; i++){
          cout << "sub1[" << i <<"] :" << sub1[i] << endl;
  }
  cout << endl;
  for(int i = 0; i < 2*n; i++){
          cout << "sub2[" << i <<"] :" << sub2[i] << endl;
  }
  */

  for (i = 0; i < 2 * n - k; i++) {
    card[i] = sub2[i];
  }
  for (int j = 0; i < 2 * n; i++) {
    card[i] = sub1[j];
    j++;
  }
}

void suffle(void) {
  int i, j = 0;

  for (i = 0; i < n; i++) {
    sub1[i] = card[i];
  }

  for (; i < 2 * n; i++) {
    sub2[j] = card[i];
    j++;
  }
  /*
  for(int i = 0; i < n; i++){
          cout << "sub1[" << i <<"] :" << sub1[i] << endl;
  }
  cout << endl;
  for(int i = 0; i < n; i++){
          cout << "sub2[" << i <<"] :" << sub2[i] << endl;
  }
  */
  j = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    card[i] = sub1[j];
    j++;
  }
  j = 0;
  for (int i = 1; i < 2 * n; i += 2) {
    card[i] = sub2[j];
    j++;
  }
}