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

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {

  vector<vector<char>> root(9, vector<char>(5));

  char c;
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 4 + (i % 2); j++) {
      cin >> c;
      root[i][j] = c;
    }
  }

  cout << "R";

  int x = 1;
  int y = 0;
  int d = 2;
  char dirs[] = {'L', 'U', 'R', 'D', 'L', 'U', 'R', 'D'};

  while (x || y) {
    bool gone = false;
    for (int i = -1; i < 3; i++) {
      switch (dirs[d + i]) {
      case 'L':
        if (x > 0 && root[2 * y][x - 1] == '1') {
          x -= 1;
          d = 4;
          cout << 'L';
          gone = true;
        }
        break;
      case 'U':
        if (y > 0 && root[2 * y - 1][x] == '1') {
          y -= 1;
          d = 1;
          cout << 'U';
          gone = true;
        }
        break;
      case 'R':
        if (x < 4 && root[2 * y][x] == '1') {
          x += 1;
          d = 2;
          cout << 'R';
          gone = true;
        }
        break;
      case 'D':
        if (y < 4 && root[2 * y + 1][x] == '1') {
          y += 1;
          d = 3;
          cout << 'D';
          gone = true;
        }
        break;
      }
      if (gone)
        break;
    }
  }
  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {

  vector<vector<char>> root(9, vector<char>(5));

  char c;
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 4 + (i % 2); j++) {
      cin >> c;
      root[i][j] = c;
    }
  }

  cout << "R";

  int x = 1;
  int y = 0;
  int d = 2;
  char dirs[] = {'L', 'U', 'R', 'D', 'L', 'U', 'R'};

  while (x || y) {
    bool gone = false;
    for (int i = -1; i < 2; i++) {
      switch (dirs[d + i]) {
      case 'L':
        if (x > 0 && root[2 * y][x - 1] == '1') {
          x -= 1;
          d = 4;
          cout << 'L';
          gone = true;
        }
        break;
      case 'U':
        if (y > 0 && root[2 * y - 1][x] == '1') {
          y -= 1;
          d = 1;
          cout << 'U';
          gone = true;
        }
        break;
      case 'R':
        if (x < 4 && root[2 * y][x] == '1') {
          x += 1;
          d = 2;
          cout << 'R';
          gone = true;
        }
        break;
      case 'D':
        if (y < 4 && root[2 * y + 1][x] == '1') {
          y += 1;
          d = 3;
          cout << 'D';
          gone = true;
        }
        break;
      }
      if (gone)
        break;
    }
  }
  cout << endl;

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

#include <iostream>
using namespace std;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
char dc[] = "RDLU";

int main() {
  int g[11][11] = {};
  char c;
  for (int i = 1; i < 10; ++i) {
    int k = i % 2; // 0=vertical, 1=horizontal
    for (int j = 1 + k; j <= 9 - k; j += 2) {
      cin >> c;
      g[i][j] |= c - '0';
      g[i - 1 + k][j - k] |= c - '0';
      g[i + 1 - k][j + k] |= c - '0';
    }
  }
  int x = 1, y = 1, d = 0;
  do {
    for (int t = d + 3;; ++t) {
      if (g[y + dy[t % 4]][x + dx[t % 4]]) {
        d = t % 4;
        break;
      }
    }
    x += dx[d] * 2;
    y += dy[d] * 2;
    cout << dc[d];
  } while (x != 1 || y != 1);
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
string dc = "RDLU";

int main() {
  int g[11][11] = {};
  char c;
  for (int i = 1; i < 10; ++i) {
    int k = 1 + (i % 2);
    int l = 9 - (i % 2);
    for (int j = k; j <= l; j += 2) {
      cin >> c;
      g[i][j] = g[i][j - 1] = g[i][j + 1] = c - '0';
    }
  }
  int x = 1, y = 1, d = 0;
  do {
    for (int t = (d + 3) % 4; t <= (d + 2) % 4; t = (t + 1) % 4) {
      if (g[y + dy[t]][x + dx[t]]) {
        d = t;
        break;
      }
    }
    x += dx[d] * 2;
    y += dy[d] * 2;
    cout << dc[d];
  } while (x != 1 || y != 1);
  cout << endl;
  return 0;
}
Problem p00037 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)

