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

#include <iostream>
using namespace std;

int main() {
  bool cards[4][14];
  int n, rank;
  char suit;

  for (int s = 0; s < 4; s++)
    for (int r = 1; r <= 13; r++)
      cards[s][r] = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> suit >> rank;
    if (suit == 'S')
      cards[0][rank] = 1;
    if (suit == 'H')
      cards[1][rank] = 1;
    if (suit == 'C')
      cards[2][rank] = 1;
    if (suit == 'D')
      cards[3][rank] = 1;
  }

  for (int s = 0; s < 4; s++) {
    for (int r = 1; r <= 13; r++) {
      if (cards[s][r])
        continue;
      if (s == 0)
        suit = 'S';
      if (s == 1)
        suit = 'H';
      if (s == 2)
        suit = 'C';
      if (s == 3)
        suit = 'D';
      cout << suit << " " << r << endl;
    }
  }

  return 0;
}


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


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, x;
  char mark;
  bool cards[4][14];

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

  cin >> n;
  for (int k = 1; k <= n; k++) {
    cin >> mark >> x;
    if (mark == 'S')
      cards[1][x] = 1;
    else if (mark == 'H')
      cards[2][x] = 1;
    else if (mark == 'C')
      cards[3][x] = 1;
    else if (mark == 'D')
      cards[4][x] = 1;
  }

  for (int s = 1; s <= 4; s++) {
    for (int t = 1; t <= 13; t++) {
      if (cards[s][t])
        continue;
      else if (s == 1)
        mark == 'S';
      else if (s == 2)
        mark == 'H';
      else if (s == 3)
        mark == 'C';
      else if (s == 4)
        mark == 'D';

      cout << mark << " " << t << endl;
    }
  }

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

#include <stdio.h>

