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

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

bool isstraight(int c[]);

int main() {
  int card[5];

  while (~scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3],
                &card[4])) {
    sort(card, card + 5);
    int n = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = i + 1; j < 5; j++) {
        if (card[i] == card[j]) {
          n++;
        }
      }
    }

    switch (n) {
    case 1:
      cout << "one pair" << endl;
      break;
    case 2:
      cout << "two pair" << endl;
      break;
    case 3:
      cout << "three card" << endl;
      break;
    case 4:
      cout << "full house" << endl;
      break;
    case 6:
      cout << "four card" << endl;
      break;
    case 10:
      cout << "four card" << endl;
      break;
    default:
      if (isstraight(card)) {
        cout << "straight" << endl;
      } else {
        cout << "null" << endl;
      }
      break;
    }
  }

  return 0;
}

bool isstraight(int c[]) {
  for (int i = 1; i < 9; i++) {
    if (c[0] == i && c[1] == i + 1 && c[2] == i + 2 && c[3] == i + 3 &&
        c[4] == i + 4) {
      return true;
    }
    if (c[0] == 1 && c[1] == 10 && c[2] == 11 && c[3] == 12 && c[4] == 13) {
      return true;
    }
  }
  return false;
}

Error: TLE

Fixed submission:

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

bool isstraight(int c[]);

int main() {
  int card[5];

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

    switch (n) {
    case 1:
      cout << "one pair" << endl;
      break;
    case 2:
      cout << "two pair" << endl;
      break;
    case 3:
      cout << "three card" << endl;
      break;
    case 4:
      cout << "full house" << endl;
      break;
    case 6:
      cout << "four card" << endl;
      break;
    case 10:
      cout << "four card" << endl;
      break;
    default:
      if (isstraight(card)) {
        cout << "straight" << endl;
      } else {
        cout << "null" << endl;
      }
      break;
    }
  }

  return 0;
}

bool isstraight(int c[]) {
  for (int i = 1; i < 9; i++) {
    if (c[0] == i && c[1] == i + 1 && c[2] == i + 2 && c[3] == i + 3 &&
        c[4] == i + 4) {
      return true;
    }
    if (c[0] == 1 && c[1] == 10 && c[2] == 11 && c[3] == 12 && c[4] == 13) {
      return true;
    }
  }
  return false;
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(), (c).end())

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

using namespace std;
int main(void) {
  for (;;) {
    int n[5];
    char c;
    REP(i, 5) {
      if (i)
        cin >> c;
      n[i] = 0;
      cin >> n[i];
      if (n[i] == 0)
        return 0;
    }
    int num[16];
    REP(i, 16) num[i] = 0;
    REP(i, 5)++ num[n[i]];
    num[14] = num[1];
    string s = "null";
    REP(i, 11) {
      int st = 0;
      REP(j, 5) if (num[i + j])++ st;
      if (st == 5)
        s = "straight";
    }
    int pa = 0;
    REP(i, 5) REP(j, i) if (n[i] == n[j])++ pa;
    if (pa == 1)
      s = "one pair";
    if (pa == 2)
      s = "two pair";
    if (pa == 3)
      s = "three card";
    if (pa == 4)
      s = "full house";
    if (pa == 6)
      s = "four card";
    cout << s << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(), (c).end())

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

using namespace std;
int main(void) {
  for (;;) {
    int n[5];
    char c;
    REP(i, 5) {
      if (i)
        cin >> c;
      if ((scanf("%d", &n[i])) == 0)
        return 0;
    }
    int num[16];
    REP(i, 16) num[i] = 0;
    REP(i, 5)++ num[n[i]];
    num[14] = num[1];
    string s = "null";
    REP(i, 11) {
      int st = 0;
      REP(j, 5) if (num[i + j])++ st;
      if (st == 5)
        s = "straight";
    }
    int pa = 0;
    REP(i, 5) REP(j, i) if (n[i] == n[j])++ pa;
    if (pa == 1)
      s = "one pair";
    if (pa == 2)
      s = "two pair";
    if (pa == 3)
      s = "three card";
    if (pa == 4)
      s = "full house";
    if (pa == 6)
      s = "four card";
    cout << s << endl;
  }
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int a[5];

string S;

string poker(int p, int q, int r, int s, int t) {
  if (p == q && q == r && r == s) {
    return "four card";
  }
  if (s == t && q == r && r == s) {
    return "four card";
  }
  if (p == q && q == r && s == t) {
    return "full house";
  }
  if (p == q && r == s && s == t) {
    return "full house";
  }
  if (p == q - 1 && q == r - 1 && r == s - 1 && s == t - 1) {
    return "straight";
  }
  if (p == 1 && q == 10 && r == 11 && s == 12 && t == 13) {
    return "straight";
  }
  if (p == q && q == r) {
    return "three card";
  }
  if (r == s && q == r) {
    return "three card";
  }
  if (r == s && s == t) {
    return "three card";
  }
  if (p == q && r == s) {
    return "two pair";
  }
  if (p == q && s == t) {
    return "two pair";
  }
  if (q == r && s == t) {
    return "two pair";
  }
  if (p == q) {
    return "one pair";
  }
  if (q == r) {
    return "one pair";
  }
  if (r == s) {
    return "one pair";
  }
  if (s == t) {
    return "one pair";
  }
  return "null";
}

int main() {
  while (cin >> S) {
    int cnt = 0;
    string U = "";
    S += ',';
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == ',') {
        a[cnt] = stoi(U);
        U = "";
        cnt++;
      } else {
        U += S[i];
      }
    }
    sort(a, a + 5);
    cout << poker(a[0], a[1], a[2], a[3], a[4]) << endl;
  }
}

