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

#include <iostream>
static void e(int *a) {
  int t = a[1];
  a[1] = a[4];
  a[4] = a[6];
  a[6] = a[3];
  a[3] = t;
}
static void n(int *a) {
  int t = a[1];
  a[1] = a[2];
  a[2] = a[6];
  a[6] = a[5];
  a[5] = t;
}
static void s(int *a) {
  int t = a[1];
  a[1] = a[5];
  a[5] = a[6];
  a[6] = a[2];
  a[2] = t;
}
static void w(int *a) {
  int t = a[1];
  a[1] = a[3];
  a[3] = a[6];
  a[6] = a[4];
  a[4] = t;
}
int main() {
  int a[7], b[7];
  for (int i = 1; i <= 6; ++i) {
    std::cin >> a[i];
  }
  for (int i = 1; i <= 6; ++i) {
    std::cin >> b[i];
  }
  bool f = false;
  std::string m;
  for (int i = 0; i < 4 && !f; ++i) {
    s(b);
    for (int j = 0; j < 4 && !f; ++j) {
      w(b);
      for (int k = 0; k < 4 && !f; ++k) {
        s(b);
        e(b);
        n(b);
        f = true;
        for (int x = 1; x <= 6; ++x) {
          if (a[x] != b[x]) {
            f = false;
            break;
          }
        }
      }
    }
  }
  std::cout << (f ? "Yes" : "No") << std::endl;
}


Error: TLE

Fixed submission:

#include <iostream>
static void e(int *a) {
  int t = a[1];
  a[1] = a[4];
  a[4] = a[6];
  a[6] = a[3];
  a[3] = t;
}
static void n(int *a) {
  int t = a[1];
  a[1] = a[2];
  a[2] = a[6];
  a[6] = a[5];
  a[5] = t;
}
static void s(int *a) {
  int t = a[1];
  a[1] = a[5];
  a[5] = a[6];
  a[6] = a[2];
  a[2] = t;
}
int main() {
  int a[7], b[7];
  for (int i = 1; i <= 6; ++i) {
    std::cin >> a[i];
  }
  for (int i = 1; i <= 6; ++i) {
    std::cin >> b[i];
  }
  while (a[1] != b[1]) {
    s(b);
  }
  for (int i = 0; i < 3 && a[2] != b[2]; ++i) {
    s(b);
    e(b);
    n(b);
  }
  std::string m = "Yes";
  for (int i = 1; i <= 6; ++i) {
    if (a[i] != b[i]) {
      m = "No";
      break;
    }
  }
  std::cout << m << std::endl;
}
Problem p02386 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

void roll(std::vector<int> &v, char c) {
  if (c == 'E') {
    char tmp = v[0];
    v[0] = v[3];
    v[3] = v[5];
    v[5] = v[2];
    v[2] = tmp;
  } else if (c == 'S') {
    char tmp = v[0];
    v[0] = v[4];
    v[4] = v[5];
    v[5] = v[1];
    v[1] = tmp;
  } else if (c == 'N') {
    char tmp = v[0];
    v[0] = v[1];
    v[1] = v[5];
    v[5] = v[4];
    v[4] = tmp;
  } else {
    char tmp = v[0];
    v[0] = v[2];
    v[2] = v[5];
    v[5] = v[3];
    v[3] = tmp;
  }
}

bool isSame(std::vector<int> v, std::vector<int> v2) {
  std::vector<int> tmp, tmp2;
  tmp = v;
  tmp2 = v2;
  std::sort(tmp.begin(), tmp.end());
  std::sort(tmp2.begin(), tmp2.end());
  if (tmp != tmp2)
    return false;
  if (v[1] != v2[1]) {
    if (v2[4] == v[1])
      roll(v2, 'N');
    while (v2[0] != v[1])
      roll(v2, 'E');
    roll(v2, 'S');
  }

  for (int i = 0; i < 4; i++) {
    if (v == v2) {
      return true;
    }
    roll(v2, 'E');
  }
  return false;
}

int main() {
  int n;

  std::cin >> n;

  std::vector<std::vector<int>> v(n, std::vector<int>(6));

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d %d %d", &v[i][0], &v[i][1], &v[i][2], &v[i][3], &v[i][4],
          &v[i][5]);
  }

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (isSame(v[i], v[j])) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }

  std::cout << "Yes" << std::endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