int maze[20][20];

char s[6];
char ans[100];
int sz = 0;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

char sym[] = "RDLU";

int main() {
  REP(i, 9) {
    scanf("%s", s);
    REP(j, strlen(s)) {
      if (i % 2 == 0) {
        maze[i + 1][2 * j + 2] = s[j] - '0';
      } else {
        maze[i + 1][2 * j + 1] = s[j] - '0';
      }
    }
  }
  ans[0] = 'R';
  sz++;
  int x = 3, y = 1;
  int dir = 0;
  while (x != 1 || y != 1) {
    REP(i, 4) {
      int d = (dir + 3 + i) % 4;
      if (maze[y + dy[d]][x + dx[d]]) {
        dir = d;
        break;
      }
    }
    x += dx[dir] * 2;
    y += dy[dir] * 2;
    ans[sz++] = sym[dir];
  }
  printf("%s\\n", ans);
  return 0;
}

Error: 0
00000000000
00101010100
00000000010
00001010000
00010001010
00000010000
00010101010
00000010000
00010000010
00001010100
00000000000


Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, a) FOR(i, 0, a)

int maze[20][20];

char s[6];
char ans[100];
int sz = 0;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

char sym[] = "RDLU";

int main() {
  REP(i, 9) {
    scanf("%s", s);
    REP(j, strlen(s)) {
      if (i % 2 == 0) {
        maze[i + 1][2 * j + 2] = s[j] - '0';
      } else {
        maze[i + 1][2 * j + 1] = s[j] - '0';
      }
    }
  }
  REP(i, 11) {
    REP(j, 11) { fprintf(stderr, "%d", maze[i][j]); }
    fprintf(stderr, "\\n");
  }
  ans[0] = 'R';
  sz++;
  int x = 3, y = 1;
  int dir = 0;
  while (x != 1 || y != 1) {
    REP(i, 4) {
      int d = (dir + 3 + i) % 4;
      if (maze[y + dy[d]][x + dx[d]]) {
        dir = d;
        break;
      }
    }
    x += dx[dir] * 2;
    y += dy[dir] * 2;
    ans[sz++] = sym[dir];
  }
  printf("%s\\n", ans);
  return 0;
}
Problem p00037 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const char ch[] = {"ULDR"};

bool g[10][10][10][10];

int main() {
  char c;

  for (int i = 1; i <= 5; i++) {
    for (int j = 1; j <= 4; j++) {
      scanf(" %c", &c);
      if (c == '0')
        continue;
      g[i][j][i][j + 1] = true;
      g[i][j + 1][i][j] = true;
    }
    if (i == 5)
      continue;
    for (int j = 1; j <= 5; j++) {
      scanf(" %c", &c);
      if (c == '0')
        continue;
      g[i][j][i + 1][j] = true;
      g[i + 1][j][i][j] = true;
    }
  }

  int dir = 3;
  int x = 1, y = 2;
  while (true) {
    printf("%c", ch[dir]);
    if (x == 1 && y == 1)
      break;
    for (int t = 1; t >= -2; t--) {
      int nd = (dir + t + 4) % 4;
      int nx = x + dx[nd];
      int ny = y + dy[nd];
      if (g[x][y][nx][ny]) {
        x = nx;
        y = ny;
        dir = nd;
        break;
      }
    }
  }
  puts("");
  return 0;
}

Error: TLE

Fixed submission:

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

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const char ch[] = {"ULDR"};

bool g[10][10][10][10];

