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

#include <stdio.h>

void era_name_translation(int x, int y, int z) {
  int n;
  n = x * 10000 + y * 100 + z;
  if (n <= 18680907) {
    printf("pre-meiji\\n");
  } else if ((18680907 <= n) && (n <= 19120729)) {
    printf("meiji %d %d %d\\n", x - 1867, y, z);
  } else if (19120729 < n && n <= 19261224) {
    printf("taisho %d %d %d\\n", x - 1911, y, z);
  } else if (19261224 < n && n <= 19890107) {
    printf("showa %d %d %d\\n", x - 1925, y, z);
  } else if (19890107 < n) {
    printf("heisei %d %d %d\\n", x - 1988, y, z);
  }
}

int main(void) {
  int a, b, c;
  while (scanf("%d %d %d", &a, &b, &c) != EOF) {
    era_name_translation(a, b, c);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

void era_name_translation(int x, int y, int z) {
  int n;
  n = x * 10000 + y * 100 + z;
  if (n <= 18680907) {
    printf("pre-meiji\\n");
  } else if (18680907 <= n && n <= 19120729) {
    printf("meiji %d %d %d\\n", x - 1868 + 1, y, z);
  } else if (19120729 < n && n <= 19261224) {
    printf("taisho %d %d %d\\n", x - 1912 + 1, y, z);
  } else if (19261224 < n && n <= 19890107) {
    printf("showa %d %d %d\\n", x - 1926 + 1, y, z);
  } else if (19890107 < n) {
    printf("heisei %d %d %d\\n", x - 1989 + 1, y, z);
  }
}

int main(void) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  while (a != EOF) {
    era_name_translation(a, b, c);
    scanf("%d %d %d", &a, &b, &c);
  }
  return 0;
}
Problem p00083 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

void era_transform(int year, int month, int day);

int main(void) {
  int year, month, day;
  while (scanf("%d %d %d", &year, &month, &day) != EOF) {
    era_transform(year, month, day);
  }
  return 0;
}

void era_transform(int year, int month, int day) {
  int z = year * 10000 + month * 100 + day; // 時代判定用関数
  if (z <= 18680907) {
    printf("pre-meiji\\n");
  } else if (z <= 19120729) {
    printf("meiji %d %d %d\\n", year - 1867, month, day);
  } else if (z <= 19261224) {
    printf("taisho %d %d %d\\n", year - 1911, month, day);
  } else if (z <= 19890107) {
    printf("showa %d %d %d\\n", year - 1925, month, day);
  } else {
    printf("heisei %d %d %d\\n", year - 1988, month, day);
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>

void era_name(int year, int month, int day);

int main(void) {
  int year;
  int month;
  int day;
  scanf("%d %d %d", &year, &month, &day);
  while (year != EOF) {
    era_name(year, month, day);
    printf("\\n");
    scanf("%d %d %d", &year, &month, &day);
  }
  return 0;
}

void era_name(int year, int month, int day) {
  int myear = year - 1867;
  int tyear = year - 1911;
  int syear = year - 1925;
  int hyear = year - 1988;
  int date = year * 10000 + month * 100 + day;
  if (date <= 18680907) {
    printf("pre-meiji");
  } else if (date <= 19120729) {
    printf("meiji %d %d %d", myear, month, day);
  } else if (date <= 19261224) {
    printf("taisyo %d %d %d", tyear, month, day);
  } else if (date <= 19890107) {
    printf("syowa %d %d %d", syear, month, day);
  } else {
    printf("heisei %d %d %d", hyear, month, day);
  }
}
Problem p00083 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

void judge(int year, int month, int day) {
  if ((year < 1868) ||
      ((year == 1868) && ((month < 9) || ((month == 9) && (day <= 7))))) {
    printf("pre-meiji\\n");
  } else if ((year < 1912) ||
             ((year == 1912) &&
              ((month < 7) || ((month == 7) && (day <= 29))))) {
    printf("meiji %d %d %d\\n", year - 1868 + 1, month, day);
  } else if ((year < 1926) ||
             ((year == 1926) &&
              ((month < 12) || ((month == 12) && (day <= 24))))) {
    printf("taisho %d %d %d\\n", year - 1912 + 1, month, day);
  } else if ((year < 1989) || ((year == 1989) &&
                               ((month < 1) || ((month == 1) && (day <= 7))))) {
    printf("showa %d %d %d\\n", year - 1926 + 1, month, day);
  } else {
    printf("heisei %d %d %d\\n", year - 1989 + 1, month, day);
  }
}

int main(void) {
  int year, month, day;
  while (scanf("%d %d %d", &year, &month, &day) != EOF) {
    judge(year, month, day);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

void judge(int year, int month, int day) {
  if ((year < 1868) ||
      ((year == 1868) && ((month < 9) || ((month == 9) && (day <= 7))))) {
    printf("pre-meiji\\n");
  } else if ((year < 1912) ||
             ((year == 1912) &&
              ((month < 7) || ((month == 7) && (day <= 29))))) {
    printf("meiji %d %d %d\\n", year - 1868 + 1, month, day);
  } else if ((year < 1926) ||
             ((year == 1926) &&
              ((month < 12) || ((month == 12) && (day <= 24))))) {
    printf("taisho %d %d %d\\n", year - 1912 + 1, month, day);
  } else if ((year < 1989) || ((year == 1989) &&
                               ((month < 1) || ((month == 1) && (day <= 7))))) {
    printf("showa %d %d %d\\n", year - 1926 + 1, month, day);
  } else {
    printf("heisei %d %d %d\\n", year - 1989 + 1, month, day);
  }
}

int main(void) {
  int year, month, day;
  scanf("%d %d %d", &year, &month, &day);
  while (((year >= 0) || (year <= 0)) && ((month >= 0) || (month <= 0)) &&
         ((day >= 0) || (day <= 0))) {
    judge(year, month, day);
    scanf("%d %d %d", &year, &month, &day);
  }
  return 0;
}
Problem p00083 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int y, m, d;
  while (scanf("%d %d %d", &y, &m, &d) != EOF) {
    if ((y < 1868) || (y == 1868 && m < 9) || (y == 1868 && m == 9 && d < 8)) {
      printf("pre-meiji\\n");
    } else if ((y < 1912) || (y == 1912 && m < 7) ||
               (y == 1912 && m == 7 && d < 30)) {
      printf("meiji %d %d %d\\n", y + 1 - 1868, m, d);
    } else if ((y < 1926) || (y == 1926 && m < 12) ||
               (y == 1926 && m == 12 && d < 25)) {
      printf("taisho %d %d %d\\n", y + 1 - 1912, m, d);
    } else if ((y < 1989) || (y == 1989 && m < 1) ||
               (y == 1989 && m == 1 && d < 8)) {
      printf("showa %d %d %d\\n", y + 1 - 1926, m, d);
    } else {
      printf("heisei %d %d %d\\n", y + 1 - 1989, m, d);
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int y, m, d;
  while (1) {

    scanf("%d %d %d", &y, &m, &d);
    if ((y <= 1868) || (y == 1868 && m <= 9) ||
        (y == 1868 && m == 9 && d < 8)) {
      printf("pre-meiji");
    } else if ((y <= 1912) || (y == 1912 && m <= 7) ||
               (y == 1912 && m == 7 && d < 30)) {
      printf("meiji %d %d %d\\n", y + 1 - 1868, m, d);
    } else if ((y <= 1926) || (y == 1926 && m <= 12) ||
               (y == 1926 && m == 12 && d < 15)) {
      printf("taisho %d %d %d\\n", y + 1 - 1912, m, d);
    } else if ((y <= 1989) || (y == 1989 && m <= 1) ||
               (y == 1989 && m == 1 && d < 8)) {
      printf("showa %d %d %d\\n", y + 1 - 1926, m, d);
    } else {
      printf("heisei %d %d %d\\n", y + 1 - 1989, m, d);
    }
  }
  return 0;
}
Problem p00083 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  int x, y, z, sum;
  while (scanf("%d%d%d", &x, &y, &z) != EOF) {
    sum = 10000 * x + 100 * y + z;
    if (sum < 18680908) {
      printf("pre-meiji\\n");
    } else if (sum < 19120730) {
      printf("meiji %d %d %d\\n", x - 1867, y, z);
    } else if (sum < 19261225) {
      printf("taisho %d %d %d\\n", x - 1911, y, z);
    } else if (sum < 19890108) {
      printf("showa %d %d %d\\n", x - 1925, y, z);
    } else {
      printf("heisei %d %d %d\\n", x - 1988, y, z);
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  int x, y, z, sum;
  while (true) {
    scanf("%d%d%d", &x, &y, &z);
    sum = 10000 * x + 100 * y + z;
    if (sum < 18680908) {
      printf("pre-meiji\\n");
    } else if (sum < 19120730) {
      printf("meiji %d %d %d\\n", x - 1867, y, z);
    } else if (sum < 19261225) {
      printf("taisho %d %d %d\\n", x - 1911, y, z);
    } else if (sum < 19890108) {
      printf("showa %d %d %d\\n", x - 1925, y, z);
    } else {
      printf("heisei %d %d %d\\n", x - 1988, y, z);
    }
  }
  return 0;
}
Problem p00083 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int y, m, d;
  while (~scanf("%d%d%d", &y, &m, &d)) {
    if (y < 1868 || y == 1868 && m < 9 || y == 1868 && m == 9 && d < 8)
      printf("pre-meiji\\n");
    else if (y < 1912 || y == 1912 && m < 7 || y == 1912 && m == 7 && d <= 29)
      printf("meiji %d %d %d\\n", y - 1868 + 1, m, d);
    else if (y < 1926 || y == 1926 && m < 12 || y == 1926 && m == 12 && d <= 24)
      printf("taisho %d %d %d\\n", y - 1912 + 1, m, d);
    else if (y < 1989 || y == 1989 && m == 1 && d <= 7)
      printf("showa %d %d %d\\n", y - 1926 + 1, m, d);
    else
      printf("heisei %d %d %d\\n", y - 1989 + 1, m, d);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int y, m, d;
  while (1) {
    scanf("%d%d%d", &y, &m, &d);
    if (y < 1868 || y == 1868 && m < 9 || y == 1868 && m == 9 && d < 8)
      printf("pre-meiji\\n");
    else if (y < 1912 || y == 1912 && m < 7 || y == 1912 && m == 7 && d <= 29)
      printf("meiji %d %d %d\\n", y - 1868 + 1, m, d);
    else if (y < 1926 || y == 1926 && m < 12 || y == 1926 && m == 12 && d <= 24)
      printf("taisho %d %d %d\\n", y - 1912 + 1, m, d);
    else if (y < 1989 || y == 1926 && m == 1 && d <= 7)
      printf("showa %d %d %d\\n", y - 1926 + 1, m, d);
    else
      printf("heisei %d %d %d\\n", y - 1989 + 1, m, d);
  }
  return 0;
}
Problem p00083 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

void Print(int i, int a) {
  switch (i) {
  case 0:
    printf("pre-meiji\\n");
    break;
  case 1:
    printf("meiji %d %d %d\\n", a / 10000 - 1867, (a % 10000) / 100, (a % 100));
    break;
  case 2:
    printf("taisho %d %d %d\\n", a / 10000 - 1911, (a % 10000) / 100, (a % 100));
    break;
  case 3:
    printf("showa %d %d %d\\n", a / 10000 - 1925, (a % 10000) / 100, (a % 100));
    break;
  case 4:
    printf("heisei %d %d %d\\n", a / 10000 - 1988, (a % 10000) / 100, (a % 100));
    break;
  }
}

int main(void) {
  int iy, im, id;
  int kami;

  int meiji = 1868 * 10000 + 9 * 100 + 8;
  int taisho = 1912 * 10000 + 7 * 100 + 30;
  int showa = 1926 * 10000 + 12 * 100 + 25;
  int heisei = 1989 * 10000 + 1 * 100 + 8;

  while (1) {
    if (scanf("%d %d %d", &iy, &im, &id) == EOF) {
      break;
    }

    kami = iy * 10000 + im * 100 + id;

    if (kami < meiji) {
      Print(0, kami);
    } else if (kami >= meiji && kami < taisho) {
      Print(1, kami);
    } else if (kami >= taisho && kami < showa) {
      Print(2, kami);
    } else if (kami >= showa && kami < heisei) {
      Print(3, kami);
    } else {
      Print(4, kami);
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

void Print(int i, int a) {
  switch (i) {
  case 0:
    printf("pre-meiji\\n");
    break;
  case 1:
    printf("meiji %d %d %d\\n", a / 10000 - 1868, (a % 10000) / 100, (a % 100));
    break;
  case 2:
    printf("taisho %d %d %d\\n", a / 10000 - 1912, (a % 10000) / 100, (a % 100));
    break;
  case 3:
    printf("showa %d %d %d\\n", a / 10000 - 1926, (a % 10000) / 100, (a % 100));
    break;
  case 4:
    printf("heisei %d %d %d\\n", a / 10000 - 1989, (a % 10000) / 100, (a % 100));
    break;
  }
}

int main(void) {
  int iy, im, id;
  int kami;

  int meiji = 1868 * 10000 + 9 * 100 + 8;
  int taisho = 1912 * 10000 + 7 * 100 + 30;
  int showa = 1926 * 10000 + 12 * 100 + 25;
  int heisei = 1989 * 10000 + 1 * 100 + 8;

  while (1) {
    scanf("%d %d %d", &iy, &im, &id);

    kami = iy * 10000 + im * 100 + id;

    if (kami < meiji) {
      Print(0, kami);
    } else if (kami >= meiji && kami < taisho) {
      Print(1, kami);
    } else if (kami >= taisho && kami < showa) {
      Print(2, kami);
    } else if (kami >= showa && kami < heisei) {
      Print(3, kami);
    } else {
      Print(4, kami);
    }
  }

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

#include <stdio.h>

int erajudge(int year, int month, int day) {
  if (year <= 1867) {
    printf("pre-meiji\\n");
  } else if (year == 1868 && month <= 8) {
    printf("pre-meiji\\n");
  } else if (year == 1868 && month == 9 && day <= 7) {
    printf("pre-meiji\\n");
  } else {
    if (year <= 1911) {
      printf("meiji %d %d %d\\n", year - 1867, month, day);
    } else if (year == 1912 && month <= 6) {
      printf("meiji %d %d %d\\n", year - 1867, month, day);
    } else if (year == 1912 && month == 7 && day <= 29) {
      printf("meiji %d %d %d\\n", year - 1867, month, day);
    } else {
      if (year <= 1925) {
        printf("taisho %d %d %d\\n", year - 1911, month, day);
      } else if (year == 1926 && month <= 11) {
        printf("taisho %d %d %d\\n", year - 1911, month, day);
      } else if (year == 1926 && month == 12 && day <= 24) {
        printf("taisho %d %d %d\\n", year - 1911, month, day);
      } else {
        if (year <= 1988) {
          printf("showa %d %d %d\\n", year - 1925, month, day);
        } else if (year == 1989 && month == 1 && day <= 7) {
          printf("showa %d %d %d\\n", year - 1925, month, day);
        } else {
          printf("heisei %d %d %d\\n", year - 1988, month, day);
        }
      }
    }
  }
}

int main(void) {
  int year, month, day;
  while (scanf("%d %d %d", &year, &month, &day) != EOF) {
    erajudge(year, month, day);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int erajudge(int year, int month, int day) {
  if (year <= 1867) {
    printf("pre-meiji\\n");
  } else if (year == 1868 && month <= 8) {
    printf("pre-meiji\\n");
  } else if (year == 1868 && month == 9 && day <= 7) {
    printf("pre-meiji\\n");
  } else {
    if (year <= 1911) {
      printf("meiji %d %d %d\\n", year - 1867, month, day);
    } else if (year == 1912 && month < 6) {
      printf("meiji %d %d %d\\n", year - 1867, month, day);
    } else if (year == 1912 && month == 7 && day >= 29) {
      printf("meiji %d %d %d\\n", year - 1867, month, day);
    } else {
      if (year <= 1925) {
        printf("taisho %d %d %d\\n", year - 1911, month, day);
      } else if (year == 1926 && month >= 11) {
        printf("taisho %d %d %d\\n", year - 1911, month, day);
      } else if (year <= 1925 && month == 12, day >= 24) {
        printf("taisho %d %d %d\\n", year - 1911, month, day);
      } else {
        if (year <= 1988) {
          printf("showa %d %d %d\\n", year - 1925, month, day);
        } else if (year == 1989, month == 1, day <= 7) {
          printf("showa %d %d %d\\n", year - 1925, month, day);
        } else {
          printf("heisei %d %d %d\\n", year - 1988, month, day);
        }
      }
    }
  }
}

int main(void) {
  int year, month, day;
  while (scanf("%d %d %d", &year, &month, &day) != 0) {
    erajudge(year, month, day);
  }
  return 0;
}
Problem p00084 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main() {
  string s;
  int i;
  getline(cin, s);
  for (i = 0; i < s.size(); i++)
    if (s[i] == ',' || s[i] == '.')
      s[i] = ' ';
  stringstream ss;
  ss << s;
  int f = 0, n;
  while (ss >> s) {
    n = s.size();
    if (n >= 3 && n <= 6) {
      cout << ((f == 1) ? " " : "") << s;
      f = 1;
    }
  }
  cout << endl;
}

Error: 0

Fixed submission:

#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  char *q, *p, *c = new char[sizeof(s) + 1];
  int f = 0, n;
  strncpy(c, s.c_str(), s.size() + 1);
  p = strtok(c, " .,");
  while (p != NULL) {
    n = string(p).size();
    if (3 <= n && n <= 6) {
      cout << ((f == 1) ? " " : "\\0") << p;
      f = 1;
    }
    p = strtok(NULL, " .,");
  }
  cout << endl;
}
Problem p00084 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
int main() {
  std::string s;
  char k[6 + 1];
  int l = 0, i = 0, j = 0;
  getline(std::cin, s);

  while (1) {
    if (s[i] == '.' || s[i] == ',' || s[i] == ' ' || s[i] == '\\0') {
      if (l >= 3 && l <= 6) {
        k[l] = '\\0';
        std::cout << (j ? " " : "") << k;
        ++j;
      }
      l = 0;
      ++i;

      if (s[i] == '\\0')
        break;
    } else {
      k[l] = s[i];
      ++l;

      ++i;
    }
  }
  std::cout << std::endl;
}

Error: -11

Fixed submission:

#include <iostream>
int main() {
  char s[1024 + 1];
  std::cin >> s;
  char k[6 + 1];
  int l = 0;

  while (1) {
    if (*s == '.' || *s == ',' || *s == ' ' || *s == '\\0') {
      if (l >= 3 && l <= 6) {
        k[l] = '\\0';
        std::cout << k << " ";
      }
      l = 0;

      if (*s == '\\0')
        break;
    }
    k[l] = *s;
    ++l;
  }
}
Problem p00084 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int x, now;
  string s;
  vector<string> box;
  getline(cin, s);
  now = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != ' ' && s[i] != '.' && s[i] != ',') {
      now++;
    } else {
      if (now >= 3 && now <= 6)
        box.push_back(s.substr(i - now, now));
      now = 0;
    }
  }
  for (int i = 0; i < box.size(); i++) {
    cout << box[i];
    cout << (box.size() - 1 != i ? ' ' : '\\n');
  }
  return 0;
}

Error: WA

Fixed submission:

#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char s[1050], box[10];
  fgets(s, 1050, stdin);
  int now = 0, k = 0;
  do {
    if (s[now] == ',' || s[now] == ' ' || s[now] == '.') {
      if (k >= 3 && 6 >= k) {
        for (int i = 0; i < k; i++)
          cout << box[i];
        cout << ' ';
      }
      k = 0;
    } else {
      box[k++] = s[now];
    }
  } while (s[now++] != '\\n');
  cout << endl;
  return 0;
}
Problem p00084 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  char data;
  string word[10000];
  int n = 0, i = 0;
  int flg = 0;
  while (scanf("%c", &data) != EOF) {
    if (data == 10)
      break;
    if (isalpha(data))
      word[i] += data;
    if (data == 39)
      word[i] += data;
    if (data == ' ') {
      i++;
    }
  }
  flg = 0;
  for (int j = 0; j <= i; j++) {
    if (word[j].length() >= 3 && word[j].length() <= 6) {
      if (flg == 1)
        cout << " ";
      cout << word[j];
      flg = 1;
    }
  }
  cout << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  char data;
  string word[100];
  int n = 0, i = 0;
  int flg = 0;
  while (scanf("%c", &data) != EOF) {
    if (isalpha(data))
      word[i] += data;
    if (data == 39 || data == ',' || flg == 1) {
      flg = 1;
      word[i][0] = ')';
    }
    if (data == ' ') {
      flg = 0;
      if (word[i][0] != ')')
        i++;
      word[i] = "";
    }
  }
  flg = 0;
  for (int j = 0; j <= i; j++) {
    if (word[j + 1].length() == 0)
      flg = 1;
    if (word[j].length() >= 3 && word[j].length() <= 6) {
      cout << word[j];
      if (flg == 0)
        cout << " ";
    }
  }
  return 0;
}
Problem p00084 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string input;
  vector<string> ans;
  getline(cin, input);
  input += " ";
  while (input.find(",") != string::npos)
    input.replace(input.find(","), 1, " ");
  while (input.find(".") != string::npos)
    input.replace(input.find("."), 1, " ");
  while (input.find_first_of(" ") != string::npos) {

    string s = input.substr(0, input.find_first_of(" "));
    if (3 <= s.size() && s.size() <= 6)
      ans.push_back(s);

    input = input.substr(input.find_first_of(" ") + 1);
  }
  for (int i = 0; i < ans.size(); i++) {
    if (i == 0)
      cout << ans[i];
    else
      cout << " " << ans[i];
  }
  cout << endl;
}

Error: 0

Fixed submission:

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

int main() {
  string input;
  string del = ",.";
  vector<string> ans;
  getline(cin, input);
  input += " ";
  while (input.find_first_of(" ") != string::npos) {
    string s = input.substr(0, input.find_first_of(" "));
    if (del.find(input.substr(s.size() - 1, 1)) != string::npos)
      s = s.substr(0, s.size() - 1);
    if (3 <= s.size() && s.size() <= 6)
      ans.push_back(s);

    input = input.substr(input.find_first_of(" ") + 1);
  }
  for (int i = 0; i < ans.size(); i++) {
    if (i == 0)
      cout << ans[i];
    else
      cout << " " << ans[i];
  }
  cout << endl;
}
Problem p00084 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
/*
vector<string> split(const string& input, char delimiter)
{
  istringstream stream(input);

  string field;
  vector<string> result;
  while (getline(stream, field, delimiter)) {
    result.push_back(field);
  }
  return result;
}
*/
int main() {
  string str, word;
  int i = 0;

  getline(cin, str);
  while (str[i] != '\\0') {
    if (str[i] == '.' || str[i] == ',')
      str[i] = ' ';
    i++;
  }

  /*
    for (const string& s : split(str, ' ')) {
      int size = s.size();
      if(size > 2 && size < 7) {
        cout << s << ' ';
      }
    }
   */

  stringstream ss(str);

  i = 0;
  while (ss >> word) {
    int len = word.length();
    if (len >= 3 && len <= 6) {
      if (i == 0) {
        cout << word;
        i++;
      } else
        cout << ' ' << word;
    }
  }

  cout << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

vector<string> split(const string &input, char delimiter) {
  istringstream stream(input);

  string field;
  vector<string> result;
  while (getline(stream, field, delimiter)) {
    result.push_back(field);
  }
  return result;
}

int main() {
  string str;
  int i = 0;

  getline(cin, str);
  while (str[i] != '\\0') {
    if (str[i] == '.' || str[i] == ',')
      str[i] = ' ';
    i++;
  }

  for (const string &s : split(str, ' ')) {
    int size = s.size();
    if (size > 2 && size < 7) {
      cout << s << ' ';
    }
  }
  cout << endl;
  return 0;
}