void roll(std::vector<int> &v, char c) {
  if (c == 'E') {
    char tmp = v[0];
    v[0] = v[3];
    v[3] = v[5];
    v[5] = v[2];
    v[2] = tmp;
  } else if (c == 'S') {
    char tmp = v[0];
    v[0] = v[4];
    v[4] = v[5];
    v[5] = v[1];
    v[1] = tmp;
  } else if (c == 'N') {
    char tmp = v[0];
    v[0] = v[1];
    v[1] = v[5];
    v[5] = v[4];
    v[4] = tmp;
  } else {
    char tmp = v[0];
    v[0] = v[2];
    v[2] = v[5];
    v[5] = v[3];
    v[3] = tmp;
  }
}

bool isSame(std::vector<int> v, std::vector<int> v2) {
  if (v[1] != v2[1]) {
    if (v2[4] == v[1])
      roll(v2, 'N');
    while (v2[0] != v[1])
      roll(v2, 'E');
    roll(v2, 'S');
  }

  for (int i = 0; i < 4; i++) {
    if (v == v2) {
      return true;
    }
    roll(v2, 'E');
  }
  return false;
}

int main() {
  int n;

  std::cin >> n;

  std::vector<std::vector<int>> v(n, std::vector<int>(6));

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d %d %d", &v[i][0], &v[i][1], &v[i][2], &v[i][3], &v[i][4],
          &v[i][5]);
  }

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (isSame(v[i], v[j])) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }

  std::cout << "Yes" << std::endl;
  return 0;
}
Problem p02386 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

class Cube {
public:
  int f[6];
  Cube() {}
  void roll_z() { roll(1, 2, 4, 3); }
  void roll_y() { roll(0, 2, 5, 3); }
  void roll_x() { roll(0, 1, 5, 4); }
  void roll(int i, int j, int k, int l) {
    int t = f[i];
    f[i] = f[j];
    f[j] = f[k];
    f[k] = f[l];
    f[l] = t;
  }
};

bool eq(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    if (c1.f[i] != c2.f[i])
      return false;
  }
  return true;
}

bool equal(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) {
      if (eq(c1, c2))
        return true;
      c1.roll_z();
    }
    if (i % 2 == 0)
      c1.roll_y();
    else
      c1.roll_x();
  }
  return false;
}

Cube C[100];
int n;

bool check() {
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (equal(C[i], C[j]))
        return false;
    }
  }
  return true;
}

int main() {
  cin >> n;

  for (int j = 0; j < n; j++) {
    for (int i = 0; i < 6; i++)
      cin >> C[j].f[i];
  }

  if (check())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

class Cube {
public:
  int f[6];
  Cube() {}
  void roll_z() { roll(1, 2, 4, 3); }
  void roll_y() { roll(0, 2, 5, 3); }
  void roll_x() { roll(0, 1, 5, 4); }
  void roll(int i, int j, int k, int l) {
    int t = f[i];
    f[i] = f[j];
    f[j] = f[k];
    f[k] = f[l];
    f[l] = t;
  }
};

bool eq(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    if (c1.f[i] != c2.f[i])
      return false;
  }
  return true;
}

bool equal(Cube c1, Cube c2) {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) {
      if (eq(c1, c2))
        return true;
      c1.roll_z();
    }
    if (i % 2 == 0)
      c1.roll_y();
    else
      c1.roll_x();
  }
  return false;
}

Cube C[100];
int n;

bool check() {
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (equal(C[i], C[j]))
        return false;
    }
  }
  return true;
}