int main() {
  char c;

  for (int i = 1; i <= 5; i++) {
    for (int j = 1; j <= 4; j++) {
      scanf(" %c", &c);
      if (c == '0')
        continue;
      g[i][j][i][j + 1] = true;
      g[i][j + 1][i][j] = true;
    }
    if (i == 5)
      continue;
    for (int j = 1; j <= 5; j++) {
      scanf(" %c", &c);
      if (c == '0')
        continue;
      g[i][j][i + 1][j] = true;
      g[i + 1][j][i][j] = true;
    }
  }

  int dir = 3;
  int x = 1, y = 2;
  while (true) {
    printf("%c", ch[dir]);
    if (x == 1 && y == 1)
      break;
    for (int t = 1; t >= -1; t--) {
      int nd = (dir + t + 4) % 4;
      int nx = x + dx[nd];
      int ny = y + dy[nd];
      if (g[x][y][nx][ny]) {
        x = nx;
        y = ny;
        dir = nd;
        break;
      }
    }
  }
  puts("");
  return 0;
}
Problem p00037 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int field[5][5] = {{0}};
  rep(i, 9) {
    char str[6];
    scanf("%s", str);
    if (i % 2) {
      rep(j, 5) {
        int a = str[j] - '0';
        field[i / 2][j] |= a << 2;
        field[i / 2 + 1][j] |= a;
      }
    } else {
      rep(j, 4) {
        int a = str[j] - '0';
        field[i / 2][j] |= a << 1;
        field[i / 2][j + 1] |= a << 3;
      }
    }
  }

  putchar('R');
  int y = 0, x = 1;
  int pre = 1;
  do {
    // printf("(%d, %d)\\n", x, y);
    pre = (pre + 2) % 4;
    int dire = pre;
    do {
      dire = (dire + 1) % 4;
    } while (!((field[y][x] >> dire) & 1));
    pre = dire;
    putchar("URDL"[dire]);

    int dx[] = {0, 1, 0, -1};
    int dy[] = {-1, 0, 1, 0};
    x += dx[dire];
    y += dy[dire];
  } while (y != 0 || x != 0 || (field[0][0] == 6 && pre == 3));
  puts("");

  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int field[5][5] = {{0}};
  rep(i, 9) {
    char str[6];
    scanf("%s", str);
    if (i % 2) {
      rep(j, 5) {
        int a = str[j] - '0';
        field[i / 2][j] |= a << 2;
        field[i / 2 + 1][j] |= a;
      }
    } else {
      rep(j, 4) {
        int a = str[j] - '0';
        field[i / 2][j] |= a << 1;
        field[i / 2][j + 1] |= a << 3;
      }
    }
  }

  putchar('R');
  int y = 0, x = 1;
  int pre = 1;
  bool right = false;
  do {
    // printf("(%d, %d)\\n", x, y);
    pre = (pre + 2) % 4;
    int dire = pre;
    do {
      dire = (dire + right * 2 + 1) % 4;
    } while (!((field[y][x] >> dire) & 1));
    if (dire == pre)
      right = !right;
    pre = dire;
    putchar("URDL"[dire]);

    int dx[] = {0, 1, 0, -1};
    int dy[] = {-1, 0, 1, 0};
    x += dx[dire];
    y += dy[dire];
  } while (y != 0 || x != 0 || right);
  puts("");

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
vector<string> strs;
int H, W;
bool isroad(int fx, int fy, int tx, int ty) {
  int fromx, fromy, tox, toy;
  fromx = min(fx, tx);
  fromy = min(fy, ty);
  tox = max(fx, tx);
  toy = max(fy, ty);
  if (fromx < 1 || tox < 1 || tox > W || fromx > W || fromy < 1 || toy < 1 ||
      fromy > H || toy > H)
    return false;
  if (fromx == tox) {
    if (strs[(fromy - 1) * 2 + 1][fromx - 1] == '1')
      return true;
    else {
      return false;
    }
  } else {
    if (strs[(fromy - 1) * 2][fromx - 1] == '1')
      return true;
    else {
      return false;
    }
  }
}
int vx[] = {1, 0, -1, 0}, vy[] = {0, -1, 0, 1};
int main() {
  string ins;
  while (cin >> ins) {
    strs.push_back(ins);
  }
  W = strs[0].size() + 1;
  H = strs.size() / 2 + 1;
  int nx = 2, ny = 1, v = 0;
  string outs = "R";
  while (nx != 1 || ny != 1) {
    for (int i = 5; i >= 2; i--) {
      bool r = isroad(nx, ny, nx + vx[(v + i) % 4], ny + vy[(v + i) % 4]);
      if (r) {
        v = (v + i) % 4;
        nx += vx[v];
        ny += vy[v];
        if (v == 0)
          outs += 'R';
        else if (v == 1)
          outs += 'U';
        else if (v == 2)
          outs += 'L';
        else
          outs += 'D';
        break;
      }
    }
  }
  cout << outs << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
vector<string> strs;
int H, W;
bool isroad(int fx, int fy, int tx, int ty) {
  int fromx, fromy, tox, toy;
  fromx = min(fx, tx);
  fromy = min(fy, ty);
  tox = max(fx, tx);
  toy = max(fy, ty);
  if (fromx < 1 || tox < 1 || tox > W || fromx > W || fromy < 1 || toy < 1 ||
      fromy > H || toy > H)
    return false;
  if (fromx == tox) {
    if (strs[(fromy - 1) * 2 + 1][fromx - 1] == '1')
      return true;
    else {
      return false;
    }
  } else {
    if (strs[(fromy - 1) * 2][fromx - 1] == '1')
      return true;
    else {
      return false;
    }
  }
}
int vx[] = {1, 0, -1, 0}, vy[] = {0, -1, 0, 1};
int main() {
  string ins;
  while (cin >> ins) {
    strs.push_back(ins);
  }
  W = strs[0].size() + 1;
  H = strs.size() / 2 + 1;
  int nx = 2, ny = 1, v = 0;
  string outs = "R";
  while (nx != 1 || ny != 1) {
    for (int i = 5; i >= 3; i--) {
      bool r = isroad(nx, ny, nx + vx[(v + i) % 4], ny + vy[(v + i) % 4]);
      if (r) {
        v = (v + i) % 4;
        nx += vx[v];
        ny += vy[v];
        if (v == 0)
          outs += 'R';
        else if (v == 1)
          outs += 'U';
        else if (v == 2)
          outs += 'L';
        else
          outs += 'D';
        break;
      }
    }
  }
  cout << outs << endl;
}
Problem p00037 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int f[5][5], i, j, a, y, x, p;
int main() {
  for (; i < 9; ++i) {
    char s[6];
    scanf("%s", s);
    for (j = 0; j < 4 + i % 2; ++j) {
      a = s[j] - 48;
      f[i / 2][j] |= a << (1 + i % 2);
      f[i / 2 + i % 2][j + !(i % 2)] |= a << 3 - i % 2 * 3;
    }
  }
  do {
    do
      p = (p + 1) % 4;
    while (!((f[y][x] >> p) & 1));
    putchar("URDL"[p]);
    x += p ? 2 - p : 0;
    y += p == 3 ? 0 : p - 1;
    p = (p + 2) % 4;
  } while (y != 0 || x != 0 || f[0][0] == 6 && p == 3);
  return !puts("");
}

Error: 1

Fixed submission:

#include <stdio.h>
int f[5][5], i, j, a, y, x, p;
int main() {
  for (; i < 9; ++i) {
    char s[6];
    scanf("%s", s);
    for (j = 0; j < 4 + i % 2; ++j) {
      a = s[j] - 48;
      f[i / 2][j] |= a << (1 + i % 2);
      f[i / 2 + i % 2][j + !(i % 2)] |= a << 3 - i % 2 * 3;
    }
  }
  do {
    do
      p = (p + 1) % 4;
    while (!((f[y][x] >> p) & 1));
    putchar("URDL"[p]);
    x += p ? 2 - p : 0;
    y += p == 3 ? 0 : p - 1;
    p = (p + 2) % 4;
  } while (y != 0 || x != 0 || f[0][0] == 6 && p == 3);
  return puts("");
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int ar[5];
  while (scanf("%d,%d,%d,%d,%d", &ar[0], &ar[1], &ar[2], &ar[3], &ar[4]) + 1) {
    sort(ar, ar + 5);
    int a = ar[0];
    int b = ar[1];
    int c = ar[2];
    int d = ar[3];
    int e = ar[4];

    if (a == d || b == e) {
      cout << "four card" << endl;
    } else if (a == c && d == e) {
      cout << "full house" << endl;
    } else if (a == b && c == e) {
      cout << "full house" << endl;
    } else if (b - a == 1 && c - b == 1 && d - c == 1 && e - d == 1) {
      cout << "straight" << endl;
    } else if (a == 1 && b == 10 && c == 11 && d == 12 && e == 13) {
      cout << "straight" << endl;
    } else if (a == c || b == d || c == e) {
      cout << "three card" << endl;
    } else if (a == b && c == d) {
      cout << "two pair" << endl;
    } else if (a == b && d == e) {
      cout << "two pair" << endl;
    } else if (b == c && d == e) {
      cout << "two pair" << endl;
    } else if (a == b || b == c || c == d || d == e) {
      cout << "one pair" << endl;
    } else {
      cout << "null" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int ar[5];
  while (scanf("%d,%d,%d,%d,%d", &ar[0], &ar[1], &ar[2], &ar[3], &ar[4])) {
    sort(ar, ar + 5);
    int a = ar[0];
    int b = ar[1];
    int c = ar[2];
    int d = ar[3];
    int e = ar[4];

    if (a == d || b == e) {
      cout << "four card" << endl;
    } else if (a == c || d == e) {
      cout << "full house" << endl;
    } else if (a == b || c == e) {
      cout << "full house" << endl;
    } else if (b - a == 1 && c - b == 1 && d - c == 1 && e - d == 1 && a != 1) {
      cout << "straight" << endl;
    } else if (a == 1 && b == 10 && c == 11 && d == 12 && e == 13) {
      cout << "straight" << endl;
    } else if (a == c || b == d || c == e) {
      cout << "three card" << endl;
    } else if (a == b && c == d) {
      cout << "two pair" << endl;
    } else if (a == b && d == e) {
      cout << "two pair" << endl;
    } else if (b == c && d == e) {
      cout << "two pair" << endl;
    } else if (a == b || b == c || c == d || d == e) {
      cout << "one pair" << endl;
    } else {
      cout << "null" << endl;
    }
  }
  return 0;
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
/* null
 * one pair
 * two pair
 * three card
 * straight
 * full house
 * four card
 * */
int main() {
  vector<int> cards(5);
  while (scanf("%d,%d,%d,%d,%d", &cards[0], &cards[1], &cards[2], &cards[3],
               &cards[4]) != EOF) {
    vector<int> cnt(13, 0);
    for (int i = 0; i < 5; i++)
      cnt[cards[i] - 1]++;
    int two = 0, three = 0, four = 0;
    for (int i = 0; i < 13; i++) {
      if (cnt[i] == 2)
        two++;
      if (cnt[i] == 3)
        three++;
      if (cnt[i] == 4)
        four++;
    }
    if (four == 1) {
      printf("four card\\n");
      continue;
    } else if (two == 1 && three == 1) {
      printf("full house\\n");
      continue;
    } else if (three == 1) {
      printf("three card\\n");
      continue;
    } else if (two == 2) {
      printf("two pair\\n");
      continue;
    } else if (two == 1) {
      printf("one pair\\n");
      continue;
    }
    int c = 0;
    bool flag = false;
    for (int i = 0; i < 9; i++) {
      if (cnt[i] == 1) {
        if (cnt[i + 1] == 1 && cnt[i + 2] == 1 && cnt[i + 3] == 1 &&
            cnt[i + 4] == 1) {
          flag = true;
          break;
        }
      }
    }
    if (flag || (cnt[9] == 1 && cnt[10] == 1 && cnt[11] == 1 && cnt[12] == 1 &&
                 cnt[0] == 1)) {
      printf("straight\\n");
    } else {
      printf("null\\n");
    }
  }
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <vector>
using namespace std;
/* null
 * one pair
 * two pair
 * three card
 * straight
 * full house
 * four card
 * */
int main() {
  vector<int> cards(5);
  while (scanf("%d,%d,%d,%d,%d", &cards[0], &cards[1], &cards[2], &cards[3],
               &cards[4])) {
    vector<int> cnt(13, 0);
    for (int i = 0; i < 5; i++)
      cnt[cards[i] - 1]++;
    int two = 0, three = 0, four = 0;
    for (int i = 0; i < 13; i++) {
      if (cnt[i] == 2)
        two++;
      if (cnt[i] == 3)
        three++;
      if (cnt[i] == 4)
        four++;
    }
    if (four == 1) {
      printf("four card\\n");
      continue;
    } else if (two == 1 && three == 1) {
      printf("full house\\n");
      continue;
    } else if (three == 1) {
      printf("three card\\n");
      continue;
    } else if (two == 2) {
      printf("two pair\\n");
      continue;
    } else if (two == 1) {
      printf("one pair\\n");
      continue;
    }
    int c = 0;
    bool flag = false;
    for (int i = 0; i < 9; i++) {
      if (cnt[i] == 1) {
        if (cnt[i + 1] == 1 && cnt[i + 2] == 1 && cnt[i + 3] == 1 &&
            cnt[i + 4] == 1) {
          flag = true;
          break;
        }
      }
    }
    if (flag || (cnt[9] == 1 && cnt[10] == 1 && cnt[11] == 1 && cnt[12] == 1 &&
                 cnt[0] == 1)) {
      printf("straight\\n");
    } else {
      printf("null\\n");
    }
  }
}
Problem p00038 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int card[13]; // A ~ 13
  int data[5];
  while (cin >> data[0]) {
    fill(card, card + 13, 0);
    ++card[data[0] - 1];
    char c0;
    for (int i = 1; i < 5; ++i) {
      cin >> c0 >> data[i];
      ++card[data[i] - 1];
    }

    sort(card, card + 13, greater<int>());
    /*
    for(int i = 0; i < 13; ++i){
            cout << card[i] << " ";
    }
    cout << endl;
    */
    switch (card[0]) {
    case 4:
      cout << "four card" << endl;
      break;

    case 3:
      if (card[1] == 2)
        cout << "full house" << endl;
      else
        cout << "three card" << endl;
      break;

    case 2:
      if (card[1] == 2)
        cout << "two pair" << endl;
      else
        cout << "one pair" << endl;
      break;

    default:
      sort(data, data + 5);
      if ((data[0] == 1 && data[1] == 10 && data[4] == 13) ||
          (data[0] + 4 == data[4]))
        cout << "straight" << endl;
      else
        cout << "null" << endl;
      break;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while (1) {
    int card[13] = {}; // A ~ 13
    int data[5] = {};

    char c0;
    for (int i = 0; i < 5; ++i) {
      if (i != 0)
        cin >> c0;
      cin >> data[i];
      ++card[data[i] - 1];
    }

    if (cin.eof())
      break;

    sort(card, card + 13, greater<int>());
    /*
    for(int i = 0; i < 13; ++i){
            cout << card[i] << " ";
    }
    cout << endl;
    */
    switch (card[0]) {
    case 4:
      cout << "four card" << endl;
      break;

    case 3:
      if (card[1] == 2)
        cout << "full house" << endl;
      else
        cout << "three card" << endl;
      break;

    case 2:
      if (card[1] == 2)
        cout << "two pair" << endl;
      else
        cout << "one pair" << endl;
      break;

    default:
      sort(data, data + 5);
      if ((data[0] == 1 && data[1] == 10 && data[4] == 13) ||
          (data[0] + 4 == data[4]))
        cout << "straight" << endl;
      else
        cout << "null" << endl;
      break;
    }
  }
  return 0;
}