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

#include <iostream>
using namespace std;

int main() {
  int n;

  bool l[4][13];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      l[i][j] = false;
    }
  }

  cin >> n;

  for (int i = 0; i < n; i++) {
    char mark;
    int number;
    cin >> mark >> number;
    switch (mark) {
    case 'S':
      l[0][number - 1] = true;
      break;
    case 'H':
      l[1][number - 1] = true;
      break;
    case 'C':
      l[2][number - 1] = true;
      break;
    case 'D':
      l[3][number - 1] = true;
      break;
    }
  }

  // 0:S
  for (int j = 0; j < 13; j++) {
    if (l[0][j] == false) {
      cout << "S " << j + 1 << endl;
    }
  }

  // 1:H
  for (int j = 0; j < 13; j++) {
    if (l[1][j] == false) {
      cout << "H " << j + 1 << endl;
    }
  }

  // 2:C
  for (int j = 0; j < 13; j++) {
    if (l[2][j] == false) {
      cout << "C " << j + 1 << endl;
    }
  }

  // 3:D
  for (int j = 0; j < 13; j++) {
    if (l[3][j] == false) {
      cout << "D " << j + 1 << endl;
    }
  }

  return (0);
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, y, s[12], h[12], c[12], d[12];
  char x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    cin >> y;
    if (x == 'S') {
      s[y - 1] = y;
    } else if (x == 'H') {
      h[y - 1] = y;
    } else if (x == 'C') {
      c[y - 1] = y;
    } else if (x == 'D') {
      d[y - 1] = y;
    }
  }
  for (int i2 = 0; i2 < 13; i2++) {
    if (s[i2] != i2 + 1) {
      cout << "S " << i2 + 1 << endl;
    }
  }
  for (int i3 = 0; i3 < 13; i3++) {
    if (h[i3] != i3 + 1) {
      cout << "H " << i3 + 1 << endl;
    }
  }
  for (int i4 = 0; i4 < 13; i4++) {
    if (c[i4] != i4 + 1) {
      cout << "C " << i4 + 1 << endl;
    }
  }
  for (int i5 = 0; i5 < 13; i5++) {
    if (d[i5] != i5 + 1) {
      cout << "D " << i5 + 1 << endl;
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  bool card[4][14] = {{0}};
  char a;
  int n = 0, b = 0, f = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a == 'S')
      f = 0;
    if (a == 'H')
      f = 1;
    if (a == 'C')
      f = 2;
    if (a == 'D')
      f = 3;

    card[f][b] = 1;
  }

  for (int j = 0; j < 4; j++) {
    for (int k = 1; k <= 13; k++) {
      if (card[j][k] != 1) {
        if (j == 0)
          cout << "S " << k << endl;
        if (j == 1)
          cout << "H " << k << endl;
        if (j == 2)
          cout << "C " << k << endl;
        if (j == 3)
          cout << "D " << k << endl;
      }
    }
  }
}

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


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  bool card[4][13];
  char a;
  int n = 0, b = 0, f = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 'S')
      f = 1;
    if (a == 'H')
      f = 2;
    if (a == 'C')
      f = 3;
    if (a == 'D')
      f = 4;

    cin >> b;

    card[f][b] = 1;
  }

  for (int j = 1; j <= 4; j++) {
    for (int k = 1; k <= 13; k++) {
      if (card[j][k] != 1) {
        if (j == 1)
          cout << "S " << k << endl;
        if (j == 2)
          cout << "H " << k << endl;
        if (j == 3)
          cout << "C " << k << endl;
        if (j == 4)
          cout << "D " << k << endl;
      }
    }
  }
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int n, i, j, a[13][4], x, p;
  char d;
  for (i = 0; i < 13; i++) {
    for (j = 0; j < 4; j++) {
      a[i][j] = 0;
    }
  }
  scanf("%d", &n);
  for (p = 0; p <= n; p++) {
    scanf(" %c", &d);
    scanf("%d", &x);
    if (d == 'S') {
      a[x - 1][0] = 1;
    } else if (d == 'H') {
      a[x - 1][1] = 1;
    } else if (d == 'C') {
      a[x - 1][2] = 1;
    } else if (d == 'D') {
      a[x - 1][3] = 1;
    }
  }
  for (j = 0; j < 4; j++) {
    for (i = 0; i < 13; i++) {
      if (a[i][j] == 0) {
        if (j == 0) {
          printf("S %d\\n", i + 1);
        } else if (j == 1) {
          printf("H %d\\n", i + 1);
        } else if (j == 2) {
          printf("C %d\\n", i + 1);
        } else if (j == 3) {
          printf("D %d\\n", i + 1);
        }
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int n, i, j, a[13][4], x, k, l;
  char d;
  for (i = 0; i < 13; i++) {
    for (j = 0; j < 4; j++) {
      a[i][j] = 0;
    }
  }
  scanf("%d", &n);
  for (; n != 0; n--) {
    scanf("%s %d", &d, &x);
    if (d == 'S') {
      a[x - 1][0] = 1;
    } else if (d == 'H') {
      a[x - 1][1] = 1;
    } else if (d == 'C') {
      a[x - 1][2] = 1;
    } else if (d == 'D') {
      a[x - 1][3] = 1;
    }
  }
  for (l = 0; l < 4; l++) {
    for (k = 0; k < 13; k++) {
      if (a[k][l] == 0) {
        if (l == 0) {
          printf("S %d\\n", k + 1);
        } else if (l == 1) {
          printf("H %d\\n", k + 1);
        } else if (l == 2) {
          printf("C %d\\n", k + 1);
        } else if (l == 3) {
          printf("D %d\\n", k + 1);
        }
      }
    }
  }
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"

using namespace std;

int main() {

  int kazu;
  bool n[4][14] = {false};
  int k[52];
  string p[52];
  cin >> kazu;
  for (int i = 1; i <= kazu; i++) {
    cin >> p[i - 1] >> k[i - 1];
    if (p[i - 1] == "S") {
      n[0][k[i - 1]] = 1;
    } else if (p[i - 1] == "H") {
      n[1][k[i - 1]] = 1;
    } else if (p[i - 1] == "C") {
      n[2][k[i - 1]] = 1;
    } else {
      n[3][k[i - 1]] = 1;
    }
  }
  for (int j = 0; j <= 3; j++) {
    for (int y = 1; y <= 13; y++) {
      if (n[j][y] == 0) {
        switch (j) {
        case 0:
          cout << "S " << y << endl;
          break;
        case 1:
          cout << "H " << y << endl;
          break;
        case 2:
          cout << "C " << y << endl;
          break;
        case 3:
          cout << "D " << y << endl;
          break;
        }
      }
    }
  }

  return 0;
}

Error: 0

Fixed submission:

#include "bits/stdc++.h"

using namespace std;

int main() {

  int kazu, sc = 0, hc = 0, cc = 0, dc = 0;
  bool n[4][13] = {false};
  int k[52] = {0};
  string p[52];
  cin >> kazu;
  for (int i = 1; i <= kazu; i++) {
    cin >> p[i - 1] >> k[i - 1];
    if (p[i - 1] == "S") {
      n[0][k[i - 1]] = 1;
    } else if (p[i - 1] == "H") {
      n[1][k[i - 1]] = 1;
    } else if (p[i - 1] == "C") {
      n[2][k[i - 1]] = 1;
    } else {
      n[3][k[i - 1]] = 1;
    }
  }
  for (int j = 0; j <= 3; j++) {
    for (int y = 1; y <= 13; y++) {
      if (n[j][y] == 0) {
        switch (j) {
        case 0:
          cout << "S " << y << endl;
          break;

        case 1:
          cout << "H " << y << endl;
          break;
        case 2:
          cout << "C " << y << endl;
          break;
        case 3:
          cout << "D " << y << endl;
          break;
        }
      }
    }
  }

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

#include <iostream>
using namespace std;

int main() {
  int n; // yomu card no kazu

  int i, j, k;
  char m;
  int r;
  char mark[4];
  mark[0] = 'S';
  mark[1] = 'H';
  mark[2] = 'C';
  mark[3] = 'D';

  int rank[13];
  for (i = 0; i < 13; i++) {
    rank[i] = i + 1;
  }
  int cnt[4][13] = {};

  cin >> n;
  for (k = 0; k < n; k++) {
    cin >> m >> r;
    for (i = 0; i < 4; i++) {
      if (mark[i] == m)
        cnt[i][r - 1] = 1;
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (cnt[i][j] == 0)
        cout << mark[i] << " " << rank[j] <\\
< endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n; // yomu card no kazu
  cin >> n;

  int i, j, k;
  char m;
  int r;
  char mark[4];
  mark[0] = 'S';
  mark[1] = 'H';
  mark[2] = 'C';
  mark[3] = 'D';

  int rank[13];
  for (i = 0; i < 13; i++) {
    rank[i] = i + 1;
  }
  int cnt[4][13] = {};

  for (k = 0; k < n; k++) {
    scanf("%s %d\\n", m, r);
    for (i = 0; i < 4; i++) {
      for (j = 0; i < 13; j++) {
        if (mark[i] == m && rank[j] == r) {
          cnt[i][j] = 1;
        }
      }
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (cnt[i][j] == 0)
        cout << mark[i] << rank[j] << endl;
    }
  }

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

#include <iostream>
using namespace std;

int main() {
  int n, num, card[5][14];
  char m;
  for (int M = 0; M < 4; M++) {
    for (int N = 1; N <= 13; N++) {
      card[M][N] = 0;
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m >> num;
    switch (m) {
    case 'S':
      card[0][num] = 1;
      break;
    case 'H':
      card[1][num] = 1;
      break;
    case 'C':
      card[2][num] = 1;
      break;
    case 'D':
      card[3][num] = 1;
      break;
    }
  }
  for (int M = 0; M < 4; M++) {
    for (int N = 1; N <= 13; N++) {
      if (card[M][N] == 1)
        continue;
      if (M == 0)
        m = 'S';
      if (M == 1)
        m = 'H';
      if (M == 2)
        m = 'C';
      if (M == 3)
        m = 'D';
      cout << m << " " << N << endl;
    }
  }

  return 0;
}

Error: -11

Fixed submission:

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

int main() {
  int n, cnt = 1, N;
  int nS = 13, nH = 13, nC = 13, nD = 13;
  int numS, numH, numC, numD;
  char M;
  queue<int> S;
  queue<int> H;
  queue<int> C;
  queue<int> D;
  for (int i = 0; i < 13; i++) {
    S.push(cnt);
    H.push(cnt);
    C.push(cnt);
    D.push(cnt);
    cnt++;
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> M >> N;
    if (M == 'S') {
      for (int j = 1; j <= 13; j++) {
        int huga = S.front();
        S.pop();
        if (huga != N) {
          S.push(j);
        }
        if (huga == N) {
          nS--;
          break;
        }
      }
    }
    if (M == 'H') {
      for (int j = 1; j <= 13; j++) {
        int huga = H.front();
        H.pop();
        if (huga != N) {
          H.push(j);
        }
        if (huga == N) {
          nH--;
          break;
        }
      }
    }
    if (M == 'C') {
      for (int j = 1; j <= 13; j++) {
        int huga = C.front();
        C.pop();
        if (huga != N) {
          C.push(j);
        }
        if (huga == N) {
          nC--;
          break;
        }
      }
    }
    if (M == 'D') {
      for (int j = 1; j <= 13; j++) {
        int huga = D.front();
        D.pop();
        if (huga != N) {
          D.push(j);
        }
        if (huga == N) {
          nD--;
          break;
        }
      }
    }
    for (int j = 0; j < nS; j++) {
      numS = S.front();
      cout << "S"
           << " " << numS << endl;
      S.pop();
    }
    for (int j = 0; j < nH; j++) {
      numH = H.front();
      cout << "H"
           << " " << numH << endl;
      H.pop();
    }
    for (int j = 0; j < nC; j++) {
      numC = C.front();
      cout << "C"
           << " " << numC << endl;
      C.pop();
    }
    for (int j = 0; j < nD; j++) {
      numD = D.front();
      cout << "D"
           << " " << numD << endl;
      D.pop();
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

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

int main(int argc, char *argv[]) {
  map<char, vector<int>> cards;
  vector<char> marks = {'S', 'H', 'C', 'D'};
  for (char c : marks) {
    vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    cards.insert(make_pair(c, v));
  }

  int input_num = 0;
  cin >> input_num;

  char m;
  int n;
  for (int i = 0; i < input_num; i++) {
    cin >> m >> n;
    cards[m][n - 1] = 0;
  }

  for (char c : marks) {
    for (int i : cards[c]) {
      if (i != 0) {
        cout << c << " " << i << endl;
      }
    }
  }

  return 0;
}

Error: -11

Fixed submission:

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

// TODO :
// ??????????????§?????£?????????????????????????????????AOJ?????¨??????????????????????????¨?????????????????§??????
int main(int argc, char *argv[]) {
  map<char, vector<int>> cards;
  vector<char> marks = {'S', 'H', 'C', 'D'};
  for (char c : marks) {
    vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
    cards.insert(make_pair(c, v));
  }

  int input_num = 0;
  cin >> input_num;

  char m;
  int n;
  for (int i = 0; i < input_num; i++) {
    cin >> m >> n;
    cards[m - 1][n - 1] = 0;
  }

  for (char c : marks) {
    for (int i : cards[c]) {
      if (i != 0) {
        cout << c << " " << i << endl;
      }
    }
  }

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

#include <iostream>
using namespace std;

int suit_str_to_int(char s[1]) {
  int suit;
  if (s[0] == 'S') {
    suit = 0;
  } else if (s[0] == 'H') {
    suit = 1;
  } else if (s[0] == 'C') {
    suit = 2;
  } else if (s[0] == 'D') {
    suit = 3;
  } else {
    cout << "You got an unexpected character.";
  }
  return suit;
}

char suit_int_to_str(int i) {
  char s[1];
  if (i == 0) {
    s[0] = {'S'};
  } else if (i == 1) {
    s[0] = {'H'};
  } else if (i == 2) {
    s[0] = {'C'};
  } else if (i == 3) {
    s[0] = {'D'};
  } else {
    cout << "You got an unexpected number";
  }
  return s[0];
}

int main() {
  int input_cards[5][14] = {0}, l, n, suit;
  char str[0];

  cin >> l;
  for (int i = 0; i < l; ++i) {
    cin >> str[0] >> n;
    suit = suit_str_to_int(str);
    input_cards[suit][n] = 1;
  }
  for (int j = 0; j < 4; ++j) {
    for (int k = 1; k < 14; ++k) {
      if (input_cards[j][k] == 1) {
        continue;
      } else {
        cout << suit_int_to_str(j) << " " << k << endl;
      }
    }
  }
  return 0;
}

Error: 0

Fixed submission:

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

int suit_str_to_int(char s[1]) {
  int suit;
  if (s[0] == 'S') {
    suit = 0;
  } else if (s[0] == 'H') {
    suit = 1;
  } else if (s[0] == 'C') {
    suit = 2;
  } else if (s[0] == 'D') {
    suit = 3;
  } else {
    cout << "You got an unexpected character.";
  }
  return suit;
}

char suit_int_to_str(int i) {
  char s[1];
  if (i == 0) {
    s[0] = {'S'};
  } else if (i == 1) {
    s[0] = {'H'};
  } else if (i == 2) {
    s[0] = {'C'};
  } else if (i == 3) {
    s[0] = {'D'};
  } else {
    cout << "You got an unexpected number";
  }
  return s[0];
}

int main() {
  int input_cards[4][13] = {0}, l, n, suit;
  char str[0];

  cin >> l;
  for (int i = 0; i < l; ++i) {
    cin >> str[0] >> n;
    suit = suit_str_to_int(str);
    input_cards[suit][n] = 1;
  }
  for (int j = 0; j < 4; ++j) {
    for (int k = 1; k < 14; ++k) {
      if (input_cards[j][k] == 1) {
        continue;
      } else {
        cout << suit_int_to_str(j) << " " << k << endl;
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {
  int a, s[5][14], d = 0, f, g, h, j, i;
  char z[2];
  for (i = 1; i <= 13; i++) {
    s[1][i] = 0;
    s[2][i] = 0;
    s[3][i] = 0;
    s[4][i] = 0;
  }
  scanf("%d", &a);
  for (i = 1; i <= a; i++) {
    scanf(" %c %d", &z[1], &d);
    //	printf("%d %d\\n",i,d);
    if (z[1] == 'S') {
      s[1][d] = 1;
    } else if (z[1] == 'H') {
      s[2][d] = 1;
    } else if (z[1] == 'C') {
      s[3][d] = 1;
    } else if (z[1] == 'D') {
      s[4][d] = 1;
    }
  }
  for (i = 1; i <= 4; i++) {
    for (j = 1; j <= 13; j++) {
      if (s[i][j] == 0) {
        if (i == 1)
          printf("S %d\\n", j);
        if (i == 2)
          printf("H %d\\n", j);
        if (i == 3)
          printf("C %d\\n", j);
        if (i == 4)
          printf("D %d\\n", j);
      }
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
int main(void) {
  int a, s[5][13], d = 0, f, g, h, j, i;
  char z[2];
  for (i = 1; i <= 13; i++) {
    s[1][i] = 0;
    s[2][i] = 0;
    s[3][i] = 0;
    s[4][i] = 0;
  }
  scanf("%d", &a);
  for (i = 1; i <= a; i++) {
    scanf(" %c %d", &z[1], &d);
    //	printf("%d %d\\n",i,d);
    if (z[1] == 'S') {
      s[1][d] = 1;
    } else if (z[1] == 'H') {
      s[2][d] = 1;
    } else if (z[1] == 'C') {
      s[3][d] = 1;
    } else if (z[1] == 'D') {
      s[4][d] = 1;
    }
  }
  for (i = 1; i <= 4; i++) {
    for (j = 1; j <= 13; j++) {
      if (s[i][j] == 0) {
        if (i == 1)
          printf("S %d\\n", j);
        if (i == 2)
          printf("H %d\\n", j);
        if (i == 3)
          printf("C %d\\n", j);
        if (i == 4)
          printf("D %d\\n", j);
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int n, i, j, ch;
  int card[4][13];
  char zu;
  int nu;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++)
      card[i][j] = 0;
  }

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s%d", &zu, &nu);
    if (zu == 'S')
      ch = 0;
    else if (zu == 'H')
      ch = 1;
    else if (zu == 'C')
      ch = 2;
    else
      ch = 3;
    card[ch][nu - 1] = 1;
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (card[i][j] == 0) {
        if (i == 0)
          printf("S %d\\n", j + 1);
        else if (i == 1)
          printf("H %d\\n", j + 1);
        else if (i == 2)
          printf("C %d\\n", j + 1);
        else
          printf("D %d\\n", j + 1);
      }
    }
  }
  return (0);
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int n, i, j, ch;
  int card[4][13];
  char zu[10];
  int nu;

  for (i = 0; i < 4; i++) {
    for (j = 0; i < 13; j++)
      card[i][j] = 0;
  }

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s%d", zu, &nu);
    if (zu == "S")
      ch = 0;
    else if (zu == "H")
      ch = 1;
    else if (zu == "C")
      ch = 2;
    else
      ch = 3;
    card[ch][nu] = 1;
  }
  i = 0;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (card[i][j] == 0) {
        if (i == 0)
          printf("S %d\\n", j);
        else if (i == 1)
          printf("H %d\\n", j);
        else if (i == 2)
          printf("C %d\\n", j);
        else
          printf("D %d\\n", j);
      }
    }
  }

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

#include <iostream>
#include <stdio.h>
using namespace std;
#pragma warning(disable : 4996)

int main(void) {

  int n, x, z;
  char s, y;
  int card[4][13] = {0};

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    cin >> y >> x;

    switch (y) {
    case 'S':
      z = 0;
      break;
    case 'H':
      z = 1;
      break;
    case 'C':
      z = 2;
      break;
    case 'D':
      z = 3;
      break;
    }

    card[z][x - 1] = 1;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == '\\0') {
        switch (i) {
        case 0:
          s = 'S';
          break;
        case 1:
          s = 'H';
          break;
        case 2:
          s = 'C';
          break;
        case 3:
          s = 'D';
          break;
        }
        printf("%c %d\\n", s, j + 1);
      }
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
#pragma warning(disable : 4996)

int main(void) {

  int n, x, z;
  char s, y;
  int card[4][13] = {0};

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &y);
    scanf("%d", &x);

    switch (x) {
    case 'S':
      z = 0;
      break;
    case 'H':
      z = 1;
      break;
    case 'C':
      z = 2;
      break;
    case 'D':
      z = 3;
      break;
    }

    card[z][x - 1] = 1;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (card[i][j] == '\\0') {
        switch (i) {
        case 0:
          s = 'S';
          break;
        case 1:
          s = 'H';
          break;
        case 2:
          s = 'C';
          break;
        case 3:
          s = 'D';
          break;
        }
        printf("%c %d\\n", s, j + 1);
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int main() {
  int a[4][14] = {};
  int n;
  cin >> n;
  REP(i, n) {
    char c;
    int x;
    cin >> c >> x;
    if (c == 'S')
      a[0][x] = 1;
    else if (c == 'H')
      a[1][x] = 1;
    else if (c == 'C')
      a[2][x] = 1;
    else
      a[3][x] = 1;
  }
  string s = "SHCD";
  REP(i, 4) FOR(j, 1, 13) if (!a[i][j]) cout << s[i] << " " << j << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

int main() {
  int a[4][14] = {};
  int n;
  cin >> n;
  REP(i, n) {
    char c, x;
    cin >> c >> x;
    if (c == 'S')
      a[0][x] = 1;
    else if (c == 'H')
      a[1][x] = 1;
    else if (c == 'C')
      a[2][x] = 1;
    else
      a[3][x] = 1;
  }
  string s = "SHCD";
  REP(i, 4) FOR(j, 1, 13) if (a[i][j]) cout << s[i] << " " << j << endl;
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int x, n, num[4][13] = {0};
  char y;
  scanf("%d", &n);
  for (int a = 0; a < n; a++) {
    scanf(" %c %d", &y, &x);
    if (y == 'S') {
      num[0][x - 1] = 1;
    } else if (y == 'H') {
      num[1][x - 1] = 1;
    } else if (y == 'C') {
      num[2][x - 1] = 1;
    } else {
      num[3][x - 1] = 1;
    }
  }
  for (int c = 0; c < 4; c++) {
    for (int d = 0; d < 13; d++) {
      if (c == 0 && num[c][d] == 0) {
        printf("S %d\\n", d + 1);
      }
      if (c == 1 && num[c][d] == 0) {
        printf("H %d\\n", d + 1);
      }
      if (c == 2 && num[c][d] == 0) {
        printf("C %d\\n", d + 1);
      }
      if (c == 3 && num[c][d] == 0) {
        printf("D %d\\n", d + 1);
      }
    }
  }

  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  int x, n, num[4][13] = {0};
  char y;

  scanf("%d", &n);
  for (int a = 0; a < n; a++) {
    scanf("%c %d", &y, &x);
    if (y == 'S') {
      num[0][x - 1] = 1;
    } else if (y == 'H') {
      num[1][x - 1] = 1;
    } else if (y == 'C') {
      num[2][x - 1] = 1;
    } else {
      num[3][x - 1] = 1;
    }
  }
  for (int c = 0; c < 4; c++) {
    for (int d = 0; d < 13; d++) {
      if (c == 0 && num[c][d] == 0) {
        printf("S %d\\n", d + 1);
      }
      if (c == 1 && num[c][d] == 0) {
        printf("H %d\\n", d + 1);
      }
      if (c == 2 && num[c][d] == 0) {
        printf("C %d\\n", d + 1);
      }
      if (c == 3 && num[c][d] == 0) {
        printf("D %d\\n", d + 1);
      }
    }
  }

  return 0;
}