int main() {
  cin >> n;

  for (int j = 0; j < n; j++) {
    for (int i = 0; i < 6; j++)
      cin >> C[j].f[i];
  }

  if (check())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

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

#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>

using namespace std;

struct dice {
  int u, n, e, s, w, d;
};

int main() {

  srand((unsigned)time(NULL));

  int n;
  dice d[100];
  int tmp;
  int q, a, b;
  int rn;
  int cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> d[i].u >> d[i].s >> d[i].e >> d[i].w >> d[i].n >> d[i].d;
  }

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      cnt = 0;
      while (1) {
        rn = rand() % 4;
        if (rn == 0) {
          tmp = d[i].u;
          d[i].u = d[i].s;
          d[i].s = d[i].d;
          d[i].d = d[i].n;
          d[i].n = tmp;
        } else if (rn == 1) {
          tmp = d[i].u;
          d[i].u = d[i].w;
          d[i].w = d[i].d;
          d[i].d = d[i].e;
          d[i].e = tmp;
        } else if (rn == 2) {
          tmp = d[i].u;
          d[i].u = d[i].n;
          d[i].n = d[i].d;
          d[i].d = d[i].s;
          d[i].s = tmp;
        } else if (rn == 3) {
          tmp = d[i].u;
          d[i].u = d[i].e;
          d[i].e = d[i].d;
          d[i].d = d[i].w;
          d[i].w = tmp;
        }
        if (d[i].u == d[j].u && d[i].w == d[j].w && d[i].e == d[j].e &&
            d[i].s == d[j].s && d[i].n == d[j].n && d[i].d == d[j].d) {
          cout << "No" << endl;
          return 0;
        }
        cnt++;
        if (cnt == 10000) {
          break;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Error: TLE

Fixed submission:

#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>

using namespace std;

struct dice {
  int u, n, e, s, w, d;
};

int main() {

  srand((unsigned)time(NULL));

  int n;
  dice d[100];
  int tmp;
  int q, a, b;
  int rn;
  int cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> d[i].u >> d[i].s >> d[i].e >> d[i].w >> d[i].n >> d[i].d;
  }

  for (int i = 1; i < n; i++) {
    cnt = 0;
    while (1) {
      rn = rand() % 4;
      if (rn == 0) {
        tmp = d[i].u;
        d[i].u = d[i].s;
        d[i].s = d[i].d;
        d[i].d = d[i].n;
        d[i].n = tmp;
      } else if (rn == 1) {
        tmp = d[i].u;
        d[i].u = d[i].w;
        d[i].w = d[i].d;
        d[i].d = d[i].e;
        d[i].e = tmp;
      } else if (rn == 2) {
        tmp = d[i].u;
        d[i].u = d[i].n;
        d[i].n = d[i].d;
        d[i].d = d[i].s;
        d[i].s = tmp;
      } else if (rn == 3) {
        tmp = d[i].u;
        d[i].u = d[i].e;
        d[i].e = d[i].d;
        d[i].d = d[i].w;
        d[i].w = tmp;
      }
      if (d[i].u == d[i - 1].u && d[i].w == d[i - 1].w &&
          d[i].e == d[i - 1].e && d[i].s == d[i - 1].s &&
          d[i].n == d[i - 1].n && d[i].d == d[i - 1].d) {
        cout << "No" << endl;
        return 0;
      }
      cnt++;
      if (cnt == 1000000) {
        break;
      }
    }
  }
  cout << "Yes" << endl;
}
Problem p02386 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n][6];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> x[i][j];
    }
  }

  char a[30] = {'N', 'N', 'N', 'N', 'E', 'E', 'E', 'N', 'N', 'N',
                'E', 'E', 'E', 'N', 'N', 'N', 'E', 'N', 'N', 'N',
                'E', 'N', 'N', 'N', 'E', 'E', 'E', 'N', 'N', 'N'};
  int b, c, d, e;
  b = c = d = e = 0;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < 30; i++) {
      if (a[i] == 'E') {
        b = x[k][0];
        c = x[k][2];
        d = x[k][3];
        e = x[k][5];
        x[k][2] = b;
        x[k][5] = c;
        x[k][0] = d;
        x[k][3] = e;
      }

      if (a[i] == 'N') {
        b = x[k][0];
        c = x[k][1];
        d = x[k][4];
        e = x[k][5];
        x[k][4] = b;
        x[k][0] = c;
        x[k][5] = d;
        x[k][1] = e;
      }
      for (int j = 0; j < k; j++) {
        if (x[j][0] == x[k][0] && x[j][1] == x[k][1] && x[j][2] == x[k][2] &&
            x[j][3] == x[k][3] && x[j][4] == x[k][4] && x[j][5] == x[k][5]) {
          cout << "No" << endl;
          goto l;
        }
      }
    }
    if (k == n - 1) {
      cout << "Yes" << endl;
      goto l;
    }
  }
l:;
  return 0;
}