Error: TLE

Fixed submission:

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

int a[5];

string poker(int p, int q, int r, int s, int t) {
  if (p == q && q == r && r == s) {
    return "four card";
  }
  if (s == t && q == r && r == s) {
    return "four card";
  }
  if (p == q && q == r && s == t) {
    return "full house";
  }
  if (p == q && r == s && s == t) {
    return "full house";
  }
  if (p == q - 1 && q == r - 1 && r == s - 1 && s == t - 1) {
    return "straight";
  }
  if (p == 1 && q == 10 && r == 11 && s == 12 && t == 13) {
    return "straight";
  }
  if (p == q && q == r) {
    return "three card";
  }
  if (r == s && q == r) {
    return "three card";
  }
  if (r == s && s == t) {
    return "three card";
  }
  if (p == q && r == s) {
    return "two pair";
  }
  if (p == q && s == t) {
    return "two pair";
  }
  if (q == r && s == t) {
    return "two pair";
  }
  if (p == q) {
    return "one pair";
  }
  if (q == r) {
    return "one pair";
  }
  if (r == s) {
    return "one pair";
  }
  if (s == t) {
    return "one pair";
  }
  return "null";
}

int main() {
  while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
    sort(a, a + 5);
    cout << poker(a[0], a[1], a[2], a[3], a[4]) << endl;
  }
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int c[5]; // card

bool straight() {
  if (c[4] == 13 && c[3] == 12 && c[2] == 11 && c[1] == 10 && c[0] == 1)
    return true;
  for (int i = 0; i < 4; i++) {
    if (c[i + 1] - c[i] != 1)
      return false;
  }
  return true;
}

