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

#include <stdbool.h>
#include <stdio.h>

int main() {
  int i, j, n;
  char mark;
  char marks[4] = {'S', 'H', 'C', 'D'};
  int num;
  bool cards[4][13] = {false};

  scanf("%d ", &n);
  for (i = 0; i < n; i++) {
    scanf("%c %d ", &mark, &num);
    for (j = 0; j < 4; j++) {
      if (mark == marks[j]) {
        cards[j][num - 1] = true;
        break;
      }
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (!cards[i][j]) {
        printf("%c %d\\n", marks[i], j + 1);
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  char number[1001];
  int i, sum;
  while (1) {
    scanf("%s", number);
    if (number[0] == '0')
      break;
    sum = 0;
    for (i = 0; number[i] != '\\0'; i++) {
      sum += number[i] - '0';
    }
    printf("%d\\n", sum);
  }

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

#include <stdio.h>

int main(void) {
  char trumpMark;
  char dummy;
  int trump[4][14];
  int cards;
  int number;

  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      trump[i][j] = 0;
    }
  }

  scanf("%d", &cards);

  for (int i = 0; i < cards; i++) {

    scanf("%*c%c", &trumpMark);
    scanf("%d", &number);

    switch (trumpMark) {
    case 'S':
      trump[0][number] = number;
      break;
    case 'H':
      trump[1][number] = number;
      break;
    case 'C':
      trump[2][number] = number;
      break;
    case 'D':
      trump[3][number] = number;
      break;
    }
  }

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


Error: 0

Fixed submission:

#include <stdio.h>

int main(void) {
  char trumpMark;
  char dummy;
  int trump[4][13];
  int cards;
  int number;

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

  scanf("%d", &cards);

  for (int i = 0; i < cards; i++) {

    scanf("%*c%c", &trumpMark);
    scanf("%d", &number);

    switch (trumpMark) {
    case 'S':
      trump[0][number] = number;
      break;
    case 'H':
      trump[1][number] = number;
      break;
    case 'C':
      trump[2][number] = number;
      break;
    case 'D':
      trump[3][number] = number;
      break;
    }
  }

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

#include <iostream>

using namespace std;

int main() {

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

  int n;
  cin >> n;
  for (int k = 0; k < n; k++) {
    int num;
    char m;
    cin >> m >> num;
    if (m == 'S') {
      cards[0][num - 1] = 1;
    }
    if (m == 'H') {
      cards[1][num - 1] = 1;
    }
    if (m == 'C') {
      cards[2][num - 1] = 1;
    }
    if (m == 'D') {
      cards[3][num - 1] = 1;
    }
  }

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


Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {

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

  int n;
  cin >> n;
  for (int k = 0; k < n; k++) {
    int num;
    char m;
    cin >> m >> num;
    if (m == 'S') {
      cards[0][num] = 1;
    }
    if (m == 'H') {
      cards[1][num] = 1;
    }
    if (m == 'C') {
      cards[2][num] = 1;
    }
    if (m == 'D') {
      cards[3][num] = 1;
    }
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (cards[i][j] == 0) {
        if (i == 0) {
          cout << "S " << j << endl;
        }
        if (i == 1) {
          cout << "H " << j << endl;
        }
        if (i == 2) {
          cout << "C " << j << endl;
        }
        if (i == 3) {
          cout << "D " << j << endl;
        }
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int cards[4][14] = {};
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int a;
    cin >> c >> a;
    for (int j = 0; j < n; j++) {
      if (c == 'S') {
        cards[0][a] = 1;
      } else if (c == 'H') {
        cards[1][a] = 1;
      } else if (c == 'C') {
        cards[2][a] = 1;
      } else {
        cards[3][a] = 1;
      }
    }
  }
  for (int k = 0; k <= 3; k++) {
    for (int l = 1; l <= 13; l++) {
      if (cards[k][l] == 0) {
        if (k == 0) {
          cout << "S " << l << endl;
        }
        if (k == 1) {
          cout << "H " << l << endl;
        }
        if (k == 2) {
          cout << "C " << l << endl;
        }
        if (k == 3) {
          cout << "D " << l << endl;
        }
      }
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int cards[4][13] = {};
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    int a;
    cin >> c >> a;
    for (int j = 0; j < n; j++) {
      if (c == 'S') {
        cards[0][a] = 1;
      } else if (c == 'H') {
        cards[1][a] = 1;
      } else if (c == 'C') {
        cards[2][a] = 1;
      } else {
        cards[3][a] = 1;
      }
    }
  }
  for (int k = 0; k <= 3; k++) {
    for (int l = 1; l <= 13; l++) {
      if (cards[k][l] == 0) {
        if (k == 0) {
          cout << "S " << l << endl;
        }
        if (k == 1) {
          cout << "H " << l << endl;
        }
        if (k == 2) {
          cout << "C " << l << endl;
        }
        if (k == 3) {
          cout << "D " << l << endl;
        }
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define MARK_MAX 4
#define NUM_MAX 13
#define TF 1
#define GET_MAX 52
using namespace std;

struct mn {
  char mark;
  int num;
  int tf;
};

int main() {
  struct mn set[MARK_MAX][NUM_MAX];
  struct mn get[GET_MAX];
  int m, n, i;

  for (m = 0; m < MARK_MAX; m++) {
    for (n = 0; n < NUM_MAX; n++) {
      if (m == 0) {
        set[m][n].mark = 'S';
      } else if (m == 1) {
        set[m][n].mark = 'H';
      } else if (m == 2) {
        set[m][n].mark = 'C';
      } else if (m == 3) {
        set[m][n].mark = 'D';
      }
      set[m][n].num = n + 1;
      set[m][n].tf = 1;
    }
  }

  int count;
  cin >> count;
  for (int i = 0; i < count; i++) {
    cin >> get[i].mark >> get[i].num;
  }
  for (m = 0; m < MARK_MAX; m++) {
    for (n = 0; n < NUM_MAX; n++) {
      for (i = 0; i < count; i++) {
        if (set[m][n].mark == get[i].mark && set[m][n].num == get[i].num) {
          set[m][n].tf = 0;
        }
      }
      if (set[m][n].tf == 1) {
        cout << set[m][n].mark << ' ' << set[m][n].num << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#define MARK_MAX 4
#define NUM_MAX 13
#define TF 1
#define GET_MAX 52
using namespace std;

struct mn {
  char mark;
  int num;
  int tf;
};

int main() {
  struct mn set[MARK_MAX][NUM_MAX];
  struct mn get[GET_MAX];
  int m, n, i;

  for (m = 0; m < MARK_MAX; m++) {
    for (n = 0; n = NUM_MAX; n++) {
      if (m == 0) {
        set[m][n].mark = 'S';
      } else if (m == 1) {
        set[m][n].mark = 'H';
      } else if (m == 2) {
        set[m][n].mark = 'C';
      } else if (m == 3) {
        set[m][n].mark = 'D';
      }
      set[m][n].num = n + 1;
      set[m][n].tf = 1;
    }
  }

  int count;
  cin >> count;
  for (int i = 0; i < count; i++) {
    cin >> get[i].mark >> get[i].num;
  }
  for (m = 0; m < MARK_MAX; m++) {
    for (n = 0; n < NUM_MAX; n++) {
      for (i = 0; i < count; i++) {
        if (set[m][n].mark == get[i].mark && set[m][n].num == get[i].num) {
          set[m][n].tf = 0;
        }
      }
      if (set[m][n].tf == 1) {
        cout << set[m][n].mark << ' ' << set[m][n].mark << endl;
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  char pattern;
  int n, rank;
  bool card[4][13];

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

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> pattern >> rank;
    if (pattern == 'S') {
      card[0][rank - 1] = true;
    } else if (pattern == 'H') {
      card[1][rank - 1] = true;
    } else if (pattern == 'C') {
      card[2][rank - 1] = true;
    } else if (pattern == 'D') {
      card[3][rank - 1] = true;
    }
  }

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

Error: TLE

Fixed submission:

#include <stdio.h>
using namespace std;

int main(void) {
  char pattern;
  int n, rank;
  bool card[4][13];

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

  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%c %d", &pattern, &rank);
    if (pattern == 'S') {
      card[0][rank - 1] = true;
    } else if (pattern == 'H') {
      card[1][rank - 1] = true;
    } else if (pattern == 'C') {
      card[2][rank - 1] = true;
    } else if (pattern == 'D') {
      card[3][rank - 1] = true;
    }
  }

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; i < 13; ++j) {
      if (i == 0 && !card[i][j]) {
        printf("S %d\\n", j);
      } else if (i == 0 && !card[i][j]) {
        printf("H %d\\n", j);
      } else if (i == 0 && !card[i][j]) {
        printf("C %d\\n", j);
      } else if (i == 0 && !card[i][j]) {
        printf("D %d\\n", j);
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int S[14], H[14], D[14], C[14];
int main() {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    char a;
    int x;
    cin >> a >> x;
    if (a == 'S')
      S[x] = 1;
    else if (a == 'H')
      H[x] = 1;
    else if (a == 'D')
      D[x] = 1;
    else if (a == 'C')
      C[x] = 1;
  }
  for (int i = 1; i <= 13; i++) {
    if (S[i] == 0)
      cout << 'S' << ' ' << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (H[i] == 0)
      cout << 'H' << ' ' << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (C[i] == 0)
      cout << 'C' << ' ' << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (D[i] == 0)
      cout << 'D' << ' ' << i << endl;
  }
}


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


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, g, l, m, p, q, h = 0, i = 0, j = 0, k = 0;
  char o;
  int S[13], H[13], C[13], D[13];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> o >> g;
    switch (o) {
    case 'S':
      S[h] = g;
      h++;
    case 'H':
      H[i] = g;
      i++;
    case 'C':
      C[j] = g;
      j++;
    case 'D':
      D[k] = g;
      k++;
    }
  }
  if (S[13] == 0) {
    for (int x = 1; x <= 13; x++) {
      for (int i = 0; i < h; i++) {
        if (S[i] == x) {
          l = 1;
          break;
        }
      }
      if (l == 0) {
        cout << "S"
             << " " << x << endl;
      }
      l = 0;
    }
  }
  if (H[13] == 0) {
    for (int x = 1; x <= 13; x++) {
      for (int i = 0; i < h; i++) {
        if (H[i] == x) {
          m = 1;
          break;
        }
      }
      if (m == 0) {
        cout << "H"
             << " " << x << endl;
      }
      m = 0;
    }
  }
  if (C[13] == 0) {
    for (int x = 1; x <= 13; x++) {
      for (int i = 0; i < h; i++) {
        if (C[i] == x) {
          p = 1;
          break;
        }
      }
      if (p == 0) {
        cout << "C"
             << " " << x << endl;
        ;
      }
      p = 0;
    }
  }
  if (D[13] == 0) {
    for (int x = 1; x <= 13; x++) {
      for (int i = 0; i < h; i++) {
        if (D[i] == x) {
          q = 1;
          break;
        }
      }
      if (q == 0) {
        cout << "D"
             << " " << x << endl;
        ;
      }
      q = 0;
    }
  }
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded

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

  int n, x, a[4][13] = {0};
  char ch;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ch >> x;
    if (ch == 'S') {
      a[0][x - 1] = 1;
    }
    if (ch == 'H') {
      a[1][x - 1] = 1;
    }
    if (ch == 'C') {
      a[2][x - 1] = 1;
    }
    if (ch == 'D') {
      a[3][x - 1] = 1;
    }
  }
  for (int k = 0; k < 4; k++) {
    for (int j = 0; j < 13; j++) {
      if (a[k][j] != 1 && k == 0) {
        cout << "S " << j + 1 << endl;
      }
      if (a[k][j] != 1 && k == 1) {
        cout << "H " << j + 1 << endl;
      }
      if (a[k][j] != 1 && k == 2) {
        cout << "C " << j + 1 << endl;
      }
      if (a[k][j] != 1 && k == 3) {
        cout << "D " << j + 1 << endl;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

  // 変数宣言&初期化
  char ch; // 絵柄代入用
  int num[52], total;
  bool card[4][13];

  cin >> total;

  // 入力
  for (int i = 0; i < total; i++) {
    for (int n = 0; i < 4; n++) {
      cin >> ch >> num[i];

      if (ch == 'S') {
        card[0][num[i]] = true;
      }

      if (ch == 'H') {
        card[1][num[i]] = true;
      }

      if (ch == 'C') {
        card[2][num[i]] = true;
      }

      if (ch == 'D') {
        card[3][num[i]] = true;
      }
    }
  }

  // 不足しているカードの特定
  for (int j = 0; j < 4; j++) {

    for (int i = 0; i < 14; i++) {

      if (card[j][i] == false && i != 0) {

        // 絵柄特定
        if (j == 0) {
          cout << "S " << i << endl;
        }

        if (j == 1) {
          cout << "H " << i << endl;
        }

        if (j == 2) {
          cout << "C " << i << endl;
        }

        if (j == 3) {
          cout << "D " << i << endl;
        }
      }
    }
  }

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

#include <algorithm>
#include <iostream>
#define _USE_MATH_DEFINES
#include <functional>
#include <map>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int n;
bool list[4][13];
vector<int> v;
map<char, int> m;
int main() {
  m['S'] = 0;
  m['H'] = 1;
  m['C'] = 2;
  m['D'] = 3;

  cin >> n;

  for (int i = 0; i < n; ++i) {
    int num;
    char c;
    cin >> c >> num;
    num--;
    list[m[c]][num] = true;
  }

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 13; ++j) {
      if (!list[i][j]) {
        char c = 'z';
        switch (i) {
        case 0:
          c = 'S';
          break;
        case 1:
          c = 'H';
          break;
        case 2:
          c = 'C';
          break;
        default:
          c = 'D';
          break;
        }
        cout << c << " " << j + 1 << endl;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#define _USE_MATH_DEFINES
#include <functional>
#include <map>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int n;
bool list[4][13];
vector<int> v;
map<char, int> m;
int main() {
  m['S'] = 0;
  m['H'] = 1;
  m['C'] = 2;
  m['D'] = 3;

  cin >> n;

  for (int i = 0; i < n; ++i) {
    int num;
    char c;
    cin >> c >> num;
    num--;
    list[m[c]][num] = true;
  }

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 13;) {
      if (!list[i][j]) {
        char c = 'z';
        switch (i) {
        case 0:
          c = 'S';
          break;
        case 1:
          c = 'H';
          break;
        case 2:
          c = 'C';
          break;
        default:
          c = 'D';
          break;
        }
        cout << c << " " << j + 1 << endl;
      }
    }
  }

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


#include <iostream>
using namespace std;

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

  int n;
  cin >> n;

  char x;
  int y;
  for (int k = 0; k < n; k++) {
    cin >> x >> y;
    for (j = 0; j < 13; j++) {
      if (x == 'S' && y == j + 1)
        card[0][j] = 0;
      if (x == 'H' && y == j + 1)
        card[1][j] = 0;
      if (x == 'C' && y == j + 1)
        card[2][j] = 0;
      if (x == 'D' && y == j + 1)
        card[3][j] = 0;
    }
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (card[i][j] == 0)
        continue;
      if (i == 0)
        cout << "S"
             << " " << j + 1 << "\\n";
      if (i == 1)
        cout << "H"
             << " " << j + 1 << "\\n";
      if (i == 2)
        cout << "C"
             << " " << j + 1 << "\\n";
      if (i == 3)
        cout << "D"
             << " " << j + 1 << "\\n";
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int card[4][13];
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j = 13; j++) {
      card[i][j] = j + 1;
    }
  }
  int n;
  cin >> n;

  char x; //?????????????¨????
  int y;  //????????????number
  int k;
  for (k = 0; k < n; k++) {
    cin >> x >> y;
    for (j = 0; i < 13; j++) {
      if (x == 'S' && y == j + 1)
        card[0][j] = 0;
      if (x == 'H' && y == j + 1)
        card[1][j] = 0;
      if (x == 'C' && y == j + 1)
        card[2][j] = 0;
      if (x == 'D' && y == j + 1)
        card[3][j] = 0;
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; i < 13; j++) {
      if (card[i][j] == 0)
        continue;
      if (i == 0)
        cout << "S"
             << " " << j + 1 << endl;
      if (i == 1)
        cout << "H"
             << " " << j + 1 << endl;
      if (i == 2)
        cout << "C"
             << " " << j + 1 << endl;
      if (i == 3)
        cout << "D"
             << " " << j + 1 << endl;
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int n, card;
  char type;
  int trump[4][14];
  int given_type;
  scanf("%d", &n);
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      trump[i][j - 1] = j;
    }
  }
  for (int i = 0; i < n; i++) {
    scanf(" %c %d", &type, &card);
    if (type == 'S') {
      given_type = 0;
    } else if (type == 'H') {
      given_type = 1;
    } else if (type == 'C') {
      given_type = 2;
    } else if (type == 'D') {
      given_type = 3;
    }
    trump[given_type][card - 1] = 0;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      int check = trump[i][j - 1];
      if (0 < check) {
        if (i == 0) {
          printf("%c %d\\n", 'S', check);
        } else if (i == 1) {
          printf("%c %d\\n", 'H', check);
        } else if (i == 2) {
          printf("%c %d\\n", 'C', check);
        } else if (i == 3) {
          printf("%c %d\\n", 'D', check);
        }
      }
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>

int main() {
  int n, card;
  char type;
  int trump[4][13];
  int given_type;
  scanf("%d", &n);
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      trump[i][j - 1] = j;
    }
  }
  for (int i = 0; i < n; i++) {
    scanf("%c %d", &type, &card);
    if (type == 'S') {
      given_type = 0;
    } else if (type == 'H') {
      given_type = 1;
    } else if (type == 'C') {
      given_type = 2;
    } else if (type == 'D') {
      given_type = 3;
    }
    trump[given_type][card - 1] = 0;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 14; j++) {
      int check = trump[i][j - 1];
      if (0 < check) {
        if (i == 0) {
          printf("%c %d\\n", 'S', check);
        } else if (i == 1) {
          printf("%c %d\\n", 'H', check);
        } else if (i == 2) {
          printf("%c %d\\n", 'C', check);
        } else if (i == 3) {
          printf("%c %d\\n", 'S', check);
        }
      }
    }
  }
}
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() {

  char mark;
  int card[4][13];
  int i, j, n, num;

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> mark >> num;
    switch (mark) {
    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;
    }
  }

  cout << endl;

  for (i = 0; i < 4; i++) {
    for (j = 1; j < 14; j++) {
      if (card[i][j] != 1) {

        if (i == 0) {
          cout << "S " << j << endl;
        }
        if (i == 1) {
          cout << "H " << j << endl;
        }
        if (i == 2) {
          cout << "C " << j << endl;
        }
        if (i == 3) {
          cout << "D " << j << endl;
        }
      }
    }
  }
  return 0;
}