Error: 1

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
int main() {
  int n;
  cin >> n;
  int x[n][6];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> x[i][j];
    }
  }

  char a[30] = {'N', 'N', 'N', 'N', 'E', 'E', 'E', 'N', 'N', 'N',
                'E', 'E', 'E', 'N', 'N', 'N', 'E', 'N', 'N', 'N',
                'E', 'N', 'N', 'N', 'E', 'E', 'E', 'N', 'N', 'N'};
  int b, c, d, e;
  b = c = d = e = 0;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < 30; i++) {
      if (a[i] == 'E') {
        b = x[k][0];
        c = x[k][2];
        d = x[k][3];
        e = x[k][5];
        x[k][2] = b;
        x[k][5] = c;
        x[k][0] = d;
        x[k][3] = e;
      }

      if (a[i] == 'N') {
        b = x[k][0];
        c = x[k][1];
        d = x[k][4];
        e = x[k][5];
        x[k][4] = b;
        x[k][0] = c;
        x[k][5] = d;
        x[k][1] = e;
      }
      for (int j = 0; j < k; j++) {
        if (x[j][0] == x[k][0] && x[j][1] == x[k][1] && x[j][2] == x[k][2] &&
            x[j][3] == x[k][3] && x[j][4] == x[k][4] && x[j][5] == x[k][5]) {
          cout << "No" << endl;
          exit(1);
        }
      }
    }
    if (k == n - 1) {
      cout << "Yes" << endl;
    }
  }
}
Problem p02386 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int k, n, set_1 = 0, dice[100][7];

  scanf("%d", &n);

  for (int i = 0; i < n; i++)
    for (int j = 1; j < 7; j++)
      scanf("%d", &dice[i][j]);

  for (int x = 0; x < n - 1; x++) {
    for (int y = x + 1; y < n; y++) {
      for (int i = 0; i < 6; i++) {
        if (dice[x][1] == dice[y][1])
          for (int j = 0; j < 4; j++) {

            // 一致判定
            for (k = 1; k < 7; k++)
              if (dice[x][k] != dice[y][k])
                break;

            if (k == 7)
              set_1 = 1;

            // スピン
            dice[y][0] = dice[y][2];
            dice[y][2] = dice[y][3];
            dice[y][3] = dice[y][5];
            dice[y][5] = dice[y][4];
            dice[y][4] = dice[y][0];
          }

        // 回転

        dice[y][0] = dice[y][1];

        switch (i) {

        case 2:
          dice[y][1] = dice[y][3];
          dice[y][3] = dice[y][6];
          dice[y][6] = dice[y][4];
          dice[y][4] = dice[y][0];
          break;

        default:
          dice[y][1] = dice[y][2];
          dice[y][2] = dice[y][6];
          dice[y][6] = dice[y][5];
          dice[y][5] = dice[y][0];
          break;
        }
      }
    }
  }

  printf(set_1 == 1 ? "No\\n" : "Yes\\n");
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main(void) {
  int i, j, k, n, dice[3][7];

  scanf("%d", &n);

  for (i = 0; i < 3; i++)
    for (j = 1; j < 7; j++)
      scanf("%d", &dice[i][j]);

  for (int x = 0; x < n - 1; x++)
    for (int y = x + 1; y < n; y++)
      for (i = 0; i < 6; i++) {
        if (dice[x][1] == dice[y][1])
          for (j = 0; j < 4; j++) {

            // 一致判定
            for (k = 1; k < 7; k++)
              if (dice[x][k] != dice[y][k])
                break;

            if (k == 7) {
              printf("No\\n");
              return 0;
            }

            // スピン
            dice[y][0] = dice[y][2];
            dice[y][2] = dice[y][3];
            dice[y][3] = dice[y][5];
            dice[y][5] = dice[y][4];
            dice[y][4] = dice[y][0];
          }

        // 回転

        dice[y][0] = dice[y][1];

        switch (i) {

        case 2:
          dice[y][1] = dice[y][3];
          dice[y][3] = dice[y][6];
          dice[y][6] = dice[y][4];
          dice[y][4] = dice[y][0];
          break;

        default:
          dice[y][1] = dice[y][2];
          dice[y][2] = dice[y][6];
          dice[y][6] = dice[y][5];
          dice[y][5] = dice[y][0];
          break;
        }
      }

  printf("Yes\\n");
  return 0;
}
Problem p02386 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

class Dice {
public:
  int *num;

  Dice(int *n) { num = n; }

  void move(char c) {
    int n[6];
    for (int i = 0; i < 6; i++) {
      n[i] = num[i];
    }
    if (c == 'N') {
      num[0] = n[1];
      num[1] = n[5];
      num[4] = n[0];
      num[5] = n[4];
    } else if (c == 'S') {
      num[0] = n[4];
      num[1] = n[0];
      num[4] = n[5];
      num[5] = n[1];
    } else if (c == 'W') {
      num[0] = n[2];
      num[2] = n[5];
      num[3] = n[0];
      num[5] = n[3];
    } else {
      num[0] = n[3];
      num[2] = n[0];
      num[3] = n[5];
      num[5] = n[2];
    }
  }
};