int main(void) {
  while (~scanf("%d,%d,%d,%d,%d", c, c + 1, c + 2, c + 3, c + 4)) {
    sort(c, c + 5);
    if (c[0] == c[3] || c[1] == c[4]) {
      puts("four card");
    } else if ((c[0] == c[2] && c[3] == c[4]) ||
               (c[0] == c[1] && c[2] == c[4])) {
      puts("full house");
    } else if (straight()) {
      puts("straight");
    } else if (c[0] == c[2] || c[1] == c[3] || c[2] == c[4]) {
      puts("three card");
    } else if ((c[0] == c[1] && (c[2] == c[3] || c[3] == c[4])) ||
               (c[1] == c[2] && c[3] == c[4])) {
      puts("two pair");
    } else if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3] || c[3] == c[4]) {
      puts("one pair");
    } else {
      puts("null");
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int c[5]; // card

bool straight() {
  if (c[4] == 13 && c[3] == 12 && c[2] == 11 && c[1] == 10 && c[0] == 1)
    return true;
  for (int i = 0; i < 4; i++) {
    if (c[i + 1] - c[i] != 1)
      return false;
  }
  return true;
}

int main(void) {
  while (~scanf("%d %d %d %d %d", c, c + 1, c + 2, c + 3, c + 4)) {
    sort(c, c + 5);
    if (c[0] == c[3] || c[1] == c[4]) {
      puts("four card");
    } else if ((c[0] == c[2] && c[3] == c[4]) ||
               (c[0] == c[1] && c[2] == c[4])) {
      puts("full house");
    } else if (straight()) {
      puts("straight");
    } else if (c[0] == c[2] || c[1] == c[3] || c[2] == c[4]) {
      puts("three card");
    } else if ((c[0] == c[1] && (c[2] == c[3] || c[3] == c[4])) ||
               (c[1] == c[2] && c[3] == c[4])) {
      puts("two pair");
    } else if (c[0] == c[1] || c[1] == c[2] || c[2] == c[3] || c[3] == c[4]) {
      puts("one pair");
    } else {
      puts("null");
    }
  }

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

#include <algorithm>
#include <stdio.h>
using namespace std;
int a[5];
int main() {
  while (~scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
    sort(a, a + 5);
    if ((a[0] == a[1] || a[3] == a[4]) && a[1] == a[2] && a[2] == a[3])
      printf("four card\\n");
    else if ((a[0] == a[1] && a[2] == a[3] && a[3] == a[4]) ||
             (a[0] == a[1] && a[1] == a[2] && a[3] == a[4]))
      printf("full house\\n");
    else if ((a[0] + 1 == a[1] || (a[0] == 1 && a[1] == 10)) &&
             a[1] + 1 == a[2] && a[2] + 1 == a[3] && a[3] + 1 == a[4])
      printf("straight\\n");
    else if (((a[0] == a[1] || a[2] == a[3]) && a[1] == a[2]) ||
             (a[2] == a[3] && a[3] == a[4]))
      printf("three card\\n");
    else {
      int p = 0;
      for (int i = 1; i < 5; i++)
        if (a[i - 1] == a[i])
          p++;
      if (p == 2)
        printf("two pair\\n");
      if (p == 1)
        printf("one pair\\n");
      if (p == 0)
        printf("null\\n");
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <stdio.h>
using namespace std;
int a[5];
int main() {
  while (~scanf("%d,%d,%d,%d,%d", a[0], a[1], a[2], a[3], a[4])) {
    sort(a, a + 5);
    if ((a[0] == a[1] || a[3] == a[4]) && a[1] == a[2] && a[2] == a[3])
      printf("four card\\n");
    if ((a[0] == a[1] && a[2] == a[3] && a[3] == a[4]) ||
        (a[0] == a[1] && a[1] == a[2] && a[3] == a[4]))
      printf("full house\\n");
    if (a[0] + 1 == a[1] && a[1] + 1 == a[2] && a[2] + 1 == a[3] &&
        (a[3] + 1) % 13 == a[4] % 13)
      printf("straight\\n");
    if (((a[0] == a[1] || a[2] == a[3]) && a[1] == a[2]) ||
        (a[2] == a[3] && a[3] == a[4]))
      printf("three card\\n");
    else {
      int p = 0;
      for (int i = 1; i < 5; i++)
        if (a[i - 1] == a[i])
          p++;
      if (p == 2)
        printf("two pair\\n");
      if (p == 1)
        printf("one pair\\n");
      if (p == 0)
        printf("null\\n");
    }
  }
  return 0;
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

#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 card[5];

int c[13];

void solve() {
  memset(c, 0, sizeof(c));
  REP(i, 5) { c[card[i] - 1]++; }
  bool f1 = false, f2 = false;
  REP(i, 13) {
    if (c[i] >= 4) {
      f1 = true;
    }
  }
  if (f1) {
    cout << "four card" << endl;
    return;
  }
  REP(i, 13) {
    if (c[i] == 3) {
      f1 = true;
    } else if (c[i] == 2) {
      f2 = true;
    }
  }
  if (f1 && f2) {
    cout << "full house" << endl;
    return;
  }
  f1 = f2 = false;
  REP(i, 10) {
    bool f = true;
    REP(j, 5) {
      if (c[(i + j) % 13] != 1) {
        f = false;
      }
    }
    if (f) {
      f1 = true;
    }
  }
  if (f1) {
    cout << "straight" << endl;
    return;
  }
  REP(i, 13) {
    if (c[i] == 3) {
      f1 = true;
    }
  }
  if (f1) {
    cout << "three card" << endl;
    return;
  }
  int k = 0;
  REP(i, 13) {
    if (c[i] == 2) {
      k++;
    }
  }
  if (k == 2) {
    cout << "two pair" << endl;
  } else if (k == 1) {
    cout << "one pair" << endl;
  } else {
    cout << "null" << endl;
  }
}

int main() {
  while (scanf("%d,%d,%d,%d,%d", card, card + 1, card + 2, card + 3,
               card + 4) != EOF) {
    solve();
  }
  return 0;
}

Error: TLE

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 card[5];

int c[13];

void solve() {
  memset(c, 0, sizeof(c));
  REP(i, 5) { c[card[i] - 1]++; }
  bool f1 = false, f2 = false;
  REP(i, 13) {
    if (c[i] >= 4) {
      f1 = true;
    }
  }
  if (f1) {
    cout << "four card" << endl;
    return;
  }
  REP(i, 13) {
    if (c[i] == 3) {
      f1 = true;
    } else if (c[i] == 2) {
      f2 = true;
    }
  }
  if (f1 && f2) {
    cout << "full house" << endl;
    return;
  }
  f1 = f2 = false;
  REP(i, 10) {
    bool f = true;
    REP(j, 5) {
      if (c[(i + j) % 13] != 1) {
        f = false;
      }
    }
    if (f) {
      f1 = true;
    }
  }
  if (f1) {
    cout << "straight" << endl;
    return;
  }
  REP(i, 13) {
    if (c[i] == 3) {
      f1 = true;
    }
  }
  if (f1) {
    cout << "three card" << endl;
    return;
  }
  int k = 0;
  REP(i, 13) {
    if (c[i] == 2) {
      k++;
    }
  }
  if (k == 2) {
    cout << "two pair" << endl;
  } else if (k == 1) {
    cout << "one pair" << endl;
  } else {
    cout << "null" << endl;
  }
}

int main() {
  while (
      scanf("%d,%d,%d,%d,%d", card, card + 1, card + 2, card + 3, card + 4)) {
    solve();
  }
  return 0;
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int c;
  int cards[14], pairs[5];
  while (scanf("%d", &c) != -1) {
    memset(cards, 0, sizeof(cards));
    memset(pairs, 0, sizeof(pairs));
    cards[c]++;
    for (int i = 0; i < 4; i++) {
      scanf(",%d", &c);
      cards[c]++;
    }
    for (int i = 1; i <= 13; i++) {
      pairs[cards[i]]++;
    }
    if (pairs[4]) {
      cout << "four card" << endl;
    } else if (pairs[3] && pairs[2]) {
      cout << "full house" << endl;
    } else if (pairs[1] == 5) {
      int i = 1;
      for (; i <= 10; i++) {
        if (cards[i] && cards[i + 1] && cards[i + 2] && cards[i + 3] &&
            cards[((i + 3) % 13) + 1]) {
          cout << "straight" << endl;
          break;
        }
      }
      if (i > 10)
        cout << "null" << endl;
    } else if (pairs[3]) {
      cout << "three card" << endl;
    } else if (pairs[2] == 2) {
      cout << "two pair" << endl;
    } else if (pairs[2]) {
      cout << "one pair" << endl;
    } else {
      cout << "null" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int c;
  int cards[14], pairs[5];
  while (scanf("%d", &c), c) {
    memset(cards, 0, sizeof(cards));
    memset(pairs, 0, sizeof(pairs));
    cards[c]++;
    for (int i = 0; i < 4; i++) {
      scanf(",%d", &c);
      cards[c]++;
    }
    for (int i = 1; i <= 13; i++) {
      pairs[cards[i]]++;
    }
    if (pairs[4]) {
      cout << "four card" << endl;
    } else if (pairs[3] && pairs[2]) {
      cout << "full house" << endl;
    } else if (pairs[1] == 5) {
      int i = 1;
      for (; i <= 10; i++) {
        if (cards[i] && cards[i + 1] && cards[i + 2] && cards[i + 3] &&
            cards[((i + 3) % 13) + 1]) {
          cout << "straight" << endl;
          break;
        }
      }
      if (i > 10)
        cout << "null" << endl;
    } else if (pairs[3]) {
      cout << "three card" << endl;
    } else if (pairs[2] == 2) {
      cout << "two pair" << endl;
    } else if (pairs[2]) {
      cout << "one pair" << endl;
    } else {
      cout << "null" << endl;
    }
  }
  return 0;
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s[] = {"one pair", "two pair", "three card", "straight", "null"};

int str(int n) {
  cout << s[n] << endl;
  return 0;
}

int main() {
  int a[5], t[14], ans, m;
  while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
    ans = -1, m = 0;
    sort(a, a + 5);
    fill(t, t + 14, 0);
    for (int i = 0; i < 5; i++) {
      t[a[i]]++;
      if (m < t[a[i]])
        m = t[a[i]];
    }

    int flag = 0;
    if (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
      str(3);
      continue;
    }
    for (int i = 1; i < 5 && a[i - 1] + 1 == a[i]; i++)
      flag = i;
    if (flag == 4) {
      str(3);
      continue;
    }

    if (m == 4) {
      cout << "four card" << endl;
      continue;
    }
    if (m == 3) {
      int f = 1;
      for (int i = 1; i <= 13; i++) {
        if (t[i] == 2)
          f = 0;
      }
      if (!f) {
        cout << "full house" << endl;
        continue;
      }
      ans = 2;
    }

    for (int i = 1; i <= 13; i++) {
      if (!ans && t[i] == 2)
        ans = 1;
      if (ans != 1 && t[i] == 2)
        ans = 0;
    }
    if (ans == -1)
      ans = 4;
    str(ans);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s[] = {"one pair", "two pair", "three card", "straight", "null"};

int str(int n) {
  cout << s[n] << endl;
  return 0;
}

int main() {
  int a[5], t[14], ans, m;
  while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
    ans = -1, m = 0;
    sort(a, a + 5);
    fill(t, t + 14, 0);
    for (int i = 0; i < 5; i++) {
      t[a[i]]++;
      if (m < t[a[i]])
        m = t[a[i]];
    }

    int flag = 0;
    if (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13) {
      str(3);
      continue;
    }
    for (int i = 1; i < 5 && a[i - 1] + 1 == a[i]; i++)
      flag = i;
    if (flag == 4) {
      str(3);
      continue;
    }

    if (m == 4) {
      cout << "four card" << endl;
      continue;
    }
    if (m == 3) {
      int f = 1;
      for (int i = 1; i <= 13; i++) {
        if (t[i] == 2)
          f = 0;
      }
      if (!f) {
        cout << "full house" << endl;
        continue;
      }
      ans = 2;
    }

    for (int i = 1; i <= 13; i++) {
      if (!ans && t[i] == 2)
        ans = 1;
      if (ans != 1 && t[i] == 2)
        ans = 0;
    }
    if (ans == -1)
      ans = 4;
    str(ans);
  }
  return 0;
}
Problem p00038 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int straight(int[]);

int main() {

  int ans, h[5];

  while (scanf("%d,%d,%d,%d,%d", &h[0], &h[1], &h[2], &h[3], &h[4]) != EOF) {
    ans = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = i + 1; j < 5; j++) {
        if (h[i] == h[j])
          ans++;
      }
    }
    switch (ans) {
    case 1:
      cout << "one pair" << endl;
      break;
    case 2:
      cout << "two pair" << endl;
      break;
    case 3:
      cout << "three card" << endl;
      break;
    case 4:
      cout << "full house" << endl;
      break;
    case 6:
      cout << "four card" << endl;
      break;
    default:
      if (straight(h))
        cout << "straight" << endl;
      else
        cout << "null" << endl;
    }
  }

  return 0;
}

int straight(int h[5]) {

  sort(h, h + 5);
  for (int i = 0; i < 9; i++) {
    if (h[0] == i && h[1] == i + 1 && h[2] == i + 2 && h[3] == i + 3 &&
            h[4] == i + 4 ||
        h[0] == 1 && h[1] == 10 && h[2] == 11 && h[3] == 12 && h[4] == 13)
      return 1;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>

using namespace std;

int straight(int[]);

int main() {

  int ans, h[5];

  while (1) {
    ans = 0;
    for (int i = 0; i < 5; i++) {
      cin >> h[i];
    }
    if (cin.eof())
      break;
    for (int i = 0; i < 4; i++) {
      for (int j = i + 1; j < 5; j++) {
        if (h[i] == h[j])
          ans++;
      }
    }
    switch (ans) {
    case 1:
      cout << "one pair" << endl;
      break;
    case 2:
      cout << "two pair" << endl;
      break;
    case 3:
      cout << "three cards" << endl;
      break;
    case 4:
      cout << "full house" << endl;
      break;
    case 6:
      cout << "four cards" << endl;
      break;
    default:
      if (straight(h))
        cout << "straight" << endl;
      else
        cout << "null" << endl;
    }
  }

  return 0;
}

int straight(int h[5]) {

  sort(h, h + 5);
  for (int i = 0; i < 9; i++) {
    if (h[4] == i + 4 && h[3] == i + 3 && h[2] == i + 2 && h[1] == i + 1 &&
            h[0] == i ||
        h[0] == 1 && h[1] == 10 && h[2] == 11 && h[3] == 12 && h[4] == 13)
      return 1;
  }

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

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

  int a[5] = {0};
  string str = "null";
  while (scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4]) != EOF) {
    sort(a, a + 5);
    if (((a[0] == a[1]) && (a[2] == a[3]) && (a[2] == a[1])) ||
        ((a[1] == a[2]) && (a[2] == a[3]) && (a[3] == a[4])))
      str = "four card";
    else if (((a[0] == a[1]) && (a[1] == a[2]) && (a[3] == a[4])) ||
             ((a[0] == a[1]) && (a[2] == a[3]) && (a[3] == a[4])))
      str = "full house";
    else if (((a[0] == 1) && (a[1] == 10) && (a[2] == 11) && (a[3] == 12) &&
              (a[4] == 13)) ||
             ((a[0] + 1 == a[1]) && (a[1] + 1 == a[2]) && (a[2] + 1 == a[3]) &&
              (a[3] + 1 == a[4])))
      str = "straight";
    else if (((a[0] == a[1]) && (a[1] == a[2])) ||
             ((a[1] == a[2]) && (a[2] == a[3])) ||
             ((a[2] == a[3]) && (a[3] == a[4])))
      str = "three card";
    else if (((a[0] == a[1]) && ((a[2] == a[3]) || (a[3] == a[4]))) ||
             ((a[1] == a[2]) && (a[3] == a[4])))
      str = "two pair";
    else if ((a[0] == a[1]) || (a[1] == a[2]) || (a[2] == a[3]) ||
             (a[3] == a[4]))
      str = "one pair";

    cout << str << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

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

  int a[5] = {0};
  string str = "null";
  while (scanf("%d,%d,%d,%d,%d", a[0], a[1], a[2], a[3], a[4]) != EOF) {
    sort(a, a + 5);
    if (((a[0] == a[1]) && (a[2] == a[3]) && (a[2] == a[1])) ||
        ((a[1] == a[2]) && (a[2] == a[3]) && (a[3] == a[4])))
      str = "four card";
    else if (((a[0] == a[1]) && (a[1] == a[2]) && (a[3] == a[4])) ||
             ((a[0] == a[1]) && (a[2] == a[3]) && (a[3] == a[4])))
      str = "full house";
    else if (((a[0] == 1) && (a[1] == 10) && (a[2] == 11) && (a[3] == 12) &&
              (a[4] == 13)) ||
             ((a[0] + 1 == a[1]) && (a[1] + 1 == a[2]) && (a[2] + 1 == a[3]) &&
              (a[3] + 1 == a[4])))
      str = "straight";
    else if (((a[0] == a[1]) && (a[1] == a[2])) ||
             ((a[1] == a[2]) && (a[2] == a[3])) ||
             ((a[2] == a[3]) && (a[3] == a[4])))
      str = "three card";
    else if (((a[0] == a[1]) && ((a[2] == a[3]) || (a[3] == a[4]))) ||
             ((a[1] == a[2]) && (a[3] == a[4])))
      str = "two pair";
    else if ((a[0] == a[1]) || (a[1] == a[2]) || (a[2] == a[3]) ||
             (a[3] == a[4]))
      str = "one pair";

    cout << str << endl;
  }
  return 0;
}