int main() {
  char cd;
  int i, j, n, rank;
  int card[4][13];
  char buf[512];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      card[i][j] = 0;
    }
  }
  fgets(buf, 512, stdin);
  sscanf(buf, "%d", &n);
  for (i = 0; i < n; i++) {
    fgets(buf, 512, stdin);
    sscanf(buf, "%c %d", &cd, &rank);
    switch (cd) {
    case 'S':
      card[0][rank - 1] = 1;
      break;

    case 'H':
      card[1][rank - 1] = 1;
      break;

    case 'C':
      card[2][rank - 1] = 1;
      break;

    case 'D':
      card[3][rank - 1] = 1;
      break;
    }
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (card[i][j] == 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;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  char cd;
  int i, j, n, rank;
  int card[4][13];
  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("%c %d", &cd, &rank);
    switch (cd) {
    case 'S':
      card[0][rank - 1] = 1;
      break;

    case 'H':
      card[1][rank - 1] = 1;
      break;

    case 'C':
      card[2][rank - 1] = 1;
      break;

    case 'D':
      card[3][rank - 1] = 1;
      break;
    }

    for (i = 0; i < 4; i++) {
      for (j = 0; j < 13; j++) {
        if (card[i][j] == 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;
          }
        }
      }
    }
  }
  printf("\\n");
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
int main() {
  int cards[4][13] = {0};
  int num, existing;
  char mark;
  int i, j;

  scanf("%d", &existing);
  for (i = 0; i < existing; i++) {
    scanf(" %c %d", &mark, &num);
    if (mark == 'S') {
      cards[0][num - 1] = 1;
    } else if (mark == 'H') {
      cards[1][num - 1] = 1;
    } else if (mark == 'C') {
      cards[2][num - 1] = 1;
    } else if (mark == 'D') {
      cards[3][num - 1] = 1;
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (cards[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 if (i == 3) {
          printf("D %d\\n", j + 1);
        }
      }
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>
using namespace std;
int main(void) {
  // Here your code !
  bool cards[4][13];
  int num, existing;
  char mark;

  scanf("%d", &existing);
  for (int i = 0; i < existing; i++) {
    scanf("%c", &mark);
    if (mark == 'S') {
      scanf("%d", &num);
      cards[0][num - 1] = true;
    } else if (mark == 'H') {
      scanf("%d", &num);
      cards[1][num - 1] = true;
    } else if (mark == 'C') {
      scanf("%d", &num);
      cards[2][num - 1] = true;
    } else {
      scanf("%d", &num);
      cards[3][num - 1] = true;
    }

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

#include <iostream>
using namespace std;
int main(void) {
  int n, a, YJSNPI[10][100];
  char ch;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> ch >> a;
    if (ch == 'S')
      YJSNPI[0][a] = a;
    else if (ch == 'H')
      YJSNPI[1][a] = a;
    else if (ch == 'C')
      YJSNPI[2][a] = a;
    else if (ch == 'D')
      YJSNPI[3][a] = a;
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[0][i] != i)
      cout << 'S' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[1][i] != i)
      cout << 'H' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[2][i] != i)
      cout << 'C' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[3][i] != i)
      cout << 'D' << " " << i << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, a, YJSNPI[4][13];
  char c;
  cin >> n;
  for (int i = 0; i <= n; i++) {

    cin >> c >> a;
    if (c == 'S')
      YJSNPI[0][a] = a;
    else if (c == 'H')
      YJSNPI[1][a] = a;
    else if (c == 'C')
      YJSNPI[2][a] = a;
    else if (c == 'D')
      YJSNPI[3][a] = a;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[0][i] != i)
      cout << 'S' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[1][i] != i)
      cout << 'H' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

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

#include <iostream>
using namespace std;
int main(void) {
  int n, a, YJSNPI[10][100];
  char ch;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> ch >> a;
    if (ch == 'S')
      YJSNPI[0][a] = a;
    else if (ch == 'H')
      YJSNPI[1][a] = a;
    else if (ch == 'C')
      YJSNPI[2][a] = a;
    else if (ch == 'D')
      YJSNPI[3][a] = a;
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[0][i] != i)
      cout << 'S' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[1][i] != i)
      cout << 'H' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {

    if (YJSNPI[2][i] != i)
      cout << 'C' << " " << i << endl;
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[3][i] != i)
      cout << 'D' << " " << i << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int n, a, YJSNPI[4][13];
  char ch;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> ch >> a;
    if (ch == 'S')
      YJSNPI[0][a];
    else if (ch == 'H')
      YJSNPI[1][a];
    else if (ch == 'C')
      YJSNPI[2][a];
    else if (ch == 'D')
      YJSNPI[3][a];
  }
  for (int i = 1; i <= 13; i++) {
    if (YJSNPI[0][i] != i)
      cout << 'S' << " " << i << endl;
    if (YJSNPI[1][i] != i)
      cout << 'H' << " " << i << endl;
    if (YJSNPI[2][i] != i)
      cout << 'C' << " " << i << endl;
    if (YJSNPI[3][i] != i)
      cout << 'D' << " " << i << endl;
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  int card[4][14] = {0};
  cin >> n;
  for (int i = 0; i < n; i++) {
    char suit;
    int num;
    int suitn;
    cin >> suit >> num;
    switch (suit) {
    case 'S':
      suitn = 0;
      break;
    case 'H':
      suitn = 1;
      break;
    case 'C':
      suitn = 2;
      break;
    case 'D':
      suitn = 3;
      break;
    default:
      throw "input error";
    }
    card[suitn][num] = 1;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      char suitc[4] = {
          'S',
          'H',
          'C',
          'D',
      };
      if (card[i][j] == 0) {
        cout << suitc[i] << ' ' << j << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  int card[4][14] = {};
  cin >> n;
  for (int i = 0; i, n; i++) {
    char suit;
    int num;
    int suitn;
    cin >> suit >> num;
    switch (suit) {
    case 'S':
      suitn = 0;
      break;
    case 'H':
      suitn = 1;
      break;
    case 'C':
      suitn = 2;
      break;
    case 'D':
      suitn = 3;
      break;
    }
    card[suitn][num] = 1;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      char suitc[4] = {
          'S',
          'H',
          'C',
          'D',
      };
      if (card[i][j] == 0) {
        cout << suitc[i] << ' ' << j << endl;
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <iostream>
using namespace std;

int main() {
  int tramp[4][13];
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      tramp[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)
        tramp[0][j] = 0;
      if (x == 'H' && y == j + 1)
        tramp[1][j] = 0;
      if (x == 'C' && y == j + 1)
        tramp[2][j] = 0;
      if (x == 'D' && y == j + 1)
        tramp[3][j] = 0;
    }
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 13; j++) {
      if (tramp[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 <iostream>
#include <math.h>
#include <stdbool.h>
using namespace std;
int main() {
  int n, i, u, iii;
  char c;
  bool cards[4][13] = {false}; // true=??? false=???
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> c >> u;
    if (c == 'S') {
      cards[0][u - 1] = true;
    } else if (c == 'H') {
      cards[1][u - 1] = true;
    } else if (c == 'C') {
      cards[2][u - 1] = true;
    } else if (c == 'D') {
      cards[3][u - 1] = true;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[0][iii - 1] == false) {
      c = 'S';
      cout << c << " " << iii << endl;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[1][iii - 1] == false) {
      c = 'H';
      cout << c << " " << iii << endl;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[2][iii - 1] == false) {
      c = 'C';
      cout << c << " " << iii << endl;
    }
  }
  for (iii = 1; iii <= 13; ++iii) {
    if (cards[3][iii - 1] == false) {
      c = 'D';
      cout << c << " " << iii << endl;
    }
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <math.h>
#include <stdbool.h>
using namespace std;
int main() {
  int n, i, x, u, ii, iii, iiii;

  char c, cc;
  bool cards[4][13]; // true=??? false=???
  while (cin >> n) {
    for (i = 0; i < n; ++i) {
      cin >> c >> u;
      if (c == 'S') {
        x = 0;
      } else if (c == 'H') {
        x = 1;
      } else if (c == 'C') {
        x = 2;
      } else if (c == 'D') {
        x = 3;
      }
      cards[x][u] = true;
    }
    for (ii = 0; ii <= 4; ++ii) {
      for (iii = 1; iii <= 13; ++iii) {
        iiii = iii;
        if (ii == 0) {
          cc = 'S';
        } else if (ii == 1) {
          cc = 'H';
        } else if (ii == 2) {
          cc = 'C';
        } else if (ii == 3) {
          cc = 'D';
        }
        if (cards[ii][iii] == false) {
          cout << cc << " " << iiii << endl;
        }
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  char ch, card[4][14] = {false};
  int n, i, a, j, k;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ch >> a;
    if (ch == 'S') {
      card[0][a] = true;
    }
    if (ch == 'H') {
      card[1][a] = true;
    }
    if (ch == 'C') {
      card[2][a] = true;
    }
    if (ch == 'D') {
      card[3][a] = true;
    }
  }
  for (j = 0; j < 4; j++) {
    for (k = 1; k < 14; k++) {
      if (!card[j][k]) {
        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;
        }
      }
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  char ch, card[4][13] = {false};
  int n, i, a, j, k;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ch >> a;
    if (ch == 'S') {
      card[0][a] = true;
    }
    if (ch == 'H') {
      card[1][a] = true;
    }
    if (ch == 'C') {
      card[2][a] = true;
    }
    if (ch == 'D') {
      card[3][a] = true;
    }
  }
  for (j = 0; j < 4; j++) {
    for (k = 1; k < 14; k++) {
      if (!card[j][k]) {
        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;
        }
      }
    }
  }
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  char tc[n];
  int tn[n];
  for (int i = 0; i < n; i++)
    cin >> tc[i] >> tn[i];
  int s[13];
  int h[13];
  int c[13];
  int d[13];
  for (int i = 0; i < 13; i++) {
    s[i] = i + 1;
    h[i] = i + 1;
    c[i] = i + 1;
    d[i] = i + 1;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (i == 0)
        cin >> s[j];
      if (i == 1)
        cin >> h[j];
      if (i == 2)
        cin >> c[j];
      if (i == 3)
        cin >> d[j];
    }
  }
  for (int i = 0; i < n; i++) {
    if (tc[i] == 'S') {
      for (int j = 0; j < 13; j++) {
        if (tn[i] == s[j])
          s[j] = 0;
      }
    } else if (tc[i] == 'H') {
      for (int j = 0; j < 13; j++) {
        if (tn[i] == h[j])
          h[j] = 0;
      }
    } else if (tc[i] == 'C') {
      for (int j = 0; j < 13; j++) {
        if (tn[i] == c[j])
          c[j] = 0;
      }
    } else if (tc[i] == 'D') {
      for (int j = 0; j < 13; j++) {
        if (tn[i] == d[j])
          d[j] = 0;
      }
    }
  }
  for (int i = 0; i < 13; i++) {
    if (s[i] > 0)
      cout << 'S' << ' ' << s[i] << endl;
  }
  for (int i = 0; i < 13; i++) {
    if (h[i] > 0)
      cout << 'H' << ' ' << h[i] << endl;
  }
  for (int i = 0; i < 13; i++) {
    if (c[i] > 0)
      cout << 'C' << ' ' << c[i] << endl;
  }
  for (int i = 0; i < 13; i++) {
    if (d[i] > 0)
      cout << 'D' << ' ' << d[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <ctype.h>
#include <stdio.h>
#include <string.h>
int main() {
  char W[10];
  char memw[10];
  char c[1000];
  char memc[1000];
  int ans = 0;
  int n, m;
  int i;
  int h;
  scanf("%s", &W);
  n = strlen(W);
  for (i = 0; i < n; i++) {
    memw[i] = tolower(W[i]);
    // printf("%c\\n",memw[i]);
  }
  while (scanf("%s", &c)) {
    h = 0;
    if (c[0] == 'E' && c[1] == 'N' && c[2] == 'D' && c[3] == '_' &&
        c[4] == 'O' && c[5] == 'F' && c[6] == '_' && c[7] == 'T' &&
        c[8] == 'E' && c[9] == 'X' && c[10] == 'T')
      break;
    m = strlen(c);
    for (i = 0; i < m; i++)
      memc[i] = tolower(c[i]);
    if (n != m)
      h = 1;
    else if (memc[0] == W[0]) {
      for (i = 1; i < n; i++) {
        if (W[i] != memc[i]) {
          h = 1;
          break;
        }
      }
      if (h == 0)
        ans++;
    }
  }
  printf("%d\\n", ans);
  return 0;
}
Problem p02408 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n, x;
  int card[5][14] = {0};
  char t;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> t >> x;
    switch (t) {
    case 'S':
      card[0][x] = 1;
      break;
    case 'H':
      card[1][x] = 1;
      break;
    case 'C':
      card[2][x] = 1;
      break;
    case 'D':
      card[3][x] = 1;
      break;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (card[i][j] == 0) {
        switch (i) {
        case 0:
          cout << 'S' << ' ' << j << endl;
          break;
        case 1:
          cout << 'H' << ' ' << j << endl;
          break;
        case 2:
          cout << 'C' << ' ' << j << endl;
          break;
        case 3:
          cout << 'D' << ' ' << j << endl;
          break;
        }
      }
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, x;
  int card[4][13] = {0};
  char t;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> t >> x;
    switch (t) {
    case 'S':
      card[0][x] = 1;
      break;
    case 'H':
      card[1][x] = 1;
      break;
    case 'C':
      card[2][x] = 1;
      break;
    case 'D':
      card[3][x] = 1;
      break;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j <= 13; j++) {
      if (card[i][j] == 0) {
        switch (i) {
        case 0:
          cout << 'S' << ' ' << j << endl;
          break;
        case 1:
          cout << 'H' << ' ' << j << endl;
          break;
        case 2:
          cout << 'C' << ' ' << j << endl;
          break;
        case 3:
          cout << 'D' << ' ' << j << endl;
          break;
        }
      }
    }
  }
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int i, j;
  cin >> n >> m;
  vector<vector<int>> A;
  A.resize(n);
  for (i = 0; i < n; i++) {
    A[i].resize(m);
  }
  vector<int> b(m), c(n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int i, j;
  cin >> n >> m;
  vector<vector<int>> A;
  A.resize(n);
  for (i = 0; i < n; i++) {
    A[i].resize(m);
  }
  vector<int> b(m), c(m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {

  int n, m;
  int a[100][100], b[100];
  int i, k, r;

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

  for (i = 0; i < n; ++i) {
    for (k = 0; k < m; ++k) {
      scanf("%d", &a[i][k]);
    }
  }

  for (i = 0; i < m; ++i) {
    scanf("%d", &b[i]);
  }

  for (i = 0; i < n; ++i) {
    r = 0;
    for (k = 0; k < m; ++k) {
      r += a[i][k] * b[k];
    }
    printf("%d\\n", r);
  }

  return 0;
}


Error: -11

Fixed submission:

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

int main() {

  int n, m, a, r = 0;
  vector<vector<int>> N;
  vector<int> M;

  cin >> n >> m;

  for (int i = 0; i < n; ++i) {
    for (int k = 0; k < m; ++k) {
      cin >> a;
      N[i][m] = a;
    }
  }

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

  for (int i = 0; i < n; ++i) {
    r = 0;
    for (int k = 0; k < m; ++k) {
      r += N[i][k] * M[k];
    }
    cout << r << endl;
  }

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

#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int a[101][101], b[101];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    printf("%d\\n", c);
  }
  return 0;
}


Error: -11

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int a[n][m], b[m];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", b[i]);
  }
  for (int i = 0; i < n; i++) {
    int c;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    printf("%d\\n", c);
  }
  return 0;
}