int main() {
  int n;
  cin >> n;
  int num[n][6];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> num[i][j];
    }
  }

  bool result = true;
  for (int a = 0; a < n - 1; a++) {
    for (int b = a + 1; b < n; b++) {
      Dice ad(num[a]), bd(num[b]);
      for (int j = 0; j < 4; j++) {
        if (ad.num[1] == bd.num[1])
          break;
        ad.move('S');
      }
      if (ad.num[1] != bd.num[1]) {
        ad.move('W');
        for (int j = 0; j < 4; j++) {
          if (ad.num[1] == bd.num[1])
            break;
          ad.move('S');
        }
      }
      for (int j = 0; j < 4; j++) {
        if (ad.num[0] == bd.num[0])
          break;
        ad.move('W');
      }
      bool eq = true;
      for (int i = 0; i < 6; i++) {
        eq = eq && (ad.num[i] == bd.num[i]);
      }
      result = result && !eq;
    }
  }
  if (result)
    cout << "Yes";
  else
    cout << "No";
  cout << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

class Dice {
public:
  int *num;

  Dice(int *n) { num = n; }

  void move(char c) {
    int n[6];
    for (int i = 0; i < 6; i++) {
      n[i] = num[i];
    }
    if (c == 'N') {
      num[0] = n[1];
      num[1] = n[5];
      num[4] = n[0];
      num[5] = n[4];
    } else if (c == 'S') {
      num[0] = n[4];
      num[1] = n[0];
      num[4] = n[5];
      num[5] = n[1];
    } else if (c == 'W') {
      num[0] = n[2];
      num[2] = n[5];
      num[3] = n[0];
      num[5] = n[3];
    } else {
      num[0] = n[3];
      num[2] = n[0];
      num[3] = n[5];
      num[5] = n[2];
    }
  }
};

int main() {
  int n;
  cin >> n;
  int num[n][6];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> num[i][j];
    }
  }

  bool result = true;
  for (int i = 0; i < n - 1; i++) {
    Dice ad(num[i]), bd(num[i + 1]);
    for (int j = 0; j < 4; j++) {
      if (ad.num[1] == bd.num[1])
        break;
      ad.move('S');
    }
    if (ad.num[1] != bd.num[1]) {
      ad.move('W');
      for (int j = 0; j < 4; j++) {
        if (ad.num[1] == bd.num[1])
          break;
        ad.move('S');
      }
    }
    while (ad.num[0] != bd.num[0]) {
      ad.move('W');
    }
    bool eq = true;
    for (int i = 0; i < 6; i++) {
      eq = eq && (ad.num[i] == bd.num[i]);
    }
    result = result && !eq;
  }
  if (result)
    cout << "Yes";
  else
    cout << "No";
  cout << endl;
}
Problem p02386 (C++) — buggy submission, verdict: Runtime Error

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

class Dice {
public:
  long r[6];
  Dice(){};
  void roll(long a, long b, long c, long d) {
    swap(r[a], r[b]);
    swap(r[b], r[c]);
    swap(r[c], r[d]);
  }
  void spinW() { roll(0, 2, 5, 3); }
  void spinN() { roll(0, 1, 5, 4); }
};

int main() {
  int ans = 0;
  int n;
  cin >> n;
  vector<Dice> D(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++)
      cin >> D[i].r[j];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      char SWS[8] = {"NNNWNNN"};
      for (int k = 0; k < 8; k++) {
        if (D[i].r[1] == D[j].r[1])
          break;
        if (SWS[k] == 'W')
          D[j].spinW();
        else
          D[j].spinN();
      }
      for (int k = 0; k < 4; k++) {
        if (D[i].r[0] == D[j].r[0]) {
          if (D[i].r[1] == D[j].r[1] && D[i].r[2] == D[j].r[2] &&
              D[i].r[3] == D[j].r[3] && D[i].r[4] == D[j].r[4] &&
              D[i].r[5] == D[j].r[5])
            ans++;
        }
        D[j].spinW();
      }
    }
  }

  if (ans == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Error: 0

Fixed submission:

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

class Dice {
public:
  long r[6];
  Dice(){};
  void roll(long a, long b, long c, long d) {
    swap(r[a], r[b]);
    swap(r[b], r[c]);
    swap(r[c], r[d]);
  }
  void spinW() { roll(0, 2, 5, 3); }
  void spinN() { roll(0, 1, 5, 4); }
};

int main() {
  int ans = 0;
  int n;
  cin >> n;
  vector<Dice> D(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++)
      cin >> D[i].r[j];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      char SWS[8] = {"NNNWNNN"};
      for (int k = 0; k < 8; k++) {
        if (D[i].r[1] == D[j].r[1])
          break;
        if (SWS[k] == 'W')
          D[j].spinW();
        else
          D[j].spinN();
      }
      for (int k = 0; k < 4; k++) {
        if (D[i].r[0] == D[j].r[0]) {
          if (D[i].r[1] == D[j].r[1] && D[i].r[2] == D[j].r[2] &&
              D[i].r[3] == D[j].r[3] && D[i].r[4] == D[j].r[4] &&
              D[i].r[5] == D[j].r[5])
            ans++;
        }
        D[j].spinW();
      }
    }
  }

  if (ans == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

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

#include <stdio.h>
int main(void) {
  int a, b;

  scanf("%d %d\\n", &a, &b);

  if (a > b) {
    printf("a > b\\n");
  }

  if (a < b) {
    printf("a < b\\n");
  }

  if (a == b) {
    printf("a == b\\n");
  }

  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>
int main(void) {
  int a, b;

  scanf("%d %d", a, b);

  if (a > b) {
    printf("a > b\\n");
  }

  if (a < b) {
    printf("a < b\\n");
  }

  if (a == b) {
    printf("a == b\\n");
  }

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

#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  char s;
  if (a > b)
    s = '>';
  else if (a == b)
    s = '=';
  else
    s = '<';
  if (s != '=')
    printf("a %c b\\n", s);
  else
    printf("a == b\\n");
  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  char s;
  if (a > b)
    s = '>';
  else if (a == b)
    s = '=';
  else
    s = '<';
  if (s != '=')
    printf("a %s b\\n", s);
  else
    printf("a == b\\n");
  return 0;
}
Problem p02391 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main(void) {
  int a, b;

  scanf("%d", &a);
  scanf("%d", &b);

  if (a < b) {
    printf("a < b\\n");
  } else if (a > b) {
    printf("a > b\\n");
  } else if (a == b) {
    printf("a == b\\n");
  }

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main(void) {
  int a, b;

  scanf("%d", &a);
  scanf("%d", &b);

  if (a < b) {
    printf("%s\\n", a < b);
  } else if (a > b) {
    printf("%s\\n", a > b);
  } else if (a == b) {
    printf("%s\\n", a == b);
  }
  return 0;
}
Problem p02391 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int a, b;

  scanf("%d%d", &a, &b);

  if (a < b) {
    printf("a < b\\n", a, b);
  }

  else if (a > b) {
    printf("a > b\\n", a, b);
  }

  else {
    printf("a == b\\n", a, b);
  }

  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int a, b;
  scanf("%d %d", a, b);
  if (a > b) {
    printf("%d %d\\n", a > b);
  }

  else if (a < b) {
    printf("%d %d\\n", a < b);
  } else if (a == b) {
    printf("%d %d\\n", a == b);
  }

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

#include <stdio.h>
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a < b) {
    printf("a < b\\n");
  } else if (a > b) {
    printf("a > b\\n");
  } else {
    printf("a == b\\n");
  }
  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int a, b;
  scanf("%d %d", a, b);
  if (a < b) {
    printf("%d<%d", a, b);
  } else if (a > b) {
    printf("%d<%d", a, b);
  } else if (a == b) {
    printf("%d==%d", a, b);
  }
  return 0;
}
Problem p02391 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {

  int a, b;

  scanf("%d %d", &a, &b);

  if (a < b) {

    printf("a < b\\n");
  }
  if (a > b) {

    printf("a > b\\n");
  }
  if (a == b) {
    printf("a == b\\n");
  }
}

Error: -11

Fixed submission:

#include <stdio.h>
int main(void) {

  int a, b;

  scanf("%d %d", a, b);

  if (a < b) {

    printf("a < b\\n");
  }
  if (a > b) {

    printf("a > b\\n");
  }
  if (a == b) {
    printf("a ==b\\n");
  }
}